:root {
  --bg: #f5f6fa; --card: #ffffff; --ink: #232b40; --muted: #687089; --line: #e2e5ee;
  --accent: #c76a88; --accent-ink: #ffffff; --accent-soft: #f7e6ec; --night: #1d1619; --night-ink: #f6f1f2;
  --ok: #1f8a5b; --ok-soft: #e3f4ec; --warn: #b7791f; --warn-soft: #fbf1df; --bad: #c2413b; --bad-soft: #fbe7e5;
  --radius: 16px; --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 4px 16px rgba(20, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151d; --card: #1a1e29; --ink: #e9ecf4; --muted: #9aa1b5; --line: #2a3040;
    --accent: #e7a1b6; --accent-ink: #1b1218; --accent-soft: #2b2028;
    --ok: #4cc28c; --ok-soft: #173126; --warn: #e2b04f; --warn-soft: #34291a; --bad: #f0807a; --bad-soft: #3a1f1e;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--night); color: var(--night-ink); }
.brand { font-weight: 700; letter-spacing: .32em; font-size: 15px; }
.who { margin-left: auto; font-size: 13px; opacity: .8; text-align: right; line-height: 1.2; max-width: 55%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn { background: none; border: 0; color: inherit; padding: 6px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; position: relative; }
.iconbtn svg { width: 22px; height: 22px; }
.dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

main { max-width: 640px; margin: 0 auto; padding: 14px 16px 24px; }
h1 { font-size: 22px; margin: 6px 0 12px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 22px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.big { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.mid { font-size: 20px; font-weight: 650; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--ink); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.gray { background: var(--line); color: var(--muted); }

/* кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 16px;
  background: var(--accent); color: var(--accent-ink); font-weight: 650; cursor: pointer; text-decoration: none; min-height: 46px; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--accent-soft); color: var(--ink); }
.btn.line { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
label.f { display: block; margin: 10px 0; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 12px; min-height: 46px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* переключатель смены */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 11px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; min-width: 44px; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg button.on.s1 { background: var(--accent); color: var(--accent-ink); }
.seg button.on.s2 { background: var(--night); color: var(--night-ink); }
.seg button:disabled { opacity: .3; }

/* списки */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 11px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.tap { cursor: pointer; }
.chev { color: var(--muted); }

/* полоска прогресса */
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar.ok > i { background: var(--ok); } .bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }

/* таблицы */
.tablewrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; white-space: normal; min-width: 120px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr.sum td { font-weight: 700; border-bottom: 0; }
tr.tap:active td { background: var(--accent-soft); }
.tablewrap th:first-child, .tablewrap td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; }
.tablewrap td input { margin: 0; }
.tablewrap td:has(input) { padding: 4px 2px; }

/* карточки точек */
.pcard { border-left: 6px solid var(--line); }
.pcard.green { border-left-color: var(--ok); } .pcard.yellow { border-left-color: var(--warn); } .pcard.red { border-left-color: var(--bad); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 10px; }
.kv div span { display: block; font-size: 12px; color: var(--muted); }
.kv div b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* нижнее меню */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
nav.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted);
  text-decoration: none; padding: 4px 0; border-radius: 10px; }
nav.tabs a svg { width: 24px; height: 24px; }
nav.tabs a.on { color: var(--accent); font-weight: 650; }

/* графики */
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-size: 10px; fill: var(--muted); font-family: inherit; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* вход */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login .logo { font-size: 34px; letter-spacing: .4em; font-weight: 700; text-align: center; margin-bottom: 4px; }
.pin { letter-spacing: .6em; text-align: center; font-size: 22px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 20; max-width: 560px; margin: 0 auto;
  background: var(--night); color: var(--night-ink); border-radius: 14px; padding: 12px 16px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); color: #fff; }
.empty { text-align: center; padding: 36px 10px; color: var(--muted); }
.monthbar { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.monthbar b { font-size: 15px; }
.flag { display: flex; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.flag:first-of-type { border-top: 0; }
.diff { font-size: 12px; color: var(--muted); word-break: break-word; }
.spacer { height: 8px; }
