:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #1c2321;
  --muted: #5d6a66;
  --line: #dde3e0;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e3f2ef;
  --danger: #b42318;
  --warn-bg: #fff4d6;
  --warn-ink: #7a4b00;
  --yes: #15803d;
  --maybe: #b45309;
  --no: #6b7280;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111615;
    --surface: #1a2120;
    --text: #e8eeec;
    --muted: #9aa8a4;
    --line: #2c3634;
    --brand: #2dd4bf;
    --brand-ink: #062320;
    --brand-soft: #16302c;
    --danger: #f97066;
    --warn-bg: #3a2e10;
    --warn-ink: #fcd98a;
    --yes: #4ade80;
    --maybe: #fbbf24;
    --no: #9ca3af;
    --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: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.loading { text-align: center; padding: 40vh 0; color: var(--muted); }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who { font-size: 13px; color: var(--muted); }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.public main { padding-bottom: 40px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 9px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600;
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--brand); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.banner { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 15px; }

/* ---------- form ---------- */
.q { margin: 0 0 18px; border: 0; padding: 0; min-width: 0; }
.q > legend, .q > label.lbl { display: block; font-weight: 650; margin-bottom: 8px; padding: 0; }
.q .hint { display: block; font-weight: 400; font-size: 14px; color: var(--muted); margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 9px 14px; min-height: 44px; cursor: pointer; font-size: 16px; text-align: left;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.chips.big .chip { flex: 1; text-align: center; font-size: 18px; padding: 12px 10px; }

input[type=text], input[type=tel], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface);
  padding: 11px 12px; min-height: 46px; font-size: 17px; /* ≥16px stops iPhone zooming in */
}
input:focus, select:focus, textarea:focus, .chip:focus-visible, .btn:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 84px; resize: vertical; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.consent { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; }
.consent input { width: 26px; height: 26px; margin: 0; flex: none; accent-color: var(--brand); }
.privacy { font-size: 14px; color: var(--muted); margin: 10px 2px 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px; min-height: 48px; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); font-weight: 650; font-size: 17px; text-decoration: none;
}
.btn.block { width: 100%; }
.btn.secondary { background: var(--brand-soft); color: var(--text); }
.btn.ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid var(--line); }
.btn.sm { min-height: 38px; padding: 7px 12px; font-size: 15px; }
.btn:disabled { opacity: .55; }
.savebar {
  position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 4;
  padding: 10px 0; background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.public .savebar { bottom: env(safe-area-inset-bottom); }
.lang { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.lang button { border: 0; background: transparent; padding: 5px 11px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--muted); }
.lang button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }

/* ---------- list ---------- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters input[type=search] { grid-column: 1 / -1; }
.filters select { min-height: 42px; font-size: 16px; padding: 8px 10px; }
.item { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.item .top { display: flex; gap: 8px; align-items: baseline; }
.item .name { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 14px; color: var(--muted); margin-top: 2px; }
.badge { font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 999px; border: 1.5px solid currentColor; flex: none; }
.badge.Yes { color: var(--yes); } .badge.Maybe { color: var(--maybe); } .badge.No { color: var(--no); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi b { display: block; font-size: 28px; line-height: 1.1; }
.kpi span { font-size: 14px; color: var(--muted); }
.bar { margin: 8px 0; }
.bar .lab { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.bar .track { height: 8px; background: var(--brand-soft); border-radius: 99px; margin-top: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--brand); border-radius: 99px; }

/* ---------- misc ---------- */
.qr { display: block; width: 100%; max-width: 280px; margin: 10px auto; background: #fff; padding: 10px; border-radius: 10px; }
.user { padding: 10px 0; border-top: 1px solid var(--line); }
.user:first-of-type { border-top: 0; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.thanks { text-align: center; padding: 50px 10px; }
.thanks .big { font-size: 64px; line-height: 1; }
.thanks h2 { font-size: 26px; }
.intro { font-size: 18px; }
.login { max-width: 400px; margin: 10vh auto 0; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 12px; }
.error { color: var(--danger); font-size: 15px; min-height: 1.4em; }
#toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 62px); transform: translateX(-50%) translateY(-12px);
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media print {
  .topbar, .tabs, .noprint { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}
