/* Котосовет — «cat» personal theme, carried over from the previous app. */
:root {
  --bg: 247 247 241; --surface: 255 254 250; --surface2: 237 240 230; --border: 217 222 211;
  --text: 23 46 39; --muted: 83 104 92; --accent: 25 64 49; --on-accent: 255 255 255;
  --pos: 69 111 82; --neg: 177 55 58; --warn: 156 96 24;
  --amount-in: 52 117 73; --amount-out: 165 82 47;
  --st-done: 52 117 73; --st-pending: 151 107 45; --st-overdue: 177 55 58; --st-cancelled: 110 118 110;
  --hero-surface: 227 237 211;
  --radius-card: 18px; --radius-btn: 10px;
  --shadow-card: 0 8px 26px -20px rgb(75 60 41 / .17);
  --forest: #183e33; --forest-deep: #133a32; --lime: #e1eda4; --cream: #fff4d8; --mint: #e5efdc;
  --serif: 'STIX Two Text', Georgia, serif;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
/* Dark mode, as in the first Kotosovet: the `dark` class on <html>, set before
   paint by the script in base.html from the saved choice (light, dark or system). */
html.dark {
  --bg: 29 32 28; --surface: 38 43 36; --surface2: 49 55 44; --border: 67 72 60;
  --text: 241 237 222; --muted: 179 180 160; --accent: 225 150 116; --on-accent: 39 27 21;
  --pos: 160 193 142; --neg: 248 145 138; --warn: 225 187 107;
  --amount-in: 150 200 140; --amount-out: 232 150 112;
  --st-done: 150 200 140; --st-pending: 214 182 120; --st-overdue: 248 145 138; --st-cancelled: 160 162 150;
  --hero-surface: 48 55 40;
  --shadow-card: 0 8px 26px -20px rgb(0 0 0 / .3);
  color-scheme: dark;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: rgb(var(--bg)); color: rgb(var(--text)); font: 400 15px/1.5 var(--sans);
  font-feature-settings: 'cv11', 'ss01'; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--serif); letter-spacing: -.04em; font-weight: 500; }
.icon { flex: none; }
.num { font-variant-numeric: lining-nums tabular-nums; }
.muted { color: rgb(var(--muted)); }
.small { font-size: .82rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; }
.muted a, .note a, .empty a:not([class]) { color: rgb(var(--accent)); text-decoration: underline; text-underline-offset: 3px; }

/* ---- Buttons & inputs ---- */
.btn-primary, .btn-ghost, .btn-soft, .btn-danger, .btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 41px; padding: 8px 15px;
  border-radius: 9px; font-size: .9rem; font-weight: 600; white-space: nowrap; transition: filter .15s, background-color .15s;
}
.btn-primary { background: rgb(var(--accent)); color: rgb(var(--on-accent)); }
.btn-primary:hover { filter: brightness(1.15); }
.btn-ghost { color: rgb(var(--text)); }
.btn-outline { color: rgb(var(--text)); background: rgb(var(--surface)); border: 1px solid rgb(var(--border)); }
.btn-outline:hover { background: rgb(var(--surface2)); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-ghost:hover { background: rgb(var(--surface2)); }
.btn-soft { background: rgb(var(--surface2)); color: rgb(var(--text)); min-height: 36px; padding: 7px 12px; font-size: .83rem; }
.btn-soft:hover { background: rgb(var(--hero-surface)); }
.btn-danger { background: rgb(var(--neg) / .1); color: rgb(var(--neg)); }
.btn-danger:hover { background: rgb(var(--neg) / .18); }
.btn-lg { min-height: 46px; width: 100%; font-size: .95rem; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; color: rgb(var(--muted)); }
.icon-btn:hover { background: rgb(var(--surface2)); color: rgb(var(--text)); }
.icon-btn-danger:hover { background: rgb(var(--neg) / .1); color: rgb(var(--neg)); }

.input { width: 100%; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1px solid rgb(var(--border)); border-radius: var(--radius-btn);
  background: rgb(var(--surface)); color: rgb(var(--text)); font-size: .95rem; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: rgb(var(--accent)); box-shadow: 0 0 0 3px rgb(var(--accent) / .18); }
.input:disabled { background: rgb(var(--surface2)); color: rgb(var(--muted)); cursor: not-allowed; }
.input[aria-invalid='true'], .field.has-error .input { border-color: rgb(var(--neg)); }
select.input { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2353685c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
input[type='date'].input { min-height: 44px; }
.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.label { display: block; font-size: .78rem; font-weight: 600; color: rgb(var(--muted)); padding: 0; }
.label em { font-style: normal; font-weight: 400; }
.hint { color: rgb(var(--muted)); font-size: .76rem; }
.field-error { color: rgb(var(--neg)); font-size: .8rem; font-weight: 500; }
.form-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: rgb(var(--neg) / .08); color: rgb(var(--neg)); font-size: .88rem; font-weight: 500; }
.form-alert .icon { margin-top: 1px; }
.form-alert p + p { margin-top: 4px; }

.segmented { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: rgb(var(--surface2)); width: fit-content; max-width: 100%; }
.segment { position: relative; }
.segment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segment span { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 7px 14px; border-radius: 9px;
  color: rgb(var(--muted)); font-size: .88rem; font-weight: 600; transition: background-color .15s, color .15s; }
.segment input:checked + span { background: rgb(var(--surface)); color: rgb(var(--text)); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }
.segment input:focus-visible + span { outline: 2px solid rgb(var(--accent)); outline-offset: 1px; }

/* ---- Shell: left rail, top bar, bottom nav on mobile ---- */
.pc-shell { min-height: 100dvh; }
.pc-rail { position: fixed; inset: 0 auto 0 0; width: 218px; z-index: 25; display: flex; flex-direction: column;
  padding: 30px 18px; background: rgb(var(--surface2)); border-right: 1px solid rgb(var(--border)); }
.pc-brand { display: inline-flex; align-items: center; gap: 10px; color: rgb(var(--text)); white-space: nowrap;
  font: 600 1.8rem/1 var(--serif); letter-spacing: -.055em; }
.pc-brand > span { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 12px; transform: rotate(-5deg);
  background: var(--forest); color: var(--lime); }
.pc-rail nav { display: grid; gap: 5px; margin-top: 45px; }
.pc-rail nav a, .pc-bottom a { display: flex; align-items: center; gap: 13px; border-radius: 9px; color: rgb(var(--muted)); font-weight: 550; }
.pc-rail nav a { padding: 12px 15px; transition: background-color .15s, color .15s; }
.pc-rail nav a:hover { color: rgb(var(--text)); background: rgb(var(--hero-surface) / .55); }
.pc-rail .pc-active, .pc-bottom .pc-active { background: rgb(var(--hero-surface)); color: rgb(var(--text)); }
.pc-rail-note { margin-top: auto; display: flex; gap: 10px; align-items: flex-start; padding: 14px; border-radius: 14px;
  background: rgb(var(--surface)); border: 1px solid rgb(var(--border)); color: rgb(var(--muted)); font-size: .8rem; line-height: 1.4; }
.pc-canvas { margin-left: 218px; min-width: 0; }
.pc-topbar { position: relative; z-index: 30; min-height: 63px; display: flex; align-items: center; justify-content: space-between;
  padding: 8px clamp(20px, 4vw, 60px); border-bottom: 1px solid rgb(var(--border)); }
.pc-crumb { display: flex; align-items: center; gap: 9px; font-size: .8rem; color: rgb(var(--muted)); }
.pc-crumb i { font-style: normal; }
.pc-crumb b { color: rgb(var(--text)); font-weight: 550; }
.pc-mobile-brand { display: none; }
.pc-tools { display: flex; align-items: center; gap: 12px; }
.pc-currency { display: inline-flex; align-items: center; gap: 2px; padding: 3px 3px 3px 9px; border-radius: 10px;
  background: rgb(var(--surface)); border: 1px solid rgb(var(--border)); color: rgb(var(--muted)); }
.pc-currency .icon { margin-right: 4px; }
.pc-currency button { min-width: 44px; min-height: 30px; padding: 0 8px; border-radius: 7px; font-size: .78rem; font-weight: 700;
  letter-spacing: .03em; color: rgb(var(--muted)); transition: background-color .15s, color .15s; }
.pc-currency button:hover { color: rgb(var(--text)); background: rgb(var(--surface2)); }
.pc-currency button.is-active { background: rgb(var(--accent)); color: rgb(var(--on-accent)); }
.pc-profile { position: relative; }
.pc-profile > summary { list-style: none; }
.pc-profile > summary::-webkit-details-marker { display: none; }
.pc-avatar { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; cursor: pointer;
  background: #e2c6a9; color: #3f352c; font-weight: 600; font-size: .9rem; user-select: none; }
.pc-profile-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px; z-index: 40;
  background: rgb(var(--surface)); border: 1px solid rgb(var(--border)); border-radius: 14px; box-shadow: 0 18px 40px -18px rgb(0 0 0 / .25); }
.pc-profile-name { padding: 8px 10px 10px; font-size: .82rem; color: rgb(var(--muted)); border-bottom: 1px solid rgb(var(--border));
  margin-bottom: 4px; overflow-wrap: anywhere; }
.pc-profile-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border-radius: 9px; font-size: .9rem; }
.pc-profile-menu button:hover { background: rgb(var(--surface2)); }
.pc-main { max-width: 1460px; margin: auto; padding: clamp(23px, 3vw, 48px) clamp(18px, 4vw, 60px) 60px; min-width: 0; }
.pc-bottom { display: none; }

/* ---- Toasts ---- */
.toasts { display: grid; gap: 8px; margin-bottom: 18px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 12px 11px 14px; border-radius: 12px; font-size: .9rem; font-weight: 500;
  background: rgb(var(--hero-surface)); color: rgb(var(--text)); animation: toast-in .25s ease-out; }
.toast-error { background: rgb(var(--neg) / .1); color: rgb(var(--neg)); }
.toast span { flex: 1; }
.toast-close { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; opacity: .7; }
.toast-close:hover { opacity: 1; background: rgb(0 0 0 / .06); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---- Page ---- */
.page { display: grid; gap: 20px; min-width: 0; }
.page-narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: clamp(2.2rem, 4vw, 3.6rem); line-height: 1.07; letter-spacing: -.05em; }
.page-narrow .page-head h1 { font-size: clamp(2rem, 3.4vw, 2.9rem); }
.page-sub { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: rgb(var(--muted)); font-size: .86rem; font-weight: 550; }
.back { display: inline-flex; align-items: center; gap: 6px; width: fit-content; min-height: 32px; color: rgb(var(--muted)); font-size: .84rem; font-weight: 600; }
.back:hover { color: rgb(var(--text)); }
.back + .page-head { margin-top: -10px; }
.panel { background: rgb(var(--surface)); border: 1px solid rgb(var(--border)); border-radius: 17px; padding: clamp(15px, 2.1vw, 25px); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel h2 { font-size: clamp(1.38rem, 2.1vw, 1.7rem); line-height: 1.1; }
.link-more { display: inline-flex; align-items: center; gap: 4px; min-height: 34px; color: rgb(var(--muted)); font-size: .8rem; font-weight: 600; }
.link-more:hover { color: rgb(var(--text)); }
.empty { display: grid; justify-items: start; align-content: center; gap: 10px; min-height: 130px; color: rgb(var(--muted)); font-size: .9rem; }
.empty p { max-width: 46ch; }
.note { display: flex; align-items: center; gap: 8px; color: rgb(var(--muted)); font-size: .84rem; }

/* ---- Capital hero ---- */
.capital { position: relative; isolation: isolate; overflow: hidden; container-type: inline-size; min-height: 250px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 22px; padding: clamp(20px, 2.6vw, 34px);
  border-radius: 17px; background: var(--forest-deep); color: var(--cream); }
.capital-art { position: absolute; z-index: -1; right: -3%; bottom: 0; width: 52%; height: 100%; object-fit: cover;
  mask-image: linear-gradient(90deg, transparent, black 26%); -webkit-mask-image: linear-gradient(90deg, transparent, black 26%); pointer-events: none; }
.capital-main { display: grid; gap: 10px; max-width: 68%; }
.capital-label { display: flex; align-items: center; gap: 7px; color: var(--mint); font-size: .88rem; font-weight: 550; }
.capital-number { display: block; white-space: nowrap; font: 500 min(clamp(2.3rem, 5vw, 4.4rem), calc(110cqi / var(--chars, 12))) / 1.05 var(--serif);
  letter-spacing: -.05em; }
.capital-number-muted { color: var(--mint); opacity: .7; }
.capital-hint { font-size: .78rem; color: var(--mint); max-width: 46ch; }

/* ---- Account cards ---- */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.acc-grid-wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.acc-card { display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 18px; border-radius: 15px;
  background: rgb(var(--surface)); border: 1px solid rgb(var(--border)); box-shadow: var(--shadow-card); }
.panel .acc-card { background: rgb(var(--bg)); box-shadow: none; }
.acc-card-head { display: flex; align-items: center; gap: 11px; }
.acc-card-head h3 { flex: 1; min-width: 0; font-size: 1.3rem; line-height: 1.15; overflow-wrap: anywhere; }
.acc-tile, .row-tile { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: #e8eddd; color: #3c6050; }
.acc-grid > :nth-child(4n+2) .acc-tile { background: #fae3c9; color: #865738; }
.acc-grid > :nth-child(4n+3) .acc-tile { background: #e5e5f1; color: #575370; }
.acc-grid > :nth-child(4n+4) .acc-tile { background: #e1ebee; color: #4f6974; }
.acc-balances { display: grid; }
.acc-balance { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid rgb(var(--border)); }
.acc-balance dd { font-size: 1.12rem; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.acc-balance dd.acc-pending { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; font-weight: 500; color: rgb(var(--muted)); }
.cur-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; background: rgb(var(--surface2)); color: rgb(var(--muted));
  font-size: .72rem; font-weight: 700; letter-spacing: .05em; }

/* ---- Income rows ---- */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 11px 0; border-top: 1px solid rgb(var(--border)); }
.row:first-child { border-top: 0; padding-top: 0; }
.row:last-child { padding-bottom: 0; }
.tile-salary { background: #e8eddd; color: #3c6050; }
.tile-other { background: #fae3c9; color: #865738; }
.tile-expense { background: #f5dfce; color: #924629; }
.row-amount.row-amount-out { color: rgb(var(--text)); }
.row-note { display: inline-flex !important; align-items: center; gap: 5px; margin-top: 3px; color: rgb(var(--warn)) !important; }
.balance-note { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 10px;
  background: rgb(var(--warn) / .1); color: rgb(var(--warn)); font-size: .85rem; font-weight: 500; }
.balance-note .icon { margin-top: 2px; }
.row-main { flex: 1; min-width: 0; }
.row-main strong, .row-main small { display: block; overflow-wrap: anywhere; }
.row-main strong { font-size: .95rem; font-weight: 600; }
.row-main small { color: rgb(var(--muted)); font-size: .8rem; }
.row-amount { color: rgb(var(--pos)); font-size: 1rem; font-weight: 600; text-align: right; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; }

/* ---- Forms ---- */
.form-panel { display: grid; gap: 20px; }
.fields-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding-top: 6px; }
[data-salary-only][hidden] { display: none; }
.currency-rows-head { display: grid; gap: 4px; padding-top: 16px; border-top: 1px solid rgb(var(--border)); }
.currency-rows-head h2 { font-size: 1.4rem; }
.currency-rows { display: grid; gap: 10px; }
.currency-row { display: grid; grid-template-columns: minmax(90px, .7fr) minmax(0, 1.2fr) minmax(0, 1.1fr) 40px; align-items: start; gap: 12px;
  padding: 14px; border-radius: 13px; background: rgb(var(--bg)); border: 1px solid rgb(var(--border)); }
.currency-row .row-errors { grid-column: 1 / -1; }
.currency-row-remove { padding-top: 26px; display: grid; justify-items: center; }
.remove-toggle { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; color: rgb(var(--muted)); cursor: pointer; }
.remove-toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.remove-toggle:hover { background: rgb(var(--neg) / .1); color: rgb(var(--neg)); }
.remove-toggle:has(input:focus-visible) { outline: 2px solid rgb(var(--accent)); }
.currency-row:has(.remove-toggle input:checked) { border-style: dashed; background: rgb(var(--neg) / .05); }
.currency-row:has(.remove-toggle input:checked) .field { opacity: .45; }
.currency-row:has(.remove-toggle input:checked) .remove-toggle { background: rgb(var(--neg) / .14); color: rgb(var(--neg)); }
.currency-row:has(.remove-toggle input:checked)::after { content: 'Валюту буде прибрано після збереження'; grid-column: 1 / -1;
  color: rgb(var(--neg)); font-size: .8rem; font-weight: 500; }
.add-currency { width: fit-content; }

.confirm { display: grid; gap: 12px; justify-items: start; }
.confirm h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); }
.confirm-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: rgb(var(--neg) / .1); color: rgb(var(--neg)); }
.confirm .form-actions { justify-self: stretch; }

/* ---- Auth & error pages ---- */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); }
.auth-art { position: relative; overflow: hidden; background: var(--forest-deep); }
.auth-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; gap: 14px; width: 100%; max-width: 440px; margin: 0 auto; padding: 48px 28px; }
.auth-panel .pc-brand { margin-bottom: 26px; }
.auth-panel h1 { font-size: clamp(2.2rem, 4vw, 3rem); line-height: 1.05; }
.form-stack { display: grid; gap: 16px; margin-top: 12px; }
.error-page { min-height: 100dvh; display: grid; place-content: center; justify-items: start; gap: 12px; padding: 32px; max-width: 560px; margin: 0 auto; }
.error-code { font: 500 4.5rem/1 var(--serif); color: rgb(var(--muted)); letter-spacing: -.05em; }
.error-page h1 { font-size: clamp(2rem, 4vw, 2.8rem); }

/* ---- Responsive ---- */
@media (max-width: 980px) and (min-width: 721px) {
  .pc-rail { width: 172px; padding: 22px 10px; }
  .pc-rail .pc-brand { font-size: 1.45rem; gap: 7px; }
  .pc-rail-note { display: none; }
  .pc-canvas { margin-left: 172px; }
  .pc-main, .pc-topbar { padding-left: 20px; padding-right: 20px; }
}
@media (max-width: 720px) {
  .pc-rail, .pc-crumb { display: none; }
  .pc-canvas { margin: 0; }
  .pc-mobile-brand { display: inline-flex; font-size: 1.45rem; }
  .pc-mobile-brand > span { width: 30px; height: 30px; border-radius: 9px; }
  .pc-tools { gap: 8px; }
  .pc-currency { padding-left: 3px; }
  .pc-currency .icon { display: none; }
  .pc-currency button { min-width: 40px; }
  .pc-topbar { min-height: 55px; padding: 7px 14px; }
  .pc-main { padding: 16px 13px calc(90px + env(safe-area-inset-bottom)); }
  .pc-bottom { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; inset: auto 0 0 0; z-index: 25;
    padding: 5px 3px calc(5px + env(safe-area-inset-bottom)); background: rgb(var(--surface)); border-top: 1px solid rgb(var(--border)); }
  .pc-bottom a { flex-direction: column; justify-content: center; gap: 1px; min-height: 46px; font-size: .68rem; }
  .pc-bottom .pc-active { background: transparent; }
  .pc-bottom .pc-active .icon { background: rgb(var(--hero-surface)); border-radius: 12px; }
  .pc-bottom .icon { padding: 3px 13px; box-sizing: content-box; }
  .page { gap: 14px; }
  .page-head h1 { font-size: 2.1rem; }
  .page-head :is(.btn-primary, .btn-outline) { min-height: 40px; padding: 7px 12px; font-size: .84rem; }
  .capital { min-height: 220px; padding: 19px; }
  .capital-main { max-width: 100%; }
  .capital-art { width: 60%; opacity: .55; }
  .capital-number { font-size: min(clamp(2.1rem, 10vw, 3.2rem), calc(108cqi / var(--chars, 12))); }
  .fields-2 { grid-template-columns: minmax(0, 1fr); }
  .currency-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; }
  .currency-row .field:nth-of-type(3) { grid-column: 1 / 3; }
  .currency-row-remove { grid-column: 3; grid-row: 1; }
  .row { flex-wrap: wrap; gap: 6px 12px; }
  .row-main { flex-basis: calc(100% - 50px); }
  .row-amount { margin-left: 50px; flex: 1; text-align: left; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { min-height: 190px; }
  .auth-panel { justify-content: flex-start; padding: 28px 20px 40px; }
  .auth-panel .pc-brand { margin-bottom: 8px; }
  .input { font-size: 16px; }
}
html.dark .acc-tile, html.dark .row-tile, html.dark .tile-salary { background: rgb(var(--hero-surface)); color: rgb(var(--pos)); }
html.dark .acc-grid > :nth-child(n) .acc-tile { background: rgb(var(--hero-surface)); color: rgb(var(--pos)); }
html.dark .tile-other, html.dark .tile-expense { background: rgb(var(--accent) / .16); color: rgb(var(--accent)); }
html.dark .pc-brand > span { background: var(--lime); color: var(--forest); }
html.dark select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b3b4a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
html.dark .toast-close:hover { background: rgb(255 255 255 / .08); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---- Month total (incomes / expenses) ---- */
.month-total { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.month-switch { display: flex; align-items: center; gap: 6px; }
.month-switch h2 { min-width: 9ch; text-align: center; font-size: clamp(1.2rem, 1.8vw, 1.45rem); }
.month-prev svg { transform: rotate(180deg); }
.month-total-value { display: grid; justify-items: end; gap: 3px; text-align: right; }
.month-total-number { font-size: clamp(1.5rem, 2.4vw, 2rem); font-weight: 600; line-height: 1.1; }
.month-total-muted { color: rgb(var(--muted)); }

/* ---- Actual amount in the account's currency ---- */
.amount-with-code { display: flex; align-items: center; gap: 8px; }
.amount-with-code .input { flex: 1; min-width: 0; }
.suggestion-apply { justify-self: start; width: fit-content; }

/* ---- Capital overview: available, actual, reserved ---- */
/* Text and illustration get their own columns: the cat never sits under a figure.
   The layout follows the card's own width (container query), not the viewport. */
.capital-overview { display: block; overflow: visible; padding: 0; min-height: 0; }
.capital-layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(150px, 34cqi, 380px); min-height: 250px; }
.capital-overview .capital-main { grid-column: 1; grid-row: 1; max-width: none; gap: 12px; align-content: start;
  padding: clamp(20px, 2.6vw, 34px); container-type: inline-size; min-width: 0; position: relative; z-index: 2; }
.capital-overview .capital-main > * { max-width: 560px; }
.capital-art-cell { grid-column: 2; grid-row: 1; position: relative; min-width: 0; overflow: hidden; border-radius: 0 17px 17px 0; }
.capital-overview .capital-art { position: absolute; inset: 0; z-index: auto; width: 100%; height: 100%; object-fit: cover;
  object-position: 62% 100%; opacity: 1; mask-image: linear-gradient(90deg, transparent, black 30%);
  -webkit-mask-image: linear-gradient(90deg, transparent, black 30%); }
@container (max-width: 760px) {
  .capital-layout { grid-template-columns: minmax(0, 1fr) clamp(120px, 28cqi, 200px); }
}
@container (max-width: 480px) {
  .capital-layout { grid-template-columns: minmax(0, 1fr); }
  .capital-art-cell { display: none; }
}
.capital-negative { color: #f6b0a6; }
.capital-bar { display: flex; gap: 4px; height: 6px; max-width: 520px; }
.capital-bar span { flex: 0 1 auto; min-width: 6px; border-radius: 99px; }
.bar-free, .dot-free { background: var(--lime); }
.bar-reserved, .dot-reserved { background: #e0b65a; }
.bar-savings, .dot-savings { background: #8eaec4; }
.dot { display: inline-block; flex: none; width: 8px; height: 8px; margin-right: 3px; border-radius: 50%; vertical-align: 1px; }
.capital-facts { display: grid; max-width: 520px; margin: 0; }
.capital-facts > div { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 40px; border-top: 1px solid rgb(255 255 255 / .12); }
.capital-facts dt { display: flex; align-items: center; gap: 4px; color: var(--mint); font-size: .86rem; font-weight: 500; }
.capital-facts dd { margin: 0; color: var(--cream); font-size: 1.12rem; font-weight: 600; text-align: right; }

/* Reserve tooltip: hover on devices that hover, click/tap everywhere. */
.tip-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; margin: -4px 0; border-radius: 8px; color: var(--mint); }
.tip-btn:hover, .tip.is-open .tip-btn { background: rgb(255 255 255 / .1); color: var(--cream); }
.tip-panel { display: none; position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: min(360px, calc(100vw - 32px));
  padding: 16px; border-radius: 14px; background: rgb(var(--surface)); color: rgb(var(--text)); border: 1px solid rgb(var(--border));
  box-shadow: 0 18px 40px -18px rgb(0 0 0 / .35); }
.tip-panel::before { content: ""; position: absolute; inset: -10px 0 auto; height: 10px; }
.tip.is-open .tip-panel { display: block; }
@media (hover: hover) { .tip:hover .tip-panel { display: block; } }
.tip-title { font-weight: 700; font-size: .98rem; }
.tip-lead { margin-top: 4px; color: rgb(var(--muted)); font-size: .78rem; line-height: 1.45; }
.tip-items { display: grid; margin-top: 10px; }
.tip-items li { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid rgb(var(--border)); }
.tip-items b { display: block; font-size: .86rem; font-weight: 600; }
.tip-items small, .tip-amount small { display: block; color: rgb(var(--muted)); font-size: .74rem; font-weight: 500; }
.tip-amount { font-size: .9rem; font-weight: 700; text-align: right; white-space: nowrap; }
.tip-empty { margin-top: 10px; color: rgb(var(--muted)); font-size: .84rem; }
.tip-total { display: flex; justify-content: space-between; gap: 12px; margin-top: 4px; padding-top: 10px; border-top: 1px solid rgb(var(--border));
  font-weight: 700; }

/* ---- Planned operations ---- */
.month-name { min-width: 9ch; text-align: center; font-weight: 600; }
.rows-title { margin: 4px 0 6px; color: rgb(var(--muted)); font-size: .78rem; font-weight: 650; letter-spacing: .03em; text-transform: uppercase; }
.rows + .rows-title { margin-top: 18px; }
.date-tile { flex: none; display: grid; place-items: center; align-content: center; width: 46px; height: 50px; border-radius: 12px;
  background: rgb(var(--surface2)); line-height: 1.05; }
.date-tile b { font-size: 1.1rem; font-weight: 700; }
.date-tile small { color: rgb(var(--muted)); font-size: .72rem; font-weight: 550; }
.plan-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.plan-line .row-amount { margin: 0; text-align: left; }
.state { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 650;
  background: rgb(var(--surface2)); color: rgb(var(--muted)); }
.state-overdue { background: rgb(var(--neg) / .1); color: rgb(var(--neg)); }
.state-confirmed { background: rgb(var(--pos) / .14); color: rgb(var(--pos)); }
.plan-overdue .date-tile { background: rgb(var(--neg) / .1); color: rgb(var(--neg)); }
.plan-overdue .date-tile small { color: inherit; }
.plan-cancelled .row-main strong, .plan-cancelled .row-amount { color: rgb(var(--muted)); text-decoration: line-through; }
.plan-confirmed .row-main strong { color: rgb(var(--muted)); }
.plan-actions { display: flex; align-items: center; gap: 2px; }
.plan-actions form { display: contents; }
.btn-compact { min-height: 36px; padding: 6px 13px; font-size: .84rem; margin-right: 4px; }
.tag-personal { display: inline-block !important; width: fit-content; margin-top: 3px; padding: 1px 7px; border-radius: 6px;
  background: rgb(var(--surface2)); color: rgb(var(--muted)) !important; font-size: .7rem !important; font-weight: 600; }

/* ---- Checkboxes ---- */
.checks { display: grid; gap: 14px; }
.check { display: flex; align-items: flex-start; gap: 10px; width: fit-content; cursor: pointer; }
.check input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: rgb(var(--accent)); }
.check b { display: block; font-size: .9rem; font-weight: 600; }
.check small { display: block; color: rgb(var(--muted)); font-size: .78rem; }

@media (max-width: 720px) {
  .capital-facts dd { font-size: 1.02rem; }
  .tip-panel { left: -6px; right: -6px; width: auto; }
  .plan-line .row-amount { flex: none; }
  .plan-row { align-items: flex-start; }
  .plan-row .row-main { flex: 1; flex-basis: calc(100% - 60px); }
  .plan-actions { width: 100%; justify-content: flex-end; }
  .plan-actions:empty { display: none; }
  .pc-bottom a { font-size: .64rem; }
  .pc-bottom .icon { padding: 3px 10px; }
}

/* ---- Dialog: every form page can open inside it ---- */
.modal { width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 18px;
  background: rgb(var(--surface)); color: rgb(var(--text)); box-shadow: 0 30px 70px -30px rgb(0 0 0 / .45); overflow: hidden; }
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgb(20 30 25 / .45); }
.modal-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px 4px 22px; }
.modal-title { font: 500 1.45rem/1.15 var(--serif); letter-spacing: -.04em; min-width: 0; overflow-wrap: anywhere; }
.modal-content { overflow-y: auto; overflow-x: hidden; padding: 4px 22px 22px; overscroll-behavior: contain; }
.modal-content .back, .modal-content .page-head h1 { display: none; }
.modal-content .page-head:not(:has(.page-sub)) { display: none; }
.modal-content .page-head .page-sub { margin-top: 0; }
.modal-content .page { gap: 12px; }
.modal-content .page-narrow { max-width: none; }
.modal-content .panel { border: 0; padding: 0; border-radius: 0; }
.modal-content .form-panel { gap: 16px; }
.modal-content .form-actions { position: sticky; bottom: -22px; margin: 0 -22px -22px; padding: 12px 22px calc(14px + env(safe-area-inset-bottom));
  background: rgb(var(--surface)); border-top: 1px solid rgb(var(--border)); }
.toast-warning { background: rgb(var(--warn) / .12); color: rgb(var(--warn)); }

/* ---- Operation entry ---- */
.fields-amount { display: grid; grid-template-columns: minmax(0, 1fr) minmax(96px, 130px); gap: 12px; }
.segmented-kind .segment span { min-height: 34px; padding: 5px 14px; }
.link-add { display: inline-flex; align-items: center; gap: 5px; width: fit-content; min-height: 28px; color: rgb(var(--accent));
  font-size: .8rem; font-weight: 600; }
.link-add:hover { text-decoration: underline; text-underline-offset: 3px; }
.quick-account { display: grid; gap: 12px; padding: 14px; border-radius: 13px; background: rgb(var(--bg)); border: 1px dashed rgb(var(--border)); }
.quick-account-title { font-weight: 700; }
.quick-account .form-actions { position: static; margin: 0; padding: 0; border: 0; background: none; }
.plan-note, .note-box { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 10px;
  background: rgb(var(--surface2)); color: rgb(var(--text)); font-size: .85rem; font-weight: 500; }
.plan-note .icon, .note-box .icon { margin-top: 2px; flex: none; color: rgb(var(--muted)); }
.note-box a { color: rgb(var(--accent)); text-decoration: underline; text-underline-offset: 3px; }
.repeat { display: grid; gap: 12px; }
.repeat-more { display: grid; gap: 12px; padding-left: 28px; }
.repeat-more .field { max-width: 260px; }
.form-actions-start { margin-right: auto; }

.panel-head .month-switch h2 { min-width: 9ch; text-align: center; font-size: clamp(1.2rem, 1.8vw, 1.45rem); }

/* ---- Dashboard additions ---- */
.capital-facts dt .dot { margin-right: 4px; }
.fact-warn { padding: 1px 6px; border-radius: 6px; background: rgb(255 255 255 / .12); font-size: .7rem; }
.tip-note { margin-top: 8px; padding: 8px 10px; border-radius: 9px; background: rgb(var(--surface2)); font-size: .76rem; line-height: 1.4; }
.tip-note-warn, .tip-deficit { color: rgb(var(--warn)) !important; }
.tip-warn b { color: rgb(var(--warn)); }
.panel-warn { border-color: rgb(var(--warn) / .45); background: rgb(var(--warn) / .05); }
.panel-warn .muted { max-width: 80ch; }
.rows-compact { margin-top: 10px; }
.rows-compact .row { min-height: 52px; padding: 8px 0; }
.rows-compact .row:first-child { padding-top: 8px; border-top: 1px solid rgb(var(--border)); }
.neg { color: rgb(var(--neg)); }

/* ---- Savings on account cards ---- */
.acc-savings { display: grid; gap: 6px; padding: 0 0 10px; }
.acc-split { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; color: rgb(var(--muted)); font-size: .8rem; }
.acc-split b { color: rgb(var(--text)); font-weight: 600; }
.acc-allocations { display: grid; gap: 2px; }
.acc-allocations li { display: flex; justify-content: space-between; gap: 10px; font-size: .8rem; color: rgb(var(--muted)); }
.acc-allocations a { color: rgb(var(--text)); text-decoration: underline; text-decoration-color: rgb(var(--border)); text-underline-offset: 3px;
  overflow-wrap: anywhere; }
.acc-allocations li .dot { margin-top: 6px; }
.acc-save { width: fit-content; margin-top: auto; }
.savings-preview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.savings-preview > div { padding: 10px 12px; border-radius: 11px; background: rgb(var(--surface2)); min-width: 0; }
.savings-preview dt { color: rgb(var(--muted)); font-size: .74rem; font-weight: 600; }
.savings-preview dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .modal { width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .modal-bar { padding: 10px 8px 2px 16px; }
  .modal-content { padding: 4px 16px 22px; }
  .modal-content .form-actions { margin: 0 -16px -22px; padding-left: 16px; padding-right: 16px; }
  .fields-amount { grid-template-columns: minmax(0, 1fr) 96px; }
  .repeat-more { padding-left: 0; }
  .repeat-more .field { max-width: none; }
  .tabs { width: 100%; }
  .tab { flex: 1; justify-content: center; padding: 6px 8px; }
  .savings-preview { grid-template-columns: minmax(0, 1fr); }
  .savings-preview > div { display: flex; justify-content: space-between; gap: 10px; }
  .page-head > .btn-primary { width: 100%; }
}

/* ---- Theme switch (profile menu) ---- */
.pc-theme { display: grid; gap: 6px; padding: 8px 10px 10px; border-bottom: 1px solid rgb(var(--border)); margin-bottom: 4px; }
.pc-theme-label { font-size: .74rem; font-weight: 600; color: rgb(var(--muted)); }
.pc-theme .segmented { width: 100%; flex-wrap: nowrap; }
.pc-profile-menu:has(.pc-theme) { min-width: 280px; }
.pc-theme .segment { flex: 1; }
.pc-theme .segment span { justify-content: center; width: 100%; min-height: 32px; padding: 5px 8px; font-size: .8rem; }

/* ---- Disabled select: no chevron (the shorthand would tile it) ---- */
select.input:disabled, html.dark select.input:disabled { background-image: none; cursor: not-allowed; }

/* ---- Status pill: the same in every list ---- */
.status { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 650;
  white-space: nowrap; line-height: 1.5; }
.status .icon { width: 12px; height: 12px; }
.status-done { background: rgb(var(--st-done) / .14); color: rgb(var(--st-done)); }
.status-pending { background: rgb(var(--st-pending) / .13); color: rgb(var(--st-pending)); }
.status-overdue { background: rgb(var(--st-overdue) / .12); color: rgb(var(--st-overdue)); }
.status-cancelled { background: rgb(var(--st-cancelled) / .14); color: rgb(var(--st-cancelled)); }
.amount-income { color: rgb(var(--amount-in)); }
.amount-expense { color: rgb(var(--amount-out)); }

/* ---- One list of operations ---- */
.op-list { display: grid; margin: 0; padding: 0; list-style: none; }
.op-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 0; border-top: 1px solid rgb(var(--border)); }
.op-list > .op-row:first-child, .op-group + .op-row { border-top: 0; }
.op-main { flex: 1; min-width: 0; }
.op-main strong, .op-main small { display: block; overflow-wrap: anywhere; }
.op-main strong { font-size: .95rem; font-weight: 600; }
.op-main small { color: rgb(var(--muted)); font-size: .8rem; }
.op-repeat { display: inline-flex; vertical-align: -1px; margin-left: 6px; color: rgb(var(--muted)); }
.op-side { display: grid; justify-items: end; gap: 4px; }
.op-amount { font-size: 1rem; font-weight: 650; white-space: nowrap; }
.op-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; min-width: 76px; }
.op-actions form { display: contents; }
.op-actions .btn-compact { margin-right: 2px; }
.op-overdue .date-tile { background: rgb(var(--st-overdue) / .1); color: rgb(var(--st-overdue)); }
.op-overdue .date-tile small { color: inherit; }
.op-cancelled .op-main strong, .op-cancelled .op-amount { color: rgb(var(--muted)); text-decoration: line-through; }
.op-group { margin: 14px 0 4px; color: rgb(var(--muted)); font-size: .74rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.op-group:first-child { margin-top: 0; }
.op-list-compact .op-row { min-height: 56px; }
.op-list-compact .op-actions { min-width: 0; }

/* ---- Month bar and filters ---- */
.month-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.month-bar .month-switch h2 { min-width: 9ch; margin: 0; text-align: center; font-size: clamp(1.15rem, 1.7vw, 1.4rem); }
.month-sums { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0; }
.month-sums div { display: grid; gap: 1px; }
.month-sums dt { color: rgb(var(--muted)); font-size: .74rem; font-weight: 600; }
.month-sums dd { margin: 0; font-size: 1rem; font-weight: 650; white-space: nowrap; }
.month-sums-total { padding-left: 22px; border-left: 1px solid rgb(var(--border)); }
.month-hint { margin: 8px 0 0; }
.list-filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 18px 0 10px; }
.filters { display: flex; gap: 4px; width: fit-content; max-width: 100%; padding: 4px; border-radius: 12px; background: rgb(var(--surface2)); overflow-x: auto; }
.filter { display: inline-flex; align-items: center; min-height: 34px; padding: 5px 14px; border-radius: 9px; color: rgb(var(--muted));
  font-size: .86rem; font-weight: 600; white-space: nowrap; }
.filter:hover { color: rgb(var(--text)); }
.filter.is-active { background: rgb(var(--surface)); color: rgb(var(--text)); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }

/* ---- Dashboard: recent pair and the account-less notice ---- */
.dash-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: inherit; }
.notice-line { border: 1px solid rgb(var(--warn) / .4); border-radius: var(--radius-card); background: rgb(var(--warn) / .06); }
.notice-line summary { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 8px 16px; color: rgb(var(--warn));
  font-size: .9rem; font-weight: 600; cursor: pointer; list-style: none; }
.notice-line summary::-webkit-details-marker { display: none; }
.notice-line summary b { margin-left: auto; text-decoration: underline; text-underline-offset: 3px; }
.notice-line[open] summary b { display: none; }
.notice-body { padding: 0 16px 12px; }
.notice-body .op-row { min-height: 54px; }

@media (max-width: 720px) {
  .op-row { flex-wrap: wrap; align-items: flex-start; gap: 8px 12px; }
  .op-main { flex-basis: calc(100% - 160px); }
  .op-actions { width: 100%; min-width: 0; }
  .op-actions:empty { display: none; }
  .op-list-compact .op-actions, .notice-body .op-actions { width: auto; }
  .month-sums { width: 100%; justify-content: space-between; gap: 6px 12px; }
  .month-sums-total { padding-left: 12px; }
}

/* ---- Savings inside the account form ---- */
.currency-savings { grid-column: 1 / -1; display: grid; gap: 8px; padding-top: 12px; border-top: 1px dashed rgb(var(--border)); }
.currency-savings-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.currency-savings-head .btn-compact { margin: 0; }
.currency-savings-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.currency-savings-list li { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: .9rem; }
.currency-savings-list li > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.currency-savings-list .num { color: rgb(var(--muted)); white-space: nowrap; }
.currency-savings-actions { display: flex; gap: 2px; }
