/* ============================================================================
   AESOP — unified design system  ·  "modern cyber professional"  ·  zero-build
   One dark theme. Electric cyan #22d3ee on deep navy #0b0e14.
   Cascade is ordered with @layer so service-local CSS can still override safely.
   ========================================================================== */
@layer tokens, base, components, utilities;

/* ---------------------------------------------------------------- TOKENS -- */
@layer tokens {
  :root {
    /* surfaces */
    --bg:          #0b0e14;
    --bg-2:        #090c11;
    --surface-1:   #11161f;
    --surface-2:   #161c28;
    --surface-3:   #1d2533;
    --border:      #232c3b;
    --border-strong:#33405a;

    /* text */
    --text:   #e6edf6;
    --text-2: #9fb0c3;
    --text-3: #677387;

    /* accent + semantic */
    --accent:      #22d3ee;
    --accent-600:  #0bb6d4;
    --accent-ink:  #04141a;            /* text on accent fills */
    --accent-glow: rgba(34, 211, 238, .30);
    --ok:   #34d399;  --ok-glow:rgba(52,211,153,.25);
    --warn: #f5a524;  --warn-glow:rgba(245,165,36,.22);
    --crit: #f43f5e;  --crit-glow:rgba(244,63,94,.25);
    --info: #38bdf8;

    /* domain / actor — one source of truth (maps, ORBAT, belligerents) */
    --friendly:  #22d3ee;
    --adversary: #f43f5e;
    --neutral:   #7c8aa3;
    --unknown:   #a78bfa;

    /* per-service identity accent (thin stripe + switcher dots only) */
    --svc-intell: #3b82f6;  --svc-modelisation:#10b981; --svc-simulation:#f59e0b;
    --svc-energy: #ec4899;  --svc-tree:#8b5cf6;          --svc-planning:#06b6d4;
    --svc-military:#ef4444;
    --service-accent: var(--accent);   /* overridden per service in :root inline */

    /* typography */
    --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
    --t-xs:.6875rem; --t-sm:.8125rem; --t-base:.9375rem; --t-lg:1.0625rem;
    --t-xl:1.375rem; --t-2xl:1.875rem; --t-3xl:2.5rem;
    --lh: 1.55;

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

    /* radius */
    --r-sm:6px; --r-md:10px; --r-lg:14px; --r-pill:999px;

    /* elevation (dark-tuned) */
    --sh-1: 0 1px 2px rgba(0,0,0,.4);
    --sh-2: 0 4px 16px rgba(0,0,0,.45);
    --sh-3: 0 12px 40px rgba(0,0,0,.55);
    --glow: 0 0 0 1px var(--accent-glow), 0 0 18px -2px var(--accent-glow);

    /* layout */
    --topbar-h: 52px;
    --rail-w: 248px;
    --rail-w-collapsed: 60px;
    --statusbar-h: 26px;
    --content-max: 1440px;

    /* motion */
    --ease: cubic-bezier(.2,.8,.2,1);
    --dur-1:120ms; --dur-2:200ms; --dur-3:320ms;
  }
}

/* ------------------------------------------------------------------ BASE -- */
@layer base {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    margin: 0;
    font-family: var(--font-ui);
    font-size: var(--t-base);
    line-height: var(--lh);
    color: var(--text);
    background-color: var(--bg);
    /* faint hex/grid texture — the "cyber" undertone, very subtle */
    background-image:
      radial-gradient(circle at 50% 0%, rgba(34,211,238,.05), transparent 60%),
      linear-gradient(to right, rgba(255,255,255,.015) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(255,255,255,.015) 1px, transparent 1px);
    background-size: 100% 480px, 48px 48px, 48px 48px;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  h1,h2,h3,h4 { margin: 0 0 var(--s-3); font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
  h1 { font-size: var(--t-2xl); } h2 { font-size: var(--t-xl); }
  h3 { font-size: var(--t-lg); } h4 { font-size: var(--t-base); color: var(--text-2); }
  p { margin: 0 0 var(--s-4); }
  a { color: var(--accent); text-decoration: none; }
  a:hover { text-decoration: underline; text-underline-offset: 2px; }
  small { font-size: var(--t-xs); color: var(--text-3); }
  code, kbd, .mono { font-family: var(--font-mono); font-size: .92em; }
  hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-5) 0; }

  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
  }
  ::selection { background: var(--accent-glow); color: #fff; }

  /* slim cyber scrollbars */
  * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px;
    border: 2px solid var(--bg); }
  *::-webkit-scrollbar-thumb:hover { background: #44557a; }

  .icon { width: 18px; height: 18px; stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none;
    vertical-align: -3px; }
  .icon-sm { width: 14px; height: 14px; } .icon-lg { width: 22px; height: 22px; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important;
      transition-duration: .001ms !important; }
  }
}

/* ------------------------------------------------------------ COMPONENTS -- */
@layer components {

  /* ---- app shell -------------------------------------------------------- */
  .app-shell { min-height: 100vh; display: grid;
    grid-template-rows: var(--topbar-h) 1fr var(--statusbar-h);
    grid-template-columns: 100%; }

  .topbar {
    grid-row: 1; display: flex; align-items: center; gap: var(--s-3);
    height: var(--topbar-h); padding: 0 var(--s-4);
    background: linear-gradient(180deg, var(--surface-1), var(--bg));
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 60;
  }
  .brand { display: flex; align-items: center; gap: var(--s-2);
    font-weight: 750; letter-spacing: .04em; color: var(--text); }
  .brand .brand-mark { color: var(--accent); filter: drop-shadow(0 0 6px var(--accent-glow)); }
  .brand-svc { display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px; font-size: var(--t-xs); font-weight: 600; letter-spacing: .03em;
    color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r-pill); }
  .brand-svc .dot { background: var(--service-accent); }
  .topbar-spacer { flex: 1 1 auto; }

  .cmd-trigger {
    display: inline-flex; align-items: center; gap: var(--s-2);
    min-width: 200px; padding: 6px 10px; color: var(--text-3);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r-md); cursor: pointer; font-size: var(--t-sm);
    transition: border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease); }
  .cmd-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
  .cmd-trigger kbd { margin-left: auto; padding: 1px 6px; font-size: var(--t-xs);
    color: var(--text-2); background: var(--surface-3); border: 1px solid var(--border);
    border-radius: 5px; }

  .topbar-theatre { display:inline-flex; align-items:center; gap:6px; padding:5px 10px;
    font-size: var(--t-sm); color: var(--text-2); background: var(--surface-2);
    border:1px solid var(--border); border-radius: var(--r-md); cursor: pointer; }
  .topbar-theatre b { color: var(--text); font-weight: 600; }

  .live { display:inline-flex; align-items:center; gap:6px; font-size: var(--t-xs);
    color: var(--text-2); letter-spacing:.06em; text-transform: uppercase; }
  .live .dot { background: var(--ok); box-shadow: 0 0 0 0 var(--ok-glow);
    animation: pulse 2.4s infinite; }
  @keyframes pulse { 0%{box-shadow:0 0 0 0 var(--ok-glow);} 70%{box-shadow:0 0 0 6px transparent;} 100%{box-shadow:0 0 0 0 transparent;} }

  .icon-btn { display:inline-grid; place-items:center; width:34px; height:34px;
    color: var(--text-2); background: transparent; border:1px solid transparent;
    border-radius: var(--r-md); cursor:pointer; transition: all var(--dur-1) var(--ease); }
  .icon-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }

  /* ---- middle row: rail + content -------------------------------------- */
  .shell-body { grid-row: 2; display: grid; grid-template-columns: var(--rail-w) 1fr;
    min-height: 0; }
  .shell-body.is-railless { grid-template-columns: 1fr; }
  .shell-body.is-collapsed { grid-template-columns: var(--rail-w-collapsed) 1fr; }

  .rail { background: var(--bg-2); border-right: 1px solid var(--border);
    padding: var(--s-3) var(--s-2); overflow-y: auto; }
  .rail-group + .rail-group { margin-top: var(--s-4); }
  .rail-group-label { padding: 0 var(--s-2) var(--s-1); font-size: var(--t-xs);
    text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
  .rail-item { display:flex; align-items:center; gap:var(--s-3); padding: 8px 10px;
    margin: 1px 0; color: var(--text-2); border-radius: var(--r-md);
    border-left: 2px solid transparent; cursor:pointer; white-space: nowrap;
    transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease); }
  .rail-item:hover { background: var(--surface-1); color: var(--text); text-decoration:none; }
  .rail-item.is-active { background: linear-gradient(90deg, rgba(34,211,238,.10), transparent);
    color: var(--text); border-left-color: var(--accent); font-weight: 600; }
  .rail-item.is-active .icon { color: var(--accent); }
  .is-collapsed .rail-item span { display: none; }

  .content { min-width: 0; overflow-y: auto; }
  .content-inner { max-width: var(--content-max); margin: 0 auto;
    padding: var(--s-6) var(--s-7); }

  .page-header { display:flex; align-items:flex-end; gap: var(--s-4);
    margin-bottom: var(--s-6); padding-bottom: var(--s-4);
    border-bottom: 1px solid var(--border); }
  .page-header .ph-titles { min-width: 0; }
  .page-header h1 { margin: 0; }
  .page-header .ph-sub { color: var(--text-2); font-size: var(--t-sm); }
  .page-header .ph-actions { margin-left: auto; display:flex; gap: var(--s-2); flex: none; }
  .breadcrumbs { display:flex; align-items:center; gap:6px; font-size: var(--t-sm);
    color: var(--text-3); margin-bottom: var(--s-2); }
  .breadcrumbs a { color: var(--text-2); } .breadcrumbs .sep { color: var(--text-3); }

  /* ---- status bar ------------------------------------------------------- */
  .statusbar { grid-row: 3; display:flex; align-items:center; gap: var(--s-4);
    height: var(--statusbar-h); padding: 0 var(--s-4); font-size: var(--t-xs);
    color: var(--text-3); background: var(--bg-2); border-top: 1px solid var(--border);
    font-family: var(--font-mono); }
  .statusbar .sb-item { display:inline-flex; align-items:center; gap:6px; }
  .statusbar .sb-spacer { flex: 1; }

  /* ---- buttons ---------------------------------------------------------- */
  .btn { display:inline-flex; align-items:center; justify-content:center; gap:8px;
    padding: 8px 14px; font: inherit; font-size: var(--t-sm); font-weight: 600;
    color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r-md); cursor: pointer; white-space: nowrap;
    transition: all var(--dur-1) var(--ease); }
  .btn:hover { border-color: var(--border-strong); background: var(--surface-3); text-decoration:none; }
  .btn:active { transform: translateY(1px); }
  .btn:disabled, .btn.is-disabled { opacity: .5; pointer-events: none; }
  .btn--primary { color: var(--accent-ink); background: var(--accent);
    border-color: transparent; box-shadow: 0 0 16px -4px var(--accent-glow); }
  .btn--primary:hover { background: var(--accent-600); box-shadow: var(--glow); }
  .btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
  .btn--ghost:hover { color: var(--text); background: var(--surface-2); }
  .btn--danger { color:#fff; background: var(--crit); border-color: transparent; }
  .btn--danger:hover { filter: brightness(1.08); }
  .btn--sm { padding: 5px 10px; font-size: var(--t-xs); }
  .btn--lg { padding: 11px 20px; font-size: var(--t-base); }
  .btn.is-loading { color: transparent !important; position: relative; pointer-events:none; }
  .btn.is-loading::after { content:""; position:absolute; width:15px; height:15px;
    border:2px solid currentColor; border-top-color: transparent; border-radius:50%;
    color: var(--accent-ink); animation: spin .7s linear infinite; }

  /* ---- cards & panels --------------------------------------------------- */
  .card { background: var(--surface-1); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--sh-1); }
  .card--pad { padding: var(--s-5); }
  .card-head { display:flex; align-items:center; gap: var(--s-3);
    padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
  .card-head h3 { margin: 0; font-size: var(--t-base); }
  .card-head .spacer { flex: 1; }
  .card-body { padding: var(--s-5); }
  .panel { background: var(--surface-1); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--sh-2); }

  .grid { display:grid; gap: var(--s-4); }
  .grid--kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .grid--cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

  /* ---- KPI / stat ------------------------------------------------------- */
  .stat { padding: var(--s-4) var(--s-5); background: var(--surface-1);
    border: 1px solid var(--border); border-radius: var(--r-lg); position: relative;
    overflow: hidden; }
  .stat::before { content:""; position:absolute; inset:0 auto 0 0; width:3px;
    background: var(--service-accent); opacity:.0; }
  .stat:hover::before { opacity:.7; }
  .stat .stat-label { font-size: var(--t-xs); text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-3); }
  .stat .stat-value { font-family: var(--font-mono); font-size: var(--t-2xl);
    font-weight: 600; color: var(--text); line-height: 1.1; margin-top: 4px; }
  .stat .stat-delta { font-size: var(--t-sm); font-weight: 600; margin-top: 4px; }
  .stat .stat-delta.up { color: var(--ok); } .stat .stat-delta.down { color: var(--crit); }

  /* ---- badges / pills / dots ------------------------------------------- */
  .badge { display:inline-flex; align-items:center; gap:5px; padding: 2px 9px;
    font-size: var(--t-xs); font-weight: 600; letter-spacing: .02em;
    border-radius: var(--r-pill); border: 1px solid transparent; white-space: nowrap; }
  .badge--neutral { color: var(--text-2); background: var(--surface-3); border-color: var(--border); }
  .badge--ok   { color: var(--ok);   background: var(--ok-glow);   border-color: rgba(52,211,153,.4); }
  .badge--warn { color: var(--warn); background: var(--warn-glow); border-color: rgba(245,165,36,.4); }
  .badge--crit { color: var(--crit); background: var(--crit-glow); border-color: rgba(244,63,94,.4); }
  .badge--info { color: var(--info); background: rgba(56,189,248,.16); border-color: rgba(56,189,248,.4); }
  .badge--accent { color: var(--accent); background: var(--accent-glow); border-color: rgba(34,211,238,.45); }

  .dot { width:8px; height:8px; border-radius:50%; background: var(--text-3); flex:none;
    display:inline-block; }
  .dot--ok{background:var(--ok);} .dot--warn{background:var(--warn);}
  .dot--crit{background:var(--crit);} .dot--info{background:var(--info);}
  .dot--accent{background:var(--accent);}

  /* ---- tables ----------------------------------------------------------- */
  .table-wrap { overflow:auto; border:1px solid var(--border); border-radius: var(--r-lg);
    background: var(--surface-1); }
  table.table { width:100%; border-collapse: collapse; font-size: var(--t-sm); }
  .table thead th { position: sticky; top:0; z-index:1; text-align:left;
    padding: 10px 14px; font-size: var(--t-xs); text-transform: uppercase;
    letter-spacing:.05em; color: var(--text-3); background: var(--surface-2);
    border-bottom:1px solid var(--border); white-space: nowrap; }
  .table tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border);
    color: var(--text); vertical-align: middle; }
  .table tbody tr:last-child td { border-bottom: 0; }
  .table tbody tr:hover td { background: var(--surface-2); }
  .table .num, .table .mono { font-family: var(--font-mono); }

  /* ---- forms ------------------------------------------------------------ */
  .field { display:block; margin-bottom: var(--s-4); }
  .field > label, .label { display:block; font-size: var(--t-sm); font-weight:600;
    color: var(--text-2); margin-bottom: 6px; }
  .field .help { font-size: var(--t-xs); color: var(--text-3); margin-top: 5px; }
  .field .err { font-size: var(--t-xs); color: var(--crit); margin-top: 5px; }
  .input, .select, .textarea, input[type=text], input[type=number], input[type=search],
  input[type=email], input[type=password], select, textarea {
    width:100%; padding: 9px 11px; font: inherit; font-size: var(--t-sm);
    color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r-md); transition: border-color var(--dur-1) var(--ease),
      box-shadow var(--dur-1) var(--ease); }
  .input:focus, .select:focus, .textarea:focus, input:focus, select:focus, textarea:focus {
    outline:none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
  textarea { min-height: 96px; resize: vertical; }
  ::placeholder { color: var(--text-3); }

  .toggle { position:relative; display:inline-block; width:40px; height:22px; }
  .toggle input { opacity:0; width:0; height:0; }
  .toggle .track { position:absolute; inset:0; background: var(--surface-3);
    border:1px solid var(--border); border-radius:999px; cursor:pointer;
    transition: background var(--dur-1) var(--ease); }
  .toggle .track::before { content:""; position:absolute; left:2px; top:1px;
    width:18px; height:18px; border-radius:50%; background: var(--text-2);
    transition: transform var(--dur-1) var(--ease), background var(--dur-1) var(--ease); }
  .toggle input:checked + .track { background: var(--accent); border-color: transparent; }
  .toggle input:checked + .track::before { transform: translateX(18px); background:#fff; }

  .segmented { display:inline-flex; padding:3px; background: var(--surface-2);
    border:1px solid var(--border); border-radius: var(--r-md); gap:2px; }
  .segmented button { padding:5px 12px; font:inherit; font-size: var(--t-sm);
    color: var(--text-2); background: transparent; border:0; border-radius:7px; cursor:pointer; }
  .segmented button.is-active { color: var(--accent-ink); background: var(--accent); font-weight:600; }

  /* ---- tabs ------------------------------------------------------------- */
  .tabs { display:flex; gap:2px; border-bottom:1px solid var(--border); margin-bottom: var(--s-5); }
  .tabs a, .tabs button { padding: 9px 14px; font:inherit; font-size: var(--t-sm);
    font-weight:600; color: var(--text-2); background:transparent; border:0;
    border-bottom: 2px solid transparent; cursor:pointer; }
  .tabs a:hover, .tabs button:hover { color: var(--text); text-decoration:none; }
  .tabs .is-active { color: var(--accent); border-bottom-color: var(--accent); }

  /* ---- command palette (⌘K) -------------------------------------------- */
  .cmd-overlay { position: fixed; inset:0; z-index: 200; display:none;
    background: rgba(4,7,12,.6); backdrop-filter: blur(3px);
    align-items: flex-start; justify-content: center; padding-top: 12vh; }
  .cmd-overlay.is-open { display:flex; }
  .cmd { width: min(620px, 92vw); background: var(--surface-1);
    border:1px solid var(--border-strong); border-radius: var(--r-lg);
    box-shadow: var(--sh-3), var(--glow); overflow:hidden; }
  .cmd-input-row { display:flex; align-items:center; gap:var(--s-3);
    padding: var(--s-4); border-bottom:1px solid var(--border); }
  .cmd-input-row .icon { color: var(--accent); }
  .cmd-input { flex:1; background:transparent; border:0; outline:0; color: var(--text);
    font-size: var(--t-lg); }
  .cmd-list { max-height: 56vh; overflow-y:auto; padding: 6px; }
  .cmd-section { padding: 8px 12px 4px; font-size: var(--t-xs); text-transform:uppercase;
    letter-spacing:.07em; color: var(--text-3); }
  .cmd-item { display:flex; align-items:center; gap: var(--s-3); padding: 9px 12px;
    border-radius: var(--r-md); cursor:pointer; color: var(--text-2); }
  .cmd-item .cmd-dot { width:7px; height:7px; border-radius:50%; background: var(--service-accent); }
  .cmd-item .cmd-meta { margin-left:auto; font-size: var(--t-xs); color: var(--text-3); }
  .cmd-item.is-active, .cmd-item:hover { background: var(--surface-3); color: var(--text); }
  .cmd-item[hidden] { display:none; }

  /* ---- modal / drawer --------------------------------------------------- */
  .overlay { position: fixed; inset:0; z-index:150; background: rgba(4,7,12,.55);
    backdrop-filter: blur(2px); display:none; }
  .overlay.is-open { display:block; }
  .modal { position: fixed; z-index:151; top:50%; left:50%; transform: translate(-50%,-50%);
    width: min(560px, 94vw); max-height: 86vh; overflow:auto; background: var(--surface-1);
    border:1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--sh-3); }
  .drawer { position: fixed; z-index:151; top:0; right:0; height:100vh; width: min(420px, 92vw);
    background: var(--surface-1); border-left:1px solid var(--border-strong);
    box-shadow: var(--sh-3); transform: translateX(100%); transition: transform var(--dur-3) var(--ease);
    display:flex; flex-direction:column; }
  .drawer.is-open { transform: translateX(0); }
  .drawer-head, .modal-head { display:flex; align-items:center; gap:var(--s-3);
    padding: var(--s-4) var(--s-5); border-bottom:1px solid var(--border); }
  .drawer-head h3, .modal-head h3 { margin:0; font-size: var(--t-base); }
  .drawer-body { padding: var(--s-4); overflow-y:auto; flex:1; }

  /* ---- activity feed ---------------------------------------------------- */
  .activity-item { display:flex; gap: var(--s-3); padding: var(--s-3) var(--s-2);
    border-bottom:1px solid var(--border); }
  .activity-item .ai-dot { margin-top:5px; }
  .activity-item .ai-body { min-width:0; }
  .activity-item .ai-title { color: var(--text); font-size: var(--t-sm); font-weight:600; }
  .activity-item .ai-meta { color: var(--text-3); font-size: var(--t-xs); font-family: var(--font-mono); }

  /* ---- stepper ---------------------------------------------------------- */
  .stepper { display:flex; flex-direction:column; gap:1px; }
  .step-phase { padding: 10px 10px 4px; font-size: var(--t-xs); text-transform:uppercase;
    letter-spacing:.07em; color: var(--text-3); }
  .step { display:flex; align-items:center; gap:var(--s-3); padding: 8px 10px;
    border-radius: var(--r-md); border-left:2px solid transparent; color: var(--text-2);
    cursor:pointer; }
  .step:hover { background: var(--surface-1); color: var(--text); text-decoration:none; }
  .step.is-current { background: rgba(34,211,238,.10); border-left-color: var(--accent);
    color: var(--text); font-weight:600; }
  .step .step-status { width:9px; height:9px; border-radius:50%; background: var(--text-3); flex:none; }
  .step-status--in_progress{background:var(--warn);} .step-status--ai_generated{background:var(--info);}
  .step-status--reviewed{background:var(--accent);} .step-status--completed{background:var(--ok);}
  .progress { height:6px; background: var(--surface-3); border-radius:999px; overflow:hidden; }
  .progress > span { display:block; height:100%; background: linear-gradient(90deg, var(--accent-600), var(--accent));
    box-shadow: 0 0 10px -2px var(--accent-glow); }

  /* ---- settings shell --------------------------------------------------- */
  .settings-layout { display:grid; grid-template-columns: 236px 1fr; gap: var(--s-6); align-items:start; }
  .settings-rail { position: sticky; top: var(--s-4); display:flex; flex-direction:column; gap:2px; }
  .settings-rail a, .settings-rail button { display:flex; align-items:center; gap:var(--s-3);
    padding:9px 12px; border-radius:var(--r-md); color:var(--text-2); background:transparent;
    border:0; border-left:2px solid transparent; cursor:pointer; text-align:left; font:inherit;
    font-size:var(--t-sm); width:100%; }
  .settings-rail a:hover, .settings-rail button:hover { background:var(--surface-1); color:var(--text); text-decoration:none; }
  .settings-rail .is-active { background:rgba(34,211,238,.10); color:var(--text);
    border-left-color:var(--accent); font-weight:600; }
  .settings-rail .is-active .icon { color: var(--accent); }
  .settings-pane { min-width:0; }
  .settings-section { margin-bottom: var(--s-7); }
  .settings-section > h3 { margin-bottom: 2px; }
  .settings-section > .sec-sub { font-size: var(--t-sm); color: var(--text-3); margin-bottom: var(--s-4); }
  .settings-row { display:grid; grid-template-columns: 1fr 300px; gap: var(--s-5); align-items:center;
    padding: var(--s-4) 0; border-bottom: 1px solid var(--border); }
  .settings-row:last-child { border-bottom: 0; }
  .settings-row .sr-label { font-weight: 550; color: var(--text); }
  .settings-row .sr-help { font-size: var(--t-xs); color: var(--text-3); margin-top: 3px; }
  .settings-row .sr-control { justify-self: stretch; }

  /* ---- service launcher / portal --------------------------------------- */
  .portal-hero { position: relative; border-radius: var(--r-lg); overflow: hidden;
    border: 1px solid var(--border); background: var(--surface-1); margin-bottom: var(--s-6); }
  .portal-hero .hero-map { position:absolute; inset:0; }
  .portal-hero .hero-overlay { position: relative; padding: var(--s-8) var(--s-7);
    background: linear-gradient(90deg, rgba(11,14,20,.92) 0%, rgba(11,14,20,.7) 55%, rgba(11,14,20,.2) 100%);
    min-height: 220px; display:flex; flex-direction:column; justify-content:center; }
  .portal-hero h1 { font-size: var(--t-3xl); margin: 0 0 var(--s-2); letter-spacing: -.02em; }
  .portal-hero .hero-tag { color: var(--text-2); max-width: 640px; }
  .portal-hero .hero-scan { position:absolute; inset:0; pointer-events:none; opacity:.5;
    background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(34,211,238,.035) 3px 4px); }
  .svc-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(264px, 1fr)); gap: var(--s-4); }
  .svc-card { display:flex; flex-direction:column; gap: var(--s-3); padding: var(--s-5);
    background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg);
    position: relative; overflow: hidden; transition: border-color var(--dur-1) var(--ease),
      transform var(--dur-1) var(--ease); }
  .svc-card::before { content:""; position:absolute; inset:0 auto 0 0; width:3px;
    background: var(--svc, var(--accent)); }
  .svc-card:hover { border-color: var(--border-strong); transform: translateY(-2px); text-decoration:none; }
  .svc-card .svc-top { display:flex; align-items:center; gap: var(--s-3); }
  .svc-card .svc-ic { display:grid; place-items:center; width:38px; height:38px; border-radius: var(--r-md);
    color: var(--svc, var(--accent)); background: color-mix(in srgb, var(--svc, var(--accent)) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--svc, var(--accent)) 35%, transparent); flex:none; }
  .svc-card .svc-name { font-weight: 650; color: var(--text); }
  .svc-card .svc-port { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--text-3); }
  .svc-card .svc-desc { font-size: var(--t-sm); color: var(--text-2); }
  .svc-card .svc-foot { display:flex; align-items:center; gap: var(--s-2); margin-top:auto;
    font-size: var(--t-xs); color: var(--text-3); }

  /* ---- toasts ----------------------------------------------------------- */
  .toast-host { position: fixed; z-index:300; right: var(--s-4); bottom: var(--s-4);
    display:flex; flex-direction:column; gap: var(--s-2); max-width: 360px; }
  .toast { display:flex; align-items:flex-start; gap: var(--s-3); padding: 11px 13px;
    background: var(--surface-2); border:1px solid var(--border-strong);
    border-left:3px solid var(--accent); border-radius: var(--r-md); box-shadow: var(--sh-2);
    color: var(--text); font-size: var(--t-sm); animation: toastin var(--dur-3) var(--ease); }
  .toast--ok{border-left-color:var(--ok);} .toast--warn{border-left-color:var(--warn);}
  .toast--crit{border-left-color:var(--crit);}
  @keyframes toastin { from{opacity:0; transform: translateY(8px);} to{opacity:1; transform:none;} }

  /* ---- empty / skeleton / tooltip -------------------------------------- */
  .empty { text-align:center; padding: var(--s-9) var(--s-5); color: var(--text-3); }
  .empty .icon { width:34px; height:34px; margin-bottom: var(--s-3); color: var(--text-3); }
  .skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
    background-size: 400% 100%; border-radius: var(--r-sm); animation: shimmer 1.3s infinite; }
  @keyframes shimmer { 0%{background-position:100% 0;} 100%{background-position:-100% 0;} }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* htmx loading affordance */
  .htmx-indicator { opacity:0; transition: opacity var(--dur-2) var(--ease); }
  .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity:1; }
}

/* -------------------------------------------------------------- UTILITIES -- */
@layer utilities {
  .mono { font-family: var(--font-mono); }
  .muted { color: var(--text-2); } .dim { color: var(--text-3); }
  .accent { color: var(--accent); }
  .glow { box-shadow: var(--glow); }
  .tnum { font-variant-numeric: tabular-nums; }
  .row { display:flex; align-items:center; gap: var(--s-3); }
  .row-wrap { display:flex; flex-wrap:wrap; gap: var(--s-2); align-items:center; }
  .col { display:flex; flex-direction:column; gap: var(--s-3); }
  .between { justify-content: space-between; } .center { justify-content:center; }
  .ml-auto { margin-left:auto; } .mt-0{margin-top:0;} .mb-0{margin-bottom:0;}
  .gap-2{gap:var(--s-2);} .gap-4{gap:var(--s-4);} .gap-6{gap:var(--s-6);}
  .mt-4{margin-top:var(--s-4);} .mt-6{margin-top:var(--s-6);} .mb-4{margin-bottom:var(--s-4);}
  .text-sm{font-size:var(--t-sm);} .text-xs{font-size:var(--t-xs);}
  .truncate{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .hidden{display:none !important;}
  @media (max-width: 1024px) {
    .shell-body, .shell-body.is-collapsed { grid-template-columns: 1fr; }
    .rail { position: fixed; z-index: 80; top: var(--topbar-h); bottom: var(--statusbar-h);
      left:0; width: var(--rail-w); transform: translateX(-100%);
      transition: transform var(--dur-3) var(--ease); }
    .rail.is-open { transform: none; }
    .content-inner { padding: var(--s-5) var(--s-4); }
  }
}
