:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d2327; --muted: #6b747b; --line: #e7e3da;
  --accent: #2f6f5e; --accent-ink: #ffffff; --accent-soft: #e3efe9;
  --red: #c93a3a; --red-soft: #fbe6e3; --yellow: #a46a00; --yellow-soft: #fbefcf;
  --blue: #2d68a8; --blue-soft: #e2edf8; --shadow: 0 1px 2px rgba(30, 30, 20, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a; --card: #1f2428; --ink: #eef1f2; --muted: #98a2a9; --line: #2e353a;
    --accent: #5fb89e; --accent-ink: #0c1512; --accent-soft: #1d3a32;
    --red: #ff8076; --red-soft: #45211f; --yellow: #f0c25a; --yellow-soft: #40330f;
    --blue: #86b8ee; --blue-soft: #1b2f45; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 30px; line-height: 1.15; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 26px 4px 8px; }
.icon { width: 24px; height: 24px; display: inline-flex; flex: none; }
.icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* каркас */
.screen { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 96px); min-height: 100vh; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sub { color: var(--muted); font-size: 15px; margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 17px; margin: 0 0 10px -6px; padding: 6px 8px 6px 0; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 6px; color: var(--muted); font-size: 11px; position: relative; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
.tabbar .dot { position: absolute; top: 4px; left: 50%; margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
@media (prefers-color-scheme: dark) { .tabbar .dot { color: #2a0d0b; } }
.fab {
  position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(env(safe-area-inset-bottom) + 74px); z-index: 6;
  width: 58px; height: 58px; border-radius: 29px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
}
.fab .icon { width: 28px; height: 28px; }
.fab .icon svg { stroke-width: 2.2; }

/* карточки и строки */
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.card.pad { padding: 14px 16px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; text-align: left; min-height: 60px; color: var(--ink); }
.row + .row { border-top: 1px solid var(--line); }
.row .main { flex: 1; min-width: 0; text-align: left; color: inherit; }
.row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .note { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .note.red { color: var(--red); } .row .note.yellow { color: var(--yellow); }
.row .chev { color: var(--line); flex: none; }
.ava { width: 40px; height: 40px; border-radius: 20px; flex: none; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.ava.red { background: var(--red-soft); color: var(--red); } .ava.yellow { background: var(--yellow-soft); color: var(--yellow); }
.ava.blue { background: var(--blue-soft); color: var(--blue); } .ava.off { background: var(--line); color: var(--muted); }
.badge { flex: none; font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 10px; background: var(--line); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge.red { background: var(--red-soft); color: var(--red); } .badge.yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge.blue { background: var(--blue-soft); color: var(--blue); } .badge.green { background: var(--accent-soft); color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 34px 20px; }
.empty b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 4px; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 11px 16px; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv span:first-child { color: var(--muted); flex: none; }
.kv span:last-child { text-align: right; overflow-wrap: anywhere; }
.stat { display: flex; gap: 10px; margin-bottom: 4px; }
.stat button { flex: 1; background: var(--card); border-radius: 16px; padding: 12px 14px; text-align: left; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat .red b { color: var(--red); } .stat .yellow b { color: var(--yellow); }

/* кнопки и формы */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 600; width: 100%; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.plain { background: none; color: var(--accent); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn[disabled] { opacity: .5; }
.actions { display: flex; gap: 8px; margin: 14px 0 4px; }
.actions .btn { flex: 1; flex-direction: column; gap: 3px; min-height: 62px; font-size: 13px; padding: 0 6px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
label.f { display: block; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin: 0 4px 5px; }
input[type=text], input[type=tel], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); -webkit-appearance: none; appearance: none; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 84px; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; min-height: 42px; border-radius: 10px; font-size: 15px; color: var(--muted); padding: 0 4px; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 12px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 7px 14px; border-radius: 18px; background: var(--card); color: var(--muted); font-size: 14px; box-shadow: var(--shadow); }
.chips button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); margin: 0 4px; }
.err { color: var(--red); font-size: 14px; margin: 0 4px; min-height: 0; }

/* этапы */
.steps { padding: 6px 0; }
.step { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 16px; text-align: left; }
.step i { width: 26px; height: 26px; border-radius: 13px; border: 2px solid var(--line); flex: none; display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 13px; font-weight: 700; color: var(--muted); }
.step.done i { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step.now i { border-color: var(--accent); color: var(--accent); }
.step.now span { font-weight: 700; }
.step.todo span { color: var(--muted); }

/* журнал */
.log { padding: 12px 16px; display: flex; gap: 12px; }
.log + .log { border-top: 1px solid var(--line); }
.log .main { flex: 1; min-width: 0; }
.log .meta { font-size: 13px; color: var(--muted); }
.log .del { color: var(--muted); padding: 4px 8px; font-size: 20px; line-height: 1; align-self: flex-start; }
.month { font-size: 20px; font-weight: 700; margin: 24px 4px 8px; text-transform: capitalize; }
.day { width: 40px; flex: none; text-align: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* вход */
.login { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12vh) 22px 40px; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 18px; display: block; }
.login h1 { margin-bottom: 6px; }
.login form { margin-top: 26px; }
.demo { margin-top: 26px; padding: 14px; border-radius: 16px; background: var(--yellow-soft); }
.demo p { margin: 0 0 10px; font-size: 14px; color: var(--yellow); }

/* шторка и всплывающее сообщение */
.veil { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .42); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 22px 22px 0 0; padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px); animation: up .22s ease-out; }
.sheet .grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet .top b { font-size: 20px; }
.sheet .top button { color: var(--accent); font-size: 17px; padding: 6px 0 6px 12px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 86px); transform: translateX(-50%); z-index: 30; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-size: 15px; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
