/* Status pages (public and internal). Same-origin file: the CSP (default-src 'self') forbids inline styles. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --border: #e3e6eb;
  --focus: #2563eb;
  --link: #1d4ed8;

  --ok: #15803d;          /* text on light surfaces (≥ 4.5:1) */
  --ok-fill: #22c55e;     /* dots and bars */
  --ok-soft: #ecfdf3;
  --degraded: #b45309;
  --degraded-fill: #f59e0b;
  --degraded-soft: #fffbeb;
  --down: #b91c1c;
  --down-fill: #ef4444;
  --down-soft: #fef2f2;
  --unknown: #4b5563;
  --unknown-fill: #9ca3af;
  --unknown-soft: #f3f4f6;
  --nodata: #d4d8de;

  --radius: 12px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e13;
    --surface: #14171e;
    --text: #e6e8ec;
    --muted: #a3aab6;
    --border: #272b35;
    --focus: #60a5fa;
    --link: #93c5fd;

    --ok: #4ade80;
    --ok-fill: #22c55e;
    --ok-soft: #0f2418;
    --degraded: #fbbf24;
    --degraded-fill: #f59e0b;
    --degraded-soft: #2a1f08;
    --down: #f87171;
    --down-fill: #ef4444;
    --down-soft: #2c1212;
    --unknown: #a3aab6;
    --unknown-fill: #6b7280;
    --unknown-soft: #1c2029;
    --nodata: #2e333e;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
code { font-family: var(--mono); font-size: 0.875em; }

.wrap { max-width: 880px; margin: 0 auto; padding: 0 var(--gutter); }
.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;
}

/* Header */
.top { border-bottom: 1px solid var(--border); background: var(--surface); }
.top__inner { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.brand { color: var(--text); font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em; text-decoration: none; }
.brand:hover { text-decoration: underline; }
.top__label { color: var(--muted); font-size: 0.9375rem; }

main.wrap { padding-top: 24px; padding-bottom: 8px; display: grid; gap: 20px; }

/* Overall banner */
.banner {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left-width: 6px;
  background: var(--surface);
}
.banner__icon {
  flex: none; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--unknown-fill); color: #fff;
}
.banner__icon .icon { width: 22px; height: 22px; }
.banner__title { font-size: 1.375rem; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
.banner__text { margin-top: 4px; color: var(--muted); }
.banner--ok { border-left-color: var(--ok-fill); background: var(--ok-soft); }
.banner--ok .banner__icon { background: var(--ok); }
.banner--degraded { border-left-color: var(--degraded-fill); background: var(--degraded-soft); }
.banner--degraded .banner__icon { background: var(--degraded); }
.banner--down { border-left-color: var(--down-fill); background: var(--down-soft); }
.banner--down .banner__icon { background: var(--down); }
.banner--unknown, .banner--stale, .banner--loading { border-left-color: var(--unknown-fill); background: var(--unknown-soft); }
.banner--unknown .banner__icon, .banner--stale .banner__icon { background: var(--unknown); }
@media (prefers-color-scheme: dark) {
  .banner__icon .icon { stroke: #0c0e13; }
}

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Live AI-call line */
.live {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.live .icon { margin-top: 3px; }
.live--ok .icon { color: var(--ok); }
.live--down .icon { color: var(--down); }
.live--unknown .icon { color: var(--unknown); }

/* Sections */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.panel__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.panel h2 { font-size: 1.0625rem; font-weight: 650; }
.panel__hint { color: var(--muted); font-size: 0.875rem; }
.note { color: var(--muted); font-size: 0.8125rem; margin-top: 12px; }

/* Area rows */
.components { list-style: none; margin: 0; padding: 0; }
.comp { padding: 16px 0; border-top: 1px solid var(--border); }
.comp:first-child { border-top: 0; padding-top: 6px; }
.comp__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.comp__name { font-size: 1rem; font-weight: 600; }
.comp__since { margin-top: 2px; color: var(--muted); font-size: 0.875rem; }

.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9375rem; white-space: nowrap; }
.status--ok { color: var(--ok); }
.status--degraded { color: var(--degraded); }
.status--down { color: var(--down); }
.status--unknown, .status--stale { color: var(--unknown); }

.dot { position: relative; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--unknown-fill); flex: none; }
.dot--ok { background: var(--ok-fill); }
.dot--degraded { background: var(--degraded-fill); }
.dot--down { background: var(--down-fill); }
.dot--stale { background: transparent; border: 2px solid var(--unknown-fill); }
/* Animated ring while an area is degraded or down. */
.dot--live::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid currentColor; opacity: 0;
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .dot--live::after { animation: none; opacity: 0.6; transform: none; }
}

/* 90-day bars */
.bars { margin-top: 10px; }
.bars__cells {
  display: flex; align-items: flex-end; gap: 2px;
  height: 32px; padding: 2px; margin: 0 -2px;
  border-radius: 6px; cursor: default;
}
.cell { flex: 1 1 0; min-width: 0; height: 100%; border-radius: 2px; background: var(--nodata); }
.cell--ok { background: var(--ok-fill); }
.cell--degraded { background: var(--degraded-fill); }
.cell--down { background: var(--down-fill); }
.cell--nodata { height: 35%; } /* shape, not only color: a day without data is a short neutral stub */
/* Mostly blind day (< 50 % of its minutes read): full height, neutral hatch, never green. */
.cell--partial { background: repeating-linear-gradient(135deg, var(--unknown-fill) 0 2px, var(--nodata) 2px 5px); }
.cell:hover, .cell.is-picked { outline: 2px solid var(--text); outline-offset: 1px; position: relative; }
.bars__axis { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; color: var(--muted); font-size: 0.75rem; }
.bars__uptime { color: var(--text); font-weight: 600; }
.bars__detail { margin-top: 4px; color: var(--muted); font-size: 0.8125rem; min-height: 1.5em; }
.narrow-only { display: none; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); font-size: 0.8125rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 14px; border-radius: 2px; background: var(--nodata); }
.swatch--ok { background: var(--ok-fill); }
.swatch--degraded { background: var(--degraded-fill); }
.swatch--down { background: var(--down-fill); }
.swatch--nodata { height: 6px; align-self: flex-end; margin-bottom: 4px; }
.swatch--partial { background: repeating-linear-gradient(135deg, var(--unknown-fill) 0 2px, var(--nodata) 2px 5px); }

/* Incidents */
.incidents { list-style: none; margin: 0; padding: 0; }
.incident { padding: 12px 0; border-top: 1px solid var(--border); }
.incident:first-child { border-top: 0; padding-top: 4px; }
.incident__title { display: flex; align-items: baseline; gap: 8px; font-weight: 600; }
.incident__title .dot { top: 1px; }
.incident__text { flex: 1 1 auto; min-width: 0; }
.incident__text .tag { margin-left: 8px; vertical-align: 1px; }
.incident__meta { margin-top: 2px; padding-left: 18px; color: var(--muted); font-size: 0.875rem; }
.tag {
  display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; line-height: 1.6;
  border: 1px solid currentColor;
}
.incident--down .tag { color: var(--down); }
.incident--degraded .tag { color: var(--degraded); }
.incident--unknown .tag, .incident--ok .tag { color: var(--unknown); }

/* Footer */
.foot { padding-top: 8px; padding-bottom: 32px; color: var(--muted); font-size: 0.8125rem; display: grid; gap: 4px; }
.foot__error { color: var(--degraded); font-weight: 600; }

/* If the page script never renders (failed to load, blocked, broken), the loading banner turns into «No se pudo cargar el
   estado» after 12 s, with no script at all: the script replaces the banner (and drops .banner--loading) well before that,
   because every fetch gives up at 10 s. Without JavaScript, noscript.css hides the banner and <noscript> explains. */
.banner__stack { display: grid; }
.banner__stack > * { grid-area: 1 / 1; }
.load-failed { visibility: hidden; }
.banner--loading .loading-msg { animation: load-conceal 0s linear 12s forwards; }
.banner--loading .load-failed { animation: load-reveal 0s linear 12s forwards; }
@keyframes load-reveal { to { visibility: visible; } }
@keyframes load-conceal { to { visibility: hidden; } }

.noscript { padding: 16px 20px; border-radius: var(--radius); background: var(--unknown-soft); border: 1px solid var(--border); }

/* Phones: 30 days instead of 90 (cells 1-60 hidden), tighter padding. */
@media (max-width: 600px) {
  .bars__cells > .cell:nth-child(-n+60) { display: none; }
  .wide-only { display: none; }
  .narrow-only { display: inline; }
  .bars__cells { gap: 3px; }
  .banner { padding: 16px; }
  .banner__title { font-size: 1.1875rem; }
  .panel { padding: 16px; }
  .comp__head { align-items: flex-start; }
}
