/* Enawi dashboard, design system v2 (V1-03). Tokens and rationale: docs/DESIGN.md. RTL-first: logical properties only.
   Dark is the hero look (navy-black to steel blue, electric-blue glow, frosted glass, gold accent); light keeps the same
   structure in a calm, white style. Every colour, radius, shadow, duration is a custom property below. */

/* ---------- fonts (self-hosted, OFL): Be Vietnam Pro for Latin, IBM Plex Sans Arabic for Arabic ---------- */
@font-face { font-family: "Be Vietnam Pro"; src: url("/static/fonts/be-vietnam-pro-latin-400.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212; }
@font-face { font-family: "Be Vietnam Pro"; src: url("/static/fonts/be-vietnam-pro-latin-500.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212; }
@font-face { font-family: "Be Vietnam Pro"; src: url("/static/fonts/be-vietnam-pro-latin-600.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212; }
@font-face { font-family: "Be Vietnam Pro"; src: url("/static/fonts/be-vietnam-pro-latin-700.woff2") format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212; }
@font-face { font-family: "Plex Arabic"; src: url("/static/fonts/plex-arabic-arabic-400.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
@font-face { font-family: "Plex Arabic"; src: url("/static/fonts/plex-arabic-arabic-500.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
@font-face { font-family: "Plex Arabic"; src: url("/static/fonts/plex-arabic-arabic-600.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
@font-face { font-family: "Plex Arabic"; src: url("/static/fonts/plex-arabic-arabic-600.woff2") format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }

/* ---------- tokens: light (calm) ---------- */
:root {
  color-scheme: light;
  /* ground and surfaces */
  --bg: #f3f5f9;
  --bg-image: radial-gradient(1100px 520px at 100% -8%, rgba(30, 111, 224, .07), transparent 62%), linear-gradient(#f6f8fb, #eef1f6);
  --ground: var(--bg);
  --surface: #ffffff; --surface-2: #f4f6fa; --surface-3: #eaeef5;
  --glass-0: rgba(255, 255, 255, .78); --glass-1: #ffffff; --glass-2: rgba(255, 255, 255, .92);
  --glass-solid-0: #ffffff; --glass-solid-1: #ffffff; --glass-solid-2: #ffffff;
  --blur: 14px; --glass-edge: rgba(14, 26, 46, .07); --glass-hi: inset 0 1px 0 rgba(255, 255, 255, .9);
  --line: #e3e8f0; --line-strong: #cdd5e1;
  /* text */
  --ink: #0e1a2e; --ink-2: #4a586e; --ink-3: #5f6c82;
  /* brand */
  --blue: #1b5fd1; --blue-ink: #ffffff; --blue-soft: #e6eefc; --glow: rgba(30, 111, 224, .18);
  --gold: #9a5d0c; --gold-fill: #e9a23b; --gold-soft: #fbf0dc;
  --hot: #b23a0a; --hot-soft: #fde9df; --badge-ink: #ffffff;
  --positive: #157a4c; --positive-soft: #e1f3ea; --negative: #b42318; --negative-soft: #fbe4e1; --warning: #a3470b; --warning-soft: #fdeedd;
  /* charts (validated: docs/DESIGN.md) */
  --series-1: #1f63d6; --series-2: #c27419; --series-3: #12936f; --series-4: #c2410c; --spark: #5f6c82; --grid: #e7ebf2;
  /* shape, depth, space */
  --th-bg: #f4f6fa; --radius-xl: 28px; --radius-lg: 22px; --radius: 18px; --radius-md: 14px; --radius-sm: 10px; --pill: 999px;
  --shadow-1: 0 1px 2px rgba(14, 26, 46, .05), 0 6px 20px rgba(14, 26, 46, .05);
  --shadow-2: 0 2px 6px rgba(14, 26, 46, .06), 0 18px 44px rgba(14, 26, 46, .12);
  --gap: 20px; --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --focus: 0 0 0 3px rgba(27, 95, 209, .40);
  /* motion */
  --ease: cubic-bezier(.16, 1, .3, 1); --t-fast: 150ms; --t: 220ms; --t-slow: 300ms;
  /* shell */
  --sb-w: 264px; --sb-w-mini: 76px; --top-h: 64px; --bottom-h: 64px;
  --font: "Be Vietnam Pro", "Plex Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
}
/* ---------- tokens: dark (hero) ---------- */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #050b18;
  --bg-image: radial-gradient(900px 560px at 92% -12%, rgba(46, 123, 255, .30), transparent 60%),
              radial-gradient(700px 460px at -6% 108%, rgba(242, 169, 59, .07), transparent 62%),
              linear-gradient(170deg, #0a1733 0%, #070f22 46%, #050b18 100%);
  --surface: #0f1d38; --surface-2: rgba(148, 176, 224, .07); --surface-3: rgba(148, 176, 224, .12);
  --glass-0: rgba(10, 22, 48, .62); --glass-1: rgba(22, 40, 74, .46); --glass-2: rgba(19, 36, 68, .86);
  --glass-solid-0: #0a1630; --glass-solid-1: #11223f; --glass-solid-2: #132648; --th-bg: #11223f;
  --blur: 18px; --glass-edge: rgba(170, 196, 240, .12); --glass-hi: inset 0 1px 0 rgba(255, 255, 255, .06);
  --line: rgba(160, 186, 230, .13); --line-strong: rgba(160, 186, 230, .24);
  --ink: #edf2fb; --ink-2: #aebbd2; --ink-3: #9eabc3;
  --blue: #74acff; --blue-ink: #04101f; --blue-soft: rgba(91, 155, 255, .16); --glow: rgba(46, 123, 255, .42);
  --gold: #f2b04a; --gold-fill: #f2a93b; --gold-soft: rgba(242, 169, 59, .14);
  --hot: #ff7849; --hot-soft: rgba(255, 120, 73, .14); --badge-ink: #1a0700;
  --positive: #45d19c; --positive-soft: rgba(69, 209, 156, .13); --negative: #ff877c; --negative-soft: rgba(255, 116, 104, .14); --warning: #ff9a4d; --warning-soft: rgba(255, 154, 77, .14);
  --series-1: #3f82e6; --series-2: #c4821f; --series-3: #1fa283; --series-4: #e45f33; --spark: #9eabc3; --grid: rgba(160, 186, 230, .10);
  --shadow-1: 0 1px 1px rgba(0, 0, 0, .25), 0 10px 30px rgba(0, 4, 16, .35);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, .3), 0 24px 60px rgba(0, 4, 16, .55);
  --focus: 0 0 0 3px rgba(91, 155, 255, .55);
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050b18;
  --bg-image: radial-gradient(900px 560px at 92% -12%, rgba(46, 123, 255, .30), transparent 60%),
              radial-gradient(700px 460px at -6% 108%, rgba(242, 169, 59, .07), transparent 62%),
              linear-gradient(170deg, #0a1733 0%, #070f22 46%, #050b18 100%);
  --surface: #0f1d38; --surface-2: rgba(148, 176, 224, .07); --surface-3: rgba(148, 176, 224, .12);
  --glass-0: rgba(10, 22, 48, .62); --glass-1: rgba(22, 40, 74, .46); --glass-2: rgba(19, 36, 68, .86);
  --glass-solid-0: #0a1630; --glass-solid-1: #11223f; --glass-solid-2: #132648; --th-bg: #11223f;
  --blur: 18px; --glass-edge: rgba(170, 196, 240, .12); --glass-hi: inset 0 1px 0 rgba(255, 255, 255, .06);
  --line: rgba(160, 186, 230, .13); --line-strong: rgba(160, 186, 230, .24);
  --ink: #edf2fb; --ink-2: #aebbd2; --ink-3: #9eabc3;
  --blue: #74acff; --blue-ink: #04101f; --blue-soft: rgba(91, 155, 255, .16); --glow: rgba(46, 123, 255, .42);
  --gold: #f2b04a; --gold-fill: #f2a93b; --gold-soft: rgba(242, 169, 59, .14);
  --hot: #ff7849; --hot-soft: rgba(255, 120, 73, .14); --badge-ink: #1a0700;
  --positive: #45d19c; --positive-soft: rgba(69, 209, 156, .13); --negative: #ff877c; --negative-soft: rgba(255, 116, 104, .14); --warning: #ff9a4d; --warning-soft: rgba(255, 154, 77, .14);
  --series-1: #3f82e6; --series-2: #c4821f; --series-3: #1fa283; --series-4: #e45f33; --spark: #9eabc3; --grid: rgba(160, 186, 230, .10);
  --shadow-1: 0 1px 1px rgba(0, 0, 0, .25), 0 10px 30px rgba(0, 4, 16, .35);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, .3), 0 24px 60px rgba(0, 4, 16, .55);
  --focus: 0 0 0 3px rgba(91, 155, 255, .55);
}
/* low-end phones and reduced transparency: solid panels, same colours (text contrast is checked against these) */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass-0: var(--glass-solid-0); --glass-1: var(--glass-solid-1); --glass-2: var(--glass-solid-2); }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass-0: var(--glass-solid-0); --glass-1: var(--glass-solid-1); --glass-2: var(--glass-solid-2); --blur: 0px; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: var(--bg-image) fixed, var(--bg); color: var(--ink); font: 400 15px/1.55 var(--font); font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
::selection { background: var(--blue-soft); color: var(--ink); }
a { color: var(--blue); text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
input, textarea { caret-color: var(--blue); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
h1 { font-size: 26px; line-height: 1.25; font-weight: 600; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 16px; line-height: 1.4; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 8px; max-width: 72ch; }
[lang="en"] h1 { letter-spacing: -.02em; }
.icon { width: 20px; height: 20px; flex: none; vertical-align: -5px; }
.mute { color: var(--ink-2); } .ink3 { color: var(--ink-3); }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; direction: ltr; unicode-bidi: isolate; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.sr-only { position: absolute; inset-inline-start: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font: 500 11px/1 var(--font); padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line-strong); color: var(--ink-3); background: var(--surface-2); direction: ltr; white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; background: var(--blue); color: var(--blue-ink); padding: 8px 14px; border-radius: var(--radius-sm); transition: top var(--t-fast) var(--ease); }
.skip:focus { top: 12px; }

/* glass: frosted panels with a thin light edge and a soft inner highlight */
.glass, .card, .panel, .kpis, .sidebar, .topbar, .bottombar, .cmdk-box, .usermenu .menu {
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.25); backdrop-filter: blur(var(--blur)) saturate(1.25);
}

/* ---------- shell: sidebar (right in RTL, left in LTR) + top bar + content ---------- */
body.app { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); }
html[data-sb="mini"] body.app { grid-template-columns: var(--sb-w-mini) minmax(0, 1fr); }
.frame { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }

.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--glass-0);
  border-inline-end: 1px solid var(--glass-edge); box-shadow: var(--glass-hi); z-index: 30; overflow: hidden;
  transition: width var(--t-slow) var(--ease), transform var(--t-slow) var(--ease); }
.sb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 16px 12px; min-height: 76px; }
.sb-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.sb-name { font-weight: 600; font-size: 14px; line-height: 1.3; overflow: hidden; }
.sb-name small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-2); }
.sidebar .sb-close { display: none; }
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 12px 16px; overscroll-behavior: contain; }
.sb-group + .sb-group { margin-block-start: 14px; }
.sb-gtitle { font-size: 12px; font-weight: 500; color: var(--ink-3); margin: 0 0 4px; padding-inline: 12px; white-space: nowrap; }
.sb-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sb-nav a, .sb-collapse { position: relative; display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-md);
  color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; border: 1px solid transparent; background: none; width: 100%; cursor: pointer; font-family: inherit;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t) var(--ease); }
.sb-nav a:hover, .sb-collapse:hover { background: var(--surface-2); color: var(--ink); }
.sb-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; background: linear-gradient(var(--blue-soft), var(--blue-soft)), var(--surface-2);
  border-color: color-mix(in srgb, var(--blue) 28%, transparent); box-shadow: 0 0 22px -6px var(--glow), var(--glass-hi); }
.sb-nav a[aria-current="page"] .icon { color: var(--blue); }
.sb-label { overflow: hidden; text-overflow: ellipsis; flex: 1; text-align: start; }
.badge { min-width: 22px; height: 20px; padding: 0 7px; border-radius: var(--pill); background: var(--hot); color: var(--badge-ink); font: 600 11.5px/20px var(--font); text-align: center; flex: none; }
.sb-foot { padding: 10px 12px 14px; border-block-start: 1px solid var(--line); }
/* collapsed: mark + icons, labels become tooltips */
html[data-sb="mini"] .sb-head { justify-content: center; padding-inline: 8px; }
html[data-sb="mini"] .sb-name, html[data-sb="mini"] .sb-gtitle { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
html[data-sb="mini"] .sb-nav { padding-inline: 10px; }
html[data-sb="mini"] .sb-group + .sb-group { margin-block-start: 8px; padding-block-start: 8px; border-block-start: 1px solid var(--line); }
html[data-sb="mini"] .sb-nav a, html[data-sb="mini"] .sb-collapse { justify-content: center; padding-inline: 0; gap: 0; }
html[data-sb="mini"] .sb-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
html[data-sb="mini"] .sb-nav .badge { position: absolute; inset-block-start: 3px; inset-inline-end: 5px; min-width: 18px; height: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; }
.tip { position: fixed; z-index: 90; pointer-events: none; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--glass-solid-2); color: var(--ink); font-size: 13px;
  border: 1px solid var(--glass-edge); box-shadow: var(--shadow-2); white-space: nowrap; opacity: 0; transform: translateY(2px); transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.tip.on { opacity: 1; transform: none; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; min-height: var(--top-h); padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 62%, transparent); border-block-end: 1px solid var(--glass-edge); }
.topbar .tb-menu { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; font-size: 14px; white-space: nowrap; }
.crumb-group { color: var(--ink-3); }
.crumb-here { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumbs .chev { width: 14px; height: 14px; color: var(--ink-3); vertical-align: 0; }
[dir="rtl"] .crumbs .chev { transform: scaleX(-1); }
.cmdk-open { display: inline-flex; align-items: center; gap: 10px; min-width: 0; width: min(380px, 34vw); height: 40px; padding: 0 8px 0 12px; padding-inline: 12px 8px;
  border-radius: var(--pill); border: 1px solid var(--line-strong); background: var(--glass-1); color: var(--ink-3); font: inherit; font-size: 14px; cursor: text;
  box-shadow: var(--glass-hi); transition: border-color var(--t-fast) var(--ease), box-shadow var(--t) var(--ease); }
.cmdk-open:hover { border-color: color-mix(in srgb, var(--blue) 45%, var(--line-strong)); box-shadow: 0 0 0 4px var(--blue-soft), var(--glass-hi); }
.cmdk-ph { flex: 1; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-tools { display: flex; align-items: center; gap: 4px; }
.iconbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--pill); border: 0; background: none; color: var(--ink-2); cursor: pointer; text-decoration: none; font: 600 13px var(--font); flex: none;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.demo-badge { background: var(--hot-soft); color: var(--hot); border: 1px solid color-mix(in srgb, var(--hot) 40%, transparent); font-weight: 600; font-size: 12px; padding: 3px 10px; border-radius: var(--pill); white-space: nowrap; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; } .usermenu summary::-webkit-details-marker { display: none; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--gold-fill), #c9741a); color: #1b1004; font-weight: 700; font-size: 13px; }
.usermenu .menu { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 220px; padding: 8px; border-radius: var(--radius-md); background: var(--glass-2);
  border: 1px solid var(--glass-edge); box-shadow: var(--shadow-2), var(--glass-hi); z-index: 40; animation: pop var(--t) var(--ease); }
.menu-who { display: grid; padding: 6px 10px 10px; margin: 0 0 4px; border-block-end: 1px solid var(--line); font-size: 14px; }
.menu-who span { color: var(--ink-2); font-size: 12.5px; }
.usermenu .menu a, .usermenu .menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 10px; border-radius: var(--radius-sm); border: 0; background: none; color: var(--ink); text-decoration: none; font: inherit; font-size: 14px; cursor: pointer; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--surface-2); }
.usermenu form { margin: 0; }

main { width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px 28px 56px; flex: 1; animation: fade-in var(--t-slow) var(--ease) both; }
main:focus { outline: none; }
body.bare main { max-width: 1240px; padding: 20px 16px 48px; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; margin-block-end: 22px; }
.title-row .answer { font-size: 15px; color: var(--ink-2); margin: 6px 0 0; }
.title-row .answer b { color: var(--ink); font-weight: 600; }
.stamp { font-size: 12px; color: var(--ink-3); }
.bottombar { display: none; }
.scrim { display: none; }

/* command palette */
.cmdk { padding: 0; border: 0; background: none; width: min(640px, calc(100vw - 32px)); max-height: min(560px, calc(100dvh - 120px)); margin: 12vh auto auto; overflow: visible; color: var(--ink); }
.cmdk::backdrop { background: rgba(3, 8, 20, .5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.cmdk[open] .cmdk-box { animation: pop var(--t) var(--ease); }
.cmdk-box { display: flex; flex-direction: column; max-height: inherit; margin: 0; border-radius: var(--radius-lg); background: var(--glass-2); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-2), var(--glass-hi); overflow: hidden; }
.cmdk-field { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-block-end: 1px solid var(--line); color: var(--ink-3); }
.cmdk-field input { flex: 1; min-width: 0; border: 0; background: none; padding: 6px 0; font-size: 16px; color: var(--ink); min-height: 40px; }
.cmdk-field input:focus-visible { box-shadow: none; }
.cmdk-field input::-webkit-search-cancel-button { display: none; }
.cmdk-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.cmdk-list .h { font-size: 12px; font-weight: 500; color: var(--ink-3); padding: 10px 10px 4px; }
.cmdk-list [role="option"] { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--ink); }
.cmdk-list [role="option"] small { color: var(--ink-3); margin-inline-start: auto; font-size: 12.5px; }
.cmdk-list [role="option"] .icon { color: var(--ink-3); }
.cmdk-list [aria-selected="true"] { background: var(--blue-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 30%, transparent); }
.cmdk-list [aria-selected="true"] .icon { color: var(--blue); }
.cmdk-empty { padding: 18px; margin: 0; color: var(--ink-2); text-align: center; }

/* ---------- panels: frosted glass cards ---------- */
.card, .panel { background: var(--glass-1); border: 1px solid var(--glass-edge); border-radius: var(--radius-lg); padding: 20px; margin-block-end: var(--gap); overflow-x: auto;
  box-shadow: var(--shadow-1), var(--glass-hi); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-block-end: 14px; }
.panel-head h2 { margin: 0; }
.panel-head .stamp a { color: var(--ink-2); }
.cols { display: grid; gap: var(--gap); }
@media (min-width: 900px) { .cols { grid-template-columns: 1.6fr 1fr; } .cols.even { grid-template-columns: 1fr 1fr; } .cols > * { margin-block-end: 0; } }
.cols + .cols, .cols + .panel { margin-block-start: var(--gap); }

/* KPI strip */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); background: var(--glass-1); border: 1px solid var(--glass-edge); border-radius: var(--radius-lg); margin-block-end: var(--gap); overflow: hidden; box-shadow: var(--shadow-1), var(--glass-hi); }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }   /* wraps instead of clipping big numbers */
.kpi { container-type: inline-size; padding: 18px 20px 16px; border-inline-start: 1px solid var(--line); border-block-start: 1px solid var(--line); margin: -1px 0 0 -1px; min-width: 0; }
.kpi .l { font-size: 13px; color: var(--ink-2); }
.kpi .v { font-size: clamp(18px, 15cqi, 26px); white-space: nowrap; font-weight: 600; line-height: 1.2; margin-block-start: 4px; letter-spacing: -.01em; }
.kpi.lead .v { font-size: clamp(22px, 17cqi, 34px); }   /* numbers shrink with their card, never clip */
.kpi .sub, .sub { display: block; font-size: 12.5px; font-weight: 400; color: var(--ink-2); letter-spacing: 0; }
.kpi .d { font-size: 12.5px; color: var(--ink-2); margin-block-start: 2px; }
.kpi .d.good { color: var(--positive); } .kpi .d.bad { color: var(--negative); }
.spark { display: block; width: 100%; height: 28px; margin-block-start: 8px; }
.spark polyline { fill: none; stroke: var(--spark); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--blue); }
.kpi.lead .spark polyline { stroke: var(--blue); filter: drop-shadow(0 0 6px var(--glow)); }
td .sub { display: inline; margin-inline-start: 6px; }

/* target rows */
.target-rows { display: grid; gap: 14px; }
.trow { display: grid; grid-template-columns: minmax(120px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.track { position: relative; height: 12px; background: var(--surface-3); border-radius: var(--pill); }
.track .fill { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--series-1); border-radius: var(--pill); max-width: 100%; box-shadow: 0 0 12px -2px var(--glow); }
.track .fill.low { background: var(--warning); box-shadow: none; }
.track .tick { position: absolute; inset-block: -4px; width: 2px; background: var(--gold-fill); border-radius: 1px; }
.trow .pct { min-width: 4.5em; text-align: end; }

/* ranked bars */
.bars { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.bars li { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.bars .bar { height: 10px; background: var(--series-1); border-radius: 0 var(--pill) var(--pill) 0; }
[dir="rtl"] .bars .bar { border-radius: var(--pill) 0 0 var(--pill); }

/* tables */
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 11px 12px; border-block-end: 1px solid var(--line); text-align: start; white-space: nowrap; vertical-align: top; }
th { color: var(--ink-2); font-weight: 500; font-size: 12.5px; }
tr:last-child td { border-block-end: 0; }
td.n, th.n { text-align: end; font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color var(--t-fast) var(--ease); }
tbody tr:hover td { background: var(--surface-2); }
.table-view summary { cursor: pointer; color: var(--ink-2); font-size: 13px; margin-block-start: 10px; }

/* controls */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 12px; max-width: 100%; min-height: 40px; color: var(--ink); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--blue); }
select option { background: var(--glass-solid-2); color: var(--ink); }
textarea { width: 100%; }
label { color: var(--ink-2); font-size: 14px; }
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--blue); color: var(--blue-ink); border: 1px solid transparent; border-radius: var(--pill); padding: 8px 18px; min-height: 40px; cursor: pointer; text-decoration: none; font-weight: 600;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t) var(--ease), transform var(--t-fast) var(--ease); }
.btn:hover { box-shadow: 0 6px 22px -6px var(--glow); }
.btn:active { transform: translateY(1px); }
.btn.gold { background: linear-gradient(180deg, #f6bb5c, var(--gold-fill) 55%, #d98a24); color: #1b1004; }
.btn.ghost { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-3); box-shadow: none; }
.btn.red { background: transparent; color: var(--negative); border-color: color-mix(in srgb, var(--negative) 40%, transparent); }
.btn.red:hover { background: var(--negative-soft); box-shadow: none; }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn[disabled], .btn.htmx-request { opacity: .55; cursor: progress; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; flex-wrap: wrap; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-block-end: 8px; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--glass-1); border: 1px solid var(--glass-edge); border-radius: var(--pill); margin-block-end: var(--gap); box-shadow: var(--glass-hi); }
.tabs a { padding: 6px 14px; border-radius: var(--pill); color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.tabs a:hover { color: var(--ink); }
.tabs a.on, .tabs a[aria-current] { background: var(--blue-soft); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 26%, transparent); }
.title-row .tabs { margin-block-end: 0; }

/* status */
.tag { display: inline-block; padding: 1px 10px; border-radius: var(--pill); font-size: 12px; line-height: 22px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; border: 1px solid var(--line); }
.tag.ok { background: var(--positive-soft); color: var(--positive); border-color: transparent; }
.tag.warning, .tag.pending { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.tag.critical, .tag.rejected, .tag.disabled { background: var(--negative-soft); color: var(--negative); border-color: transparent; }
.banner { padding: 12px 16px; border-radius: var(--radius-md); margin-block-end: 16px; background: var(--warning-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); }
.banner.bad { background: var(--negative-soft); border-color: color-mix(in srgb, var(--negative) 35%, transparent); }
.banner.ok { background: var(--positive-soft); border-color: color-mix(in srgb, var(--positive) 35%, transparent); }

/* needs-you list */
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-block-end: 1px solid var(--line); font-size: 14px; }
.todo li:last-child { border-block-end: 0; }
.todo .dot { width: 8px; height: 8px; border-radius: 50%; margin-block-start: 7px; flex: none; background: var(--ink-3); }
.todo .dot.warning { background: var(--warning); box-shadow: 0 0 8px var(--warning); } .todo .dot.critical { background: var(--negative); box-shadow: 0 0 8px var(--negative); }
.todo a { color: var(--ink); text-decoration: none; } .todo a:hover { text-decoration: underline; }

/* charts */
.chart { position: relative; height: 240px; }
.chart.short { height: 180px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }

/* empty, loading */
.empty { padding: 28px 12px; text-align: center; color: var(--ink-2); font-size: 14px; }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-block-end: 4px; }
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 7%, transparent), transparent); animation: shimmer 1.4s var(--ease) infinite; }
.chart.skeleton canvas { visibility: hidden; }
.htmx-indicator { display: none; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }

/* chat */
.msg { padding: 10px 14px; border-radius: 16px; margin: 8px 0; max-width: 85%; white-space: pre-wrap; }
.msg.user { background: var(--blue); color: var(--blue-ink); margin-inline-start: auto; }
.msg.assistant { background: var(--surface-2); border: 1px solid var(--line); }

/* login and narrow forms */
.login { max-width: 400px; margin: 10vh auto 0; padding: 28px; border-radius: var(--radius-xl); }
.login input { width: 100%; margin-block-end: 12px; }
.login .brand { margin-block-end: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; white-space: nowrap; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-2); line-height: 1.2; }
.brand-hero { flex-direction: column; text-align: center; gap: 12px; white-space: normal; }
.brand-hero .logo-plate { border-radius: 18px; box-shadow: 0 18px 48px -18px var(--glow); }
.login h1 { font-size: 20px; margin-block-end: 14px; }
.pw-wrap { position: relative; }                                              /* V3-04: show / hide the password */
.pw-wrap input { padding-inline-end: 76px; }
.pw-eye { position: absolute; inset-inline-end: 6px; inset-block-start: 4px; min-height: 32px; padding: 0 10px; border: 0; background: transparent; color: var(--ink-2); font-size: 13px; cursor: pointer; border-radius: var(--radius-sm); }
.pw-eye:hover, .pw-eye:focus-visible { color: var(--ink); background: var(--surface-3); }
.caps-hint { padding: 8px 12px; font-size: 13px; margin-block-end: 12px; }
.errpage { text-align: center; }
.err-code { font-size: 56px; font-weight: 700; line-height: 1; color: var(--ink-3); margin: 0 0 8px; }
.stack-form { display: grid; gap: 6px; max-width: 380px; }                    /* V3-04: label above its field, one column (account page) */
.stack-form input { width: 100%; margin-block-end: 8px; }
.stack-form .btn { justify-self: start; margin-block-start: 4px; }
.logo-plate { display: inline-flex; flex: none; background: #0a1630; border-radius: 10px; line-height: 0; }   /* the logo is made for dark navy */
.logo-plate .logo { display: block; max-width: 100%; height: auto; }                                     /* never stretched */
html[data-sb="mini"] .sb-brand .logo-plate { padding: 5px 4px !important; }
html[data-sb="mini"] .sb-brand .logo { width: 48px; }

/* ---------- page parts (secondary pages) ---------- */
.panel.flush { padding: 0; }
.panel.flush > .empty { padding: 32px 16px; }
.panel-head.pad { padding: 14px 16px 0; }
.panel.narrow { max-width: 640px; }
.panel + .panel { margin-block-start: 0; }
@media (min-width: 1100px) { .cols.three { grid-template-columns: 1fr 1fr 1fr; } }
.kpis.two { grid-template-columns: 1fr 1fr; max-width: 560px; }
.tbl { overflow-x: auto; position: relative; -webkit-overflow-scrolling: touch; }
.tbl + .tbl { margin-block-start: 16px; }
.panel.flush .tbl th:first-child, .panel.flush .tbl td:first-child { padding-inline-start: 16px; }
.panel.flush .tbl th:last-child, .panel.flush .tbl td:last-child { padding-inline-end: 16px; }
thead th { background: var(--surface-2); }
tfoot th { color: var(--ink); font-weight: 600; border-block-start: 1px solid var(--line-strong); border-block-end: 0; }
td.wrap { white-space: normal; min-width: 260px; }
td.wrap.tight { min-width: 14ch; overflow-wrap: anywhere; } table:has(td.tight) th, table:has(td.tight) td:last-child { white-space: normal; } table:has(td.tight) .tag { white-space: normal; line-height: 18px; padding-block: 2px; }   /* V1-07: names in narrow panels wrap instead of pushing the numbers out */
td.actions { white-space: nowrap; } td.actions form.inline { flex-wrap: nowrap; }
.w5 { font-weight: 500; } .small { font-size: 12.5px; } .neg { color: var(--negative); }
.ok-mark { color: var(--positive); display: inline-flex; }
.search { display: flex; gap: 6px; } .search input { min-width: 220px; }
.title-row > form, .title-row > nav { align-self: center; }
.row-between { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.addrow { margin: 12px 0 0; padding-block-start: 12px; border-block-start: 1px dashed var(--line); }
.check { margin: 12px 0; }
.toc { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-block-end: var(--gap); font-size: 13.5px; }
.toc a { color: var(--ink-2); }
.setting { display: grid; grid-template-columns: minmax(200px, 30%) 1fr auto; gap: 10px; align-items: start; padding-block: 8px; border-block-end: 1px solid var(--line); margin: 0; }
.setting:last-child { border-block-end: 0; }
.setting label { padding-block-start: 7px; font-size: 13px; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 12px 24px; margin: 0 0 12px; align-items: center; }
.facts dt { color: var(--ink-2); font-size: 14px; } .facts dd { margin: 0; }
.tag .icon { width: 14px; height: 14px; vertical-align: -3px; }
.btn.block { display: flex; width: 100%; }
.qr { background: #fff; padding: 12px; border-radius: var(--radius-md); text-align: center; margin-block-end: 12px; }
.qr svg { max-width: 220px; height: auto; }
.banner.inset { margin: 8px 0 0; }
.pad-x { padding-inline: 16px; padding-block-end: 14px; }
.click-row { display: flex; gap: 16px; align-items: flex-start; }
.small-qr { width: 132px; flex: none; padding: 6px; margin: 0; } .small-qr svg { width: 120px; height: 120px; }
#wa-budget .track { margin-block-end: 12px; }
.cols + .inbox { margin-block-start: var(--gap); }

/* feed: alerts, threads */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-block-end: 1px solid var(--line); }
.feed li:last-child { border-block-end: 0; }
.feed li.done { opacity: .7; }
.feed-body { flex: 1; min-width: 0; } .feed-body p { margin: 2px 0 4px; font-size: 14px; }
.feed-act { flex: none; }
.feed li[aria-current] { background: var(--blue-soft); }

/* inbox + chat */
.inbox { display: grid; gap: var(--gap); align-items: start; }
@media (min-width: 900px) { .inbox { grid-template-columns: minmax(240px, 1fr) 2fr; } }
.inbox > .panel { margin: 0; }
.thread { flex: 1; min-width: 0; color: var(--ink); text-decoration: none; display: grid; gap: 2px; }
.thread span { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread:hover b { text-decoration: underline; }
.conv { display: flex; flex-direction: column; }
.chatlog { display: flex; flex-direction: column; min-height: 240px; }
.chat .chatlog { min-height: 50vh; }
.chatlog .empty { margin: auto 0; }
.msg-meta { display: block; font-size: 11px; opacity: .75; margin-block-start: 4px; }
.msg-actions { margin: 8px 0 0; }
.compose { margin: 12px 0 0; padding-block-start: 12px; border-block-start: 1px solid var(--line); }
.compose input[name="message"] { flex: 1; min-width: 200px; }
.msg { align-self: flex-start; } .msg.user { align-self: flex-end; margin-inline-start: 0; }


/* ---------- tablet: sidebar is a rail of icons unless the user expands it ---------- */
@media (max-width: 1100px) { .cmdk-open { width: 44px; padding: 0; justify-content: center; } .cmdk-open .cmdk-ph, .cmdk-open kbd { display: none; } }

/* ---------- phone (< 768 px): slide-in drawer + bottom bar ---------- */
@media (max-width: 767.98px) {
  body.app, html[data-sb="mini"] body.app { display: block; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); height: 100dvh; transform: translateX(-104%); visibility: hidden;
    box-shadow: var(--shadow-2); background: var(--glass-2); transition: transform var(--t-slow) var(--ease), visibility 0s linear var(--t-slow); }
  [dir="rtl"] .sidebar { transform: translateX(104%); }
  html[data-drawer="open"] .sidebar { transform: none; visibility: visible; transition: transform var(--t-slow) var(--ease); }
  html[data-drawer="open"] .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(3, 8, 20, .5); animation: fade-in var(--t) var(--ease); }
  /* the drawer always shows labels, whatever the desktop setting */
  html[data-sb="mini"] .sb-name, html[data-sb="mini"] .sb-gtitle, html[data-sb="mini"] .sb-label { position: static; width: auto; height: auto; clip: auto; overflow: hidden; }
  html[data-sb="mini"] .sb-nav a { justify-content: flex-start; padding-inline: 12px; gap: 12px; }
  html[data-sb="mini"] .sb-nav .badge { position: static; min-width: 22px; height: 20px; font-size: 11.5px; line-height: 20px; }
  html[data-sb="mini"] .sb-head { justify-content: space-between; padding-inline: 16px; }
  html[data-sb="mini"] .sb-brand .logo { width: auto; }
  html[data-sb="mini"] .sb-group + .sb-group { border: 0; padding: 0; margin-block-start: 14px; }
  .sidebar .sb-close { display: inline-grid; } .sb-foot { display: none; }
  .topbar .tb-menu { display: inline-grid; margin-inline-start: -8px; }
  .topbar { padding: 8px 16px; gap: 6px; min-height: 56px; }
  .crumb-group, .crumbs .chev { display: none; }
  .crumb-here { font-size: 16px; }
  .tb-tools { gap: 0; } .tb-tools .lang { display: none; }
  .demo-badge { font-size: 11px; padding: 2px 8px; }
  main { padding: 18px 16px calc(var(--bottom-h) + 28px + env(safe-area-inset-bottom)); }
  .bottombar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; inset-inline: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 22;
    height: var(--bottom-h); padding: 6px; border-radius: var(--radius-lg); background: var(--glass-2); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-2), var(--glass-hi); }
  .bottombar a, .bottombar button { position: relative; display: grid; place-items: center; align-content: center; gap: 2px; min-width: 44px; min-height: 44px; border-radius: var(--radius-md);
    color: var(--ink-2); text-decoration: none; font: 500 11px/1.2 var(--font); border: 0; background: none; cursor: pointer; padding: 0 2px; }
  .bottombar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottombar [aria-current="page"] { color: var(--ink); background: var(--blue-soft); }
  .bottombar [aria-current="page"] .icon { color: var(--blue); }
  .bottombar .dot { position: absolute; top: 6px; inset-inline-end: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--hot); }
  .trow { grid-template-columns: 1fr auto; } .trow .track { grid-column: 1 / -1; grid-row: 2; }
  th, td { padding: 9px 8px; }
  .setting { grid-template-columns: 1fr; }
  .search { width: 100%; } .search input { min-width: 0; flex: 1; }
  .feed li { flex-wrap: wrap; }
  .card, .panel { padding: 16px; border-radius: var(--radius); }
  .panel.flush { padding: 0; }
  .btn, .iconbtn, .tabs a { min-height: 44px; }
  .iconbtn { width: 44px; height: 44px; }
  .cmdk { margin-top: 10px; width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
}
@media (max-width: 479.98px) { .crumbs { visibility: hidden; } }   /* the page heading sits right below: no squeezed duplicate */
@media (max-width: 380px) { .tb-tools #theme-toggle { display: none; } }

/* ---------- motion: short, eased, and off under prefers-reduced-motion ---------- */
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { transform: translateX(100%); } }
[dir="rtl"] .skeleton::after { animation-direction: reverse; }
@media (hover: hover) { .card:hover, .panel:hover, .kpis:hover { box-shadow: var(--shadow-2), var(--glass-hi); } .card, .panel, .kpis { transition: box-shadow var(--t) var(--ease); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* =====================================================================================================================
   V1-04 page components
   ===================================================================================================================== */
/* page header: title + one line + actions on one line, related pages as chips */
.title-row h1 + .answer { margin-block-start: 6px; }
.title-row > :last-child:not(:first-child) { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -10px 0 22px; }
.chips a { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px; border-radius: var(--pill); border: 1px solid var(--line-strong); background: var(--glass-1);
  color: var(--ink-2); text-decoration: none; font-size: 13px; transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t) var(--ease); }
.chips a:hover { color: var(--ink); border-color: color-mix(in srgb, var(--blue) 45%, var(--line-strong)); box-shadow: 0 0 0 3px var(--blue-soft); }

/* KPI row: separate floating glass cards (Cubee), big confident numbers */
.kpis { gap: 14px; background: none; border: 0; box-shadow: none; overflow: visible; -webkit-backdrop-filter: none; backdrop-filter: none; }
.kpi { margin: 0; border: 1px solid var(--glass-edge); border-radius: var(--radius-lg); background: var(--glass-1); box-shadow: var(--shadow-1), var(--glass-hi);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.25); backdrop-filter: blur(var(--blur)) saturate(1.25); position: relative; overflow: hidden;
  transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease); }
.kpi.lead { background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--blue) 18%, transparent), transparent 60%), var(--glass-1);
  border-color: color-mix(in srgb, var(--blue) 30%, var(--glass-edge)); }
@media (hover: hover) { .kpi:hover { box-shadow: var(--shadow-2), var(--glass-hi); transform: translateY(-1px); } }
.k-top { display: flex; align-items: center; gap: 10px; margin-block-end: 6px; }
.k-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); flex: none; }
.k-ic .icon { width: 18px; height: 18px; }
.kpi.lead .k-ic { color: var(--blue); background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 25%, transparent); box-shadow: 0 0 18px -4px var(--glow); }
.kpi.gold .k-ic { color: var(--gold); background: var(--gold-soft); border-color: transparent; }
.kpi.hot .k-ic { color: var(--hot); background: var(--hot-soft); border-color: transparent; }
.kpi a.k-link { position: absolute; inset: 0; border-radius: inherit; }
.kpi a.k-link:focus-visible { box-shadow: var(--focus) inset; }
.kpis.two { max-width: 640px; }

/* radial gauges (production vs target per line) */
.gauges { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 18px 12px; }
.gauge { margin: 0; display: grid; justify-items: center; gap: 10px; text-align: center; }
.g-ring { position: relative; width: min(132px, 100%); aspect-ratio: 1; }
.g-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
[dir="rtl"] .g-ring svg { transform: rotate(-90deg) scaleY(-1); }
.g-track { fill: none; stroke: var(--surface-3); stroke-width: 10; }
.g-fill { fill: none; stroke: var(--series-1); stroke-width: 10; stroke-linecap: round; stroke-dasharray: var(--p) 100; filter: drop-shadow(0 0 6px var(--glow));
  animation: gauge-in 900ms var(--ease) both; }
.gauge.low .g-fill { stroke: var(--warning); filter: none; }
.gauge.none .g-fill { stroke: transparent; }
.g-target { stroke: var(--gold-fill); stroke-width: 3; stroke-linecap: round; transform: rotate(90deg); transform-origin: 60px 60px; }
.g-c { position: absolute; inset: 0; display: grid; place-content: center; gap: 2px; }
.g-c b { font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em; }
.g-c small { font-size: 12px; color: var(--ink-2); }
.gauge figcaption { font-size: 14px; font-weight: 500; line-height: 1.35; }
.gauge figcaption small { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-2); }
@keyframes gauge-in { from { stroke-dasharray: 0 100; } }

/* the "waiting for you" list with action buttons */
.todo li { align-items: center; gap: 12px; }
.todo .t-text { flex: 1; min-width: 0; }
.todo .t-act { display: flex; gap: 6px; flex: none; }
.todo .t-act form { margin: 0; }

/* greeting */
.hello { margin-block-end: 22px; }
.hello .hello-date { color: var(--ink-2); font-size: 14px; margin: 0 0 4px; }
.hello h1 { font-size: 30px; }
.hello .answer { font-size: 15px; color: var(--ink-2); margin: 8px 0 0; max-width: 80ch; }
.hello .answer b { color: var(--ink); font-weight: 600; }
@media (max-width: 767.98px) { .hello h1 { font-size: 24px; } }

/* 12-column grid of cards */
.grid-12 { display: grid; gap: var(--gap); grid-template-columns: repeat(12, minmax(0, 1fr)); margin-block-end: var(--gap); }
.grid-12 > * { grid-column: span 12; margin: 0; min-width: 0; }
@media (min-width: 1024px) { .grid-12 > .span-8 { grid-column: span 8; } .grid-12 > .span-7 { grid-column: span 7; } .grid-12 > .span-6 { grid-column: span 6; } .grid-12 > .span-5 { grid-column: span 5; } .grid-12 > .span-4 { grid-column: span 4; } }

/* empty states */
.empty { display: grid; justify-items: center; gap: 4px; padding: 32px 16px; }
.empty-ic { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3); margin-block-end: 8px; }
.empty b { margin: 0; }

/* tables: sticky header, toolbar (search + count), sortable headers, pagination (app.js enhances any long table) */
.tbl { max-height: min(72vh, 760px); overflow: auto; overscroll-behavior: contain; }
.tbl thead th { position: sticky; top: 0; z-index: 1; background: var(--th-bg, #f4f6fa); box-shadow: inset 0 -1px 0 var(--line); }
.tbl-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 12px 16px; border-block-end: 1px solid var(--line); }
.panel:not(.flush) > .tbl-bar { padding-inline: 0; padding-block-start: 0; }
.tbl-bar .tb-search { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 220px; max-width: 360px; position: relative; }
.tbl-bar .tb-search .icon { position: absolute; inset-inline-start: 12px; color: var(--ink-3); pointer-events: none; }
.tbl-bar input { width: 100%; padding-inline-start: 38px; border-radius: var(--pill); min-height: 38px; }
.tbl-bar .tb-count { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
th[aria-sort] { padding: 0; }
th .th-sort { display: flex; align-items: center; gap: 4px; width: 100%; padding: 11px 12px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: start; white-space: nowrap; }
th.n .th-sort { justify-content: flex-end; }
th .th-sort:hover { color: var(--ink); }
th .th-sort::after { content: ""; width: 0; height: 0; border-inline: 4px solid transparent; border-block-end: 5px solid currentColor; opacity: 0; transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
th[aria-sort="ascending"] .th-sort::after { opacity: .8; }
th[aria-sort="descending"] .th-sort::after { opacity: .8; transform: rotate(180deg); }
th[aria-sort="none"] .th-sort:hover::after { opacity: .35; }
.tbl-pages { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-block-start: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.panel:not(.flush) > .tbl-pages { padding-inline: 0; padding-block-end: 0; }
.tbl-pages .btn { min-height: 32px; }
tr.tb-hide { display: none; }
td.actions { text-align: end; }
td.actions.stack { white-space: normal; min-width: 15ch; } td.actions.stack .btn { margin: 2px 0; }   /* V1-07: several links per row wrap instead of widening the table */

/* status chips carry a dot */
.tag.ok::before, .tag.warning::before, .tag.pending::before, .tag.critical::before, .tag.rejected::before, .tag.disabled::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-inline-end: 6px; vertical-align: 1px; }

/* board view (projects, maintenance) */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: start; margin-block-end: var(--gap); }   /* wraps: never scrolls sideways */
.b-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.b-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px; font-size: 13.5px; font-weight: 600; }
.b-head .num { color: var(--ink-3); font-weight: 500; }
.b-card { display: grid; gap: 6px; padding: 14px; border-radius: var(--radius-md); background: var(--glass-1); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-1), var(--glass-hi);
  color: var(--ink); text-decoration: none; transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease); }
a.b-card:hover { box-shadow: var(--shadow-2), var(--glass-hi); transform: translateY(-1px); }
.b-card .b-meta { font-size: 12.5px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.b-card .track { height: 6px; }
.b-card form { margin: 0; }
.b-empty { font-size: 13px; color: var(--ink-3); padding: 10px 4px; }
@media (max-width: 767.98px) { .board { grid-template-columns: 1fr; } }

/* assistant: "Ask ... anything" composer (Foreman) */
.ask { border-radius: var(--radius-lg); background: var(--glass-2); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-2), var(--glass-hi); padding: 14px 14px 10px; margin: 12px 0 0; }
.ask textarea { border: 0; background: none; resize: none; min-height: 52px; font-size: 16px; padding: 4px 6px; }
.ask textarea:focus-visible { box-shadow: none; }
.ask:focus-within { box-shadow: var(--shadow-2), 0 0 0 3px var(--blue-soft), var(--glass-hi); }
.ask-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ask-bar .btn { width: 44px; height: 44px; padding: 0; border-radius: 14px; }
[dir="rtl"] .ask-bar .btn .icon { transform: scaleX(-1); }
.ask-hint { font-size: 12.5px; color: var(--ink-3); }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.suggest button { min-height: 34px; padding: 4px 12px; border-radius: var(--pill); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-2); font-size: 13px; cursor: pointer; }
.suggest button:hover { color: var(--ink); border-color: color-mix(in srgb, var(--blue) 45%, var(--line-strong)); }
.chat .chatlog { min-height: 46vh; max-height: 62vh; overflow-y: auto; padding: 4px 2px 12px; }
.chat-wrap { max-width: 920px; margin-inline: auto; }

/* phone: tables become cards, KPIs two per row */
@media (max-width: 767.98px) {
  .tbl.cards { max-height: none; overflow: visible; }
  .tbl.cards table, .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: 100%; }
  .tbl.cards thead { display: none; }
  .tbl.cards tr { padding: 12px 16px; border-block-end: 1px solid var(--line); }
  .tbl.cards tr.tb-hide { display: none; }
  .tbl.cards td { border: 0; padding: 3px 0; white-space: normal; display: flex; justify-content: space-between; gap: 12px; text-align: end; }
  .tbl.cards td::before { content: attr(data-label); color: var(--ink-3); font-size: 12.5px; text-align: start; flex: none; max-width: 48%; font-family: var(--font); font-weight: 400; letter-spacing: 0; }
  /* V1-07: code cells (.mono) are left-to-right; on Arabic pages keep their label on the right like every other row */
  [dir="rtl"] .tbl.cards td.mono { flex-direction: row-reverse; }
  .tbl.cards td:first-child { font-size: 15px; padding-block-end: 6px; }
  .tbl.cards td:first-child::before, .tbl.cards td.actions::before { display: none; }
  .tbl.cards td.actions { justify-content: flex-start; padding-block-start: 8px; flex-wrap: wrap; }
  .tbl.cards tfoot tr { display: flex; justify-content: space-between; }
  .tbl.cards tfoot th { border: 0; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi.lead { grid-column: 1 / -1; }
  .gauges { grid-template-columns: repeat(2, 1fr); }
}

/* reports and invoices centre (V1-06) */
.rep-group { margin-block-end: 28px; }
.rep-gtitle { font-size: 15px; color: var(--ink-2); font-weight: 600; margin: 0 0 12px; }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.rep-card { margin: 0; display: flex; flex-direction: column; gap: 14px; }
.rep-card.focus { border-color: color-mix(in srgb, var(--blue) 45%, var(--glass-edge)); box-shadow: 0 0 0 3px var(--blue-soft), var(--shadow-2); }
.rep-head { display: flex; gap: 12px; align-items: flex-start; }
.rep-head h3 { margin: 2px 0 2px; font-size: 15px; }
.rep-head p { margin: 0; }
.rep-form { display: flex; flex-direction: column; gap: 12px; margin: 0; flex: 1; justify-content: flex-end; }
.rep-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.rep-f { display: grid; gap: 4px; font-size: 12.5px; color: var(--ink-3); min-width: 0; }
.rep-f input, .rep-f select { width: 100%; min-width: 0; }
.rep-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.rep-send { margin: 0 0 18px; padding-block-end: 18px; border-block-end: 1px solid var(--line); display: grid; gap: 10px; justify-items: start; }
.rep-send:last-child { border: 0; margin: 0; padding: 0; }
.rep-send h3 { display: flex; align-items: center; gap: 8px; margin: 0; }
.rep-send .rep-f { min-width: 220px; }
@media (max-width: 767.98px) { .rep-grid { grid-template-columns: 1fr; } .rep-actions .btn { flex: 1 1 auto; } }

/* ---------- print (reports) ---------- */
@media print {
  :root { --bg: #fff; --bg-image: none; --ground: #fff; --surface: #fff; --glass-1: #fff; --line: #bbb; --ink: #000; --ink-2: #333; }
  body.app { display: block; }
  .sidebar, .topbar, .bottombar, .scrim, .cmdk, .shell-tools, form, .btn, .tabs, .table-view summary, .demo-badge { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main { max-width: none; padding: 0; animation: none; }
  .card, .panel, .kpis { border-color: #999; break-inside: avoid; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .table-view[open] > *, .table-view > table { display: table !important; }
  a { color: #000; text-decoration: none; }
}

/* V2-02: split between the two steel lines (oiled in gold, black in slate) */
.sline { background: var(--glass-1); border: 1px solid var(--glass-edge); border-radius: var(--radius-lg); padding: 16px 18px; margin-block-end: 16px; }
.sline-head .l { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.sline-bar { display: flex; height: 10px; border-radius: var(--pill); overflow: hidden; background: var(--surface-2); margin: 10px 0 12px; }
.sline-bar span { display: block; height: 100%; transition: width var(--t-slow) var(--ease); }
.sl-oiled { background: var(--gold-fill); }
.sl-black { background: var(--ink-2); }
.sline-vals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 0; }
.sline-vals div { min-width: 0; }
.sline-vals dt { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.sline-vals dd { margin: 2px 0 0; font-size: 18px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.sline-vals dd small { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-inline-start: 6px; }
.sl-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
@media (prefers-reduced-motion: reduce) { .sline-bar span { transition: none; } }

/* V2-04: finance page (partners, how net profit is built) */
.tag.private { display: inline-flex; align-items: center; gap: 6px; background: var(--gold-soft); color: var(--gold); border-color: transparent; font-weight: 600; }
.tag.private .icon { width: 14px; height: 14px; }
.partners { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-block-end: 10px; }
.partner { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--surface-2); }
.partner h3 { margin: 0 0 10px; font-size: 18px; }
.partner dl, .fin-steps { margin: 0; padding: 0; }
.partner dl div, .fin-steps li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-block-end: 1px solid var(--line); }
.partner dt, .fin-steps span { color: var(--ink-2); font-size: 14px; min-width: 0; }
.partner dd { margin: 0; font-weight: 600; white-space: nowrap; }
.partner .total, .fin-steps .total { border-block-end: 0; padding-block-start: 10px; }
.partner .total dt, .partner .total dd, .fin-steps .total span, .fin-steps .total b { color: var(--ink); font-weight: 700; font-size: 16px; }
.fin-steps { list-style: none; }
.fin-steps b { white-space: nowrap; font-weight: 600; }
.fin-sources { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); }
tr.total td { font-weight: 700; color: var(--ink); }
.fin-runs { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.fin-runs dd { font-size: 14px; white-space: normal; }
