/* Atoriz Control — brand tokens follow platform-landing/atoriz.css (Atoriz Black
   #090909, Aged Bronze #567066, Signal Blue #3978F6). Product accents match the
   portal's pills: Recon blue, Scope violet, OPS coral. */
:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f8f8f5;
  --line: #e2e2dc;
  --line-strong: #cfcfc7;
  --ink: #111214;
  --muted: #62645f;
  --faint: #8d8f89;
  --rail: #090909;
  --rail-ink: #f2f2ee;
  --rail-muted: #9a9c96;
  --bronze: #567066;
  --signal: #3978f6;
  --good: #1f8a5b;
  --good-soft: #e5f4ec;
  --warn: #a86a00;
  --warn-soft: #fbf1dc;
  --bad: #c2412d;
  --bad-soft: #fbe9e5;
  --recon: #3978f6;
  --scope: #7b5ce0;
  --ops: #e65f43;
  --platform: #567066;
  --shadow: 0 1px 2px rgba(16, 17, 19, .05), 0 4px 16px rgba(16, 17, 19, .04);
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e0f; --surface: #15171a; --surface-2: #1b1d21; --line: #272a2f; --line-strong: #353940;
    --ink: #eceee9; --muted: #a3a6a0; --faint: #7a7d78; --rail: #060606;
    --good: #45c08a; --good-soft: rgba(69, 192, 138, .12); --warn: #e0a43a; --warn-soft: rgba(224, 164, 58, .13);
    --bad: #f07a63; --bad-soft: rgba(240, 122, 99, .13); --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e0f; --surface: #15171a; --surface-2: #1b1d21; --line: #272a2f; --line-strong: #353940;
  --ink: #eceee9; --muted: #a3a6a0; --faint: #7a7d78; --rail: #060606;
  --good: #45c08a; --good-soft: rgba(69, 192, 138, .12); --warn: #e0a43a; --warn-soft: rgba(224, 164, 58, .13);
  --bad: #f07a63; --bad-soft: rgba(240, 122, 99, .13); --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; }
.boot { padding: 48px; color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand span { display: block; font-size: 11px; color: var(--rail-muted); letter-spacing: .08em; text-transform: uppercase; }
.nav { display: grid; gap: 2px; }
.nav-label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--rail-muted); padding: 16px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--rail-muted); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--rail-ink); background: rgba(255, 255, 255, .05); }
.nav a.active { color: var(--rail-ink); background: rgba(255, 255, 255, .09); }
.nav .swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.nav .nav-dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; }
.rail-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .08); padding: 14px 8px 0; font-size: 12px; color: var(--rail-muted); display: grid; gap: 8px; }
.rail-foot button { background: none; border: 1px solid rgba(255, 255, 255, .14); color: var(--rail-ink); border-radius: 6px; padding: 6px 10px; cursor: pointer; text-align: left; }
.rail-foot button:hover { border-color: rgba(255, 255, 255, .3); }
.topbar { display: none; }
.main { padding: 28px 32px 64px; max-width: 1360px; width: 100%; }

/* page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 7px 12px; cursor: pointer; font-weight: 500; text-decoration: none; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn[disabled] { opacity: .55; cursor: default; }

/* blocks */
.grid { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; margin-top: 4px; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-body { padding: 14px 16px; }
.section-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 26px 0 10px; }

/* product cards */
.products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.product { position: relative; overflow: hidden; }
.product::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.product .card-head { padding-left: 20px; }
.product .card-body { padding-left: 20px; }
.product-name { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.product-name strong { font-size: 16px; }
.product-name span { color: var(--muted); font-size: 12.5px; }
.envs { display: grid; gap: 8px; }
.env { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.env-name { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.env-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.env-meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.drift { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stats > div { padding: 9px 12px; border-right: 1px solid var(--line); min-width: 0; }
.stats > div:last-child { border-right: 0; }
.stats b { display: block; font-size: 18px; font-weight: 650; }
.stats span { font-size: 11.5px; color: var(--muted); }
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin: 14px 0 -4px; }

/* atoms */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.good { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.pill { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 1px 8px; font-size: 11.5px; font-weight: 600; white-space: nowrap; color: var(--muted); background: var(--surface); }
.pill.good { color: var(--good); border-color: transparent; background: var(--good-soft); }
.pill.warn { color: var(--warn); border-color: transparent; background: var(--warn-soft); }
.pill.bad { color: var(--bad); border-color: transparent; background: var(--bad-soft); }
.pill.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.sha { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 5px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
a.sha:hover { border-color: var(--ink); }
.note { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); background: var(--surface-2); }
.note.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.note.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.empty { padding: 22px; text-align: center; color: var(--faint); font-size: 13px; }
.errors { margin-top: 10px; display: grid; gap: 4px; }
.errors div { font-size: 12px; color: var(--warn); }

/* lists + tables */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: baseline; padding: 9px 16px; border-top: 1px solid var(--line); min-width: 0; }
.list li:first-child { border-top: 0; }
.list .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.list a.title:hover { text-decoration: underline; }
.list .meta { color: var(--faint); font-size: 12px; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* layout helpers */
.two { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.halves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search { flex: 1; min-width: 200px; max-width: 420px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 8px 12px; font: inherit; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--muted); padding: 7px 12px; cursor: pointer; border-right: 1px solid var(--line); font-weight: 500; }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--ink); color: var(--surface); }

/* chart */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; align-items: end; height: 120px; padding-top: 8px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar i { display: block; width: 100%; max-width: 30px; background: var(--signal); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar b { font-size: 11px; font-weight: 600; color: var(--muted); }
.bar span { font-size: 10px; color: var(--faint); white-space: nowrap; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--rail); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; padding: 28px; }
.auth-card h1 { margin: 12px 0 4px; font-size: 20px; }
.auth-card p { margin: 0 0 18px; color: var(--muted); }
.field { display: grid; gap: 5px; margin-bottom: 12px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 9px 11px; font: inherit; font-weight: 400; }
.auth-card .btn { width: 100%; justify-content: center; padding: 9px; margin-top: 4px; }
.auth-msg { margin-top: 12px; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.auth-msg.bad { color: var(--bad); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .products, .two, .halves { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 20; transform: translateX(-100%); transition: transform .18s ease; }
  .shell.open .rail { transform: none; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--rail); color: var(--rail-ink); position: sticky; top: 0; z-index: 10; }
  .topbar button { background: none; border: 1px solid rgba(255, 255, 255, .2); color: inherit; border-radius: 6px; padding: 4px 10px; }
  .main { padding: 18px 16px 48px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .env { grid-template-columns: 38px minmax(0, 1fr); }
  .env-meta { grid-column: 2; white-space: normal; }
  .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats.four > div:nth-child(2) { border-right: 0; }
  .stats.four > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

/* admin actions */
.action-form { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 12px; margin: 10px 0; display: grid; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 10px; }
.field select { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 8px 10px; font: inherit; font-weight: 400; }
.field input[type="date"], .field input[type="number"] { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 8px 10px; font: inherit; font-weight: 400; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr 1fr; } }

/* sign-in: password visibility toggle, text button */
.password-field { position: relative; display: block; }
.password-field input { width: 100%; padding: 9px 42px 9px 11px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 7px; font: inherit; font-weight: 400; }
.password-field .eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 32px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; }
.password-field .eye:hover, .password-field .eye:focus-visible { color: var(--ink); background: var(--surface-2); }
.password-field .eye svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link-button { display: block; margin: 10px auto 0; border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px; }
.link-button:hover { color: var(--ink); }
