/* ══════════════════════════════════════════════════════════════════════════
   Public status page.
   Light values live on :root; dark overrides apply when the visitor's OS is
   dark (unless they forced light) or when they picked dark with the toggle.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f7f8fa;
    --border: #e1e5ea;
    --border-strong: #cdd3db;
    --ink: #17202b;
    --ink-soft: #3f4a58;
    --muted: #6b7684;
    --faint: #9aa3ae;
    --accent: #2563a6;
    --accent-soft: #e8f0fa;

    --up: #1f9d55;
    --up-soft: #e5f6ec;
    --degraded: #d98a04;
    --degraded-soft: #fdf3e0;
    --partial: #e8590c;
    --down: #d63c2f;
    --down-soft: #fdebe9;
    --maintenance: #2f74c0;
    --maintenance-soft: #e7f0fb;
    --nodata: #dfe3e8;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1419;
        --surface: #171d24;
        --surface-2: #1d242c;
        --border: #2a333d;
        --border-strong: #38434f;
        --ink: #e7ebf0;
        --ink-soft: #c0c8d2;
        --muted: #8b95a3;
        --faint: #5e6875;
        --accent: #6aa6e8;
        --accent-soft: rgba(106, 166, 232, .14);
        --up-soft: rgba(31, 157, 85, .16);
        --degraded-soft: rgba(217, 138, 4, .16);
        --down-soft: rgba(214, 60, 47, .18);
        --maintenance-soft: rgba(47, 116, 192, .2);
        --nodata: #2a323b;
        --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    }
}

:root[data-theme="dark"] {
    --bg: #0f1419;
    --surface: #171d24;
    --surface-2: #1d242c;
    --border: #2a333d;
    --border-strong: #38434f;
    --ink: #e7ebf0;
    --ink-soft: #c0c8d2;
    --muted: #8b95a3;
    --faint: #5e6875;
    --accent: #6aa6e8;
    --accent-soft: rgba(106, 166, 232, .14);
    --up-soft: rgba(31, 157, 85, .16);
    --degraded-soft: rgba(217, 138, 4, .16);
    --down-soft: rgba(214, 60, 47, .18);
    --maintenance-soft: rgba(47, 116, 192, .2);
    --nodata: #2a323b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

* { 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: 15px;
    line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-org { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.brand-title { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.site-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.site-nav a, .nav-btn {
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 600;
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
}
.site-nav a:hover, .nav-btn:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.site-nav a.active { color: var(--accent); background: var(--accent-soft); }
.nav-btn svg { width: 16px; height: 16px; vertical-align: -3px; }
.theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: inline; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon-light { display: inline; }
    :root:not([data-theme="light"]) .theme-icon-dark { display: none; }
}

main { padding: 28px 0 48px; }

/* ── Overall banner ──────────────────────────────────────────────────────── */
.banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
    border-radius: var(--radius);
    color: #fff;
    box-shadow: var(--shadow);
    margin-bottom: 28px;
}
.banner-icon { width: 40px; height: 40px; flex-shrink: 0; }
.banner h1 { font-size: 21px; font-weight: 700; }
.banner p { margin: 2px 0 0; font-size: 13.5px; opacity: .9; }
.banner-operational { background: var(--up); }
.banner-degraded { background: var(--degraded); }
.banner-partial_outage { background: var(--partial); }
.banner-major_outage { background: var(--down); }
.banner-maintenance { background: var(--maintenance); }

/* ── Sections / cards ────────────────────────────────────────────────────── */
.section { margin-bottom: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.section-head h2 { font-size: 17px; font-weight: 700; }
.section-head .muted { font-size: 13px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card + .card { margin-top: 14px; }
.card-pad { padding: 16px 18px; }

/* ── Notices (active incident / maintenance) ─────────────────────────────── */
.notice { border-left: 4px solid var(--down); padding: 14px 18px; }
.notice + .notice { border-top: 1px solid var(--border); }
.notice.impact-minor { border-left-color: var(--degraded); }
.notice.impact-none { border-left-color: var(--muted); }
.notice.maintenance { border-left-color: var(--maintenance); }
.notice h3 { font-size: 15.5px; font-weight: 700; margin-bottom: 4px; }
.notice h3 a { color: var(--ink); }
.notice-meta { font-size: 12.5px; color: var(--muted); }
.notice-body { margin: 6px 0 0; font-size: 14px; color: var(--ink-soft); white-space: pre-line; }

/* ── Group + monitor rows ────────────────────────────────────────────────── */
.group-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 13px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.group-head h3 { font-size: 15px; font-weight: 700; }
.group-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.monitor { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.monitor:last-child { border-bottom: none; }
.monitor-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.monitor-name { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.monitor-name a { color: var(--ink); font-weight: 600; }
.monitor-name .crit {
    font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
    padding: 1px 7px; border-radius: 999px;
    border: 1px solid var(--border-strong); color: var(--muted);
    white-space: nowrap;
}
.monitor-meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.monitor-meta .uptime { font-family: var(--mono); font-weight: 700; color: var(--ink-soft); }
.monitor-meta .uptime.bad { color: var(--down); }

/* Status label */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.st::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.st-up { color: var(--up); }
.st-degraded { color: var(--degraded); }
.st-down { color: var(--down); }
.st-down::before { animation: pulse 1.4s ease-in-out infinite; }
.st-maintenance { color: var(--maintenance); }
.st-unknown, .st-paused { color: var(--faint); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }

/* ── History bars ────────────────────────────────────────────────────────── */
.bars { display: flex; gap: 2px; height: 32px; margin-top: 10px; align-items: stretch; }
.bar { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: var(--nodata); cursor: default; transition: transform .1s ease, opacity .1s ease; }
.bar:hover, .bar:focus-visible { transform: scaleY(1.12); outline: none; opacity: .85; }
.bar.lvl-up { background: var(--up); }
.bar.lvl-degraded { background: #9ccc65; }
.bar.lvl-minor { background: var(--degraded); }
.bar.lvl-partial { background: var(--partial); }
.bar.lvl-major { background: var(--down); }
.bar.lvl-maintenance { background: var(--maintenance); }
.bars-legend { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); margin-top: 5px; gap: 10px; }
.bars-legend .line { flex: 1; height: 1px; background: var(--border); align-self: center; }

@media (max-width: 640px) {
    /* 90 slivers are unreadable on a phone: keep the last 30 days. */
    .bars .bar:nth-last-child(n+31) { display: none; }
    .bars-legend .days-full { display: none; }
    .bars-legend .days-short { display: inline; }
}
.bars-legend .days-short { display: none; }

.tooltip {
    position: fixed;
    z-index: 50;
    pointer-events: none;
    background: var(--ink);
    color: var(--bg);
    font-size: 12px;
    line-height: 1.4;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
    max-width: 240px;
    opacity: 0;
    transition: opacity .1s ease;
}
.tooltip.is-visible { opacity: 1; }
.tooltip strong { display: block; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 700; padding: 10px 14px;
    background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }

@media (max-width: 720px) {
    .stack thead { display: none; }
    .stack, .stack tbody, .stack tr, .stack td { display: block; width: 100%; }
    .stack tr { border-bottom: 1px solid var(--border); padding: 6px 0; }
    .stack td { border: none; padding: 4px 14px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .stack td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; text-align: left; }
    .stack td.num { font-family: var(--mono); }
}

/* ── Compliance chips ────────────────────────────────────────────────────── */
.cmp { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-sm); border: 1px solid; white-space: nowrap; }
.cmp-cumple { color: var(--up); background: var(--up-soft); border-color: var(--up); }
.cmp-parcial { color: var(--degraded); background: var(--degraded-soft); border-color: var(--degraded); }
.cmp-no_cumple { color: var(--down); background: var(--down-soft); border-color: var(--down); }
.cmp-no_verificado { color: var(--muted); background: var(--surface-2); border-color: var(--border-strong); }
.cmp-lg { font-size: 15px; padding: 7px 14px; }

/* ── KPI tiles ───────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 22px; font-weight: 700; font-family: var(--mono); margin-top: 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-value.ok { color: var(--up); }
.kpi-value.bad { color: var(--down); }

/* ── Page heading, pills, pager ──────────────────────────────────────────── */
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.pill-nav { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.pill-nav a { padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--ink-soft); border-right: 1px solid var(--border); }
.pill-nav a:last-child { border-right: none; }
.pill-nav a.active { background: var(--accent-soft); color: var(--accent); }
.pill-nav a:hover { text-decoration: none; background: var(--surface-2); }

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--surface);
    color: var(--ink-soft); font-size: 13px; font-weight: 600;
}
.btn:hover { text-decoration: none; background: var(--surface-2); color: var(--ink); }
.btn.disabled { opacity: .4; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.pager { display: flex; justify-content: space-between; margin-top: 16px; }

/* ── Incident timeline ───────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 20px 26px; }
.timeline li::before { content: ''; position: absolute; left: 6px; top: 8px; bottom: -8px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ''; position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--faint); }
.timeline li.tl-investigating::after { border-color: var(--down); }
.timeline li.tl-identified::after { border-color: var(--degraded); }
.timeline li.tl-monitoring::after { border-color: var(--maintenance); }
.timeline li.tl-resolved::after { border-color: var(--up); }
.tl-status { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.tl-time { font-size: 12.5px; color: var(--muted); margin-left: 8px; }
.tl-msg { margin: 4px 0 0; white-space: pre-line; color: var(--ink-soft); }

.impact { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; }
.impact-critical, .impact-major { background: var(--down-soft); color: var(--down); }
.impact-minor { background: var(--degraded-soft); color: var(--degraded); }
.impact-none { background: var(--surface-2); color: var(--muted); }

.methodology { font-size: 13.5px; color: var(--ink-soft); }
.methodology pre { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; overflow-x: auto; white-space: pre; line-height: 1.6; }
.methodology li { margin-bottom: 4px; }
.checksum { font-family: var(--mono); font-size: 12px; word-break: break-all; }

.empty { padding: 26px 18px; text-align: center; color: var(--muted); }

.chart-box { position: relative; height: 220px; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--border); padding: 20px 0 30px; font-size: 13px; color: var(--muted); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--ink); }
.footer-links { display: flex; gap: 14px; flex-wrap: wrap; }

/* ── Auth / error pages ──────────────────────────────────────────────────── */
.narrow { max-width: 420px; margin: 40px auto; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.form-group input {
    padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--ink); font-size: 15px; font-family: inherit;
}
.form-group input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; justify-content: center; padding: 10px 14px; font-size: 15px; cursor: pointer; font-family: inherit; }
.btn-primary:hover { background: var(--accent); color: #fff; opacity: .92; }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; border: 1px solid; }
.alert-error { background: var(--down-soft); border-color: var(--down); color: var(--down); }
.alert-info { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.error-code { font-size: 64px; font-weight: 800; font-family: var(--mono); color: var(--faint); margin: 0; line-height: 1; }

@media (max-width: 640px) {
    main { padding-top: 18px; }
    .banner { padding: 16px; }
    .banner h1 { font-size: 18px; }
    .monitor, .group-head, .notice { padding-left: 14px; padding-right: 14px; }
    .site-nav a, .nav-btn { padding: 6px 8px; font-size: 13px; }
}

@media print {
    .site-header nav, .site-footer, .no-print { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; }
}
