/* ─────────────────────────────────────────────────────────────
   Status page (/status, /status/history, /status/incidents/:id) and the owner console's Status tab.
   Site chrome stays crimson / gold / black; status colours stay semantic (green, yellow, orange, red, blue),
   tuned per theme: bright on the dark floor, deeper on platinum for contrast.
   ───────────────────────────────────────────────────────────── */

:root {
  --st-op: #3fb950;
  --st-deg: #e3b341;
  --st-par: #f0883e;
  --st-maj: #f85149;
  --st-mnt: #58a6ff;
  --st-none: rgba(169, 169, 184, .2);
  /* bar fills */
  --bar-op: #3fb950;
  --bar-deg: #e3b341;
  --bar-par: #f0883e;
  --bar-maj: #f85149;
  --bar-mnt: #58a6ff;
  /* text on a solid level colour */
  --lv-ink: #0b0b0f;
}
:root[data-theme='light'] {
  --st-op: #1a7f37;
  --st-deg: #8a5d00;
  --st-par: #b34700;
  --st-maj: #cf222e;
  --st-mnt: #0969da;
  --st-none: rgba(22, 22, 29, .11);
  --bar-op: #2da44e;
  --bar-deg: #d4a72c;
  --bar-par: #e16f24;
  --bar-maj: #d1242f;
  --bar-mnt: #218bff;
  --lv-ink: #ffffff;
}

.lv-operational { --lv: var(--st-op); --lv-bar: var(--bar-op); }
.lv-degraded { --lv: var(--st-deg); --lv-bar: var(--bar-deg); }
.lv-partial { --lv: var(--st-par); --lv-bar: var(--bar-par); }
.lv-major { --lv: var(--st-maj); --lv-bar: var(--bar-maj); }
.lv-maintenance { --lv: var(--st-mnt); --lv-bar: var(--bar-mnt); }
.lv-none { --lv: var(--muted); --lv-bar: var(--st-none); }
.im-none { --im: var(--muted); }
.im-minor { --im: var(--st-deg); }
.im-major { --im: var(--st-par); }
.im-critical { --im: var(--st-maj); }
.is-maint { --im: var(--st-mnt); }

.st-page { max-width: 1000px; }
.st-page h2 { font-size: 1.2rem; margin: 0; }

/* ───────────── header ───────────── */
.st-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.st-brand { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.st-brand img { width: 50px; height: 50px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--gold), 0 0 18px rgba(200, 16, 46, .35); }
.st-brand h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 4vw, 2.3rem); line-height: 1.05; margin: 0; }
.st-brand .dt-eyebrow { margin-bottom: .15rem; }
.st-head-actions { display: flex; gap: var(--sp-2); align-items: center; }

/* subscribe menu */
.st-sub { position: relative; }
.st-sub > summary { list-style: none; }
.st-sub > summary::-webkit-details-marker { display: none; }
.st-sub-menu { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 40; width: min(330px, calc(100vw - 2rem)); padding: var(--sp-4); background: var(--surface-solid); border: 1px solid var(--trim); border-radius: var(--radius-sm); box-shadow: var(--shadow); display: grid; gap: .8rem; }
.st-sub-menu h3 { font-size: .95rem; margin: 0; }
.st-sub-item { display: grid; gap: .3rem; }
.st-sub-item p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.st-copy { display: flex; gap: .4rem; }
.st-copy .input { font-family: var(--font-mono); font-size: .76rem; padding: .45rem .6rem; }

/* ───────────── overall banner ───────────── */
.st-banner {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3) var(--sp-4);
  padding: 1.15rem 1.35rem 1.15rem 1.55rem; margin-bottom: var(--sp-6); border-radius: var(--radius); position: relative; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--lv) 55%, transparent);
  background: linear-gradient(100deg, color-mix(in srgb, var(--lv) 20%, transparent), color-mix(in srgb, var(--lv) 5%, transparent) 75%), var(--surface);
  box-shadow: var(--shadow);
}
.st-banner::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--lv); }
.st-banner-ico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--lv); color: var(--lv-ink); font-weight: 800; font-size: 1.35rem; line-height: 1; box-shadow: 0 0 0 5px color-mix(in srgb, var(--lv) 22%, transparent); }
.st-banner.lv-operational .st-banner-ico { animation: st-pulse 3s ease-in-out infinite; }
@keyframes st-pulse { 0%, 100% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--lv) 22%, transparent); } 50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--lv) 8%, transparent); } }
.st-banner-text { min-width: 0; }
.st-banner-text strong { display: block; font-size: clamp(1.15rem, 2.6vw, 1.45rem); line-height: 1.25; }
.st-banner-sub { display: block; color: var(--text-2); font-size: .86rem; margin-top: .15rem; }
.st-banner-meta { text-align: right; color: var(--muted); font-size: .76rem; line-height: 1.5; white-space: nowrap; }
.st-banner-meta time { color: var(--text-2); font-weight: 600; }
.st-live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--st-op); margin-right: .3rem; vertical-align: .05em; }
.st-banner.is-stale .st-live-dot { background: var(--muted); }

/* ───────────── incidents & maintenance ───────────── */
.st-stack { display: grid; gap: var(--sp-4); margin-bottom: var(--sp-6); }
.st-stack:empty { display: none; }
.st-inc { position: relative; padding: var(--sp-5) var(--sp-5) var(--sp-4) calc(var(--sp-5) + 4px); border-radius: var(--radius); background: var(--surface); border: 1px solid color-mix(in srgb, var(--im) 45%, var(--border)); box-shadow: var(--shadow); overflow: hidden; }
.st-inc::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--im); }
.st-inc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; }
.st-inc-head h3 { margin: 0; font-size: 1.08rem; line-height: 1.35; min-width: 0; overflow-wrap: anywhere; }
.st-inc-head h3 a { color: var(--text); }
.st-inc-head h3 a:hover { color: var(--im); }
.st-kind { display: block; font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--im); margin-bottom: .2rem; }
.st-inc-meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin-top: .45rem; color: var(--muted); font-size: .8rem; }
.st-inc-meta b { color: var(--text-2); font-weight: 600; }

.st-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .16rem .65rem; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; color: var(--sc); border: 1px solid color-mix(in srgb, var(--sc) 45%, transparent); background: color-mix(in srgb, var(--sc) 12%, transparent); }
.st-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-s-investigating { --sc: var(--st-par); }
.st-s-identified { --sc: var(--st-deg); }
.st-s-monitoring { --sc: var(--st-mnt); }
.st-s-resolved { --sc: var(--st-op); }
.st-s-scheduled { --sc: var(--st-mnt); }
.st-s-in_progress { --sc: var(--st-mnt); }
.st-s-completed { --sc: var(--st-op); }
.st-auto { font-size: .68rem; font-weight: 600; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: 999px; padding: .05rem .5rem; white-space: nowrap; }

.st-timeline { list-style: none; margin: var(--sp-4) 0 0; padding: 0 0 0 1.15rem; border-left: 2px solid var(--border); display: grid; gap: var(--sp-4); }
.st-timeline li { position: relative; min-width: 0; }
.st-timeline li::before { content: ''; position: absolute; left: calc(-1.15rem - 6px); top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface-solid); border: 2px solid var(--border-strong); }
.st-timeline li:first-child::before { background: var(--sc, var(--im)); border-color: var(--sc, var(--im)); }
.st-tl-head { display: flex; align-items: baseline; gap: .2rem .6rem; flex-wrap: wrap; }
.st-tl-status { font-weight: 700; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--sc); }
.st-tl-msg { margin: .2rem 0 0; color: var(--text-2); font-size: .92rem; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
.st-tl-time { color: var(--muted); font-size: .76rem; }

/* ───────────── components & uptime bars ───────────── */
.st-card { padding: 0; overflow: visible; }
.st-sec-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem 1rem; flex-wrap: wrap; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.st-sec-head p { margin: .15rem 0 0; }
.st-group-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem var(--sp-5); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.st-group-head h3 { margin: 0; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-ink); }
.st-group + .st-group .st-group-head { border-top: 1px solid var(--border); }
.st-comp { padding: var(--sp-4) var(--sp-5) var(--sp-4); }
.st-comp + .st-comp { border-top: 1px solid var(--border); }
.st-comp-top { display: flex; align-items: center; justify-content: space-between; gap: .3rem 1rem; flex-wrap: wrap; margin-bottom: .65rem; }
.st-comp-name { display: flex; align-items: center; gap: .5rem; min-width: 0; font-weight: 600; }
.st-help { display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 1px solid var(--border-strong); background: transparent; color: var(--muted); font: inherit; font-size: .66rem; font-weight: 700; line-height: 1; cursor: help; flex: none; }
.st-help:hover, .st-help:focus-visible { color: var(--text); border-color: var(--trim); }
.st-comp-state { display: flex; align-items: center; gap: .8rem; margin-left: auto; }
.st-metric { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-chip { display: inline-flex; align-items: center; gap: .4rem; font-size: .84rem; font-weight: 600; color: var(--lv); white-space: nowrap; }
.st-chip::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--lv); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lv) 20%, transparent); }
.st-chip.lv-none::before { box-shadow: none; }

.ub { display: flex; gap: 2px; height: 34px; border-radius: 5px; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.ub:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.ub i { flex: 1 1 0; min-width: 0; border-radius: 2px; background: var(--lv-bar); transition: opacity .15s ease, transform .15s ease; transform-origin: bottom; }
.ub:hover i { opacity: .6; }
.ub i:hover, .ub i.is-cur { opacity: 1 !important; transform: scaleY(1.1); }
.ub.has-cur i:not(.is-cur) { opacity: .6; }
.ub-foot { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; color: var(--muted); font-size: .74rem; white-space: nowrap; }
.ub-foot .ln { flex: 1; height: 1px; background: var(--border); min-width: 8px; }
.ub-foot .up { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.ub-d60, .ub-d30 { display: none; }
@media (max-width: 720px) {
  .ub i:nth-child(-n+30) { display: none; }
  .ub-d90 { display: none; }
  .ub-d60 { display: inline; }
}
@media (max-width: 460px) {
  .ub i:nth-child(-n+60) { display: none; }
  .ub { gap: 3px; height: 30px; }
  .ub-d60 { display: none; }
  .ub-d30 { display: inline; }
}

.st-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); color: var(--muted); font-size: .75rem; }
.st-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.st-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--lv-bar); }

/* tooltip (bars and ? marks) */
.st-tip { position: fixed; left: 0; top: 0; z-index: 150; width: max-content; max-width: min(300px, calc(100vw - 24px)); padding: .7rem .85rem; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow); color: var(--text); font-size: .8rem; line-height: 1.45; pointer-events: none; opacity: 0; transition: opacity .12s ease; }
.st-tip.on { opacity: 1; }
.st-tip .tt-date { font-weight: 700; margin-bottom: .15rem; }
.st-tip .tt-up { color: var(--muted); margin-bottom: .35rem; }
.st-tip .tt-row { display: flex; align-items: center; gap: .45rem; }
.st-tip .tt-row::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--lv-bar); flex: none; }
.st-tip .tt-row span { margin-left: auto; padding-left: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.st-tip .tt-inc { margin-top: .45rem; padding-top: .45rem; border-top: 1px solid var(--border); display: grid; gap: .2rem; }
.st-tip .tt-inc div { display: flex; gap: .4rem; align-items: baseline; }
.st-tip .tt-inc div::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--im); flex: none; transform: translateY(-1px); }

/* ───────────── metrics ───────────── */
.st-metrics { margin-top: var(--sp-6); }
.st-charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.st-chart { min-width: 0; padding: var(--sp-4); border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.st-chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.st-chart-head h3 { margin: 0; font-size: .82rem; color: var(--text-2); font-weight: 600; }
.st-chart-head b { font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-chart-head b small { color: var(--muted); font-weight: 500; font-size: .72rem; margin-left: .2rem; }
.st-chart .chart-box { height: 150px; }
.st-nochart { display: grid; place-items: center; height: 150px; color: var(--muted); font-size: .84rem; text-align: center; }
@media (max-width: 860px) { .st-charts { grid-template-columns: minmax(0, 1fr); } }

/* ───────────── past incidents ───────────── */
.st-past { margin-top: var(--sp-7); }
.st-past-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.st-day { padding: var(--sp-4) 0; border-bottom: 1px solid var(--border); }
.st-day:last-of-type { border-bottom: 0; }
.st-day-h { font-size: .98rem; margin: 0 0 .55rem; color: var(--text); }
.st-quiet { margin: 0; color: var(--muted); font-size: .88rem; }
.st-entries { display: grid; gap: .45rem; }
details.st-entry { border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
details.st-entry > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .4rem .8rem; flex-wrap: wrap; padding: .7rem .9rem; border-radius: var(--radius-sm); }
details.st-entry > summary::-webkit-details-marker { display: none; }
details.st-entry > summary::after { content: '+'; margin-left: auto; color: var(--gold-ink); font-size: 1.2rem; line-height: 1; transition: transform .2s; }
details.st-entry[open] > summary::after { transform: rotate(45deg); }
details.st-entry[open] { border-color: color-mix(in srgb, var(--im) 40%, var(--border)); }
.st-entry-title { font-weight: 600; color: var(--im); min-width: 0; overflow-wrap: anywhere; flex: 1 1 220px; }
.st-entry-meta { color: var(--muted); font-size: .78rem; }
.st-entry-body { padding: 0 .9rem .9rem; }
.st-entry-body .st-timeline { margin-top: .4rem; }
.st-entry-body .st-perma { display: inline-block; margin-top: .7rem; font-size: .8rem; }

.st-upcoming { margin-top: var(--sp-6); }
.st-upcoming .st-inc + .st-inc { margin-top: var(--sp-3); }
.st-foot { margin-top: var(--sp-7); text-align: center; }
.st-foot a { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--trim); text-underline-offset: 2px; }

/* history */
.st-month-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.st-month-nav h2 { font-size: 1.25rem; }
.st-month-nav .btn[aria-disabled='true'] { opacity: .45; pointer-events: none; }
.st-hist { display: grid; gap: var(--sp-3); }

/* ───────────── owner console ───────────── */
.st-own-chips { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; }
.st-own-list { display: grid; gap: var(--sp-3); }
.st-own-item { padding: var(--sp-4); border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--im); min-width: 0; }
.st-own-item.is-maint { border-left-color: var(--st-mnt); }
.st-own-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; }
.st-own-top strong { overflow-wrap: anywhere; }
.st-own-top strong a { color: var(--text); }
.st-own-top strong a:hover { color: var(--im); }
.st-own-last { margin: .45rem 0 0; color: var(--text-2); font-size: .86rem; white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.st-own-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }
.st-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: .1rem .9rem; }
.st-checks .check { margin-top: .25rem; }
.st-own-item details { margin-top: .5rem; }
.st-own-item details > summary { cursor: pointer; }
.st-updates-mini { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .35rem; }
.st-updates-mini li { display: flex; gap: .5rem; align-items: flex-start; font-size: .8rem; color: var(--text-2); }
.st-updates-mini li > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.st-own-sub { margin: var(--sp-5) 0 var(--sp-3); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
#incModal .card, #updModal .card, #mntModal .card { width: min(620px, 100%); }

/* ───────────── phones ───────────── */
@media (max-width: 560px) {
  .st-banner { grid-template-columns: auto minmax(0, 1fr); padding: 1rem 1rem 1rem 1.2rem; }
  .st-banner-ico { width: 38px; height: 38px; font-size: 1.1rem; }
  .st-banner-meta { grid-column: 1 / -1; text-align: left; white-space: normal; }
  .st-sec-head, .st-comp, .st-legend { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .st-group-head { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .st-inc { padding: var(--sp-4) var(--sp-4) var(--sp-4) calc(var(--sp-4) + 4px); }
  .st-comp-state { margin-left: 0; width: 100%; justify-content: space-between; }
  .st-head-actions { width: 100%; }
  .st-sub { flex: 1; }
  .st-sub > summary { width: 100%; }
  .st-sub-menu { left: 0; right: auto; width: 100%; }
  .st-month-nav h2 { order: -1; width: 100%; text-align: center; }
  .st-month-nav .btn { flex: 1 1 0; }
}
@media (prefers-reduced-motion: reduce) {
  .st-banner-ico { animation: none !important; }
}
