/* ============================================================
   Tridorian Short — design system
   Quiet precision: hairline borders, one white content panel on a
   soft canvas, ink text, a single emerald accent, tabular numerals
   and mono for slugs. Mobile gets a bottom tab bar and card rows.
   ============================================================ */

/* ---------- Fonts (self-hosted, latin subset; see web/FONTS.md) ----------
   First visit: text paints at once in the "* Fallback" faces, which re-shape a
   local system font to the metrics of the web font so the swap barely moves
   layout. The inline script in index.html adds .fonts-loaded to <html> once the
   web fonts are loaded (or straight away on a repeat visit, when they are
   cached), and the variables below switch to them. */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-latin-var.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/space-grotesk-latin-var.woff2') format('woff2');
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-latin-var.woff2') format('woff2');
  font-weight: 500 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial'), local('Liberation Sans'), local('Arimo');
  font-weight: 400 500;
  size-adjust: 107.47%;
  ascent-override: 90.14%;
  descent-override: 22.44%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial Bold'), local('Arial-BoldMT'), local('Liberation Sans Bold'), local('Arimo Bold');
  font-weight: 600 700;
  size-adjust: 107.47%;
  ascent-override: 90.14%;
  descent-override: 22.44%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Space Grotesk Fallback';
  src: local('Arial Bold'), local('Arial-BoldMT'), local('Liberation Sans Bold'), local('Arimo Bold');
  font-weight: 500 700;
  size-adjust: 102.72%;
  ascent-override: 95.79%;
  descent-override: 28.43%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'JetBrains Mono Fallback';
  src: local('Courier New'), local('Liberation Mono'), local('Cousine');
  font-weight: 500 600;
  size-adjust: 99.98%;
  ascent-override: 102.02%;
  descent-override: 30%;
  line-gap-override: 0%;
}

/* ============================================================
   Tokens
   One flat, hairline-bordered system: a quiet canvas, one white
   panel for content, ink text, and a single emerald accent used only
   for the primary action, the active nav, slugs and focus.
   Light/dark follow prefers-color-scheme. Every text/background pair
   below is checked for WCAG AA (4.5:1 text, 3:1 controls) by
   scripts/contrast.mjs.
   ============================================================ */
:root {
  color-scheme: light;
  --font-display: 'Space Grotesk Fallback', system-ui, sans-serif;
  --font-body: 'Inter Fallback', system-ui, sans-serif;
  --font-code: 'JetBrains Mono Fallback', ui-monospace, monospace;

  --canvas: #F4F6F4;
  --panel: #FFFFFF;
  --subtle: #F7F9F7;
  --sunken: #EEF1EF;
  --border: #E3E8E5;
  --border-strong: #CDD4D0;
  --input-border: #8A9690;

  --text: #0E1311;
  --text-2: #37413C;
  --text-3: #5B6761;
  --placeholder: #66726C;

  --accent: #0B7A55;
  --accent-hover: #08623F;
  --accent-text: #0A6B4A;
  --on-accent: #FFFFFF;
  --danger: #B83224;
  --warn: #8F5400;
  --info: #14607F;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--panel));
  --danger-soft: color-mix(in srgb, var(--danger) 9%, var(--panel));
  --warn-soft: color-mix(in srgb, var(--warn) 11%, var(--panel));
  --info-soft: color-mix(in srgb, var(--info) 10%, var(--panel));
  --accent-line: color-mix(in srgb, var(--accent) 28%, var(--panel));
  --danger-line: color-mix(in srgb, var(--danger) 28%, var(--panel));
  --warn-line: color-mix(in srgb, var(--warn) 30%, var(--panel));
  --info-line: color-mix(in srgb, var(--info) 28%, var(--panel));
  --focus: var(--accent);

  --shadow-xs: 0 1px 1px rgb(14 19 17 / 0.05);
  --shadow-sm: 0 1px 2px rgb(14 19 17 / 0.06), 0 1px 1px rgb(14 19 17 / 0.03);
  --shadow-panel: 0 1px 2px rgb(14 19 17 / 0.04), 0 12px 32px -16px rgb(14 19 17 / 0.1);
  --shadow-pop: 0 12px 32px -8px rgb(14 19 17 / 0.22), 0 2px 6px rgb(14 19 17 / 0.08);
  --chart-human: var(--accent);
  --chart-bot: #8A958F;
  --badge-bg-l: 93%;
  --badge-fg-l: 27%;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6761' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --tabbar-h: 58px;

  font-family: var(--font-body);
}

:root.fonts-loaded {
  --font-display: 'Space Grotesk', 'Space Grotesk Fallback', system-ui, sans-serif;
  --font-body: 'Inter', 'Inter Fallback', system-ui, sans-serif;
  --font-code: 'JetBrains Mono', 'JetBrains Mono Fallback', ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --canvas: #090D0B;
    --panel: #101613;
    --subtle: #141B18;
    --sunken: #1A231F;
    --border: #1E2823;
    --border-strong: #2D3A34;
    --input-border: #5A6962;

    --text: #E9EFEC;
    --text-2: #B9C4BE;
    --text-3: #8D9B94;
    --placeholder: #7F8C85;

    --accent: #34C58F;
    --accent-hover: #5CD9A9;
    --accent-text: #4CD29E;
    --on-accent: #04251A;
    --danger: #F28B7B;
    --warn: #EDB654;
    --info: #6CC0E0;
    --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--panel));
    --danger-soft: color-mix(in srgb, var(--danger) 14%, var(--panel));
    --warn-soft: color-mix(in srgb, var(--warn) 14%, var(--panel));
    --info-soft: color-mix(in srgb, var(--info) 14%, var(--panel));
    --accent-line: color-mix(in srgb, var(--accent) 34%, var(--panel));
    --danger-line: color-mix(in srgb, var(--danger) 34%, var(--panel));
    --warn-line: color-mix(in srgb, var(--warn) 34%, var(--panel));
    --info-line: color-mix(in srgb, var(--info) 34%, var(--panel));

    --shadow-xs: 0 1px 1px rgb(0 0 0 / 0.35);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-panel: 0 0 0 1px rgb(255 255 255 / 0.02), 0 16px 40px -20px rgb(0 0 0 / 0.7);
    --shadow-pop: 0 16px 40px -8px rgb(0 0 0 / 0.7), 0 2px 8px rgb(0 0 0 / 0.5);
    --chart-bot: #5F6C66;
    --badge-bg-l: 17%;
    --badge-fg-l: 74%;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238D9B94' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 0.875rem/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

a { color: var(--accent-text); text-decoration: none; }
button, a, input, select, textarea {
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

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

h1, h2, h3, .brand-name { font-family: var(--font-display); letter-spacing: -0.02em; margin: 0; color: var(--text); }
h1 { font-size: clamp(1.625rem, 1.3rem + 1vw, 2rem); line-height: 1.15; font-weight: 600; letter-spacing: -0.03em; }
h2 { font-size: 1rem; line-height: 1.3; font-weight: 600; }
h3 { font-size: 0.9375rem; line-height: 1.3; font-weight: 600; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

.muted { color: var(--text-3); }
.mono { font-family: var(--font-code); }
.cap { text-transform: capitalize; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.skip-link {
  position: absolute; left: 12px; top: -56px; z-index: 200;
  padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow-pop);
}
.skip-link:focus { top: 12px; }

/* ---------- Shell: canvas + sidebar, content sits on one panel ---------- */
.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 240px; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 16px 12px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin-bottom: 16px; border-radius: var(--r-md); }
.side-cta { width: 100%; margin-bottom: 24px; }
.brand-mark {
  width: 30px; height: 30px; display: grid; place-items: center; flex: none;
  border-radius: var(--r-md); background: var(--accent); color: var(--on-accent);
}
.brand-mark .icon { width: 17px; height: 17px; stroke-width: 2.25; }
.brand-text { display: grid; line-height: 1.2; }
.brand-name { font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.01em; }
.brand-caption { color: var(--text-3); font-size: 0.75rem; }

.nav-label { padding: 0 10px; margin: 0 0 6px; color: var(--text-3); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.nav-list { display: grid; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px;
  border: 1px solid transparent; border-radius: var(--r-md);
  color: var(--text-2); font-weight: 500;
}
.nav-link .icon { color: var(--text-3); }
.nav-link:hover { background: color-mix(in srgb, var(--text) 5%, transparent); color: var(--text); }
.nav-link.active { background: var(--panel); border-color: var(--border); box-shadow: var(--shadow-xs); color: var(--text); font-weight: 600; }
.nav-link.active .icon { color: var(--accent-text); }

.sidebar-footer { margin-top: auto; }
.user-card {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel);
}
.avatar {
  width: 30px; height: 30px; display: grid; place-items: center; flex: none;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-text);
  border: 1px solid var(--accent-line);
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.02em;
}
.user-meta { min-width: 0; flex: 1; line-height: 1.3; }
.user-meta strong, .user-meta span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta strong { font-size: 0.8125rem; font-weight: 600; }
.user-meta span { color: var(--text-3); font-size: 0.75rem; }

.main-pane { grid-column: 2; min-width: 0; display: flex; flex-direction: column; padding: 10px 10px 10px 0; }
.content {
  flex: 1; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--r-xl);
  background: var(--panel);
  box-shadow: var(--shadow-panel);
}
.content:focus { outline: none; }
.page { width: min(1080px, 100%); margin: 0 auto; padding: 36px 40px 64px; }
.topbar, .tabbar, .mobile-backdrop { display: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-head > div:first-child { min-width: 0; }
.page-head p { max-width: 62ch; margin: 6px 0 0; color: var(--text-3); font-size: 0.875rem; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 14px -2px; color: var(--text-3); font-size: 0.8125rem; font-weight: 500; }
.back-link:hover { color: var(--text); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: var(--accent); color: var(--on-accent);
  font: 600 0.8125rem/1 var(--font-body); white-space: nowrap; cursor: pointer;
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn.secondary { border-color: var(--border-strong); background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { background: var(--subtle); border-color: var(--text-3); color: var(--text); }
.btn.ghost { background: transparent; color: var(--text-2); box-shadow: none; }
.btn.ghost:hover { background: var(--sunken); color: var(--text); }
.btn.danger { border-color: var(--danger-line); background: var(--panel); color: var(--danger); box-shadow: none; }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 0.8125rem; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 0.9375rem; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--r-md); }
.btn-icon.ghost { color: var(--text-3); }
.btn.ghost.del:hover { background: var(--danger-soft); color: var(--danger); }
.btn-xs { width: 24px; height: 24px; border-radius: var(--r-sm); }
.btn-xs .icon { width: 14px; height: 14px; }

/* ---------- Stat cards ---------- */
.stat-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat {
  min-width: 0; padding: 16px 18px 14px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'label label' 'value visual' 'note note'; align-items: end; column-gap: 12px;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel); box-shadow: var(--shadow-xs);
}
.stat-label { grid-area: label; display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 0.8125rem; font-weight: 500; }
.stat-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent-text); }
.stat-icon .icon { width: 14px; height: 14px; }
.stat-value {
  grid-area: value; display: block; margin-top: 12px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 600 2rem/1.1 var(--font-display); letter-spacing: -0.035em; font-variant-numeric: tabular-nums;
}
.stat-value.is-code { font: 600 1.375rem/1.6 var(--font-code); letter-spacing: -0.02em; color: var(--accent-text); }
.stat-visual { grid-area: visual; width: 112px; height: 36px; display: flex; align-items: flex-end; justify-content: flex-end; }
.stat-note { grid-area: note; display: block; margin-top: 6px; min-height: 1.1rem; color: var(--text-3); font-size: 0.75rem; }
.spark { display: flex; align-items: flex-end; gap: 2px; width: 100%; height: 100%; }
.spark span { flex: 1; min-height: 3px; border-radius: 2px 2px 0 0; background: color-mix(in srgb, var(--accent) 35%, var(--panel)); }
.spark span.top { background: var(--accent); }
.meter { width: 100%; height: 6px; margin-bottom: 8px; overflow: hidden; border-radius: 9999px; background: var(--sunken); }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* ---------- Toolbar + search ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.search-field { position: relative; display: flex; align-items: center; flex: 1; min-width: 220px; max-width: 400px; }
.search-field .icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.search-field input { padding-left: 36px; }
.toolbar { flex-wrap: nowrap; scroll-margin-top: 72px; }
.toolbar .search-field { flex: 1 1 160px; min-width: 160px; max-width: 340px; }
.filter-select { flex: 0 1 136px; width: auto; min-width: 120px; }
.filter-select.is-wide { flex-basis: 156px; }
.filter-select.is-sort { flex-basis: 150px; }
.filter-clear { flex: none; }
.filter-clear { color: var(--text-2); }
[hidden] { display: none !important; }

/* ---------- Tables ---------- */
.table-card { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th {
  padding-top: 10px; padding-bottom: 10px;
  background: var(--subtle); color: var(--text-3);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  position: relative; /* contains the visually hidden "Actions" label so it never widens the page */
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 100ms ease; }
tbody tr:hover { background: var(--subtle); }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px;
  border-top: 1px solid var(--border); background: var(--subtle);
  color: var(--text-3); font-size: 0.8125rem;
}

.pager { display: flex; align-items: center; gap: 2px; }
.pager .btn-xs { width: 28px; height: 28px; }
.pager .btn-xs[disabled] { opacity: 0.4; cursor: default; pointer-events: none; }
.pager .pg { width: auto; min-width: 28px; padding: 0 6px; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.pager .pg.is-current { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.pg-gap { padding: 0 4px; color: var(--text-3); }

.links-table { table-layout: fixed; }
/* Six columns plus three row actions have to fit a 940 px table without clipping the slug,
   so this table trades its side padding for room. */
.links-table th, .links-table td { padding-left: 12px; padding-right: 12px; }
.links-table td.col-actions { padding-left: 4px; }
.links-table th:nth-child(1) { width: 28%; }
.links-table th:nth-child(2) { width: 17%; }
.links-table th:nth-child(3) { width: 13%; }
.links-table th:nth-child(4) { width: 11%; }
.links-table th:nth-child(5) { width: 128px; }
.links-table th:nth-child(6) { width: 144px; }

.link-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.link-cell .meta { min-width: 0; flex: 1; }
.host-badge {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: var(--r-md);
  background: hsl(var(--h) 50% var(--badge-bg-l)); color: hsl(var(--h) 55% var(--badge-fg-l));
  font: 600 0.875rem/1 var(--font-display);
}
.slug-domain { color: var(--text-3); font: 500 0.8125rem/1.4 var(--font-code); white-space: nowrap; }
.cell-sub.is-empty { color: var(--text-3); }
.dest-host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.dest-host.is-empty { color: var(--text-3); font-weight: 400; }
.preview-body { display: grid; gap: 10px; margin: 12px 0; padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--r-md); }
.preview-tags:empty { display: none; }
.tags { display: flex; gap: 4px; overflow: hidden; }
.tag { display: inline-flex; align-items: center; flex: none; height: 20px; padding: 0 6px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--subtle); color: var(--text-2); font-size: 0.75rem; white-space: nowrap; }
.tag.more { color: var(--text-3); }
button.tag { font-family: inherit; cursor: pointer; }
.tag-btn:hover { border-color: var(--text-3); background: var(--sunken); color: var(--text); }

.slug-line { display: flex; align-items: center; gap: 0; min-width: 0; }
.slug-line .copy { margin-left: 4px; }
.slug-link {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--accent-text); font: 600 0.8125rem/1.4 var(--font-code);
}
.slug-link:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.is-inactive .slug-link { color: var(--text-2); }
.cell-sub { margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 0.8125rem; }
.link-sub { display: flex; align-items: center; gap: 8px; min-width: 0; }
.link-sub .cell-sub { flex: 0 1 auto; min-width: 0; }
.owner-badge {
  width: 20px; height: 20px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: hsl(var(--h) 50% var(--badge-bg-l)); color: hsl(var(--h) 55% var(--badge-fg-l));
  font: 600 0.625rem/1 var(--font-display);
}
.dest-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.dest-url { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); font-size: 0.75rem; }
.dest-url.solo { color: var(--text-2); font-size: 0.8125rem; }
a.dest-url:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.visits { display: flex; align-items: center; gap: 10px; }
.visit-bar { width: 48px; height: 4px; flex: none; overflow: hidden; border-radius: 9999px; background: var(--sunken); }
.visit-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.visit-bar.is-warn > span { background: var(--warn); }
.visit-cap { margin-top: 2px; color: var(--text-3); font: 500 0.6875rem/1.3 var(--font-code); }
.visit-count { min-width: 3ch; font: 600 0.8125rem var(--font-code); font-variant-numeric: tabular-nums; text-align: right; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border: 1px solid var(--border-strong); border-radius: 9999px;
  background: var(--panel); color: var(--text-2);
  font-size: 0.75rem; font-weight: 500; white-space: nowrap;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.success { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }
.chip.danger { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.chip.warn { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.chip.info { border-color: var(--info-line); background: var(--info-soft); color: var(--info); }
.chip.plain { padding: 0 8px; background: var(--subtle); border-color: var(--border); }
.chip.plain::before { display: none; }
.chip.mono { font-family: var(--font-code); font-size: 0.75rem; }
.chip.act { padding: 0 8px; border-radius: var(--r-sm); background: var(--subtle); border-color: var(--border); }
.chip.act::before { display: none; }
.chip.act-create { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }
.chip.act-update { border-color: var(--info-line); background: var(--info-soft); color: var(--info); }
.chip.act-delete { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.chip.act-pause { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.chip.act-resume { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Cards, sections ---------- */
.card { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel); padding: 24px; }
.stack { display: grid; gap: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head .muted { font-size: 0.8125rem; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.aside { position: sticky; top: 24px; display: grid; gap: 16px; }
.aside .card { padding: 20px; }
.eyebrow { margin: 0 0 10px; color: var(--text-3); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }

/* ---------- Forms ---------- */
form { display: grid; gap: 20px; }
label { display: grid; align-content: start; gap: 6px; color: var(--text); font-size: 0.8125rem; font-weight: 600; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
input, select, textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--input-border); border-radius: var(--r-md);
  background: var(--panel); color: var(--text);
  font: 400 0.875rem/1.4 var(--font-body);
}
input.with-icon { padding-left: 36px; }
select { appearance: none; padding-right: 36px; background: var(--panel) var(--chevron) no-repeat right 12px center / 16px; cursor: pointer; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:hover, select:hover { border-color: var(--text-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-inline { display: grid; grid-template-columns: minmax(0, 1fr) 180px auto; gap: 12px; align-items: end; }
.key-form { grid-template-columns: minmax(0, 1fr) auto; }
.help { color: var(--text-3); font-size: 0.75rem; font-weight: 400; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 20px; border-top: 1px solid var(--border); }
.form-section { display: grid; gap: 16px; margin-top: 4px; padding-top: 20px; border-top: 1px solid var(--border); }
.form-section h3 { font-size: 0.875rem; }
.form-section .help { margin: 2px 0 0; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--subtle);
  cursor: pointer;
}
.switch-row .copy { display: grid; gap: 2px; min-width: 0; }
.switch-row .copy strong { font-size: 0.8125rem; font-weight: 600; }
.switch-row .copy span { color: var(--text-3); font-size: 0.75rem; font-weight: 400; }
input.switch {
  position: relative; flex: none; width: 40px; height: 24px; padding: 0; appearance: none;
  border: 1px solid var(--text-3); border-radius: 9999px; background: var(--sunken); cursor: pointer;
}
input.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--text-3); transition: transform 140ms ease;
}
input.switch:checked { border-color: var(--accent); background: var(--accent); }
input.switch:checked::after { transform: translateX(16px); border-color: transparent; }
.input-wrap.is-expired input { border-color: var(--danger); }
.input-wrap.is-expired .icon { color: var(--danger); }

.error { min-height: 0; margin: 0; }
.error:empty { display: none; }
.callout {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--danger-line); border-radius: var(--r-md);
  background: var(--danger-soft); color: var(--danger);
  font-size: 0.8125rem; font-weight: 500;
}
.callout.warn { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.callout.info { border-color: var(--info-line); background: var(--info-soft); color: var(--info); }
.callout .icon { margin-top: 1px; }
.error.callout { align-items: center; }

/* ---------- API keys ---------- */
.key-reveal { display: grid; gap: 10px; }
.key-reveal .callout { margin: 0; align-items: center; }
.key-copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.key-name { min-width: 0; }
.key-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

/* ---------- Link preview ---------- */
.short-url {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 14px 16px;
  border: 1px solid var(--accent-line); border-radius: var(--r-md); background: var(--accent-soft);
  font: 500 0.9375rem/1.4 var(--font-code); overflow-wrap: anywhere;
}
.short-url .domain { color: var(--accent-text); font-weight: 600; }
.short-url .slug { color: var(--text); }
.short-url .empty { color: var(--text-3); }
.aside .short-url { margin-bottom: 12px; font-size: 0.875rem; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.mini-stats div { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--subtle); }
.mini-stats span { display: block; color: var(--text-3); font-size: 0.75rem; }
.mini-stats strong { display: block; margin-top: 2px; font: 600 1.125rem/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.cap-usage { display: grid; gap: 6px; margin-top: 12px; }
.cap-usage .meter { margin-bottom: 0; }
.aside-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }

/* ---------- Team ---------- */
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .meta { min-width: 0; line-height: 1.35; }
.person strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.person .cell-sub { margin-top: 0; }

/* ---------- Audit ---------- */
.audit-table .chip.mono { max-width: 100%; }
.audit-table td.when { white-space: nowrap; }
.audit-table td.when span { display: block; }
.audit-detail-row[hidden] { display: none; }
.audit-detail-row td { padding: 0; background: var(--subtle); }
.audit-detail { display: grid; gap: 20px; padding: 20px; }
.audit-meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.audit-meta-grid div { min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel); }
.audit-meta-grid dt { color: var(--text-3); font-size: 0.75rem; }
.audit-meta-grid dd { margin: 2px 0 0; overflow-wrap: anywhere; font-size: 0.8125rem; font-weight: 500; }
.audit-json-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.audit-json-grid section { min-width: 0; }
.audit-json-grid h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 0.8125rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.dot.before { background: var(--danger); }
.dot.after { background: var(--accent); }
pre {
  max-height: 360px; overflow: auto; margin: 0; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel); color: var(--text-2);
  font: 500 0.75rem/1.65 var(--font-code); white-space: pre-wrap; overflow-wrap: anywhere;
}
.toggle .icon { transition: transform 140ms ease; }
.toggle[aria-expanded='true'] .icon { transform: rotate(180deg); }

/* ---------- Empty, loading ---------- */
.empty-state { display: grid; justify-items: center; gap: 4px; padding: 56px 24px; text-align: center; color: var(--text-3); }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--subtle); color: var(--text-3); }
.empty-state strong { color: var(--text); font-size: 0.9375rem; font-weight: 600; }
.empty-state span { max-width: 38ch; }
.empty-state .btn { margin-top: 14px; }

.skeleton { background: var(--sunken); border-radius: var(--r-sm); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
.skel-row { display: flex; align-items: center; gap: 16px; height: 62px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.skel-row:last-child { border-bottom: 0; }
.skel-line { height: 12px; }
.skel-line.l1 { width: 22%; }
.skel-line.l2 { flex: 1; }
.skel-line.l3 { width: 8%; }
.skel-line.l4 { width: 72px; height: 20px; border-radius: 9999px; }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--panel);
  box-shadow: var(--shadow-pop); color: var(--text);
  font-size: 0.8125rem; font-weight: 500; pointer-events: auto;
  animation: toast-in 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast .icon { color: var(--accent-text); }
.toast.error .icon { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast.leave { animation: toast-out 160ms ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

/* ---------- Login ---------- */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--canvas); }
.login-aside {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
  padding: 48px 56px; color: #E9EFEC; background: #0A100D;
}
.login-aside::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 50% at 85% 0%, rgb(52 197 143 / 0.16), transparent 70%),
    linear-gradient(rgb(255 255 255 / 0.035) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgb(255 255 255 / 0.035) 1px, transparent 1px) 0 0 / 44px 44px;
  mask-image: linear-gradient(180deg, #000 30%, transparent 95%);
}
.login-aside > * { position: relative; }
.login-brand { display: flex; align-items: center; gap: 10px; font: 600 1rem var(--font-display); color: #fff; }
.login-brand .brand-mark { background: #34C58F; color: #04251A; }
.login-pitch { max-width: 460px; }
.login-pitch h1 { color: #fff; font-size: clamp(2rem, 3vw, 2.75rem); line-height: 1.08; letter-spacing: -0.035em; }
.login-pitch p { margin: 16px 0 0; color: #B9C4BE; font-size: 1rem; line-height: 1.6; }
.route-demo {
  display: grid; gap: 10px; margin-top: 32px; padding: 14px 16px;
  border: 1px solid rgb(255 255 255 / 0.12); border-radius: var(--r-lg); background: rgb(255 255 255 / 0.04);
  font: 500 0.8125rem/1.4 var(--font-code);
}
.route-demo .row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.route-demo .from { color: #5CD9A9; }
.route-demo .to { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #B9C4BE; }
.route-demo .tag { padding: 1px 7px; border-radius: 9999px; background: rgb(52 197 143 / 0.16); color: #5CD9A9; font-size: 0.6875rem; }
.route-demo .icon { color: #8D9B94; width: 14px; height: 14px; }
.login-points { display: grid; gap: 12px; margin: 28px 0 0; padding: 0; list-style: none; color: #B9C4BE; }
.login-points li { display: flex; align-items: center; gap: 10px; }
.login-points .icon { color: #5CD9A9; width: 16px; height: 16px; }
.login-foot { color: #8D9B94; font-size: 0.75rem; }

.login-main { display: grid; place-items: center; padding: 32px; background: var(--panel); }
.login-card { width: min(380px, 100%); }
.login-card .brand-mark { width: 40px; height: 40px; margin-bottom: 24px; border-radius: 10px; }
.login-card .brand-mark .icon { width: 22px; height: 22px; }
.login-card h1 { font-size: 1.625rem; }
.login-card p { margin: 8px 0 28px; color: var(--text-3); font-size: 0.9375rem; }
.login-card .btn-lg { width: 100%; }
.google-btn .g { width: 18px; height: 18px; flex: none; }
.login-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 20px; color: var(--text-3); font-size: 0.8125rem; }
.login-note .icon { margin-top: 1px; width: 15px; height: 15px; }

/* ---------- Analytics ---------- */
.stats-link { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.stats-link .stats-slug { font: 600 0.875rem/1.4 var(--font-code); color: var(--accent-text); }
.stats-link .stats-slug:hover { text-decoration: underline; text-underline-offset: 3px; }
.stats-link span { color: var(--text-3); }
.stats-toolbar { justify-content: space-between; }
.segmented { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--panel); }
.seg-btn { height: 30px; padding: 0 12px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font: 500 0.8125rem/1 var(--font-body); cursor: pointer; }
.seg-btn:hover { background: var(--sunken); color: var(--text); }
.seg-btn[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.stats-body { display: grid; gap: 16px; margin-bottom: 16px; transition: opacity 120ms ease; }
.stats-body.is-loading { opacity: 0.55; }
.viz-placeholder { min-height: 360px; }
.viz-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.viz-card { padding: 20px; }
.viz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.viz-title { font-size: 0.9375rem; }
.viz-head .help { margin: 2px 0 0; }
.viz-toggle { flex: none; color: var(--text-2); }
.viz-legend { display: flex; gap: 16px; margin: 0 0 8px; padding: 0; list-style: none; color: var(--text-2); font-size: 0.8125rem; }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; border-radius: 2px; }
.viz-swatch.human, .viz-key.human, .bar-seg.human { background: var(--chart-human); }
.viz-swatch.bot, .viz-key.bot, .bar-seg.bot { background: var(--chart-bot); }

.viz-plot { min-height: 200px; }
.viz-chart { display: block; max-width: 100%; touch-action: pan-y; }
.viz-chart:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.viz-chart .grid { stroke: var(--border); stroke-width: 1; }
.viz-chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.viz-chart .tick { fill: var(--text-3); font: 400 11px/1 var(--font-body); }
.viz-chart .peak { fill: var(--text-2); font: 600 11px/1 var(--font-body); }
.viz-chart .bar.human { fill: var(--chart-human); }
.viz-chart .bar.bot { fill: var(--chart-bot); }
.viz-chart .bar-group { transition: opacity 80ms ease; }
.viz-chart.has-active .bar-group:not(.is-active) { opacity: 0.45; }

.viz-tip {
  position: fixed; z-index: 70; min-width: 148px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--panel);
  box-shadow: var(--shadow-pop); pointer-events: none; font-size: 0.8125rem;
}
.tip-date { margin-bottom: 6px; color: var(--text-3); font-size: 0.75rem; }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.tip-row strong { min-width: 3ch; font-variant-numeric: tabular-nums; text-align: right; }
.tip-row span { color: var(--text-2); }
.viz-key { flex: none; width: 12px; height: 3px; border-radius: 2px; }
.tip-foot { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 0.75rem; }

.bar-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.bar-row { display: grid; grid-template-columns: minmax(96px, 36%) minmax(0, 1fr); align-items: center; gap: 12px; min-height: 32px; margin: 0 -8px; padding: 2px 8px; border-radius: var(--r-sm); }
.bar-row:hover, .bar-row:focus-visible { background: var(--subtle); }
.bar-label { overflow: hidden; color: var(--text-2); font-size: 0.8125rem; text-overflow: ellipsis; white-space: nowrap; }
.bar-area { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-fill { display: flex; gap: 2px; height: 10px; width: max(4px, calc((100% - 44px) * var(--w))); }
.bar-seg { min-width: 2px; height: 100%; }
.bar-seg:last-child { border-radius: 0 4px 4px 0; }
.bar-value { flex: none; color: var(--text); font: 600 0.75rem/1 var(--font-code); font-variant-numeric: tabular-nums; }

.viz-table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.viz-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.viz-table th, .viz-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; font-weight: 400; }
.viz-table thead th { position: sticky; top: 0; background: var(--subtle); color: var(--text-3); font-weight: 600; }
.viz-table tbody th { background: transparent; color: var(--text-2); font-size: inherit; letter-spacing: 0; text-transform: none; }
.viz-table tbody tr:last-child th, .viz-table tbody tr:last-child td { border-bottom: 0; }
.viz-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.viz-note { display: grid; gap: 8px; max-width: 80ch; color: var(--text-3); font-size: 0.8125rem; }
.viz-note p { margin: 0; }
.viz-note summary { color: var(--text-2); cursor: pointer; }
.viz-note details p { margin-top: 6px; }
.view-stats { margin-top: 12px; width: 100%; justify-content: center; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .toolbar { flex-wrap: wrap; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .aside { position: static; }
  .aside.first { order: -1; }
  .page { padding: 28px 28px 56px; }
  .audit-table th, .audit-table td { padding-left: 12px; padding-right: 12px; }
  .visit-bar { display: none; }
  .visit-count { text-align: left; }
  .links-table th:nth-child(3), .links-table td:nth-child(3) { display: none; }
  .links-table th:nth-child(1) { width: 36%; }
  .links-table th:nth-child(2) { width: 28%; }
  .links-table th:nth-child(4) { width: 12%; }
  .stat-visual { width: 72px; }
  .audit-table .person { max-width: 210px; }
}

/* Small laptops: the sidebar collapses to an icon rail; labels stay in the DOM for
   screen readers and show as tooltips via title. */
@media (min-width: 901px) and (max-width: 1100px) {
  .app-shell { grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar { width: 68px; padding: 16px 10px 12px; align-items: stretch; }
  .brand { justify-content: center; padding: 6px 0; }
  .brand-text, .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .side-cta, .nav-link { justify-content: center; gap: 0; padding: 0; font-size: 0; }
  .side-cta { height: 40px; margin-bottom: 20px; }
  .nav-link { height: 40px; }
  .user-card { flex-direction: column; gap: 6px; padding: 6px 0; border: 0; background: none; }
  .user-meta { display: none; }
  .audit-table .person { max-width: 150px; }
}

/* Phones and small tablets: panel goes edge to edge, drawer + bottom tabs */
@media (max-width: 900px) {
  .app-shell { display: block; }
  .main-pane { grid-column: auto; padding: 0; }
  .content { border: 0; border-radius: 0; box-shadow: none; min-height: 100vh; }
  .page { padding: 20px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px); }

  .sidebar {
    z-index: 60; width: 280px;
    padding-top: calc(16px + env(safe-area-inset-top));
    background: var(--panel); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform 200ms ease; visibility: hidden;
  }
  .sidebar.open { transform: none; visibility: visible; box-shadow: var(--shadow-pop); }
  .mobile-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgb(0 0 0 / 0.45); opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
  .mobile-backdrop.open { opacity: 1; pointer-events: auto; }
  .nav-link.active { background: var(--accent-soft); border-color: var(--accent-line); box-shadow: none; }

  .topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    border-bottom: 1px solid var(--border); background: var(--panel);
  }
  .topbar .brand-mark { width: 28px; height: 28px; }
  .topbar .brand-name { font-size: 0.9375rem; }
  .menu-toggle { margin-left: -4px; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border); background: var(--panel);
  }
  .tabbar-link {
    position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-3); font-size: 0.6875rem; font-weight: 500;
  }
  .tabbar-link .icon { width: 21px; height: 21px; }
  .tabbar-link.active { color: var(--accent-text); font-weight: 600; }
  .tabbar-link.active::before { content: ''; position: absolute; top: 0; width: 28px; height: 2px; border-radius: 0 0 3px 3px; background: var(--accent); }

  .page-head { flex-direction: column; align-items: stretch; gap: 16px; margin-bottom: 20px; }
  .page-actions .btn { flex: 1; }
  .form-grid, .audit-meta-grid, .audit-json-grid, .form-inline, .key-copy { grid-template-columns: minmax(0, 1fr); }
  .form-inline .btn { width: 100%; }
  .card { padding: 16px; }

  /* Stats: three compact cards, no charts or notes */
  .stat-strip { gap: 8px; margin-bottom: 20px; }
  .stat { padding: 12px 12px 10px; grid-template-areas: 'label' 'value'; grid-template-columns: minmax(0, 1fr); }
  .stat-label { font-size: 0.75rem; }
  .stat-icon, .stat-visual, .stat-note { display: none; }
  .stat-value { font-size: 1.25rem; margin-top: 4px; }
  .stat-value.is-code { font-size: 0.875rem; line-height: 1.8; }

  input, select, textarea { height: 44px; font-size: 1rem; }
  .btn { height: 44px; }
  .btn-sm { height: 36px; }
  .btn-icon { width: 40px; height: 40px; }
  .btn-xs { width: 32px; height: 32px; }

  .search-field { max-width: none; }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .toolbar .search-field { grid-column: 1 / -1; max-width: none; min-width: 0; }
  .filter-select { width: 100%; min-width: 0; }
  .filter-clear { grid-column: 1 / -1; justify-content: center; }
  .viz-pair { grid-template-columns: minmax(0, 1fr); }
  .viz-card { padding: 16px; }
  .viz-table th, .viz-table td { padding: 8px; }
  .viz-table tbody th { white-space: normal; overflow-wrap: anywhere; }
  .stats-toolbar { display: flex; }
  .seg-btn { height: 36px; }
  .pager .btn-xs { width: 36px; height: 36px; }
  .pager .pg, .pg-gap { display: none; }
  .pager .pg.is-current { display: none; }

  /* Tables become stacked cards */
  .table-scroll { overflow: visible; }
  .table-card table, .table-card tbody { display: block; width: 100%; }
  .table-card thead { display: none; }
  .table-card tbody tr { display: grid; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .table-card tbody tr:last-child { border-bottom: 0; }
  .table-card tbody tr:hover { background: transparent; }
  .table-card td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0; border: 0; }
  .table-card td::before { content: attr(data-label); flex: none; color: var(--text-3); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
  .table-card td[data-label='']::before, .table-card td[colspan]::before { content: none; }
  .table-card td[data-label=''] { justify-content: flex-end; }
  .col-actions { width: auto; }

  /* Link cards: slug + visits, destination, then status and actions */
  /* Visits and the three row actions get their own tracks so the actions don't widen the
     column the visit count sits in and squeeze the slug. */
  .links-table tbody tr { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: 'link link visits' 'dest dest dest' 'tags tags tags' 'status actions actions'; align-items: center; gap: 8px 12px; }
  .links-table td { display: block; }
  .links-table td::before { content: none; }
  .links-table td:nth-child(1) { grid-area: link; }
  .links-table td:nth-child(2) { grid-area: dest; padding-left: 44px; }
  .links-table td:nth-child(3) { grid-area: tags; display: block; padding-left: 44px; }
  .links-table td:nth-child(3).is-empty { display: none; }
  .links-table td:nth-child(4) { grid-area: visits; }
  .links-table td:nth-child(5) { grid-area: status; padding-left: 44px; }
  .links-table td:nth-child(6) { grid-area: actions; justify-self: end; }
  .links-table .visits { justify-content: flex-end; }
  .links-table .visit-cap { text-align: right; }

  /* Team rows: member and role on one line, action below */
  .table-card td:first-child::before { content: none; }
  .team-table tbody tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'member role' 'actions actions'; align-items: center; gap: 10px 12px; }
  .team-table td { display: block; }
  .team-table td::before { content: none; }
  .team-table td:nth-child(1) { grid-area: member; }
  .team-table td:nth-child(2) { grid-area: role; }
  .team-table td:nth-child(3) { grid-area: actions; text-align: right; }

  /* Audit rows: action, target and outcome; actor and details; time */
  .audit-table { min-width: 0; }
  .audit-table tbody tr:not(.audit-detail-row) { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: 'action target outcome' 'actor actor toggle' 'when when when'; align-items: center; gap: 8px 10px; }
  .audit-table td { display: block; }
  .audit-table td::before { content: none; }
  .audit-table td:nth-child(1) { grid-area: when; color: var(--text-3); font-size: 0.75rem; }
  .audit-table td.when span { display: inline; color: inherit; font-size: inherit; }
  .audit-table td.when .cell-sub::before { content: ' · '; }
  .audit-table td:nth-child(2) { grid-area: actor; }
  .audit-table td:nth-child(3) { grid-area: action; }
  .audit-table td:nth-child(4) { grid-area: target; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 0.8125rem; }
  .audit-table td:nth-child(5) { grid-area: outcome; }
  .audit-table td:nth-child(6) { grid-area: toggle; }
  tr.audit-detail-row { display: block; padding: 0; }
  .audit-detail-row td { display: block; }
  .audit-detail { padding: 16px; gap: 16px; }
  .table-card .person { flex: 1; }

  .toast-stack { left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); }

  .login-shell { display: block; }
  .login-aside { display: none; }
  .login-main { min-height: 100vh; padding: 24px 20px; place-items: start center; padding-top: 12vh; }
}

@media (max-width: 480px) {
  .page-head h1 { font-size: 1.5rem; }
}

@media (hover: none) {
  tbody tr:hover { background: transparent; }
}

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

.created-by { margin: 12px 0 0; }
