/*
  Website Monitor UI. The design system is the one shared by
  secure-proxy-manager and rustcd: semantic --ds-* tokens with one value per
  theme, Inter for text, JetBrains Mono for identifiers and numbers in code.
  Red is for failed checks and danger, amber for warnings, green for passed:
  never decoration.

  Inter and JetBrains Mono are vendored as variable woff2 (latin and
  latin-ext) from @fontsource-variable 5.3.0, OFL-1.1, licence next to the
  files. Paths are relative so the page works both on GitHub Pages
  (/websites-monitor/) and under the API's /docs/ mount.
*/
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 300 800;
  src: url('../fonts/inter-5.3.0/inter-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 300 800;
  src: url('../fonts/inter-5.3.0/inter-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 300 800;
  src: url('../fonts/jetbrains-mono-5.3.0/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 300 800;
  src: url('../fonts/jetbrains-mono-5.3.0/jetbrains-mono-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */

:root {
  color-scheme: light;
  accent-color: var(--ds-accent-solid);
  scrollbar-color: var(--ds-border-strong) transparent;
  scrollbar-width: thin;
  --ds-ground: #F7F8FA;
  --ds-surface: #FFFFFF;
  --ds-surface-muted: #F9FAFB;
  --ds-border: #E4E7EC;
  --ds-border-subtle: #F2F4F7;
  --ds-border-strong: #D0D5DD;
  --ds-text: #101828;
  --ds-text-secondary: #344054;
  --ds-muted: #475467;
  --ds-subtle: #667085;
  --ds-accent: #1D4ED8;
  --ds-accent-solid: #1D4ED8;
  --ds-accent-solid-hover: #1E40AF;
  --ds-accent-foreground: #FFFFFF;
  --ds-accent-subtle: #EFF4FF;
  --ds-accent-border: #C7D7FE;
  --ds-danger: #B42318;
  --ds-danger-strong: #D92D20;
  --ds-danger-bg: #FEF3F2;
  --ds-danger-border: #FECDCA;
  --ds-warning: #B54708;
  --ds-warning-strong: #F79009;
  --ds-warning-text: #7A2E0E;
  --ds-warning-bg: #FFFAEB;
  --ds-warning-border: #FEDF89;
  --ds-success: #067647;
  --ds-success-strong: #12B76A;
  --ds-success-bg: #ECFDF3;
  --ds-neutral-bar: #858F9F;
  --ds-backdrop: rgba(16, 24, 40, 0.45);
  --ds-shadow-lg: 0 12px 24px rgba(16, 24, 40, 0.18);
  --radius-control: 8px;
  --radius-panel: 12px;
  --h-control: 36px;
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html.dark {
  color-scheme: dark;
  --ds-ground: #0C111D;
  --ds-surface: #161B26;
  --ds-surface-muted: #1F242F;
  --ds-border: #333741;
  --ds-border-subtle: #1F242F;
  --ds-border-strong: #61646C;
  --ds-text: #F5F5F6;
  --ds-text-secondary: #CECFD2;
  --ds-muted: #94969C;
  --ds-subtle: #8F9298;
  --ds-accent: #84ADFF;
  --ds-accent-solid: #1D4ED8;
  --ds-accent-solid-hover: #2563EB;
  --ds-accent-foreground: #FFFFFF;
  --ds-accent-subtle: #102A56;
  --ds-accent-border: #1D3A7A;
  --ds-danger: #F97066;
  --ds-danger-strong: #F04438;
  --ds-danger-bg: #3B1613;
  --ds-danger-border: #7A271A;
  --ds-warning: #FDB022;
  --ds-warning-strong: #F79009;
  --ds-warning-text: #FEDF89;
  --ds-warning-bg: #33200A;
  --ds-warning-border: #93370D;
  --ds-success: #47CD89;
  --ds-success-strong: #17B26A;
  --ds-success-bg: #0A2E1F;
  --ds-neutral-bar: #85888E;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; margin: 0; padding: 0; border-color: var(--ds-border); }

body {
  font-family: var(--font-sans);
  background: var(--ds-ground);
  color: var(--ds-text);
  font-feature-settings: "rlig" 1, "calt" 1;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

body, aside, main, tr, td, button, input, select, h1, h2, h3, p, span, label {
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

a { color: var(--ds-accent); text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
code, kbd, .mono, .stat-val, .badge, .num { font-variant-numeric: tabular-nums; }
code, kbd, .mono { font-family: var(--font-mono); }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.icon-22, .icon-18, .icon-16, .icon-14 { flex-shrink: 0; display: inline-block; vertical-align: middle; }
.icon-22 { width: 22px; height: 22px; }
.icon-18 { width: 18px; height: 18px; }
.icon-16 { width: 16px; height: 16px; }
.icon-14 { width: 14px; height: 14px; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ds-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ds-border-strong); }

[hidden] { display: none !important; }

/* ---------- Sidebar ---------- */

.mobile-backdrop { position: fixed; inset: 0; z-index: 40; background: var(--ds-backdrop); display: none; }
.mobile-backdrop.open { display: block; }

aside.sidebar {
  width: 248px; height: 100vh; height: 100dvh;
  background: var(--ds-surface); border-right: 1px solid var(--ds-border);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: width 0.15s ease-out, transform 0.2s ease-out;
  z-index: 50;
}
@media (min-width: 1024px) {
  aside.sidebar.collapsed { width: 72px; }
  aside.sidebar.collapsed .hide-collapsed { display: none; }
  main.viewport .mobile-topbar { display: none; }
  aside.sidebar .mobile-close-btn { display: none; }
}
@media (max-width: 1023px) {
  aside.sidebar { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%); }
  aside.sidebar.drawer-open { transform: translateX(0); box-shadow: var(--ds-shadow-lg); }
  aside.sidebar #btn-collapse { display: none; }
}

.sb-header {
  height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 16px;
  border-bottom: 1px solid var(--ds-border-subtle); flex-shrink: 0;
}
@media (min-width: 1024px) { aside.sidebar.collapsed .sb-header { justify-content: center; padding: 0; } }
.sb-logo { width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px; }
.sb-brand-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.sb-title { font-size: 0.875rem; font-weight: 600; color: var(--ds-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-sub { font-size: 0.75rem; color: var(--ds-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sb-search-wrap { padding: 12px 12px 4px; }
.sb-search-box {
  height: 36px; width: 100%; display: flex; align-items: center; gap: 8px; padding: 0 10px;
  border-radius: var(--radius-control); border: 1px solid var(--ds-border);
  background: var(--ds-surface-muted); color: var(--ds-subtle);
}
.sb-search-box:focus-within { border-color: var(--ds-accent); color: var(--ds-text); }
.sb-search-input {
  border: none; background: transparent; color: var(--ds-text);
  font-family: var(--font-sans); font-size: 0.8125rem; width: 100%; outline: none;
}
.sb-search-input::placeholder { color: var(--ds-subtle); }
.sb-search-input::-webkit-search-cancel-button { display: none; }
.kbd {
  font-size: 0.6875rem; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--ds-border); background: var(--ds-surface); color: var(--ds-subtle); white-space: nowrap;
}

.sb-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 14px; }
.sb-group-label {
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ds-subtle); margin: 6px 8px 4px;
}
.sb-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.sb-item {
  display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 10px;
  border-radius: var(--radius-control); color: var(--ds-text-secondary);
  font-family: var(--font-sans); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; border: none; background: transparent; width: 100%; text-align: left; text-decoration: none;
}
.sb-item:hover { background: var(--ds-surface-muted); color: var(--ds-text); text-decoration: none; }
.sb-item.active { background: var(--ds-accent-subtle); color: var(--ds-accent); font-weight: 600; }
.sb-item .sb-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-count {
  font-size: 0.6875rem; font-weight: 600; padding: 1px 7px; border-radius: 9999px;
  background: var(--ds-border-subtle); color: var(--ds-muted); font-variant-numeric: tabular-nums;
}
.sb-item.active .sb-count { background: var(--ds-surface); color: var(--ds-accent); }
@media (min-width: 1024px) {
  aside.sidebar.collapsed .sb-item { justify-content: center; padding: 0; }
}

.sb-footer {
  border-top: 1px solid var(--ds-border-subtle); padding: 12px;
  display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}
.sb-health-row {
  display: flex; min-height: 28px; align-items: center; gap: 8px; padding: 0 8px;
  font-size: 0.75rem; color: var(--ds-muted);
}
@media (min-width: 1024px) { aside.sidebar.collapsed .sb-health-row { justify-content: center; padding: 0; } }
.dot { width: 8px; height: 8px; border-radius: 9999px; flex-shrink: 0; display: inline-block; }
.dot-success { background: var(--ds-success-strong); }
.dot-warning { background: var(--ds-warning-strong); }
.dot-danger { background: var(--ds-danger-strong); }
.dot-unknown { background: var(--ds-neutral-bar); }
.dot-accent { background: var(--ds-accent); }

.sb-footer-btn {
  display: flex; height: 36px; width: 100%; align-items: center; gap: 10px; padding: 0 10px;
  border-radius: var(--radius-control); border: none; background: transparent; color: var(--ds-muted);
  font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 500; cursor: pointer;
}
@media (min-width: 1024px) { aside.sidebar.collapsed .sb-footer-btn { justify-content: center; padding: 0; } }
.sb-footer-btn:hover { background: var(--ds-surface-muted); color: var(--ds-text); }

/* ---------- Viewport ---------- */

main.viewport { flex: 1; min-width: 0; height: 100vh; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; }
.mobile-topbar {
  position: sticky; top: 0; z-index: 30; height: 56px;
  display: flex; align-items: center; gap: 8px; padding: 0 8px 0 4px;
  border-bottom: 1px solid var(--ds-border); background: var(--ds-surface); flex-shrink: 0;
}
.mobile-topbar-title {
  flex: 1; font-size: 1.0625rem; font-weight: 600; color: var(--ds-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-control); border: none; background: transparent;
  color: var(--ds-text-secondary); cursor: pointer;
}
.topbar-icon-btn:hover { background: var(--ds-surface-muted); color: var(--ds-text); }

.page-container {
  width: 100%; max-width: 1640px; margin: 0 auto; padding: 16px;
  display: flex; flex-direction: column; gap: 24px;
}
@media (min-width: 1024px) { .page-container { padding: 24px 28px 40px; } }

header.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-header-text { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.eyebrow { font-size: 0.8125rem; color: var(--ds-muted); }
h1.page-title {
  font-size: 1.5rem; font-weight: 600; line-height: 2rem; letter-spacing: -0.01em; color: var(--ds-text);
  overflow-wrap: anywhere;
}
.page-desc { font-size: 0.875rem; color: var(--ds-muted); }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; font-family: var(--font-sans); font-size: 0.875rem; font-weight: 600;
  border-radius: var(--radius-control); border: 1px solid var(--ds-border-strong);
  background: var(--ds-surface); color: var(--ds-text-secondary);
  cursor: pointer; white-space: nowrap; text-decoration: none; flex-shrink: 0;
}
.btn:hover:not(:disabled) { background: var(--ds-surface-muted); color: var(--ds-text); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 0.8125rem; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; border-color: transparent; background: transparent; color: var(--ds-muted);
}
.btn-icon:hover:not(:disabled) { background: var(--ds-surface-muted); color: var(--ds-text); }
.btn-primary { background: var(--ds-accent-solid); border-color: var(--ds-accent-solid); color: var(--ds-accent-foreground); }
.btn-primary:hover:not(:disabled) {
  background: var(--ds-accent-solid-hover); border-color: var(--ds-accent-solid-hover); color: var(--ds-accent-foreground);
}
.btn-danger { background: var(--ds-danger-bg); border-color: var(--ds-danger-border); color: var(--ds-danger); }
.btn-danger:hover:not(:disabled) { background: var(--ds-danger-strong); border-color: var(--ds-danger-strong); color: #FFFFFF; }
.btn-link {
  border: none; background: none; padding: 0; height: auto; color: var(--ds-accent);
  font: inherit; font-weight: 500; cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }

/* ---------- Stat cards ---------- */

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 639px) {
  .stat-card { padding: 14px; gap: 4px; }
  .stat-val { font-size: 1.5rem; line-height: 2rem; }
  .stat-sub { font-size: 0.75rem; }
}
@media (min-width: 640px) { .stats-grid { gap: 16px; } }
@media (min-width: 1100px) { .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat-card {
  min-width: 0; background: var(--ds-surface); border: 1px solid var(--ds-border);
  border-radius: var(--radius-panel); padding: 20px; display: flex; flex-direction: column; gap: 8px;
}
.stat-label { font-size: 0.8125rem; font-weight: 500; color: var(--ds-muted); }
.stat-val { font-size: 1.875rem; font-weight: 600; line-height: 2.25rem; color: var(--ds-text); }
.stat-val.tone-success { color: var(--ds-success); }
.stat-val.tone-warning { color: var(--ds-warning); }
.stat-val.tone-danger { color: var(--ds-danger); }
.stat-missing { font-size: 1rem; font-weight: 500; line-height: 2.25rem; color: var(--ds-muted); }
.stat-sub { font-size: 0.8125rem; color: var(--ds-muted); }

/* ---------- Panels ---------- */

.panel {
  min-width: 0; background: var(--ds-surface); border: 1px solid var(--ds-border);
  border-radius: var(--radius-panel); overflow: hidden;
}
.panel-head { padding: 16px 20px 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head-text { min-width: 0; }
.panel-title { font-size: 1rem; font-weight: 600; color: var(--ds-text); }
.panel-desc { font-size: 0.8125rem; color: var(--ds-muted); margin-top: 2px; }
.panel-body { padding: 4px 20px 20px; }
.panel-body.flush { padding: 0; }
.panel-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 20px 12px;
}
.panel-toolbar > * { min-width: 0; max-width: 100%; }
.panel-toolbar .grow { flex: 1 1 200px; min-width: 0; }

.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
@media (min-width: 1280px) { .layout-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; } }

/* ---------- Tables ---------- */

.table-wrap {
  position: relative; width: 100%; max-inline-size: 100%; overflow-x: auto;
  overscroll-behavior-x: contain; container-type: inline-size;
}
table.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0; text-align: left;
  font-size: 0.875rem; color: var(--ds-text);
}
table.data-table th {
  padding: 9px 10px; font-size: 0.75rem; font-weight: 500; color: var(--ds-muted);
  background: var(--ds-surface-muted); border-top: 1px solid var(--ds-border); border-bottom: 1px solid var(--ds-border);
  white-space: nowrap;
}
table.data-table th:first-child, table.data-table td:first-child { padding-inline-start: 20px; }
table.data-table th:last-child, table.data-table td:last-child { padding-inline-end: 20px; }
table.data-table td {
  padding: 10px; border-top: 1px solid var(--ds-border-subtle);
  color: var(--ds-text-secondary); vertical-align: middle;
}
table.data-table tbody tr:first-child td { border-top: none; }
table.data-table tbody tr:hover td { background: var(--ds-surface-muted); }
table.data-table .col-right { text-align: right; }
table.data-table .col-status { width: 1%; white-space: nowrap; }
table.data-table .col-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty-row-cell { text-align: center; padding: 28px 16px !important; color: var(--ds-muted); }

@container (width < 680px) {
  table.data-table, table.data-table thead, table.data-table tbody, table.data-table tr, table.data-table th, table.data-table td {
    display: block;
  }
  table.data-table thead { display: none; }
  table.data-table tr { border-top: 1px solid var(--ds-border-subtle); padding: 10px 0; }
  table.data-table tbody tr:first-child { border-top: none; }
  table.data-table td { border-top: none; padding: 3px 16px !important; }
  table.data-table td.col-num, table.data-table td.col-right { text-align: left; }
  table.data-table td[data-label]::before {
    content: attr(data-label) ": "; color: var(--ds-subtle); font-size: 0.75rem;
  }
  table.data-table td.empty-row-cell { padding: 28px 16px !important; }
  table.data-table td:empty { display: none; }
  .action-group { justify-content: flex-start; }
}

.cell-primary { font-weight: 600; color: var(--ds-text); }
.cell-sub { font-size: 0.75rem; color: var(--ds-subtle); margin-top: 2px; }
.cell-result { color: var(--ds-text-secondary); overflow-wrap: anywhere; }
.cell-error { color: var(--ds-danger); font-size: 0.8125rem; overflow-wrap: anywhere; }
td > .cell-result, td > .cell-error { margin-top: 4px; font-size: 0.8125rem; }
.cell-muted { color: var(--ds-subtle); }
.action-group { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; white-space: nowrap; }
.action-group .btn-icon { width: 30px; height: 30px; border: 1px solid var(--ds-border); background: var(--ds-surface); }
.action-group .btn-icon:hover:not(:disabled) { background: var(--ds-surface-muted); color: var(--ds-text); }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border-radius: 9999px;
  padding: 2px 9px; font-size: 0.75rem; font-weight: 500; line-height: 1.25rem;
}
.badge .dot { width: 6px; height: 6px; }
.badge-neutral { background: var(--ds-border-subtle); color: var(--ds-muted); }
.badge-success { background: var(--ds-success-bg); color: var(--ds-success); }
.badge-warning { background: var(--ds-warning-bg); color: var(--ds-warning); }
.badge-danger { background: var(--ds-danger-bg); color: var(--ds-danger); }
.badge-accent { background: var(--ds-accent-subtle); color: var(--ds-accent); }
html.dark .badge-neutral { background: var(--ds-surface-muted); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 0.8125rem; font-weight: 500; color: var(--ds-text-secondary); }
.field-help { font-size: 0.75rem; color: var(--ds-muted); }
.field-help.is-error { color: var(--ds-danger); }
.field-help.is-ok { color: var(--ds-success); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

.form-input {
  width: 100%; height: var(--h-control); padding: 0 10px;
  border-radius: var(--radius-control); border: 1px solid var(--ds-border);
  background: var(--ds-surface-muted); color: var(--ds-text);
  font-family: var(--font-sans); font-size: 0.875rem;
}
.form-input.mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.form-input::placeholder { color: var(--ds-subtle); }
.form-input:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 1px; border-color: var(--ds-accent); }
.form-input[aria-invalid="true"] { border-color: var(--ds-danger); }
select.form-input { padding-right: 28px; }
select.form-input option { background: var(--ds-surface); color: var(--ds-text); }
select.form-input.filter-select { width: auto; min-width: 150px; height: 32px; font-size: 0.8125rem; }
.form-input:disabled { opacity: 0.55; cursor: not-allowed; }

.input-icon { position: relative; display: flex; align-items: center; min-width: 0; }
.input-icon > svg { position: absolute; left: 11px; color: var(--ds-subtle); pointer-events: none; }
.input-icon > .form-input { padding-left: 34px; }
.input-icon.sm > .form-input { height: 32px; font-size: 0.8125rem; }

.target-row { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.target-row .input-icon { flex: 1 1 320px; }
.target-row .form-input { height: 40px; font-size: 0.9375rem; }
.target-row .btn { height: 40px; }

.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip {
  display: inline-block; max-width: 100%; height: 26px; line-height: 24px; padding: 0 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: 9999px; border: 1px solid var(--ds-border); background: var(--ds-surface);
  color: var(--ds-text-secondary); font-family: var(--font-sans); font-size: 0.75rem; font-weight: 500; cursor: pointer;
}
.chip:hover { border-color: var(--ds-border-strong); color: var(--ds-text); }

/* ---------- Segmented control and switch ---------- */

.segmented {
  display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 3px;
  border-radius: var(--radius-control); border: 1px solid var(--ds-border); background: var(--ds-surface);
  max-width: 100%; overflow-x: auto;
}
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 10px;
  border: none; border-radius: 6px; background: transparent; color: var(--ds-text-secondary);
  font-family: var(--font-sans); font-size: 0.8125rem; cursor: pointer; white-space: nowrap;
}
.segmented button:hover { background: var(--ds-surface-muted); }
.segmented button[aria-pressed="true"] { background: var(--ds-text); color: var(--ds-surface); font-weight: 600; }
.segmented .seg-count { font-size: 0.6875rem; opacity: 0.75; font-variant-numeric: tabular-nums; }

input[type="checkbox"].check {
  width: 16px; height: 16px; accent-color: var(--ds-accent-solid); cursor: pointer; flex-shrink: 0; margin: 0;
}

/* ---------- Check picker ---------- */

.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.picker-cat {
  border: 1px solid var(--ds-border); border-radius: var(--radius-control);
  background: var(--ds-surface); overflow: hidden; display: flex; flex-direction: column;
}
.picker-cat.is-off { background: var(--ds-surface-muted); }
.picker-cat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--ds-border-subtle); cursor: pointer; user-select: none;
}
.picker-cat-icon {
  width: 28px; height: 28px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ds-accent-subtle); color: var(--ds-accent); flex-shrink: 0;
}
.picker-cat.is-off .picker-cat-icon { background: var(--ds-border-subtle); color: var(--ds-subtle); }
.picker-cat-name { flex: 1; min-width: 0; font-size: 0.875rem; font-weight: 600; color: var(--ds-text); }
.picker-cat-count { font-size: 0.75rem; color: var(--ds-muted); font-variant-numeric: tabular-nums; }
.picker-list { list-style: none; padding: 6px; display: flex; flex-direction: column; }
.picker-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 6px 6px; border-radius: 6px; cursor: pointer;
}
.picker-item:hover { background: var(--ds-surface-muted); }
.picker-item input { margin-top: 2px; }
.picker-item-text { min-width: 0; display: flex; flex-direction: column; }
.picker-item-name { font-size: 0.8125rem; font-weight: 500; color: var(--ds-text); }
.picker-item-hint { font-size: 0.75rem; color: var(--ds-subtle); }

/* ---------- Progress and bars ---------- */

.progress {
  height: 8px; width: 100%; border-radius: 9999px; overflow: hidden;
  background: var(--ds-border-subtle); display: flex;
}
html.dark .progress { background: var(--ds-surface-muted); }
.progress > span { display: block; height: 100%; transition: width 0.25s ease-out; }
.seg-pass { background: var(--ds-success-strong); }
.seg-warn { background: var(--ds-warning-strong); }
.seg-fail { background: var(--ds-danger-strong); }
.seg-unknown { background: var(--ds-neutral-bar); }
.seg-running { background: var(--ds-accent); opacity: 0.45; }

.run-strip { display: flex; flex-direction: column; gap: 10px; padding: 16px 20px; }
.run-strip-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.8125rem; color: var(--ds-muted); }
.run-strip-meta strong { color: var(--ds-text); font-weight: 600; }

.cat-bars { display: flex; flex-direction: column; gap: 14px; }
.cat-bar-row { display: flex; flex-direction: column; gap: 6px; }
.cat-bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8125rem; }
.cat-bar-name { color: var(--ds-text); font-weight: 500; }
.cat-bar-count { color: var(--ds-muted); font-variant-numeric: tabular-nums; }
.cat-bar-row .progress { height: 6px; gap: 2px; background: transparent; }
.cat-bar-row .progress > span { border-radius: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.75rem; color: var(--ds-muted); padding-top: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.9s linear infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
.skeleton { display: block; height: 20px; width: 96px; border-radius: 6px; background: var(--ds-border-subtle); animation: pulse 1.4s ease-in-out infinite; }

/* ---------- Notices, empty states, toasts ---------- */

.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px;
  border-radius: var(--radius-panel); border: 1px solid var(--ds-border); font-size: 0.8125rem; line-height: 1.5;
  background: var(--ds-surface); color: var(--ds-text-secondary);
}
.notice > svg { margin-top: 1px; }
.notice-title { font-weight: 600; color: inherit; }
.notice-danger { background: var(--ds-danger-bg); border-color: var(--ds-danger-border); color: var(--ds-danger); }
.notice-warning { background: var(--ds-warning-bg); border-color: var(--ds-warning-border); color: var(--ds-warning-text); }
.notice-info { background: var(--ds-accent-subtle); border-color: var(--ds-accent-border); color: var(--ds-text-secondary); }
.notice-info > svg { color: var(--ds-accent); }
.notice code { font-size: 0.75rem; padding: 1px 5px; border-radius: 4px; background: var(--ds-surface); border: 1px solid var(--ds-border); color: var(--ds-text); }

.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 48px 24px;
}
.empty-state-icon {
  width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ds-surface-muted); border: 1px solid var(--ds-border); color: var(--ds-muted); margin-bottom: 4px;
}
.empty-state-title { font-size: 0.9375rem; font-weight: 600; color: var(--ds-text); }
.empty-state-desc { font-size: 0.8125rem; color: var(--ds-muted); max-width: 420px; }
.empty-state .btn { margin-top: 8px; }

#toast-box { position: fixed; bottom: 20px; right: 20px; left: auto; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--ds-surface); color: var(--ds-text); border: 1px solid var(--ds-border);
  border-radius: var(--radius-control); padding: 10px 14px; font-size: 0.8125rem; box-shadow: var(--ds-shadow-lg);
}

/* ---------- Settings ---------- */

.settings-shell { display: flex; flex-direction: column; gap: 20px; width: 100%; }
.settings-nav { width: 100%; flex-shrink: 0; }
.settings-content { flex: 1; width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
@media (min-width: 1024px) {
  .settings-shell { flex-direction: row; align-items: flex-start; gap: 32px; }
  .settings-nav { width: 220px; position: sticky; top: 0; }
}
.settings-nav-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 1023px) { .settings-nav-list { flex-direction: row; overflow-x: auto; } }
.settings-nav-btn {
  display: flex; height: 36px; width: 100%; align-items: center; padding: 0 12px; white-space: nowrap;
  border-radius: var(--radius-control); border: none; background: transparent; color: var(--ds-muted);
  font-family: var(--font-sans); font-size: 0.875rem; font-weight: 500; cursor: pointer; text-align: left;
}
.settings-nav-btn:hover { background: var(--ds-surface-muted); color: var(--ds-text); }
.settings-nav-btn.active { background: var(--ds-surface); color: var(--ds-text); font-weight: 600; box-shadow: 0 0 0 1px var(--ds-border); }

.radio-group { border: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.radio-card {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; cursor: pointer;
  border-radius: var(--radius-control); border: 1px solid var(--ds-border);
}
.radio-card:hover { background: var(--ds-surface-muted); }
.radio-card.selected { border-color: var(--ds-accent-border); background: var(--ds-accent-subtle); }
.radio-card input[type="radio"] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--ds-accent-solid); }
.radio-title { font-size: 0.875rem; font-weight: 600; color: var(--ds-text); display: block; }
.radio-help { font-size: 0.8125rem; color: var(--ds-muted); display: block; margin-top: 2px; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kv-box {
  padding: 12px 14px; border-radius: var(--radius-control); border: 1px solid var(--ds-border);
  background: var(--ds-surface-muted); display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.kv-label { font-size: 0.75rem; color: var(--ds-muted); }
.kv-val { font-size: 0.8125rem; font-weight: 600; color: var(--ds-text); overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; }

.link-list { list-style: none; display: flex; flex-direction: column; }
.link-list li + li { border-top: 1px solid var(--ds-border-subtle); }
.link-list a {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; color: var(--ds-text); text-decoration: none; font-size: 0.875rem;
}
.link-list a:hover .link-title { text-decoration: underline; }
.link-list .link-title { font-weight: 500; }
.link-list .link-desc { font-size: 0.8125rem; color: var(--ds-muted); }
.link-list svg { color: var(--ds-subtle); }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.text-muted { color: var(--ds-muted); font-size: 0.8125rem; }

/* ---------- Print: the results table, nothing else ---------- */

@media print {
  body { height: auto; overflow: visible; display: block; background: #FFFFFF; }
  aside.sidebar, .mobile-topbar, .mobile-backdrop, #toast-box, .header-actions, .panel-toolbar,
  .action-group, .no-print { display: none !important; }
  main.viewport { height: auto; overflow: visible; }
  .panel, .stat-card { break-inside: avoid; }
}
