/*
 * Sentinel
 * app.css
 *
 * The whole app's styling. Layout A (sidebar console) for pages,
 * layout C (site inspector) for website detail, from the wireframes.
 *
 * The Content-Security-Policy forbids inline styles, so templates use
 * only these classes. Bars and charts are SVG with attributes.
 */

@font-face { font-family: "Plex Sans"; src: url("fonts/IBMPlexSans-Regular.5aaadb685d3c.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("fonts/IBMPlexSans-Medium.02ec16345450.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("fonts/IBMPlexSans-SemiBold.51d76d33ef85.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/IBMPlexMono-Regular.6114a47be53b.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
    --ground: #F4F5F7;
    --surface: #FFFFFF;
    --ink: #15181C;
    --muted: #5B636E;
    --line: #DDE1E6;
    --line-soft: #ECEEF1;
    --field: #C9CED5;
    --accent: #2450C8;
    --accent-dark: #1A3A94;
    --nav: #15181C;
    --nav-hover: #2A2F36;
    --nav-text: #C3C8CF;
    --nav-link: #8FB0FF;

    --up: #136B43;     --up-bg: #E2F2E9;   --up-mark: #1F8A5B;
    --warn: #8A5300;   --warn-bg: #FBEFD9; --warn-mark: #D08A1A;
    --down: #B42318;   --down-bg: #FCE7E5; --down-mark: #B42318;
    --na: #4A525C;     --na-bg: #ECEEF1;   --na-mark: #D5D9DE;

    --sans: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; }

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { text-align: right; font-family: var(--mono); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App shell (layout A) ---------- */

.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }

.sidebar { flex: 1 1 232px; max-width: 100%; background: var(--nav); color: #E8EAED; padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; font-weight: 600; font-size: 17px; }
.brand svg { stroke: var(--nav-link); }
.nav-link { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 6px; color: var(--nav-text); text-decoration: none; font-size: 14px; }
.nav-link:hover { background: var(--nav-hover); color: #FFFFFF; }
.nav-link[aria-current="page"] { background: var(--nav-hover); color: #FFFFFF; font-weight: 500; }
.nav-section { margin: 16px 12px 4px; font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; color: #8C949E; }
.nav-spacer { flex-grow: 1; min-height: 24px; }
.nav-user { border-top: 1px solid #2E343B; padding: 16px 8px 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.nav-user .who { color: #FFFFFF; overflow-wrap: anywhere; }
.nav-user .role { color: #A9B0B8; font-size: 12px; }
.nav-user form { margin-top: 8px; }
.link-button { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--nav-link); cursor: pointer; text-decoration: underline; min-height: 32px; }

.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px; display: flex; flex-direction: column; gap: 24px; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.page-head .titles { display: flex; flex-direction: column; gap: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Controls ---------- */

.button, button.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--field); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; }
.button:hover { border-color: var(--ink); color: var(--ink); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; font-weight: 500; }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #FFFFFF; }
.button.danger { color: var(--down); border-color: #E3A39D; }
.button.danger:hover { background: var(--down-bg); }
.button.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.button.full { width: 100%; }

.segmented { display: inline-flex; border: 1px solid var(--field); border-radius: 6px; overflow: hidden; background: var(--surface); }
.segmented a { display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px; color: var(--ink); text-decoration: none; font-size: 14px; }
.segmented a + a { border-left: 1px solid var(--field); }
.segmented a[aria-current="true"] { background: var(--ink); color: #FFFFFF; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; color: #4A525C; text-decoration: none; font-size: 14px; }
.tabs a[aria-current="true"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }

form.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 500; }
.field .help { font-size: 12px; color: var(--muted); }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=url], .field input[type=number], .field select, .field textarea, .search { min-height: 44px; padding: 8px 12px; border: 1px solid var(--field); border-radius: 6px; background: var(--surface); font: inherit; font-size: 15px; color: var(--ink); width: 100%; }
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search:focus, .button:focus-visible, a:focus-visible { outline: 3px solid #9DB4F0; outline-offset: 1px; }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field.check input { width: 20px; height: 20px; }
.field .errors, .errorlist { margin: 0; padding: 0; list-style: none; color: var(--down); font-size: 13px; }
.code-input { font-family: var(--mono); letter-spacing: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 20px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 16px 20px 20px; margin: 0; }
legend { padding: 0 6px; font-weight: 600; font-size: 15px; }

/* ---------- Surfaces ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.card.pad { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 28px; font-weight: 600; font-family: var(--mono); line-height: 1.2; }
.kpi .value.up { color: var(--up); }
.kpi .value.down { color: var(--down); }
.kpi .sub { font-size: 12px; color: var(--muted); }

.notice { border-radius: 8px; padding: 12px 16px; font-size: 14px; }
.notice.error { background: var(--down-bg); color: #8C1B13; }
.notice.success { background: var(--up-bg); color: #0F5133; }
.notice.info { background: #E8EEFB; color: #1A3A94; }
.notice.warning { background: var(--warn-bg); color: #6B4000; }

/* ---------- Check run progress ---------- */

.run-panel { background: var(--surface); border: 1px solid #B9C8F0; border-radius: 8px; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.run-panel.is-done { border-color: #A8D5BC; }
.run-head { display: flex; align-items: center; gap: 12px; }
.run-title { font-size: 15px; font-weight: 600; flex-grow: 1; }
.run-count { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.run-detail { margin: 0; font-size: 13px; color: var(--muted); }
.run-spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #C9D6F6; border-top-color: var(--accent); animation: run-spin 0.9s linear infinite; flex-shrink: 0; }
.run-panel.is-done .run-spinner { animation: none; border-color: var(--up-mark); }
@keyframes run-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .run-spinner { animation: none; } }

progress.run-bar { width: 100%; height: 8px; border: 0; border-radius: 4px; background: var(--line-soft); color: var(--accent); accent-color: var(--accent); overflow: hidden; -webkit-appearance: none; appearance: none; }
progress.run-bar::-webkit-progress-bar { background: var(--line-soft); border-radius: 4px; }
progress.run-bar::-webkit-progress-value { background: var(--accent); border-radius: 4px; transition: width 0.4s ease; }
progress.run-bar::-moz-progress-bar { background: var(--accent); border-radius: 4px; }
.run-panel.is-done progress.run-bar::-webkit-progress-value { background: var(--up-mark); }
.run-panel.is-done progress.run-bar::-moz-progress-bar { background: var(--up-mark); }

.button[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- Categories ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips a { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border: 1px solid var(--field); border-radius: 999px; background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px; }
.chips a:hover { border-color: var(--ink); }
.chips a[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.chip-count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.chips a[aria-current="true"] .chip-count { color: #C3C8CF; }

table.data tr.group-row th { background: #F7F8FA; border-top: 1px solid var(--line); padding-top: 10px; padding-bottom: 10px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); text-align: left; }
.group-name { font-weight: 600; margin-right: 10px; }
.group-meta { font-weight: 400; color: var(--muted); }
.list-group { margin: 8px 10px 2px; font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 4px; background: #E8EEFB; color: #1A3A94; font-size: 12px; font-weight: 500; }

/* ---------- Security ---------- */

.issue-list { margin: 0; padding: 0; list-style: none; }
.issue-list li { display: flex; align-items: flex-start; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line-soft); }
.issue-list li:first-child { border-top: 0; }
.issue-list.compact li { padding: 10px 0; }
.issue-list .pill { min-width: 84px; justify-content: center; margin-top: 2px; }
.issue-text { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; font-size: 14px; }
table.matrix td, table.matrix th[scope="row"] { white-space: nowrap; }
table.matrix th[scope="row"] { text-align: left; font-weight: 500; padding-left: 20px; }
table.matrix .pill { cursor: help; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 500; padding: 10px 12px; white-space: nowrap; }
table.data td { padding: 12px; border-top: 1px solid var(--line-soft); vertical-align: top; }
table.data th:first-child, table.data td:first-child { padding-left: 20px; }
table.data th:last-child, table.data td:last-child { padding-right: 20px; }
table.data th.num { text-align: right; }
table.data.compact td { padding-top: 7px; padding-bottom: 7px; }
.cell-stack { display: flex; flex-direction: column; gap: 2px; }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }

/* ---------- Status ---------- */

.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.s-HEALTHY { background: var(--up-bg); color: var(--up); }
.pill.s-WARNING { background: var(--warn-bg); color: var(--warn); }
.pill.s-CRITICAL, .pill.s-DOWN, .pill.s-ERROR { background: var(--down-bg); color: var(--down); }
.pill.s-DISABLED, .pill.s-NONE, .pill.s-PAUSED { background: var(--na-bg); color: var(--na); }
.pill.s-MAINTENANCE { background: #E8EEFB; color: #1A3A94; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--na-mark); }
.dot.s-HEALTHY { background: var(--up-mark); }
.dot.s-WARNING { background: var(--warn-mark); }
.dot.s-CRITICAL, .dot.s-DOWN, .dot.s-ERROR { background: var(--down-mark); }

.text-up { color: var(--up); }
.text-down { color: var(--down); font-weight: 600; }
.text-warn { color: var(--warn); }

svg.bar { display: block; }
svg.bar .track { fill: var(--line-soft); }
svg.bar .fill-up { fill: var(--up-mark); }
svg.bar .fill-down { fill: var(--down-mark); }
svg.bar .fill-warn { fill: var(--warn-mark); }
.uptime-cell { display: flex; align-items: center; gap: 10px; }

/* ---------- Lists ---------- */

.ranked { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.events { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.events li { display: flex; gap: 12px; }
.events .when { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 120px; padding-top: 2px; }

/* ---------- Website detail (layout C) ---------- */

.inspector { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.site-list { flex: 1 1 260px; max-width: 100%; padding: 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.site-list ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.site-list a { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.site-list a:hover { background: var(--ground); }
.site-list a[aria-current="page"] { background: #EEF2FC; }
.site-list .label { display: flex; flex-direction: column; gap: 1px; flex-grow: 1; min-width: 0; font-size: 14px; font-weight: 500; }
.site-list .label span { font-size: 12px; font-weight: 400; color: var(--muted); }
.detail { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stats .kpi .value { font-size: 22px; }

svg.chart { width: 100%; height: 180px; display: block; }
svg.chart .bar-ok { fill: #5B7FD9; }
svg.chart .bar-down { fill: var(--down-mark); }
svg.chart .bar-none { fill: var(--line-soft); }
svg.chart .axis { stroke: var(--field); stroke-width: 1; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-family: var(--mono); }

dl.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line-soft); font-size: 14px; }

/* ---------- Sign-in pages ---------- */

.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 36px 32px; display: flex; flex-direction: column; gap: 20px; }
.auth-card.wide { max-width: 560px; }
.auth-head { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.auth-head svg { stroke: var(--accent); }
.auth-foot { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.qr { display: flex; justify-content: center; }
.qr svg { width: 200px; height: 200px; }
.secret { font-family: var(--mono); font-size: 14px; background: var(--ground); border-radius: 6px; padding: 10px 12px; text-align: center; overflow-wrap: anywhere; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 15px; }
.codes li { background: var(--ground); border-radius: 6px; padding: 8px 12px; text-align: center; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

@media (max-width: 640px) {
    .main { padding: 20px 16px; }
    .auth-card { padding: 28px 20px; }
}
