:root {
  --bg: #f4f6f5; --card: #ffffff; --text: #0f1f1a; --muted: #5b6f68; --line: #e3e9e6; --soft: #f0f5f3;
  --side: #0b3d2e; --side-text: #cfe7dd; --side-active: #145a43;
  --accent: #14704f; --accent-2: #0b3d2e; --gold-1: #f6c453; --gold-2: #d99a1e;
  --ok: #11845b; --wait: #b7791f; --bad: #d03b3b;
  --radius: 16px; --shadow: 0 1px 2px rgba(15, 31, 26, .04), 0 4px 16px rgba(15, 31, 26, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0; }
.muted, .hint, .sub, .opt { color: var(--muted); }
.small { font-size: 13px; }
.income { color: var(--ok); } .expense, .neg { color: var(--bad); }
[hidden] { display: none !important; }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 18px; padding: 4px 8px; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2)); color: #3b2a05; font-weight: 800; font-size: 19px; }
.brand-mark.big { width: 56px; height: 56px; border-radius: 16px; font-size: 30px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a, .side-out { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--side-text); font-weight: 500; }
.side-nav a:hover, .side-out:hover { background: rgba(255, 255, 255, .06); }
.side-nav a.active { background: var(--side-active); color: #fff; font-weight: 700; }
.side-out { margin-top: auto; opacity: .75; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.main { padding: 28px 32px 48px; max-width: 1240px; width: 100%; min-width: 0; }
.tabbar { display: none; }

.page-head { margin-bottom: 20px; }
.page-head .sub { margin: 4px 0 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.row-between.wrap { flex-wrap: wrap; align-items: flex-end; }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- карточки ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; min-width: 0; }
.card-head { margin-bottom: 14px; }
.card-head .hint { margin: 2px 0 0; font-size: 13px; }
.subcard { background: var(--soft); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.empty { color: var(--muted); background: var(--soft); border-radius: 12px; padding: 14px; margin: 0; }
.more { display: inline-block; margin-top: 12px; font-weight: 600; font-size: 14px; }

.kpis { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; color: var(--text); min-width: 0; }
.kpi-l { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; white-space: nowrap; }
.kpi-s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.hero { background: linear-gradient(135deg, #0b3d2e, #14704f); color: #fff; }
.kpi.hero .kpi-l, .kpi.hero .kpi-s { color: #cfe7dd; }
.kpi.hero .kpi-v { font-size: 30px; }
a.kpi:hover { box-shadow: 0 2px 4px rgba(15, 31, 26, .06), 0 8px 24px rgba(15, 31, 26, .1); }

.grid-main { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.col { min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid3 .card { margin-bottom: 0; }
.grid3 + .card { margin-top: 16px; }

/* ---------- платежи ---------- */
.pay-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.card-head + .pay-row { border-top: 0; padding-top: 0; }
.pay-row.paid { opacity: .55; }
.date-tile { width: 88px; flex: none; background: var(--soft); border-radius: 12px; padding: 8px 6px; text-align: center; line-height: 1.2; }
.date-tile b { display: block; font-size: 16px; }
.date-tile span { font-size: 11px; white-space: nowrap; color: var(--muted); }
.pay-main { flex: 1; min-width: 0; }
.pay-title { font-weight: 600; overflow-wrap: anywhere; }
.pay-sub { color: var(--muted); font-size: 13px; }
.pay-right { text-align: right; flex: none; }
.pay-amt { font-weight: 700; white-space: nowrap; }
.pay-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.st { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; margin-top: 3px; }
.st.ok { color: var(--ok); background: #e3f4ec; }
.st.wait { color: var(--wait); background: #fbf1dc; }
.st.risk { color: var(--bad); background: #fbe5e5; }

/* ---------- операции ---------- */
.tx { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.card-head + .tx { border-top: 0; padding-top: 0; }
.tx-dot { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; font-weight: 700;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, #fff); }
.tx-main { flex: 1; min-width: 0; }
.tx-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tx-amt { font-weight: 700; white-space: nowrap; }
.tx-amt.income { color: var(--ok); } .tx-amt.expense { color: var(--text); } .tx-amt.transfer { color: var(--muted); }
.chips-row { display: flex; gap: 10px; flex-wrap: wrap; margin: -4px 0 16px; }
.chip-stat { background: var(--card); box-shadow: var(--shadow); border-radius: 99px; padding: 6px 14px; font-size: 14px; color: var(--muted); }
.chip-stat b { margin-left: 6px; color: var(--text); }
.chip-stat b.income { color: var(--ok); } .chip-stat b.expense { color: var(--bad); }

/* ---------- кольцо и цели ---------- */
.donut-wrap { display: grid; place-items: center; margin: 4px 0 16px; }
.donut { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; }
.donut-hole { width: 104px; height: 104px; border-radius: 50%; background: var(--card); display: grid; place-content: center; text-align: center; line-height: 1.2; }
.donut-hole span { color: var(--muted); font-size: 12px; }
.donut-hole b { font-size: 14px; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.legend li span { flex: 1; }
.legend i, .sq { width: 12px; height: 12px; border-radius: 4px; flex: none; display: inline-block; }
.goal { padding: 10px 0; border-top: 1px solid var(--line); }
.card-head + .goal { border-top: 0; padding-top: 0; }
.goal-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 14px; }
.goal-cap { color: var(--muted); font-size: 13px; }
.goal.big .goal-top { font-size: 15px; }
.goal-actions { display: flex; gap: 8px; margin-top: 8px; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin: 7px 0 5px; }
.bar > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #14704f, #f6c453); }

/* ---------- деньги ---------- */
.funnel-list { display: grid; gap: 4px; }
.funnel-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; }
.funnel-row:nth-child(odd) { background: var(--soft); }
.funnel-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.funnel-main span { color: var(--muted); font-size: 13px; }
.funnel-v { font-weight: 700; white-space: nowrap; }
.acc-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.card-head + .acc-row { border-top: 0; }
.acc-row span { display: flex; align-items: center; gap: 8px; }

/* ---------- формы ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-form.three { grid-template-columns: repeat(3, 1fr); }
.span2 { grid-column: span 2; }
label, .lbl { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
.opt { font-weight: 400; font-size: 12px; }
input, select { font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px; min-width: 0; }
input:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--accent) 20%, transparent); border-color: var(--accent); }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
label.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9d6d1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.wide { width: 100%; padding: 13px; font-size: 16px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 22px; cursor: pointer; padding: 0 6px; line-height: 1; }
.icon-btn:hover { color: var(--bad); }
.flash { background: #e3f4ec; color: #0c5d40; padding: 11px 14px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; }
.flash.err { background: #fbe5e5; color: #9c2424; }

.tabs { display: inline-flex; background: #fff; box-shadow: var(--shadow); border-radius: 12px; padding: 4px; margin-bottom: 16px; gap: 2px; }
.tabs a { padding: 8px 16px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tabs a.active { background: var(--side); color: #fff; }
.seg-links { display: inline-flex; background: #fff; box-shadow: var(--shadow); border-radius: 12px; padding: 4px; gap: 2px; }
.seg-links a { padding: 6px 12px; border-radius: 9px; color: var(--muted); font-size: 14px; font-weight: 600; }
.seg-links a.active { background: var(--soft); color: var(--text); }

details.pop { position: relative; }
details.pop summary { list-style: none; }
details.pop summary::-webkit-details-marker { display: none; }
.pop-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; width: 250px; display: flex; flex-direction: column;
  gap: 10px; background: #fff; border-radius: 14px; padding: 14px; box-shadow: 0 12px 32px rgba(15, 31, 26, .18); }

.split { border-top: 1px solid var(--line); padding-top: 14px; }
.split-parts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.part { border-left: 4px solid var(--c); padding-left: 10px; }
.part span { color: var(--text); font-weight: 600; }
.split-sum { margin-top: 10px; font-weight: 600; font-size: 14px; } .split-sum.ok { color: var(--ok); } .split-sum.bad { color: var(--bad); }
.notes { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); color: var(--text); cursor: pointer; background: #fff; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }

.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.filters-btns { display: flex; gap: 8px; align-items: end; }

/* ---------- вход ---------- */
.bare { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 30% 20%, #145a43 0%, #0b3d2e 60%, #072a20 100%); }
.login { width: 100%; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login-head { text-align: center; } .login-head h1 { margin: 12px 0 2px; }
.login-head p { margin: 0; }

/* ---------- телефон и планшет ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid-main, .grid3 { grid-template-columns: 1fr; }
  .grid3 .card { margin-bottom: 16px; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .side { display: none; }
  .main { padding: 18px 16px calc(92px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi.hero, .kpi:last-child { grid-column: span 2; }
  .kpi-v { font-size: 18px; } .kpi.hero .kpi-v { font-size: 26px; }
  .kpi-s { display: none; }
  .card { padding: 16px; }
  .grid-form, .grid-form.three, .filters { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .split-parts { grid-template-columns: 1fr 1fr; }
  .pay-row { flex-wrap: wrap; gap: 10px 12px; }
  .date-tile { width: 76px; }
  .pay-main { flex: 1 1 calc(100% - 92px); }
  .pay-right { flex: 1; text-align: left; margin-left: 88px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .pay-right .st { margin-top: 0; }
  .pay-actions { margin-left: auto; }
  .tabs { display: flex; } .tabs a { flex: 1; text-align: center; padding: 8px 6px; }
  .tabbar { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--side); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--side-text); padding: 4px 0; border-radius: 10px; min-width: 0; }
  .tabbar a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tabbar a.active { color: #fff; background: var(--side-active); }
  .tabbar a.plus .ic { color: var(--gold-1); }
  .pop-form { width: min(250px, calc(100vw - 32px)); }
}
