:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-soft: #6b7280;
  --accent: #b45309;
  --accent-soft: #fef3c7;
  --dark: #1f2937;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --radius: 10px;
  --topbar-h: 56px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(180,83,9,.15);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  background: var(--dark); color: #fff;
  padding: 0 16px; height: 56px;
}
.icon-btn {
  background: none; border: none; color: inherit; font-size: 18px;
  cursor: pointer; padding: 6px 10px; border-radius: 8px; display: none;
}
.icon-btn:hover { background: rgba(255,255,255,.1); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-board {
  width: 26px; height: 26px; border-radius: 6px; overflow: hidden;
  display: grid; grid-template-columns: 1fr 1fr; flex-shrink: 0;
}
.brand-board i { display: block; }
.brand-board i:nth-child(1), .brand-board i:nth-child(4) { background: #f59e0b; }
.brand-board i:nth-child(2), .brand-board i:nth-child(3) { background: #4b5563; }
.brand-text { font-size: 15px; font-weight: 400; letter-spacing: .2px; white-space: nowrap; }
.brand-text b { font-weight: 700; }
.topbar-spacer { flex: 1; }
.auth-area { display: flex; align-items: center; gap: 10px; }
.auth-area .username { font-weight: 600; }
.role-chip {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 20px; background: var(--accent); color: #fff;
}

/* ---------- global search ---------- */
.global-search { margin: 0; }
/* .topbar prefix beats the generic input[type=search] rule below (dark text) */
.topbar .global-search input {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22);
  color: #fff; caret-color: #f59e0b; border-radius: 8px; padding: 6px 12px; width: 230px;
  font: inherit; outline: none; transition: background .12s, border-color .12s, width .15s;
}
.topbar .global-search input::placeholder { color: #9ca3af; }
.topbar .global-search input:focus {
  background: rgba(255,255,255,.16); border-color: #f59e0b; width: 280px;
  color: #fff; box-shadow: none;
}

/* ---------- dev-status dots ---------- */
.st-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 7px; vertical-align: middle; flex-shrink: 0;
}
.st-active { background: #16a34a; }
.st-discontinued { background: #dc2626; }
.st-unknown { background: #e5e7eb; border: 1.5px solid #9ca3af; }
.st-other { background: #f59e0b; }
.legend {
  color: var(--text-soft); font-size: 12.5px;
  display: inline-flex; gap: 5px; align-items: center; white-space: nowrap;
}
.legend .st-dot { margin-right: 2px; }

/* ---------- search results ---------- */
.search-hit {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 9px 6px; border-top: 1px solid var(--border); cursor: pointer;
}
.search-hit:hover { background: #fffbeb; }
.hit-name { font-weight: 600; }
.hero-search { display: flex; gap: 8px; margin-top: 18px; max-width: 540px; position: relative; z-index: 1; }
.hero-search input { flex: 1; }

/* ---------- disclaimer bar ---------- */
.disclaimer-bar {
  background: var(--accent-soft); color: var(--accent);
  border-bottom: 1px solid #f3e3c3;
  padding: 6px 16px; font-size: 12px; line-height: 1.5;
}
.disclaimer-bar b { font-weight: 700; }
.disc-more {
  background: none; border: none; color: var(--accent); font: inherit;
  font-weight: 600; text-decoration: underline; cursor: pointer; padding: 0;
}
.disc-full { display: block; margin-top: 2px; color: #92651c; }
.disc-full[hidden] { display: none; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); min-height: calc(100dvh - var(--topbar-h)); }
.sidebar {
  width: 250px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 10px; position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.nav-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-soft); margin: 16px 10px 6px; }
.nav-section:first-child { margin-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; color: var(--text);
  cursor: pointer; margin-bottom: 1px; font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .count {
  margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-soft);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 20px;
}
.nav-item.active .count { background: #fff; border-color: transparent; color: var(--accent); }
.nav-item .badge {
  margin-left: auto; font-size: 11px; font-weight: 700; color: #fff;
  background: var(--red); padding: 1px 7px; border-radius: 20px;
}

.main { flex: 1; padding: 24px; min-width: 0; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0 0 2px; font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.page-head .sub { color: var(--text-soft); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------- controls ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn.primary:hover { background: #111827; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: #92400e; }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: var(--red-soft); }
.btn.success { color: var(--green); border-color: #bbf7d0; }
.btn.success:hover { background: var(--green-soft); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { border-color: transparent; background: transparent; color: #d1d5db; }
.btn.ghost:hover { background: rgba(255,255,255,.1); color:#fff; }

input[type=text], input[type=password], input[type=search], select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; background: var(--surface); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(180,83,9,.12); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .search { flex: 1; min-width: 220px; max-width: 380px; }
.toolbar .meta { color: var(--text-soft); font-size: 13px; margin-left: auto; }

/* ---------- table ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto;
  max-height: calc(100vh - 230px);
  -webkit-overflow-scrolling: touch;
}
table.data { border-collapse: collapse; width: 100%; min-width: 700px; }
table.data th {
  position: sticky; top: 0; z-index: 2;
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-soft); background: var(--surface-2);
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: #fffbeb; }
table.data tbody tr:last-child td { border-bottom: none; }
td.cell-name { font-weight: 600; white-space: nowrap; }
.cell-soft { color: var(--text-soft); }

.chip {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 1px 8px; border-radius: 20px; white-space: nowrap;
}
.chip.yes { background: var(--green-soft); color: var(--green); }
.chip.no { background: var(--red-soft); color: var(--red); }
.chip.info { background: var(--blue-soft); color: var(--blue); }
.chip.warn { background: var(--accent-soft); color: var(--accent); }
.chip.muted { background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border); }

.status-active { color: var(--green); font-weight: 600; }
.status-discontinued { color: var(--red); }
.status-unknown { color: var(--text-soft); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(17,24,39,.55); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%; max-width: 720px; animation: pop .15s ease-out;
}
.modal.wide { max-width: 920px; }
.modal.narrow { max-width: 420px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; }
.modal-body { padding: 20px; max-height: 65vh; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 14px 14px;
}
.close-x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-soft); padding: 4px 8px; border-radius: 6px; }
.close-x:hover { background: var(--surface-2); }

/* detail view */
.detail-group { margin-bottom: 18px; }
.detail-group h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-soft); margin: 0 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border);
}
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 16px; }
.detail-row { display: flex; flex-direction: column; gap: 1px; padding: 4px 0; }
.detail-row .k { font-size: 11.5px; color: var(--text-soft); font-weight: 500; }
.detail-row .v { font-weight: 500; word-break: break-word; }

/* form */
.form-group { margin-bottom: 18px; }
.form-group h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-soft); margin: 0 0 10px; padding-bottom: 5px; border-bottom: 1px solid var(--border);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.field input, .field select, .field textarea { width: 100%; }
.field.full { grid-column: 1 / -1; }
.form-error { color: var(--red); font-size: 13px; margin-top: 8px; }
.hint { color: var(--text-soft); font-size: 12.5px; }

/* ---------- suggestions ---------- */
.sugg-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.sugg-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.sugg-head .title { font-weight: 700; }
.sugg-head .when { color: var(--text-soft); font-size: 12.5px; margin-left: auto; }
.sugg-note { background: var(--surface-2); border-left: 3px solid var(--border); padding: 8px 12px; border-radius: 0 8px 8px 0; margin: 8px 0; color: var(--text-soft); }
.diff-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.diff-table th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--text-soft); padding: 4px 8px; }
.diff-table td { padding: 4px 8px; border-top: 1px solid var(--border); vertical-align: top; }
.diff-old { color: var(--red); text-decoration: line-through; text-decoration-color: rgba(185,28,28,.4); }
.diff-new { color: var(--green); font-weight: 600; }
.sugg-actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.sugg-actions input { flex: 1; min-width: 180px; }

/* ---------- stats ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.stat-card .num { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.stat-card .lbl { color: var(--text-soft); font-size: 13px; }
.chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.chart-card h3 { margin: 0 0 14px; font-size: 15px; }
.bar-row { display: grid; grid-template-columns: 220px 1fr 44px; gap: 10px; align-items: center; margin-bottom: 7px; }
.bar-row .lbl { font-size: 13px; text-align: right; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #f59e0b, #b45309); border-radius: 6px; min-width: 2px; }
.bar-row .val { font-size: 13px; font-weight: 700; }

/* ---------- users table ---------- */
.users-table select { padding: 4px 8px; }

/* ---------- toast ---------- */
.toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--dark); color: #fff; padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow); font-weight: 500; animation: pop .18s ease-out;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ---------- empty / home ---------- */
.empty { text-align: center; color: var(--text-soft); padding: 60px 20px; }
.home-hero {
  background: linear-gradient(120deg, #1f2937, #374151);
  color: #fff; border-radius: 16px; padding: 36px 32px; margin-bottom: 20px;
  position: relative; overflow: hidden;
}
.home-hero::after {
  content: ''; position: absolute; right: -30px; top: -30px; width: 220px; height: 220px;
  background:
    conic-gradient(#f59e0b 90deg, transparent 90deg 180deg, #f59e0b 180deg 270deg, transparent 270deg);
  background-size: 55px 55px; opacity: .18; transform: rotate(12deg); border-radius: 20px;
}
.home-hero h1 { margin: 0 0 8px; font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.home-hero p { margin: 0; color: #d1d5db; max-width: 640px; }
.cat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; cursor: pointer; color: var(--text);
  transition: transform .12s, box-shadow .12s; display: block;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); text-decoration: none; color: var(--text); }
.cat-card .name { font-weight: 700; margin-bottom: 4px; }
.cat-card .n { color: var(--text-soft); font-size: 13px; }

/* ---------- scrim behind the off-canvas sidebar ---------- */
.sidebar-scrim {
  position: fixed; inset: var(--topbar-h) 0 0; z-index: 55;
  background: rgba(17,24,39,.45);
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.sidebar-scrim.show { opacity: 1; pointer-events: auto; }
body.nav-open { overflow: hidden; }

/* ---------- responsive: tablet ---------- */
@media (max-width: 900px) {
  .icon-btn { display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  .topbar .global-search input { width: 150px; }
  .topbar .global-search input:focus { width: 190px; }
  .legend { display: none; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 60;
    width: 270px; max-width: 82vw;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .sidebar.open { transform: translateX(0); }
  .nav-item { padding: 11px 12px; }
  .main { padding: 16px 12px; }
  .brand-text { font-size: 13px; }
  .bar-row { grid-template-columns: 120px 1fr 40px; }
  .table-wrap { max-height: none; }
}

/* ---------- responsive: phone ---------- */
@media (max-width: 640px) {
  /* Topbar collapses to brand + menu; search moves to its own row below. */
  .topbar { padding: 0 10px; gap: 8px; }
  .brand-board { width: 22px; height: 22px; }
  .brand-text { font-size: 13px; }
  .brand-text b { display: block; font-size: 12px; line-height: 1.15; }
  .topbar-spacer { display: none; }
  .global-search {
    order: 10; flex-basis: 100%;
  }
  .topbar { flex-wrap: wrap; height: auto; padding-bottom: 8px; }
  .topbar .global-search input { width: 100%; font-size: 16px; padding: 9px 12px; }
  .topbar .global-search input:focus { width: 100%; }
  .auth-area { gap: 6px; margin-left: auto; }
  .auth-area .username { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .btn.sm { padding: 8px 10px; }

  .disclaimer-bar { padding: 8px 12px; }
  .main { padding: 14px 10px; }

  .page-head { gap: 10px; margin-bottom: 14px; }
  .page-head h1 { font-size: 19px; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1; justify-content: center; }

  /* Toolbar controls go full width and stack instead of squeezing. */
  .toolbar { gap: 8px; }
  .toolbar .search { min-width: 0; max-width: none; flex-basis: 100%; }
  .toolbar select { flex: 1; min-width: 140px; }
  .toolbar .meta { margin-left: 0; flex-basis: 100%; }
  input[type=text], input[type=password], input[type=search], select, textarea {
    font-size: 16px; /* keeps iOS Safari from zooming in on focus */
    padding: 9px 12px;
  }
  .btn { padding: 9px 14px; }

  /* Buttons and rows get real touch targets. */
  .close-x { min-width: 40px; min-height: 40px; }

  /* ---- data table becomes stacked cards ---- */
  .table-wrap {
    background: transparent; border: none; box-shadow: none;
    border-radius: 0; overflow: visible; max-height: none;
  }
  table.data { min-width: 0; display: block; }
  table.data thead { display: none; }
  table.data tbody { display: block; }
  table.data tbody tr {
    display: block; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 10px 12px; margin-bottom: 10px;
  }
  table.data tbody tr:hover { background: var(--surface); }
  table.data tbody tr:last-child td { border-bottom: none; }
  /* Grid, not flex: the value column is explicitly `minmax(0, 1fr)` so long
     nowrap content (variant chips) wraps inside the cell instead of forcing
     the whole document wider than the viewport. */
  /* Two columns: a fixed label gutter and a `minmax(0, 1fr)` value column.
     The 0 minimum is what lets long nowrap content (variant chips) wrap inside
     the cell instead of forcing the whole document wider than the viewport. */
  table.data td {
    display: grid; grid-template-columns: 38% minmax(0, 1fr);
    gap: 4px 10px; align-items: baseline;
    padding: 4px 0; border-bottom: none; white-space: normal;
    overflow-wrap: anywhere;
  }
  /* data-label is set by the renderer so each cell keeps its column name */
  table.data td::before {
    content: attr(data-label);
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-soft); font-weight: 600;
  }
  /* Cells holding several chips would otherwise make each chip its own grid
     item, stretched to the full column. Contain them in one flex line-box. */
  table.data td.cell-chips {
    align-items: start;
  }
  table.data td.cell-chips .chip-wrap {
    display: flex; flex-wrap: wrap; gap: 4px; min-width: 0;
  }
  table.data td .chip { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
  table.data td:empty { display: none; }
  td.cell-name {
    display: block; white-space: normal; font-size: 15px; font-weight: 700;
    padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
  }
  td.cell-name::before { display: none; }
  /* the name cell keeps its inline status dot, so restore its alignment */
  td.cell-name .st-dot { vertical-align: middle; }
  table.data td.empty { display: block; text-align: center; }
  table.data td.empty::before { display: none; }

  /* ---- modals go near-fullscreen ---- */
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal, .modal.wide, .modal.narrow {
    max-width: none; width: 100%; border-radius: 0;
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column;
  }
  .modal-head { padding: 12px 14px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
  .modal-head h2 { font-size: 16px; }
  .modal-body { padding: 14px; max-height: none; flex: 1; }
  .modal-foot {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    border-radius: 0; flex-wrap: wrap; position: sticky; bottom: 0;
  }
  .modal-foot .btn { flex: 1; justify-content: center; min-width: 120px; }

  .detail-grid, .form-grid, .var-grid { grid-template-columns: 1fr; }
  .var-item { padding: 6px 0; }

  .home-hero { padding: 22px 18px; border-radius: 12px; }
  .home-hero h1 { font-size: 21px; }
  .home-hero::after { display: none; }
  .hero-search { flex-wrap: wrap; }
  .cat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cat-card { padding: 14px; }
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-card .num { font-size: 22px; }
  .chart-card { padding: 14px; }
  .bar-row { grid-template-columns: 1fr; gap: 2px; margin-bottom: 12px; }
  .bar-row .lbl { text-align: left; white-space: normal; }
  .bar-row .val { text-align: left; }

  .sugg-card { padding: 13px; }
  .sugg-head .when { margin-left: 0; flex-basis: 100%; }
  .sugg-actions .btn { flex: 1; justify-content: center; }
  .sugg-actions input { flex-basis: 100%; }

  .toast-root { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); }
  .toast { text-align: center; }

  /* horizontal-scroll containers for the diff tables that stay tabular */
  .diff-table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 380px) {
  .cat-cards, .stat-cards { grid-template-columns: 1fr; }
  table.data td { grid-template-columns: 45% minmax(0, 1fr); }
}

/* Devices without hover (touch) should not keep hover styling stuck after a tap. */
@media (hover: none) {
  .cat-card:hover { transform: none; box-shadow: var(--shadow); }
  table.data tbody tr:hover { background: var(--surface); }
  .search-hit:hover { background: transparent; }
}

/* ---------- variant tags ---------- */
.var-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 14px; }
.var-item { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; padding: 2px 0; }
.var-item input { accent-color: var(--accent); }
a.chip:hover { text-decoration: none; filter: brightness(.93); }

/* category chips acting as buttons in grouped rows */
button.chip-btn { border: 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
button.chip-btn:hover { filter: brightness(.92); }
.hit-match { opacity: .75; }

/* deactivated: admin-only soft-deleted entries */
.st-deactivated { background: #374151; border: 1.5px solid #111827; position: relative; }
