:root {
  --bg: #0E0C16;
  --bg2: #15121F;
  --card: #1A1726;
  --card2: #221E31;
  --line: #2D283F;
  --text: #EEEAF6;
  --muted: #9A94B2;
  --faint: #6C6688;
  --gold: #E2B84B;
  --gold-soft: rgba(226, 184, 75, .14);
  --ok: #3CC883;
  --ok-soft: rgba(60, 200, 131, .16);
  --late: #F2A93B;
  --late-soft: rgba(242, 169, 59, .18);
  --bad: #F0566A;
  --bad-soft: rgba(240, 86, 106, .16);
  --auto: #4F7E6A;
  --t-dnk: #A86BF5;
  --t-sdvig: #3FB6F2;
  --t-feniks: #F7803A;
  --t-proryv: #3CC883;
  --r: 14px;
  --nav-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.boot { padding: 80px 20px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.stack-s > * + * { margin-top: 6px; }
.hidden { display: none !important; }

/* ── каркас ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(14, 12, 22, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
}
.top-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; letter-spacing: .02em; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; letter-spacing: 0; }
.page { max-width: 1100px; margin: 0 auto; padding: 16px; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(21, 18, 31, .97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-inner { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--nav-h); }
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: 11px; font-weight: 500;
}
.nav a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.on { color: var(--gold); }

/* ── карточки и элементы ──────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card.flat { background: var(--bg2); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 22px 2px 10px; }
.section-title h2 { font-size: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 720px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid3 > .kpi:nth-child(3) { grid-column: span 2; } }

.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi .lbl { font-size: 12px; color: var(--muted); }
.kpi .val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card2); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 14px; cursor: pointer;
  min-height: 40px; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #3d3657; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.gold { background: var(--gold); color: #1a1405; border-color: var(--gold); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 0; width: 36px; min-height: 36px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--gold); cursor: pointer; padding: 0; font-weight: 600; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
  font-size: 13px; background: var(--bg2); color: var(--muted); cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--gold-soft); color: var(--gold); border-color: rgba(226, 184, 75, .45); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); white-space: nowrap; }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.late { background: var(--late-soft); color: var(--late); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }

.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 8px 6px; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--text); }

/* ── формы ─────────────────────────────────────────────── */
label.f { display: block; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
label.f > span b { color: var(--bad); font-weight: 600; }
input[type=text], input[type=number], input[type=date], input[type=tel], input[type=url], select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 42px; outline: none;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
select.inline { min-height: 32px; padding: 4px 26px 4px 10px; font-size: 13px; width: auto; background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.err { color: var(--bad); font-size: 13px; }

.pick { display: grid; gap: 8px; }
.pick.c2 { grid-template-columns: 1fr 1fr; }
.pick.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 560px) { .pick.c4 { grid-template-columns: 1fr 1fr; } }
.pick button {
  text-align: left; border: 1px solid var(--line); background: var(--bg2); border-radius: 12px; padding: 11px 12px; cursor: pointer;
}
.pick button.on { border-color: var(--gold); background: var(--gold-soft); }
.pick button b { display: block; font-size: 15px; }
.pick button small { color: var(--muted); font-size: 12px; }

/* ── прогресс ─────────────────────────────────────────── */
.bar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--gold); min-width: 2px; }
.bar.thin { height: 5px; }
.bar.ok > i { background: var(--ok); }

/* ── отчёты: кнопка-отметка ───────────────────────────── */
.tick {
  width: 44px; height: 44px; border-radius: 12px; flex: none; cursor: pointer;
  border: 2px solid var(--line); background: var(--bg2); display: grid; place-items: center;
}
.tick svg { width: 22px; height: 22px; stroke: transparent; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.tick.on { background: var(--ok); border-color: var(--ok); }
.tick.on svg { stroke: #08150f; }
.tick.late.on { background: var(--late); border-color: var(--late); }
.tick.sm { width: 30px; height: 30px; border-radius: 8px; }
.tick.sm svg { width: 16px; height: 16px; }
.tick:disabled { cursor: default; }

.list > .li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list > .li:first-child { border-top: 0; padding-top: 2px; }
.list > .li:last-child { padding-bottom: 2px; }

/* ── сетка отчётов ────────────────────────────────────── */
.grid-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
table.rg { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.rg th, table.rg td { padding: 0; }
table.rg thead th { position: sticky; top: 0; background: var(--card); color: var(--faint); font-weight: 500; padding: 8px 2px 6px; text-align: center; min-width: 30px; }
table.rg thead th.today { color: var(--gold); }
table.rg .name { position: sticky; left: 0; z-index: 2; background: var(--card); text-align: left; padding: 6px 10px 6px 12px; min-width: 150px; max-width: 190px; font-size: 13px; border-right: 1px solid var(--line); }
table.rg .name .muted { font-size: 11px; }
table.rg td.c { text-align: center; padding: 3px 2px; }
.cell { width: 26px; height: 26px; border-radius: 7px; display: inline-grid; place-items: center; border: 0; padding: 0; background: transparent; }
button.cell { cursor: pointer; }
.cell.done { background: var(--ok); }
.cell.late { background: var(--late); }
.cell.auto { background: var(--auto); }
.cell.miss { background: var(--bad-soft); border: 1px solid rgba(240, 86, 106, .55); }
.cell.pend { border: 1.5px dashed var(--gold); }
.cell.fut { background: var(--bg2); }
.cell.na { background: transparent; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .cell { width: 14px; height: 14px; border-radius: 4px; }

/* ── таблицы ──────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.r, table.t th.r { text-align: right; }
table.t tr.click { cursor: pointer; }
table.t td:first-child { min-width: 170px; }
table.t tr.click:hover td { background: rgba(255, 255, 255, .02); }
table.t tr.total td { font-weight: 700; }

/* ── декларация ───────────────────────────────────────── */
.item { padding: 14px; }
.item + .item { border-top: 1px solid var(--line); }
.item .ttl { font-weight: 600; }
.item .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.item.done .ttl { color: var(--muted); }
.entries { margin-top: 10px; padding: 8px 10px; background: var(--bg2); border-radius: 10px; font-size: 13px; }
.entries .e { display: flex; gap: 10px; align-items: center; padding: 4px 0; }
.kind-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; font-size: 15px; font-weight: 700; }
.kind-simple { background: rgba(63, 182, 242, .14); color: var(--t-sdvig); }
.kind-tracker { background: rgba(168, 107, 245, .16); color: var(--t-dnk); }
.kind-money { background: var(--gold-soft); color: var(--gold); }

/* ── вовлекаемые ──────────────────────────────────────── */
.lead { display: flex; gap: 12px; padding: 12px 14px; align-items: flex-start; }
.lead + .lead { border-top: 1px solid var(--line); }
.lead .fio { font-weight: 600; }
.funnel { display: grid; gap: 6px; }
.funnel .fr { display: grid; grid-template-columns: 150px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
@media (max-width: 520px) { .funnel .fr { grid-template-columns: 112px 1fr 36px; font-size: 12px; } }
.funnel .fb { height: 22px; background: var(--card2); border-radius: 6px; overflow: hidden; }
.funnel .fb > i { display: block; height: 100%; border-radius: 6px; }

/* ── аватары ──────────────────────────────────────────── */
.ava { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #120f1b; overflow: hidden; }
.ava img { width: 100%; height: 100%; object-fit: cover; }
.ava.sm { width: 26px; height: 26px; font-size: 11px; }
.ava.lg { width: 56px; height: 56px; font-size: 20px; }
.ava-btn { border: 0; background: none; padding: 0; cursor: pointer; }

/* ── графики ──────────────────────────────────────────── */
.chart svg { width: 100%; height: auto; max-height: 300px; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--faint); font-size: 12px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 64px; gap: 10px; align-items: center; font-size: 14px; }
.hbar + .hbar { margin-top: 10px; }
.hbar .hb { height: 12px; background: var(--card2); border-radius: 99px; overflow: hidden; position: relative; }
.hbar .hb > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; }
.hbar .hb > em { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .55; }

/* ── модалка ──────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(5, 4, 10, .72); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 18px 18px 0 0; width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60;
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { border-color: var(--bad); color: var(--bad); }

/* ── вход ─────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { max-width: 420px; width: 100%; padding: 28px 22px; text-align: center; }
.login h1 { font-size: 26px; margin: 14px 0 6px; }
.onb { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; }
body.no-nav { padding-bottom: 0; }

.empty { text-align: center; padding: 26px 14px; color: var(--muted); font-size: 14px; }
.tm { display: inline-flex; align-items: center; gap: 6px; }
.menu-pop { position: absolute; right: 16px; top: 58px; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 200px; z-index: 40; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; color: var(--text); background: none; border: 0; cursor: pointer; font-size: 14px; }
.menu-pop a:hover, .menu-pop button:hover { background: rgba(255, 255, 255, .05); }
