/* ===================================================================
   WPWarden — design system
   -------------------------------------------------------------------
   One stylesheet. No framework, no web fonts, no CDN, no external
   requests of any kind. The Content-Security-Policy on every page is
   'self' only and forbids inline styles, so everything — including
   chart colours and bar widths — is expressed as classes here.

   Palette notes (the chart colours were validated, not eyeballed):

     light  #0F8A5F  #C98A00  #D02B44  #5C74A8
     dark   #2AAF80  #D9A32B  #E96877  #7E95C4

   · Colour-vision separation passes at ΔE 9.5 (protanopia) and 20.7
     (normal vision) in light mode — red/amber/green status sets
     usually fail this badly, so the hues were pushed apart until they
     didn't.
   · Amber lands at 2.87:1 against white, just under the 3:1 bar. That
     is permitted only where the colour is not the sole carrier of
     meaning — in this UI every status always ships with its text
     label and a table view, so it never is.
   · The "silent" slate is deliberately low-chroma. It represents the
     absence of data, and it should read quieter than the states that
     mean something.
   =================================================================== */

:root {
  /* Surfaces and ink — neutrals tinted toward the accent hue, never
     dead grey. */
  --bg:         #f4f6fa;
  --surface:    #ffffff;
  --surface-2:  #f7f9fc;
  --surface-3:  #eef2f8;
  --line:       #e2e7f0;
  --line-2:     #cfd7e5;

  --ink:        #121826;
  --ink-2:      #58637a;
  --ink-3:      #8590a6;

  --accent:     #2e54c8;
  --accent-ink: #1e3ea3;
  --accent-soft:#e8edfd;

  /* Status — see the palette note above. */
  --st-clean:      #0f8a5f;
  --st-clean-soft: #e3f5ec;
  --st-warn:       #c98a00;
  --st-warn-soft:  #fbf0d8;
  --st-bad:        #d02b44;
  --st-bad-soft:   #fdeaed;
  --st-quiet:      #5c74a8;
  --st-quiet-soft: #eceff7;

  /* Chart ink */
  --grid:       #e8ecf4;
  --axis-text:  #8590a6;
  --series:     #2e54c8;
  --series-wash:#2e54c8;

  /* Scale */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --sh-1: 0 1px 2px rgba(18, 24, 38, .05);
  --sh-2: 0 1px 3px rgba(18, 24, 38, .06), 0 8px 24px -12px rgba(18, 24, 38, .18);

  --ease: cubic-bezier(.2, .7, .3, 1);
  --dur:  160ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #0d121b;
    --surface:    #151d2b;
    --surface-2:  #1a2434;
    --surface-3:  #202b3e;
    --line:       #253148;
    --line-2:     #33425f;

    --ink:        #e7ecf5;
    --ink-2:      #9aa6bd;
    --ink-3:      #6f7c95;

    --accent:     #6d8dff;
    --accent-ink: #9db3ff;
    --accent-soft:#182444;

    --st-clean:      #2aaf80;
    --st-clean-soft: #10301f;
    --st-warn:       #d9a32b;
    --st-warn-soft:  #2f2611;
    --st-bad:        #e96877;
    --st-bad-soft:   #35171d;
    --st-quiet:      #7e95c4;
    --st-quiet-soft: #1d2740;

    --grid:       #212c41;
    --axis-text:  #6f7c95;
    --series:     #6d8dff;
    --series-wash:#6d8dff;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-2: 0 1px 3px rgba(0, 0, 0, .5), 0 10px 28px -14px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv05" 1;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── Top bar ──────────────────────────────────────────────── */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 58px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 680;
  font-size: 15px;
  letter-spacing: -.25px;
  color: var(--ink);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand .mark {
  min-width: 26px;
  height: 22px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -.5px;
  flex: none;
}

.nav { display: flex; gap: 1px; flex-wrap: wrap; flex: 1; }

.nav a {
  padding: 7px 12px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.who { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }

/* ── Page ─────────────────────────────────────────────────── */

.page { max-width: 1400px; margin: 0 auto; padding: 28px 24px 72px; }

h1 { font-size: 22px; font-weight: 660; margin: 0 0 3px; letter-spacing: -.4px; }
h2 { font-size: 15px; font-weight: 640; margin: 0; letter-spacing: -.2px; }
h3 { font-size: 13.5px; font-weight: 640; margin: 0 0 10px; }

.lede { color: var(--ink-2); margin: 0; font-size: 13.5px; }

.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

/* ── Cards ────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.card-head .sub { color: var(--ink-3); font-size: 12px; }
.card-body { padding: 18px; }

/* ── Hero panel (the one loud moment on the overview) ─────── */

.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: 24px 26px;
  margin-bottom: 18px;
}

.hero-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.hero-figure {
  font-size: 46px;
  font-weight: 640;
  line-height: 1;
  letter-spacing: -1.6px;
  /* Proportional figures deliberately: tabular digits make a large
     standalone number look loose. */
}
.hero-label { color: var(--ink-2); font-size: 13.5px; margin-top: 6px; }

.hero-figure.ok  { color: var(--st-clean); }
.hero-figure.bad { color: var(--st-bad); }

/* Fleet ribbon — one stacked bar, the whole estate at a glance. */
.ribbon {
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-3);
  line-height: 0;
}
.ribbon svg { display: block; width: 100%; height: 26px; }

.ribbon-key {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.ribbon-key a, .ribbon-key span {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-2);
}
.ribbon-key a:hover { text-decoration: none; color: var(--ink); }
.ribbon-key .dot {
  width: 9px; height: 9px; border-radius: 3px; flex: none;
}
.ribbon-key b { color: var(--ink); font-weight: 640; font-variant-numeric: tabular-nums; }

/* ── Stat tiles ───────────────────────────────────────────── */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(152px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px 12px;
  box-shadow: var(--sh-1);
  display: block;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
a.tile:hover {
  text-decoration: none;
  border-color: var(--line-2);
  transform: translateY(-1px);
}

.tile .k {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.tile .n {
  font-size: 27px;
  font-weight: 640;
  line-height: 1.1;
  letter-spacing: -.8px;
  color: var(--ink);
  margin-top: 5px;
}
.tile .foot { margin-top: 7px; min-height: 18px; }

.tile.ok   .n { color: var(--st-clean); }
.tile.warn .n { color: var(--st-warn); }
.tile.bad  .n { color: var(--st-bad); }

/* ── Tables ───────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }

table.grid th {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
  font-weight: 620;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
  background: var(--surface-2);
}
table.grid th a { color: inherit; }
table.grid th a:hover { color: var(--accent); }

table.grid td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: var(--surface-2); }

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
td.nowrap, th.nowrap { white-space: nowrap; }
td.mid { vertical-align: middle; }

.site-name { font-weight: 620; }
.site-url { color: var(--ink-3); font-size: 12px; word-break: break-all; margin-top: 1px; }

.empty { padding: 44px 20px; text-align: center; color: var(--ink-2); }
.empty strong { display: block; margin-bottom: 4px; color: var(--ink); }

/* ── Badges & pills ───────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 7px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 620;
  white-space: nowrap;
  line-height: 1.5;
}
.badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge.clean, .badge.active, .badge.done {
  background: var(--st-clean-soft); color: var(--st-clean);
}
.badge.suspicious, .badge.silent, .badge.medium, .badge.rolled_back {
  background: var(--st-warn-soft); color: var(--st-warn);
}
.badge.hacked, .badge.high, .badge.critical, .badge.failed {
  background: var(--st-bad-soft); color: var(--st-bad);
}
.badge.unknown, .badge.disabled, .badge.low, .badge.expired, .badge.cancelled {
  background: var(--surface-3); color: var(--ink-2);
}
.badge.pending, .badge.queued, .badge.sent, .badge.running, .badge.held {
  background: var(--accent-soft); color: var(--accent-ink);
}
.badge.critical { box-shadow: inset 0 0 0 1px var(--st-bad); }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 5px;
  background: var(--surface-3);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.pill.warn { background: var(--st-warn-soft); color: var(--st-warn); }
.pill.bad  { background: var(--st-bad-soft);  color: var(--st-bad); }
.pill.ok   { background: var(--st-clean-soft); color: var(--st-clean); }

/* ── Forms & buttons ──────────────────────────────────────── */

label { display: block; font-weight: 600; font-size: 12.5px; margin: 14px 0 5px; color: var(--ink); }
label.inline { display: inline; font-weight: 400; margin: 0; }

input[type=text], input[type=password], input[type=email], input[type=url],
input[type=number], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--ink-3); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); text-decoration: none; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn.danger { color: var(--st-bad); border-color: var(--st-bad); }
.btn.danger:hover { background: var(--st-bad-soft); border-color: var(--st-bad); color: var(--st-bad); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions input[type=text], .actions input[type=password], .actions input[type=number] {
  width: auto; max-width: 118px;
}
.card-head .actions, table.grid .actions { flex-wrap: nowrap; align-items: center; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; }
.seg a {
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  border-right: 1px solid var(--line-2);
}
.seg a:last-child { border-right: 0; }
.seg a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.seg a.on { background: var(--accent); color: #fff; }

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.filters input[type=text], .filters select { width: auto; min-width: 156px; }

/* ── Notices ──────────────────────────────────────────────── */

.notice {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  margin-bottom: 18px;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.notice.ok   { background: var(--st-clean-soft); color: var(--st-clean); border-left-color: var(--st-clean); }
.notice.bad  { background: var(--st-bad-soft);   color: var(--st-bad);   border-left-color: var(--st-bad); }
.notice.warn { background: var(--st-warn-soft);  color: var(--st-warn);  border-left-color: var(--st-warn); }
.notice.info { background: var(--accent-soft);   color: var(--accent-ink); border-left-color: var(--accent); }
.notice strong { font-weight: 660; }
.notice.mb0 { margin-bottom: 0; }

/* ── Code & evidence ──────────────────────────────────────── */

code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
}
code.path {
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 4px;
  word-break: break-all;
  color: var(--ink-2);
}

pre.evidence {
  background: var(--surface-2);
  border-left: 3px solid var(--st-bad);
  border-radius: 0 4px 4px 0;
  padding: 9px 12px;
  margin: 8px 0 0;
  overflow-x: auto;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--ink-2);
  max-height: 120px;
}

.detail { color: var(--ink-2); font-size: 12.5px; white-space: pre-line; margin-top: 4px; }

/* ===================================================================
   Charts — server-rendered inline SVG
   Geometry comes from presentation attributes (allowed under CSP);
   colour comes from these classes so dark mode works.
   =================================================================== */

.chart { display: block; width: 100%; height: auto; }
.chart-wrap { padding: 16px 18px 10px; }

.c-grid   { stroke: var(--grid); stroke-width: 1; fill: none; }
.c-axis   { fill: var(--axis-text); font-size: 11px; font-weight: 500; }
.c-line   { fill: none; stroke: var(--series); stroke-width: 2;
            stroke-linejoin: round; stroke-linecap: round; }
.c-area   { fill: var(--series-wash); opacity: .10; }
.c-dot    { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.c-label  { fill: var(--ink); font-size: 12px; font-weight: 620; }
/* Hover layer. The hit target stays invisible; the crosshair and the
   point marker are revealed by a sibling selector, so the whole
   interaction works without a line of JavaScript. */
.c-hit    { fill: transparent; pointer-events: all; }
.c-cross  { stroke: var(--line-2); stroke-width: 1; opacity: 0; }
.c-pdot   { fill: var(--series); stroke: var(--surface); stroke-width: 2; opacity: 0; }

.c-hit:hover ~ .c-cross,
.c-hit:focus ~ .c-cross { opacity: 1; }
.c-hit:hover ~ .c-pdot,
.c-hit:focus ~ .c-pdot  { opacity: 1; }

.c-bar      { fill: var(--series); }
.c-bar-track{ fill: var(--surface-3); }

/* Status fills, shared by the ribbon, bars and sparklines. */
.f-clean { fill: var(--st-clean); }
.f-warn  { fill: var(--st-warn); }
.f-bad   { fill: var(--st-bad); }
.f-quiet { fill: var(--st-quiet); }
.s-clean { stroke: var(--st-clean); }
.s-warn  { stroke: var(--st-warn); }
.s-bad   { stroke: var(--st-bad); }

.k-clean { background: var(--st-clean); }
.k-warn  { background: var(--st-warn); }
.k-bad   { background: var(--st-bad); }
.k-quiet { background: var(--st-quiet); }

/* Sparkline in a table cell */
.spark { display: block; width: 104px; height: 26px; }
.spark-line { fill: none; stroke: var(--series); stroke-width: 1.75;
              stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: var(--series-wash); opacity: .12; }
.spark-dot  { fill: var(--series); }

/* Horizontal meter used in ranking tables */
.meter {
  display: block;
  width: 100%;
  min-width: 84px;
  height: 8px;
}
.meter-track { fill: var(--surface-3); }
.meter-fill  { fill: var(--series); }
.meter-fill.warn { fill: var(--st-warn); }
.meter-fill.bad  { fill: var(--st-bad); }

.chart-note { color: var(--ink-3); font-size: 12px; padding: 0 18px 14px; }

.chart-empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

/* ── Login ────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1100px 500px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 384px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: 30px;
}
.login-card h1 { font-size: 19px; margin-bottom: 3px; }
.login-card .brand { margin-bottom: 20px; }
.login-card .btn { width: 100%; margin-top: 22px; justify-content: center; }
.login-card .code-input {
  font-size: 21px;
  letter-spacing: 8px;
  text-align: center;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  padding: 11px;
}

/* ── Misc ─────────────────────────────────────────────────── */

.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 12.5px; }
.mt    { margin-top: 18px; }
.mb0   { margin-bottom: 0; }
.nowrap{ white-space: nowrap; }
.bad   { color: var(--st-bad); }
.ok    { color: var(--st-clean); }
.warn  { color: var(--st-warn); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.split-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kv td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv td:first-child { color: var(--ink-2); width: 44%; padding-right: 12px; }
.kv tr:last-child td { border-bottom: 0; }

.qr { background: #fff; padding: 12px; border-radius: var(--r-sm); display: inline-block; line-height: 0; max-width: 100%; }
/* The QR is rendered at a fixed pixel size so the modules stay crisp; on a
   narrow phone it must shrink rather than push the page sideways. */
.qr svg { max-width: 100%; height: auto; }
.secret-key {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 16px;
  letter-spacing: 2px;
  background: var(--surface-3);
  padding: 10px 13px;
  border-radius: var(--r-sm);
  display: inline-block;
  word-break: break-all;
  color: var(--ink);
}

.pager { display: flex; gap: 10px; align-items: center; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  a.tile:hover { transform: none; }
}

@media (max-width: 980px) {
  .split, .split-3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar-inner { min-height: 0; padding: 10px 16px; gap: 14px; }
  .page { padding: 18px 16px 56px; }
  .hero { padding: 18px; }
  .hero-figure { font-size: 38px; }
  .card-body, .chart-wrap { padding: 14px; }
}
