/* ============================================================
   Memora dashboard — design tokens
   Colour values (series / status / surfaces) are kept as-is:
   they were validated for contrast + CVD. Everything else is
   layout, typography, spacing and motion polish.
   ============================================================ */

:root {
  color-scheme: light;

  --page: #f6f6f3;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --surface-3: #e9e8e4;
  --text-primary: #17160f;
  --text-secondary: #56544d;
  --text-muted: #8a887f;
  --gridline: #e4e3dc;
  --baseline: #c3c2b7;
  --border: rgba(17, 16, 9, 0.10);
  --border-strong: rgba(17, 16, 9, 0.16);
  --success-text: #006300;

  --series-1: #2a78d6; /* liquidity */
  --series-2: #eb6834; /* volume */
  --series-3: #1baf7a; /* market cap */

  --status-good: #0ca30c;
  --status-warning: #c98500;
  --status-serious: #d76b3f;
  --status-critical: #d03b3b;
  --status-neutral: #8a887f;
  --status-flagged: #4a3aa7;

  --accent: var(--series-1);
  --accent-soft: color-mix(in srgb, var(--series-1) 12%, transparent);
  --focus-ring: color-mix(in srgb, var(--series-1) 32%, transparent);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(17, 16, 9, 0.05), 0 1px 3px rgba(17, 16, 9, 0.04);
  --shadow: 0 2px 6px rgba(17, 16, 9, 0.06), 0 8px 24px rgba(17, 16, 9, 0.06);

  --sidebar-w: 236px;
  --content-max: 1280px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f0f10;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --surface-3: #2c2c2a;
    --text-primary: #f4f3ee;
    --text-secondary: #c3c2b7;
    --text-muted: #8c8a80;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --success-text: #0ca30c;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --status-warning: #e7a63a;
    --status-serious: #ec835a;
    --status-flagged: #9085e9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f0f10;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --surface-3: #2c2c2a;
  --text-primary: #f4f3ee;
  --text-secondary: #c3c2b7;
  --text-muted: #8c8a80;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --success-text: #0ca30c;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --status-warning: #e7a63a;
  --status-serious: #ec835a;
  --status-flagged: #9085e9;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.35);
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); }

a { color: var(--accent); }

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

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 3px solid var(--page);
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- app shell / layout ---------- */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.content {
  min-width: 0;
  padding: 32px clamp(20px, 4vw, 44px) 72px;
}

#app {
  max-width: var(--content-max);
  margin: 0 auto;
}

#app.route-enter {
  animation: route-in 0.2s var(--ease);
}
@keyframes route-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 14px 16px;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--series-1), color-mix(in srgb, var(--series-1) 55%, var(--series-3)));
  box-shadow: 0 0 0 4px var(--accent-soft);
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  flex: 1;
}

.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 10px 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}

.sidebar-nav a svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
}

.sidebar-nav a:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.sidebar-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-foot {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.unit-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 34px;
}
.unit-toggle button {
  appearance: none;
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 650;
  padding: 0 12px;
  cursor: pointer;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.unit-toggle button + button { border-left: 1px solid var(--border); }
.unit-toggle button:hover { color: var(--text-primary); }
.unit-toggle button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-toggle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: border-color 0.14s, background 0.14s;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--border-strong); }

/* ---------- mobile bar / drawer ---------- */

.mobile-bar { display: none; }
.scrim { display: none; }

.menu-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.menu-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--text-primary); stroke-width: 2; stroke-linecap: round; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .mobile-bar .brand-name { font-size: 15px; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: 264px;
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease);
  }
  .scrim.show { opacity: 1; pointer-events: auto; }

  .content { padding: 20px 16px 56px; }
}

/* ---------- typography / page head ---------- */

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

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 30px 0 12px;
}

p.stat-label { line-height: 1.55; }

.updated-at {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.page-head-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- heartbeat pill (compact "is the Scanner alive" indicator) ---------- */

.hb-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: default;
}
.hb-pill .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; position: relative; }

.hb-pill.hb-ok {
  background: color-mix(in srgb, var(--status-good) 13%, transparent);
  color: var(--status-good);
  border-color: color-mix(in srgb, var(--status-good) 28%, transparent);
}
.hb-pill.hb-ok .dot {
  background: var(--status-good);
  animation: hb-pulse-ring 2s ease-in-out infinite;
}
.hb-pill.hb-stale {
  background: color-mix(in srgb, var(--status-critical) 13%, transparent);
  color: var(--status-critical);
  border-color: color-mix(in srgb, var(--status-critical) 28%, transparent);
}
.hb-pill.hb-stale .dot { background: var(--status-critical); }

@keyframes hb-pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 50%, transparent); }
  50% { box-shadow: 0 0 0 4px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .hb-pill .dot { animation: none; }
}

/* ---------- home pipeline ---------- */

.pipeline {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
  margin-bottom: 2px;
}

.pl-stage {
  --pl-accent: var(--baseline);
  --pl-fill: var(--surface-1);
  background: var(--pl-fill);
  border: 1px solid var(--border);
  border-left: 3px solid var(--pl-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 17px 19px;
  position: relative;
  flex: 1 1 150px;
  min-width: 138px;
  min-height: 94px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  text-align: left;
}

.pl-num {
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.pl-stage-sub .pl-num { font-size: 20px; }
.pl-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.pl-hint { font-size: 11px; color: var(--text-muted); }

/* tones — soft tinted fills keyed to meaning */
.pl-tone-live1 {
  --pl-accent: var(--series-1);
  --pl-fill: color-mix(in srgb, var(--series-1) 9%, var(--surface-1));
}
.pl-tone-live2 {
  --pl-accent: var(--status-warning);
  --pl-fill: color-mix(in srgb, var(--status-warning) 11%, var(--surface-1));
}
.pl-tone-flagged {
  --pl-accent: var(--status-flagged);
  --pl-fill: color-mix(in srgb, var(--status-flagged) 10%, var(--surface-1));
}
.pl-tone-good {
  --pl-accent: var(--status-good);
  --pl-fill: color-mix(in srgb, var(--status-good) 12%, var(--surface-1));
}
.pl-tone-warning {
  --pl-accent: var(--status-warning);
  --pl-fill: color-mix(in srgb, var(--status-warning) 15%, var(--surface-1));
}
.pl-tone-neutral {
  --pl-accent: var(--status-neutral);
  --pl-fill: var(--surface-2);
}

a.pl-link,
button.pl-link {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  font: inherit;
  text-align: left;
  transition: transform 0.14s var(--ease), border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
a.pl-link:hover,
button.pl-link:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--pl-accent) 50%, var(--border-strong));
  box-shadow: var(--shadow);
}
a.pl-link:focus-visible,
button.pl-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* live-state emphasis: brighter border + a pinging indicator dot */
.pl-live { border-color: color-mix(in srgb, var(--pl-accent) 42%, var(--border)); }
.pl-pulse {
  position: absolute;
  top: 11px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pl-accent);
}
.pl-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--pl-accent);
  animation: pl-ping 2.1s var(--ease) infinite;
}
@keyframes pl-ping {
  0% { transform: scale(1); opacity: 0.5; }
  70%, 100% { transform: scale(3.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .pl-pulse::after { animation: none; }
}

/* connector "pipe" between stages */
.pl-pipe {
  flex: 0 0 30px;
  align-self: flex-start;
  margin-top: 40px;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--accent) 22%, var(--baseline)),
    color-mix(in srgb, var(--accent) 44%, var(--baseline))
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 -1px 0 rgba(0, 0, 0, 0.06);
  position: relative;
}
.pl-pipe::after {
  content: "";
  position: absolute;
  right: -2px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-top: 3px solid color-mix(in srgb, var(--accent) 55%, var(--baseline));
  border-right: 3px solid color-mix(in srgb, var(--accent) 55%, var(--baseline));
  transform: translateY(-50%) rotate(45deg);
}

/* fork — a single card the same height as its neighbours */
.pl-fork {
  padding: 0;
  gap: 0;
  overflow: hidden;
}
.pl-fork-cap {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 10px 17px 4px;
}
.pl-fork-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 17px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.14s var(--ease);
}
.pl-fork-row + .pl-fork-row { border-top: 1px solid var(--border); }
.pl-fork-row:hover { background: color-mix(in srgb, var(--pl-accent) 12%, transparent); }
.pl-fork-row:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.pl-fork-num {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.pl-fork-label { font-size: 12.5px; color: var(--text-secondary); }

/* final — the peak-strength cluster: a compact trio that sits level with the
   spine on wide screens, stacks on narrow ones. Grouped with its connecting
   pipe in one flex item so the two always wrap together — a lone connector
   stranded at the end of a line (nothing to point at) would break the "one
   continuous flow" read the pipes exist for. */
.pl-final-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 3 1 420px;
  min-width: 230px;
}
.pl-final {
  flex: 1 1 auto;
  min-width: 200px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
}
.pl-final .pl-stage {
  flex: 1 1 116px;
  min-width: 104px;
  min-height: 88px;
  padding: 13px 14px;
}
.pl-final .pl-label { font-size: 11.5px; }

@media (max-width: 900px) {
  .pipeline { flex-direction: column; align-items: stretch; }
  .pl-stage,
  .pl-fork,
  .pl-final,
  .pl-final-group { flex: 1 1 auto; width: 100%; }
  .pl-final-group { flex-direction: column; align-items: stretch; gap: 8px; }
  .pl-final { flex-direction: column; }
  .pl-final .pl-stage { min-height: 0; }
  .pl-pipe {
    align-self: center;
    margin: 0;
    flex-basis: 22px;
    width: 14px;
    height: 22px;
    background: linear-gradient(
      180deg,
      color-mix(in srgb, var(--accent) 22%, var(--baseline)),
      color-mix(in srgb, var(--accent) 44%, var(--baseline))
    );
  }
  .pl-pipe::after {
    right: 50%;
    top: auto;
    bottom: -2px;
    transform: translateX(50%) rotate(135deg);
  }
}

/* ---------- cards / tables ---------- */

.table-card,
.chart-wrap {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

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

.chart-wrap { padding: 20px; margin-top: 16px; }

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--surface-2);
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

th[data-sortable="true"] { cursor: pointer; user-select: none; transition: color 0.12s; }
th[data-sortable="true"]:hover { color: var(--text-primary); }
th.active-sort { color: var(--text-primary); }
th .sort-arrow { margin-left: 4px; color: var(--accent); font-weight: 700; }

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gridline);
  font-size: 13px;
  white-space: nowrap;
  color: var(--text-primary);
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12.5px;
}

tbody tr { transition: background 0.1s; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }

/* ---------- status badge ---------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-badge .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.status-badge.SEEN {
  background: color-mix(in srgb, var(--status-neutral) 13%, transparent);
  color: var(--text-secondary);
  border-color: color-mix(in srgb, var(--status-neutral) 26%, transparent);
}
.status-badge.SEEN .dot { background: var(--text-muted); }

.status-badge.WATCHING {
  background: color-mix(in srgb, var(--status-warning) 15%, transparent);
  color: var(--status-warning);
  border-color: color-mix(in srgb, var(--status-warning) 30%, transparent);
}
.status-badge.WATCHING .dot { background: var(--status-warning); animation: pulse-dot 1.6s ease-in-out infinite; }

.status-badge.MIGRATED {
  background: color-mix(in srgb, var(--status-good) 15%, transparent);
  color: var(--status-good);
  border-color: color-mix(in srgb, var(--status-good) 30%, transparent);
}
.status-badge.MIGRATED .dot { background: var(--status-good); }

.status-badge.DIED {
  background: color-mix(in srgb, var(--status-critical) 15%, transparent);
  color: var(--status-critical);
  border-color: color-mix(in srgb, var(--status-critical) 30%, transparent);
}
.status-badge.DIED .dot { background: var(--status-critical); }

.status-badge.SURVIVED {
  background: color-mix(in srgb, var(--status-serious) 15%, transparent);
  color: var(--status-serious);
  border-color: color-mix(in srgb, var(--status-serious) 30%, transparent);
}
.status-badge.SURVIVED .dot { background: var(--status-serious); }

.status-badge.SUSPICIOUS_SPIKE {
  background: color-mix(in srgb, var(--status-flagged) 15%, transparent);
  color: var(--status-flagged);
  border-color: color-mix(in srgb, var(--status-flagged) 30%, transparent);
}
.status-badge.SUSPICIOUS_SPIKE .dot { background: var(--status-flagged); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--status-warning) 50%, transparent); }
  50% { opacity: 0.55; box-shadow: 0 0 0 4px transparent; }
}

/* ---------- links / mint cell ---------- */

a.mint-link {
  color: var(--accent);
  text-decoration: none;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
}
a.mint-link:hover { text-decoration: underline; }

.copy-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 5px;
  vertical-align: middle;
  transition: color 0.12s, background 0.12s;
}
.copy-btn:hover { color: var(--text-primary); background: var(--surface-2); }
.copy-btn.copied { color: var(--status-good); }

/* ---------- filters ---------- */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px 14px;
  align-items: end;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 18px;
}

.filters .field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.filters .field.wide { grid-column: span 2; }
.filters label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }

.filters input,
.filters select {
  background: var(--page);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.filters input:focus,
.filters select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.filters .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  padding-top: 12px;
  border-top: 1px dashed var(--gridline);
  margin-top: 2px;
}

/* ---------- buttons ---------- */

button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: filter 0.12s, transform 0.06s;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button:active, .btn:active { transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); background: var(--surface-2); filter: none; border-color: var(--border-strong); }

.btn-danger { background: var(--status-critical); }

button:disabled, .btn:disabled {
  cursor: not-allowed;
  filter: none;
  background: var(--surface-3);
  color: var(--text-muted);
}
button:disabled:hover, .btn:disabled:hover { filter: none; transform: none; }

/* ---------- pagination ---------- */

.pagination { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.pagination button {
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.pagination button:hover { background: var(--surface-2); filter: none; }
.pagination .page-info {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

/* ---------- Управление: Scanner / База данных ---------- */

.control-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.control-card-status { display: flex; align-items: center; gap: 12px; }
.control-card-title { font-size: 15px; font-weight: 650; }
.control-card-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.cleanup-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.cleanup-card h2 { margin-top: 0; }
.cleanup-preview {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 8px 0 14px;
  font-variant-numeric: tabular-nums;
}
.cleanup-preview b { color: var(--text-primary); font-family: "JetBrains Mono", ui-monospace, monospace; }

.danger-zone {
  border: 1px solid color-mix(in srgb, var(--status-critical) 35%, var(--border));
  background: color-mix(in srgb, var(--status-critical) 6%, var(--surface-1));
}
.danger-zone h2 { color: var(--status-critical); }

/* ---------- settings form ---------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
}
.settings-field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.settings-field input {
  background: var(--page);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 14px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  width: 150px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.settings-field input.wide { width: 100%; max-width: 260px; }
.settings-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.field-hint {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ---------- detail grid / misc ---------- */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.detail-grid .item {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
}
.detail-grid .item .label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.detail-grid .item .value { font-size: 15px; font-weight: 600; margin-top: 4px; word-break: break-all; }
.detail-grid .item .value.mono {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
}

.empty-state {
  color: var(--text-muted);
  padding: 56px 20px;
  text-align: center;
  font-size: 13px;
}

.back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.12s;
}
.back-link:hover { color: var(--text-primary); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
