/* GetARQ Watchtower — design system (vanilla CSS, no build step)
   Palette: graphite surfaces, ice-silver text, deep aubergine secondary, marigold accent. */

:root {
  --graphite-950: #0e0f12;
  --graphite-900: #15171b;
  --graphite-850: #1b1e23;
  --graphite-800: #22262c;
  --graphite-700: #2e333b;
  --graphite-600: #3d434d;
  --ice-100: #eef2f6;
  --ice-200: #d9e0e8;
  --ice-300: #b5c0cc;
  --ice-400: #8b97a5;
  --aubergine-900: #2a1630;
  --aubergine-700: #4a2553;
  --aubergine-500: #7a3f87;
  --aubergine-300: #b88cc2;
  --marigold-500: #f2a900;
  --marigold-400: #ffbe2e;
  --marigold-900: #3a2a05;

  --ok: #3fb68b;
  --ok-bg: #12302a;
  --warn: #f2a900;
  --warn-bg: #3a2a05;
  --crit: #ef5f5f;
  --crit-bg: #3a1616;
  --info: #6fa8dc;
  --info-bg: #162a3d;

  --bg: var(--graphite-950);
  --surface: var(--graphite-900);
  --surface-2: var(--graphite-850);
  --surface-3: var(--graphite-800);
  --border: var(--graphite-700);
  --border-strong: var(--graphite-600);
  --text: var(--ice-100);
  --text-2: var(--ice-300);
  --text-3: var(--ice-400);
  --accent: var(--marigold-500);
  --accent-ink: #1a1302;
  --secondary: var(--aubergine-500);
  --secondary-bg: var(--aubergine-900);
  --focus: var(--marigold-400);

  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 6px;
  --radius-sm: 4px;
  --sidebar-w: 248px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-2: #f7f8fa;
    --surface-3: #eceff3;
    --border: #dde2e8;
    --border-strong: #c5ccd5;
    --text: #15171b;
    --text-2: #3d434d;
    --text-3: #5d6672;
    --accent: #c98a00;
    --accent-ink: #ffffff;
    --secondary: #5d2c69;
    --secondary-bg: #f1e7f3;
    --ok-bg: #e3f5ee;
    --ok: #1d7a57;
    --warn-bg: #fdf1d6;
    --warn: #8a5f00;
    --crit-bg: #fbe5e5;
    --crit: #b42828;
    --info-bg: #e3eef8;
    --info: #2a6299;
    --focus: #c98a00;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-feature-settings: "tnum" 1;
}
a { color: var(--text); text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
p { margin: 0 0 0.75em; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 6px 10px; z-index: 50; }
.skip-link:focus { left: 8px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--secondary-bg); border: 1px solid var(--secondary);
  display: grid; place-items: center;
}
.brand-mark span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.brand-name { font-weight: 650; font-size: 14px; line-height: 1.15; }
.brand-name small { display: block; color: var(--text-3); font-weight: 500; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.nav { padding: 6px 10px 16px; flex: 1; }
.nav-section { margin-top: 14px; }
.nav-section-title { padding: 0 8px 4px; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-size: 13.5px;
  border-left: 2px solid transparent;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--surface-3); color: var(--text); border-left-color: var(--accent); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 14px; font-size: 12.5px; }
.sidebar-foot .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .role { color: var(--text-3); }
.sidebar-foot form { margin-top: 8px; display: flex; gap: 6px; }

.main { min-width: 0; }
.topbar {
  display: none; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.content { padding: 24px 28px 48px; max-width: 1360px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-3); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card + .card, .section + .section { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { font-size: 12px; color: var(--text-3); }
.stat-value { font-size: 26px; font-weight: 600; margin-top: 2px; letter-spacing: -0.02em; }
.stat-note { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.stat.is-crit .stat-value { color: var(--crit); }
.stat.is-warn .stat-value { color: var(--warn); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-crit { color: var(--crit); background: var(--crit-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-neutral { color: var(--text-2); background: var(--surface-3); }
.badge-role { color: var(--aubergine-300); background: var(--secondary-bg); border-color: color-mix(in srgb, var(--secondary) 50%, transparent); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 14px; border-radius: var(--radius-sm);
  font: 600 13px/1 var(--font); cursor: pointer; text-decoration: none;
  border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text);
}
.btn:hover { border-color: var(--text-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.07); border-color: var(--accent); }
.btn-danger { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 45%, transparent); background: transparent; }
.btn-danger:hover { background: var(--crit-bg); border-color: var(--crit); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { min-height: 28px; padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.inline-form { display: inline; }

.field { margin-bottom: 14px; }
.field label, .label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; color: var(--text-2); }
.input, .select, textarea.input {
  width: 100%; min-height: 36px; padding: 7px 10px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: 14px var(--font);
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--crit); }
.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.error { font-size: 12.5px; color: var(--crit); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters .field { margin: 0; min-width: 160px; }

/* ---------- Alerts ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid; margin-bottom: 16px; font-size: 13.5px; }
.alert-ok { color: var(--ok); background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.alert-crit { color: var(--crit); background: var(--crit-bg); border-color: color-mix(in srgb, var(--crit) 35%, transparent); }
.alert-warn { color: var(--warn); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.alert ul { margin: 0; padding-left: 18px; }

.empty { padding: 32px 16px; text-align: center; color: var(--text-3); }
.empty strong { display: block; color: var(--text-2); margin-bottom: 4px; }

.codes { display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 24px; padding: 12px 16px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); font-family: var(--mono); }
.secret { font-family: var(--mono); letter-spacing: 0.08em; word-break: break-all; background: var(--surface-2); padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); }
.pagination nav { display: flex; gap: 6px; }

/* ---------- Permission matrix ---------- */
.matrix th.rot { text-align: center; }
.matrix td.cell { text-align: center; }
.matrix input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Guest (auth) ---------- */
.guest { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 600px at 85% -10%, color-mix(in srgb, var(--secondary) 16%, transparent), transparent 60%), var(--bg); }
.guest-card { width: 100%; max-width: 400px; }
.guest-card .card-body { padding: 24px; }
.guest-card .brand { padding: 0 0 18px; }
.guest-foot { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); z-index: 40; transform: translateX(-100%); transition: transform 0.18s ease; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5); }
  .content { padding: 18px 14px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.grid > .card, .grid > .card + .card { margin-top: 0; }
.grid + .card, .grid + .section, .stats + .card, .card + .grid { margin-top: 16px; }
code { overflow-wrap: anywhere; }
.grid-span-2 { grid-column: 1 / -1; }
fieldset.field { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
fieldset .check { margin-bottom: 4px; }
fieldset .btn { margin-top: 10px; }
.detail-panel { border-top: 1px solid var(--border); }
.detail-panel summary { cursor: pointer; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.diff-add { color: var(--ok); }
.diff-del { color: var(--crit); }
.page-head p .badge { vertical-align: middle; }

/* ---------- Phase 3: monitoring ---------- */
.badge-strong { outline: 1px solid currentColor; }
.pct { font-weight: 650; font-variant-numeric: tabular-nums; }
.pct-ok { color: var(--ok); } .pct-warn { color: var(--warn); } .pct-crit { color: var(--crit); }
.stat-value .hint { font-size: 11.5px; font-weight: 400; letter-spacing: 0; }
.small-value { font-size: 17px; }
.sparkline { width: 100%; height: 90px; display: block; background: var(--surface-2); border-radius: var(--radius-sm); }
.spark-line { stroke: var(--accent); stroke-width: 1.6; }
.spark-fail { stroke: var(--crit); stroke-width: 1; opacity: 0.55; }
.spark-legend { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-3); margin-top: 6px; gap: 8px; }
.timeline { list-style: none; margin: 0; padding: 12px 16px; }
.timeline-item { position: relative; padding: 0 0 14px 18px; border-left: 2px solid var(--border); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface-3); border: 2px solid var(--border-strong); }
.timeline-opened::before, .timeline-reopened::before, .timeline-escalated::before { background: var(--crit); border-color: var(--crit); }
.timeline-recovered::before { background: var(--ok); border-color: var(--ok); }
.timeline-meta { font-size: 11.5px; color: var(--text-3); }
.timeline-body { font-size: 13px; overflow-wrap: anywhere; }
.run-strip { display: inline-flex; gap: 2px; }
.run { width: 6px; height: 16px; border-radius: 1px; background: var(--surface-3); }
.run-success { background: var(--ok); } .run-failed { background: var(--crit); } .run-running { background: var(--info); }
.check-columns { columns: 3 220px; }
.check-columns legend { column-span: all; }
.auth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.auth-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); }
.auth-item h4 { margin: 0 0 6px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }

/* ---------- Phase 4: application monitoring ---------- */
.health-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.health-row:last-of-type { border-bottom: 0; }
.check-pills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pill { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-fail { background: var(--crit-bg); color: var(--crit); }
.pill-degraded { background: var(--warn-bg); color: var(--warn); }
.log-message { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 14px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 80px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px; }
.bar { flex: 1; background: var(--crit); opacity: 0.8; border-radius: 1px 1px 0 0; min-height: 1px; }
.bar-h0 { height: 1px; opacity: 0.25; background: var(--border-strong); }
.bar-h1 { height: 10%; } .bar-h2 { height: 20%; } .bar-h3 { height: 30%; } .bar-h4 { height: 40%; } .bar-h5 { height: 50%; }
.bar-h6 { height: 60%; } .bar-h7 { height: 70%; } .bar-h8 { height: 80%; } .bar-h9 { height: 90%; } .bar-h10 { height: 100%; }
.inline-details { display: inline-block; text-align: left; }
.inline-details summary { list-style: none; }
.inline-details summary::-webkit-details-marker { display: none; }
.popover-panel { position: absolute; right: 16px; z-index: 30; width: min(720px, 90vw); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.table td.actions { position: relative; }

/* The hidden attribute must win over component display rules. */
[hidden] { display: none !important; }

/* ---------- Phase 7: AI findings ---------- */
.confidence { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.confidence-bar { width: 60px; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; display: inline-block; }
.confidence-fill { display: block; height: 100%; background: var(--secondary); }
.conf-0 { width: 4%; } .conf-10 { width: 10%; } .conf-20 { width: 20%; } .conf-30 { width: 30%; } .conf-40 { width: 40%; } .conf-50 { width: 50%; }
.conf-60 { width: 60%; } .conf-70 { width: 70%; } .conf-80 { width: 80%; } .conf-90 { width: 90%; } .conf-100 { width: 100%; }
.report-body h3 { margin: 14px 0 4px; }
.report-body h3:first-child { margin-top: 0; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.finding-group { border-left: 3px solid var(--border-strong); padding-left: 12px; }
.finding-fact { border-left-color: var(--ok); } .finding-inference { border-left-color: var(--info); }
.finding-hypothesis { border-left-color: var(--warn); } .finding-missing_information { border-left-color: var(--text-3); }
.evidence-ref { font-family: var(--mono); font-size: 11.5px; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.compare-grid .card + .card { margin-top: 0; }

/* ---------- Phase 9: reports ---------- */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 16px; }
.report-grid .card + .card { margin-top: 0; }
.report-tile { text-decoration: none; display: block; }
.report-tile:hover { border-color: var(--accent); }
.report-tile h2 { margin-bottom: 4px; }
.report-summary { padding: 12px 16px 0; margin-bottom: 0; }
