:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Telegram injects --tg-theme-* variables, so the page follows the app's light/dark theme. */
  --bg: var(--tg-theme-secondary-bg-color, #f6f7f9);
  --card: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #17212b);
  --muted: var(--tg-theme-hint-color, #667383);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --field: var(--tg-theme-secondary-bg-color, #eef1f4);
  --error: var(--tg-theme-destructive-text-color, #d93025);
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); }
.page { max-width: 760px; margin: 0 auto; padding: 20px 16px 32px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0 0 8px; font-size: clamp(24px, 7vw, 34px); line-height: 1.1; }
.status { min-height: 22px; margin: 0 0 14px; color: var(--muted); }
.status.error { color: var(--error); }
.muted { color: var(--muted); font-weight: 400; }

.card, .map-card { overflow: hidden; border-radius: 18px; background: var(--card); box-shadow: 0 2px 14px #1c27330f; }
.form { display: grid; gap: 16px; padding: 16px; margin-bottom: 14px; }
.field { display: grid; gap: 7px; min-width: 0; margin: 0; padding: 0; border: 0; }
.label { font-size: 14px; font-weight: 700; }
input {
  width: 100%; min-width: 0; min-height: 44px; padding: 0 12px;
  border: 1px solid transparent; border-radius: 12px;
  color: var(--text); background: var(--field); font: inherit; font-size: 16px;
}
input:focus { outline: none; border-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--error); }
.range { display: flex; align-items: center; gap: 8px; }
.dash { color: var(--muted); }
.field-error { min-height: 0; color: var(--error); font-size: 13px; }
.field-error:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 19px; color: var(--text); background: var(--field); font-weight: 600; }
.chip[aria-pressed="true"] { color: var(--accent-text); background: var(--accent); }

.map-card { position: relative; }
.map-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px 10px; }
#map { height: min(60vh, 480px); min-height: 320px; }
.hint { margin: 0; padding: 10px 16px 0; color: var(--muted); font-size: 13px; }
.map-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px 14px; }
.map-error { display: block; padding: 0 16px 14px; }
.map-error:empty { display: none; }

.actions { position: sticky; bottom: 0; display: flex; padding: 14px 0 calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
button { min-height: 44px; border: 0; border-radius: 12px; padding: 0 16px; font: inherit; font-weight: 700; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
.primary { flex: 1; min-height: 50px; color: var(--accent-text); background: var(--accent); }
.secondary { min-height: 38px; color: var(--text); background: var(--field); font-size: 14px; }
.return { width: 100%; margin-top: 10px; color: var(--accent); background: transparent; }
@media (min-width: 600px) { .page { padding-top: 32px; } }

/* Admin page */
.people { margin-bottom: 18px; }
.people h2 { margin: 0 0 10px; font-size: 17px; }
.people .count { color: var(--muted); font-weight: 400; }
.list { display: grid; gap: 10px; }
.person { display: grid; grid-template-columns: 48px 1fr; gap: 6px 12px; align-items: center; padding: 12px 14px; }
.avatar {
  display: grid; place-items: center; width: 48px; height: 48px; overflow: hidden;
  border-radius: 50%; color: #fff; font-weight: 700; font-size: 17px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-info { min-width: 0; }
.person-name { display: flex; align-items: center; gap: 6px; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.badge { padding: 1px 7px; border-radius: 9px; color: var(--accent-text); background: var(--accent); font-size: 11px; font-weight: 700; }
.person-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 2px; font-size: 14px; }
.person-meta a { color: var(--accent); text-decoration: none; }
.id-chip { min-height: 24px; padding: 0 8px; border-radius: 8px; color: var(--muted); background: var(--field); font-size: 12px; font-weight: 600; font-family: ui-monospace, monospace; }
.person-details { margin-top: 3px; font-size: 13px; }
.person-actions { display: flex; grid-column: 1 / -1; gap: 8px; }
.person-actions button { flex: 1; min-height: 40px; }
.person-actions .primary { min-height: 40px; }
.danger { color: var(--error); }
