/* ============================================================
   Beacon CS — Design System
   Fin (Intercom) aligned: light, restrained, generous whitespace,
   thin borders, low saturation. Inter type. Dark slate nav.
   ============================================================ */

:root {
  /* Brand — BMDS teal (Day). Replaces former blue. */
  --blue: #03B2BD;
  --blue-600: #029AA3;
  --blue-50: rgba(3,178,189,.10);
  --blue-100: rgba(3,178,189,.20);
  --purple: #03B2BD;      /* AI accent → brand teal (BMDS has no purple) */
  --purple-50: rgba(3,178,189,.10);

  /* Nav rail — BMDS Night surface tokens */
  --nav: #1B1D1F;
  --nav-2: #262729;
  --nav-hover: #262729;
  --nav-text: #787878;
  --nav-text-active: #F3F3F3;

  /* Neutrals — BMDS Day (primary #0F0F0F, secondary #B0B0B0, third #CCCCCC).
     Mid-greys are legibility-safe tints between those anchors. */
  --ink: #0F0F0F;
  --ink-2: #4D4D4D;
  --ink-3: #787878;
  --ink-4: #B0B0B0;
  --line: #E8E8E9;
  --line-2: #F3F4F7;
  --bg: #FFFFFF;
  --bg-2: #F4F4F4;
  --card: #FFFFFF;

  /* AI summary / copilot card → BMDS warning (amber) */
  --amber: #F19D1E;
  --amber-bg: rgba(241,157,30,.10);
  --amber-bd: rgba(241,157,30,.32);
  --amber-ink: #9A6510;

  /* Semantic — BMDS buy / warning / sell */
  --green: #13C287;
  --green-bg: rgba(19,194,135,.10);
  --green-bd: rgba(19,194,135,.30);
  --orange: #F19D1E;
  --orange-bg: rgba(241,157,30,.10);
  --orange-bd: rgba(241,157,30,.32);
  --red: #FA3B61;
  --red-bg: rgba(250,59,97,.10);
  --red-bd: rgba(250,59,97,.30);

  /* BMDS radius scale: 2 4 8 12 16 20 24 · pill 9999 */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  /* BMDS forbids shadows — elevation = border + bg tone. Kept as no-ops. */
  --shadow-sm: none;
  --shadow-soft: none;
  --shadow: none;
  --shadow-md: none;
  --shadow-lg: none;

  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px;
  --sans: "Alexandria", sans-serif;
  --mono: "Alexandria", sans-serif;  /* Alexandria-only; numerics use tabular-nums */
}

* { box-sizing: border-box; }
/* Remix Icon glyphs must keep their own font even under BMDS's global Alexandria rule */
[class^="ri-"], [class*=" ri-"],
[class^="ri-"]::before, [class*=" ri-"]::before {
  font-family: "remixicon" !important; font-style: normal; -webkit-font-smoothing: antialiased;
}
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.35;
}
#root { height: 100%; }
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }
::selection { background: var(--blue-100); }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0; }

/* ============================================================ APP SHELL */
.app { display: flex; height: 100vh; overflow: hidden; }

/* --- dark slate left nav --- */
.nav {
  width: 232px; flex-shrink: 0; background: var(--nav);
  display: flex; flex-direction: column; color: var(--nav-text);
  border-right: 1px solid #0B1220;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px; color: var(--nav-text-active);
}
.nav-logo {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--blue);
  display: grid; place-items: center; color: #00211f; font-weight: 700; font-size: 15px;
}
.nav-brand-name { font-weight: 600; font-size: 15px; letter-spacing: 0; }
.nav-brand-sub { font-size: 10.5px; color: #787878; margin-top: 2px; letter-spacing: 0; }
.nav-sections { padding: 6px 12px; flex: 1; overflow-y: auto; }
.nav-group-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0;
  color: #5C6066; padding: 16px 10px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 11px; border-radius: 8px; border: none; background: none;
  color: var(--nav-text); font-size: 13.5px; font-weight: 500; text-align: left;
  margin-bottom: 2px; transition: background var(--motion-exit), color var(--motion-exit); position: relative;
}
.nav-item:hover { background: var(--nav-hover); color: #E5E5E5; }
.nav-item.active { background: var(--blue); color: #00211f; }
.nav-item.active .nav-ico { opacity: 1; }
.nav-ico { width: 17px; height: 17px; opacity: .8; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 600; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; display: grid; place-items: center;
  background: #334155; color: #CBD5E1;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.22); color: #fff; }
.nav-badge.red { background: var(--red); color: #fff; }
.nav-foot { padding: 12px; border-top: 1px solid #1E293B; }
.nav-widget-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px;
  border-radius: 8px; background: #1E293B; color: #E2E8F0; border: 1px solid #334155;
  font-size: 12.5px; font-weight: 500; transition: background .12s;
}
.nav-widget-btn:hover { background: #273449; }

/* --- main column --- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* --- thin top bar --- */
.topbar {
  height: 54px; flex-shrink: 0; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
}
.topbar-title { font-weight: 600; font-size: 15px; letter-spacing: 0; }
.topbar-crumb { color: var(--ink-4); font-size: 13px; }
.topbar-search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid transparent; border-radius: 8px;
  padding: 7px 12px; width: 270px; color: var(--ink-4); font-size: 13px;
}
.topbar-search:focus-within { border-color: var(--blue); background: #fff; }
.topbar-search input { border: none; background: none; outline: none; flex: 1; font-size: 13px; color: var(--ink); }
.agent-status {
  display: flex; align-items: center; gap: 9px; padding: 5px 6px 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; font-size: 12.5px; font-weight: 500;
}
.agent-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.agent-av { width: 26px; height: 26px; border-radius: 50%; background: var(--blue); color: #00211f;
  display: grid; place-items: center; font-size: 11px; font-weight: 600; }

@media (max-width: 1180px) {
  .topbar-crumb { display: none; }
}

/* --- content region --- */
.content { flex: 1; overflow-y: auto; background: var(--bg); }
.content-pad { padding: 24px 28px 64px; max-width: 1320px; margin: 0 auto; }
.page-head { margin-bottom: 20px; }
.page-h1 { font-size: 19px; font-weight: 600; letter-spacing: 0; margin: 0; }
.page-sub { color: var(--ink-3); font-size: 13px; margin-top: 6px; letter-spacing: 0; max-width: 760px; }

/* ============================================================ PRIMITIVES */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }
.grid { display: grid; gap: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
}
.card-title { font-weight: 600; font-size: 14px; letter-spacing: 0; }
.card-sub { color: var(--ink-3); font-size: 12.5px; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border: none; background: none; color: var(--ink-3);
  font-size: 13.5px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--motion-exit), border-color var(--motion-exit); letter-spacing: 0;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.tab-count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: 999px; background: var(--bg-2); color: var(--ink-3);
  font-size: 10.5px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
}
.tab.active .tab-count { background: var(--blue-50); color: var(--blue-600); }

/* pills / sub-tabs */
.pills { display: flex; gap: 6px; }
.pill {
  padding: 6px 13px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--ink-2); font-size: 12.5px; font-weight: 500;
}
.pill:hover { border-color: #CBD5E1; }
.pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 9999px;
  font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--ink);
  transition: opacity .12s, background .12s, border-color .12s;
}
.btn:hover { background: var(--bg-2); }
.btn:active { opacity: .8; }
.btn:focus-visible, .pill:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-600); border-color: var(--blue-600); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn.sm { padding: 6px 13px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.locked { background: var(--bg-2); color: var(--ink-4); border-color: var(--line); cursor: not-allowed; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; line-height: 1.7; border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge.gray { background: transparent; color: var(--ink-3); border-color: var(--line); }

/* chrome-less status: dot + text */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-ico { color: var(--ink-4); flex-shrink: 0; }
.badge.blue { background: var(--blue-50); color: var(--blue-600); border-color: var(--blue-100); }
.badge.purple { background: var(--amber-bg); color: var(--amber-ink); border-color: var(--amber-bd); }
.badge.green { background: var(--green-bg); color: #15803D; border-color: var(--green-bd); }
.badge.amber { background: var(--amber-bg); color: var(--amber-ink); border-color: var(--amber-bd); }
.badge.orange { background: var(--orange-bg); color: #C2410C; border-color: var(--orange-bd); }
.badge.red { background: var(--red-bg); color: #B91C1C; border-color: var(--red-bd); }

/* redline marker — quiet, BMDS-restrained: hairline + small red lock glyph, no red fill */
.redline {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 500; background: transparent; color: var(--ink-2);
  border: 1px solid var(--line);
}
.redline i { color: var(--red); }
.lock-field {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-3);
  font-size: 11.5px; font-weight: 500; letter-spacing: 0;
}
.lock-field i { color: var(--ink-4); }

/* stat tiles */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat-label { font-size: 12px; color: var(--ink-3); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-val { font-size: 26px; font-weight: 600; letter-spacing: 0; margin-top: 8px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-val .unit { font-size: 15px; font-weight: 600; color: var(--ink-3); margin-left: 2px; }
.stat-delta { font-size: 12px; font-weight: 600; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-bar { height: 4px; border-radius: 4px; background: var(--bg-2); margin-top: 12px; overflow: hidden; }
.stat-bar > i { display: block; height: 100%; border-radius: 4px; background: var(--blue); }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0;
  color: var(--ink-4); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fff;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg-2); }
.tbl tbody tr { transition: background var(--motion-exit); }

/* progress meter */
.meter { height: 7px; border-radius: 7px; background: var(--bg-2); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 7px; }

/* mini sparkbars */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 40px; }
.spark > i { flex: 1; background: var(--blue-100); border-radius: 2px 2px 0 0; min-height: 3px; }
.spark > i.hi { background: var(--blue); }

/* avatars */
.av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0; }
.av.ai { background: var(--purple); }
.av.sm { width: 26px; height: 26px; font-size: 11px; }

/* gate banner — human-review / AI-never-publishes */
.gate {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: var(--radius);
  background: var(--amber-bg); border: 1px solid var(--amber-bd); color: var(--amber-ink);
  font-size: 13px; font-weight: 500;
}
.gate.red { background: var(--red-bg); border-color: var(--red-bd); color: #B91C1C; }
.gate-ico { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  background: rgba(245,158,11,.16); }
.gate.red .gate-ico { background: rgba(220,38,38,.12); }

/* divider */
.hr { height: 1px; background: var(--line-2); border: none; margin: 16px 0; }

/* key-value list */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-weight: 500; }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; text-align: right; }

/* code/diff */
.diff-line { display: flex; gap: 8px; padding: 4px 10px; font-family: var(--mono); font-size: 12px; border-radius: 5px; }
.diff-line.add { background: var(--green-bg); color: #15803D; }
.diff-line.del { background: var(--red-bg); color: #B91C1C; text-decoration: line-through; opacity: .75; }
.diff-line.mod { background: var(--amber-bg); color: var(--amber-ink); }
.diff-sign { font-weight: 700; flex-shrink: 0; }

/* segmented progress dots for flows */
.steps { display: flex; align-items: center; gap: 0; }
.step-dot { display: flex; align-items: center; gap: 8px; }
.step-num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; background: var(--bg-2); color: var(--ink-3); border: 1px solid var(--line); }
.step-num.done { background: var(--green); color: #fff; border-color: var(--green); }
.step-num.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.step-line { width: 38px; height: 2px; background: var(--line); }
.step-line.done { background: var(--green); }
.step-label { font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.step-label.active { color: var(--ink); }

/* empty / inline note */
.note { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; align-items: flex-start; }

/* fade-in */
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fadein { animation: fadein .28s ease; }

/* skeleton — BMDS shimmer between bgline and bgline2 (no gradient color, neutral only) */
@keyframes shimmer { 0% { background-position: -360px 0; } 100% { background-position: 360px 0; } }
.sk { border-radius: 8px; background: var(--bg-2);
  background-image: linear-gradient(90deg, var(--bg-2) 0%, #ECEDEF 40%, var(--bg-2) 80%);
  background-size: 360px 100%; background-repeat: no-repeat; animation: shimmer 1.2s infinite linear; }
.sk-line { height: 12px; margin-bottom: 9px; }
.sk-card { height: 96px; border-radius: var(--radius); }

/* empty state */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 48px 24px; color: var(--ink-3); }
.empty-ico { width: 46px; height: 46px; border-radius: 12px; background: var(--bg-2); color: var(--ink-4);
  display: grid; place-items: center; margin-bottom: 14px; font-size: 22px; }
.empty-title { font-weight: 600; font-size: 14px; color: var(--ink); letter-spacing: 0; }
.empty-sub { font-size: 12.5px; margin-top: 5px; max-width: 320px; line-height: 1.5; }

@media (max-width: 760px) {
  html, body, #root { min-height: 100%; }
  .app {
    height: 100dvh;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
  }

  .nav {
    width: 100%;
    height: auto;
    max-height: 156px;
    border-right: none;
    border-bottom: 1px solid #0B1220;
  }
  .nav-brand {
    padding: 12px 14px 8px;
  }
  .nav-brand-name { font-size: 14px; }
  .nav-brand-sub { font-size: 10px; }
  .nav-sections {
    display: flex;
    gap: 4px;
    padding: 6px 10px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 0 0 auto;
    scrollbar-width: none;
  }
  .nav-sections::-webkit-scrollbar { display: none; }
  .nav-sections > div { display: contents; }
  .nav-group-label { display: none; }
  .nav-item {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
    padding: 8px 9px;
    gap: 7px;
    white-space: nowrap;
  }
  .nav-badge {
    margin-left: 0;
    min-width: 17px;
    height: 17px;
    font-size: 10.5px;
  }
  .nav-foot {
    padding: 0 10px 10px;
    border-top: none;
  }
  .nav-widget-btn {
    justify-content: center;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 12px;
  }

  .main {
    width: 100%;
    min-height: 0;
  }
  .topbar {
    height: auto;
    min-height: 48px;
    padding: 8px 12px;
    gap: 8px;
  }
  .topbar .row {
    min-width: 0;
    flex: 1 1 auto;
  }
  .topbar-title {
    font-size: 14px;
    white-space: nowrap;
  }
  .topbar-crumb {
    display: none;
  }
  .topbar-search {
    display: none;
  }
  .agent-status {
    padding: 4px 5px 4px 9px;
    gap: 7px;
    font-size: 12px;
  }
  .agent-av {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  .content {
    min-height: 0;
    overflow: auto;
  }
  .content-pad {
    width: 100%;
    padding: 16px 14px 40px;
    max-width: none;
  }
  .page-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
  .page-head > .row {
    width: 100%;
    flex-wrap: wrap;
  }
  .page-h1 { font-size: 18px; }
  .page-sub { font-size: 12.5px; }

  .spread {
    min-width: 0;
    flex-wrap: wrap;
  }
  .card,
  .stat {
    min-width: 0;
  }
  .card {
    overflow-x: auto;
  }
  .card-head {
    padding: 12px 14px;
    flex-wrap: wrap;
  }
  .card-pad {
    padding: 14px;
  }
  .tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 9px 8px;
    gap: 5px;
    font-size: 12.5px;
  }
  .pills {
    flex-wrap: wrap;
  }
  .btn {
    min-width: 0;
    justify-content: center;
    white-space: normal;
    line-height: 1.25;
  }
  .gate {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .gate > .btn,
  .gate > .row {
    margin-left: 46px;
  }
  .kv {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .kv dd {
    text-align: left;
    overflow-wrap: anywhere;
  }
  .tbl {
    min-width: 720px;
  }
  .steps {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }
  .step-line {
    display: none;
  }
}
