:root {
  --bg: #f5f4f0; --card: #ffffff; --ink: #1f2328; --muted: #6b6f76; --line: #e4e2dc;
  --accent: #2f6f5e; --accent-soft: #e3efe9; --inc: #2f7d4f; --exp: #b5543c; --warn: #c48a1d;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header.top { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
header.top .in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 28px; padding: 0 20px; height: 56px; }
.brand { font-weight: 700; font-size: 17px; color: var(--ink); }
.brand span { color: var(--accent); }
nav a { color: var(--muted); padding: 17px 2px; margin-right: 18px; border-bottom: 2px solid transparent; }
nav a.on { color: var(--ink); border-color: var(--accent); }
nav a:hover { text-decoration: none; color: var(--ink); }
header .right { margin-left: auto; color: var(--muted); font-size: 13px; }
main { max-width: 1240px; margin: 0 auto; padding: 24px 20px 60px; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 14px; }
.row { display: flex; gap: 18px; flex-wrap: wrap; }
.grow { flex: 1 1 0; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.titlebar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.titlebar .sp { flex: 1; }
.monthnav { display: flex; align-items: center; gap: 6px; }
.monthnav a { display: inline-block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.inc { color: var(--inc); } .exp { color: var(--exp); } .muted { color: var(--muted); } .warn { color: var(--warn); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.grp td { background: #faf9f6; font-weight: 600; }
tr.sub td:first-child { padding-left: 22px; }
table.compact td, table.compact th { padding: 5px 6px; font-size: 13px; }
.scroll { overflow-x: auto; }
form.inline { display: inline; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #cfccc4; border-radius: 7px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.btn { display: inline-block; font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--exp); border-color: #e2b4a7; }
.quick { display: grid; grid-template-columns: 150px 250px 120px 1fr 120px 1.2fr auto; gap: 10px; align-items: end; }
.seg { display: inline-flex; border: 1px solid #cfccc4; border-radius: 7px; overflow: hidden; }
.seg input { display: none; }
.seg label { margin: 0; padding: 7px 12px; color: var(--ink); cursor: pointer; font-size: 14px; }
.seg input:checked + label { background: var(--accent); color: #fff; }
.bar { height: 6px; background: #eeece6; border-radius: 3px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar i.over { background: var(--exp); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eeece6; color: var(--muted); }
.pill.exp { background: #f6e5df; color: var(--exp); } .pill.inc { background: #e1f0e6; color: var(--inc); }
.filters { display: grid; grid-template-columns: repeat(8, 1fr) auto; gap: 10px; align-items: end; }
.note { background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.pending { background: #fff7e6; border: 1px solid #f0d9a6; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; }
.chart-box { position: relative; height: 280px; }
.login { max-width: 360px; margin: 12vh auto; }
.pager a, .pager span { margin-right: 8px; }
.diff-up { color: var(--exp); } .diff-down { color: var(--inc); }
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .quick, .filters { grid-template-columns: 1fr 1fr; }
}

.budget-left .big { font-size: 20px; margin-bottom: 4px; }
.budget-left .big b { font-size: 24px; }
.plan-sum { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.plan-sum .kpi .v { font-size: 20px; }
.plan-sum .op { color: var(--muted); font-size: 12px; }
input.plan-in { width: 110px; text-align: right; padding: 5px 7px; }
input.plan-in.custom { border-color: var(--warn); background: #fffaf0; }
.rec { cursor: pointer; border-bottom: 1px dashed var(--muted); }
.funds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 18px; }
.fund h2 { display: flex; justify-content: space-between; align-items: baseline; }
.fund .bal { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--accent); margin-top: 10px; }
.cats-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 10px; max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 7px; padding: 8px; }
.cats-pick label { display: flex; gap: 6px; align-items: center; color: var(--ink); font-size: 13px; margin: 0; }
.cats-pick input { width: auto; }
@media (max-width: 1000px) { .plan-sum { grid-template-columns: repeat(2, 1fr); } }
nav { display: flex; align-items: stretch; height: 56px; flex-wrap: nowrap; white-space: nowrap; }
nav > a, nav .dd > a { display: inline-flex; align-items: center; height: 56px; padding: 0 2px; }
.dd { position: relative; margin-right: 18px; }
.dd > a { margin-right: 0; }
.dd .menu { display: none; position: absolute; top: 54px; left: -10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.08); padding: 6px 0; min-width: 190px; z-index: 20; }
.dd:hover .menu, .dd:focus-within .menu { display: block; }
.dd .menu a { display: block; padding: 7px 14px; color: var(--ink); margin: 0; border: 0; height: auto; }
.dd .menu a:hover { background: var(--accent-soft); text-decoration: none; }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.alerts li:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; transform: translateY(-1px); }
.dot.exp { background: var(--exp); } .dot.warn { background: var(--warn); } .dot.info { background: #6b8fb5; }
.wish-ready { background: #eef6f0; }
.insights li { margin-bottom: 6px; }
.print-only { display: none; }
@media print {
  header.top, .no-print, .btn { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main { padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .print-only { display: block; }
}
.wk { display: grid; grid-template-columns: 46px repeat(7, 1fr); column-gap: 4px; }
.wk-head { text-align: center; font-weight: 600; color: var(--muted); padding: 4px 0 8px; text-transform: uppercase; font-size: 12.5px; }
.wk-head.today { color: var(--accent); }
.wk-times, .wk-day { position: relative; height: var(--h); }
.wk-day { background: #faf9f6; border-radius: 6px; }
.wk-day.today { background: var(--accent-soft); }
.wk-time { position: absolute; left: 0; font-size: 11px; color: var(--muted); transform: translateY(-6px); }
.wk-line { position: absolute; left: 0; right: 0; border-top: 1px dashed #e7e4dc; }
.wk-slot { position: absolute; color: #fff; border-radius: 6px; padding: 3px 6px; font-size: 11.5px; line-height: 1.25; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.wk-slot b { font-weight: 600; }
.sched-item { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.sched-item:last-child { border-bottom: 0; }
.sched-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
@media print { .wk-slot { -webkit-print-color-adjust: exact; print-color-adjust: exact; } .wk-day { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

button.chk { width: 18px; height: 18px; border: 2px solid var(--accent); border-radius: 5px; background: #fff; cursor: pointer; padding: 0; flex: none; transform: translateY(3px); }
button.chk:hover { background: var(--accent-soft); }
button.chk.on { background: var(--accent); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 12px; border-radius: 7px; color: var(--ink); background: #fff; border: 1px solid var(--line); }
.tabs a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tabs a:hover { text-decoration: none; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .t-main { flex: 1; min-width: 0; }
.task .t-meta { font-size: 12px; color: var(--muted); }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.prio2 .t-title { font-weight: 600; }
.prio2 .t-title::before { content: "! "; color: var(--exp); }
.who { display: inline-block; font-size: 11.5px; padding: 0 7px; border-radius: 9px; background: #eef2f7; color: #4a5d75; }
.day-col { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; min-height: 90px; }
.day-col.today { border-color: var(--accent); background: #f6fbf8; }
.day-col h3 { font-size: 13px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month-grid .day-col { min-height: 70px; font-size: 12px; }
.mini { font-size: 12.5px; display: flex; gap: 5px; align-items: flex-start; margin: 3px 0; }
.mini button.chk { width: 14px; height: 14px; border-width: 1.5px; transform: translateY(2px); }
.hgrid td.c { text-align: center; width: 46px; font-size: 12px; padding: 4px 2px; }
.hgrid td.c.ok { background: #e1f0e6; color: var(--inc); }
.hgrid td.c.bad { background: #fbeee9; color: var(--exp); }
.hgrid button { border: 0; background: none; cursor: pointer; width: 100%; height: 22px; font-size: 12px; color: inherit; }
@media (max-width: 1000px) { .week-grid, .month-grid { grid-template-columns: 1fr 1fr; } }

.task.pay { align-items: center; }
.task.pay.done > div { opacity: .6; }
.task.pay button.chk { transform: none; }

.demo-badge { background: #fff1d6; color: #8a5a00; border: 1px solid #f0d9a6; border-radius: 6px; padding: 2px 8px; font-size: 12.5px; margin-right: 6px; }
.demo-blur { filter: blur(5px); }

/* ============================================================ мобильная версия и PWA */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-ic { width: 22px; height: 22px; border-radius: 5px; }
.m-title, .m-only, .tabbar { display: none; }
.h-link { font-size: 13px; font-weight: 400; margin-left: 6px; }
.kpis.k3 { grid-template-columns: repeat(3, 1fr); }
.big-add { display: none; }
.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; align-items: start; }
.tx-line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.tx-line:last-child { border-bottom: 0; }
.tx-line:hover { text-decoration: none; background: #faf9f6; }
.tx-line b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.hab-quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; align-items: center; }
.hab-quick .btn { grid-column: 1 / -1; }
.hq-check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 15px; margin: 0; padding: 6px 0; }
.hq-check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.hq-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink); font-size: 15px; margin: 0; }
.hq-row i { color: var(--muted); font-style: normal; font-size: 12.5px; }
.hq-row input { width: 120px; text-align: right; }
.btn.wide { width: 100%; text-align: center; }
.add-form { max-width: 640px; }
.add-kind { display: flex; justify-content: center; margin-bottom: 14px; }
.amount-box { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 6px 0 16px; }
.amount-box input { font-size: 40px; font-weight: 650; text-align: center; border: 0; border-bottom: 2px solid var(--line); border-radius: 0; max-width: 260px; padding: 4px; font-variant-numeric: tabular-nums; }
.amount-box input:focus { outline: none; border-bottom-color: var(--accent); }
.amount-box span { font-size: 28px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { font: inherit; font-size: 14px; padding: 7px 13px; border-radius: 18px; border: 1px solid #cfccc4; background: #fff; color: var(--ink); cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.add-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.btn.big { padding: 13px 16px; font-size: 16px; }
.more-group h2 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.more-link { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 16px; }
.more-link:last-child { border-bottom: 0; }
.more-link span { color: var(--muted); font-size: 20px; }
.more-link:hover { text-decoration: none; }
.install-hint p { font-size: 14px; margin: 0 0 8px; }

@media (max-width: 760px) {
  body { font-size: 15px; -webkit-text-size-adjust: 100%; }
  header.top { padding-top: env(safe-area-inset-top); }
  header.top .in { height: 50px; gap: 12px; padding: 0 14px; }
  header.top nav { display: none; }
  .brand { font-size: 0; }               /* на телефоне — только значок, рядом название страницы */
  .brand-ic { width: 26px; height: 26px; }
  .m-title { display: block; font-weight: 650; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  header .right { font-size: 12.5px; white-space: nowrap; }
  header .right a[href="/logout"] { display: none; }
  .m-only { display: block; }
  .m-hide-h1, .m-hide { display: none !important; }
  .monthnav { flex-wrap: wrap; }
  .m-date { color: var(--muted); margin: -4px 0 12px; font-size: 14px; }
  main { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  h1 { font-size: 20px; }
  .titlebar { gap: 8px; margin-bottom: 12px; }
  .titlebar .sp { display: none; }
  .card { padding: 14px 14px; margin-bottom: 12px; border-radius: 12px; }
  .row { gap: 0; flex-direction: column; }
  .row > * { width: 100% !important; min-width: 0 !important; flex: none !important; }
  .kpis, .kpis.k3, .plan-sum { grid-template-columns: 1fr 1fr !important; gap: 10px; margin-bottom: 12px; }
  .kpis.k3 .kpi:first-child { grid-column: 1 / -1; }
  .kpi { padding: 11px 12px; border-radius: 12px; }
  .kpi .v { font-size: 20px; }
  .today-grid { grid-template-columns: 1fr; }
  .big-add { display: block; text-align: center; padding: 13px; font-size: 16px; margin-bottom: 12px; border-radius: 12px; }
  /* широкие таблицы листаются пальцем внутри карточки, а не растягивают страницу */
  .scroll { -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
  table { font-size: 13.5px; }
  th, td { padding: 7px 6px; }
  .quick, .filters, .add-fields { grid-template-columns: 1fr !important; }
  .funds-grid { grid-template-columns: 1fr; }
  .week-grid, .month-grid { grid-template-columns: 1fr !important; }
  .cats-pick { grid-template-columns: 1fr 1fr; }
  .chart-box { height: 220px; }
  input, select, textarea { font-size: 16px; padding: 9px 10px; }   /* 16px — iPhone не приближает страницу при вводе */
  .btn { padding: 10px 16px; }
  .btn.small { padding: 7px 12px; font-size: 14px; }
  .seg label { padding: 9px 14px; font-size: 15px; }
  button.chk { width: 24px; height: 24px; border-radius: 7px; transform: none; }
  .task { padding: 11px 0; align-items: center; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .tabs a { white-space: nowrap; }
  .monthnav a { padding: 7px 12px; }
  .wk { grid-template-columns: 36px repeat(7, minmax(64px, 1fr)); overflow-x: auto; }
  .dd .menu { display: none !important; }
  .amount-box input { font-size: 44px; }
  .chip { padding: 9px 14px; font-size: 15px; }
  .hab-quick { grid-template-columns: 1fr; gap: 2px; }
  .hq-row { padding: 6px 0; }
  .note { font-size: 14px; }

  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255,255,255,.96);
            backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line);
            padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: center; }
  .tabbar a { margin: 0; border: 0; height: auto; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; padding: 2px 0; }
  .tabbar a:hover { text-decoration: none; color: var(--accent); }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a.plus { flex: none; width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; margin-top: -22px;
                   box-shadow: 0 4px 14px rgba(47,111,94,.35); justify-content: center; }
  .tabbar a.plus svg { width: 28px; height: 28px; stroke-width: 2.4; }
}
@media (max-width: 760px) and (display-mode: standalone) {
  header .right a[href^="/demo"] { display: none; }    /* в приложении переключатель — в «Ещё» */
}
@media print { .tabbar { display: none !important; } }
.more-list > summary { list-style: none; color: var(--accent); padding: 10px 0 2px; font-size: 14px; margin: 0; }
.more-list > summary::-webkit-details-marker { display: none; }
.more-list[open] > summary { display: none; }
