/* CertiWatch dashboard styles. Dependency-free; system fonts and system colour theme. */

:root {
  color-scheme: dark;
  --bg:      #0f172a;
  --bg2:     #1e293b;
  --surface: #1e293b;
  --card:    #1e293b;
  --border:  #334155;
  --border2: #475569;
  --text:    #f1f5f9;
  --muted:   #94a3b8;
  --muted2:  #94a3b8;
  --green:   #10b981;
  --yellow:  #f59e0b;
  --orange:  #f97316;
  --red:     #f87171;
  --blue:    #5b5cf0;
  --blue-text: #818cf8;
  --pill-blue: #a5b4fc;
  --purple:  #a78bfa;
  --focus:   #a5b4fc;
  --topbar-bg: rgba(15, 23, 42, 0.82);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.22), 0 4px 6px -2px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.16), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg:      #f8fafc;
    --bg2:     #f1f5f9;
    --surface: #ffffff;
    --card:    #ffffff;
    --border:  #e2e8f0;
    --border2: #cbd5e1;
    --text:    #0f172a;
    --muted:   #5b6b7f;
    --muted2:  #5b6b7f;
    --green:   #047857;
    --yellow:  #a14a06;
    --orange:  #b23c09;
    --red:     #b91c1c;
    --blue:    #4f46e5;
    --blue-text: #4f46e5;
    --pill-blue: #4f46e5;
    --purple:  #7c3aed;
    --focus:   #4338ca;
    --topbar-bg: rgba(248, 250, 252, 0.86);
    --shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:      #0f172a;
  --bg2:     #1e293b;
  --surface: #1e293b;
  --card:    #1e293b;
  --border:  #334155;
  --border2: #475569;
  --text:    #f1f5f9;
  --muted:   #94a3b8;
  --muted2:  #94a3b8;
  --green:   #10b981;
  --yellow:  #f59e0b;
  --orange:  #f97316;
  --red:     #f87171;
  --blue:    #5b5cf0;
  --blue-text: #818cf8;
  --pill-blue: #a5b4fc;
  --purple:  #a78bfa;
  --focus:   #a5b4fc;
  --topbar-bg: rgba(15, 23, 42, 0.82);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.22), 0 4px 6px -2px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.16), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg:      #f8fafc;
  --bg2:     #f1f5f9;
  --surface: #ffffff;
  --card:    #ffffff;
  --border:  #e2e8f0;
  --border2: #cbd5e1;
  --text:    #0f172a;
  --muted:   #5b6b7f;
  --muted2:  #5b6b7f;
  --green:   #047857;
  --yellow:  #a14a06;
  --orange:  #b83f0a;
  --red:     #b91c1c;
  --blue:    #4f46e5;
  --blue-text: #4f46e5;
  --pill-blue: #4f46e5;
  --purple:  #7c3aed;
  --focus:   #4338ca;
  --topbar-bg: rgba(248, 250, 252, 0.86);
  --shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.2s, color 0.2s;
}

button, input, select { font: inherit; }
button { color: inherit; }
a { color: var(--blue-text); }
[hidden] { display: none !important; }

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

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

.skip-link {
  position: absolute;
  left: 16px; top: -48px;
  z-index: 500;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

/* ── TOP BAR ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex; align-items: center;
  height: 64px;
  transition: background 0.3s ease;
}

.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; margin-right: 32px; }
.brand-stack { display: flex; flex-direction: column; gap: 2px; }
.brand-logo { height: 32px; width: auto; display: block; flex-shrink: 0; }
.brand-sub { font-size: 0.65rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; }

.theme-toggle {
  height: 34px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg2);
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; font-weight: 600;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
  flex-shrink: 0; white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--blue); color: var(--text); background: var(--border); }

.refresh-btn {
  height: 34px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg2);
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  font-size: 0.8rem; font-weight: 600;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
  flex-shrink: 0; white-space: nowrap;
}
.refresh-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--text); background: var(--border); }
.refresh-btn:disabled { opacity: 0.55; cursor: progress; }
.refresh-icon { font-size: 1rem; line-height: 1; }
.refresh-btn[aria-busy="true"] .refresh-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.nav-tabs { display: flex; align-items: stretch; height: 64px; gap: 4px; flex: 1; }
.nav-tab {
  display: flex; align-items: center; gap: 8px;
  padding: 0 24px; border: none; background: none;
  color: var(--muted); font-size: 0.875rem; font-weight: 600;
  cursor: pointer; position: relative;
  transition: color 0.25s ease, background 0.25s ease;
  white-space: nowrap;
}
.nav-tab::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--blue); border-radius: 3px 3px 0 0;
  transform: scaleX(0); transition: transform 0.25s ease;
}
.nav-tab.active { color: var(--blue-text); }
.nav-tab.active::after { transform: scaleX(1); }
.nav-tab:hover:not(.active) { color: var(--text); }
.nav-badge {
  background: var(--border); color: var(--text); border-radius: 8px;
  padding: 2px 8px; font-size: 0.7rem; font-weight: 700; line-height: 1.4;
  font-variant-numeric: tabular-nums;
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-tab.active .nav-badge { background: var(--blue); color: #fff; }
.nav-tab-short { display: none; }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; margin-left: auto; }
.theme-label { font-size: 0.75rem; font-weight: 600; }
.updated-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px 16px;
  font-size: 0.75rem; color: var(--muted);
  transition: border-color 0.2s ease;
  font-variant-numeric: tabular-nums;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 7px var(--green);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}
.live-dot.stale { background: var(--red); box-shadow: 0 0 7px var(--red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── PAGE ── */
.page { padding: 24px 32px 56px; max-width: 1600px; margin: 0 auto; }
.tab-panel[hidden] { display: none; }

/* ── STAT CARDS ── */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 22px 24px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--blue); box-shadow: var(--shadow); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: 20px 20px 0 0;
}
.sc-total::before  { background: var(--blue); }
.sc-ok::before     { background: var(--green); }
.sc-warn::before   { background: var(--yellow); }
.sc-urgent::before { background: var(--orange); }
.sc-exp::before    { background: var(--red); }
.sc-err::before    { background: var(--muted2); }
.stat-lbl { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 10px; font-weight: 700; }
.stat-val { font-size: 2.15rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.sc-total  .stat-val { color: var(--blue-text); }
.sc-ok     .stat-val { color: var(--green); }
.sc-warn   .stat-val { color: var(--yellow); }
.sc-urgent .stat-val { color: var(--orange); }
.sc-exp    .stat-val { color: var(--red); }
.sc-err    .stat-val { color: var(--muted); }
.stat-sub { font-size: 0.72rem; color: var(--muted); margin-top: 6px; font-weight: 500; }

/* ── NOTICES ── */
.notice {
  display: flex; align-items: flex-start; flex-wrap: wrap; gap: 10px 16px;
  border: 1px solid; border-radius: 14px;
  padding: 12px 16px; margin-bottom: 16px;
  font-size: 0.82rem; line-height: 1.5;
  color: var(--text);
}
.notice > span { flex: 1 1 320px; min-width: 0; }
.notice-warn  { background: color-mix(in srgb, var(--yellow) 10%, var(--card)); border-color: color-mix(in srgb, var(--yellow) 38%, var(--border)); }
.notice-error { background: color-mix(in srgb, var(--red) 10%, var(--card));  border-color: color-mix(in srgb, var(--red) 38%, var(--border)); }
.notice-info  { background: color-mix(in srgb, var(--blue) 8%, var(--card));   border-color: color-mix(in srgb, var(--blue) 32%, var(--border)); }
.notice strong { font-weight: 700; }
.notice-action {
  flex-shrink: 0;
  padding: 6px 14px; border-radius: 10px;
  border: 1px solid var(--border2); background: var(--bg);
  color: var(--text); font-size: 0.76rem; font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.notice-action:hover { border-color: var(--blue); background: var(--bg2); }

/* ── INFO CARDS (attention, timeline) ── */
.info-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow-sm);
  padding: 18px 20px; margin-bottom: 20px;
}
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.section-head h2 { font-size: 0.92rem; font-weight: 700; letter-spacing: -0.01em; }
.section-head p { font-size: 0.76rem; color: var(--muted); }

.attention-card {
  border-left: 4px solid var(--orange);
  background: color-mix(in srgb, var(--orange) 5%, var(--card));
}
.attention-card.is-ok {
  border-left-color: var(--green);
  background: color-mix(in srgb, var(--green) 5%, var(--card));
}
.attention-list {
  list-style: none;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}
.attention-item {
  display: flex; align-items: center; gap: 9px;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg2);
}
.attention-item .badge { padding: 4px 9px; font-size: 0.68rem; flex-shrink: 0; }
.attention-domain {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.attention-days {
  margin-left: auto; flex-shrink: 0;
  font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.attention-more { font-size: 0.75rem; color: var(--muted); padding: 9px 4px; }

/* ── TIMELINE ── */
.timeline {
  display: flex; width: 100%; height: 16px;
  border-radius: 8px; overflow: hidden;
  background: var(--border); margin: 4px 0 12px;
}
.timeline:empty::after {
  content: ''; display: block; width: 100%; background: var(--border2);
}
.timeline-seg { height: 100%; min-width: 0; transition: width 0.3s ease; }
.timeline-seg + .timeline-seg { box-shadow: inset 1px 0 0 rgba(15, 23, 42, 0.22); }
.seg-expired { background: var(--red); }
.seg-d7      { background: var(--orange); }
.seg-d30     { background: var(--yellow); }
.seg-d90     { background: var(--blue); }
.seg-d365    { background: var(--green); }
.seg-later   { background: var(--purple); }
.seg-unknown { background: var(--border2); }

.timeline-legend {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  list-style: none; font-size: 0.73rem; color: var(--muted);
}
.timeline-legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.legend-count { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── DISTRIBUTION ── */
.dist-list { list-style: none; display: grid; gap: 9px; }
.dist-item {
  display: grid; grid-template-columns: minmax(110px, 220px) 1fr 46px;
  align-items: center; gap: 12px;
  font-size: 0.78rem;
}
.dist-name {
  color: var(--text); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dist-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.dist-fill { display: block; height: 100%; background: var(--blue); border-radius: 4px; transition: width 0.3s ease; }
.dist-count {
  text-align: right; color: var(--muted); font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── HISTORY SPARKLINE ── */
.spark-wrap { margin: 2px 0 6px; }
.spark { display: block; width: 100%; height: auto; max-height: 190px; }
.spark-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.spark-area { fill: color-mix(in srgb, var(--blue) 14%, transparent); stroke: none; }
.spark-line {
  fill: none; stroke: var(--blue-text); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.spark-renewal-line { stroke: var(--green); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.7; }
.spark-renewal { fill: var(--green); stroke: var(--card); stroke-width: 1.5; }
.spark-last { fill: var(--blue-text); stroke: var(--card); stroke-width: 1.5; }
.history-empty { font-size: 0.78rem; color: var(--muted); padding: 4px 0 2px; }
.history-data { margin-top: 8px; font-size: 0.78rem; color: var(--muted); }
.history-data summary { cursor: pointer; font-weight: 700; color: var(--text); padding: 4px 0; }
.history-table-wrap { overflow-x: auto; margin-top: 8px; }
.history-table-wrap table { font-size: 0.75rem; }
.history-table-wrap thead th {
  position: static; background: transparent; padding: 8px 10px;
  color: var(--muted);
}
.history-table-wrap td {
  padding: 8px 10px; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.history-table-wrap tbody tr { border-bottom: 1px solid var(--border); }
.history-table-wrap tbody tr:last-child { border-bottom: none; }

/* ── TABLE CARD ── */
.table-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow);
  overflow: hidden;
}
.controls {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.search-wrap { position: relative; flex: 1 1 220px; min-width: 190px; max-width: 320px; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
input[type="search"] {
  width: 100%; padding: 10px 12px 10px 38px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text);
  font-size: 0.875rem; outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input[type="search"]:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
input[type="search"]::placeholder { color: var(--muted2); }
.filter-group { display: flex; gap: 6px; flex-wrap: wrap; }
.fb {
  padding: 9px 15px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--muted);
  font-size: 0.75rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.fb:hover { border-color: var(--blue); color: var(--text); background: var(--border); }
.fb:disabled,
.sort-sel:disabled,
input[type="search"]:disabled { opacity: 0.55; cursor: not-allowed; }
.fb.on        { background: var(--blue); border-color: var(--blue); color: #fff; }
.fb.on-green  { background: color-mix(in srgb, var(--green) 8%, transparent);  border-color: var(--green);  color: var(--green); }
.fb.on-yellow { background: color-mix(in srgb, var(--yellow) 8%, transparent); border-color: var(--yellow); color: var(--yellow); }
.fb.on-orange { background: color-mix(in srgb, var(--orange) 8%, transparent); border-color: var(--orange); color: var(--orange); }
.fb.on-red    { background: color-mix(in srgb, var(--red) 8%, transparent);    border-color: var(--red);    color: var(--red); }
.fb.on-gray   { background: color-mix(in srgb, var(--muted2) 8%, transparent); border-color: var(--muted2); color: var(--muted); }
.sort-sel {
  padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); font-size: 0.8rem;
  outline: none; cursor: pointer;
  margin-left: auto;
  transition: border-color 0.2s ease;
}
.sort-sel:hover { border-color: var(--blue); }
.scope-sel {
  padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); font-size: 0.8rem;
  outline: none; cursor: pointer; max-width: 220px;
  transition: border-color 0.2s ease;
}
.scope-sel:hover:not(:disabled) { border-color: var(--blue); }
.scope-sel:disabled { opacity: 0.55; cursor: not-allowed; }
.export-group { display: flex; gap: 6px; flex-shrink: 0; }
.export-btn {
  padding: 8px 13px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--muted); font-size: 0.74rem; font-weight: 700;
  cursor: pointer; letter-spacing: 0.02em;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.export-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--text); background: var(--bg2); }
.export-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── TABLE ── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  background: var(--bg2); color: var(--muted);
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700;
  padding: 14px 18px; text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
  position: sticky; top: 0; z-index: 1;
}
thead th.th-details { width: 72px; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0; margin: 0; border: 0; background: none;
  color: inherit; font: inherit; letter-spacing: inherit;
  text-transform: inherit; cursor: pointer; white-space: nowrap;
}
.sort-btn:hover { color: var(--text); }
.sort-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.sort-arrow { font-size: 0.8rem; line-height: 1; }
th[aria-sort="ascending"] { color: var(--text); }
th[aria-sort="descending"] { color: var(--text); }
th[aria-sort="ascending"] .sort-arrow::after { content: "↑"; }
th[aria-sort="descending"] .sort-arrow::after { content: "↓"; }
th[aria-sort="none"] .sort-btn:hover .sort-arrow::after,
th[aria-sort="none"] .sort-btn:focus-visible .sort-arrow::after { content: "↕"; opacity: 0.7; }
tbody tr.row { border-bottom: 1px solid var(--border); transition: background 0.18s ease; }
tbody tr.row:last-of-type { border-bottom: none; }
tbody tr.row:hover { background: color-mix(in srgb, var(--blue) 5%, transparent); }
td { padding: 13px 18px; white-space: nowrap; vertical-align: middle; }
td.cell-domain { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; font-weight: 500; }
td.cell-domain a { color: var(--text); text-decoration: none; transition: color 0.18s ease; }
td.cell-domain a:hover { color: var(--blue-text); text-decoration: underline; }
td.cell-muted { color: var(--muted); }
td.cell-details { width: 72px; text-align: right; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 10px;
  font-size: 0.73rem; font-weight: 700;
  white-space: nowrap; border: 1px solid transparent;
}
.badge-icon { font-size: 0.72rem; line-height: 1; }
.b-green  { background: color-mix(in srgb, var(--green) 10%, transparent);  color: var(--green);  border-color: color-mix(in srgb, var(--green) 24%, transparent); }
.b-yellow { background: color-mix(in srgb, var(--yellow) 10%, transparent); color: var(--yellow); border-color: color-mix(in srgb, var(--yellow) 24%, transparent); }
.b-orange { background: color-mix(in srgb, var(--orange) 10%, transparent); color: var(--orange); border-color: color-mix(in srgb, var(--orange) 24%, transparent); }
.b-red    { background: color-mix(in srgb, var(--red) 10%, transparent);    color: var(--red);    border-color: color-mix(in srgb, var(--red) 24%, transparent); }
.b-gray   { background: color-mix(in srgb, var(--muted) 10%, transparent);  color: var(--muted);  border-color: color-mix(in srgb, var(--muted) 20%, transparent); }

.bar-wrap { display: flex; align-items: center; gap: 10px; min-width: 132px; }
.bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 76px; }
.bar-fill { height: 100%; border-radius: 3px; }
.bar-num { font-size: 0.79rem; font-weight: 700; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.tone-green  { color: var(--green); }  .bar-fill.tone-green  { background: var(--green); }
.tone-yellow { color: var(--yellow); } .bar-fill.tone-yellow { background: var(--yellow); }
.tone-orange { color: var(--orange); } .bar-fill.tone-orange { background: var(--orange); }
.tone-red    { color: var(--red); }    .bar-fill.tone-red    { background: var(--red); }
.tone-gray   { color: var(--muted); }  .bar-fill.tone-gray   { background: var(--border2); }

.pi {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 5px;
  font-size: 0.56rem; font-weight: 800; letter-spacing: 0.02em;
  margin-right: 7px; vertical-align: middle; flex-shrink: 0;
  background: var(--border); color: var(--text);
}
.pi.p-green  { background: color-mix(in srgb, var(--green) 10%, transparent);  color: var(--green); }
.pi.p-orange { background: color-mix(in srgb, var(--orange) 10%, transparent); color: var(--orange); }
.pi.p-blue   { background: color-mix(in srgb, var(--pill-blue) 10%, transparent);   color: var(--pill-blue); }
.pi.p-purple { background: color-mix(in srgb, var(--purple) 10%, transparent); color: var(--purple); }
.pi.p-yellow { background: color-mix(in srgb, var(--yellow) 10%, transparent); color: var(--yellow); }
.pi.p-gray   { background: color-mix(in srgb, var(--muted) 10%, transparent);  color: var(--muted); }

.row-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg); color: var(--muted);
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.row-toggle:hover { border-color: var(--blue); color: var(--text); background: var(--bg2); }
.row-toggle .chevron { display: block; font-size: 1rem; line-height: 1; transition: transform 0.2s ease; }
.row-toggle[aria-expanded="true"] { border-color: var(--blue); color: var(--blue-text); }
.row-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

/* ── DETAIL ROW ── */
tr.detail-row > td {
  padding: 0;
  background: var(--bg2);
  white-space: normal;
  border-bottom: 1px solid var(--border);
}
.detail-panel { padding: 16px 18px 18px; }
.detail-panel h3 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin-bottom: 12px;
}
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 24px;
}
.detail-item { min-width: 0; }
.detail-item dt { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.detail-item dd { font-size: 0.8rem; color: var(--text); overflow-wrap: anywhere; }
.detail-command { margin-top: 14px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg); }
.detail-command-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  font-size: 0.7rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.detail-command code {
  display: block; padding: 12px; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem; color: var(--text); white-space: pre;
}
.copy-btn {
  padding: 5px 11px; border-radius: 8px;
  border: 1px solid var(--border2); background: var(--bg2);
  color: var(--text); font-size: 0.68rem; font-weight: 700;
  text-transform: none; letter-spacing: 0;
  cursor: pointer;
}
.copy-btn:hover { border-color: var(--blue); }
.copy-status { font-size: 0.7rem; color: var(--green); min-height: 1em; }
.copy-status:empty { display: none; }

.no-rows { text-align: center; padding: 48px 20px; color: var(--muted); font-size: 0.875rem; }

/* ── SKELETON ── */
.skeleton-card { pointer-events: none; }
.skeleton-line {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--border) 25%, var(--border2) 37%, var(--border) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.skeleton-line.short { width: 42%; margin-bottom: 14px; height: 9px; }
.skeleton-line.tall { width: 64%; height: 26px; }
.skeleton-row td { padding: 16px 18px; }
.skeleton-row .skeleton-line { max-width: 420px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ── FOOTER ── */
.site-footer {
  text-align: center; padding: 28px 32px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 0.78rem;
  margin-top: 40px;
}
.site-footer strong { color: var(--text); font-weight: 600; }
.site-footer a { color: var(--blue-text); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .sort-sel { margin-left: 0; }
  .scope-sel { max-width: 190px; }
  .export-group { margin-left: auto; }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 16px;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 0;
  }
  .brand { margin-right: auto; flex-shrink: 0; }
  .brand-sub { display: none; }
  .topbar-right { order: 2; margin-left: 12px; gap: 10px; flex-shrink: 0; }
  .nav-tabs {
    order: 3;
    width: calc(100% + 32px);
    margin: 0 -16px;
    height: 48px;
    border-top: 1px solid var(--border);
    flex: none;
  }
  .nav-tab { padding: 0 16px; font-size: 0.8rem; flex: 1; justify-content: center; }
  .nav-tab::after { left: 0; right: 0; }
  .page { padding: 14px 12px 40px; }
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stat-card { padding: 16px 16px; border-radius: 16px; }
  .stat-val { font-size: 1.75rem; }
  .controls { flex-direction: column; align-items: stretch; gap: 9px; }
  .search-wrap { max-width: 100%; flex-basis: auto; }
  .sort-sel { margin-left: 0; width: 100%; }
  .scope-sel { width: 100%; max-width: none; }
  .export-group { margin-left: 0; }
  .export-group .export-btn { flex: 1; }
  .bar-wrap { min-width: 96px; }
  .bar { min-width: 44px; }
  .updated-pill { padding: 4px 10px; font-size: 0.68rem; }
  .site-footer { padding: 20px 16px 18px; }
  .timeline-legend { gap: 5px 12px; }
  .refresh-label { display: none; }
  .dist-item { grid-template-columns: minmax(90px, 45%) 1fr 40px; gap: 9px; }
}

/* Cards instead of a wide table on phones. Explicit ARIA roles above keep
   the table semantics even while the CSS display changes. */
@media (max-width: 640px) {
  .tbl-wrap { overflow: visible; padding: 12px; background: var(--bg2); }
  table { display: block; }
  thead {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  tbody { display: grid; gap: 12px; }
  tbody tr.row {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 15px;
    box-shadow: var(--shadow-sm);
  }
  tbody tr.row:last-of-type { border-bottom: 1px solid var(--border); }
  tbody tr.row:hover { background: var(--card); }
  tbody tr.row > td {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    width: 100%; padding: 6px 0;
    white-space: normal;
    border: none;
    text-align: right;
  }
  tbody tr.row > td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    text-align: left;
  }
  tbody tr.row > td.cell-domain {
    display: block;
    padding: 0 0 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
    text-align: left;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  tbody tr.row > td.cell-domain::before { display: none; }
  tbody tr.row > td.cell-details {
    display: block;
    width: 100%;
    padding: 10px 0 0;
    margin-top: 8px;
    border-top: 1px solid var(--border);
    text-align: left;
  }
  tbody tr.row > td.cell-details::before { display: none; }
  tbody tr.row > td .bar-wrap { flex: 1; justify-content: flex-end; }
  tbody tr.row > td .bar { max-width: 120px; }
  tbody tr.row > td.cell-details .row-toggle { width: 100%; height: 36px; gap: 8px; }
  tbody tr.row > td.cell-details .row-toggle::after { content: 'Details'; font-size: 0.74rem; font-weight: 700; }
  tbody tr.row > td.cell-details .row-toggle[aria-expanded="true"]::after { content: 'Hide details'; }
  tbody tr.detail-row { display: block; margin-top: -4px; }
  tbody tr.detail-row > td {
    display: block;
    padding: 0;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 16px 16px;
    text-align: left;
    background: var(--bg2);
    margin-top: -10px;
  }
  .detail-panel { padding: 14px 15px 16px; }
  .detail-grid { grid-template-columns: 1fr; gap: 9px; }
  .skeleton-row { display: block; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 8px; }
  .skeleton-row td { display: block; border: none; padding: 8px; }
  .skeleton-row .skeleton-line { max-width: 100%; }
  .no-rows { padding: 36px 14px; }
  /* The card layout above applies to the results table only; keep the
     history numbers a normal table so its columns stay readable. */
  .history-table-wrap table { display: table; }
  .history-table-wrap thead {
    position: static !important;
    width: auto; height: auto;
    padding: 0; margin: 0;
    overflow: visible;
    clip: auto; clip-path: none;
    white-space: normal;
    border: 0;
  }
  .history-table-wrap tbody { display: table-row-group; }
  .history-table-wrap tbody tr,
  .history-table-wrap tbody tr.row {
    display: table-row;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: 0;
    box-shadow: none;
  }
  .history-table-wrap tbody td,
  .history-table-wrap tbody tr.row > td {
    display: table-cell;
    width: auto;
    padding: 8px 6px;
    text-align: left;
    white-space: nowrap;
    border: 0;
  }
  .history-table-wrap tbody td::before,
  .history-table-wrap tbody tr.row > td::before { display: none; content: none; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .nav-tab { font-size: 0.75rem; padding: 0 10px; }
  .nav-tab-long { display: none; }
  .nav-tab-short { display: inline; }
  /* Keep the last-updated text in the accessibility tree on tiny screens. */
  .updated-pill span:not(.live-dot) {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .theme-label { display: none; }
  .section-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .attention-list { grid-template-columns: 1fr; }
  .dist-item { grid-template-columns: 1fr 40px; gap: 6px 10px; }
  .dist-name { grid-column: 1 / -1; white-space: normal; overflow-wrap: anywhere; }
  .timeline-legend { font-size: 0.7rem; }
  .detail-command code { font-size: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
