:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --ink: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --green: #059669;
  --green-dot: #10b981;
  --red: #dc2626;
  --red-dot: #ef4444;
  --amber: #d97706;
  --amber-bg: #fef3c7;
  --red-bg: #fee2e2;
  --radius: 12px;
  font-family: Inter, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; height: 100dvh; overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { margin: 0; font-size: 20px; letter-spacing: -0.03em; }
h2 { margin: 0; font-size: 13px; }
p { margin: 0; }

.app { display: flex; height: 100dvh; background: var(--bg); }
.side {
  width: 196px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 16px 12px 14px;
}
.brand-name { font-weight: 600; font-size: 14px; }
.brand-sub { color: var(--faint); font-size: 12px; margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 16px; }
.nav a, .tabbar a {
  border-radius: 8px;
  padding: 6px 10px;
  color: #334155;
  font-weight: 500;
}
.nav a.on, .tabbar a.on { background: var(--ink); color: #fff; }
.nav a.quiet { color: var(--muted); font-weight: 500; }
.nav a.quiet.on { color: #fff; }
.side-gap { flex: 1; }
.who-name { font-weight: 500; }
.who-sub, .muted { color: var(--muted); font-size: 12px; }
.text-btn {
  background: none;
  border: 0;
  padding: 6px 0 0;
  color: var(--muted);
  cursor: pointer;
}
.column { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mobile-head, .tabbar { display: none; }
main { flex: 1; overflow: auto; padding: 18px 22px 28px; }

.head-row, .card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.head-row { margin-bottom: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.card + .card, .trend-card, .flow, .capital, .dash-grid, .cal-split { margin-top: 12px; }
.trend-card h2, .card-head { align-items: center; }
.seg { display: flex; gap: 6px; }
.seg a, .seg span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #334155;
}
.seg .on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; margin-top: 8px; }
.chart .hit { cursor: pointer; }
.tip {
  position: absolute;
  transform: translate(-50%, -130%);
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 8px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
}
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; margin-top: 4px; }
.swatch { width: 8px; height: 8px; border-radius: 99px; display: inline-block; margin-right: 6px; }
.swatch.green { background: var(--green-dot); }
.swatch.yellow { background: #f59e0b; }
.gap {
  display: block;
  margin-top: 10px;
  background: var(--amber-bg);
  color: #92400e;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.gap.static { cursor: default; }

.cal-split { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; align-items: start; }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.weekdays { color: var(--faint); font-size: 11px; margin-bottom: 4px; text-align: center; }
.day {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.day.out { opacity: 0.38; }
.day.low { background: var(--amber-bg); border-color: #fde68a; }
.day.neg { background: var(--red-bg); border-color: #fecaca; }
.day.today { box-shadow: inset 0 0 0 2px var(--ink); }
.day.sel { box-shadow: inset 0 0 0 2px #2563eb; }
.num { font-weight: 600; }
.dots { display: flex; gap: 3px; min-height: 5px; }
.dot { width: 5px; height: 5px; border-radius: 99px; }
.dot.in { background: var(--green-dot); }
.dot.out { background: var(--red-dot); }
.balance { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; margin: 4px 0 0; }
.balance.ok { color: var(--green); }
.balance.low { color: var(--amber); }
.balance.neg { color: var(--red); }
.ops { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; }
.ops li { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.ops li div { display: flex; flex-direction: column; }
.plus { color: var(--green); }
.minus { color: var(--red); }
.note { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink);
}
textarea { resize: vertical; }
.btn {
  border: 0;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 500;
  cursor: pointer;
  width: fit-content;
}
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.plan-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.month-nav { display: flex; gap: 8px; }
.month-nav a {
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px;
}
.dash-grid { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 12px; }
.cat { margin-top: 14px; }
.cat-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.bar { height: 6px; background: #f1f5f9; border-radius: 99px; margin: 4px 0; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.cat.over .bar i { background: var(--red-dot); }
.capital h2, .open-sum h2 { margin: 4px 0; font-size: 16px; letter-spacing: -0.03em; }
.open-sum p:last-child { margin: 0; }
.flow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.flow strong { display: block; margin-top: 2px; font-size: 16px; letter-spacing: -0.03em; }
.capital {
  background: #ecfdf5;
  border-color: #a7f3d0;
}
.capital p + p { margin-top: 4px; }
.capital form { margin-top: 10px; }
.capital .btn { width: 100%; background: #065f46; padding: 8px 12px; }
.ok-text { color: var(--green); margin-top: 8px; }
.flash { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pill {
  display: flex; flex-direction: row; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; background: #fff; cursor: pointer; color: #334155; font-size: 13px;
  white-space: nowrap; width: auto;
}
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); }
.rub { font-weight: 600; }
.rub.in { color: var(--green); }
.rub.out { color: var(--red); }
.pill:has(input:checked) .rub.out { color: #fb7185; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.wide { grid-column: 1 / -1; }
.hint { margin: 0; }
.entry .btn { margin-top: 16px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.check input { width: auto; padding: 0; }
.ask { display: grid; grid-template-columns: 1fr 160px auto; gap: 12px; align-items: center; margin-top: 14px; }
.ask-ok { grid-template-columns: 1fr auto; }
.ask div { display: flex; flex-direction: column; }
.capital-form { display: grid; grid-template-columns: 220px auto; gap: 12px; align-items: end; justify-content: start; }
.record-actions { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.record-actions .text-btn { padding: 0; }
.more { position: relative; }
.more summary { list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more-menu {
  position: absolute; top: 44px; left: 0; z-index: 6;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  min-width: 180px; padding: 6px; display: flex; flex-direction: column;
}
.more-menu a { padding: 10px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.add-cat { display: grid; grid-template-columns: 1fr 160px 160px auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.cat-item { align-items: flex-start; }
.cat-fold { flex: 1; min-width: 0; }
.cat-fold summary { display: flex; cursor: pointer; }
.cat-fold summary > span { display: flex; flex-direction: column; }
.month-plans { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.month-plan { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 8px; align-items: center; }
.login-screen { min-height: 100%; display: grid; place-items: center; }
.login-card { width: min(360px, 100%); }
.login-card h1 { margin-bottom: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.login-card .btn { width: 100%; }
.login-error { color: var(--red); font-size: 12px; }
.cats { margin-top: 0; }

@media (max-width: 860px) {
  body { overflow: hidden; font-size: 15px; }
  h1 { font-size: 22px; }
  input, select, textarea { font-size: 16px; padding: 10px 12px; }
  .side { display: none; }
  .mobile-head {
    display: flex; align-items: center; gap: 12px;
    height: 60px; padding: 0 16px; background: #fff;
    border-bottom: 1px solid var(--line); flex: none;
  }
  .mobile-title { font-weight: 600; flex: 1; }
  .icon-btn {
    width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px;
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
    background: #fff;
  }
  .icon-btn span { width: 16px; height: 2px; background: var(--ink); border-radius: 1px; display: block; }
  main { padding: 16px 16px 68px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 52px;
    background: #fff; border-top: 1px solid var(--line); z-index: 5;
  }
  .tabbar a { flex: 1; display: grid; place-items: center; border-radius: 0; color: #64748b; }
  .tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .cal-split, .dash-grid, .form-grid, .add-cat, .flow, .capital-form, .month-plan { grid-template-columns: 1fr; }
  .day { min-height: 52px; }
  .wide { grid-column: auto; }
}
