/* The admin panel in the app's own look (webapp/app.css): true black, elevation by lightness alone, colour only
   on data, the primary button inverted. No motion beyond a press. */

:root,
:root[data-theme="dark"] {
  --ground: #000000;
  --surface: #111111;
  --raised: #2a2a2a;
  --press: #1c1c1c;
  --rule: #1a1a1a;
  --text: #ffffff;
  --muted: #b4b4b4;
  --faint: #949494;
  --accent: #4da3ff;
  --primary-bg: #ffffff;
  --primary-ink: #000000;
  --bar: #262626;
  --halo: rgba(32, 72, 190, 0.45);
  --red: #ff453a;
  --green: #30d158;
  --yellow: #ffd60a;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --ground: #ffffff;
  --surface: #f4f4f5;
  --raised: #e6e6e9;
  --press: #ececef;
  --rule: #ededf0;
  --text: #111111;
  --muted: #55595f;
  --faint: #6b6b6b;
  --accent: #1f6feb;
  --primary-bg: #111111;
  --primary-ink: #ffffff;
  --bar: #e6e6e9;
  --halo: rgba(29, 78, 216, 0.16);
  --red: #e5484d;
  --green: #12b347;
  --yellow: #c99400;
  color-scheme: light;
}
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius-card: 20px;
  --radius-small: 14px;
  --margin: 16px;
  --top-inset: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --bottom-inset: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--ground); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; text-size-adjust: 100%;
}
html { overflow-x: clip; }
body { min-height: 100vh; overflow-x: clip; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(110vmax 80vmax at -18% -22%, var(--halo), transparent 55%);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
svg { display: block; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 0; height: 0; }

#app {
  position: relative; z-index: 1; max-width: 640px; margin: 0 auto;
  padding: calc(var(--top-inset) + 16px) var(--margin) calc(96px + var(--bottom-inset));
}

/* ---------- headings ---------- */
.view-title { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.view-sub { margin-top: 4px; color: var(--faint); font-size: 13px; }
.label { margin: 26px 4px 10px; font-size: 13px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; }
.label:first-child { margin-top: 0; }
.hint { margin: 8px 4px 0; font-size: 13px; color: var(--faint); }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; color: var(--accent); font-size: 15px; }

/* ---------- cards and numbers ---------- */
.card { margin-top: 12px; padding: 16px; border-radius: var(--radius-card); background: var(--surface); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.kpis.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { padding: 14px 14px 12px; border-radius: var(--radius-small); background: var(--surface); min-width: 0; }
.kpi b { display: block; font-size: 24px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi span { display: block; margin-top: 3px; font-size: 12px; color: var(--faint); line-height: 1.3; }
.kpi.alert b { color: var(--red); }
.kpi.button { display: flex; flex-direction: column; justify-content: flex-start; text-align: left; }
.kpi.button:active { background: var(--press); }

.chart { margin-top: 10px; }
.chart svg { width: 100%; height: auto; }
.chart .axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--faint); }
.legend { display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--faint); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.rows { list-style: none; }
.rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 8px 0; }
.rows li + li { border-top: 1px solid var(--rule); }
.rows .name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows .val { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rows .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--bar); overflow: hidden; }
.rows .bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }

/* ---------- lists of people and clubs ---------- */
.list { list-style: none; margin-top: 12px; border-radius: var(--radius-card); background: var(--surface); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--ground); }
.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; min-width: 0; }
button.item:active, .item.tap:active { background: var(--press); }
.item-text { flex: 1; min-width: 0; }
.item-text b { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-text span { display: block; font-size: 13px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-side { flex: none; font-size: 12px; color: var(--faint); text-align: right; }
.avatar {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; overflow: hidden;
  background: var(--raised); color: var(--muted); font-size: 15px; font-weight: 600;
}
.avatar.big { width: 72px; height: 72px; font-size: 24px; }
.avatar.club { border-radius: 12px; }
.avatar.big.club { border-radius: 20px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; vertical-align: 1px;
  font-size: 11px; font-weight: 600; background: var(--raised); color: var(--muted);
}
.tag.red { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.tag.yellow { background: color-mix(in srgb, var(--yellow) 20%, transparent); color: var(--yellow); }
.tag.blue { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.tag.green { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }

/* ---------- controls ---------- */
.search { display: block; width: 100%; margin-top: 14px; padding: 12px 14px; border: 0; border-radius: var(--radius-small); background: var(--surface); }
.chips { display: flex; gap: 6px; margin: 12px calc(var(--margin) * -1) 0; padding: 0 var(--margin); overflow-x: auto; }
.chip { flex: none; padding: 7px 12px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-ink); }
.selects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
select, input[type="date"], input[type="datetime-local"], input[type="text"], textarea {
  width: 100%; min-width: 0; padding: 10px 12px; border: 0; border-radius: 12px; background: var(--surface); appearance: none;
}
.sheet select, .sheet input, .sheet textarea { background: var(--raised); }
textarea { resize: vertical; min-height: 84px; line-height: 1.4; }
.field { margin-top: 12px; }
.field > span { display: block; margin: 0 4px 6px; font-size: 13px; color: var(--faint); }
.row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 0; }

.btn {
  display: block; width: 100%; margin-top: 12px; padding: 13px 16px; border-radius: var(--radius-small);
  background: var(--primary-bg); color: var(--primary-ink); font-weight: 600; text-align: center;
}
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.secondary { background: var(--raised); color: var(--text); }
.btn.danger { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.btn.small { display: inline-block; width: auto; margin-top: 0; padding: 7px 12px; border-radius: 999px; font-size: 13px; }
.row .btn { margin-top: 0; }
.link { color: var(--accent); font-size: 14px; }
.link.danger { color: var(--red); }
.more { display: block; width: 100%; margin-top: 12px; padding: 12px; color: var(--accent); font-weight: 500; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 13px 14px; text-align: left; }
.toggle small { display: block; font-size: 12px; color: var(--faint); }
.switch { flex: none; position: relative; width: 46px; height: 28px; border-radius: 14px; background: var(--raised); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
[aria-checked="true"] .switch { background: var(--green); }
[aria-checked="true"] .switch::after { left: 21px; }

/* ---------- posts, reports, messages ---------- */
.entry { padding: 14px; }
.entry-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.entry-head .avatar { width: 34px; height: 34px; font-size: 13px; }
.entry-who { flex: 1; min-width: 0; font-size: 13px; color: var(--faint); }
.entry-who b { display: block; color: var(--text); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-body { margin-top: 10px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-body.quote { padding: 10px 12px; border-radius: 12px; background: var(--raised); color: var(--muted); }
.entry-photo { display: block; margin-top: 10px; max-width: 100%; max-height: 240px; border-radius: 12px; }
.entry-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--faint); }
.entry-foot .grow { flex: 1; }
.entry-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.reply { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--accent); border-radius: 0 12px 12px 0; background: var(--raised); font-size: 14px; }
.reply small { display: block; color: var(--faint); font-size: 12px; }
.details { list-style: none; margin-top: 8px; font-size: 12px; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.heat { display: grid; grid-template-columns: repeat(30, 1fr); gap: 3px; margin-top: 10px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--bar); }
.heat i.on { background: var(--accent); }

.facts { list-style: none; }
.facts li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 14px; }
.facts li + li { border-top: 1px solid var(--rule); }
.facts li span { color: var(--faint); }
.facts li b { font-weight: 500; text-align: right; overflow-wrap: anywhere; }

.note { margin-top: 14px; padding: 16px; border-radius: var(--radius-card); background: var(--surface); color: var(--faint); font-size: 14px; }
.note strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 15px; }
.center { display: grid; place-items: center; min-height: 70vh; text-align: center; color: var(--faint); }
.center strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 18px; }
.err { margin-top: 8px; color: var(--red); font-size: 13px; }
.ok { margin-top: 8px; color: var(--green); font-size: 13px; }
.sk { display: block; height: 64px; margin-top: 10px; border-radius: var(--radius-small); background: var(--surface); }

/* ---------- the tab bar and the sheet ---------- */
.tabbar {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-inset) + 12px);
  display: flex; gap: 2px; padding: 5px; width: min(calc(100% - 24px), 520px);
  border-radius: 24px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border: 1px solid var(--rule);
}
.tabbar[hidden] { display: none; }
.tabbar button {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 6px;
  border-radius: 19px; color: var(--faint); font-size: 11px; font-weight: 500;
}
.tabbar button[aria-current="page"] { background: var(--raised); color: var(--text); }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dot { position: absolute; top: 6px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet[hidden] { display: none; }
.sheet-back { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; max-height: calc(100% - var(--top-inset) - 24px);
  overflow-y: auto; overscroll-behavior: contain; border-radius: 24px 24px 0 0; background: var(--surface);
  padding: 20px var(--margin) calc(24px + var(--bottom-inset));
}
.sheet-x { position: sticky; top: 0; float: right; z-index: 2; width: 32px; height: 32px; margin: -6px -4px 0 0; border-radius: 50%; background: var(--raised); color: var(--muted); font-size: 20px; line-height: 1; }
.sheet .card, .sheet .list, .sheet .kpi, .sheet .note { background: var(--ground); }
.sheet .list > li + li { border-top-color: var(--surface); }
.sheet .entry-body.quote, .sheet .reply { background: var(--surface); }
.hero { display: flex; align-items: center; gap: 14px; padding-right: 36px; }
.hero h2 { font-size: 20px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.hero p { margin-top: 2px; font-size: 13px; color: var(--faint); }
.status { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-small); font-size: 14px; }
.status.red { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.status.yellow { background: color-mix(in srgb, var(--yellow) 16%, transparent); color: var(--yellow); }
.status b { display: block; }

@media (max-width: 360px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .selects { grid-template-columns: 1fr; }
}
