/* ServeX Guard dashboard — light theme.
   Colour roles are all tokens, so the palette can be swapped without touching
   any component rule. */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  --bg: #F6F8FB;        /* page */
  --bg2: #EEF2F7;       /* subtle fills, hover rows */
  --card: #FFFFFF;
  --border: #E3E8EF;

  --blue: #2563EB;
  /* Orange and green are darkened from the dark-theme values: the light ones
     failed contrast against white. */
  --orange: #C2410C;
  --orange-soft: #F97316;   /* chart strokes and accents, not text */
  --green: #047857;
  --red: #DC2626;

  --text: #0F172A;
  /* Real prose (labels, table headers, captions). 4.8:1 on --card. */
  --muted: #5A6B85;
  /* Decorative only — chart axes and gridlines. */
  --muted-dim: #94A3B8;

  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .05);
  --shadow-lift: 0 2px 4px rgba(15, 23, 42, .06), 0 8px 20px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, sans-serif; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
code, kbd, pre, .mono { font-family: "IBM Plex Mono", monospace; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 7px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; transition: .15s; cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost { border-color: var(--border); color: var(--text); background: var(--card); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-orange { background: #EA580C; color: #fff; }
.btn-orange:hover { background: #C2410C; }
.btn-danger { border: 1px solid #FCA5A5; color: var(--red); background: var(--card); }
.btn-danger:hover { background: #FEF2F2; border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Header / nav */
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .88); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.logo-hex { width: 30px; height: 30px; flex: none; }
.nav-links { display: flex; align-items: center; gap: 22px; font-size: 14px; color: #475569; }
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--blue); font-weight: 600; }
.nav-email { font-size: 12px; color: var(--muted); }
@media (max-width: 820px) { .nav-email { display: none; } }
@media (max-width: 640px) { .nav-links { gap: 14px; font-size: 13px; } }

/* Layout */
main { padding: 40px 0 80px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
h2 { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 22px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 720px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* Stat tiles */
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.stat .v { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; }

/* Tables */
/* Wrap every table in this: the run table is 8 columns wide and would otherwise
   push the whole page sideways on a phone. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 620px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th {
  color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .5px; font-weight: 600;
  background: var(--bg2);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg2); }
td.mono, th.mono { font-family: "IBM Plex Mono", monospace; }
.num { text-align: right; font-family: "IBM Plex Mono", monospace; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill-pass { background: #DCFCE7; color: #15803D; }
.pill-fail { background: #FEE2E2; color: #B91C1C; }
.pill-tier { background: #DBEAFE; color: #1D4ED8; text-transform: uppercase; letter-spacing: .5px; }
.pill-pro { background: #FFEDD5; color: #C2410C; }

/* Forms */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select {
  width: 100%; padding: 10px 12px; border-radius: 7px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  font-family: inherit; font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.field + .field { margin-top: 16px; }

/* Auth page */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; box-shadow: var(--shadow-lift); }
.auth-card .brand { justify-content: center; margin-bottom: 22px; }

/* Misc */
.notice { padding: 11px 14px; border-radius: 7px; font-size: 13.5px; margin-bottom: 16px; border: 1px solid; }
.notice-err { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.notice-ok { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.notice-warn { background: #FFF7ED; color: #9A3412; border-color: #FED7AA; }
.keycode {
  font-family: "IBM Plex Mono", monospace; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 7px; padding: 12px;
  word-break: break-all; font-size: 13px; color: var(--text);
}
.row { display: flex; gap: 12px; align-items: center; }
.spacer { flex: 1; }
.center { text-align: center; }
.link { color: var(--blue); cursor: pointer; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* Keyboard focus — visible on every interactive element, not just the ones
   the browser styles by default. */
:is(a, button, input, select, .link):focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Loading skeletons */
.skeleton {
  background: linear-gradient(90deg, var(--bg2) 25%, #F8FAFC 50%, var(--bg2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 7px;
}
.skeleton + .skeleton { margin-top: 10px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  * { transition: none !important; }
}

/* Copy-to-clipboard */
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn.is-copied { background: var(--green); border-color: var(--green); color: #fff; }
.copy-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; }
.copy-row .keycode, .copy-row .cmd { flex: 1; }

/* Chart tooltip */
.chart-tip {
  position: absolute; transform: translate(-50%, -140%);
  background: var(--text); color: #fff; border-radius: 6px;
  padding: 6px 10px; font-size: 12px; line-height: 1.35;
  pointer-events: none; white-space: nowrap; box-shadow: var(--shadow-lift);
}
.chart-tip b { display: block; font-family: "IBM Plex Mono", monospace; font-size: 13px; }
.chart-tip span { opacity: .75; font-size: 11px; }

/* Dialogs */
dialog.modal {
  border: 1px solid var(--border); border-radius: 12px; padding: 26px;
  background: var(--card); color: var(--text);
  width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-lift);
}
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
dialog.modal h3 { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
@media (max-width: 480px) { .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; justify-content: center; } }

/* Run detail */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 16px; }
@media (max-width: 520px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-grid .kv {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
}
.detail-grid .kv .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.detail-grid .kv .v { font-family: "IBM Plex Mono", monospace; font-size: 15px; margin-top: 3px; }
.detail-grid .kv.bad .v { color: var(--red); }
.detail-grid .kv.good .v { color: var(--green); }
.fail-list { margin: 14px 0 0; padding: 12px 14px; border-radius: 8px;
  background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; font-size: 13.5px; }
.fail-list ul { margin: 6px 0 0 18px; }
.fail-list li { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; }
details.raw { margin-top: 16px; }
details.raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.raw pre {
  margin-top: 10px; background: var(--term-bg, #0B1120); color: #E2E8F0;
  border-radius: 8px; padding: 14px; font-size: 12px; line-height: 1.6;
  max-height: 320px; overflow: auto;
}
tr.clickable { cursor: pointer; }

/* First-run onboarding */
.onboard { padding: 8px 0 4px; }
.onboard ol { list-style: none; counter-reset: step; }
.onboard li {
  counter-increment: step; position: relative;
  padding: 0 0 22px 42px; border-left: 1px solid var(--border); margin-left: 13px;
}
.onboard li:last-child { border-left-color: transparent; padding-bottom: 4px; }
.onboard li::before {
  content: counter(step); position: absolute; left: -13px; top: -2px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border); color: var(--blue);
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
}
.onboard h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.onboard p { color: var(--muted); font-size: 13.5px; margin-bottom: 8px; }
.cmd {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 7px;
  padding: 9px 12px; font-family: "IBM Plex Mono", monospace; font-size: 13px;
  overflow-x: auto; color: var(--text);
}
.cmd span { flex: 1; white-space: nowrap; }
