/* Armenia Proptech — design tokens & base styles
   See web/DESIGN.md for the full inventory. */

:root {
  /* --- Light palette (default) --- */
  --bg: #f6f7f9;
  --bg-raised: #ffffff;
  --bg-sunken: #eef0f3;
  --border: #dde1e6;
  --border-strong: #c3c9d1;
  --text: #14181f;
  --text-muted: #565f6d;
  --text-faint: #8790a0;
  --accent: #1f5eff;
  --accent-contrast: #ffffff;
  --accent-muted: #e8edff;
  --positive: #157f4a;
  --positive-bg: #e5f6ec;
  --negative: #c0293a;
  --negative-bg: #fbe9ea;
  --warning: #a15c00;
  --warning-bg: #fdf1de;

  /* series colours: kept distinct from status colours so they never carry
     accidental "good/bad" meaning */
  --series-amd: #1f5eff;
  --series-usd: #d1791a;
  --series-3: #7a4de0;
  --series-4: #0f9ea6;
  --series-5: #c0293a;

  --shadow-sm: 0 1px 2px rgba(20, 24, 31, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 24, 31, 0.08);
  --shadow-lg: 0 12px 32px rgba(20, 24, 31, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;

  --focus-ring: 0 0 0 3px rgba(31, 94, 255, 0.35);
  --transition: 150ms ease;
  color-scheme: light;
}

/* System dark preference, only when the user hasn't explicitly chosen light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --bg-raised: #151b23;
    --bg-sunken: #0a0e13;
    --border: #262e38;
    --border-strong: #3a4451;
    --text: #eaedf2;
    --text-muted: #a3adbb;
    --text-faint: #6b7585;
    --accent: #5b8dff;
    --accent-contrast: #071022;
    --accent-muted: #17244a;
    --positive: #3ecf8e;
    --positive-bg: #0f2b21;
    --negative: #ff6b6b;
    --negative-bg: #33161a;
    --warning: #e3a53d;
    --warning-bg: #33280f;
    --series-amd: #5b8dff;
    --series-usd: #f0a94e;
    --series-3: #a78bfa;
    --series-4: #38c9d1;
    --series-5: #ff6b6b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

/* Explicit dark toggle wins regardless of system preference */
:root[data-theme="dark"] {
  --bg: #0d1117;
  --bg-raised: #151b23;
  --bg-sunken: #0a0e13;
  --border: #262e38;
  --border-strong: #3a4451;
  --text: #eaedf2;
  --text-muted: #a3adbb;
  --text-faint: #6b7585;
  --accent: #5b8dff;
  --accent-contrast: #071022;
  --accent-muted: #17244a;
  --positive: #3ecf8e;
  --positive-bg: #0f2b21;
  --negative: #ff6b6b;
  --negative-bg: #33161a;
  --warning: #e3a53d;
  --warning-bg: #33280f;
  --series-amd: #5b8dff;
  --series-usd: #f0a94e;
  --series-3: #a78bfa;
  --series-4: #38c9d1;
  --series-5: #ff6b6b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0 0 var(--space-2); font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { margin: 0 0 var(--space-3); color: var(--text-muted); }

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

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

button, select, input {
  font: inherit;
  color: inherit;
}

/* --- Layout shell --- */
.app-shell { display: flex; min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: var(--text-lg); margin-right: auto; white-space: nowrap; }
.brand small { display: block; font-weight: 500; font-size: var(--text-xs); color: var(--text-faint); }

.nav {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.nav a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
}
.nav a:hover { background: var(--bg-sunken); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-muted); color: var(--accent); }
.nav a.disabled { pointer-events: none; opacity: 0.45; }
.nav .soon { font-size: 10px; vertical-align: super; }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: var(--radius-md);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--border-strong); }

.lang-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex: none;
}
.lang-btn {
  border: none;
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: var(--text-xs, 11px);
  font-weight: 600;
  padding: 0 10px;
  height: 36px;
  cursor: pointer;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--border); }
.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: var(--accent-muted); color: var(--accent); }

.menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: var(--radius-md);
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  cursor: pointer;
}

main.page {
  flex: 1;
  padding: var(--space-5);
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
}

/* --- Filter bar --- */
.filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 130px; }
.field label { font-size: var(--text-xs); color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.field select, .field input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text);
  min-height: 40px;
}
.presets { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 999px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  cursor: pointer;
  min-height: 36px;
}
.chip[aria-pressed="true"] { background: var(--accent-muted); color: var(--accent); border-color: var(--accent); font-weight: 600; }

.granularity { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.granularity button {
  border: none; background: var(--bg-sunken); padding: var(--space-2) var(--space-3);
  cursor: pointer; min-height: 40px; border-right: 1px solid var(--border);
  color: var(--text-muted); font-weight: 600; font-size: var(--text-sm);
}
.granularity button:last-child { border-right: none; }
.granularity button[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }

/* --- KPI tiles --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.kpi-tile {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  min-width: 0; /* let grid items shrink below their content's intrinsic width
                   instead of overflowing — matters for longer Armenian labels */
}
.kpi-label { font-size: var(--text-xs); color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: var(--space-1); overflow-wrap: break-word; }
.kpi-value { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; overflow-wrap: break-word; }
.kpi-delta { font-size: var(--text-sm); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; margin-top: var(--space-1); }
.kpi-delta.up { color: var(--positive); }
.kpi-delta.down { color: var(--negative); }
.kpi-delta.flat { color: var(--text-faint); }

/* --- Chart blocks --- */
.block {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.block-head {
  display: flex;
  /* NOT space-between: the head holds three children (title group, share
     button, view toggle), so space-between stranded the share button in
     the middle of the header. Push the title group out instead and let
     both controls sit together on the right. */
  justify-content: flex-start;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.block-head > :first-child { margin-right: auto; }
.block-title { font-size: var(--text-lg); font-weight: 650; }
.block-caption { font-size: var(--text-xs); color: var(--text-faint); margin-top: 2px; }
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; height: fit-content; }
.view-toggle button {
  border: none; background: var(--bg-sunken); padding: var(--space-2) var(--space-3);
  cursor: pointer; border-right: 1px solid var(--border); font-size: var(--text-sm); font-weight: 600; color: var(--text-muted);
}
.view-toggle button:last-child { border-right: none; }
.view-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }

/* --- Share menu --- */
.share-wrap { position: relative; }
.share-btn {
  border: 1px solid var(--border); background: var(--bg-sunken); border-radius: var(--radius-sm);
  width: 36px; height: 36px; cursor: pointer; font-size: var(--text-base); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.share-btn:hover { color: var(--accent); border-color: var(--accent); }
.share-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); min-width: 180px; padding: var(--space-1);
}
.share-menu button {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: var(--space-2) var(--space-3); cursor: pointer; font-size: var(--text-sm);
  color: var(--text); border-radius: var(--radius-sm); min-height: 36px;
}
.share-menu button:hover { background: var(--bg-sunken); }
.share-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: var(--accent-contrast); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: 600; z-index: 100;
  box-shadow: var(--shadow-sm);
}

/* --- Rent / sale index pair --- */
.index-pair {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4);
  margin-bottom: var(--space-5);
}
@media (max-width: 720px) {
  .index-pair { grid-template-columns: 1fr; }
  /* The tagline is a single 339px nowrap line, so on a phone it cannot
     shrink and pushed the whole topbar to 554px — the page then scrolled
     sideways on every route. The brand name alone is enough here. */
  .brand small { display: none; }
}
.index-block {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-4); box-shadow: var(--shadow-sm);
  display: flex; gap: var(--space-5); flex-wrap: wrap; align-items: center;
}
.index-pair .index-block { margin-bottom: 0; }
.index-main { flex: 1 1 260px; min-width: 0; }
.index-name { font-size: var(--text-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-faint); }
.index-value { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin: var(--space-1) 0; }
.index-meta { font-size: var(--text-sm); color: var(--text-muted); display: flex; gap: var(--space-3); flex-wrap: wrap; }
.index-disclaimer { font-size: var(--text-xs); color: var(--text-faint); margin-top: var(--space-2); max-width: 60ch; }
.index-spark { flex: 1 1 220px; min-width: 200px; max-width: 360px; height: 100px; position: relative; }

.tabstrip { display: flex; gap: var(--space-1); margin-bottom: var(--space-3); flex-wrap: wrap; }
.tabstrip button {
  border: 1px solid var(--border); background: var(--bg-sunken); border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3); cursor: pointer; font-size: var(--text-sm); font-weight: 600; color: var(--text-muted);
  min-height: 36px;
}
.tabstrip button[aria-pressed="true"] { background: var(--accent-muted); color: var(--accent); border-color: var(--accent); }

.chart-wrap { position: relative; height: 320px; }
.chart-wrap canvas { max-width: 100%; }

.legend { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); font-size: var(--text-sm); }
.legend-item { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; color: var(--text-muted); }
.legend-item[aria-pressed="false"] { opacity: 0.4; text-decoration: line-through; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }
.stat-row .kpi-tile { padding: var(--space-3); }

/* --- States --- */
.state-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-4);
  color: var(--text-faint);
  text-align: center;
  min-height: 200px;
}
.state-msg .icon { font-size: 28px; }
.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border) 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* --- Tables --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--text-sm); min-width: 640px; }
table.data th, table.data td { padding: var(--space-2) var(--space-3); text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { background: var(--bg-sunken); color: var(--text-faint); font-weight: 600; text-transform: uppercase; font-size: var(--text-xs); letter-spacing: 0.03em; position: sticky; top: 0; cursor: pointer; }
table.data th[aria-sort]:after { content: " \2195"; opacity: 0.5; }
table.data th[aria-sort="ascending"]:after { content: " \2191"; opacity: 1; }
table.data th[aria-sort="descending"]:after { content: " \2193"; opacity: 1; }
table.data tbody tr:hover { background: var(--bg-sunken); }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 700;
}
.badge.listam { background: var(--accent-muted); color: var(--accent); }
.badge.telegram { background: var(--warning-bg); color: var(--warning); }
.badge.amd { background: var(--bg-sunken); color: var(--series-amd); font-weight: 700; }
.badge.usd { background: var(--bg-sunken); color: var(--series-usd); font-weight: 700; }

.pagination { display: flex; align-items: center; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-3); font-size: var(--text-sm); flex-wrap: wrap; }
.pagination button {
  border: 1px solid var(--border); background: var(--bg-sunken); border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3); cursor: pointer; min-height: 36px; min-width: 44px;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Card-list fallback for tables on small screens --- */
.card-list { display: none; flex-direction: column; gap: var(--space-2); }
.data-card {
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-raised);
  padding: var(--space-3); display: flex; flex-direction: column; gap: 4px; font-size: var(--text-sm);
}
.data-card .row1 { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.data-card .meta { color: var(--text-muted); font-size: var(--text-xs); }

/* --- Drawer (mobile nav / filters) --- */
.drawer-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 30; }
.drawer-backdrop.open { display: block; }

/* --- Mobile filter summary (compact trigger shown instead of the full
   filterbar below 860px; the filterbar itself becomes a bottom-sheet
   drawer, same open/backdrop convention as the nav drawer above). --- */
.filterbar-summary { display: none; }
.filterbar-summary-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-sm); cursor: pointer;
  color: var(--text); text-align: left; min-height: 48px;
}
.filterbar-summary-text { font-size: var(--text-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filterbar-summary-icon { flex: none; font-size: var(--text-md); color: var(--text-faint); }
.filterbar-actions {
  display: none;
  width: 100%;
  flex-basis: 100%;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.filterbar-actions button {
  flex: 1;
  min-height: 44px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
}
.filterbar-actions .btn-reset { border: 1px solid var(--border); background: var(--bg-sunken); color: var(--text-muted); }
.filterbar-actions .btn-apply { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-contrast); }

footer.site { padding: var(--space-5); text-align: center; color: var(--text-faint); font-size: var(--text-xs); }

/* --- Responsive --- */
@media (max-width: 860px) {
  .nav { display: none; }
  .menu-btn { display: flex; }
  .nav.open {
    display: flex; position: fixed; inset: 0 0 0 auto; width: min(320px, 85vw);
    background: var(--bg-raised); flex-direction: column; padding: var(--space-5); z-index: 40;
    box-shadow: var(--shadow-lg); border-left: 1px solid var(--border);
  }
  main.page { padding: var(--space-3); }
  .filterbar { flex-direction: column; align-items: stretch; }

  /* Larger (pointer: coarse) tap targets on lang/theme controls add width
     the topbar didn't have before; let the brand name shrink/ellipsize
     instead of forcing the header (and the page) wider than the viewport. */
  /* Ellipsis is the safety net, not the plan: at 375px the name needs
     ~150px and only ~133px was left, so "Armenia Proptech" rendered as
     "Armenia Pro…". Drop the size a step on phones so the product name
     fits whole; the ellipsis only ever engages on narrower screens. */
  .brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; font-size: var(--text-md); }
  .topbar { gap: var(--space-2); }

  /* Two 44px language buttons cost 90px of a 375px bar and still left the
     product name clipped to "Armenia Propt…". Show only the language you
     are NOT in — it is the button you would press, it keeps the full 44px
     target, and the page's own text already tells you the current one. */
  .lang-btn.active { display: none; }
  .lang-switch { border-radius: var(--radius-md); }
  /* With three languages the switch shows two buttons on a phone, which
     clipped the product name again. Trim their side padding — the 44px
     touch height is what matters, the width can give. */
  .lang-btn { padding: 0 6px; }
  /* Brand needed 132px and had 125. The 24px side padding was the cheapest
     7px to give back; 16px still satisfies the minimum page gutter. */
  .topbar { padding-inline: var(--space-4); }

  /* The shared filterbar (#filterbar, used on / and /listings — the one
     with 8 stacked fields that pushed all content below the fold) becomes
     a bottom-sheet drawer: hidden by default, shown via .open (same
     open/backdrop convention as .nav.open above), with a compact summary
     button always visible above the fold instead. Other pages' shorter,
     purpose-built filterbars (events, map, cadastre) keep the plain
     stacked layout from the rule above — they don't hide content. */
  .filterbar-summary { display: block; margin-bottom: var(--space-4); }
  #filterbar {
    display: none;
    flex-wrap: nowrap;
    position: fixed; inset: auto 0 0 0; z-index: 40;
    max-height: 85vh; overflow-y: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
    margin-bottom: 0;
  }
  #filterbar.open { display: flex; }
  .filterbar-actions { display: flex; }
  .field { min-width: 0; width: 100%; }
  .table-wrap { display: none; }
  .card-list { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-wrap { height: 260px; }
}

@media (min-width: 861px) {
  .drawer-backdrop { display: none !important; }
}

/* --- Touch tap targets: raise below the 44x44 accessibility minimum on
   coarse-pointer (touch) devices without bulking up the desktop header. --- */
@media (pointer: coarse) {
  /* .menu-btn was left at 36px while its neighbours went to 44 — it opens
     the whole nav, so it is the last control that should be hard to hit. */
  .theme-toggle, .lang-btn, .share-btn, .menu-btn { min-width: 44px; min-height: 44px; }
  .theme-toggle { width: 44px; height: 44px; }
  .share-btn { width: 44px; height: 44px; }
  .chip { min-height: 44px; }
  .filterbar-summary-btn, .filterbar-open-btn { min-height: 48px; }
}

/* Small tables that must stay readable on a phone. Unlike .table-wrap
   (hidden below 860px in favour of a .card-list), this keeps the table
   visible and lets it scroll sideways inside its own box — the page
   itself must never scroll horizontally. */
.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll table.data { width: 100%; }

/* --- Icons ---
   Stroked SVG from the sprite in base.html, inheriting currentColor so
   they follow the theme. Replaced the emoji that used to sit in buttons
   and state blocks: those rendered as colour glyphs, ignored light/dark
   entirely, and looked different on every operating system. */
.icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; flex: none; }
.state-icon { width: 28px; height: 28px; color: var(--text-faint); margin-bottom: var(--space-2); }
.state-msg .state-icon { display: block; margin-inline: auto; }
.spin { animation: apt-spin 900ms linear infinite; }
@keyframes apt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.filterbar-summary-icon .icon { width: 20px; height: 20px; }
