/* =====================================================================
   Niyaal web styles: navy and electric blue design system (plain CSS, no framework)
   Sections: tokens, backdrop, base, buttons, forms, auth, shell, badges,
   tables, tabs, upload, chat, sources, dialogs, toasts, ingestion, small screens.
   Fonts: Instrument Sans and Wix Madefor Display are used when installed on the device.
   The page policy only allows files from this site, so there is no font download.
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Palette: Deep Navy + Electric Blue + White */
  --bg: #F1F6FF;            /* main background (soft blue) */
  --surface: #FFFFFF;       /* cards and panels */
  --surface-2: #F7FAFF;     /* subtle inner panels, table heads */
  --hover: #EEF4FF;         /* hover fill on white */
  --text: #142D50;          /* primary text (dark navy) */
  --text-2: #2E4A70;
  --muted: #647A99;         /* secondary text (slate blue) */
  --primary: #087EFF;       /* primary buttons (electric blue) */
  --primary-2: #3D9BFF;
  --primary-dark: #0563D6;  /* button hover, accent text */
  --primary-soft: #E8F2FF;
  --border: #DCE7F5;        /* borders and dividers (light blue) */
  --border-strong: #C5D6EC;
  --success: #15803d;
  --error: #c0392b;
  --warning: #b45309;
  --info: #0563D6;

  /* surfaces: solid white with soft shadows (names kept from the earlier glass system) */
  --glass: var(--surface);
  --glass-strong: var(--surface);
  --glass-soft: #E8F0FC;
  --glass-line: var(--border);
  --glass-blur: none;
  --glass-shadow: 0 1px 2px rgba(20, 45, 80, .04), 0 6px 18px -8px rgba(20, 45, 80, .10);
  --glass-shadow-lg: 0 2px 6px rgba(20, 45, 80, .05), 0 24px 60px -20px rgba(20, 45, 80, .25);

  /* sidebar (deep navy) */
  --side: #0B1F44;
  --side-hover: #16305E;
  --side-panel: #122A55;
  --side-text: #FFFFFF;
  --side-muted: #9FB2CF;
  --side-line: rgba(255, 255, 255, .08);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --gap: 16px;

  /* access classifications: exact colour for dot and border, darker shade of the same hue for text */
  --lvl-general-dot: #16A36A;
  --lvl-general: #0E7A4E;
  --lvl-general-bg: #E7F6EF;
  --lvl-team-dot: #1685E8;
  --lvl-team: #0F64B3;
  --lvl-team-bg: #E7F2FD;
  --lvl-confidential-dot: #E99A18;
  --lvl-confidential: #9A5F05;
  --lvl-confidential-bg: #FDF3E1;
  --lvl-executive-dot: #E5485D;
  --lvl-executive: #B8283C;
  --lvl-executive-bg: #FDECEE;

  --font-body: "Instrument Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Wix Madefor Display", "Instrument Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-code: "Red Hat Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, 0, 0, 1);
}

/* ---------- Backdrop: the colour field the glass sits on ---------- */
html { background: var(--bg); }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1; background: var(--bg); }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0; position: relative; min-height: 100vh;
  font-family: var(--font-body); font-size: 14px; line-height: 1.5; color: var(--text);
  background: transparent; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body.center { display: grid; place-items: center; padding: 1.5rem; }
h1, h2, h3 { font-family: var(--font-head); margin: 0 0 .5rem; letter-spacing: -.015em; color: var(--text); }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .9rem; font-weight: 600; margin-top: 1.1rem; }
a { color: var(--primary-dark); text-underline-offset: 2px; }
.muted { color: var(--muted); font-size: .8rem; }
.center-text { text-align: center; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; }
::selection { background: rgba(8, 126, 255, .22); }
* { scrollbar-width: thin; scrollbar-color: rgba(20, 45, 80, .2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(20, 45, 80, .18); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- Glass surface (cards and panels) ---------- */
.card, .glass, .topbar, .bar, .chat, .notice, dialog {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line);
  box-shadow: var(--glass-shadow);
}
.card { border-radius: var(--radius-lg); padding: 1.35rem 1.4rem; position: relative; }
.card > h2:first-child, .card > .row:first-child { margin-bottom: .35rem; }
.card h3 { color: var(--text-2); }
.login { width: min(430px, 94vw); }

/* ---------- Layout helpers ---------- */
.spacer { flex: 1; }
.stack { display: grid; gap: var(--gap); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; flex-wrap: wrap; }
.row h2 { margin: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-row .end { align-self: end; }
.form-row .end button { width: auto; }
.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: var(--gap); align-items: start; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; }
.filters select { width: auto; min-width: 11rem; }
.hint { margin: .3rem 0 0; font-size: .8rem; color: var(--muted); }
.fineprint { text-align: center; font-size: .72rem; color: var(--muted); margin: .5rem 0 0; }
.warn { color: var(--warning); font-size: .88rem; background: rgba(254, 243, 199, .55); border: 1px solid rgba(217, 119, 6, .2); border-radius: var(--radius-sm); padding: .5rem .7rem; }
.error-text { color: var(--error); font-size: .78rem; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 0; }

/* ---------- Buttons ---------- */
button {
  font: inherit; font-weight: 600; font-size: .86rem; cursor: pointer; border: 0; border-radius: 10px;
  padding: .6rem 1.05rem; color: #fff;
  background: var(--primary);
  box-shadow: 0 1px 2px rgba(8, 126, 255, .18), 0 4px 12px -4px rgba(8, 126, 255, .45);
  transition: transform .12s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
button:hover { background: var(--primary-dark); filter: none; box-shadow: 0 2px 4px rgba(5, 99, 214, .2), 0 8px 18px -6px rgba(5, 99, 214, .5); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; filter: none; }
button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button.secondary, button.ghost {
  background: var(--glass-strong); color: var(--text-2); font-weight: 550;
  border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(20, 45, 80, .05);
}
button.secondary:hover, button.ghost:hover { background: var(--hover); color: var(--text); border-color: var(--border-strong); filter: none; box-shadow: 0 1px 2px rgba(20, 45, 80, .05); }
button.block { width: 100%; display: flex; align-items: center; justify-content: center; gap: .5rem; }
button.icon-only { display: grid; place-items: center; padding: .55rem; }
button.danger { color: var(--error); }
button.danger:hover { background: rgba(254, 226, 226, .85); color: #b91c1c; }
button.danger-solid { background: #dc2626; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 6px 16px -6px rgba(220, 38, 38, .55); }
button.link { background: none; box-shadow: none; color: var(--primary-dark); padding: 0; text-decoration: underline; font-weight: 550; }
button.link:hover { background: none; box-shadow: none; filter: none; }
button.small { padding: .3rem .7rem; font-size: .78rem; border-radius: 8px; }
form button[type="submit"] { width: 100%; margin-top: 1.3rem; padding: .72rem 1rem; }

.icon-btn {
  display: inline-grid; place-items: center; padding: .38rem; border-radius: 9px; font-weight: 400;
  background: transparent; color: var(--muted); box-shadow: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); filter: none; }
.icon-btn.small { padding: .3rem; opacity: 0; }
.icon-btn.small svg { width: 15px; height: 15px; }
.icon-btn.small:hover { color: var(--error); background: rgba(254, 226, 226, .8); box-shadow: none; }
.thread:hover .icon-btn.small, .icon-btn.small:focus-visible { opacity: 1; }
.icon-btn.small-icon svg { width: 17px; height: 17px; }

/* ---------- Forms ---------- */
label { display: block; margin: .9rem 0 .3rem; font-weight: 550; font-size: .8rem; color: var(--text-2); }
input, textarea, select {
  width: 100%; padding: .62rem .8rem; font: inherit; font-size: .88rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: inset 0 1px 2px rgba(20, 45, 80, .04);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: #8A9BB5; }
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus {
  outline: none; background: var(--surface); border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(8, 126, 255, .14);
}
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); box-shadow: none; }
textarea { resize: vertical; }
label.check { display: flex; align-items: center; gap: .55rem; font-weight: 450; font-size: .85rem; margin-top: .9rem; color: var(--text-2); }
label.check input { width: 16px; }

/* ---------- Auth pages (login, change password) ---------- */
body.auth { overflow: hidden; }
.glass {
  position: relative; z-index: 1; padding: 2.2rem 2.1rem; border-radius: 22px;
  background: var(--surface); box-shadow: var(--glass-shadow-lg);
}
.glass > * { position: relative; }
.auth-brand { text-align: center; margin-bottom: .8rem; }
.auth-brand h1 { font-size: 1.65rem; font-weight: 700; margin: .7rem 0 .15rem; }
.auth-brand p { margin: 0; font-size: .85rem; }
.auth-mark, .brand-mark, .welcome-mark {
  display: inline-grid; place-items: center; color: #fff; font-family: var(--font-head); font-weight: 700;
  background: var(--primary);
  box-shadow: 0 6px 16px -6px rgba(8, 126, 255, .6);
}
.auth-mark { width: 52px; height: 52px; border-radius: 14px; font-size: 1.55rem; text-decoration: none; }
.field-icon { position: relative; }
.field-icon input { padding-right: 2.7rem; }
.field-icon .icon-btn { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); }
.sso { margin-top: 1.3rem; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .74rem; font-weight: 550; margin-bottom: .9rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.sso-buttons { display: grid; gap: .6rem; }
a.sso-btn, a.button {
  display: block; text-decoration: none; text-align: center; font-weight: 550; font-size: .86rem; color: var(--text);
  padding: .68rem 1rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 1px 2px rgba(20, 45, 80, .05);
  transition: background .15s var(--ease), transform .12s var(--ease);
}
a.sso-btn:hover, a.button:hover { background: var(--hover); border-color: var(--border-strong); }

/* =====================================================================
   Application shell: floating deep-navy sidebar, white top bar
   ===================================================================== */
/* The shell is exactly one screen tall. The page itself never scrolls: the content area under the
   top bar does. No sticky positioning, so the top bar and sidebar cannot shift or be clipped. */
html:has(body.shell), body.shell { height: 100%; overflow: hidden; }
.app {
  display: grid; grid-template-columns: 256px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
  gap: var(--gap); padding: var(--gap); height: 100vh; height: 100dvh;
}

.sidebar {
  position: relative; height: 100%; min-height: 0; z-index: 30;
  display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
  color: var(--side-text); border-radius: var(--radius-lg);
  background: var(--side);
  border: 1px solid rgba(255, 255, 255, .06);
  box-shadow: 0 24px 50px -24px rgba(11, 31, 68, .55);
}
.brand { display: flex; align-items: center; gap: .75rem; height: 68px; padding: 0 1.1rem; border-bottom: 1px solid var(--side-line); color: #fff; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; font-size: 1.1rem; flex: none; }
.brand-text { display: grid; line-height: 1.15; flex: 1; min-width: 0; }
.brand-name { font: 700 1.08rem var(--font-head); color: #fff; letter-spacing: -.01em; }
.brand-sub { font-size: .6rem; text-transform: uppercase; letter-spacing: .12em; color: var(--side-muted); font-weight: 650; }
.sidebar-close { display: none; color: var(--side-muted); }
.sidebar-close:hover { background: var(--side-hover); color: #fff; box-shadow: none; }

.nav { display: grid; gap: .25rem; padding: .9rem .7rem; }
.nav::before {
  content: "Workspace"; padding: 0 .65rem .45rem; font-size: .62rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--side-muted);
}
.nav-item {
  position: relative; display: flex; align-items: center; gap: .75rem; padding: .62rem .75rem; border-radius: 10px;
  color: var(--side-text); text-decoration: none; font-weight: 550; font-size: .85rem;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item.active {
  color: #fff; font-weight: 650;
  background: var(--primary);
  box-shadow: 0 6px 16px -8px rgba(8, 126, 255, .8);
}
.nav-item.active:hover { background: var(--primary); }
.nav-item.active svg { color: #fff; }

.sidebar-foot { padding: .75rem; border-top: 1px solid var(--side-line); }
.who { display: flex; align-items: center; gap: .65rem; padding: .5rem; border-radius: 12px; background: var(--side-panel); border: 1px solid var(--side-line); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 650; font-size: .76rem;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .9);
}
.who-text { display: grid; line-height: 1.25; min-width: 0; flex: 1; }
.who-text strong { color: #fff; font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text span { font-size: .7rem; text-transform: capitalize; color: var(--side-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { color: var(--side-muted); }
.logout:hover { background: var(--side-hover); color: #fff; box-shadow: none; }

.main { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; min-height: 0; height: 100%; }
.topbar {
  flex: none; position: relative; z-index: 10; display: flex; align-items: center; gap: 1rem;
  min-height: 68px; padding: .7rem 1.3rem; border-radius: var(--radius-lg);
  background: var(--surface);
}
.page-heading { min-width: 0; }
.page-title { font-size: 1.28rem; font-weight: 700; margin: 0; line-height: 1.2; }
.page-sub { margin: .15rem 0 0; font-size: .78rem; color: var(--muted); }
.menu-btn { display: none; }
/* Scroll area. The side padding (offset by a negative margin) keeps card shadows from being cut off. */
.content {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  margin: 0 calc(-1 * var(--gap)); padding: 2px var(--gap) calc(var(--gap) * 2);
}
/* One spacing rule for page blocks: banner, tabs, panels, cards. */
.content > * + *, .panel > * + * { margin-top: var(--gap); }
.content > .notice, .content > .tabs { margin-bottom: 0; }
.scrim { display: none; }

/* ---------- Platform page header ---------- */
.bar { display: flex; align-items: center; gap: .75rem; margin: var(--gap); padding: .8rem 1.2rem; border-radius: var(--radius-lg); position: sticky; top: var(--gap); z-index: 5; }
.bar .brand-mark { width: 32px; height: 32px; font-size: 1rem; }
.page { max-width: 1180px; margin: 0 auto 2rem; padding: 0 var(--gap); display: grid; gap: var(--gap); }

/* ---------- Classification and clearance badges ---------- */
.lvl {
  display: inline-flex; align-items: center; gap: .35rem; padding: .14rem .6rem; border-radius: 999px;
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
  border: 1px solid currentColor; border-color: color-mix(in srgb, var(--lvl-dot, currentColor) 35%, transparent);
}
.lvl::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--lvl-dot, currentColor); }
.lvl.pill { padding: .34rem .85rem; font-size: .68rem; box-shadow: 0 4px 12px -6px var(--lvl-dot, currentColor); }
.lvl-general { --lvl-dot: var(--lvl-general-dot); color: var(--lvl-general); background: var(--lvl-general-bg); }
.lvl-team { --lvl-dot: var(--lvl-team-dot); color: var(--lvl-team); background: var(--lvl-team-bg); }
.lvl-confidential { --lvl-dot: var(--lvl-confidential-dot); color: var(--lvl-confidential); background: var(--lvl-confidential-bg); }
.lvl-executive { --lvl-dot: var(--lvl-executive-dot); color: var(--lvl-executive); background: var(--lvl-executive-bg); }

/* ---------- Notice banner ---------- */
.notice {
  display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; margin-bottom: var(--gap); border-radius: var(--radius);
  background: var(--primary-soft); border-color: #CFE2FB; color: var(--primary-dark); font-size: .85rem;
}
.notice svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin-top: .6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
/* A table that ends a card runs edge to edge. */
.card > .table-wrap { margin: .8rem -1.4rem 0; border-width: 1px 0 0; border-radius: 0; background: transparent; }
.card > .table-wrap:last-child, .card > .table-wrap:has(+ [hidden]:last-child) { margin-bottom: -1.35rem; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card > table { margin-top: .6rem; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .84rem; }
th, td { text-align: left; padding: .72rem 1rem; border-bottom: 1px solid #EDF2FA; vertical-align: middle; }
th {
  color: var(--muted); font-weight: 650; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
.card > .table-wrap th:first-child, .card > .table-wrap td:first-child { padding-left: 1.4rem; }
.card > .table-wrap th:last-child, .card > .table-wrap td:last-child { padding-right: 1.4rem; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.doc-title { display: grid; gap: .12rem; }
.doc-title strong { font-weight: 600; }
.doc-title .muted { font-size: .72rem; }

/* ---------- Chips, badges, status ---------- */
.chips { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem; }
.chips li {
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  padding: .25rem .7rem; border-radius: 999px; font-size: .76rem; font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}
.badge { display: inline-flex; align-items: center; padding: .14rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 600; background: rgba(232, 242, 255, .8); color: var(--primary-dark); }
.badge.off { background: rgba(254, 226, 226, .85); color: #b91c1c; }
.badge.ok { background: rgba(220, 252, 231, .85); color: #15803d; }
.badge.docs { background: rgba(254, 243, 199, .9); color: #b45309; }
.status {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .74rem; font-weight: 600;
  padding: .18rem .65rem; border-radius: 999px; background: #EEF2F8; color: var(--text-2);
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.ready { background: rgba(236, 253, 245, .9); color: #047857; box-shadow: inset 0 0 0 1px rgba(16, 185, 129, .25); }
.status.failed { background: rgba(254, 242, 242, .9); color: #b91c1c; box-shadow: inset 0 0 0 1px rgba(239, 68, 68, .25); }
.status.processing { background: rgba(241, 246, 255, .9); color: var(--primary-dark); box-shadow: inset 0 0 0 1px rgba(8, 126, 255, .25); }
.status.processing::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

/* ---------- Tabs (segmented glass control) ---------- */
.tabs {
  display: flex; width: fit-content; gap: .25rem; padding: .3rem; margin-bottom: var(--gap); max-width: 100%; overflow-x: auto;
  background: var(--glass-soft); border: 1px solid var(--glass-line); border-radius: 14px;
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 2px rgba(20, 45, 80, .05);
}
.tab {
  display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; padding: .5rem .95rem; border-radius: 10px;
  background: transparent; color: var(--muted); font-weight: 550; box-shadow: none;
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { background: rgba(255, 255, 255, .6); color: var(--text); box-shadow: none; filter: none; }
.tab.active {
  background: var(--surface); color: var(--primary-dark); font-weight: 650;
  box-shadow: 0 1px 2px rgba(20, 45, 80, .08), 0 4px 12px -4px rgba(20, 45, 80, .12);
}

/* ---------- Upload (drag and drop) ---------- */
.dropzone {
  margin-top: 1rem; border: 1.5px dashed rgba(8, 126, 255, .35); border-radius: 16px; padding: 2.2rem 1rem; text-align: center;
  color: var(--muted); cursor: pointer; background: var(--surface-2);
  transition: border-color .15s var(--ease), background .15s var(--ease), transform .15s var(--ease);
}
.dropzone svg {
  width: 52px; height: 52px; padding: 12px; border-radius: 14px; fill: none; stroke: var(--primary); stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; background: var(--surface); box-shadow: var(--glass-shadow);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); outline: none; }
.dropzone.over { transform: scale(1.01); }
.dropzone p { margin: .4rem 0; }
.dropzone strong { color: var(--text); }
.queue { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; }
.queue-item { border: 1px solid var(--border); border-radius: 12px; padding: .65rem .85rem; display: grid; gap: .35rem; background: var(--surface); }
.queue-item.done { border-color: rgba(16, 185, 129, .35); background: rgba(236, 253, 245, .75); }
.queue-item.failed { border-color: rgba(239, 68, 68, .35); background: rgba(254, 242, 242, .75); }
.queue-name { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.queue-state { font-size: .78rem; color: var(--muted); }
.progress { height: 5px; background: #E8F0FC; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); transition: width .15s; }
/* Live progress of an upload or ingestion run */
.progress-lg { height: 10px; margin: .35rem 0 .25rem; }
.progress-lg .progress-fill { transition: width .4s ease; }
.progress-line { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-top: .5rem; font-size: .88rem; }
.progress-percent { font-variant-numeric: tabular-nums; }
.progress-detail { margin: 0; }

/* =====================================================================
   Chat
   ===================================================================== */
/* The chat page is exactly one screen tall; only the thread list and the message list scroll. */
/* Only the thread list and the message list scroll on the chat page. */
.content:has(> .chat) { overflow: hidden; display: flex; flex-direction: column; margin: 0; padding: 0; }
.content > .chat { max-width: none; width: 100%; margin: 0; }
.chat {
  display: grid; grid-template-columns: 290px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
  flex: 1; min-height: 0; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface);
}

.threads {
  min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: .7rem; padding: 1rem .8rem;
  border-right: 1px solid var(--border); background: var(--surface-2);
}
.search-box { position: relative; }
.search-box svg { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search-box input { padding: .5rem .7rem .5rem 2.1rem; font-size: .82rem; }
.threads-label { padding: .2rem .5rem 0; font-size: .62rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.thread-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.thread { display: flex; align-items: center; border-radius: 10px; border: 1px solid transparent; padding-right: .25rem; transition: background .12s var(--ease); }
.thread:hover { background: var(--hover); }
.thread.active { background: var(--surface); border-color: var(--border); box-shadow: 0 1px 2px rgba(20, 45, 80, .05), 0 4px 12px -6px rgba(8, 126, 255, .3); }
.thread-open { flex: 1; min-width: 0; display: grid; gap: .08rem; text-align: left; padding: .55rem .65rem; background: transparent; color: var(--text); font-weight: 400; box-shadow: none; }
.thread-open:hover { background: transparent; box-shadow: none; filter: none; }
.thread-title { font-size: .82rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread.active .thread-title { font-weight: 650; }
.thread-time { font-size: .68rem; color: var(--muted); }
.thread.active .thread-time { color: var(--primary-dark); }

.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 1.75rem 1.5rem; display: flex; flex-direction: column; gap: 1.3rem; }
.messages > * { width: 100%; max-width: 1120px; margin-left: auto; margin-right: auto; }
.welcome { margin: auto; max-width: 620px; text-align: center; padding: 1rem; }
.welcome-mark { width: 56px; height: 56px; border-radius: 16px; font-size: 1.6rem; }
.welcome h2 { font-size: 1.65rem; font-weight: 700; margin-top: .9rem; }
.welcome p { color: var(--muted); }
.legend {
  text-align: left; margin: 1.2rem 0; padding: 1rem 1.15rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
}
.legend h3 { margin: 0 0 .6rem; font: 700 .64rem var(--font-body); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.legend li { display: flex; align-items: center; gap: .75rem; }
.legend-desc { color: var(--muted); font-size: .84rem; }

.msg { display: flex; align-items: flex-start; gap: .75rem; animation: rise .25s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg.user { flex-direction: row-reverse; }
.msg-avatar { width: 34px; height: 34px; flex: none; display: grid; place-items: center; font-size: .72rem; font-weight: 650; }
.msg-avatar.user { border-radius: 50%; color: #fff; background: var(--primary); box-shadow: 0 4px 12px -4px rgba(8, 126, 255, .6); }
.msg-avatar.assistant {
  border-radius: 10px; color: var(--primary-dark); font: 700 .92rem var(--font-head);
  background: var(--surface); border: 1px solid rgba(8, 126, 255, .25); box-shadow: var(--glass-shadow);
}
.bubble { max-width: min(820px, calc(100% - 46px)); padding: .8rem 1.05rem; border-radius: 18px; line-height: 1.6; min-width: 0; }
.msg.user .bubble {
  color: #fff; border-top-right-radius: 6px; white-space: pre-wrap;
  background: var(--primary);
  box-shadow: 0 8px 20px -12px rgba(8, 126, 255, .7);
}
.msg.assistant .bubble {
  flex: 1; max-width: none; padding: 1.1rem 1.3rem; border-top-left-radius: 6px;
  background: var(--surface); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); box-shadow: var(--glass-shadow);
}
.msg-actions { display: flex; gap: .2rem; margin-top: .85rem; padding-top: .55rem; border-top: 1px solid var(--border); }

.composer-area { flex: none; padding: .85rem 1.5rem 1rem; border-top: 1px solid var(--border); background: var(--surface-2); }
.composer-area > * { max-width: 1120px; margin-left: auto; margin-right: auto; }
.suggestions { display: flex; align-items: center; gap: .5rem; overflow-x: auto; padding-bottom: .65rem; }
.suggestions-label { font-size: .62rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.suggestion {
  padding: .32rem .85rem; border-radius: 999px; font-size: .76rem; font-weight: 550; white-space: nowrap; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9);
}
.suggestion:hover { color: var(--primary-dark); background: var(--primary-soft); border-color: rgba(8, 126, 255, .35); filter: none; box-shadow: 0 4px 12px -6px rgba(8, 126, 255, .45); }
.composer {
  display: block; padding: .65rem .8rem; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  transition: box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.composer:focus-within { border-color: var(--primary); box-shadow: var(--glass-shadow), 0 0 0 4px rgba(8, 126, 255, .14); }
.composer textarea { border: 0; background: transparent; resize: none; max-height: 160px; padding: .3rem .15rem; box-shadow: none; font-size: .92rem; }
.composer textarea:focus { outline: none; box-shadow: none; background: transparent; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding-top: .55rem; margin-top: .3rem; border-top: 1px solid var(--border); }
.composer-meta { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.scope-chip { display: inline-flex; align-items: center; gap: .35rem; color: var(--primary-dark); background: var(--primary-soft); border: 1px solid #CFE2FB; border-radius: 999px; padding: .12rem .7rem; font-size: .7rem; font-weight: 650; white-space: nowrap; }
.scope-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.composer-note { font-size: .7rem; color: var(--muted); }
.composer-actions { display: flex; align-items: center; gap: .6rem; flex: none; }
.char-count { font: 500 .7rem var(--font-code); color: var(--muted); white-space: nowrap; }
.composer button.send { width: 36px; height: 36px; padding: 0; margin: 0; border-radius: 10px; flex: none; }

.typing { display: flex; gap: 5px; padding: .35rem 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

/* ---------- Answer formatting ---------- */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: .55rem 0; }
.md h3, .md h4, .md h5, .md h6 { margin: 1.05rem 0 .35rem; }
.md ul, .md ol { margin: .45rem 0; padding-left: 1.3rem; }
.md li { margin: .15rem 0; }
.md code { background: rgba(20, 45, 80, .06); padding: .05rem .35rem; border-radius: 5px; font: .85em var(--font-code); }
.md pre { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: .9rem 1rem; border-radius: 12px; overflow-x: auto; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06); }
.md pre code { background: transparent; color: inherit; }
.md table { display: block; overflow-x: auto; width: max-content; max-width: 100%; margin: .7rem 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.md th { position: static; }
.cite { background: rgba(232, 242, 255, .95); color: var(--primary-dark); border-radius: 5px; padding: .05rem .38rem; font: 700 .68rem var(--font-code); margin-left: 1px; }

/* ---------- Sources under an answer ---------- */
.sources { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--border); display: grid; gap: .45rem; }
.sources-title { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.source { border: 1px solid var(--border); border-radius: 12px; padding: .55rem .75rem; background: var(--surface); transition: border-color .15s var(--ease), background .15s var(--ease); }
.source:hover { border-color: rgba(8, 126, 255, .4); background: var(--surface); box-shadow: var(--glass-shadow); }
.source.cited { border-color: rgba(8, 126, 255, .3); }
.source[open] { background: var(--surface); }
.source summary { display: flex; align-items: center; gap: .55rem; cursor: pointer; list-style: none; flex-wrap: wrap; }
.source summary::-webkit-details-marker { display: none; }
.ref { color: #fff; border-radius: 6px; padding: .06rem .42rem; font: 700 .68rem var(--font-code); background: var(--primary); }
.source-title { font-weight: 600; font-size: .82rem; }
.tag { font-size: .64rem; font-weight: 600; background: #EEF2F8; color: #4A5F80; border-radius: 999px; padding: .06rem .5rem; }
.source-meta { margin: .45rem 0 0; font-size: .72rem; color: var(--muted); text-transform: capitalize; }
.source-snippet { margin: .4rem 0 .15rem; font-size: .8rem; color: var(--text-2); font-style: italic; background: var(--surface-2); border-left: 3px solid var(--primary); border-radius: 6px; padding: .45rem .65rem; }
.source-snippet.calculated { white-space: pre-line; font-style: normal; }

/* ---------- Dialogs ---------- */
dialog {
  width: min(500px, 94vw); padding: 1.5rem 1.6rem; color: var(--text); border-radius: 20px;
  background: var(--surface); box-shadow: var(--glass-shadow-lg);
}
dialog[open] { animation: pop .18s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog::backdrop { background: rgba(11, 31, 68, .45); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog h2 { font-size: 1.15rem; }
dialog.confirm { width: min(420px, 94vw); }
dialog.confirm p { margin: 0; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.3rem; }
.dialog-actions.start { justify-content: flex-start; flex-wrap: wrap; }
.dialog-actions button[type="submit"], .dialog-actions button.primary { width: auto; margin: 0; }
.secret {
  display: block; padding: .65rem .8rem; border: 1px dashed var(--border-strong); border-radius: 10px;
  background: var(--surface-2); font-family: var(--font-code); font-size: .84rem; word-break: break-all; user-select: all;
}

/* ---------- Toasts (top right, glass with a coloured edge) ---------- */
.toasts { position: fixed; top: 1rem; right: 1rem; display: grid; gap: .55rem; z-index: 1000; }
.toast {
  display: flex; align-items: center; gap: .75rem; min-width: 280px; max-width: 400px; padding: .75rem .9rem .75rem 1rem;
  border-radius: 14px; color: var(--text); font-size: .85rem; font-weight: 500;
  background: var(--surface); border: 1px solid var(--glass-line); border-left: 4px solid var(--info);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); box-shadow: var(--glass-shadow-lg);
  animation: rise .2s var(--ease);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.warning { border-left-color: #E99A18; }
.toast span { flex: 1; }
.toast-close { background: transparent; box-shadow: none; color: var(--muted); padding: 0 .25rem; font-size: 1.2rem; line-height: 1; }
.toast-close:hover { background: transparent; box-shadow: none; color: var(--text); filter: none; }

/* ---------- Data sources (ingestion) and HRM link ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .7rem; margin-top: .9rem; }
.tool-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; text-align: left; font-weight: 400;
  padding: .85rem .95rem; border-radius: 14px; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
  transition: transform .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.tool-card:hover { background: var(--surface); border-color: var(--border-strong); transform: translateY(-2px); filter: none; box-shadow: var(--glass-shadow), 0 12px 24px -12px rgba(8, 126, 255, .35); }
.tool-card.active { border-color: rgba(8, 126, 255, .6); background: var(--surface); box-shadow: 0 0 0 4px rgba(8, 126, 255, .14), var(--glass-shadow); }
.tool-card strong { font-size: .92rem; font-weight: 650; }
.tool-card .tool-vendor { font-size: .74rem; color: var(--muted); }
.tool-card .badge { margin-top: .25rem; }
.guide-steps { margin: .7rem 0 0; padding-left: 1.3rem; display: grid; gap: .6rem; line-height: 1.5; }
.guide-notes {
  margin: .9rem 0 0; padding: .75rem .95rem .75rem 1.8rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; font-size: .84rem; color: var(--muted); display: grid; gap: .35rem;
}
.guide-notes:empty { display: none; }
.cred-state { font-size: .74rem; font-weight: 650; margin-left: .4rem; }
.cred-state.on { color: var(--success); }
.cred-state.off { color: var(--error); }
.columns-list { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; max-height: 220px; overflow-y: auto; }
.columns-list code { font: .74rem var(--font-code); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .1rem .4rem; }

/* ---------- Browsers without backdrop blur: keep text readable ---------- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card, .glass, .topbar, .bar, .chat, dialog, .toast, .composer { background: var(--surface); }
  .sidebar { background: var(--side); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Small screens ---------- */
@media (max-width: 960px) {
  :root { --gap: 12px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: var(--gap); bottom: var(--gap); left: var(--gap); height: auto; width: 270px; z-index: 30;
    transform: translateX(calc(-100% - 2 * var(--gap))); transition: transform .26s cubic-bezier(.16, 1, .3, 1);
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(11, 31, 68, .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
  .menu-btn, .sidebar-close { display: inline-grid; }
  .topbar { padding: .6rem .9rem; min-height: 60px; }
  .page-sub { display: none; }
  .chat { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .threads { border-right: 0; border-bottom: 1px solid var(--border); max-height: 160px; }
  .messages { padding: 1rem; }
  .composer-area { padding: .6rem .9rem .8rem; }
  .composer-note { display: none; }
  .grid-2, .form-row { grid-template-columns: 1fr; }
  .card { padding: 1.1rem; }
  .card > .table-wrap { margin-left: -1.1rem; margin-right: -1.1rem; }
  .card > .table-wrap:last-child, .card > .table-wrap:has(+ [hidden]:last-child) { margin-bottom: -1.1rem; }
  .glass { padding: 1.6rem 1.4rem; }
}

/* ---------- Calculated answers: context, key numbers, table, chart ---------- */
.insight { margin-bottom: .9rem; padding-bottom: .8rem; border-bottom: 1px solid var(--border); display: grid; gap: .65rem; }
.ins-head { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; }
.ins-title { font-size: .95rem; }
.ins-chip { font-size: .68rem; font-weight: 650; padding: .14rem .6rem; border-radius: 999px; background: #EEF2F8; color: var(--text-2); }
.ins-chip.period { background: rgba(232, 242, 255, .95); color: var(--primary-dark); }
.ins-chip.period.past { background: rgba(254, 243, 199, .95); color: #b45309; }
.ins-population, .ins-interpreted, .ins-version { margin: 0; font-size: .76rem; color: var(--muted); line-height: 1.45; }
.ins-interpreted { font-style: italic; }
.ins-cards, .stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .55rem; }
.ins-card, .stat-card { display: grid; gap: .12rem; padding: .6rem .75rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.ins-card-label, .stat-label { font-size: .6rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.ins-card-value, .stat-value { font-size: 1.3rem; line-height: 1.2; letter-spacing: -.01em; color: var(--text); overflow-wrap: anywhere; }
.ins-card-hint, .stat-hint { font-size: .7rem; color: var(--muted); overflow-wrap: anywhere; }
.insight h4 { margin: 0 0 .3rem; font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ins-table .table-wrap { margin-top: 0; }
.ins-table table { font-size: .78rem; }
.ins-table th, .ins-table td { padding: .45rem .7rem; }
.ins-chart { display: grid; gap: .3rem; }
.ins-bar-row { display: grid; grid-template-columns: minmax(70px, 150px) 1fr auto; align-items: center; gap: .55rem; font-size: .76rem; }
.ins-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.ins-bar-track { display: block; height: 10px; border-radius: 999px; background: #E8F0FC; overflow: hidden; }
.ins-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.ins-bar-value { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.ins-list ul { margin: 0; padding-left: 1.1rem; font-size: .78rem; color: var(--text-2); display: grid; gap: .25rem; }
.ins-notes { padding: .5rem .7rem; border-radius: var(--radius-sm); background: rgba(254, 243, 199, .55); border: 1px solid rgba(217, 119, 6, .2); }
.ins-more summary { cursor: pointer; font-size: .76rem; font-weight: 600; color: var(--primary-dark); }
.ins-more[open] { display: grid; gap: .6rem; }

/* ---------- AI usage (Administration and Platform pages) ---------- */
.stat-cards { margin: .8rem 0; }
.usage-state { margin: .6rem 0 0; }
.usage-state.warning { background: rgba(254, 243, 199, .7); color: #b45309; }
.usage-state.exceeded { background: rgba(254, 242, 242, .9); color: #b91c1c; }
.usage-state.ok { background: rgba(236, 253, 245, .9); color: #047857; }
.usage-state.none { background: #EEF2F8; color: var(--text-2); }
.usage-state { padding: .5rem .7rem; border-radius: var(--radius-sm); font-size: .84rem; }
.usage-sub { margin: 1rem 0 .2rem; font-size: .8rem; font-weight: 700; color: var(--text-2); }

/* SharePoint libraries table: audience choice and its team or unit */
.audience { display: flex; gap: .4rem; min-width: 14rem; }
.audience select, .audience input { min-width: 0; flex: 1; }

/* ---------- Chat trust: evidence level, confidence, data quality, saved items ---------- */
.evidence { margin-bottom: .8rem; padding: .6rem .8rem; border-radius: var(--radius-sm); border: 1px solid var(--border); display: grid; gap: .5rem; background: var(--surface); }
.evidence h4 { margin: 0 0 .25rem; font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.evidence ul { margin: 0; padding-left: 1.1rem; font-size: .78rem; color: var(--text-2); display: grid; gap: .2rem; }
.ev-head { display: flex; align-items: center; gap: .5rem; }
.ev-label { font-size: .78rem; font-weight: 700; }
.ev-strong { border-color: rgba(21, 128, 61, .3); background: rgba(220, 252, 231, .5); }
.ev-strong .ev-label { color: var(--success); }
.ev-partial { border-color: rgba(8, 126, 255, .25); background: rgba(232, 242, 255, .5); }
.ev-partial .ev-label { color: var(--primary-dark); }
.ev-weak { border-color: rgba(217, 119, 6, .35); background: rgba(254, 243, 199, .6); }
.ev-weak .ev-label { color: var(--warning); }
.ev-none { border-color: rgba(192, 57, 43, .3); background: rgba(254, 226, 226, .55); }
.ev-none .ev-label { color: var(--error); }
.confidence { margin-top: .8rem; display: grid; gap: .3rem; }
.conf summary { cursor: pointer; display: flex; align-items: center; gap: .5rem; font-size: .76rem; }
.conf-label { color: var(--text-2); font-weight: 600; }
.conf-level { font-size: .68rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; }
.conf-high { background: rgba(220, 252, 231, .95); color: var(--success); }
.conf-medium { background: rgba(254, 243, 199, .95); color: var(--warning); }
.conf-low { background: rgba(254, 226, 226, .95); color: var(--error); }
.conf-reasons { margin: .3rem 0 .2rem; padding-left: 1.1rem; font-size: .76rem; color: var(--text-2); display: grid; gap: .2rem; }
.dq { margin-top: .6rem; padding: .45rem .7rem; border-radius: var(--radius-sm); border: 1px solid rgba(217, 119, 6, .3); background: rgba(254, 243, 199, .45); }
.dq.dq-poor { border-color: rgba(192, 57, 43, .3); background: rgba(254, 226, 226, .45); }
.dq summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .76rem; }
.dq-label { font-weight: 700; color: var(--text-2); }
.dq-level { font-weight: 700; color: var(--warning); }
.dq-poor .dq-level { color: var(--error); }
.dq-count { color: var(--muted); }
.dq h4 { margin: .5rem 0 .25rem; font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.dq ul { margin: 0; padding-left: 1.1rem; font-size: .76rem; color: var(--text-2); display: grid; gap: .2rem; }
.bookmark-btn.on svg { fill: var(--primary); stroke: var(--primary); }
.thread:hover .bookmark-btn.small, .bookmark-btn.small.on { opacity: 1; }
.saved-list .thread-time { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem .9rem; }

/* =====================================================================
   Sidebar effects: navy depth, bottom waves, glossy logo, glowing active item.
   Blue-only palette (navy #0B1F44 + electric blue #087EFF). Remove this block to go back to flat.
   ===================================================================== */
.sidebar {
  background:
    radial-gradient(220px 180px at 0% 0%, rgba(8, 126, 255, .16), transparent 70%),
    linear-gradient(180deg, #102A5A 0%, #0B1F44 55%, #091A3A 100%);
}
/* Layered waves along the bottom of the sidebar */
.sidebar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 48%; pointer-events: none; z-index: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 400' preserveAspectRatio='none'%3E%3Cpath d='M0 110 C70 40 150 40 256 0 L256 400 L0 400 Z' fill='%23153A7A' fill-opacity='.45'/%3E%3Cpath d='M0 250 C80 160 170 230 256 150 L256 400 L0 400 Z' fill='%231B4590' fill-opacity='.35'/%3E%3C/svg%3E") no-repeat bottom / 100% 100%;
}
.sidebar > * { position: relative; z-index: 1; }

/* Glossy logo mark (sidebar, login, chat welcome) */
.auth-mark, .brand-mark, .welcome-mark {
  background: linear-gradient(145deg, #3D9BFF 0%, #087EFF 55%, #0563D6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 6px 18px -4px rgba(8, 126, 255, .6);
}

/* Active navigation: blue gradient with a soft glow */
.nav-item.active, .nav-item.active:hover {
  background: linear-gradient(135deg, #2E93FF 0%, #087EFF 60%, #0563D6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 8px 22px -6px rgba(8, 126, 255, .65);
}
.nav-item { transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease); }
.nav-item:not(.active):hover { transform: translateX(2px); }

/* User card: sits directly on the sidebar, avatar matches the logo */
.who { background: transparent; border-color: transparent; transition: background .2s var(--ease); }
.who:hover { background: rgba(255, 255, 255, .05); }
.avatar { background: linear-gradient(145deg, #3D9BFF 0%, #087EFF 55%, #0563D6 100%); box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 6px 14px -4px rgba(8, 126, 255, .6); }

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sidebar { background: linear-gradient(180deg, #102A5A 0%, #0B1F44 55%, #091A3A 100%); }
}

/* ---------- Niyaal logo (static/img/niyaal-logo.png) ----------
   The emblem is navy, teal, green and gold on a transparent background. It sits on a white tile so the
   navy strokes stay visible on the navy sidebar; on white pages the tile blends in. */
.auth-mark, .brand-mark, .welcome-mark {
  background: #fff; padding: 3px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .6), 0 6px 16px -6px rgba(8, 126, 255, .45);
}
.auth-mark img, .brand-mark img, .welcome-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.auth-mark, .welcome-mark { box-shadow: 0 0 0 1px var(--border), 0 8px 20px -8px rgba(20, 45, 80, .25); }
.auth-mark { width: 64px; height: 64px; border-radius: 16px; padding: 5px; }
.welcome-mark { width: 64px; height: 64px; border-radius: 18px; padding: 5px; }
.brand-mark { padding: 2px; }
.msg-avatar.assistant { padding: 3px; overflow: hidden; }
.msg-avatar.assistant img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* ---------- Analytics (Week 7): filters, KPI cards, trend, insight, detail, drill-down, comparison ---------- */
.an-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.an-filters {
  position: sticky; top: 0; max-height: calc(100vh - 2 * var(--gap)); overflow-y: auto;
  padding: 1.1rem 1rem 0; min-width: 0;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.an-filters-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.an-filters-head h2 { display: flex; align-items: center; gap: .45rem; margin: 0; font-size: 1rem; }
.an-filters-head svg { width: 18px; height: 18px; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linejoin: round; }
.an-filters label { margin: 0; }
.an-filters > form > label { margin: 1rem 0 .4rem; }
.an-filters select, .an-filters input { padding: .48rem .65rem; font-size: .82rem; width: 100%; }
/* Each dimension: label row above, select below */
.an-dim { display: grid; gap: .3rem; min-width: 0; }
.an-dim-head { display: flex; align-items: center; gap: .4rem; min-width: 0; flex-wrap: wrap; min-height: auto; }
.an-dim-head label {
  font-size: .78rem; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1 1 auto;
}
.an-dim-tag {
  flex: none; font-size: .6rem; font-weight: 650; letter-spacing: .02em;
  padding: .08rem .45rem; border-radius: 999px; background: var(--glass-soft); color: var(--muted); cursor: help;
  white-space: nowrap;
}
.an-seg { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .2rem; padding: .2rem; margin-bottom: .45rem; background: var(--glass-soft); border: 1px solid var(--border); border-radius: 10px; }
.an-seg-btn { padding: .4rem .3rem; font-size: .74rem; white-space: nowrap; background: transparent; color: var(--muted); box-shadow: none; border-radius: 8px; text-align: center; }
.an-seg-btn:hover { background: rgba(255, 255, 255, .7); color: var(--text); box-shadow: none; }
.an-seg-btn.active { background: var(--surface); color: var(--primary-dark); box-shadow: 0 1px 2px rgba(20, 45, 80, .1); }
.an-custom { display: grid; gap: .4rem; }
.an-dimensions { display: grid; gap: .75rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.an-dim.off label { color: var(--muted); }
.an-dim.off select { color: var(--muted); background: var(--surface-2); }
.an-personal { font-weight: 450; color: var(--muted); }
.an-filter-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: 1rem; position: sticky; bottom: 0; padding: .75rem 0; background: var(--surface); border-top: 1px solid var(--border); }
#an-scope { margin: 0 0 1rem; }
#an-filter-form .an-filter-actions button[type="submit"] { width: auto; margin-top: 0; padding: .55rem .8rem; }

.an-main { display: grid; gap: var(--gap); min-width: 0; }
/* The sections inside the page body need the same spacing as the page itself. */
#an-body { display: grid; gap: var(--gap); min-width: 0; }
.an-main > .tabs { margin-bottom: 0; }
.an-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.an-head-text { min-width: 0; }
.an-head .an-sources { margin: .3rem 0 0; font-size: .74rem; }
.an-asof { flex: none; margin-top: .3rem; white-space: nowrap; }
.an-head h2 { margin: 0; font-size: 1.3rem; }
.an-head p { margin: .2rem 0 0; font-size: .85rem; }
.an-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.an-chips:empty { display: none; }
.an-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .35rem .22rem .7rem; border-radius: 999px; font-size: .76rem; background: var(--primary-soft); color: var(--primary-dark); border: 1px solid rgba(8, 126, 255, .2); }
.an-chip-key { color: var(--text-2); }
.an-chip-x { padding: 0 .4rem; background: transparent; color: var(--primary-dark); box-shadow: none; font-size: .95rem; line-height: 1; }
.an-chip-x:hover { background: rgba(8, 126, 255, .12); box-shadow: none; }
.an-crumb { background: var(--surface); padding-right: .7rem; }
.an-crumb button.link { font-size: .76rem; }
.an-state .empty { padding: 1.5rem 0; }

.an-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.an-kpi {
  display: grid; align-content: start; gap: .2rem; text-align: left; padding: .9rem 1rem; border-radius: var(--radius); min-height: 118px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--glass-shadow); font-weight: 400; min-width: 0;
}
.an-kpi:hover { background: var(--surface-2); border-color: var(--border-strong); box-shadow: var(--glass-shadow); }
/* The selected KPI (the one the trend and drill-down show) is the only card with the blue edge. */
.an-kpi.selected, .an-kpi.selected:hover { background: var(--primary-soft); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(8, 126, 255, .14); }
.an-kpi-label { font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.an-kpi-value { font-family: var(--font-head); font-size: 1.55rem; font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
.an-kpi-delta { font-size: .74rem; font-weight: 650; color: var(--text-2); }
.an-kpi-delta.up { color: var(--success); }
.an-kpi-delta.down { color: var(--error); }
.an-kpi-hint { font-size: .7rem; color: var(--muted); overflow-wrap: anywhere; }
.an-kpi-status { font-size: .72rem; font-weight: 650; color: var(--warning); }
.an-kpi-reason { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.an-kpi.missing .an-kpi-value, .an-kpi.not_available .an-kpi-value, .an-kpi.not_split .an-kpi-value,
.an-kpi.no_data .an-kpi-value, .an-kpi.hidden .an-kpi-value { color: var(--muted); }
.an-kpi.hidden .an-kpi-status { color: var(--muted); }

.an-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--gap); align-items: stretch; }
.an-trend-card { display: flex; flex-direction: column; }
.an-trend-card .an-trend { flex: 1; display: flex; align-items: center; }
.an-trend-card .an-trend > * { flex: 1; }
.an-grid > .card, .an-details > .card { margin: 0; }
.an-grid h3, .an-detail h3, .an-drill h3, .an-compare h3 { margin: 0; font-size: .95rem; }
.an-trend { margin-top: .4rem; }
.an-trend-svg { width: 100%; height: auto; display: block; }
.an-grid-line { stroke: var(--border); stroke-width: 1; }
.an-axis { font-size: 10px; fill: var(--muted); }
.an-line { fill: none; stroke: var(--primary); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.an-dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.an-missing { margin: .6rem 0 0; padding: .6rem .75rem; font-size: .8rem; color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }

.an-insight { display: grid; gap: .35rem; align-content: start; }
.an-insight > h3 { display: flex; align-items: center; gap: .45rem; }
.an-insight > h3 svg { width: 18px; height: 18px; fill: none; stroke: var(--primary); stroke-width: 1.6; stroke-linejoin: round; }
.an-insight h4 { margin: .5rem 0 0; font-size: .64rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.an-list { margin: 0; padding-left: 1.05rem; display: grid; gap: .35rem; font-size: .8rem; color: var(--text-2); }
.an-actions li.data { color: var(--warning); }
.an-evidence { display: block; font-size: .7rem; color: var(--muted); }
.an-insight button.small { justify-self: start; display: inline-flex; align-items: center; gap: .4rem; margin-top: .5rem; }
.an-insight button.small svg { width: 15px; height: 15px; }

.an-section-title { margin: .4rem 0 -.5rem; font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.an-details { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--gap); }
.an-detail .hint { margin: .1rem 0 .7rem; }
.an-detail .ins-bar-row { grid-template-columns: minmax(80px, 140px) 1fr auto; }
.hidden-bar { background: var(--border-strong); }

.an-inline { display: flex; align-items: center; gap: .45rem; }
.an-inline-label { margin: 0; }
.an-inline select { width: auto; min-width: 10rem; padding: .4rem .6rem; font-size: .82rem; }
.an-split td.num, .an-split th.num { text-align: right; font-variant-numeric: tabular-nums; }
.an-split tr.pick { cursor: pointer; }
.an-split tr.pick:hover td:first-child, .an-split tr.pick:focus-visible td:first-child { color: var(--primary-dark); text-decoration: underline; }
.an-split tr.pick:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.an-compare-form { display: grid; grid-template-columns: minmax(160px, 220px) 1fr auto; gap: 1rem; align-items: end; }
.an-compare-form label { margin-top: 0; }
.an-compare-kpis { margin: 0; padding: .3rem .7rem .5rem; border: 1px solid var(--border); border-radius: 10px; }
.an-compare-kpis legend { padding: 0 .3rem; font-size: .75rem; font-weight: 600; color: var(--text-2); }
.an-compare-kpis > div { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.an-compare-kpis label.check { margin-top: .35rem; }
.an-compare-insight { margin: .8rem 0 0; font-size: .85rem; color: var(--text-2); }
.an-notes h4 { margin: 0 0 .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--warning); }
.an-notes ul { margin: 0; padding-left: 1.1rem; font-size: .78rem; color: var(--text-2); display: grid; gap: .2rem; }

@media (max-width: 1180px) {
  .an-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .an-layout { grid-template-columns: minmax(0, 1fr); }
  .an-filters { position: static; max-height: none; }
  .an-compare-form { grid-template-columns: 1fr; }
  .an-head { flex-direction: column; gap: .4rem; }
  .an-asof { margin-top: 0; }
}
.ins-analytics { justify-self: start; font-size: .76rem; font-weight: 600; color: var(--primary-dark); }

/* ---------- Skeleton loading (Analytics) ---------- */
.an-sk {
  display: block; border-radius: 6px;
  background: linear-gradient(90deg, var(--glass-soft) 0%, var(--hover) 40%, var(--glass-soft) 80%);
  background-size: 300% 100%; animation: an-shimmer 1.4s ease-in-out infinite;
}
@keyframes an-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -50% 0; } }
.an-kpi-sk { cursor: default; gap: .45rem; }
.an-kpi-sk:hover { border-color: var(--border); }
.an-sk-label { width: 55%; height: .6rem; }
.an-sk-value { width: 42%; height: 1.55rem; }
.an-sk-hint { width: 70%; height: .55rem; }
.an-sk-title { width: 50%; height: .9rem; margin-bottom: .5rem; }
.an-detail .an-sk-hint { margin-bottom: .9rem; }
.an-sk-chart { width: 100%; height: 190px; border-radius: var(--radius-sm); }
.an-sk-li { list-style: none; margin-left: -1.05rem; }
.an-sk-line { width: 92%; height: .7rem; }
.an-sk-li:nth-child(2n) .an-sk-line { width: 68%; }
.an-sk-rows { display: grid; gap: .55rem; margin-top: .4rem; }
.an-sk-row { height: .8rem; }
.an-sk-row:nth-child(2) { width: 82%; }
.an-sk-row:nth-child(3) { width: 64%; }
.an-sk-row:nth-child(4) { width: 46%; }
.an-sk-row:nth-child(5) { width: 30%; }
.an-sk-filter-label { width: 40%; height: .6rem; margin: .25rem 0 .1rem; }
.an-sk-input { height: 2.1rem; border-radius: 10px; }
/* ---------- AI data setup: proposals on the HRM link and SharePoint tabs ---------- */
.ai-badge { margin-left: .4rem; background: var(--primary-soft); color: var(--primary-dark); font-size: .62rem; letter-spacing: .04em; }
.sg-maps { list-style: none; margin: .3rem 0 .6rem; padding: 0; display: grid; gap: .15rem; }
.sg-maps label.check { margin-top: .2rem; }
.sp-why { max-width: 360px; gap: .2rem; font-size: .78rem; }
.sp-why .ins-more ul { margin: .3rem 0 0; padding-left: 1rem; }
#sp-files select { min-width: 9rem; padding: .35rem .5rem; font-size: .8rem; }
