/* ===================================================================
   IRIS — design tokens + component styles
   The "Assembly Mills (AMOS)" visual language: warm cream ground, flat
   white cards, rust accent, earthy data palette. Source of truth for the
   IRIS front end. See docs/design/BRAND.md.

   Framework-agnostic plain CSS — works on its own; Tailwind (see
   tailwind.config.js) maps these same tokens to utility classes.
   =================================================================== */

/* --- Self-hosted display/body face (add the woff2 files, then this wins
       over the system fallback). See docs/design/BRAND.md. --- */
/* @font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/inter/Inter-Variable.woff2") format("woff2");
} */

/* ---------- tokens (light) ---------- */
:root {
  /* ground */
  --bg:        #F4EEE3;
  --surface:   #FFFFFF;
  --surface-2: #FBF8F1;
  --border:    #E7DFCF;
  --hairline:  #EBE4D6;
  /* ink */
  --ink:       #211E19;
  --ink-soft:  #4A453C;
  --muted:     #8C8578;
  /* brand */
  --accent:    #B26A38;   /* rust — eyebrows, links, focus */
  --pill:      #1E1B16;   /* active nav pill */
  --pill-ink:  #F4EEE3;
  /* attention / critical banner */
  --crit-bg:   #FAEBE9;
  --crit-bd:   #EFD4D0;
  --crit-ink:  #A5433C;
  /* earthy data palette (charts, category bars) */
  --c-gray:  #8B8578;
  --c-rust:  #C16B36;
  --c-teal:  #2F5E55;
  --c-ochre: #D09A2C;
  --c-olive: #647140;
  --c-char:  #39352E;
  /* semantic status (separate from the accent) */
  --good:    #5F7A45;
  --good-bg: #ECEFE2;
  --warn:    #C79024;
  --crit:    #B24A42;

  --radius:    15px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(40, 34, 22, .04);
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- tokens (dark) ---------- */
:root[data-theme="dark"] {
  --bg:        #201D18;
  --surface:   #2A2620;
  --surface-2: #262019;
  --border:    #3A342B;
  --hairline:  #332E26;
  --ink:       #F1EADD;
  --ink-soft:  #D2CBBB;
  --muted:     #9C9584;
  --accent:    #D08A52;
  --pill:      #F1EADD;
  --pill-ink:  #201D18;
  --crit-bg:   #382420;
  --crit-bd:   #573330;
  --crit-ink:  #E8A79E;
  --c-gray:  #A39C8B;
  --c-rust:  #D2814E;
  --c-teal:  #4E8E80;
  --c-ochre: #E0B24A;
  --c-olive: #8B9B5E;
  --c-char:  #CDC5B5;
  --good:    #8CA867;
  --good-bg: #2E2E22;
  --warn:    #E0B24A;
  --crit:    #DB8078;
  --shadow:  0 1px 2px rgba(0, 0, 0, .25);
}
/* Follow the OS when the user hasn't explicitly toggled */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#201D18; --surface:#2A2620; --surface-2:#262019; --border:#3A342B; --hairline:#332E26;
    --ink:#F1EADD; --ink-soft:#D2CBBB; --muted:#9C9584;
    --accent:#D08A52; --pill:#F1EADD; --pill-ink:#201D18;
    --crit-bg:#382420; --crit-bd:#573330; --crit-ink:#E8A79E;
    --c-gray:#A39C8B; --c-rust:#D2814E; --c-teal:#4E8E80; --c-ochre:#E0B24A; --c-olive:#8B9B5E; --c-char:#CDC5B5;
    --good:#8CA867; --good-bg:#2E2E22; --warn:#E0B24A; --crit:#DB8078; --shadow:0 1px 2px rgba(0,0,0,.25);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- app shell ---------- */
.app  { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; }

/* ---------- sidebar ---------- */
.side { background: var(--bg); border-right: 1px solid var(--hairline); padding: 18px 14px 28px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 6px 0; }
.brand .logo { width: 38px; height: 38px; border-radius: 10px; background: var(--pill); color: var(--pill-ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; letter-spacing: .5px; }
.brand .name { font-weight: 650; font-size: 14.5px; letter-spacing: -.1px; }
.brand .sub  { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; font-weight: 600; letter-spacing: .9px; text-transform: uppercase; color: var(--muted); padding: 0 8px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink-soft); font-size: 13.5px; font-weight: 500; text-decoration: none; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; font-family: inherit; transition: background .15s, color .15s; }
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--pill); color: var(--pill-ink); font-weight: 550; }
.nav-item.active svg { opacity: 1; }
.nav-item.muted { color: var(--muted); }
.nav-item .chip { margin-left: auto; font-size: 9.5px; font-weight: 600; letter-spacing: .4px; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; }
.chip.live { color: var(--good); background: var(--good-bg); }
.chip.soon { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 34px; border-bottom: 1px solid var(--hairline); }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs b { color: var(--ink-soft); font-weight: 550; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft); cursor: pointer; display: grid; place-items: center; }
.icon-btn svg { width: 16px; height: 16px; }
.btn { font-family: inherit; font-size: 13px; font-weight: 550; color: var(--ink-soft); padding: 8px 15px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--pill); color: var(--pill-ink); border-color: var(--pill); }
.btn-primary:hover { opacity: .92; background: var(--pill); }

/* ---------- content + headings ---------- */
.content { padding: 30px 34px 48px; display: flex; flex-direction: column; gap: 22px; max-width: 1240px; }
.eyebrow { font-size: 11.5px; font-weight: 650; letter-spacing: 1.4px; text-transform: uppercase; color: var(--accent); }
h1.title { font-size: 40px; font-weight: 680; letter-spacing: -1.1px; margin: 8px 0 6px; text-wrap: balance; }
.lede { font-size: 15px; color: var(--muted); }

/* ---------- attention banner ---------- */
.banner { display: flex; align-items: center; gap: 10px; background: var(--crit-bg); border: 1px solid var(--crit-bd); color: var(--crit-ink); padding: 13px 18px; border-radius: var(--radius); font-size: 13.5px; font-weight: 500; }
.banner svg { width: 16px; height: 16px; flex: none; }

/* ---------- cards + stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { padding: 20px 20px 22px; display: flex; flex-direction: column; gap: 3px; min-height: 148px; }
.stat .k { font-size: 11px; font-weight: 600; letter-spacing: .9px; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 40px; font-weight: 680; letter-spacing: -1.5px; margin-top: auto; font-variant-numeric: tabular-nums; }
.stat .v.good { color: var(--good); }
.stat .cap { font-size: 12.5px; color: var(--muted); }
.statlist { padding: 20px; display: flex; flex-direction: column; gap: 11px; justify-content: center; }
.statlist .hd { font-size: 11px; font-weight: 600; letter-spacing: .9px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.statlist .row { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; }
.statlist .row span { color: var(--ink-soft); }
.statlist .row b { font-weight: 650; font-variant-numeric: tabular-nums; }
.statlist .row .dot { display: inline-flex; align-items: center; gap: 8px; }
.dotmark { width: 7px; height: 7px; border-radius: 999px; display: inline-block; }

/* ---------- panel head ---------- */
.panel-head { padding: 20px 22px 4px; }
.panel-head h2 { font-size: 16px; font-weight: 640; letter-spacing: -.3px; }
.panel-head p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.panel-head .row { display: flex; align-items: center; justify-content: space-between; }
.panel-head .link { font-size: 13px; color: var(--accent); font-weight: 550; text-decoration: none; }

/* ---------- health / list rows with bars ---------- */
.list { padding: 14px 22px 22px; display: flex; flex-direction: column; }
.lrow { display: grid; grid-template-columns: 190px 1fr auto; align-items: center; gap: 16px; padding: 11px 0; border-top: 1px solid var(--hairline); }
.lrow:first-child { border-top: 0; }
.lrow .svc { font-size: 13.5px; font-weight: 500; }
.lrow .svc small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; margin-top: 1px; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; }

/* ---------- embedded tool view (full-height pane) ---------- */
.content.embed { max-width: none; padding: 18px 24px 22px; gap: 12px; }
.embed-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.embed-head .title { font-size: 25px; letter-spacing: -.6px; margin: 3px 0 0; }
.embed-head .grow { margin-left: auto; }
.embed-shell { height: calc(100vh - 172px); min-height: 440px; padding: 0; overflow: hidden; }
.embed-shell iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--surface-2); }

/* ---------- status pills ---------- */
.pill { font-size: 11px; font-weight: 600; letter-spacing: .3px; padding: 4px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.pill.op   { color: var(--good); background: var(--good-bg); }
.pill.plan { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill.crit { color: var(--crit); background: var(--crit-bg); }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--hairline); gap: 14px; align-items: center; }
  .brand { flex: none; }
  .nav-group { flex-direction: row; flex: none; }
  .nav-label { display: none; }
  .nav-item .chip { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  h1.title { font-size: 32px; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .lrow { grid-template-columns: 1fr auto; }
  .lrow .bar { display: none; }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
