/* Fahad AI Office — UX & Workflow V2.
   Design tokens first; every component below uses only these variables.
   The final visual identity (V3) replaces the token values, not the rules. */

/* ---------------------------------------------------------------- Premium tokens (V2.0)
   Calm, warm and minimal: an Apple-like neutral canvas with one bronze/gold
   accent. Dark is deep graphite (never pure black); light is a real light
   design, not an inversion. Colour, type, spacing, radii, depth, materials,
   motion, z-index, status and employee colours all live here; components
   use only these variables. Text colours meet 4.5:1 on the rendered
   surfaces; --text-decor is decorative only. */
:root {
  /* colour — dark (default; light follows the system or Settings) */
  --bg: #151514;
  --bg-elevated: #1b1b19;
  --surface: #20201e;
  --surface-2: #272724;
  --surface-3: #33332f;
  --surface-glass: rgba(28, 28, 30, .94);
  --material: rgba(44, 44, 46, .55);
  --material-solid: #20201e;
  --nav-material: rgba(21, 21, 20, .78);
  --hairline: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #f5f5f7;
  --text-muted: #aeaeb2;
  --text-faint: #98989d;
  --text-decor: #8e8e93;
  --accent: #c9a063;
  --accent-strong: #ddb97a;
  --accent-fill: #c9a063;
  --accent-soft: rgba(212, 175, 106, .12);
  --on-accent: #111113;
  --gold: #d4af6a;
  --success: #86c79f;
  --success-soft: rgba(134, 199, 159, .12);
  --warning: #e3b866;
  --warning-soft: rgba(227, 184, 102, .13);
  --danger: #ff8a8a;
  --danger-soft: rgba(255, 138, 138, .12);
  --info: #9fb2c6;
  --info-soft: rgba(143, 163, 184, .13);
  --code-bg: #0c0c0e;
  --scrim: rgba(5, 5, 6, .56);
  --floor-a: #16171a;
  --floor-b: #1b1c20;
  --floor-line: rgba(255, 255, 255, .045);
  --desk-top: #22242a;
  --desk-edge: #2c2e35;
  --screen: #0b0c0e;
  --screen-line: rgba(255, 255, 255, .16);
  --glow: rgba(212, 175, 106, .24);
  --glow-warm: rgba(201, 160, 99, .11);
  --focus: 0 0 0 3px rgba(201, 160, 99, .5);

  /* status (visual state of employees and work) */
  --st-available: #98989d;
  --st-thinking: #c9a063;
  --st-working: #d4af6a;
  --st-testing: #9fb2c6;
  --st-waiting: #e3b866;
  --st-reviewing: #c9a063;
  --st-needs: #e3b866;
  --st-blocked: #ff8a8a;
  --st-completed: #86c79f;

  /* employees — UI-only identity tints, keyed by agent slug (small dots,
     avatar tints and highlights only; never large backgrounds) */
  --emp-chief: #d4af6a; --emp-research: #c08a5e; --emp-product: #8fa3b8; --emp-finance: #a9a872; --emp-coding: #7d8b98;
  --emp-audit: #d9b86e; --emp-social: #bf8676; --emp-creative: #d09aa5; --emp-legal: #a8a39c; --emp-neutral: #8e8e93;

  /* spacing (4px base) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  /* typography — IBM Plex Sans Arabic for Arabic, Inter for Latin, JetBrains
     Mono for numbers, dates and technical values (unicode-range keeps each
     script in its own face, so mono numerals never break Arabic text) */
  --font: "Inter", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Noto Sans Arabic", Arial, sans-serif;
  --font-display: "Inter", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, -apple-system, "SF Pro Display", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 12px; --fs-sm: 13.5px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 30px; --fs-3xl: 40px;
  --fs-display: clamp(30px, 2.2rem + 1.4vw, 46px);
  --lh: 1.6; --lh-tight: 1.2;
  --tracking-tight: -.02em; --tracking-caps: .08em;

  /* shape, depth, materials */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 18px; --r-2xl: 22px; --r-full: 999px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, .32), 0 1px 2px rgba(0, 0, 0, .24);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, .42), 0 2px 6px rgba(0, 0, 0, .28);
  --shadow-soft: 0 1px 1px rgba(0, 0, 0, .18), 0 8px 24px rgba(0, 0, 0, .22);
  --blur: saturate(180%) blur(20px);

  /* motion — press, hover, state change; critically damped, never bouncy */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
  --ease-spring: cubic-bezier(.23, 1, .32, 1);
  --t-press: 100ms; --t-fast: 150ms; --t-base: 200ms; --t-slow: 250ms; --t-scene: 600ms; --t-handoff: 1800ms;

  /* layers */
  --z-base: 1; --z-sticky: 10; --z-overlay: 30; --z-drawer: 40; --z-modal: 50; --z-toast: 60;

  /* The Office overlay (Final Design Spec §08, §10, §13): frosted ivory by day,
     smoked ink at night, following the scene's lighting phase rather than the
     Hub theme. Red only for attention. AA contrast on both surfaces. */
  --ov-day-surface: rgba(248, 245, 239, .8); --ov-day-surface-strong: rgba(250, 248, 244, .95); --ov-day-border: rgba(29, 27, 24, .1); --ov-day-text: #1d1b18; --ov-day-muted: #625b51; --ov-day-rule: rgba(29, 27, 24, .14);
  --ov-night-surface: rgba(20, 22, 26, .74); --ov-night-surface-strong: rgba(22, 24, 29, .94); --ov-night-border: rgba(236, 230, 218, .13); --ov-night-text: #ece6da; --ov-night-muted: #aaa396; --ov-night-rule: rgba(236, 230, 218, .15);
  --ov-working-day: #2a62c9; --ov-working-night: #7aa5f2; --ov-done-day: #23784b; --ov-done-night: #6cc093; --ov-attention-day: #bf3a32; --ov-attention-night: #f2726a;
  --ov-caution-day: #8a5f0c; --ov-caution-night: #e3b04d; --ov-neutral-day: #7b7468; --ov-neutral-night: #9d968a;
  --ov-ease: cubic-bezier(.22, 1, .36, 1); --ov-hover: 120ms; --ov-press: 80ms; --ov-select: 180ms; --ov-panel: 280ms; --ov-state: 400ms;

  /* layout */
  --sidebar-w: 256px;
  --content-w: 880px;
  --page-w: 1200px;
  --nav-h: 76px;
  --tabbar-h: 64px;
}

/* Light — follows the system unless Fahad picks one in Settings. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #faf9f6; --bg-elevated: #fdfcf9; --surface: #ffffff; --surface-2: #f4f2ed; --surface-3: #e9e6df; --surface-glass: rgba(253, 252, 249, .88);
    --material: rgba(255, 255, 255, .82); --material-solid: #ffffff; --nav-material: rgba(250, 249, 246, .8); --hairline: rgba(255, 255, 255, .85);
    --border: rgba(29, 29, 31, .08); --border-strong: rgba(29, 29, 31, .14); --text: #1d1d1f; --text-muted: #515154; --text-faint: #6e6e73; --text-decor: #7a7a7f;
    --accent: #80642f; --accent-strong: #624b23; --accent-fill: #80642f; --accent-soft: rgba(176, 141, 87, .09); --on-accent: #ffffff; --gold: #997a3e;
    --success: #2f6b45; --success-soft: rgba(47, 107, 69, .09); --warning: #8a600f; --warning-soft: rgba(176, 141, 87, .14);
    --danger: #b4232f; --danger-soft: rgba(180, 35, 47, .08); --info: #4f5b66; --info-soft: rgba(79, 91, 102, .09);
    --code-bg: #f2f2f4; --scrim: rgba(29, 29, 31, .26);
    --floor-a: #eeeef2; --floor-b: #e7e7ec; --floor-line: rgba(0, 0, 0, .05); --desk-top: #ffffff; --desk-edge: #dcdce2; --screen: #1c1d21; --screen-line: rgba(255, 255, 255, .22); --glow: rgba(176, 141, 87, .2); --glow-warm: rgba(176, 141, 87, .15);
    --st-available: #6e6e73; --st-thinking: #7a5a3a; --st-working: #8a6a2f; --st-testing: #4f5b66; --st-waiting: #8a600f; --st-reviewing: #7a5a3a; --st-needs: #8a600f; --st-blocked: #b4232f; --st-completed: #2f6b45;
    --emp-chief: #8a6a2f; --emp-research: #a47148; --emp-product: #6b7c8f; --emp-finance: #8c8c5a; --emp-coding: #4f5b66; --emp-audit: #c2a15e; --emp-social: #9c6b5e; --emp-creative: #b5838d; --emp-legal: #8e8a84; --emp-neutral: #8e8e93;
    --shadow-1: 0 1px 2px rgba(29, 29, 31, .05); --shadow-2: 0 10px 28px rgba(29, 29, 31, .07), 0 1px 2px rgba(29, 29, 31, .04); --shadow-3: 0 24px 56px rgba(29, 29, 31, .12), 0 2px 6px rgba(29, 29, 31, .05); --shadow-soft: 0 1px 1px rgba(29, 29, 31, .03), 0 8px 24px rgba(29, 29, 31, .05);
    --focus: 0 0 0 3px rgba(122, 90, 58, .32);
  }
}
:root[data-theme="light"] {
    --bg: #faf9f6; --bg-elevated: #fdfcf9; --surface: #ffffff; --surface-2: #f4f2ed; --surface-3: #e9e6df; --surface-glass: rgba(253, 252, 249, .88);
    --material: rgba(255, 255, 255, .82); --material-solid: #ffffff; --nav-material: rgba(250, 249, 246, .8); --hairline: rgba(255, 255, 255, .85);
    --border: rgba(29, 29, 31, .08); --border-strong: rgba(29, 29, 31, .14); --text: #1d1d1f; --text-muted: #515154; --text-faint: #6e6e73; --text-decor: #7a7a7f;
    --accent: #80642f; --accent-strong: #624b23; --accent-fill: #80642f; --accent-soft: rgba(176, 141, 87, .09); --on-accent: #ffffff; --gold: #997a3e;
    --success: #2f6b45; --success-soft: rgba(47, 107, 69, .09); --warning: #8a600f; --warning-soft: rgba(176, 141, 87, .14);
    --danger: #b4232f; --danger-soft: rgba(180, 35, 47, .08); --info: #4f5b66; --info-soft: rgba(79, 91, 102, .09);
    --code-bg: #f2f2f4; --scrim: rgba(29, 29, 31, .26);
    --floor-a: #eeeef2; --floor-b: #e7e7ec; --floor-line: rgba(0, 0, 0, .05); --desk-top: #ffffff; --desk-edge: #dcdce2; --screen: #1c1d21; --screen-line: rgba(255, 255, 255, .22); --glow: rgba(176, 141, 87, .2); --glow-warm: rgba(176, 141, 87, .15);
    --st-available: #6e6e73; --st-thinking: #7a5a3a; --st-working: #8a6a2f; --st-testing: #4f5b66; --st-waiting: #8a600f; --st-reviewing: #7a5a3a; --st-needs: #8a600f; --st-blocked: #b4232f; --st-completed: #2f6b45;
    --emp-chief: #8a6a2f; --emp-research: #a47148; --emp-product: #6b7c8f; --emp-finance: #8c8c5a; --emp-coding: #4f5b66; --emp-audit: #c2a15e; --emp-social: #9c6b5e; --emp-creative: #b5838d; --emp-legal: #8e8a84; --emp-neutral: #8e8e93;
    --shadow-1: 0 1px 2px rgba(29, 29, 31, .05); --shadow-2: 0 10px 28px rgba(29, 29, 31, .07), 0 1px 2px rgba(29, 29, 31, .04); --shadow-3: 0 24px 56px rgba(29, 29, 31, .12), 0 2px 6px rgba(29, 29, 31, .05); --shadow-soft: 0 1px 1px rgba(29, 29, 31, .03), 0 8px 24px rgba(29, 29, 31, .05);
    --focus: 0 0 0 3px rgba(122, 90, 58, .32);
}
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("./fonts/inter-latin-var.woff2?v=f798ee36866c") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 400; font-display: swap; src: url("./fonts/plex-arabic-400.woff2?v=f798ee36866c") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 500; font-display: swap; src: url("./fonts/plex-arabic-500.woff2?v=f798ee36866c") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 600; font-display: swap; src: url("./fonts/plex-arabic-600.woff2?v=f798ee36866c") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 700; font-display: swap; src: url("./fonts/plex-arabic-700.woff2?v=f798ee36866c") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url("./fonts/jetbrains-mono-latin-var.woff2?v=f798ee36866c") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2212; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs-md)/var(--lh) var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-feature-settings: "cv11", "ss01"; }
.num, .tabular { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: var(--tracking-tight); line-height: var(--lh-tight); }
[dir="rtl"], :lang(ar) { letter-spacing: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.mono { font-family: var(--mono); }
.row { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: var(--s-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: var(--s-3); }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 36px; padding: 0 var(--s-4); border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-success { background: var(--success); border-color: var(--success); color: var(--bg); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 30px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn-lg { min-height: 44px; padding: 0 var(--s-6); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); border: 1px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 16px; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.input { width: 100%; min-height: 40px; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input-sm { min-height: 34px; font-size: var(--fs-sm); }
textarea.input { resize: vertical; line-height: var(--lh); }
.field-label { display: block; margin: var(--s-3) 0 var(--s-1); font-size: var(--fs-sm); color: var(--text-muted); font-weight: 600; }
.form-error { color: var(--danger); font-size: var(--fs-sm); margin: var(--s-2) 0; }

/* ---------------------------------------------------------------- badges */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em; background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.running, .pill.active, .pill.queued { background: var(--info-soft); color: var(--info); }
.pill.attention, .pill.awaiting_approval, .pill.blocked, .pill.cooldown { background: var(--warning-soft); color: var(--warning); }
.pill.completed, .pill.available { background: var(--success-soft); color: var(--success); }
.pill.failed, .pill.account { background: var(--danger-soft); color: var(--danger); }
.pill.cancelled, .pill.unavailable { background: var(--surface-3); color: var(--text-faint); }
.count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: var(--r-full); background: var(--surface-3); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 700; text-align: center; line-height: 20px; }
.count-alert { background: var(--warning); color: #1a1204; }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-4) var(--s-5); box-shadow: var(--shadow-1); }
.card + .card { margin-top: var(--s-4); }
.card-title { margin: 0 0 var(--s-3); font-size: var(--fs-md); font-weight: 700; }
.section-title { margin: var(--s-6) 0 var(--s-3); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
.empty { padding: var(--s-8) var(--s-4); text-align: center; color: var(--text-muted); }
.empty h3 { margin: 0 0 var(--s-2); color: var(--text); font-size: var(--fs-lg); }
.list-item { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; }
.list-item + .list-item { margin-top: var(--s-2); }
.list-item:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.list-item .title { font-weight: 600; overflow-wrap: anywhere; }
.list-item .sub { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s-3); }
.kv div { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); min-width: 0; }
.kv dt { font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.kv dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.tabs { display: flex; gap: var(--s-1); overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: var(--s-4); scrollbar-width: none; }
.tab { padding: var(--s-2) var(--s-3); border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-muted); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
details.disclosure { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
details.disclosure + details.disclosure { margin-top: var(--s-2); }
details.disclosure > summary { cursor: pointer; padding: var(--s-3) var(--s-4); font-weight: 600; font-size: var(--fs-sm); color: var(--text-muted); list-style: none; }
details.disclosure > summary::before { content: "▸ "; }
details.disclosure[open] > summary::before { content: "▾ "; }
details.disclosure > .disclosure-body { padding: 0 var(--s-4) var(--s-4); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { text-align: left; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--text-faint); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.toast { position: fixed; bottom: var(--s-5); left: 50%; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); padding: var(--s-2) var(--s-4); border-radius: var(--r-md); box-shadow: var(--shadow-2); z-index: 50; max-width: calc(100vw - 32px); }

/* ---------------------------------------------------------------- login */
.login { min-height: 100%; display: grid; place-items: center; padding: var(--s-4); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--s-8); box-shadow: var(--shadow-2); }
.login-card h1 { margin: var(--s-3) 0 var(--s-1); font-size: var(--fs-xl); }
.login-card .btn { margin-top: var(--s-5); }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4) var(--s-3); background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; min-height: 0; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: var(--s-2); color: var(--text); font-weight: 700; text-decoration: none; padding: var(--s-1) var(--s-2); }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff; font-weight: 800; }
.project-select { margin-top: var(--s-1); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: var(--s-4) var(--s-2) var(--s-1); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
.nav-item { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); color: var(--text-muted); font-weight: 600; font-size: var(--fs-sm); text-decoration: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-sub { display: block; padding: 2px var(--s-3) var(--s-2) calc(var(--s-3) + 22px); color: var(--text-faint); font-size: var(--fs-xs); font-weight: 600; text-decoration: none; }
.nav-sub:hover, .nav-sub.active { color: var(--text); text-decoration: none; }
.nav-more { margin-top: var(--s-3); border-top: 1px solid var(--border); padding-top: var(--s-2); }
.nav-more > summary { list-style: none; cursor: pointer; }
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more[open] > summary { color: var(--text); }
.nav-ico { width: 18px; text-align: center; }
.recent-chats { display: flex; flex-direction: column; gap: 1px; margin: 0 0 var(--s-1) var(--s-5); }
.recent-chats a { display: block; padding: 5px var(--s-2); border-radius: var(--r-sm); color: var(--text-muted); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.recent-chats a:hover { background: var(--surface-2); color: var(--text); }
.recent-chats a.active { color: var(--text); background: var(--surface-2); }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view { flex: 1 1 auto; overflow-y: auto; min-height: 0; outline: none; }
.view:focus, .view:focus-visible { box-shadow: none; }
.page { max-width: var(--content-w); margin: 0 auto; padding: var(--s-8) var(--s-6) var(--s-10); }
.page-wide { max-width: 1120px; }
.page-head { display: flex; gap: var(--s-3); align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-head h1 { margin: 0; font-size: var(--fs-2xl); line-height: 1.2; overflow-wrap: anywhere; }
.page-head p { margin: var(--s-1) 0 0; color: var(--text-muted); }
.topbar { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-title { font-weight: 700; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.attention-dot { color: var(--warning); }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 19; }
.only-mobile { display: none; }
.show-sm { display: none; }

/* ---------------------------------------------------------------- V5 owner product */
.owner-home { padding-top: var(--s-6); }
.owner-loading { min-height: 48vh; display: grid; place-items: center; align-content: center; gap: var(--s-3); }
.owner-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-6); margin-bottom: var(--s-6); }
.owner-kicker { display: block; margin-bottom: var(--s-2); color: var(--accent); font-size: var(--fs-xs); font-weight: 750; letter-spacing: .14em; }
.owner-hero h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.055em; }
.owner-hero p { max-width: 650px; margin: var(--s-2) 0 0; color: var(--text-muted); font-size: var(--fs-lg); }
.owner-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.owner-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
.owner-metric { min-width: 0; padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.owner-metric > span, .owner-metric small { display: block; color: var(--text-muted); font-size: var(--fs-xs); }
.owner-metric strong { display: block; margin: var(--s-1) 0; font-size: var(--fs-xl); letter-spacing: -.04em; }
.owner-metric.tone-live { border-color: color-mix(in srgb, var(--info) 30%, var(--border)); }
.owner-metric.tone-alert { border-color: color-mix(in srgb, var(--warning) 42%, var(--border)); background: var(--warning-soft); }
.owner-metric.tone-good strong { color: var(--success); }
.owner-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.owner-span-2 { grid-column: 1 / -1; }
.owner-card { min-width: 0; padding: var(--s-5); border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-1); }
.owner-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.owner-card-head h2 { margin: 0; font-size: var(--fs-lg); }
.owner-label { display: block; margin-bottom: var(--s-1); color: var(--text-faint); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.owner-objective { max-width: 780px; color: var(--text-muted); }
.owner-live-list { display: grid; gap: var(--s-2); margin-top: var(--s-4); }
.owner-live-list > a { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(120px, .45fr); align-items: center; gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); color: var(--text); text-decoration: none; }
.owner-live-list small { display: block; margin-top: 2px; color: var(--text-muted); }
.live-pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px var(--success-soft); }
.owner-row { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.owner-row:last-child { border-bottom: 0; }
.owner-row strong, .owner-row small { display: block; }
.owner-row small, .owner-row time { margin-top: 2px; color: var(--text-muted); font-size: var(--fs-xs); }
.owner-risk, .owner-done { flex: 0 0 auto; padding: 3px 8px; border-radius: var(--r-full); background: var(--warning-soft); color: var(--warning); font-size: 11px; font-weight: 750; }
.owner-done { background: var(--success-soft); color: var(--success); }
.owner-empty { display: flex; align-items: center; gap: var(--s-3); min-height: 90px; padding: var(--s-4); border-radius: var(--r-lg); background: var(--surface-2); color: var(--text-muted); }
.owner-empty > span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--success-soft); color: var(--success); }
.owner-empty p { flex: 1; margin: 0; }
.capacity-state { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-lg); background: var(--surface-2); }
.capacity-state strong, .capacity-state small { display: block; }
.capacity-state small { margin-top: 3px; color: var(--text-muted); }
.capacity-orb { display: block; flex: 0 0 auto; width: 13px; height: 13px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 7px var(--warning-soft); }
.is-good .capacity-orb, .capacity-state.is-good .capacity-orb { background: var(--success); box-shadow: 0 0 0 7px var(--success-soft); }
.owner-cost { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); margin: var(--s-4) 0 0; }
.owner-cost div { min-width: 0; padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.owner-cost dt { color: var(--text-muted); font-size: var(--fs-xs); }
.owner-cost dd { margin: 4px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.owner-team { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.owner-team a { min-width: 0; padding: var(--s-2); border-radius: var(--r-md); background: var(--surface-2); color: var(--text); text-decoration: none; }
.owner-team strong, .owner-team small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owner-team small { color: var(--text-muted); font-size: var(--fs-xs); }
.team-dot { display: inline-block; width: 7px; height: 7px; margin-inline-end: 5px; border-radius: 50%; background: var(--st-available); }
.team-dot.st-dot-working, .team-dot.st-dot-thinking, .team-dot.st-dot-testing, .team-dot.st-dot-reviewing { background: var(--success); }
.team-dot.st-dot-waiting { background: var(--warning); }
.team-dot.st-dot-blocked, .team-dot.st-dot-needs-fahad { background: var(--danger); }

/* Work, projects and approvals */
.work-section + .work-section { margin-top: var(--s-6); }
.work-section > .spread { margin-bottom: var(--s-3); }
.work-section h2 { margin: 0; font-size: var(--fs-lg); }
.work-card { display: flex; gap: var(--s-3); margin-top: var(--s-2); padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); text-decoration: none; }
.work-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); text-decoration: none; }
.work-card p { margin: var(--s-1) 0 var(--s-2); color: var(--text-muted); font-size: var(--fs-sm); }
.work-icon { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent); }
.work-icon.coding { background: var(--success-soft); color: var(--success); }
.project-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.project-card-v5 { min-width: 0; padding: var(--s-5); border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); text-decoration: none; }
.project-card-v5:hover { border-color: var(--accent); box-shadow: var(--shadow-2); text-decoration: none; }
.project-card-v5 h2 { margin: var(--s-4) 0 var(--s-2); font-size: var(--fs-xl); }
.project-card-v5 > p { min-height: 3em; color: var(--text-muted); }
.project-card-v5 dl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2); margin: var(--s-4) 0; }
.project-card-v5 dl div { padding: var(--s-2); border-radius: var(--r-md); background: var(--surface-2); }
.project-card-v5 dt { color: var(--text-faint); font-size: var(--fs-xs); }
.project-card-v5 dd { margin: 3px 0 0; font-weight: 750; }
.project-status { padding: 3px 9px; border-radius: var(--r-full); background: var(--surface-3); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 700; }
.project-status.is-live { background: var(--success-soft); color: var(--success); }
.project-open { color: var(--accent); font-size: var(--fs-sm); font-weight: 650; }
.approval-card { margin-bottom: var(--s-4); padding: var(--s-5); border: 1px solid var(--border); border-inline-start: 4px solid var(--warning); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-1); }
.approval-card.risk-high, .approval-card.risk-critical { border-inline-start-color: var(--danger); }
.approval-top, .approval-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.approval-top time { color: var(--text-faint); font-size: var(--fs-xs); }
.approval-risk { color: var(--warning); font-size: var(--fs-xs); font-weight: 800; letter-spacing: .08em; }
.approval-card h2 { margin: var(--s-3) 0; font-size: var(--fs-lg); }
.approval-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-2); margin: var(--s-4) 0; }
.approval-facts div { padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.approval-facts dt { color: var(--text-faint); font-size: var(--fs-xs); }
.approval-facts dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.approval-actions { justify-content: flex-end; }

/* Capacity, settings and team detail */
.capacity-overview { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s-4); margin-bottom: var(--s-5); }
.capacity-hero { display: flex; align-items: flex-start; gap: var(--s-4); padding: var(--s-6); border: 1px solid var(--border); border-radius: var(--r-xl); background: linear-gradient(145deg, var(--surface), var(--surface-2)); }
.capacity-hero h2 { margin: var(--s-1) 0; font-size: var(--fs-xl); }
.capacity-hero p { margin: 0; color: var(--text-muted); }
.capacity-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.capacity-kpis > div { padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.capacity-kpis span, .capacity-kpis small { display: block; color: var(--text-muted); font-size: var(--fs-xs); }
.capacity-kpis strong { display: block; margin: var(--s-1) 0; }
.pool-grid, .provider-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.pool-grid article, .provider-safe { padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.provider-safe { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.settings-grid .card { margin: 0; }
.settings-grid #officeQuality { max-width: 220px; margin-top: var(--s-2); }
.platform-health { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-5); border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); }
.platform-health h2 { margin: var(--s-1) 0; font-size: var(--fs-lg); }
.platform-health p { margin: 0; color: var(--text-muted); }
.readiness-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.readiness-grid > div { padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.readiness-grid span, .readiness-grid strong { display: block; }
.readiness-grid span { color: var(--text-muted); font-size: var(--fs-xs); }
.readiness-grid strong { margin-top: 4px; }
.agent-now, .agent-output { padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.agent-now span, .agent-output span { display: block; margin-bottom: 3px; color: var(--text-faint); font-size: var(--fs-xs); }
.agent-now strong, .agent-output strong { display: block; font-size: var(--fs-sm); }

/* RTL is structural, while mixed user content keeps dir=auto. */
[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--border); }
[dir="rtl"] .nav-sub { padding-right: calc(var(--s-3) + 22px); padding-left: var(--s-3); }
[dir="rtl"] .recent-chats { margin-right: var(--s-5); margin-left: 0; }
[dir="rtl"] .table th, [dir="rtl"] .table td { text-align: right; }
[dir="rtl"] .task-chip { border-left-width: 1px; border-right: 3px solid var(--accent); }

@media (max-width: 900px) {
  .owner-hero { align-items: flex-start; flex-direction: column; }
  .owner-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .capacity-overview { grid-template-columns: minmax(0, 1fr); }
  .project-cards { grid-template-columns: minmax(0, 1fr); }
  [dir="rtl"] .sidebar { right: 0; left: auto; border-left: 1px solid var(--border); }
}
@media (max-width: 620px) {
  .owner-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .owner-span-2 { grid-column: auto; }
  .owner-live-list > a { grid-template-columns: auto minmax(0, 1fr); }
  .owner-live-list .progress { grid-column: 2; }
  .owner-cost, .owner-team, .readiness-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pool-grid, .provider-grid { grid-template-columns: minmax(0, 1fr); }
  .project-card-v5 dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .approval-actions { align-items: stretch; flex-direction: column-reverse; }
  .approval-actions .btn { width: 100%; }
}
@media (max-width: 420px) {
  .owner-metrics { grid-template-columns: minmax(0, 1fr); }
  .owner-cost, .owner-team, .capacity-kpis, .readiness-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------- chat */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-6); border-bottom: 1px solid var(--border); min-height: 56px; }
.chat-title { margin: 0; font-size: var(--fs-md); flex: 1; min-width: 0; font-weight: 700; font-size: var(--fs-md); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-scroll { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.messages { max-width: var(--content-w); margin: 0 auto; padding: var(--s-6) var(--s-6) var(--s-4); }
.msg { display: flex; margin-bottom: var(--s-5); }
.msg-user { justify-content: flex-end; }
.bubble { max-width: 82%; min-width: 0; }
.msg-user .bubble { background: var(--accent-soft); border: 1px solid var(--border); padding: var(--s-3) var(--s-4); border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-office .bubble { max-width: 100%; width: 100%; }
.msg-meta { margin-top: var(--s-1); font-size: var(--fs-xs); color: var(--text-faint); display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.msg-user .msg-meta { justify-content: flex-end; }
.msg-actions { display: flex; gap: var(--s-1); margin-top: var(--s-1); }
.thinking { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--text-muted); font-size: var(--fs-sm); padding: var(--s-2) 0; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: .8; } }
.composer-wrap { border-top: 1px solid var(--border); background: var(--bg); padding: var(--s-3) var(--s-6) var(--s-4); }
.composer { max-width: var(--content-w); margin: 0 auto; display: flex; gap: var(--s-2); align-items: flex-end; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); padding: var(--s-2); }
.composer:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.composer textarea { flex: 1; border: 0; background: transparent; resize: none; max-height: 240px; min-height: 40px; padding: var(--s-2); outline: none; line-height: var(--lh); }
.composer-hint { max-width: var(--content-w); margin: var(--s-1) auto 0; font-size: var(--fs-xs); color: var(--text-faint); text-align: center; }
.welcome { max-width: 640px; margin: 12vh auto 0; padding: 0 var(--s-6); text-align: center; }
.welcome h1 { font-size: var(--fs-2xl); margin: var(--s-4) 0 var(--s-2); }
.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-2); margin-top: var(--s-6); text-align: left; }
.suggestion { padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); cursor: pointer; font-size: var(--fs-sm); color: var(--text-muted); }
.suggestion:hover { border-color: var(--accent); color: var(--text); }
.task-chip { display: flex; gap: var(--s-3); align-items: center; margin-top: var(--s-3); padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r-md); background: var(--surface); color: var(--text); text-decoration: none; }
.task-chip:hover { background: var(--surface-2); text-decoration: none; }
.error-note { color: var(--danger); background: var(--danger-soft); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); }
.error-details { margin-top: var(--s-2); color: var(--text-muted); } .error-details summary { cursor: pointer; font-size: var(--fs-xs); } .error-details code { display: block; white-space: pre-wrap; word-break: break-word; margin-top: var(--s-1); font-size: var(--fs-xs); }

/* ---------------------------------------------------------------- markdown */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md .table-wrap { margin: 0 0 var(--s-3); }
.md h1, .md h2, .md h3, .md h4 { margin: var(--s-5) 0 var(--s-2); line-height: 1.3; }
.md h1 { font-size: var(--fs-xl); } .md h2 { font-size: var(--fs-lg); } .md h3, .md h4 { font-size: var(--fs-md); }
.md ul, .md ol { padding-inline-start: var(--s-6); }
.md li + li { margin-top: 2px; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.md pre { position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-8) var(--s-4) var(--s-3); overflow-x: auto; }
.md pre[data-lang]::before { content: attr(data-lang); position: absolute; top: var(--s-2); left: var(--s-4); font-size: var(--fs-xs); color: var(--text-faint); font-family: var(--mono); }
.md pre code { background: none; padding: 0; font-size: var(--fs-sm); white-space: pre; }
.md pre .copy { position: absolute; top: var(--s-1); right: var(--s-1); }
.md blockquote { border-inline-start: 3px solid var(--border-strong); padding-inline-start: var(--s-3); color: var(--text-muted); }
.md table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
.md th, .md td { border-bottom: 1px solid var(--border); padding: var(--s-2) var(--s-3); text-align: start; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }

/* ---------------------------------------------------------------- tasks */
.task-head { display: grid; gap: var(--s-3); }
.task-head h1 { margin: 0; font-size: var(--fs-xl); line-height: 1.25; overflow-wrap: anywhere; }
.now { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface-2); font-weight: 600; }
.now .dots { flex: none; }
.timeline { display: flex; gap: 0; overflow-x: auto; padding: var(--s-2) 0 var(--s-1); scrollbar-width: thin; }
.step { flex: 1 0 84px; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; text-align: center; font-size: var(--fs-xs); color: var(--text-faint); padding: 0 2px; }
.step::before { content: ""; position: absolute; top: 11px; left: -50%; right: 50%; height: 2px; background: var(--border); z-index: 0; }
.step:first-child::before { display: none; }
.step .dot { position: relative; z-index: 1; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--surface-3); border: 2px solid var(--border-strong); color: var(--text-faint); }
.step.passed .dot { background: var(--success); border-color: var(--success); color: #06140e; }
.step.passed::before, .step.active::before, .step.failed::before, .step.needs_input::before { background: var(--success); }
.step.active .dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.step.failed .dot { background: var(--danger); border-color: var(--danger); color: #fff; }
.step.needs_input .dot { background: var(--warning); border-color: var(--warning); color: #1a1204; }
.step.skipped { opacity: .45; }
.step.active, .step.needs_input, .step.failed { color: var(--text); font-weight: 700; }
.owner-card:has(.what), .owner-card:has(.owner-item) { border: 1px solid var(--warning); background: linear-gradient(0deg, var(--warning-soft), var(--warning-soft)), var(--surface); border-radius: var(--r-lg); padding: var(--s-5); }
.owner-card h2 { margin: 0 0 var(--s-2); font-size: var(--fs-lg); }
.owner-card .what { font-weight: 700; }
.owner-card .resources { display: flex; flex-wrap: wrap; gap: var(--s-1); margin: var(--s-2) 0; }
.owner-card .resources code { font-family: var(--mono); font-size: var(--fs-xs); background: var(--surface-3); padding: 2px 8px; border-radius: var(--r-sm); overflow-wrap: anywhere; }
.owner-item + .owner-item { margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.risk { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.risk.high, .risk.critical { color: var(--danger); } .risk.medium { color: var(--warning); } .risk.low { color: var(--success); }
.events { max-height: 420px; overflow: auto; font-family: var(--mono); font-size: var(--fs-xs); }
.events div { padding: 5px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; white-space: pre-wrap; }
.events .warning { color: var(--warning); } .events .error { color: var(--danger); } .events .success { color: var(--success); }
.report { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.files { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.files code { font-family: var(--mono); font-size: var(--fs-xs); background: var(--surface-2); padding: 2px 8px; border-radius: var(--r-sm); overflow-wrap: anywhere; }
.big-input { min-height: 160px; font-size: var(--fs-md); }

/* ---------------------------------------------------------------- office */
.pill.st-available { background: var(--surface-3); color: var(--text-muted); }
.pill.st-working { background: var(--info-soft); color: var(--info); }
.pill.st-waiting { background: var(--surface-3); color: var(--text-faint); }
.pill.st-blocked { background: var(--danger-soft); color: var(--danger); }
.pill.st-needs { background: var(--warning-soft); color: var(--warning); }
.pill.st-completed { background: var(--success-soft); color: var(--success); }
.avatar { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-3); color: var(--text); font-weight: 800; border: 2px solid var(--agent, var(--accent)); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-xl); }
.welcome .avatar-lg { margin: 0 auto; }
.chat-who { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-6); border-bottom: 1px solid var(--border); background: var(--surface); }
.who-name { font-weight: 700; }
.who-role { font-size: var(--fs-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.office-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-3); }
.office-grid-1 { grid-template-columns: minmax(0, 460px); }
.agent-card { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4); border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; min-width: 0; }
.agent-card:hover { border-color: var(--border-strong); text-decoration: none; background: var(--surface-2); }
.agent-card .title { font-weight: 700; }
.agent-card.st-working { border-color: var(--info); box-shadow: 0 0 0 3px var(--info-soft); }
.agent-card.st-needs { border-color: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.agent-card.st-blocked { border-color: var(--danger); }
.agent-card.st-working .avatar { animation: pulse 1.6s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--info-soft); } 50% { box-shadow: 0 0 0 6px var(--info-soft); } }
@media (prefers-reduced-motion: reduce) { .agent-card.st-working .avatar { animation: none; } }
.agent-detail { overflow-wrap: anywhere; }
.agent-head { display: flex; gap: var(--s-4); align-items: center; flex-wrap: wrap; }
.agent-head h1 { margin: 0; font-size: var(--fs-2xl); }
.flow-card { display: block; margin-top: var(--s-3); padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r-md); background: var(--surface); color: var(--text); text-decoration: none; }
.flow-card:hover { background: var(--surface-2); text-decoration: none; }
.flow-row { display: flex; gap: var(--s-2); align-items: baseline; font-size: var(--fs-sm); padding: 2px 0; min-width: 0; }
.flow-row .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-icon { width: 16px; flex: none; text-align: center; font-weight: 800; color: var(--text-faint); }
.st-done > .flow-icon { color: var(--success); }
.st-working > .flow-icon { color: var(--info); }
.st-failed > .flow-icon, .st-blocked > .flow-icon { color: var(--danger); }
.flow-node { display: flex; gap: var(--s-3); padding: var(--s-2) 0; }
.flow-node + .flow-node, .flow-branch + .flow-node { border-top: 1px dashed var(--border); }
.flow-branch { margin-left: var(--s-5); padding-left: var(--s-4); border-left: 2px solid var(--border); }
.flow-branch .flow-node.st-working { background: var(--info-soft); border-radius: var(--r-sm); padding-left: var(--s-2); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 20; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-2); }
  [dir="rtl"] .sidebar { inset: 0 0 0 auto; transform: translateX(102%); }
  [dir="rtl"] .sidebar.open { transform: translateX(0); }
  .sidebar.open { transform: none; }
  .only-mobile { display: inline-grid; }
  .topbar.only-mobile { display: flex; }
  .page { padding: var(--s-5) var(--s-4) var(--s-8); }
  .page-head h1 { font-size: var(--fs-xl); }
  .messages { padding: var(--s-4); }
  .chat-head { padding: var(--s-1) var(--s-3); min-height: 44px; justify-content: flex-end; }
  .chat-head .chat-title { display: none; }
  .composer-wrap { padding: var(--s-2) var(--s-3) calc(var(--s-3) + env(safe-area-inset-bottom)); }
  .bubble { max-width: 92%; }
  .welcome { margin-top: 6vh; padding: 0 var(--s-4); }
  .owner-card { padding: var(--s-4); }
  .owner-card .row .btn { flex: 1 1 auto; }
  .chat-who { padding: var(--s-2) var(--s-3); }
  .flow-branch { margin-left: var(--s-2); padding-left: var(--s-3); }
}
@media (max-width: 520px) {
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step { flex-basis: 72px; }
  .hide-sm { display: none; }
  .show-sm { display: block; }
}

/* ---------------------------------------------------------------- living office */

/* ---------------------------------------------------------------- chips, tags */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.chip { padding: 4px 12px; border-radius: var(--r-full); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: var(--fs-sm); cursor: pointer; text-decoration: none; }
.chip.active, .chip:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); text-decoration: none; }
.tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag.ok { background: var(--success-soft); color: var(--success); } .tag.warn { background: var(--warning-soft); color: var(--warning); }
.tag.bad { background: var(--danger-soft); color: var(--danger); } .tag.muted { background: var(--surface-3); color: var(--text-muted); }

/* ---------------------------------------------------------------- artifacts */
.artifact { margin: var(--s-4) 0; padding: var(--s-4); border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); min-width: 0; }
.artifact figcaption { display: flex; gap: var(--s-2); align-items: baseline; flex-wrap: wrap; margin-bottom: var(--s-3); }
.art-type { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 800; }
.artifact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: var(--s-4); align-items: start; }
.artifact-grid .artifact { margin: 0; }
.artifact-meta { margin-top: 4px; }
.art-scroll { overflow-x: auto; }
table.art-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.art-scroll .art-table { min-width: 640px; }
.art-table th { text-align: start; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); border-bottom: 1px solid var(--border-strong); padding: 6px 8px; }
.art-table td { border-bottom: 1px solid var(--border); padding: 6px 8px; vertical-align: top; }
.art-chart svg { width: 100%; height: auto; display: block; }
.art-chart .grid line { stroke: var(--border); } .art-chart text { fill: var(--text-faint); font-size: 11px; }
.art-pie { display: flex; gap: var(--s-4); align-items: center; flex-wrap: wrap; } .art-pie svg { width: 180px; flex: none; }
.art-legend { display: flex; flex-wrap: wrap; gap: var(--s-3); font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--s-2); }
.art-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 4px; vertical-align: -1px; }
.art-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s-2); margin-bottom: var(--s-3); }
.art-kpis div { padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); } .art-kpis span { display: block; font-size: var(--fs-xs); color: var(--text-muted); }
ol.art-timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--border-strong); }
.art-timeline li { display: flex; gap: var(--s-3); padding: 0 0 var(--s-3) var(--s-3); position: relative; }
.tl-dot { position: absolute; inset-inline-start: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.art-check { list-style: none; margin: 0; padding: 0; } .art-check li { display: flex; gap: var(--s-2); align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--border); }
.ck-box { width: 18px; height: 18px; flex: none; border-radius: 5px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.ck-done .ck-box, .ck-pass .ck-box { background: var(--success); border-color: var(--success); color: #fff; } .ck-fail .ck-box { background: var(--danger); border-color: var(--danger); color: #fff; } .ck-blocked .ck-box { border-color: var(--warning); color: var(--warning); }
div.art-kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(180px, 1fr); gap: var(--s-3); overflow-x: auto; }
.kb-col { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s-2); } .kb-head { font-weight: 700; font-size: var(--fs-sm); padding: 4px; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--s-2); margin-top: var(--s-2); font-size: var(--fs-sm); }
div.art-flow { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.fl-step { display: flex; gap: var(--s-2); align-items: flex-start; padding: var(--s-2) var(--s-3); border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface-2); max-width: 240px; }
.fl-n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 800; flex: none; }
.fl-arrow { color: var(--text-faint); }
.mb-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--s-3); }
.mb-chip { height: 72px; border-radius: var(--r-md); border: 1px solid var(--border); margin-bottom: 6px; }
.mb-type { display: grid; gap: var(--s-2); margin-top: var(--s-4); } .mb-sample { font-size: var(--fs-xl); line-height: 1.3; }
.mb-concepts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-3); margin: var(--s-4) 0 var(--s-3); }
.mb-concept { padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.audit-verdict { display: inline-block; padding: 4px 14px; border-radius: var(--r-full); font-weight: 800; letter-spacing: .06em; font-size: var(--fs-sm); margin-bottom: var(--s-3); }
.v-pass { background: var(--success-soft); color: var(--success); } .v-needs-work { background: var(--warning-soft); color: var(--warning); } .v-blocked { background: var(--danger-soft); color: var(--danger); }
.cc-kpi .audit-verdict { margin: 0; }
.issue { padding: var(--s-2) var(--s-3); border-inline-start: 3px solid var(--border-strong); background: var(--surface-2); border-radius: var(--r-sm); margin-bottom: var(--s-2); }
.issue.sev-critical, .issue.sev-high { border-color: var(--danger); } .issue.sev-medium, .issue.sev-review { border-color: var(--warning); }
ul.art-evidence { list-style: none; margin: 0; padding: 0; } .art-evidence li { display: flex; gap: var(--s-2); align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border); }
.art-list { margin: var(--s-3) 0 0; padding-inline-start: 20px; } .art-list li { margin-bottom: var(--s-2); }
.rm { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 4px; max-width: 360px; }
.rm-y { writing-mode: vertical-rl; transform: rotate(180deg); font-size: var(--fs-xs); color: var(--text-faint); text-align: center; }
.rm-x { grid-column: 2; font-size: var(--fs-xs); color: var(--text-faint); text-align: center; }
.rm-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.rm-cell { aspect-ratio: 1; border-radius: 4px; display: flex; flex-wrap: wrap; gap: 2px; align-content: center; justify-content: center; }
.rm-lo { background: var(--success-soft); } .rm-mid { background: var(--warning-soft); } .rm-hi { background: var(--danger-soft); }
.rm-cell b { font-size: 10px; background: var(--surface); border-radius: 50%; width: 16px; height: 16px; display: grid; place-items: center; }

/* ---------------------------------------------------------------- command center */
.command-center > * + * { margin-top: var(--s-3); }
.cc-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); }
.cc-kpi { padding: var(--s-4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.cc-kpi span { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; } .cc-kpi strong { font-size: var(--fs-xl); } .cc-kpi em { font-style: normal; font-size: var(--fs-xs); color: var(--text-faint); }
.cc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); } .cc-grid .card { margin: 0; }
.progress i { display: block; height: 100%; background: var(--accent); }
@media (max-width: 720px) { .cc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cc-grid { grid-template-columns: minmax(0, 1fr); } .art-kpis { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- shared V4 components (state chips, role marks, progress, sheets) */
.state-chip { --c: var(--st-available); display: inline-flex; align-items: center; gap: 5px; padding: 1px var(--s-2); border-radius: var(--r-full); font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); white-space: nowrap; }
.state-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.state-chip[data-state="THINKING"] { --c: var(--st-thinking); } .state-chip[data-state="WORKING"] { --c: var(--st-working); } .state-chip[data-state="TESTING"] { --c: var(--st-testing); }
.state-chip[data-state="REVIEWING"] { --c: var(--st-reviewing); } .state-chip[data-state="WAITING"], .state-chip[data-state="QUEUED"] { --c: var(--st-waiting); }
.state-chip[data-state="NEEDS FAHAD"] { --c: var(--st-needs); } .state-chip[data-state="BLOCKED"], .state-chip[data-state="FAILED"] { --c: var(--st-blocked); } .state-chip[data-state="COMPLETED"] { --c: var(--st-completed); }

.progress { display: block; height: 4px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width var(--t-scene) var(--ease-out); }
/* ---------------------------------------------------------------- role mark */
.role-mark { --agent: var(--accent); position: relative; display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; }
.role-mark svg { width: 100%; height: 100%; }
.rm-bg { fill: color-mix(in srgb, var(--agent) 16%, var(--surface-2)); } .rm-torso { fill: var(--agent); } .rm-head { fill: color-mix(in oklab, var(--agent) 42%, var(--surface)); }
.rm-letter { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.role-mark[data-role="chief"] { --agent: var(--st-working); } .role-mark[data-role="research"] { --agent: var(--st-thinking); }
.role-mark[data-role="finance"], .role-mark[data-role="social"] { --agent: var(--st-completed); } .role-mark[data-role="audit"] { --agent: var(--st-waiting); }
.role-mark[data-role="creative"] { --agent: var(--danger); } .role-mark[data-role="coding"], .role-mark[data-role="product"] { --agent: var(--st-testing); } .role-mark[data-role="legal"] { --agent: var(--st-available); }

/* ---------------------------------------------------------------- sheet (drawer / dialog) */
.sheet { position: fixed; inset: 0; z-index: var(--z-drawer); display: flex; justify-content: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity var(--t-slow) var(--ease-out); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sheet-panel { position: relative; width: min(600px, 100vw); height: 100%; overflow: auto; background: var(--bg-elevated); border-inline-start: 1px solid var(--border); box-shadow: var(--shadow-3); transform: translateX(28px); opacity: 0; transition: transform var(--t-slow) var(--ease-out), opacity var(--t-slow) var(--ease-out); outline: none; }
[dir="rtl"] .sheet-panel { transform: translateX(-28px); }
.sheet-xl .sheet-panel { width: min(980px, 100vw); }
.sheet-sm { align-items: center; justify-content: center; }
.sheet-sm .sheet-panel { width: min(460px, calc(100vw - 32px)); height: auto; max-height: calc(100vh - 48px); border-radius: var(--r-2xl); border: 1px solid var(--border); transform: translateY(12px) scale(.98); }
.sheet.open .sheet-scrim { opacity: 1; } .sheet.open .sheet-panel { transform: none; opacity: 1; }
.sheet.closing .sheet-scrim, .sheet.closing .sheet-panel { opacity: 0; }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-6); background: var(--surface-glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-bottom: 1px solid var(--border); }
.sheet-title { margin: 0; font-size: var(--fs-lg); font-weight: 700; letter-spacing: var(--tracking-caps); }
.sheet-body { padding: var(--s-5) var(--s-6) var(--s-8); }
.drawer-loading { height: 240px; border-radius: var(--r-xl); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.drawer-head { display: grid; grid-template-columns: 220px 1fr; gap: var(--s-5); align-items: center; margin-bottom: var(--s-5); }
.drawer-art .station-art { max-width: 220px; }
.drawer-art .screen-content { opacity: 1; }
.drawer-art .badge-done, .drawer-art .badge-wait, .drawer-art .badge-alert { opacity: 0; }
.drawer-id { display: flex; flex-direction: column; gap: var(--s-2); }
.drawer-role { font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.drawer-id p { margin: 0; }
.drawer-chat { display: flex; gap: var(--s-2); }
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); margin-bottom: var(--s-4); overflow-x: auto; }
.tab { border: 0; background: transparent; color: var(--text-muted); padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab:focus-visible { box-shadow: var(--focus); }
.pane-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-faint); margin: var(--s-5) 0 var(--s-2); }
.now-card { padding: var(--s-4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.now-title { font-size: var(--fs-md); font-weight: 650; color: var(--text); }
.capacity-note { color: var(--st-waiting); }
.list-row { display: flex; gap: var(--s-3); align-items: baseline; padding: var(--s-3) 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; width: 100%; background: none; border-inline: 0; border-top: 0; font: inherit; text-align: start; cursor: pointer; }
.list-row:hover { text-decoration: none; } .list-row:hover .grow { color: var(--accent); }
.block { display: block; }
.attention-row { display: block; padding: var(--s-3); border-radius: var(--r-md); margin-bottom: var(--s-2); background: color-mix(in srgb, var(--st-needs) 12%, transparent); color: var(--text); }
.attention-failed { background: color-mix(in srgb, var(--st-blocked) 12%, transparent); }
.drawer-artifacts { display: grid; gap: var(--s-3); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-2); margin-bottom: var(--s-3); }
.tool { display: flex; justify-content: space-between; gap: var(--s-2); align-items: center; padding: var(--s-3); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); font-size: var(--fs-sm); }
.conn { font-size: var(--fs-xs); font-weight: 650; white-space: nowrap; }
.conn-ok { color: var(--success); } .conn-configured { color: var(--info); } .conn-account { color: var(--warning); } .conn-off { color: var(--text-faint); } .conn-unavailable { color: var(--danger); }

@media (max-width: 900px) { .drawer-head { grid-template-columns: 1fr; } .drawer-art { display: none; } }
@media (max-width: 720px) {
  .sheet { align-items: flex-end; justify-content: stretch; }
  .sheet-panel, [dir="rtl"] .sheet-panel { width: 100%; height: min(92dvh, 860px); border: 1px solid var(--border); border-radius: var(--r-2xl) var(--r-2xl) 0 0; transform: translateY(24px); }
  .sheet-body { padding: var(--s-4) var(--s-4) calc(var(--s-8) + env(safe-area-inset-bottom)); }
  .sheet-head { padding: var(--s-3) var(--s-4); }
}
@media (prefers-reduced-motion: reduce) { .sheet, .sheet * { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- V4 deliverables */
.fin-basis { display: flex; height: 10px; border-radius: var(--r-full); overflow: hidden; margin: var(--s-3) 0 var(--s-2); background: var(--surface-3); }
.fin-basis span { display: block; height: 100%; }
.fb-known { background: var(--success); } .fb-estimated { background: var(--warning); } .fb-assumption { background: var(--text-faint); }
.fin-basis-legend { display: flex; flex-wrap: wrap; gap: var(--s-4); font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--s-3); }
.fin-basis-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; }
.fin-cats { display: grid; gap: 6px; margin: var(--s-2) 0 var(--s-4); }
.fin-cat { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: var(--s-3); align-items: center; font-size: var(--fs-sm); }
.fin-bar { height: 8px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.fin-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.fin-sens { margin: var(--s-3) 0 var(--s-1); padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.fin-validation { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.fin-validation.fv-inconsistent { box-shadow: inset 3px 0 0 var(--danger); }
.fin-validation.fv-verified { box-shadow: inset 3px 0 0 var(--success); }
.fin-issues { margin: var(--s-2) 0; padding-inline-start: var(--s-5); color: var(--danger); }
.legal-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-2); margin-bottom: var(--s-3); }
.legal-summary div { display: flex; flex-direction: column; padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.legal-summary strong { font-size: var(--fs-lg); } .legal-summary span { font-size: var(--fs-xs); color: var(--text-muted); }
.legal-summary .ls-flag { background: var(--danger-soft); } .legal-summary .ls-review { background: var(--warning-soft); }
.legal-note { margin-top: var(--s-3); padding: var(--s-2) var(--s-3); border-inline-start: 3px solid var(--warning); background: var(--warning-soft); border-radius: var(--r-sm); color: var(--text); }
.audit-head { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-3); }
.audit-head .audit-verdict { margin: 0; }
.audit-counts { display: flex; gap: var(--s-3); font-size: var(--fs-xs); color: var(--text-muted); text-transform: capitalize; }
.audit-counts .ac-critical strong, .audit-counts .ac-high strong { color: var(--danger); } .audit-counts .ac-medium strong { color: var(--warning); }
.owner-cell { display: inline-flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-3); }
.cal-day { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.cal-date { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.cal-post { display: flex; flex-direction: column; gap: 4px; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); }
.cal-hook { font-weight: 600; font-size: var(--fs-sm); }
.mb-preview { display: grid; grid-template-columns: 1.3fr .8fr 1fr; gap: var(--s-3); margin-bottom: var(--s-4); }
.mbp-wordmark, .mbp-phone, .mbp-post { border-radius: var(--r-lg); min-height: 190px; position: relative; overflow: hidden; box-shadow: var(--shadow-1); }
.mbp-wordmark { display: grid; place-items: center; font-size: clamp(22px, 3vw, 36px); font-weight: 700; letter-spacing: -.01em; }
.mbp-wordmark i { position: absolute; bottom: 18%; width: 34px; height: 4px; border-radius: 4px; }
.mbp-phone { padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); border: 6px solid var(--desk-edge); border-radius: 26px; }
.mbp-bar { height: 6px; width: 40%; border-radius: 6px; opacity: .8; }
.mbp-title { font-weight: 700; font-size: var(--fs-md); }
.mbp-card { border: 1.5px solid; border-radius: var(--r-md); padding: var(--s-2); font-size: var(--fs-xs); }
.mbp-cta { margin-top: auto; text-align: center; border-radius: var(--r-full); padding: 6px; font-size: var(--fs-xs); font-weight: 700; }
.mbp-post { padding: var(--s-4); display: flex; flex-direction: column; justify-content: flex-end; gap: var(--s-2); font-size: var(--fs-lg); font-weight: 700; line-height: 1.25; }
.mbp-post-kicker { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; }
/* library */
.lib-filters { display: grid; grid-template-columns: 2fr repeat(5, minmax(0, 1fr)); gap: var(--s-2); margin-bottom: var(--s-3); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-4); margin-top: var(--s-3); }
.lib-card { display: flex; flex-direction: column; gap: var(--s-2); text-align: start; padding: var(--s-4); border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border); color: var(--text); font: inherit; cursor: pointer; min-width: 0; transition: transform var(--t-base) var(--ease-out), border-color var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out); }
.lib-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.lib-card:focus-visible { outline: none; box-shadow: var(--focus); }
.lib-head { display: flex; align-items: center; gap: var(--s-2); }
.lib-type { font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-flag { font-size: 10.5px; font-weight: 700; color: var(--warning); background: var(--warning-soft); border-radius: var(--r-full); padding: 1px 8px; white-space: nowrap; }
.lib-title { font-weight: 650; font-size: var(--fs-md); line-height: 1.3; }
.lib-preview { display: flex; flex-direction: column; gap: 4px; min-height: 64px; padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); overflow: hidden; }
.lib-meta { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-muted); }
.lib-objective { font-size: var(--fs-xs); color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-line { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-swatches { display: flex; height: 38px; border-radius: var(--r-sm); overflow: hidden; }
.pv-swatches span { flex: 1; }
.pv-kpis { display: flex; gap: var(--s-4); font-size: var(--fs-xs); color: var(--text-muted); } .pv-kpis b { font-size: var(--fs-md); color: var(--text); }
.pv-cols { display: flex; gap: var(--s-2); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-muted); } .pv-cols span { padding: 2px 8px; border-radius: var(--r-sm); background: var(--surface-3); }
.pv-verdict { font-size: var(--fs-xs) !important; padding: 2px 10px !important; margin: 0 0 4px !important; align-self: flex-start; }
.pv-chart svg { max-height: 90px; }
.viewer-meta { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.viewer-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; margin: var(--s-3) 0 var(--s-4); }
.viewer-body .artifact { margin: 0; }
.print-only { display: none; }
@media print {
  body.printing > *:not(.print-only) { display: none !important; }
  body.printing .print-only { display: block; padding: 24px; color: var(--text); }
  body.printing .print-title { font-size: 22px; margin: 0 0 16px; }
  body.printing .art-scroll { overflow: visible; }
}
@media (max-width: 1100px) { .lib-filters { grid-template-columns: 1fr 1fr 1fr; } .lib-filters input { grid-column: 1 / -1; } .mb-preview { grid-template-columns: 1fr 1fr; } .legal-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .lib-filters { grid-template-columns: 1fr 1fr; } .mb-preview { grid-template-columns: 1fr; } .legal-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } .fin-cat { grid-template-columns: 1fr auto; } .fin-cat .fin-bar { grid-column: 1 / -1; grid-row: 2; } }
@media (prefers-reduced-motion: reduce) { .lib-card, .member, .station { transition: none !important; } }

/* CHIEF home */
.chief-home { max-width: 1080px; margin: 0 auto; padding: var(--s-10) var(--s-6) var(--s-6); }
.ch-hero { text-align: center; max-width: 720px; margin: 0 auto var(--s-8); }
.ch-hero h1 { font-size: var(--fs-3xl); margin: 0 0 var(--s-2); font-weight: 700; }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s-4); text-align: start; align-items: start; }
.ch-card { padding: var(--s-5); border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.ch-alert { border-color: color-mix(in srgb, var(--st-needs) 50%, transparent); background: color-mix(in srgb, var(--st-needs) 7%, var(--surface)); }
.ch-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.ch-card h2 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-faint); margin: 0; font-weight: 650; }
.ch-row { display: flex; gap: var(--s-2); align-items: center; padding: 6px 0; color: var(--text); text-decoration: none; font-size: var(--fs-sm); min-width: 0; }
.ch-row:hover { text-decoration: none; } .ch-row:hover .grow { color: var(--accent); }
.ch-row .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-kind { flex: none; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 8px; border-radius: var(--r-full); color: var(--st-needs); background: color-mix(in srgb, var(--st-needs) 9%, transparent); }
.ch-kind.k-failed { color: var(--st-blocked); background: color-mix(in srgb, var(--st-blocked) 14%, transparent); }
.ch-kind.k-completed { color: var(--st-completed); background: color-mix(in srgb, var(--st-completed) 14%, transparent); }
.ch-pct { font-size: var(--fs-xs); color: var(--text-muted); }
.ch-team { display: flex; flex-direction: column; gap: 2px; }
.ch-member { display: grid; grid-template-columns: 10px 80px 1fr; gap: var(--s-2); align-items: center; text-align: start; background: none; border: 0; padding: 6px 0; color: var(--text); font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.ch-member span.xs { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-member:hover strong { color: var(--accent); }
.ch-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-available); }
.st-dot-working, .st-dot-thinking, .st-dot-reviewing { background: var(--st-working); } .st-dot-testing { background: var(--st-testing); } .st-dot-waiting, .st-dot-queued { background: var(--st-waiting); }
.st-dot-needs-fahad { background: var(--st-needs); } .st-dot-blocked, .st-dot-failed { background: var(--st-blocked); } .st-dot-completed { background: var(--st-completed); }
.ch-decision { padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.chief-home .suggestions { margin-top: var(--s-5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 600px) { .chief-home .suggestions { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) { .chief-home { padding: var(--s-6) var(--s-4); } .ch-hero h1 { font-size: var(--fs-2xl); } }

/* Needs Fahad */
.nf-group { margin-bottom: var(--s-6); }
.nf-group h2 { display: flex; align-items: baseline; gap: var(--s-3); font-size: var(--fs-md); margin: 0 0 var(--s-3); }
.nf-level { font-size: var(--fs-xs); font-weight: 800; letter-spacing: var(--tracking-caps); padding: 3px 10px; border-radius: var(--r-full); color: var(--text-muted); background: var(--surface-3); }
.nf-urgent .nf-level { color: var(--danger); background: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger); }
.nf-action-needed .nf-level { color: var(--st-needs); background: color-mix(in srgb, var(--st-needs) 9%, transparent); }
.nf-item { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-4); margin-bottom: var(--s-2); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.nf-item:hover { text-decoration: none; border-color: var(--border-strong); }
.nf-urgent .nf-item { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.nf-cat { flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; border-radius: var(--r-full); background: var(--surface-3); color: var(--text-muted); margin-top: 2px; }
.nf-title { display: block; font-weight: 600; } .nf-detail { display: block; font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }
.nf-clear { padding: var(--s-5); border-radius: var(--r-xl); background: var(--success-soft); margin-bottom: var(--s-6); }

/* Integrations & models */
.conn-legend { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-5); }
.conn-badge { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; padding: 2px 9px; border-radius: var(--r-full); white-space: nowrap; }
.conn-badge.conn-ok { color: var(--success); background: var(--success-soft); } .conn-badge.conn-configured { color: var(--info); background: var(--info-soft); }
.conn-badge.conn-off { color: var(--text-muted); background: var(--surface-3); } .conn-badge.conn-account { color: var(--warning); background: var(--warning-soft); } .conn-badge.conn-unavailable { color: var(--danger); background: var(--danger-soft); }
.int-group { margin-bottom: var(--s-6); }
.int-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-faint); margin: 0 0 var(--s-3); }
.int-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-3); }
.int-card { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); }
.int-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); }
.capacity-banner { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: color-mix(in srgb, var(--st-waiting) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--st-waiting) 40%, transparent); margin-bottom: var(--s-4); font-size: var(--fs-sm); }

/* search palette */
.search-trigger { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: var(--s-2); padding: 8px var(--s-3); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.search-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.search-trigger kbd { font-family: var(--font); font-size: var(--fs-xs); color: var(--text-faint); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; }
.palette { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.palette-scrim { position: absolute; inset: 0; background: var(--scrim); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.palette-panel { position: relative; width: min(640px, calc(100vw - 32px)); border-radius: var(--r-xl); background: var(--bg-elevated); border: 1px solid var(--border-strong); box-shadow: var(--shadow-3); overflow: hidden; }
.palette-input { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; font-size: var(--fs-lg); padding: var(--s-4) var(--s-5); outline: none; }
.palette-list { list-style: none; margin: 0; padding: var(--s-2); max-height: 50vh; overflow: auto; }
.palette-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); cursor: pointer; font-size: var(--fs-sm); }
.palette-item[aria-selected="true"], .palette-item:hover { background: var(--surface-3); }
.palette-kind { flex: none; width: 76px; font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; }
.palette-hint { padding: var(--s-3); color: var(--text-faint); font-size: var(--fs-sm); }

/* accessibility: links inside text are underlined; scroll regions are reachable */
p a, li a, .small a, .xs a, .sub a, .composer-hint a { text-decoration: underline; text-underline-offset: 2px; }
.art-scroll:focus-visible, .art-kanban:focus-visible { outline: none; box-shadow: var(--focus); }
.fahad-mark { background: var(--accent-fill); }
.decision-open .faint, .need .faint, .verdict + .faint { color: var(--text-muted); }

/* V5.1: one human sentence at the top of each screen. */
.page-summary { font-size: var(--fs-md, 1.0625rem); color: var(--text); font-weight: 500; letter-spacing: -0.005em; margin-top: var(--s-1); }
