/* BusyBean admin. Chrome in the app's colours; the charts use the data
   palette (blue, then orange) so a series never looks like a button. */
:root {
  color-scheme: light;
  --page: #f6f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --ink: #1d1b20;
  --muted: #67616b;
  --line: #e7e2e8;
  --accent: #6750a4;
  --accent-soft: #eee8fb;
  --accent-ink: #ffffff;
  --series-1: #257de0;
  --series-2: #f47230;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --good: #0a7a1f;
  --good-soft: #e3f4e5;
  --warn: #8a5a00;
  --warn-soft: #fdf1d6;
  --neutral-soft: #eeedf0;
  --danger: #a74444;
  --shadow: 0 1px 2px rgba(20, 16, 24, 0.06), 0 2px 8px rgba(20, 16, 24, 0.04);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #121113;
    --surface: #1c1b1e;
    --surface-2: #232126;
    --ink: #efedf1;
    --muted: #a39ea8;
    --line: #322f36;
    --accent: #b9a6f2;
    --accent-soft: #2c2540;
    --accent-ink: #1a1528;
    --series-1: #338ced;
    --series-2: #e76624;
    --grid: #303030;
    --axis: #474747;
    --good: #53c556;
    --good-soft: #17301b;
    --warn: #f2b84a;
    --warn-soft: #3a2d12;
    --neutral-soft: #2b2930;
    --danger: #ef8a8a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-width: 320px; background: var(--page); color: var(--ink); font-size: 15px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 650; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; }
[hidden] { display: none !important; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* Sign-in */
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px 16px; }
.login { width: min(380px, 100%); padding: 32px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); text-align: center; }
.login img { border-radius: 14px; }
.login h1 { margin: 14px 0 22px; font-size: 22px; }
.login-form { display: grid; gap: 10px; text-align: left; }
.login-form label { font-weight: 600; font-size: 14px; }
.login-form input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.login-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-form button { margin-top: 4px; padding: 11px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 650; cursor: pointer; }
.message { min-height: 1.4em; margin: 0; color: var(--danger); font-size: 14px; }
.hint { margin: 18px 0 0; color: var(--muted); font-size: 12.5px; }

/* Header */
.top { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand img { border-radius: 7px; }
.brand-sub { color: var(--muted); font-weight: 500; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 7px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 600; }
.tabs a:hover { color: var(--ink); background: var(--neutral-soft); }
.tabs a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.who { display: flex; align-items: center; gap: 10px; margin: 0 0 0 auto; color: var(--muted); font-size: 14px; }
.ghost { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; }
.ghost:hover { background: var(--neutral-soft); }

main { max-width: 1240px; margin: 0 auto; padding: 20px 24px 48px; }
/* One column the width of the page: a long line wraps instead of widening it. */
.view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

/* Tiles and panels */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.tile { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.tile-label { color: var(--muted); font-size: 13px; }
.tile-value { margin-top: 2px; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.tile-note { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
a.tile { color: inherit; text-decoration: none; }
a.tile:hover { border-color: var(--accent); }
.panel { padding: 16px 18px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { margin-bottom: 12px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .column.dim { opacity: 0.35; }
.chart .hit { fill: transparent; cursor: default; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch.s1 { background: var(--series-1); }
.swatch.s2 { background: var(--series-2); }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; align-items: center; gap: 10px; padding: 2px 4px; border-radius: 6px; font-size: 13.5px; color: inherit; text-decoration: none; }
a.bar-row:hover, .bar-row:hover { background: var(--neutral-soft); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar { height: 14px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--series-1); }
.bar-value { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
details.table-view { margin-top: 10px; color: var(--muted); font-size: 13px; }
details.table-view summary { cursor: pointer; }
details.table-view table { margin-top: 8px; }
.tooltip { position: fixed; z-index: 2000; padding: 8px 10px; background: var(--ink); color: var(--page); border-radius: 8px; font-size: 12.5px; line-height: 1.4; pointer-events: none; max-width: 260px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18); }
.tooltip b { font-weight: 650; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input, .filters select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); min-width: 0; }
.filters input[name="q"] { flex: 1 1 220px; }
.filters input[name="source"] { flex: 0 1 200px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-left: auto; }
.segmented button { padding: 5px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.states { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip .count { font-variant-numeric: tabular-nums; font-weight: 500; }
.venue-filter { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--accent-soft); border-radius: 10px; font-size: 14px; }
.venue-filter button { margin-left: auto; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* Feed */
.feed { display: grid; gap: 10px; }
.card { display: grid; gap: 6px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.card-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.card-title { min-width: 0; overflow-wrap: anywhere; padding: 0; border: 0; background: none; color: var(--ink); font-weight: 650; font-size: 15.5px; text-align: left; cursor: pointer; }
.card-title:hover { color: var(--accent); text-decoration: underline; }
.card-line { color: var(--muted); font-size: 13.5px; }
.card-when { color: var(--ink); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { padding: 2px 8px; border-radius: 999px; background: var(--neutral-soft); font-size: 12px; color: var(--muted); }
.sources { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; }
.sources a { color: var(--muted); }
.sources a:hover { color: var(--accent); }
.badge { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warning { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: var(--neutral-soft); color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; }
.error { padding: 12px 14px; color: var(--danger); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 14px; }
.pager button { padding: 7px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; }
.pager button:disabled { opacity: 0.45; cursor: default; }

/* Maps */
.map-wrap { display: grid; gap: 8px; }
.map { height: min(70vh, 680px); min-height: 380px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.map-note { margin: 0; color: var(--muted); font-size: 13px; }
.leaflet-container { font: inherit; }
.popup { display: grid; gap: 4px; min-width: 200px; font-size: 13.5px; }
.popup b { font-size: 14px; }
.popup button { justify-self: start; margin-top: 6px; padding: 5px 10px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-tooltip { background: var(--surface); color: var(--ink); border-color: var(--line); font-size: 12.5px; }
.leaflet-tooltip-top::before { border-top-color: var(--surface); }
.map-tip { display: grid; gap: 1px; }
@media (prefers-color-scheme: dark) {
  /* OpenStreetMap draws light tiles only; dim them so the points stay readable. */
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9); }
  .leaflet-container { background: #1f1f22; }
}

/* Subscriptions */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
table.wide { min-width: 1120px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }

/* Card detail */
dialog { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10, 8, 12, 0.45); }
.detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 20px 22px 22px; }
.detail-head { display: flex; gap: 12px; align-items: flex-start; }
.detail-head > div { display: grid; gap: 6px; justify-items: start; flex: 1 1 auto; min-width: 0; }
.detail-head h2 { font-size: 19px; overflow-wrap: anywhere; }
.detail-head .ghost { flex: none; margin-left: auto; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.description { white-space: pre-wrap; font-size: 14px; padding: 12px 14px; background: var(--surface-2); border-radius: 10px; max-height: 320px; overflow: auto; }
.card-id { color: var(--muted); font-size: 12px; word-break: break-all; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 8px 14px; padding: 10px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .brand-sub { display: none; }
  main { padding: 16px 16px 40px; }
  .filters > input, .filters > select { flex: 1 1 140px; }
  .segmented { margin-left: 0; }
  .two { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px 13px; }
  .tile-value { font-size: 24px; }
  .panel { padding: 14px 14px 16px; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: 4px; }
}
