:root {
  --bg: #f5f4f0; --surface: #ffffff; --surface-2: #efede7; --line: #e2dfd7; --text: #1c1d21; --muted: #6b6c73;
  --accent: #b8703c; --accent-soft: #f4e6db; --ok: #1f8a57; --ok-soft: #e1f3ea; --warn: #b7791f; --warn-soft: #fbefd8;
  --err: #c0392b; --err-soft: #f9e2df; --info: #3a5a8c; --info-soft: #e3eaf5; --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 16px rgba(20, 20, 30, .04);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111317; --surface: #1a1d23; --surface-2: #22262e; --line: #2d323b; --text: #eceae6; --muted: #9b9ea6;
    --accent: #d4935f; --accent-soft: #3a2a1f; --ok: #4cc38a; --ok-soft: #173327; --warn: #e3a948; --warn-soft: #3a2d15;
    --err: #ef6b5b; --err-soft: #3d1d19; --info: #7fa3dc; --info-soft: #1d2a3d; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.25rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 22px; padding: 0 6px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: radial-gradient(circle at 30% 30%, #f1c79c, var(--accent) 55%, #5a3419); }
.nav button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; color: var(--text); padding: 10px 12px;
  border-radius: 10px; font: inherit; cursor: pointer; text-align: left; }
.nav button:hover { background: var(--surface-2); }
.nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.main { padding: 26px 32px 60px; max-width: 1180px; width: 100%; min-width: 0; }
.app > * { min-width: 0; }
.hero-status > div, .legend span, td, .card p { overflow-wrap: anywhere; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.sync { font-size: .82rem; color: var(--muted); }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; height: auto; z-index: 5; padding: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin-bottom: 8px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .nav button { white-space: nowrap; width: auto; padding: 8px 12px; }
  .main { padding: 16px 14px 60px; }
}

/* components */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .g4, .g3, .g2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card, .section + .section { margin-top: 14px; }
.section { margin-top: 18px; }
.kpi .label { color: var(--muted); font-size: .82rem; } .kpi .value { font-size: 1.55rem; font-weight: 700; margin-top: 2px; }
.kpi .sub { font-size: .8rem; color: var(--muted); }
.pill { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); } .pill.info { background: var(--info-soft); color: var(--info); }
.pill.idle { background: var(--surface-2); color: var(--muted); }
.hero-status { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero-status .big { font-size: 1.35rem; font-weight: 700; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #e0a574); border-radius: 99px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); align-items: start; }
.dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 4px; border: 2px solid var(--line); }
.dot.done { background: var(--ok); border-color: var(--ok); } .dot.running { background: var(--accent); border-color: var(--accent); }
.dot.failed { background: var(--err); border-color: var(--err); } .dot.scheduled { background: var(--info); border-color: var(--info); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.thumbs img, .ep-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--surface-2); display: block; }
.episode { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
@media (max-width: 640px) { .episode { grid-template-columns: 1fr; } }
.btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: 10px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.chart svg { width: 100%; height: 180px; display: block; }
.chart .axis { stroke: var(--line); } .chart .bar { fill: var(--accent); } .chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart text { fill: var(--muted); font-size: 10px; }
.note { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: .88rem; color: var(--muted); }
.alert-item { padding: 8px 10px; border-left: 3px solid var(--warn); background: var(--warn-soft); border-radius: 6px; margin-bottom: 6px; font-size: .88rem; }
audio, video { width: 100%; margin-top: 6px; }
details summary { cursor: pointer; font-weight: 600; }
pre.script { white-space: pre-wrap; font-family: Georgia, serif; font-size: .95rem; max-height: 480px; overflow: auto; background: var(--surface-2); padding: 14px; border-radius: 10px; }
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 22px; max-width: 460px; width: 100%; }
.modal input, .login-card input, select { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); margin-top: 4px; }
.modal label, .login-card label { display: block; margin: 12px 0; font-size: .9rem; }
.error { color: var(--err); font-size: .9rem; }
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow); text-align: center; }
.login-card .brand-mark { margin: 0 auto 12px; width: 44px; height: 44px; border-radius: 12px; }
.login-card form { text-align: left; margin-top: 16px; } .login-card .btn { width: 100%; margin-top: 8px; padding: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }

/* wide analysis tables scroll inside their card instead of squeezing the text */
table.wide { min-width: 860px; }
table.wide td:first-child { min-width: 200px; }
