/* Spend — budget tracker */

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 100px; }
.hide-sm { }
.head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.month-nav { display: flex; align-items: center; gap: 10px; }
.month-label { min-width: 170px; text-align: center; font-size: 1.7rem; font-weight: 800; letter-spacing: -.05em; line-height: 1; }
.month-label em { font-size: 1.1em; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.cur .select { width: auto; padding: 10px 34px 10px 14px; border-radius: 999px; font-size: .84rem; }

.stage { transition: opacity .35s, transform .5s var(--ease-out); }
.stage.swap { opacity: 0; transform: translateY(10px); }
.pad { padding: 24px; }

/* ───── KPIs ───── */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }
.kpi { padding: 22px 24px; display: grid; gap: 6px; align-content: start; position: relative; overflow: hidden; }
.kpi-num { font-size: clamp(2rem, 3.6vw, 2.9rem); font-weight: 800; letter-spacing: -.06em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi:nth-child(1) .kpi-num { color: var(--ok); }
.kpi-net { background: linear-gradient(145deg, #f2f3fd, #e4e8fb); }
.kpi-net .kpi-num { color: var(--accent-lo); }
.chip-delta { justify-self: start; font: 700 .72rem var(--sans); padding: 5px 10px; border-radius: 999px; background: var(--bg-soft); color: var(--ink-2); min-height: 26px; display: inline-flex; align-items: center; gap: 5px; }
.chip-delta.good { background: rgba(63,154,130,.12); color: #2c7561; } .chip-delta.bad { background: rgba(194,90,112,.12); color: var(--bad); }
.chip-delta:empty { display: none; }
.rate { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(82,96,189,.1); }
.rate i { position: absolute; inset: 0; background: linear-gradient(90deg, var(--accent-soft), var(--accent)); transform-origin: 0 50%; transform: scaleX(0); transition: transform 1.2s var(--ease-out); }

/* ───── charts ───── */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.donut-wrap { display: grid; grid-template-columns: 210px 1fr; gap: 22px; align-items: center; }
.donut { position: relative; width: 210px; height: 210px; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.d-track { fill: none; stroke: var(--bg-soft); stroke-width: 24; }
.arc { fill: none; stroke-width: 24; stroke-dasharray: 0 100; stroke-dashoffset: 0; transition: stroke-dasharray 1.1s var(--ease-out), stroke-dashoffset 1.1s var(--ease-out), stroke-width .35s var(--ease-out), opacity .35s; cursor: pointer; outline: none; }
.donut.has-hover .arc:not(.hot) { opacity: .28; }
.arc.hot { stroke-width: 29; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 0 38px; pointer-events: none; }
.donut-center small { font: 500 .62rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.donut-center b { font-size: 1.55rem; font-weight: 800; letter-spacing: -.05em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.donut-center span { font: 600 .74rem var(--sans); color: var(--accent); min-height: 1em; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.legend li button { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 12px; cursor: pointer; font-size: .86rem; font-weight: 600; color: var(--ink-2); transition: background .25s; }
.legend li button:hover, .legend li button.hot { background: var(--bg-soft); color: var(--ink); }
.legend li button:focus-visible { outline: 2px solid var(--accent); }
.legend li button.sel { background: var(--accent-ghost); color: var(--accent-lo); }
.legend i { width: 12px; height: 12px; border-radius: 4px; }
.legend b { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); font-size: .82rem; }
.legend li.zero { opacity: .45; }

.key { display: flex; gap: 14px; font: 500 .66rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.key i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.k-in { background: var(--ok); opacity: .75; } .k-out { background: var(--accent); }
.trend { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; height: 224px; align-items: stretch; }
.t-col { position: relative; display: grid; grid-template-rows: 1fr auto; gap: 10px; cursor: pointer; border-radius: 14px; padding: 4px 2px 0; transition: background .3s; outline: none; }
.t-col:hover, .t-col:focus-visible { background: var(--bg-soft); }
.t-col.sel { background: var(--accent-ghost); }
.t-bars { display: flex; align-items: flex-end; justify-content: center; gap: 5px; }
.t-bar { width: 38%; max-width: 22px; border-radius: 8px 8px 4px 4px; height: 0; transition: height 1.1s var(--ease-out); }
.t-bar.in { background: linear-gradient(180deg, #6fc0a8, #a5d6c8); }
.t-bar.out { background: linear-gradient(180deg, var(--accent), var(--accent-soft)); }
.t-lbl { text-align: center; font: 500 .66rem var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding-bottom: 6px; }
.t-col.sel .t-lbl { color: var(--accent-lo); font-weight: 500; }
.t-tip { position: absolute; left: 50%; top: 4px; transform: translate(-50%, -10%) scale(.9); background: var(--ink); color: #fff; padding: 8px 11px; border-radius: 11px; font: 600 .72rem var(--sans); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .25s, transform .35s var(--ease-spring); z-index: 3; line-height: 1.5; }
.t-col:hover .t-tip, .t-col:focus-visible .t-tip { opacity: 1; transform: translate(-50%, -105%) scale(1); }
.t-tip span { display: block; opacity: .7; font-weight: 500; }

/* ───── lower ───── */
.lower { display: grid; grid-template-columns: .82fr 1.18fr; gap: 18px; align-items: start; }
.budgets { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.bud-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; font-size: .88rem; font-weight: 700; }
.bud-head span:first-child { display: inline-flex; align-items: center; gap: 9px; }
.bud-head i { width: 10px; height: 10px; border-radius: 3px; }
.bud-head small { font: 500 .7rem var(--mono); color: var(--muted); letter-spacing: .02em; }
.bud-head small b { color: var(--ink); font-weight: 500; }
.bud-track { height: 9px; border-radius: 9px; background: var(--bg-soft); overflow: hidden; }
.bud-fill { height: 100%; width: 0; border-radius: 9px; background: var(--accent); transition: width 1.2s var(--ease-out), background .4s; }
.bud-fill.warn { background: var(--warn); } .bud-fill.over { background: var(--bad); }
.bud-note { font-size: .72rem; margin-top: 6px; color: var(--muted); } .bud-note.over { color: var(--bad); font-weight: 600; } .bud-note.warn { color: #9a6a22; font-weight: 600; }
.empty-s { font-size: .86rem; color: var(--muted); margin: 6px 0 0; }

.tools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 200px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 42px; border-radius: 999px; padding-top: 11px; padding-bottom: 11px; }
.seg { display: inline-flex; background: var(--bg-soft); border-radius: 999px; padding: 4px; gap: 2px; position: relative; }
.seg button { border: 0; background: none; font: 700 .8rem var(--sans); color: var(--ink-2); padding: 8px 14px; border-radius: 999px; cursor: pointer; transition: background .3s, color .3s, box-shadow .3s; position: relative; z-index: 1; }
.seg button.on { background: #fff; color: var(--accent-lo); box-shadow: 0 2px 8px rgba(18,20,43,.1); }
.seg.big { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 18px; }
.seg.big button { padding: 11px; font-size: .9rem; background: none; box-shadow: none; }
.seg.big button.on { background: none; box-shadow: none; }
.seg-ink { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px; background: #fff; box-shadow: 0 2px 10px rgba(18,20,43,.12); transition: transform .55s var(--ease-out), background .4s; }
.seg.big[data-k="income"] .seg-ink { transform: translateX(100%); }
.seg.big[data-k="expense"] button[data-k="expense"], .seg.big[data-k="income"] button[data-k="income"] { color: var(--accent-lo); }

.day { margin-top: 14px; }
.day-head { display: flex; justify-content: space-between; font: 500 .66rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 8px 6px; position: sticky; top: 64px; background: rgba(255,255,255,.9); z-index: 2; border-radius: 10px; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.row { display: grid; grid-template-columns: 42px 1fr auto; gap: 14px; align-items: center; width: 100%; text-align: left; padding: 10px 8px; border-radius: 16px; border: 0; background: none; cursor: pointer; transition: background .25s, transform .4s var(--ease-out); animation: rowIn .6s var(--ease-out) backwards; animation-delay: calc(var(--n, 0) * 35ms); }
@keyframes rowIn { from { opacity: 0; transform: translateY(12px); } }
.row:hover { background: var(--bg-soft); transform: translateX(3px); }
.row.flash { animation: rowFlash 1.6s var(--ease-out); }
@keyframes rowFlash { 0% { background: var(--accent-tint); transform: scale(1.02); } 100% { background: transparent; transform: none; } }
.ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, white); color: color-mix(in srgb, var(--c) 78%, #14183a); }
.ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.r-main { min-width: 0; } .r-main b { display: block; font-size: .92rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .r-main small { color: var(--muted); font-size: .76rem; font-weight: 600; }
.r-amt { font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; font-size: .98rem; } .r-amt.pos { color: var(--ok); }
.more { width: 100%; margin-top: 14px; }

.empty { text-align: center; padding: 34px 10px 18px; color: var(--ink-2); }
.empty svg { width: 120px; margin: 0 auto 14px; color: var(--accent-soft); }
.empty h3 { margin: 0 0 6px; font-size: 1.15rem; letter-spacing: -.03em; } .empty p { margin: 0 0 18px; font-size: .9rem; color: var(--muted); }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ───── dialogs ───── */
.amount { position: relative; }
.amount em { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font: normal 800 1.5rem var(--sans); color: var(--muted); letter-spacing: -.04em; }
.amount .input { font-size: 1.9rem; font-weight: 800; letter-spacing: -.05em; padding: 14px 16px 14px 44px; }
.amount-field { margin-bottom: 14px; }
.err { color: var(--bad); font-weight: 600; font-size: .78rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.sheet-actions.between { align-items: center; } .grow { flex: 1; }
.bud-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.bud-grid label.field > span { display: flex; align-items: center; gap: 8px; }
.bud-grid i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.data-actions { display: grid; gap: 8px; }
.data-row { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 3px; padding: 15px 18px; border-radius: 18px; background: var(--bg-soft); transition: background .25s, transform .35s var(--ease-out); }
.data-row:hover { background: var(--accent-tint); transform: translateX(4px); } .data-row:focus-visible { outline: 2px solid var(--accent); }
.data-row b { font-size: .95rem; } .data-row small { color: var(--muted); font-size: .8rem; }
.data-row.danger:hover { background: rgba(194,90,112,.12); } .data-row.danger b { color: var(--bad); }

@media (max-width: 960px) {
  .charts, .lower { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .kpis { grid-template-columns: 1fr; gap: 12px; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .legend { width: 100%; }
  .month-label { min-width: 0; font-size: 1.35rem; }
  .head { flex-direction: column; align-items: stretch; }
  .head-actions { justify-content: space-between; }
  .hide-sm { display: none; }
  .two, .bud-grid { grid-template-columns: 1fr; }
  .day-head { top: 58px; }
}
