:root {
  --bg: #f1f3f0; --surface: #ffffff; --fg: #17201b; --muted: #5b6862; --line: #d9dfda;
  --accent: #0e6b4f; --accent-fg: #ffffff; --signal: #d9531e; --soft: #e3eee8; --danger: #b3261e;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101512; --surface: #1a221e; --fg: #e8eee9; --muted: #9aa8a0; --line: #2c3731;
    --soft: #202d27; --danger: #ff8a80; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101512; --surface: #1a221e; --fg: #e8eee9; --muted: #9aa8a0; --line: #2c3731;
  --soft: #202d27; --danger: #ff8a80; color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}
.top {
  position: sticky; top: 0; z-index: 5; background: var(--accent); color: var(--accent-fg);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-left, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
}
.top h1 { margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }
.top p { margin: 0; font-size: 0.8rem; opacity: 0.85; }
.pill { font-size: 0.72rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,0.2); white-space: nowrap; }
main { max-width: 560px; margin: 0 auto; padding: 14px max(14px, env(safe-area-inset-left, 0px)); }
.view { display: flex; flex-direction: column; gap: 14px; }
.view[hidden] { display: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card h2 { margin: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 600; min-width: 0; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; width: 100%; min-width: 0;
}
textarea { resize: vertical; font-size: 0.92rem; line-height: 1.45; }
input[type="color"] { height: 48px; padding: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, label.btn:focus-within {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px;
}
.phone { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }
.btnrow .btn { flex: 1 1 140px; }
.btn {
  font: inherit; font-weight: 600; font-size: 0.95rem; min-height: 48px; padding: 12px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-align: center; width: 100%;
}
.btnrow .btn { width: auto; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.big-btn { min-height: 54px; font-size: 1rem; }
.eta { background: var(--soft); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.eta .big { font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--accent); }
.eta .lbl { font-size: 0.82rem; color: var(--muted); }
.total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 12px; }
.total span { font-weight: 600; }
.total strong { font-size: 1.5rem; color: var(--signal); font-variant-numeric: tabular-nums; }
.photo { display: flex; flex-direction: column; gap: 12px; }
.photo img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.note { margin: 0; font-size: 0.8rem; color: var(--muted); }
.err { margin: 0; font-size: 0.85rem; color: var(--danger); min-height: 0; }
.err:empty { display: none; }
.ok { margin: 0; font-size: 0.85rem; color: var(--accent); font-weight: 600; }
.ok:empty { display: none; }
details summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); padding: 4px 0; }
details label { margin-top: 8px; }
.presets { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; position: relative; overflow: hidden; }
.swatch i { position: absolute; inset: 0 0 0 50%; display: block; }
.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.hist li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.hist li:last-child { border-bottom: none; }
.hist .who { font-weight: 600; }
.hist .meta { font-size: 0.8rem; color: var(--muted); }
.hist .amt { font-weight: 700; color: var(--signal); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hist .empty { color: var(--muted); justify-content: center; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px max(8px, env(safe-area-inset-left, 0px)) calc(6px + env(safe-area-inset-bottom, 0px));
}
.tabs button { font: inherit; font-size: 0.85rem; font-weight: 600; background: none; border: none; color: var(--muted); min-height: 48px; border-radius: 10px; cursor: pointer; }
.tabs button.on { color: var(--accent); background: var(--soft); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
