:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef1ef;
  --text: #17201b;
  --muted: #5d6b63;
  --border: #dce2de;
  --brand: #0f7a55;
  --brand-ink: #ffffff;
  --brand-soft: #e1f3eb;
  --danger: #c0352b;
  --danger-soft: #fbe7e5;
  --warn: #9a6200;
  --warn-soft: #fdf1dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #1f2824;
    --text: #e6ece8;
    --muted: #94a39a;
    --border: #2a3530;
    --brand: #34b884;
    --brand-ink: #062015;
    --brand-soft: #173628;
    --danger: #f0776c;
    --danger-soft: #3a1e1b;
    --warn: #e8b55a;
    --warn-soft: #3a2e17;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
main.wide { max-width: 960px; }

header.bar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
header.bar h1 { font-size: 17px; margin: 0; }
header.bar .sub { font-size: 13px; color: var(--muted); }

h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}

label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
input, select {
  width: 100%; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; min-height: 48px;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 22px; min-height: 22px; height: 22px; }

button, .btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; cursor: pointer;
  min-height: 48px; padding: 0 18px; background: var(--brand); color: var(--brand-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
button:disabled { opacity: .55; cursor: default; }
button.secondary { background: var(--surface-2); color: var(--text); }
button.ghost { background: transparent; color: var(--muted); padding: 0 8px; min-height: 40px; }
button.danger { background: var(--danger-soft); color: var(--danger); }
button.block { width: 100%; margin-top: 16px; }
button.small { min-height: 36px; padding: 0 12px; font-size: 14px; }

.big-action { width: 100%; min-height: 72px; font-size: 20px; border-radius: 16px; margin-top: 16px; }

.msg { border-radius: 10px; padding: 12px 14px; margin-top: 12px; font-size: 15px; white-space: pre-line; }
.msg.ok { background: var(--brand-soft); color: var(--brand); }
.msg.err { background: var(--danger-soft); color: var(--danger); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg:empty { display: none; }

.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.pill {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.present { background: var(--brand-soft); color: var(--brand); }
.pill.absent { background: var(--danger-soft); color: var(--danger); }
.pill.done { background: var(--surface-2); color: var(--text); }

.status-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.status-big { font-size: 22px; font-weight: 700; margin: 4px 0 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; margin-top: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.map { height: 240px; border-radius: 12px; overflow: hidden; margin-top: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.map.tall { height: 320px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list .title { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

.tabs {
  display: flex; gap: 4px; overflow-x: auto; padding: 4px; margin-bottom: 16px;
  background: var(--surface-2); border-radius: 12px; scrollbar-width: none;
}
.tabs button { flex: 1; background: transparent; color: var(--muted); min-height: 42px; white-space: nowrap; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; border-top: 0; }
td.num, th.num { text-align: right; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: 0; border-radius: 18px;
  padding: 0; background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { padding: 18px; }
dialog h3 { margin: 0 0 4px; }

.auth-wrap { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; max-width: 420px; margin: 0 auto; }
.logo { width: 56px; height: 56px; border-radius: 16px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; margin-bottom: 16px; }
.auth-wrap h1 { font-size: 26px; margin: 0 0 4px; }

.hidden { display: none !important; }
.spinner { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.assigned {
  display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 14px;
  background: var(--brand-soft); border-radius: 12px; color: var(--text);
}
.assigned > svg { color: var(--brand); flex: 0 0 auto; }
.assigned > div { flex: 1; min-width: 0; }
.assigned .title { font-size: 17px; font-weight: 700; }
.maps-link {
  flex: 0 0 auto; font-size: 14px; font-weight: 600; color: var(--brand); text-decoration: none;
  padding: 8px 12px; border-radius: 999px; border: 1px solid currentColor;
}

.progress-num { font-size: 28px; font-variant-numeric: tabular-nums; }
.progress { height: 10px; border-radius: 999px; background: var(--danger-soft); overflow: hidden; margin: 12px 0 8px; }
.progress > div { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .4s; }
