/* Layout only — colours/typography come from tokens.css, widgets from components.css. */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg-0); color: var(--fg); font-family: var(--font-ui); overflow-x: hidden; }
body { min-height: 100dvh; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--fg-dim); font-size: var(--fs-sm); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.panel { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4); margin-bottom: var(--s4); }
.panel > header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); margin-bottom: var(--s3); }
.panel h2 { font-size: var(--fs-md); margin: 0; font-weight: 600; }
.empty { color: var(--fg-dim); text-align: center; padding: var(--s6); }

.top { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-0); z-index: var(--z-sticky); }
.brand { display: flex; align-items: center; gap: var(--s2); }
.orb { width: 10px; height: 10px; border-radius: var(--r-pill); background: var(--info); box-shadow: 0 0 12px var(--info); }
.banner { background: color-mix(in srgb, var(--warn) 18%, var(--bg-1)); border-bottom: 1px solid var(--warn); padding: var(--s2) var(--s4); font-size: var(--fs-sm); }

.shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s4); padding: var(--s4); flex: 1; min-width: 0; }
main, .panel, .toolbar, .chips, .cards { min-width: 0; }
.cards > *, .tun-card { min-width: 0; }
.side { position: sticky; top: 64px; align-self: start; }
.nav { display: flex; flex-direction: column; gap: var(--s1); }
.nav-item { padding: var(--s2) var(--s3); border-radius: var(--r-md); color: var(--fg-dim); min-height: 40px; display: flex; align-items: center; }
.nav-item:hover { background: var(--bg-2); color: var(--fg); }
.nav-item.is-active { background: color-mix(in srgb, var(--brand) 20%, var(--bg-1)); color: var(--fg); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.toolbar { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s3); max-width: 100%; }
.search { background: var(--bg-2); border: 1px solid var(--line); color: var(--fg); border-radius: var(--r-pill); padding: var(--s2) var(--s4); min-height: 40px; font-size: var(--fs-md); }
.table-wrap { overflow-x: auto; padding: 0; }
.dt th[data-sort] { cursor: pointer; user-select: none; }

.feed { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: 160px 1fr 48px; gap: var(--s3); align-items: baseline; padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.ev[data-state="crit"] .ev-kind { color: var(--crit); }
.ev[data-state="warn"] .ev-kind { color: var(--warn); }
.ev[data-state="ok"] .ev-kind { color: var(--ok); }
.ev-detail { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-time { color: var(--fg-dim); text-align: right; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: var(--s2) var(--s4); font-size: var(--fs-sm); }
.kv span { color: var(--fg-dim); }
.rules { margin: 0; padding-left: var(--s5); font-size: var(--fs-sm); color: var(--fg-dim); }
.detail-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.detail-head h3 { margin: 0; font-size: var(--fs-lg); }

.tun-cards { list-style: none; margin: 0; padding: 0; display: none; gap: var(--s2); grid-template-columns: 1fr; }
.tun-card { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3); }
.tun-card[data-state="crit"] { border-color: var(--crit); }
.tun-card[data-state="warn"] { border-color: var(--warn); }
.tc-head { display: flex; align-items: center; gap: var(--s2); justify-content: space-between; }
.tc-cc { color: var(--fg-dim); font-size: var(--fs-xs); }
.tc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); font-size: var(--fs-sm); color: var(--fg-dim); margin-top: var(--s2); }
.tc-ip { font-size: var(--fs-xs); color: var(--fg-dim); margin-top: var(--s1); }

#login { position: fixed; inset: 0; background: rgba(7, 9, 15, 0.94); display: grid; place-items: center; z-index: var(--z-modal); padding: var(--s4); }
#login[hidden] { display: none; }
.login { width: min(380px, 100%); display: grid; gap: var(--s3); }
.login label { display: grid; gap: var(--s1); font-size: var(--fs-sm); color: var(--fg-dim); }
.login input { background: var(--bg-2); border: 1px solid var(--line); color: var(--fg); border-radius: var(--r-md); padding: var(--s3); min-height: 44px; font-size: var(--fs-md); }
.login button { background: var(--brand); color: #fff; border: 0; border-radius: var(--r-md); padding: var(--s3); min-height: 44px; font-size: var(--fs-md); cursor: pointer; }

.bottom { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: var(--s3); padding-bottom: 76px; }
  .side { display: none; }
  .table-wrap { display: none; }
  .tun-cards { display: grid; }
  .ev { grid-template-columns: 90px 1fr 40px; }
  .ev-detail { display: block; }
  .bottom { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-1); border-top: 1px solid var(--line); padding: var(--s1) var(--s2) calc(var(--s1) + env(safe-area-inset-bottom)); z-index: var(--z-sticky); }
  .bottom .nav-item { flex-direction: column; font-size: var(--fs-xs); justify-content: center; min-height: 48px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .brand .muted { display: none; }
  .tc-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- phase 2 additions --- */
.top-actions { display: flex; align-items: center; gap: var(--s2); }
.btn { background: var(--bg-2); color: var(--fg); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s2) var(--s3); min-height: 36px; font-size: var(--fs-sm); cursor: pointer; }
.btn:hover { border-color: var(--line-strong); }
.btn.ghost { background: transparent; }
.row { display: flex; gap: var(--s2); align-items: center; }
.row .search { flex: 1; }
.tm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2); }
.tm-item { background: var(--bg-2); border: 1px solid var(--line); color: var(--fg); border-radius: var(--r-md); padding: var(--s3); font-size: var(--fs-sm); cursor: pointer; text-align: left; }
.live-link { color: var(--info); text-decoration: underline; }
#palette { position: fixed; inset: 0; background: rgba(7, 9, 15, 0.86); z-index: var(--z-palette); display: grid; place-items: start center; padding-top: 12vh; }
#palette[hidden] { display: none; }
.pal { width: min(640px, 92vw); background: var(--bg-1); border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: var(--s3); display: grid; gap: var(--s2); }
.pal-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
.pal-item { width: 100%; text-align: left; background: none; border: 0; color: var(--fg); padding: var(--s2) var(--s3); border-radius: var(--r-md); cursor: pointer; display: flex; gap: var(--s3); align-items: center; min-height: 40px; }
.pal-item.is-active, .pal-item:hover { background: color-mix(in srgb, var(--brand) 18%, var(--bg-2)); }
.pal-kind { font-size: var(--fs-xs); color: var(--fg-dim); text-transform: uppercase; min-width: 52px; }
/* --- phase 3: control page --- */
.action { border-top: 1px solid var(--line); padding: var(--s3) 0; }
.action:first-of-type { border-top: 0; }
.action-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.action-body { display: flex; gap: var(--s2); align-items: center; margin-top: var(--s2); flex-wrap: wrap; }
.action-body .search { flex: 1; min-width: 140px; }
.action[data-risk="high"] { background: color-mix(in srgb, var(--crit) 6%, transparent); }
.plan { margin-top: var(--s2); display: grid; gap: var(--s1); }
.plan code { background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s2); overflow-x: auto; font-size: var(--fs-xs); }
.out { background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s3); overflow: auto; max-height: 220px; font-size: var(--fs-xs); white-space: pre-wrap; }
.out.err { border-color: var(--crit); }

/* NOC mode */
.noc { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 18px 0; }
.noc-item { background: var(--surface, #0b1220); border: 1px solid var(--border, #1f2937); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.noc-item span { color: var(--muted, #94a3b8); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
.noc-item b { font-size: 42px; line-height: 1; font-family: ui-monospace, monospace; }
.noc-item b.ok { color: #16a34a; } .noc-item b.crit { color: #dc2626; } .noc-item b.warn { color: #d97706; }
.noc-item em { color: var(--muted, #64748b); font-style: normal; font-size: 12px; }
.panel-inset { background: var(--surface-2, #0f172a); border: 1px solid var(--border, #1f2937); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }

:focus-visible { outline: 2px solid var(--accent, #60a5fa); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
