/* Atomic Tech Command Center -- one design system for every page.
   One type family (system UI sans) + tabular numerals, one 4px spacing rhythm,
   one color set with a light and a dark theme. Colors live ONLY in the tokens
   below; components never use raw colors. */

:root {
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px;
  --s8: 32px; --s10: 40px;
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --side: 248px;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --sunken: #e9ecf0;
  --text: #15181d;
  --text-2: #4a5260;
  --muted: #6b7381;
  --border: #e1e4e9;
  --border-strong: #cdd2da;
  --accent: #2557d6;
  --accent-text: #ffffff;
  --accent-soft: #e8eefc;
  --focus: #2557d6;
  --good: #1b7a4a;  --good-soft: #e5f4ec;
  --warn: #9a5a00;  --warn-soft: #fbf0dc;
  --bad: #b8312a;   --bad-soft: #fbe7e5;
  --side-bg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1d222a; --sunken: #12161b;
    --text: #e8ebf0; --text-2: #b6bdc8; --muted: #8b94a3;
    --border: #262c35; --border-strong: #343b46;
    --accent: #7ea2ff; --accent-text: #0b1020; --accent-soft: #1c2640; --focus: #9db8ff;
    --good: #5cc98f; --good-soft: #15291f; --warn: #e8b05a; --warn-soft: #2e2413;
    --bad: #f0857c; --bad-soft: #321b19; --side-bg: #13171c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --surface-2: #1d222a; --sunken: #12161b;
  --text: #e8ebf0; --text-2: #b6bdc8; --muted: #8b94a3;
  --border: #262c35; --border-strong: #343b46;
  --accent: #7ea2ff; --accent-text: #0b1020; --accent-soft: #1c2640; --focus: #9db8ff;
  --good: #5cc98f; --good-soft: #15291f; --warn: #e8b05a; --warn-soft: #2e2413;
  --bad: #f0857c; --bad-soft: #321b19; --side-bg: #13171c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none;
        stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- shell -- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--side-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: var(--s4) var(--s3);
}
.brand { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s2) var(--s5); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 14px;
}
.brand-name { font-weight: 650; font-size: 15px; line-height: 1.15; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
             color: var(--muted); padding: var(--s4) var(--s3) var(--s2); }
.nav a {
  display: flex; align-items: center; gap: var(--s3); padding: 9px var(--s3);
  border-radius: var(--r-sm); color: var(--text-2); font-weight: 520; font-size: 14px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
/* Sections are chapters: a native <details> per section (no script needed),
   its tools listed underneath. The section you are in starts open. */
.chapter summary {
  display: flex; align-items: center; gap: var(--s3); padding: 9px var(--s3);
  border-radius: var(--r-sm); color: var(--text-2); font-weight: 520; font-size: 14px;
  cursor: pointer; list-style: none; user-select: none;
}
.chapter summary::-webkit-details-marker { display: none; }
.chapter summary:hover { background: var(--surface-2); color: var(--text); }
.chapter summary span { flex: 1; }
.chapter summary.here { color: var(--text); font-weight: 620; }
.chapter summary .chev { width: 15px; height: 15px; color: var(--muted); transition: transform .15s ease; }
.chapter[open] summary .chev { transform: rotate(90deg); }
.sub { list-style: none; margin: 2px 0 var(--s2) 21px; padding: 0 0 0 var(--s3);
       border-left: 1px solid var(--border); }
.sub a {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: 6px var(--s3); border-radius: var(--r-sm); color: var(--text-2);
  font-size: 13.5px; line-height: 1.3;
}
.sub a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sub a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 560; }
.sub svg.ext { width: 13px; height: 13px; opacity: .45; }
.sub a:hover svg.ext { opacity: .8; }
.sub-empty { font-size: 13px; color: var(--muted); padding: 6px var(--s3); }

.side-foot { margin-top: auto; padding-top: var(--s4); border-top: 1px solid var(--border);
             display: flex; flex-direction: column; gap: var(--s3); }
.me { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2);
          border: 1px solid var(--border); display: grid; place-items: center;
          font-size: 12px; font-weight: 650; color: var(--text-2); flex: none; }
.me-name { font-size: 13px; font-weight: 600; }
.me-mail { font-size: 12px; color: var(--muted); word-break: break-all; }
.foot-row { display: flex; gap: var(--s2); padding: 0 var(--s2); }

.main { min-width: 0; padding: var(--s8) var(--s10) var(--s10); max-width: 1320px; width: 100%; }
.topbar { display: none; }
#navtoggle { display: none; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
             gap: var(--s4); margin-bottom: var(--s6); }
.page-head p { margin: var(--s1) 0 0; color: var(--text-2); }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: var(--s2); }
.crumb a { color: var(--muted); }

/* -------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex; align-items: center; gap: var(--s2); padding: 8px 14px;
  border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
  font-weight: 560; cursor: pointer; line-height: 1.2; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ---------------------------------------------------------------- cards -- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
        box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
             padding: var(--s4) var(--s5) var(--s2); }
.card-body { padding: var(--s2) var(--s5) var(--s4); }
.card-foot { padding: var(--s3) var(--s5); border-top: 1px solid var(--border);
             font-size: 12px; color: var(--muted); display: flex; justify-content: space-between;
             gap: var(--s3); flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
       letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

/* --------------------------------------------------------------- welcome -- */
.lanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s6);
         align-items: start; }
.lane > h2 { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3);
             font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.lane-count { font-size: 12px; color: var(--muted); font-weight: 500; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3);
           padding: 9px 0; border-bottom: 1px solid var(--border); }
.rows li:last-child { border-bottom: 0; }
.row-label { min-width: 0; }
.row-label .note { display: block; font-size: 12px; color: var(--muted); }
.row-value { font-weight: 620; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tone-good { color: var(--good); } .tone-warn { color: var(--warn); } .tone-bad { color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.tone-good { background: var(--good-soft); } .pill.tone-warn { background: var(--warn-soft); }
.pill.tone-bad { background: var(--bad-soft); }
.empty { display: flex; gap: var(--s3); align-items: flex-start; color: var(--muted);
         font-size: 14px; padding: var(--s2) 0 var(--s1); }
.empty svg.i { margin-top: 2px; color: var(--border-strong); }
.err { color: var(--warn); font-size: 14px; }
.card-body.pt { padding-top: var(--s5); }
.maxw { max-width: 640px; }
.mt { margin: var(--s4) 0 0; }
.quick { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* ------------------------------------------------------------- sections -- */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: var(--s4); }
.tool-card { display: flex; flex-direction: column; }
.tool-card .card-body { flex: 1; }
.tool-card p { margin: 0 0 var(--s3); color: var(--text-2); font-size: 14px; }
.links { display: flex; flex-wrap: wrap; gap: var(--s2); }
.legacy { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.banner { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4);
          border-radius: var(--r); background: var(--accent-soft); color: var(--text);
          font-size: 14px; margin-bottom: var(--s6); }
.banner.warn { background: var(--warn-soft); }
.banner.bad { background: var(--bad-soft); }
.banner.good { background: var(--good-soft); }

/* ----------------------------------------------------------------- grid -- */
.tabs { display: flex; gap: var(--s1); overflow-x: auto; padding-bottom: var(--s2);
        margin-bottom: var(--s4); border-bottom: 1px solid var(--border); }
.tabs a { padding: 7px 12px; border-radius: var(--r-sm); white-space: nowrap; color: var(--text-2);
          font-size: 14px; font-weight: 540; }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.tabs a:hover { text-decoration: none; background: var(--surface-2); }
.grid-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--border);
             border-radius: var(--r-lg); background: var(--surface); }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
table.grid th, table.grid td { border-bottom: 1px solid var(--border); padding: 0; }
table.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2);
                      font-weight: 600; color: var(--text-2); vertical-align: bottom; }
table.grid thead th .colh { display: block; padding: var(--s3) var(--s2); width: 96px;
                            line-height: 1.25; text-align: center; }
table.grid thead th.sec .colh { color: var(--accent); }
table.grid th.who, table.grid td.who { position: sticky; left: 0; z-index: 1; background: var(--surface);
                                       text-align: left; border-right: 1px solid var(--border); }
table.grid thead th.who { z-index: 3; background: var(--surface-2); padding: var(--s3); }
td.who { padding: var(--s2) var(--s3) !important; min-width: 200px; }
td.who .n { font-weight: 600; font-size: 13px; }
td.who .m { font-size: 11px; color: var(--muted); }
td.c { text-align: center; }
td.c.sec { background: var(--accent-soft); }
.cell { display: grid; place-items: center; width: 96px; height: 44px; position: relative; cursor: pointer; }
.cell input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.cell.changed::before { content: ""; position: absolute; top: 6px; left: 8px; width: 7px;
                        height: 7px; border-radius: 2px; background: var(--warn); }
.cell.inert input { opacity: .45; }
.cell .live { position: absolute; top: 6px; right: 8px; width: 7px; height: 7px; border-radius: 50%;
              background: var(--good); }
.cell.locked { cursor: default; color: var(--muted); font-size: 12px; }
.cell .count { font-weight: 620; font-size: 13px; }
.cell .count.zero { color: var(--muted); font-weight: 500; }
a.cell:hover { background: var(--surface-2); text-decoration: none; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s4); font-size: 12px; color: var(--muted);
          margin: var(--s3) 0; align-items: center; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px;
      margin-right: 6px; border: 1px solid var(--border); }
.sw.changed { width: 8px; height: 8px; border-radius: 2px; background: var(--warn); border: 0; }
.sw.live { width: 8px; height: 8px; border-radius: 50%; background: var(--good); border: 0; }
.sw.sec { background: var(--accent-soft); }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3);
       padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--border);
       border-radius: var(--r); margin-bottom: var(--s4); }
.bar form { display: inline; }
.toast { position: fixed; bottom: var(--s5); left: 50%; transform: translateX(-50%);
         background: var(--text); color: var(--bg); padding: var(--s2) var(--s4);
         border-radius: var(--r-sm); font-size: 14px; display: none; z-index: 50; }
.toast.on { display: block; }

table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th, table.list td { text-align: left; padding: var(--s2) var(--s3);
                               border-bottom: 1px solid var(--border); vertical-align: top; }
table.list th { color: var(--muted); font-weight: 600; font-size: 12px; }
.change-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chg { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 560; }
.chg.add { background: var(--good-soft); color: var(--good); }
.chg.remove { background: var(--bad-soft); color: var(--bad); }

/* ---------------------------------------------------------------- login -- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); }
.auth-card { width: 100%; max-width: 400px; padding: var(--s8); }
.auth-card h1 { font-size: 22px; margin: var(--s5) 0 var(--s2); }
.auth-card p { color: var(--text-2); margin: 0 0 var(--s6); }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); }
.field input { font: inherit; padding: 10px 12px; border-radius: var(--r-sm);
               border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.auth-alt { margin-top: var(--s5); text-align: center; font-size: 13px; }

/* ---------------------------------------------------------------- phone -- */
@media (max-width: 1100px) {
  .lanes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
    position: sticky; top: 0; z-index: 20; padding: var(--s3) var(--s4);
    background: var(--side-bg); border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; }
  .menu-btn { display: inline-grid; place-items: center; width: 40px; height: 40px;
              border-radius: var(--r-sm); border: 1px solid var(--border); cursor: pointer;
              background: var(--surface); color: var(--text); }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: min(86vw, 300px);
          transform: translateX(-100%); transition: transform .18s ease;
          box-shadow: 0 10px 30px rgba(0,0,0,.25); }
  .scrim { display: none; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.35); }
  #navtoggle:checked ~ .shell .side { transform: none; }
  #navtoggle:checked ~ .shell .scrim { display: block; }
  .main { padding: var(--s5) var(--s4) var(--s8); }
  h1 { font-size: 22px; }
  .lanes { grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
  .card-head, .card-body { padding-left: var(--s4); padding-right: var(--s4); }
  .card-foot { padding-left: var(--s4); padding-right: var(--s4); }
  .grid-wrap { max-height: none; }
}
@media (min-width: 861px) { .scrim { display: none; } }
