/* LiveDash console. Dark only, calm; status is the loudest thing on screen. */
:root {
  --bg:#0c0714; --bg-2:#120a1f; --surface:#160d26; --surface-2:#1e1333; --surface-3:#271a42;
  --line:rgba(255,255,255,.075); --line-2:rgba(255,255,255,.14); --line-3:rgba(255,255,255,.22);
  --ink:#f7f3ff; --ink-2:#cbbfe6; --ink-3:#9d92bb; --ink-4:#6e648a;
  /* Brand derived from ACCENT_COLOR #FF9A4D */
  --brand:#ff9a4d; --brand-ink:#ffb47f; --brand-wash:rgba(255,154,77,.13); --brand-wash-2:rgba(255,154,77,.22); --on-brand:#1f1004;
  --brand-deep:#e0661a;
  --up:#34d399; --warn:#fbbf24; --down:#f87171; --unknown:#6e648a;
  --up-wash:rgba(52,211,153,.12); --warn-wash:rgba(251,191,36,.12); --down-wash:rgba(248,113,113,.14);
  --c-visits:#ff9a4d; --c-pv:#0891b2; --c-usual:#9d92bb;
  --r:18px; --r-sm:12px; --tap:44px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs:15px; --fs-big:34px; --fs-card-num:26px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(1100px 600px at 100% -10%, rgba(255,154,77,.10), transparent 60%);
  background-attachment: fixed;
  color: var(--ink); font: 400 var(--fs)/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body.layout-compact { --fs:14px; --fs-big:28px; --fs-card-num:22px; }
body.layout-large { --fs:18px; --fs-big:52px; --fs-card-num:40px; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: .86em; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- mark ---------- */
.mark { width: 34px; height: 34px; flex: none; display: block; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px clamp(12px, 2.5vw, 28px);
  background: rgba(12,7,20,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; letter-spacing: .2px; min-height: var(--tap); }
.brand:hover { text-decoration: none; }
.brand .word { font-size: 17px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 14px; border-radius: 999px;
  font-weight: 650; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink);
}
.pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--unknown); flex: none; }
.pill.up { background: var(--up-wash); border-color: rgba(52,211,153,.35); }
.pill.up .dot { background: var(--up); }
.pill.down { background: var(--down); border-color: var(--down); color: #2a0505; animation: pulse 1.6s ease-in-out infinite; }
.pill.down .dot { background: #2a0505; }
.pill.late { background: var(--warn); border-color: var(--warn); color: #2a1d00; }
.pill.late .dot { background: #2a1d00; }
.pill.amber { background: var(--warn-wash); border-color: rgba(251,191,36,.45); }
.pill.amber .dot { background: var(--warn); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(248,113,113,.55); } 50% { box-shadow: 0 0 0 8px rgba(248,113,113,0); } }
@media (prefers-reduced-motion: reduce) { .pill.down { animation: none; } * { transition: none !important; } }
.spacer { flex: 1; }
.periods { display: inline-flex; background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; }
.periods button {
  min-height: 38px; min-width: 44px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2);
  cursor: pointer; font-weight: 600;
}
.periods button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.updated { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: .9em; }
.updated.failing { color: var(--warn); }
.iconbtn {
  width: var(--tap); height: var(--tap); display: inline-grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn svg { width: 20px; height: 20px; }

/* ---------- layout ---------- */
main { padding: 18px clamp(12px, 2.5vw, 28px) 40px; max-width: 2400px; margin: 0 auto; }
.banner {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-radius: var(--r-sm);
  margin-bottom: 12px; font-weight: 600; border: 1px solid transparent;
}
.banner.down { background: var(--down); color: #2a0505; }
.banner.down a { color: #2a0505; text-decoration: underline; }
.banner.late { background: var(--warn); color: #2a1d00; }
.banner.amber { background: var(--warn-wash); border-color: rgba(251,191,36,.45); color: var(--ink); }
.banner.amber a { color: var(--warn); }
.banner .grow { flex: 1; min-width: 200px; }
.banner .reason { font-weight: 450; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin: 4px 0 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; }
.tile .label { color: var(--ink-3); font-weight: 600; font-size: .9em; }
.tile .value { font-size: var(--fs-big); font-weight: 750; line-height: 1.15; margin: 4px 0 2px; letter-spacing: -.5px; }
.tile .base { color: var(--ink-3); font-size: .9em; }
.up-txt { color: var(--up); } .down-txt { color: var(--down); } .warn-txt { color: var(--warn); }

.section-h { display: flex; align-items: baseline; gap: 12px; margin: 26px 0 10px; flex-wrap: wrap; }
.section-h h2 { font-size: 1.1em; margin: 0; }
.section-h .grow { flex: 1; }
select.sort {
  min-height: var(--tap); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 0 10px; color: var(--ink);
}

/* ---------- site cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
body.layout-large .cards { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
body.layout-compact .cards { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.card {
  position: relative; display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px 18px 0; overflow: hidden; color: var(--ink); min-width: 0;
}
a.card:hover { text-decoration: none; border-color: var(--line-3); background: var(--surface-2); }
.card.is-down { border-color: var(--down); background: linear-gradient(180deg, var(--down-wash), var(--surface) 70%); box-shadow: inset 4px 0 0 var(--down); }
.card.is-amber { box-shadow: inset 4px 0 0 var(--warn); }
.card .head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card .name { font-weight: 700; font-size: 1.05em; overflow-wrap: anywhere; }
.sdot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--unknown); }
.sdot.up { background: var(--up); } .sdot.blip { background: var(--warn); } .sdot.down { background: var(--down); } .sdot.unknown { background: var(--unknown); }
.card .status { color: var(--ink-2); font-size: .92em; }
.card.is-down .status { color: var(--ink); font-weight: 600; }
.card .nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 12px 18px; }
.card .n .v { font-size: var(--fs-card-num); font-weight: 750; line-height: 1.1; }
.card .n .l { color: var(--ink-3); font-size: .85em; }
.card .n .b { color: var(--ink-3); font-size: .82em; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 3px 10px; border-radius: 999px; background: var(--brand-wash); color: var(--brand-ink); font-size: .85em; font-weight: 600; }
.chip.more { background: var(--surface-3); color: var(--ink-2); }
.card .track { color: var(--ink-3); font-size: .86em; }
.card .track.amber { color: var(--warn); font-weight: 600; }
.card .domain { color: var(--warn); font-size: .86em; font-weight: 600; }
body.layout-compact .card .track.ok { display: none; }
.strip { display: block; width: calc(100% + 36px); margin: auto -18px 0; padding-top: 4px; height: 12px; }
.strip svg { display: block; }
.card.is-down .strip { height: 22px; }

/* ---------- lists / panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; }
.panel h3 { margin: 0 0 10px; font-size: 1em; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin-top: 12px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); min-width: 0; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .v { font-weight: 650; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(60px, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; }
.hbar .lbl { overflow-wrap: anywhere; }
.hbar .track { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--c-visits); border-radius: 4px; width: 0; }
.hbar .fill.pv { background: var(--c-pv); }
.hbar .val { font-weight: 650; text-align: right; white-space: nowrap; }
.empty { color: var(--ink-3); padding: 6px 0; }
.foot { color: var(--ink-3); font-size: .88em; margin-top: 28px; }

/* ---------- site page ---------- */
.site-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 4px 0 16px; }
.site-head h1 { font-size: 1.6em; margin: 0; overflow-wrap: anywhere; }
.site-head .sdot { width: 16px; height: 16px; }
.back { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); color: var(--ink-2); }
.back:hover { text-decoration: none; background: var(--surface-2); }

/* ---------- charts ---------- */
.chart { width: 100%; min-height: 60px; position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .grid line { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { fill: var(--ink-3); font-size: 11px; }
.chart .peak { fill: var(--ink); font-size: 11px; font-weight: 700; }
.chart .bar-v { fill: var(--c-visits); }
.chart .bar-pv { fill: var(--c-pv); }
.chart .bar-mute { fill: var(--ink-4); }
.chart .usual { fill: none; stroke: var(--c-usual); stroke-width: 2; stroke-dasharray: 4 3; }
.chart .lat { fill: none; stroke: var(--c-pv); stroke-width: 2; }
.chart [data-tip]:focus { outline: none; }
.chart [data-tip]:focus rect, .chart [data-tip]:focus path { stroke: var(--ink); stroke-width: 1.5; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--ink-3); font-size: .86em; margin-top: 6px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.v { background: var(--c-visits); } .sw.pv { background: var(--c-pv); } .sw.usual { background: var(--c-usual); }
.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface-3); border: 1px solid var(--line-3); color: var(--ink);
  padding: 6px 10px; border-radius: 8px; font-size: 13px; white-space: pre; box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.strip-ok { fill: rgba(52,211,153,.35); }
.strip-bad { fill: var(--down); }
.strip-down { fill: var(--down); }
.cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(14px, 1fr)); gap: 3px; margin: 8px 0; }
.cal .d { aspect-ratio: 1; border-radius: 3px; background: var(--surface-3); }
.cal .d.g { background: var(--up); } .cal .d.y { background: var(--warn); } .cal .d.r { background: var(--down); }
details.twin summary { cursor: pointer; color: var(--ink-3); min-height: 32px; display: flex; align-items: center; }
table.t { width: 100%; border-collapse: collapse; font-size: .9em; }
table.t th, table.t td { text-align: right; padding: 4px 8px; border-top: 1px solid var(--line); }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t th { color: var(--ink-3); font-weight: 600; }

/* ---------- forms / sign-in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin .box { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); padding: 28px; }
.signin .mark { width: 52px; height: 52px; }
.signin h1 { font-size: 1.5em; margin: 14px 0 4px; }
.signin p { color: var(--ink-2); margin: 0 0 18px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; color: var(--ink-2); font-size: .9em; margin-bottom: 6px; }
.field input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line-3); color: var(--ink);
}
.field input.code { letter-spacing: 6px; font-size: 1.3em; text-align: center; }
.btn {
  min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink);
  cursor: pointer; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); width: 100%; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.link { background: transparent; border-color: transparent; color: var(--brand-ink); padding: 0 6px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.msg { color: var(--ink-2); margin: 12px 0 0; min-height: 1.4em; }
.msg.err { color: var(--down); }
.signin .fine { color: var(--ink-3); font-size: .85em; margin-top: 22px; }
.report-picks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.report-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.report-form label { display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); font-size: .9em; }
.report-form input { min-height: var(--tap); background: var(--bg-2); border: 1px solid var(--line-3); border-radius: 10px; padding: 0 10px; color: var(--ink); }

/* ---------- options drawer, toasts ---------- */
.drawer {
  position: fixed; right: 12px; top: 64px; z-index: 40; width: min(360px, calc(100vw - 24px));
  background: var(--surface-2); border: 1px solid var(--line-3); border-radius: var(--r); padding: 16px 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.drawer h3 { margin: 0 0 8px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); border-top: 1px solid var(--line); }
.opt:first-of-type { border-top: 0; }
.opt select { min-height: 36px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 0 8px; }
.opt input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand); }
.toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(520px, calc(100vw - 24px)); }
.toast { background: var(--surface-3); border: 1px solid var(--line-3); padding: 10px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.4); width: 100%; }
.toast.down { border-color: var(--down); } .toast.up { border-color: var(--up); } .toast.warn { border-color: var(--warn); }

/* ---------- responsive ---------- */
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px) {
  .top { gap: 8px; }
  .brand .word { display: none; }
  .spacer, .updated:not(.failing) { display: none; }
  .pill { flex: 1 1 0; min-width: 0; line-height: 1.25; padding: 6px 12px; }
  .updated.failing { order: 6; width: 100%; }
  .periods { order: 5; width: 100%; justify-content: space-between; }
  .periods button { flex: 1; padding: 0 6px; }
  .updated .when { display: none; }
  .tile { padding: 12px 14px; }
  .tile .base .extra, .card .n .b .extra { display: none; }
  .cards { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: minmax(0, 1fr) 70px auto; }
}
@media (min-width: 1800px) { :root { --fs:16px; } }
