:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #14213d;
  --muted: #6b7280;
  --line: #e3e7ee;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --warn: #b45309;
  --bad: #b91c1c;
  --later: #eef0f4;
  --shadow: 0 1px 2px rgba(20, 33, 61, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1522;
    --card: #182133;
    --text: #e8edf6;
    --muted: #9aa5b8;
    --line: #2a3550;
    --accent: #4f7cff;
    --later: #1f2a40;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
header .who { flex: 1; min-width: 0; }
#who-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#who-role { font-size: 13px; }
main { max-width: 640px; margin: 0 auto; padding: 16px; padding-bottom: 48px; }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
a { color: var(--accent); }

button, .btn {
  font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 12px 14px; min-height: 48px;
  box-shadow: var(--shadow); text-align: left; text-decoration: none;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.icon { min-height: 40px; width: 40px; padding: 0; font-size: 20px; box-shadow: none; }
button.small { min-height: 40px; padding: 6px 12px; font-size: 14px; box-shadow: none; }
button:disabled { opacity: .55; cursor: default; }
button.later { background: var(--later); color: var(--muted); box-shadow: none; }
button.later small { display: block; font-size: 12px; }

.menu { display: grid; gap: 8px; }
.menu .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.menu button, .menu .btn { flex-direction: column; text-align: center; }
.list { display: grid; gap: 8px; margin: 8px 0; }
.list button { justify-content: flex-start; text-align: left; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; box-shadow: var(--shadow); overflow-wrap: anywhere;
}
.card + .card { margin-top: 8px; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }

.note { background: var(--later); border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.error { color: var(--bad); }

form.inline { display: flex; gap: 8px; margin: 8px 0; }
input, select {
  font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-height: 48px; width: 100%;
}
form.inline input { flex: 1; }
form.stack { display: grid; gap: 10px; }
label { font-size: 14px; color: var(--muted); display: grid; gap: 4px; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); }
label.check input { width: 22px; height: 22px; min-height: 0; }

/* Пін-код */
.pin-box { max-width: 320px; margin: 24px auto; text-align: center; }
.dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.dots span.on { background: var(--text); border-color: var(--text); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { font-size: 22px; min-height: 60px; justify-content: center; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 608px; margin: 0 auto; background: var(--text); color: var(--bg);
  border-radius: 12px; padding: 12px 14px; z-index: 5;
}
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; z-index: 9; }
.viewer img { max-width: 100%; max-height: 100%; }
