/* Live Update Console — DESIGN.md §2–§5, §11. One gray family, one accent. */
:root {
  color-scheme: dark;
  --bg: #0c0d0e;
  --surface: #141518;
  --raised: #1b1d20;
  --line: #26282d;
  --ink: #e8e9ea;
  --muted: #9ba0a6;
  --faint: #6b7078;
  --accent: #2dd4bf;
  --accent-ink: #062a26;
  --accent-dim: rgba(45, 212, 191, 0.12);
  --danger: #f87171;
  --ok: #4ade80;
  --warn: #fbbf24;
  --r: 14px;
  --r-sm: 9px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --z-nav: 30;
  --z-modal: 50;
  --z-toast: 60;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  min-height: 100dvh;
  overflow-x: clip;
}
h1, h2, h3 { text-wrap: balance; letter-spacing: -0.02em; margin: 0 0 8px; }
h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  overflow-wrap: anywhere;
}
pre {
  background: #08090a;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  overflow: auto;
  font-size: 12px;
}
pre code { background: none; border: 0; padding: 0; }
a { color: var(--accent); }
.sr {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.skip {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 14px; border-radius: 8px; font-weight: 600;
  transition: top 150ms ease;
}
.skip:focus-visible { top: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
#app { min-height: 100dvh; }
#side {
  position: fixed; inset: 0 auto 0 0; width: 220px; z-index: var(--z-nav);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
}
.brand { font-weight: 600; font-size: 15px; color: var(--ink); text-decoration: none; }
#side nav { margin-top: 18px; display: flex; flex-direction: column; gap: 2px; }
#side nav a {
  color: var(--muted); text-decoration: none;
  padding: 8px 10px; border-radius: var(--r-sm);
}
#side nav a:hover { background: var(--raised); color: var(--ink); }
#side nav a.on { background: var(--accent-dim); color: var(--accent); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.health { display: inline-flex; align-items: center; gap: 7px; }
#health-dot, #health-dot-m {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--faint); flex: none;
}
#health-dot[data-state="live"], #health-dot-m[data-state="live"] { background: var(--ok); }
#health-dot[data-state="live"], #health-dot-m[data-state="live"] { animation: pulse 2.4s ease infinite; }
#health-dot[data-state="retrying"], #health-dot-m[data-state="retrying"] { background: var(--warn); }
#health-dot[data-state="offline"], #health-dot-m[data-state="offline"] { background: var(--danger); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.linklike {
  background: none; border: 0; color: var(--faint);
  cursor: pointer; padding: 4px; font-size: 12px;
  touch-action: manipulation;
}
.linklike:hover { color: var(--ink); }
#top {
  display: none;
  position: sticky; top: 0; z-index: var(--z-nav);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  align-items: center; gap: 12px;
}
#top .brand { flex: 1; }
#menu-btn {
  background: var(--raised); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  min-width: 44px; min-height: 44px; font-size: 17px; cursor: pointer;
  touch-action: manipulation;
}
#view {
  margin-left: 220px;
  padding: 26px 28px calc(40px + env(safe-area-inset-bottom));
  max-width: 1200px;
}
#view:focus { outline: none; }

/* ---------- content ---------- */
.hero { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 6px; }
.hero h1 { font-size: 20px; }
.kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 18px; min-width: 104px;
}
.kpi-num { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-num.trunc { font-size: 15px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-label { color: var(--muted); font-size: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px;
  margin: 14px 0;
}
.card.muted { color: var(--muted); }
.err-card { border-color: var(--danger); color: var(--danger); }
.gate { max-width: 420px; margin: 8vh auto; }
.guide ol { margin: 6px 0; padding-left: 20px; }
.tight li { margin-bottom: 6px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.row { display: flex; gap: 8px; align-items: end; }
.row.wrap { flex-wrap: wrap; }
.row input, .row select { flex: 1; min-width: 0; }
label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.flabel { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
input, select {
  font: inherit; color: var(--ink);
  background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 9px 11px; min-width: 0;
  touch-action: manipulation;
}
input[type="file"] { padding: 8px; }
select { background-color: var(--raised); }
.form-actions { display: flex; align-items: end; }
.form-err { color: var(--danger); font-size: 12px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: var(--r-sm);
  padding: 9px 16px; min-height: 44px;
  touch-action: manipulation;
  transition: filter 150ms ease, transform 150ms ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn-small { padding: 6px 12px; min-height: 44px; font-size: 12px; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn-danger:hover { border-color: var(--danger); filter: none; }

/* ---------- lists: one DOM, grid rows ↔ cards (§11) ---------- */
.rows { display: flex; flex-direction: column; gap: 8px; }
.rhead, .rrow {
  display: grid; gap: 10px; align-items: center;
  padding: 10px 14px;
}
.rows-bundles .rhead, .rows-bundles .rrow { grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr auto; }
#apps-region .rhead, #apps-region .rrow { grid-template-columns: 1.2fr 1.6fr auto auto; }
.rhead {
  color: var(--faint); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; padding-bottom: 2px;
}
.rrow {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.rrow:hover { border-color: var(--faint); }
.rrow > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.num { font-variant-numeric: tabular-nums; }
.c-act { justify-self: end; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 7px; color: var(--muted); white-space: nowrap;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 12px; }
.chip {
  font: inherit; font-size: 12px; cursor: pointer;
  background: var(--raised); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; min-height: 44px;
  touch-action: manipulation;
  transition: color 150ms ease, border-color 150ms ease;
}
.chip:hover { color: var(--ink); }
.chip.on { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.chip-add { display: inline-flex; gap: 6px; }
.chip-add input { width: 150px; min-height: 44px; }

/* ---------- tabs / misc ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0; }
.tab {
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  background: none; border: 0; color: var(--muted);
  padding: 10px 14px; min-height: 44px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  touch-action: manipulation;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.progress {
  height: 8px; background: var(--raised);
  border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
}
.progress .fill {
  height: 100%; width: 0%;
  background: var(--accent);
  transition: width 150ms ease;
}
.skel {
  height: 52px; border-radius: var(--r-sm);
  background: var(--raised);
  animation: shimmer 1.6s ease infinite;
}
@keyframes shimmer {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
#toasts {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
}
.toast {
  background: var(--raised); border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: var(--r-sm); padding: 10px 14px; font-size: 13px;
  transition: opacity 300ms ease, transform 300ms ease;
}
.toast-err { border-left-color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(6px); }
dialog {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 22px; width: min(440px, calc(100vw - 40px));
  overscroll-behavior: contain;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--accent); min-height: 44px; display: inline-flex; align-items: center; }
.json-out { max-height: 320px; }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  #side {
    transform: translateX(-100%);
    transition: transform 200ms ease;
    top: 0; padding-top: calc(18px + env(safe-area-inset-top));
    width: min(280px, 84vw);
  }
  #side.open { transform: none; }
  #top { display: flex; }
  #view { margin-left: 0; padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); }
}
@media (max-width: 720px) {
  .rhead { display: none; }
  .rows { gap: 10px; }
  .rrow {
    display: block; padding: 14px;
  }
  .rrow > span { display: block; margin-bottom: 6px; }
  .rrow > span:last-child { margin-bottom: 0; }
  .c-act { margin-top: 10px; }
  .c-act .btn { width: 100%; }
  .hero h1 { font-size: 18px; }
  .grid { grid-template-columns: 1fr; }
  #toasts { left: 16px; right: 16px; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
