:root {
  --bg: #f4f6f5; --card: #ffffff; --text: #17211f; --muted: #5f6d69; --line: #e2e7e5;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #e2f3f1;
  --warn: #a15c00; --warn-soft: #fdf1dc; --bad: #b42318; --bad-soft: #fdeceb; --ok: #18794e; --ok-soft: #e4f5ec;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,22,.06), 0 2px 8px rgba(16,24,22,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1413; --card: #182120; --text: #e8eeec; --muted: #9aa8a4; --line: #2a3533;
    --accent: #2bb3a3; --accent-ink: #062a26; --accent-soft: #173a36;
    --warn: #f0b45a; --warn-soft: #3a2c14; --bad: #f2867b; --bad-soft: #3b1d1a; --ok: #5fd19a; --ok-soft: #173426;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
.top-in { max-width: 980px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.who { margin-left: auto; color: var(--muted); font-size: 14px; text-align: right; }
.tabs { max-width: 980px; margin: 8px auto 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 8px 12px; border-radius: 999px; color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 15px; }
.tab.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tab .badge { margin-left: 6px; }

main { max-width: 980px; margin: 0 auto; padding: 16px; padding-bottom: max(32px, env(safe-area-inset-bottom)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

/* кнопки */
.btn { border: 1px solid var(--line); background: var(--card); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; min-height: 40px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.ok { color: var(--ok); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 14px; border-radius: 8px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; min-height: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.big { width: 100%; padding: 18px; font-size: 19px; font-weight: 700; border-radius: 14px; }

/* период */
.period { display: flex; align-items: center; gap: 6px; }
.period .lbl { text-align: center; min-width: 0; }
.period .lbl b { display: block; font-size: 15px; }
.period .lbl span { font-size: 13px; color: var(--muted); }
.arrow { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 18px; flex: none; }

/* сводка */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 14px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.total { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--accent-soft); display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.total .v { font-size: 26px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }

.running { text-align: center; }
.running .clock { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 4px 0; }

/* списки */
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.item:first-child { border-top: 0; }
.item .main { flex: 1; min-width: 180px; }
.item .title { font-weight: 600; }
.item .sub { font-size: 14px; color: var(--muted); }
.item .amt { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.item .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 10px 0; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; vertical-align: middle; }
.b-pending { background: var(--warn-soft); color: var(--warn); }
.b-approved { background: var(--ok-soft); color: var(--ok); }
.b-rejected { background: var(--bad-soft); color: var(--bad); }
.b-run { background: var(--accent-soft); color: var(--accent); }
.b-count { background: var(--bad); color: #fff; }
.b-off { background: var(--line); color: var(--muted); }

/* отчёт */
.tbl-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.rep { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 760px; }
.rep th, .rep td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rep th { font-size: 13px; color: var(--muted); font-weight: 600; }
.rep th:first-child, .rep td:first-child { text-align: left; white-space: normal; }
.rep tfoot td { font-weight: 700; border-bottom: 0; }
.rep .pay { font-weight: 700; color: var(--accent); }
.rep tbody tr { cursor: pointer; }
.rep tbody tr:hover td { background: var(--bg); }
.note { padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; margin-bottom: 12px; }

/* формы */
.form { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid3 > :first-child { grid-column: 1 / -1; } }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); }
label.f input, label.f select, label.f textarea, select.inp { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 12px; font-size: 16px; color: var(--text); min-height: 44px; width: 100%; }
label.f input:focus, label.f select:focus, select.inp:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.err { color: var(--bad); font-size: 14px; min-height: 0; }

/* вход */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login .logo img { width: 48px; height: 48px; border-radius: 12px; }
.login h1 { margin: 0; font-size: 22px; }

/* окно */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 600px) { .overlay { align-items: center; } }
.modal { background: var(--card); width: 100%; max-width: 480px; border-radius: 18px 18px 0 0; padding: 18px 16px; padding-bottom: max(18px, env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; }
@media (min-width: 600px) { .modal { border-radius: 18px; } }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal .acts { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; z-index: 30; pointer-events: none; max-width: calc(100% - 32px); text-align: center; font-size: 15px; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
