@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
}

:root {
  --navy: #001155;
  --navy-hover: #001a77;
  --navy-gradient:
    linear-gradient(135deg, rgba(0, 17, 85, 0.96), rgba(0, 104, 180, 0.82)),
    var(--navy);
  --white: #ffffff;
  --gray: #f8f8f8;
  --accent: #0068b4;
  --gray-mid: #e6e8ee;
  --ink: #001155;
  --muted: #4b5568;
  --chart-tooltip-bg: #596375;
  --line: #e2e5ee;
  --danger: #d32f2f;
  --alert-yellow: #f2c94c;
  --alert-orange: #c84a00;
  --success: #1b5e20;
  --flow-income: var(--navy);
  --flow-expense: #af2b1e;
  --flow-saving: #a5b45e;
  --flow-saving-text: #596b22;
  --flow-available: #31adbe;
  --flow-available-text: #147483;
  --flow-extraordinary: #e32065;
  --income-salary: #191970;
  --income-atelier: #003153;
  --income-thirteenth: #305cde;
  --income-bonus: #560591;
  --expense-housing: #a52019;
  --expense-obligation: #75151e;
  --expense-health: #a12312;
  --expense-mobility: #a2231d;
  --expense-household: #781f19;
  --expense-communication: #642424;
  --expense-leisure: #ea899a;
  --expense-personal: #c1876b;
  --expense-education: #d36e70;
  --flow-living: var(--flow-expense);
  --flow-obligation: var(--expense-obligation);
  --saving-regular: #596b22;
  --saving-youth: #718235;
  --saving-pillar: #879746;
  --saving-amortization: #9aab52;
  --saving-purpose: #b4c375;
  --available-before-saving: #147483;
  --available-potential: #31adbe;
  --available-daily: #8ad9e1;
  --extra-income: #b0005a;
  --extra-expense: #f23d72;
  --extra-balance: #8e2a68;
  --ist-good: #c8e6c9;
  --ist-ok: #e8f5e9;
  --ist-warn: #ffebee;
  --ist-over: #ffcdd2;
  --shadow: 0 4px 16px rgba(0, 17, 85, 0.08);
  --radius: 16px;
  --radius-btn: 12px;
  --font: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-ui: 0.9rem;
  --text-base: 1rem;
  --text-title: 1.25rem;
  --text-large: 1.5rem;
  --text-display: clamp(2.65rem, 6vw, 4rem);
  --control-size: var(--text-base);
  --control-height: 42px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  color: var(--ink);
  background: var(--gray);
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.45;
}

body.is-data-loading main,
body.is-data-loading .nav {
  visibility: hidden;
}

.login-page {
  min-height: 100vh;
  background: var(--navy-gradient);
}

.login-product-link {
  position: fixed;
  z-index: 10;
  top: max(20px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  color: var(--white);
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
}

.login-product-link:hover {
  color: #dbeffc;
}

.login-product-link:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 4px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 430px);
  padding: 32px;
}

.login-card h1 {
  margin: 4px 0 8px;
  color: var(--navy);
}

.login-card .eyebrow {
  color: var(--accent);
}

.login-intro {
  margin: 0 0 24px;
  color: var(--muted);
}

.login-demo {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  text-align: center;
}

.login-demo-start {
  color: var(--navy);
  font-weight: 700;
  text-decoration: none;
}

.login-demo-start:hover {
  color: var(--accent);
}

.login-form > .status:empty {
  display: none;
}

.offline-retry {
  display: block;
  text-align: center;
  text-decoration: none;
}

.is-standalone .nav,
.is-standalone .recent-link,
.is-standalone .login-product-link {
  display: none;
}

.is-standalone .topbar-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
}

.is-standalone .topbar-inner > div:first-child {
  display: contents;
}

.is-standalone .topbar-inner .eyebrow {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
}

.is-standalone .topbar-inner h1 {
  grid-column: 1;
  grid-row: 2;
}

.is-standalone .topbar-account {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-self: end;
}

.is-standalone .demo-controls {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-self: end;
}

.is-standalone .quick-categories {
  min-width: 0;
}

.is-standalone .quick-category-buttons {
  max-width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.is-standalone .quick-category-buttons::-webkit-scrollbar {
  display: none;
}

.is-standalone .quick-category-button {
  flex: 0 0 auto;
  min-height: var(--control-height);
  padding-block: 9px;
}

.push-card {
  display: none;
}

.push-card::backdrop {
  background: rgba(0, 17, 85, 0.68);
  backdrop-filter: blur(3px);
}

.is-standalone .push-card[open] {
  display: grid;
  width: min(620px, calc(100% - 32px));
  height: fit-content;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 28px;
  overflow-y: auto;
  gap: 20px;
  grid-auto-rows: max-content;
  align-content: start;
  border: 1px solid var(--line);
  background: var(--white);
  box-shadow: 0 24px 70px rgba(0, 17, 85, 0.24);
}

.push-card h2:focus {
  outline: none;
}

.push-eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.push-copy {
  max-width: 620px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: var(--text-ui);
}

.push-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  justify-content: flex-start;
  gap: 8px;
}

.push-actions .primary {
  width: 100%;
  height: var(--control-height);
  flex: 1 0 100%;
  margin: 0;
  padding: 9px 14px;
  min-height: var(--control-height);
  font-size: var(--text-ui);
}

.push-actions .link-btn {
  height: var(--control-height);
  min-height: var(--control-height);
  padding: 9px 14px;
  font-size: var(--text-ui);
  font-weight: 600;
  line-height: 1.2;
}

.push-card > .status {
  grid-column: 1 / -1;
  margin: 0;
}

.push-card > .status:empty {
  display: none;
}

.is-standalone .captured-by-field {
  display: none;
}

.login-form,
.household-setup {
  display: grid;
  gap: 16px;
}

.household-setup {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 24px;
}

.household-setup h2,
.household-setup p {
  margin: 0;
}

.data-load-error {
  padding-top: 32px;
}

.sync-error-banner {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-btn);
  background: var(--white);
  color: var(--danger);
  box-shadow: var(--shadow);
  font-size: var(--text-sm);
  font-weight: 600;
}

.topbar {
  background: var(--navy-gradient);
  color: var(--white);
}

.is-standalone .topbar {
  background: var(--navy);
}

.financial-alert {
  width: 100%;
  color: var(--white);
}

.financial-alert-good {
  background: var(--success);
}

.financial-alert-ok {
  background: #2e7d32;
}

.financial-alert-yellow {
  background: var(--alert-yellow);
  color: var(--navy);
}

.financial-alert-orange {
  background: var(--alert-orange);
}

.financial-alert-red {
  background: var(--danger);
}

.financial-alert-inner {
  max-width: 1180px;
  min-height: 50px;
  margin: 0 auto;
  padding: 7px 20px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  font-size: var(--text-ui);
  font-weight: 500;
  line-height: 1.45;
}

.financial-alert-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1;
}

.financial-alert-message {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.financial-alert-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.financial-alert-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.financial-alert-yellow .financial-alert-close:hover {
  background: rgba(0, 17, 85, 0.1);
}

.financial-alert-close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

.financial-alert-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: var(--text-xs);
  color: #c9d0e8;
}

.topbar-inner .eyebrow {
  white-space: nowrap;
}

h1,
h2,
h3 {
  font-family: inherit;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--white);
}

.demo-title-mark {
  position: relative;
  display: inline-block;
}

.is-demo-mode .demo-title-mark::after {
  content: "";
  position: absolute;
  right: -0.05em;
  bottom: -0.08em;
  left: -0.05em;
  height: 0.14em;
  border-radius: 999px;
  background: #f03a47;
}

.demo-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.nav .demo-exit {
  margin-left: auto;
  padding: 8px 0 8px 12px;
  font-size: var(--text-ui);
  line-height: normal;
}

.demo-exit {
  margin: 0;
  border: 0;
  border-radius: 3px;
  padding: 0;
  background: transparent;
  color: var(--white);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.3;
  text-align: right;
  cursor: pointer;
}

.demo-exit:hover {
  color: #c9d0e8;
}

.demo-exit:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 3px;
}

.topbar-account {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.topbar-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  padding: 0;
  background: var(--white);
  color: var(--navy);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.topbar-avatar:hover {
  background: #f1f3f9;
}

.topbar-avatar:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 4px;
}

.account-panel {
  position: absolute;
  inset: calc(100% + 10px) 0 auto auto;
  z-index: 60;
  width: min(320px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  overflow-y: auto;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(0, 17, 85, 0.2);
  text-align: left;
}

.account-panel[open] {
  display: grid;
  height: fit-content;
  gap: 18px;
  grid-auto-rows: max-content;
  align-content: start;
}

.account-panel::backdrop {
  background: rgba(0, 17, 85, 0.6);
  backdrop-filter: blur(2px);
}

.account-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
}

.account-panel-label {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-panel-close {
  display: grid;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  margin: 0;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: var(--navy);
  cursor: pointer;
}

.account-panel-close:hover {
  background: var(--gray);
}

.account-panel-close:focus-visible,
.account-sign-out:focus-visible,
.account-setting:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.account-panel-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.account-profile-summary {
  display: grid;
  justify-items: center;
  min-width: 0;
  text-align: center;
}

.account-profile-avatar {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin-bottom: 14px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: var(--navy);
  color: var(--white);
  font-family: inherit;
  font-size: var(--text-large);
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: none;
}

.account-profile-avatar:not(:disabled) {
  cursor: pointer;
}

.account-profile-avatar:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.account-profile-avatar:disabled {
  opacity: 1;
}

.account-profile-summary h2 {
  max-width: 100%;
  margin: 0;
  color: var(--navy);
  font-size: var(--text-base);
  overflow-wrap: anywhere;
}

.account-profile-summary h2:focus {
  outline: none;
}

.account-profile-email {
  max-width: 100%;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.account-demo-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-ui);
  line-height: 1.45;
}

.account-sign-out {
  justify-self: center;
  align-self: start;
  height: var(--control-height);
  min-height: var(--control-height);
  margin: -2px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  padding: 9px 14px;
  background: var(--white);
  color: var(--navy);
  font-family: inherit;
  font-size: var(--text-ui);
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
}

.account-sign-out:hover {
  border-color: var(--navy);
  background: var(--gray);
}

.account-sign-out:disabled {
  cursor: wait;
  opacity: 0.55;
}

.account-panel-settings {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.account-setting {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin: 0;
  border: 0;
  border-radius: var(--radius-btn);
  padding: 7px 8px;
  background: transparent;
  color: var(--navy);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.account-setting:hover {
  background: var(--gray);
}

.account-setting[aria-disabled="true"] {
  cursor: wait;
  opacity: 0.65;
}

.account-setting > svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.account-setting > span:not(.account-setting-switch) {
  display: grid;
  gap: 1px;
}

.account-setting strong {
  font-size: var(--text-ui);
  font-weight: 600;
}

.account-setting small {
  color: var(--muted);
  font-size: var(--text-xs);
}

.account-setting .account-setting-chevron {
  width: 17px;
  height: 17px;
}

.account-setting-toggle {
  grid-template-columns: 22px minmax(0, 1fr) 36px;
}

.account-setting-switch {
  position: relative;
  width: 36px;
  height: 22px;
  border-radius: 999px;
  background: var(--line);
  transition: background-color 160ms ease;
}

.account-setting-switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0, 17, 85, 0.24);
  content: "";
  transition: transform 160ms ease;
}

.account-setting-toggle[aria-checked="true"] .account-setting-switch {
  background: var(--navy);
}

.account-setting-toggle[aria-checked="true"] .account-setting-switch::after {
  transform: translateX(14px);
}

.account-panel-status {
  margin: 0;
  color: var(--danger);
  font-size: var(--text-sm);
  text-align: center;
}

.account-panel-status:empty {
  display: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 14px;
}

.nav a {
  color: #c9d0e8;
  text-decoration: none;
  font-size: var(--text-ui);
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
}

.nav a:hover,
.nav a.is-active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
}

.page-stack {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.recent-card {
  background: #eef3f9;
}

.recent-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.recent-link {
  color: var(--navy);
  font-size: var(--text-ui);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: var(--text-ui);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-actions .primary {
  width: auto;
}

.capture-form-actions .primary {
  flex: 1;
  white-space: nowrap;
}

.entry-form-actions .primary,
.entry-form-actions .link-btn {
  height: var(--control-height);
  min-height: var(--control-height);
  margin-top: 0;
  font-size: var(--text-ui);
}

.entry-form-actions .primary {
  padding: 0 16px;
}

.entry-form-actions .link-btn {
  padding: 0 10px;
}

.entry-actions {
  display: flex;
  gap: 6px;
}

.entry-actions .link-btn {
  font-size: var(--text-sm);
  font-weight: 400;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 24px;
  align-items: start;
}

.overview-column {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.capture-card {
  position: sticky;
  top: 16px;
}

.capture-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.card .capture-heading h2,
.card .overview-head h2 {
  margin-right: auto;
  margin-bottom: 0;
}

.entry-edit-delete {
  display: inline-grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  background: var(--white);
  color: var(--navy);
  cursor: pointer;
}

.entry-edit-delete[hidden] {
  display: none;
}

.entry-edit-delete svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.entry-edit-delete:hover {
  border-color: var(--navy);
  background: var(--gray);
}

.entry-edit-delete:focus-visible,
.entry-tap:focus-visible,
.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.entry-edit-delete:disabled {
  cursor: wait;
  opacity: 0.55;
}

.control-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.control-filters .field {
  margin: 0;
  min-width: 140px;
}

.control-filters [hidden] {
  display: none;
}

.budget-year-controls {
  align-items: center;
}

.control-filters .budget-year-control {
  flex: 0 0 120px;
  min-width: 120px;
}

.budget-year-controls .link-btn {
  min-height: var(--control-height);
  padding-right: 14px;
  padding-left: 14px;
}

.compare-head,
.compare-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) repeat(4, minmax(4.5rem, 1fr));
  gap: 8px;
  align-items: center;
  text-align: right;
  font-size: var(--text-sm);
  font-weight: 400;
}

.compare-head {
  color: var(--muted);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
}

.compare-head span:first-child,
.compare-row > span:first-child {
  text-align: left;
}

#control-breakdown .compare-row,
#control-breakdown .compare-row .cat-label,
#control-breakdown details > summary.compare-row,
#control-breakdown .compare-sub {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--ink);
}

#control-breakdown .compare-row .icon {
  width: 14px;
  height: 14px;
}

.compare-ist {
  justify-self: stretch;
  text-align: right;
  padding: 0;
}

.compare-ist > .value-fill,
.compare-diff > .value-fill {
  display: inline-block;
  box-sizing: border-box;
  min-width: 50%;
  border-radius: 8px;
  padding: 4px 8px;
}

.compare-ist-good > .value-fill {
  background: var(--ist-good);
}

.compare-ist-ok > .value-fill {
  background: var(--ist-ok);
}

.compare-ist-warn > .value-fill {
  background: var(--ist-warn);
}

.compare-ist-over > .value-fill {
  background: var(--ist-over);
}

.compare-diff {
  justify-self: stretch;
  padding: 0;
}

.compare-diff-good > .value-fill {
  background: var(--ist-good);
}

.compare-diff-ok > .value-fill {
  background: var(--ist-ok);
}

.compare-diff-warn > .value-fill {
  background: var(--ist-warn);
}

.compare-diff-over > .value-fill {
  background: var(--ist-over);
}

#control-breakdown .compare-row .compare-ist.positive,
#control-breakdown .compare-row .compare-diff.positive,
#control-breakdown .matrix-month.positive,
#control-breakdown .matrix-year-ist.positive,
#control-breakdown .matrix-diff.positive {
  color: var(--success);
  font-weight: 600;
}

#control-breakdown .compare-row .compare-ist.negative,
#control-breakdown .compare-row .compare-diff.negative,
#control-breakdown .matrix-month.negative,
#control-breakdown .matrix-year-ist.negative,
#control-breakdown .matrix-diff.negative {
  color: var(--danger);
  font-weight: 600;
}

#control-breakdown .compare-row span.warn {
  color: #b45309;
  font-weight: 600;
}

#control-breakdown .compare-row span.over {
  color: var(--danger);
  font-weight: 600;
}

#control-breakdown .compare-total {
  border-top: 2px solid var(--navy);
  margin-top: 8px;
  padding-top: 10px;
  color: var(--ink);
  font-weight: 700;
}

#control-breakdown .compare-extra-row {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.statement-kpis {
  margin: 0;
}

.statement-kpis .stat {
  min-width: 0;
}

.statement-kpis .stat.accent {
  background: var(--navy-gradient);
}

.statement-kpis .stat.accent .stat-meta {
  overflow-wrap: anywhere;
  white-space: normal;
}

#control-breakdown details > summary.compare-row {
  display: grid;
  font-size: var(--text-sm);
  font-weight: 700;
}

#control-breakdown details > summary.compare-row .cat-label,
#control-breakdown details > summary.compare-row .compare-diff.positive,
#control-breakdown details > summary.compare-row .compare-diff.negative,
#control-breakdown details > summary.compare-row span.warn,
#control-breakdown details > summary.compare-row span.over {
  font-weight: 700;
}

#control-breakdown details li.compare-row {
  display: grid;
  justify-content: stretch;
  color: var(--ink);
}

.page-budget {
  display: grid;
  gap: 24px;
}

.budget-section-title {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.budget-form,
#budget-fields {
  display: grid;
  gap: 24px;
}

.budget-cat-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px;
  gap: 8px 12px;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.budget-cat-summary::-webkit-details-marker {
  display: none;
}

.budget-cat-summary .cat-label {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.budget-cat-panel {
  padding-top: 4px;
}

.budget-cat-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px 48px;
  gap: 8px 12px;
  align-items: end;
  padding: 12px 0 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.budget-cat-cols-total,
.budget-cat-foot-total {
  grid-template-columns: minmax(0, 1fr) 110px 110px;
}

.budget-cat-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px 48px;
  gap: 8px 12px;
  align-items: center;
  padding-top: 14px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  font-weight: 700;
}

.budget-col-label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  text-align: right;
}

.budget-cat-total,
.budget-cat-month {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.budget-amt-year,
.budget-amt-month {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.budget-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.budget-item:last-child {
  border-bottom: 0;
}

.budget-item-top {
  display: none;
}

.budget-item-title {
  margin: 0 0 8px;
  font-weight: 400;
}

.budget-item-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px 48px;
  gap: 12px;
  align-items: center;
}

.budget-item-body.budget-item-no-fix {
  grid-template-columns: minmax(0, 1fr) 110px 110px;
}

.budget-item .field {
  margin-bottom: 0;
}

.budget-item-amounts {
  display: contents;
}

.budget-salary-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  min-width: 0;
  align-items: end;
}

.budget-salary-thomas {
  grid-template-columns: repeat(4, minmax(88px, 1fr));
}

.budget-factor-field {
  width: 60px;
  max-width: 60px;
  justify-self: start;
}

.budget-factor-field input {
  padding-left: 6px;
  padding-right: 6px;
}

.budget-year-field {
  max-width: 180px;
}

.budget-group-block {
  padding: 8px 0 0;
}

.budget-group-title {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: var(--text-ui);
  font-weight: 600;
}

.budget-sub-summary,
.budget-hypo-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px 48px;
  grid-template-rows: var(--control-height);
  column-gap: 12px;
  align-items: center;
  position: relative;
  z-index: 1;
  padding: 0;
  cursor: pointer;
  list-style: none;
}

.budget-sub-summary::-webkit-details-marker,
.budget-hypo-summary::-webkit-details-marker {
  display: none;
}

.budget-sub-summary .cat-label,
.budget-hypo-summary .cat-label {
  display: flex;
  align-items: center;
  min-height: var(--control-height);
}

.budget-sub-summary .budget-amt-year,
.budget-sub-summary .budget-amt-month,
.budget-hypo-summary .budget-amt-year,
.budget-hypo-summary .budget-amt-month {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: var(--control-height);
}

.budget-amt-year.is-total,
.budget-amt-month.is-total {
  font-weight: 700;
}

.budget-sub-summary,
.budget-sub-summary .cat-label,
.budget-sub-summary .budget-amt-year.is-total,
.budget-sub-summary .budget-amt-month.is-total {
  font-weight: 600;
}

.budget-fix-spacer {
  display: block;
  min-height: var(--control-height);
}

.budget-fold-body {
  position: relative;
  z-index: 0;
}

.budget-fold:not([open]),
.budget-hypo:not([open]) {
  padding-bottom: 4px;
}

.budget-item-hypo {
  padding: 14px 0;
}

.budget-item-hypo > .budget-calc {
  margin: 0;
}

.budget-calc.budget-hypo {
  padding: 0;
  background: var(--gray);
}

.budget-hypo-fields {
  grid-template-columns: repeat(4, minmax(88px, 1fr));
}

.budget-rate-field {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
  justify-self: start;
}

.budget-rate-field input {
  padding-left: 6px;
  padding-right: 6px;
}

.budget-hypo-part {
  padding: 10px 0;
  border-bottom: 0;
}

.budget-hypo-part {
  padding: 10px 0;
  border-bottom: 0;
}

.budget-hypo-part .budget-item-title {
  margin: 0 0 8px;
}

.budget-item-body > .budget-calc {
  grid-column: 1;
}

.budget-item-income .budget-item-body {
  align-items: end;
}

.budget-item-income .budget-amt-year,
.budget-item-income .budget-amt-month,
.budget-item-income .budget-fix {
  box-sizing: border-box;
  height: 42px;
  min-height: 42px;
  display: flex;
  align-items: center;
}

.budget-item-income .budget-amt-year,
.budget-item-income .budget-amt-month {
  justify-content: flex-end;
}

.budget-fix {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  gap: 6px;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.budget-fix input[type="checkbox"] {
  accent-color: var(--navy);
}

.budget-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  align-self: end;
  padding-bottom: 8px;
}

.budget-salary-fields select,
.budget-salary-fields input,
.budget-dual-input,
.budget-num {
  width: 100%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.budget-item-dual .budget-item-title {
  margin: 0;
}

.budget-dual-input.is-computed,
input.is-computed {
  background: var(--gray);
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.budget-fold {
  margin: 8px 0 12px;
}

.budget-fold .budget-item {
  padding: 10px 0;
}

.budget-fold .budget-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.budget-calc .budget-item-dual {
  padding-top: 10px;
}

.budget-breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px;
  gap: 12px;
  align-items: center;
}

.budget-breakdown-row .budget-item-title {
  margin: 0;
}

.budget-breakdown-row .budget-item-amounts {
  display: contents;
}

.budget-calc {
  background: var(--gray);
  border-radius: var(--radius-btn);
  padding: 4px 0 10px;
  border-top: 0;
}

.budget-calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 8px;
}

.budget-calc-result {
  margin: 12px 0 0;
  font-weight: 600;
}

.card {
  min-width: 0;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card h2 {
  margin-bottom: 18px;
  font-size: var(--text-title);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.segmented label {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--gray-mid);
  border-radius: var(--radius-btn);
  cursor: pointer;
  background: var(--white);
}

.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.segmented input:checked + span {
  color: var(--white);
  font-weight: 600;
}

.segmented label {
  font-size: var(--text-ui);
}

.segmented label:has(input:checked) {
  border-color: var(--navy);
  background: var(--navy);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  min-width: 0;
}

.field span {
  font-size: var(--text-ui);
  color: var(--muted);
  font-weight: 500;
}

.currency-amount-field > label {
  color: var(--muted);
  font-size: var(--text-ui);
  font-weight: 500;
}

.currency-amount-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 8px;
}

.currency-conversion {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.2;
}

.currency-conversion.is-error {
  color: var(--danger);
}

.quick-categories {
  margin: -2px 0 14px;
}

.quick-categories-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: var(--text-ui);
  font-weight: 500;
}

.quick-category-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-category-button {
  border: 1px solid #c7dceb;
  border-radius: var(--radius-btn);
  padding: 5px 9px;
  background: #f2f7fb;
  color: var(--navy);
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: 400;
  line-height: 1.2;
}

.quick-category-button:hover {
  border-color: var(--accent);
  background: #e7f1f8;
}

.quick-category-button:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

input,
select,
textarea {
  font-family: var(--font);
  font-size: var(--control-size);
}

button {
  font-family: var(--font);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: var(--control-height);
  border: 1px solid var(--gray-mid);
  border-radius: var(--radius-btn);
  padding: 0 12px;
  background: var(--white);
  color: var(--ink);
}

input[type="file"] {
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--gray-mid);
  border-radius: var(--radius-btn);
  padding: 6px;
  background: var(--white);
  color: var(--ink);
}

input[type="file"]::file-selector-button {
  margin-right: 10px;
  border: 0;
  border-radius: calc(var(--radius-btn) - 3px);
  padding: 7px 10px;
  background: var(--navy);
  color: var(--white);
  cursor: pointer;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="month"],
input[type="date"] {
  display: block;
}

input[type="month"]::-webkit-date-and-time-value,
input[type="date"]::-webkit-date-and-time-value {
  min-height: 1.2em;
  text-align: left;
}

@supports (-webkit-touch-callout: none) {
  input[type="month"],
  input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    line-height: calc(var(--control-height) - 2px);
  }

  input[type="month"]::-webkit-date-and-time-value,
  input[type="date"]::-webkit-date-and-time-value {
    display: flex;
    align-items: center;
    height: calc(var(--control-height) - 2px);
    min-height: calc(var(--control-height) - 2px);
    line-height: calc(var(--control-height) - 2px);
  }

  input[type="month"]::-webkit-datetime-edit,
  input[type="date"]::-webkit-datetime-edit {
    display: flex;
    align-items: center;
    height: 100%;
    padding-block: 0;
    line-height: calc(var(--control-height) - 2px);
  }
}

input::-webkit-datetime-edit,
input::-webkit-datetime-edit-fields-wrapper,
input::-webkit-datetime-edit-text,
input::-webkit-datetime-edit-month-field,
input::-webkit-datetime-edit-day-field,
input::-webkit-datetime-edit-year-field {
  font-family: inherit;
  font-size: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 72px;
  border: 1px solid var(--gray-mid);
  border-radius: var(--radius-btn);
  padding: 10px 12px;
  background: var(--white);
  color: var(--ink);
  resize: vertical;
}

textarea.note-input {
  height: var(--control-height);
  min-height: var(--control-height);
  padding: 9px 12px;
}

.row {
  display: grid;
  grid-template-columns: 1fr;
}

.primary {
  width: 100%;
  margin-top: 6px;
  border: 0;
  background: var(--navy);
  color: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-size: var(--text-ui);
  font-weight: 600;
  line-height: 1.2;
}

.primary:hover {
  background: var(--navy-hover);
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.data-form {
  max-width: 560px;
  margin-top: 18px;
}

.data-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.data-actions .primary {
  margin-top: 0;
}

.data-actions .link-btn {
  padding: 12px 16px;
  color: var(--navy);
  font-size: var(--text-ui);
  font-weight: 600;
}

.budget-form > .status:empty {
  display: none;
}

.status {
  min-height: 1.2em;
  margin: 10px 0 0;
  font-size: var(--text-ui);
  color: var(--navy);
}

.status.error {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 40;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%) translateY(8px);
  background: var(--white);
  color: var(--navy);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow);
  padding: 10px 16px;
  font-size: var(--text-ui);
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.overview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.link-btn {
  border: 1px solid var(--gray-mid);
  background: var(--white);
  color: var(--navy);
  border-radius: var(--radius-btn);
  padding: 6px 10px;
  cursor: pointer;
  font-size: var(--text-ui);
  font-weight: 600;
  line-height: 1.2;
  color: var(--muted);
}

.confirm-card[open] {
  display: grid;
  width: min(420px, calc(100% - 32px));
  margin: auto;
  padding: 24px;
  gap: 20px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--navy);
  box-shadow: 0 24px 70px rgba(0, 17, 85, 0.24);
}

.confirm-card::backdrop {
  background: rgba(0, 17, 85, 0.68);
  backdrop-filter: blur(3px);
}

.card.confirm-card h2 {
  margin: 0;
}

.confirm-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--text-ui);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-actions .primary,
.confirm-actions .link-btn {
  width: auto;
  min-height: var(--control-height);
  margin: 0;
  padding: 9px 14px;
  font-size: var(--text-ui);
  font-weight: 600;
}

.weekly-check-card[open] {
  width: min(500px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.weekly-check-card h2:focus {
  outline: none;
}

.weekly-check-eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.weekly-check-period-block {
  margin-top: 18px;
}

.weekly-check-card.is-combined #monthly-check-section {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.weekly-check-section-label {
  margin: 0;
  color: var(--navy);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.weekly-check-section-label + .weekly-check-period {
  margin-top: 3px;
}

.weekly-check-period,
.weekly-check-question {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: var(--text-ui);
}

.weekly-check-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.weekly-check-stat {
  min-width: 0;
  border-radius: var(--radius-btn);
  padding: 12px;
  background: var(--gray);
}

.weekly-check-stat span {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
}

.weekly-check-stat strong {
  display: block;
  margin-top: 4px;
  font-size: var(--text-base);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.weekly-check-question {
  margin-top: 18px;
  color: var(--navy);
  font-weight: 600;
}

.weekly-check-status:empty {
  display: none;
}

.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.totals.totals-wide {
  grid-template-columns: repeat(3, 1fr);
}

.overview-totals {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 0;
}

.expense-overview {
  margin: 18px -24px -24px;
  overflow: hidden;
  border-radius: 0 0 var(--radius) var(--radius);
}

.expense-overview-content {
  padding: 18px 24px 16px;
}

.expense-overview-heading h3 {
  margin: 0;
  color: var(--navy);
  font-size: var(--text-ui);
}

.expense-overview-question {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.expense-overview-rows {
  display: grid;
  gap: 14px;
  margin-top: 17px;
}

.expense-row-head,
.expense-total-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.expense-row-head > span {
  min-width: 0;
  overflow: hidden;
  font-size: var(--text-xs);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expense-row-head > strong {
  flex: none;
}

.expense-category-amount {
  color: var(--navy);
  font-size: var(--text-xs);
  font-weight: 400;
  text-align: right;
  white-space: nowrap;
}

.expense-total-status {
  color: var(--navy);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: right;
}

.expense-budget-over {
  color: var(--danger);
}

.expense-row-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--stats-category-color);
}

.expense-share-bar {
  display: block;
  width: 100%;
  height: 7px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
}

.expense-share-track {
  fill: var(--gray-mid);
}

.bar-fill-line {
  stroke-width: 7px;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.expense-share-fill-line {
  stroke: var(--stats-category-color);
}

.expense-total-progress .expense-share-fill-line {
  stroke: var(--flow-expense);
}

.funds-use-saving-line {
  stroke: var(--flow-saving-text);
}

.expense-share-over-line {
  stroke: var(--danger);
}

.expense-share-fill {
  fill: var(--stats-category-color);
}

.expense-share-over {
  fill: var(--danger);
}

.expense-overview-total {
  margin-top: 16px;
  padding-top: 14px;
}

.saving-goal-total {
  margin-top: 14px;
  padding-top: 0;
}

.expense-total-head {
  font-size: var(--text-xs);
  font-weight: 700;
}

.expense-total-progress {
  height: 7px;
  margin-top: 8px;
}

.expense-total-fill {
  fill: var(--flow-expense);
}

.funds-use-saving-dot {
  background: var(--flow-saving-text);
}

.funds-use-saving-amount {
  color: var(--navy);
}

.funds-use-expense-fill {
  fill: var(--flow-expense);
}

.funds-use-shortfall-fill {
  fill: var(--danger);
}

.funds-use-limit-marker {
  stroke: var(--danger);
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.saving-goal-marker {
  stroke: var(--navy);
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.expense-total-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

.expense-overview-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-height: var(--control-height);
  margin: 0;
  border: 0;
  padding: 8px 16px;
  background: var(--white);
  color: var(--navy);
  font-family: inherit;
  font-size: var(--text-ui);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.expense-overview-toggle:hover {
  background: var(--white);
}

.expense-overview-toggle:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: -3px;
}

.expense-overview-toggle svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.expense-overview.is-expanded .expense-overview-toggle svg {
  transform: rotate(180deg);
}

.totals.totals-wide.statement-kpis {
  grid-template-columns: repeat(4, 1fr);
}

.budget-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.totals-extra {
  display: grid;
  justify-items: center;
  margin: -6px 0 18px;
}

.totals-extra .stat {
  width: min(100%, 280px);
}

.stat {
  background: var(--gray);
  border-radius: var(--radius-btn);
  padding: 14px;
}

.stat.accent {
  background: var(--navy-gradient);
  color: var(--white);
}

.stat.accent-soft {
  background: var(--accent);
  color: var(--white);
}

.stat.accent-soft .stat-label,
.stat.accent-soft .stat-value {
  color: var(--white);
}

.stat.accent .stat-label,
.stat.accent .stat-value {
  color: var(--white);
}

.stat-label {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.stat-value {
  margin: 6px 0 0;
  font-size: var(--text-title);
  font-weight: 700;
}

.stat-meta {
  margin: 4px 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
  white-space: pre-line;
}

.stat.accent .stat-meta {
  white-space: normal;
}

.stat.accent .stat-meta,
.stat.accent-soft .stat-meta {
  color: rgba(255, 255, 255, 0.8);
}

.stat-value.income {
  color: var(--flow-income);
}

.stat-value.saving {
  color: var(--flow-saving-text);
}

.statement-kpis .stat-value.saving {
  color: var(--navy);
}

.stat-value.expense {
  color: var(--flow-expense);
}

.stat-value.negative {
  color: var(--danger);
}

.stat.accent-soft .stat-value.negative,
.stat.accent .stat-value.negative {
  color: #ffd6dc;
}

.breakdown-block {
  margin-bottom: 18px;
}

.breakdown-block h3,
#entries h3 {
  margin-bottom: 10px;
  font-size: var(--text-base);
}

details {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.chevron {
  width: 0.7em;
  color: var(--accent);
  font-size: var(--text-xs);
}

.chevron::before {
  content: "▶";
}

details[open] > summary .chevron::before {
  content: "▼";
}

.nested {
  margin-left: 12px;
  padding-left: 8px;
  border-left: 2px solid var(--line);
}

.nested details {
  border-top: 0;
}

.cat-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon {
  width: 16px;
  height: 16px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

summary::-webkit-details-marker {
  display: none;
}

details ul {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

details li,
.entry {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  color: var(--muted);
}

.empty {
  color: var(--muted);
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.entry-status {
  margin-left: 6px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
}

.entry.is-budget {
  background: #eef3f9;
  border-radius: 10px;
  padding: 8px 10px;
}

.entry {
  align-items: flex-start;
  border-top: 1px solid var(--line);
  padding: 12px 0;
  color: var(--ink);
}

.entry.entry-tappable {
  display: block;
  padding: 0;
}

.entry-tap {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
  gap: 12px;
  padding: 10px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.entry-tap:active {
  background: rgba(0, 104, 180, 0.08);
}

.entry-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.entry-copy .entry-note {
  margin: 0;
}

.entry-meta {
  margin: 0;
}

.entry-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.entry-side {
  display: grid;
  justify-items: end;
  gap: 6px;
  white-space: nowrap;
}

.entry.income .entry-side strong {
  color: var(--flow-income);
}

.entry.expense .entry-side strong {
  color: var(--flow-expense);
}

.entry.extra-income .entry-side strong {
  color: var(--flow-income);
}

.entry.extra-expense .entry-side strong {
  color: var(--flow-extraordinary);
}

.entry.saving .entry-side strong {
  color: var(--flow-saving-text);
}

body[data-page="stats"] {
  background: var(--white);
}

.stats-page {
  display: grid;
  max-width: 1080px;
  gap: 32px;
  padding-top: 48px;
}

.stats-heading {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0;
  padding: 18px 24px 12px;
  text-align: center;
}

.stats-heading h2 {
  max-width: 760px;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.05;
}

.stats-section-number {
  margin: 0;
  color: var(--navy);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-transform: uppercase;
}

.stats-period-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: var(--text-ui);
}

.stats-mode-control {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 280px);
  padding: 0;
  border: 0;
  margin-top: 20px;
  margin-bottom: 0;
}

.stats-mode-control label {
  min-height: var(--control-height);
}

.stats-guiding-question {
  max-width: 680px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: var(--text-ui);
  line-height: 1.45;
}

.stats-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.stats-kpi {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 220px;
  padding: 28px;
  border: 1px solid #dde3e7;
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.stats-kpi-primary {
  border-color: transparent;
  background: var(--navy-gradient);
  color: var(--white);
}

.stats-kpi p,
.stats-kpi-details span {
  margin: 0;
  color: var(--muted);
}

.stats-kpi p {
  font-size: var(--text-ui);
  font-weight: 600;
}

.stats-kpi strong {
  align-self: center;
  display: block;
  margin: 24px 0 12px;
  font-size: var(--text-display);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
}

.stats-kpi strong.is-negative {
  color: var(--danger);
}

.stats-kpi-saving strong {
  color: var(--navy);
}

.stats-kpi-details {
  display: grid;
  gap: 5px;
}

.stats-kpi-details span {
  display: block;
  font-size: var(--text-sm);
  text-align: center;
}

.stats-kpi-primary p,
.stats-kpi-primary .stats-kpi-details span {
  color: rgba(255, 255, 255, 0.86);
}

.stats-kpi-primary strong.is-negative {
  color: #ffd4df;
}

.stats-ai-advisor {
  border-color: #c7dceb;
  background: #f7fbfe;
}

.stats-funds-use {
  display: grid;
  gap: 22px;
}

.stats-funds-use-bar {
  display: block;
  width: 100%;
  height: 16px;
  overflow: visible;
}

.stats-funds-use-track {
  stroke: var(--gray-mid);
  stroke-linecap: round;
  stroke-width: 10px;
  vector-effect: non-scaling-stroke;
}

.stats-funds-use-line {
  stroke-width: 10px;
}

.stats-funds-use-line.stats-funds-use-expense {
  stroke: var(--flow-expense);
}

.stats-funds-use-swatch.stats-funds-use-expense {
  background: var(--flow-expense);
}

.stats-funds-use-line.stats-funds-use-saving {
  stroke: var(--flow-saving-text);
}

.stats-funds-use-swatch.stats-funds-use-saving {
  background: var(--flow-saving-text);
}

.stats-funds-use-line.stats-funds-use-available {
  stroke: var(--flow-available);
}

.stats-funds-use-swatch.stats-funds-use-available {
  background: var(--flow-available);
}

.stats-funds-use-swatch.stats-funds-use-shortfall {
  background: var(--danger);
}

.stats-funds-use-income-marker {
  stroke: var(--danger);
  stroke-linecap: round;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.stats-funds-use-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-funds-use-item {
  min-width: 0;
  border-left: 1px solid #dde3e7;
  padding: 0 20px;
}

.stats-funds-use-item:first-child {
  border-left: 0;
  padding-left: 0;
}

.stats-funds-use-item:last-child {
  padding-right: 0;
}

.stats-funds-use-item p,
.stats-funds-use-item strong,
.stats-funds-use-item span {
  display: block;
  margin: 0;
}

.stats-funds-use-item p {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.stats-funds-use-swatch {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.stats-funds-use-item strong {
  margin-top: 6px;
  color: var(--navy);
  font-size: var(--text-large);
  font-variant-numeric: tabular-nums;
}

.stats-funds-use-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.stats-funds-use-item.is-negative strong {
  color: var(--danger);
}

.stats-ai-status {
  min-height: 0;
  margin: 0;
  color: var(--muted);
}

.stats-ai-status:empty {
  display: none;
}

.stats-ai-content {
  display: grid;
  gap: 24px;
}

.stats-ai-highlight {
  max-width: 880px;
  border-left: 3px solid var(--navy);
  padding: 4px 0 4px 16px;
}

.stats-ai-highlight-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stats-ai-headline {
  margin: 0;
  color: var(--navy);
  font-size: var(--text-large);
  font-weight: 700;
  line-height: 1.35;
}

.stats-ai-situation {
  max-width: 880px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: var(--text-base);
  line-height: 1.6;
}

.stats-ai-highlight .stats-ai-evidence {
  margin-top: 10px;
}

.stats-ai-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.stats-ai-changes {
  max-width: 880px;
  border-top: 1px solid #dce8f0;
  border-bottom: 1px solid #dce8f0;
  padding: 16px 0;
}

.stats-ai-changes h3 {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: var(--text-ui);
}

.stats-ai-changes ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.stats-ai-section {
  min-width: 0;
  padding: 20px;
  border: 1px solid #dce8f0;
  border-radius: var(--radius-btn);
  background: var(--white);
}

.stats-ai-section-comparisons {
  border-color: #c7dceb;
  background: var(--gray);
}

.stats-ai-section h3,
.stats-ai-section h4 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: var(--text-ui);
}

.stats-ai-comparison-context {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}

.stats-ai-section ul {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  list-style: none;
}

.stats-ai-section li {
  display: grid;
  gap: 6px;
}

.stats-ai-section li + li {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.stats-ai-section li > p {
  margin: 0;
  line-height: 1.45;
}

.stats-ai-priority {
  color: var(--navy);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats-ai-evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.stats-ai-evidence span {
  border-radius: 999px;
  padding: 3px 7px;
  background: #eef5fa;
  color: var(--navy);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.stats-ai-retry {
  width: auto;
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px solid var(--navy);
  border-radius: var(--radius-btn);
  background: var(--white);
  color: var(--navy);
  cursor: pointer;
  font-size: var(--text-ui);
  font-weight: 600;
}

.stats-ai-retry:hover {
  background: #e7f1f8;
}

.stats-ai-retry:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.stats-ai-disclaimer {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

.stats-view-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.stats-category-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 48px;
  align-items: center;
}

.stats-category-list {
  display: grid;
}

.stats-category-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 56px 110px;
  gap: 12px;
  align-items: center;
  min-height: 38px;
  border-bottom: 1px solid #dde3e7;
  font-size: var(--text-sm);
}

.stats-category-row:last-child {
  border-bottom: 0;
}

.stats-category-row strong {
  min-width: 0;
  font-size: inherit;
}

.stats-category-row span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.stats-category-row span:last-child {
  color: var(--ink);
  font-weight: 600;
}

.stats-category-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--stats-category-color);
}

.stats-category-color-0 {
  --stats-category-color: var(--expense-housing);
}

.stats-category-color-1 {
  --stats-category-color: var(--expense-obligation);
}

.stats-category-color-2 {
  --stats-category-color: var(--expense-health);
}

.stats-category-color-3 {
  --stats-category-color: var(--expense-mobility);
}

.stats-category-color-4 {
  --stats-category-color: var(--expense-household);
}

.stats-category-color-5 {
  --stats-category-color: var(--expense-communication);
}

.stats-category-color-6 {
  --stats-category-color: var(--expense-leisure);
}

.stats-category-color-7 {
  --stats-category-color: var(--expense-personal);
}

.stats-category-color-8 {
  --stats-category-color: var(--expense-education);
}

.stats-category-color-9 {
  --stats-category-color: var(--extra-expense);
}

.stats-category-color-10 {
  --stats-category-color: var(--flow-extraordinary);
}

.stats-donut-chart {
  display: block;
  width: min(100%, 300px);
  margin: 0 auto;
  overflow: visible;
}

.stats-donut-track,
.stats-donut-arc {
  fill: none;
  stroke-width: 18;
}

.stats-donut-track {
  stroke: var(--gray);
}

.stats-donut-arc {
  stroke: var(--stats-category-color);
}

.stats-donut-value,
.stats-donut-label {
  fill: var(--navy);
  font-family: var(--font);
}

.stats-donut-value {
  font-size: var(--text-large);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stats-donut-label {
  fill: var(--muted);
  font-size: 0.625rem;
}

.stats-chart-card {
  overflow: hidden;
  padding: 34px;
  border: 1px solid #dde3e7;
  box-shadow: var(--shadow);
}

.stats-card-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 0;
}

.stats-card-heading > div {
  width: 100%;
  min-width: 0;
}

.stats-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 6px;
}

.stats-card-heading h2 {
  margin: 0;
  font-size: var(--text-large);
}

.stats-card-heading-compact {
  margin-bottom: 0;
}

.stats-card-question {
  margin: 7px 0 26px;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.stats-card-heading-compact + .stats-card-question {
  margin-bottom: 18px;
}

.stats-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.stats-legend,
.stats-dot-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.stats-legend span,
.stats-dot-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stats-legend i,
.stats-dot-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.stats-legend-living,
.stats-segment-living {
  fill: var(--flow-living);
  background: var(--flow-living);
}

.stats-legend-obligation,
.stats-segment-obligation {
  fill: var(--flow-obligation);
  background: var(--flow-obligation);
}

.stats-legend-wealth,
.stats-segment-wealth {
  fill: var(--flow-saving-text);
  background: var(--flow-saving-text);
}

.stats-segment-extra {
  fill: var(--flow-extraordinary);
  background: var(--flow-extraordinary);
}

.stats-legend-extra {
  background: var(--flow-extraordinary);
}

.stats-segment-category {
  fill: var(--stats-category-color);
  background: var(--stats-category-color);
}

.stats-segment-tax {
  fill: var(--expense-obligation);
  background: var(--expense-obligation);
}

.stats-segment-insurance {
  fill: var(--expense-personal);
  background: var(--expense-personal);
}

.stats-segment-health-insurance {
  fill: var(--expense-health);
  background: var(--expense-health);
}

.stats-segment-income-0 {
  fill: var(--income-salary);
  background: var(--income-salary);
}

.stats-segment-income-1 {
  fill: var(--accent);
  background: var(--accent);
}

.stats-segment-income-2 {
  fill: var(--income-thirteenth);
  background: var(--income-thirteenth);
}

.stats-segment-income-3 {
  fill: var(--income-bonus);
  background: var(--income-bonus);
}

.stats-segment-extra-income {
  fill: var(--extra-income);
  background: var(--extra-income);
}

.stats-series-controls {
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-bottom: 23px;
  padding-bottom: 3px;
  overscroll-behavior-inline: contain;
}

.stats-series-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.stats-series-button.is-active,
.stats-series-button[aria-pressed="true"] {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
  font-weight: 600;
}

.stats-series-color-use {
  --stats-series-color: var(--flow-income);
}

.stats-series-color-income {
  --stats-series-color: var(--accent);
}

.stats-series-color-living {
  --stats-series-color: var(--flow-living);
}

.stats-series-color-obligation {
  --stats-series-color: var(--flow-obligation);
}

.stats-series-color-extra {
  --stats-series-color: var(--flow-extraordinary);
}

.stats-series-color-wealth {
  --stats-series-color: var(--flow-saving-text);
}

.stats-series-color-available {
  --stats-series-color: var(--flow-available-text);
}

.stats-legend-series {
  background: var(--stats-series-color);
}

.stats-legend-cumulative {
  position: relative;
  background: transparent;
}

.stats-legend-cumulative::after {
  position: absolute;
  top: 4px;
  right: 0;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--stats-series-color);
  content: "";
}

.stats-legend-forecast {
  position: relative;
  background: transparent;
}

.stats-legend-forecast::after {
  position: absolute;
  top: 4px;
  right: 0;
  left: 0;
  border-top: 2px dashed var(--accent);
  content: "";
}

.stats-chart-tooltip-root {
  position: relative;
}

.stats-chart-scroll {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.stats-chart-tooltip {
  position: absolute;
  z-index: 2;
  top: 4px;
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 48px);
  transform: translateX(-50%);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--chart-tooltip-bg);
  box-shadow: var(--shadow);
  color: var(--white);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

[data-chart-tooltip] {
  cursor: pointer;
}

.stats-cashflow-chart {
  display: block;
  width: 100%;
  min-width: 760px;
}

.stats-chart-grid {
  stroke: #dde3e7;
  stroke-width: 1;
}

.stats-chart-zero {
  stroke: var(--ink);
  stroke-width: 1.5;
  opacity: 0.42;
}

.stats-axis-title {
  fill: var(--ink);
  font-family: var(--font);
  font-size: 0.625rem;
  font-weight: 600;
}

.stats-axis-label,
.stats-month-label,
.stats-current-label {
  fill: var(--muted);
  font-family: var(--font);
  font-size: 0.625rem;
}

.stats-month-label {
  fill: var(--ink);
  font-weight: 600;
}

.stats-month-label.is-future {
  fill: #a2a9b8;
  font-weight: 400;
}

.stats-current-label {
  fill: var(--accent);
  font-size: 0.625rem;
}

.stats-series-bar {
  fill: var(--stats-series-color);
}

.stats-series-bar.is-negative {
  fill: var(--danger);
}

.stats-cumulative-line {
  fill: none;
  stroke: var(--stats-series-color);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.stats-cumulative-point {
  fill: var(--white);
  stroke: var(--stats-series-color);
  stroke-width: 3;
  pointer-events: none;
}

.stats-chart-point-hit {
  fill: transparent;
  pointer-events: all;
}

.stats-cumulative-line-forecast {
  stroke-dasharray: 7 6;
  opacity: 0.7;
}

.stats-cumulative-point.is-forecast {
  opacity: 0.7;
}

.stats-forecast-month {
  opacity: 0.56;
}

.stats-month-label.is-forecast {
  fill: var(--accent);
}

.stats-forecast-divider {
  stroke: #aeb8c8;
  stroke-dasharray: 4 5;
  stroke-width: 1;
}

.stats-bullet-list,
.stats-benchmark-list {
  display: grid;
  gap: 20px;
}

.stats-bullet-heading,
.stats-benchmark-heading,
.stats-bullet-values {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.stats-bullet-heading strong,
.stats-benchmark-heading strong {
  font-size: var(--text-sm);
}

.stats-bullet-heading span,
.stats-benchmark-heading span,
.stats-bullet-values {
  color: var(--muted);
  font-size: var(--text-xs);
}

.stats-benchmark-row svg {
  display: block;
  width: 100%;
  height: 18px;
  margin: 5px 0 2px;
  overflow: visible;
}

.stats-bullet-bar-frame {
  position: relative;
  height: 11px;
  margin: 6px 0 2px;
}

.stats-bullet-bar-frame .stats-bullet-bar {
  position: absolute;
  left: 0;
  top: 2px;
  display: block;
  width: 100%;
  height: 7px;
  margin: 0;
}

.stats-bullet-marker-layer {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: 100%;
  height: 11px;
  pointer-events: none;
}

.stats-bullet-value {
  fill: var(--navy);
}

.stats-bullet-fill-line {
  stroke: var(--navy);
}

.stats-bullet-row.is-over .stats-bullet-value,
.stats-bullet-row.is-over .stats-bullet-fill-line {
  fill: var(--danger);
  stroke: var(--danger);
}

.stats-bullet-marker {
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.stats-bullet-values {
  font-variant-numeric: tabular-nums;
}

.stats-dot-own,
.stats-dot-reference {
  border-radius: 50%;
}

i.stats-dot-own {
  background: var(--navy);
}

i.stats-dot-reference {
  border: 2px solid #7d8799;
  background: var(--white);
}

.stats-dot-axis {
  stroke: #dde3e7;
  stroke-width: 5;
  vector-effect: non-scaling-stroke;
}

.stats-dot-connector {
  stroke: #bfc8cf;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

line.stats-dot-own {
  stroke: var(--navy);
  stroke-linecap: round;
  stroke-width: 7;
  vector-effect: non-scaling-stroke;
}

line.stats-dot-reference {
  stroke: #7d8799;
  stroke-linecap: round;
  stroke-width: 5;
  vector-effect: non-scaling-stroke;
}

.stats-benchmark-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.stats-reference-note {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin-top: 26px;
  padding: 20px;
  border-radius: var(--radius-btn);
  background: var(--gray);
}

.stats-reference-note > p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--navy);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats-reference-note div {
  min-width: 0;
}

.stats-reference-note strong,
.stats-reference-note span {
  display: block;
}

.stats-reference-note strong {
  font-size: var(--text-ui);
  font-variant-numeric: tabular-nums;
}

.stats-reference-note span {
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.stats-method {
  padding: 28px 32px;
  border-radius: var(--radius);
  background: var(--gray);
}

.stats-method h2 {
  margin-bottom: 8px;
  font-size: var(--text-title);
}

.stats-method p {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: var(--text-sm);
}

.stats-sources a {
  color: #0445c8;
}

@media (min-width: 861px) {
  .budget-fold,
  .budget-calc.budget-hypo {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .budget-fix-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .budget-cat-foot strong,
  .budget-cat-foot > span:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
}

@media (max-width: 860px) {
  .stats-page {
    gap: 24px;
    padding-top: 36px;
  }

  .stats-mode-control {
    margin-top: 18px;
  }

  .stats-lower-grid {
    grid-template-columns: 1fr;
  }

  .stats-ai-sections {
    grid-template-columns: 1fr;
  }

  .stats-category-layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .stats-card-heading {
    display: block;
  }

  .stats-view-note {
    white-space: normal;
  }

  .stats-card-meta .stats-view-note {
    margin-top: 0;
    text-align: right;
  }

  .layout,
  .totals,
  .overview-totals,
  .totals.totals-wide,
  .totals.totals-wide.statement-kpis,
  .totals-extra,
  .filters,
  .budget-cat-summary,
  .budget-cat-cols,
  .budget-cat-foot,
  .budget-item-body,
  .budget-item-body.budget-item-no-fix,
  .budget-sub-summary,
  .budget-hypo-summary,
  .budget-calc-grid,
  .budget-breakdown-row,
  .compare-head,
  .compare-row {
    grid-template-columns: 1fr;
  }

  .budget-cat-head .cat-label {
    grid-row: auto;
  }

  .budget-item-amounts {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .budget-col-label,
  .budget-amt-year,
  .budget-amt-month,
  .budget-cat-total,
  .budget-cat-month,
  .budget-cat-foot {
    text-align: left;
  }

  .capture-card {
    position: static;
  }

  .overview-head,
  .recent-head,
  .nav,
  .control-filters {
    flex-direction: column;
    align-items: flex-start;
  }

  .budget-year-controls {
    flex-direction: row;
    align-items: center;
  }

  .budget-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .budget-summary {
    grid-template-columns: 1fr;
  }

  .stats-funds-use-values {
    grid-template-columns: 1fr;
  }

  .stats-funds-use-item,
  .stats-funds-use-item:first-child,
  .stats-funds-use-item:last-child {
    border-top: 1px solid #dde3e7;
    border-left: 0;
    padding: 14px 0;
  }

  .stats-funds-use-item:first-child {
    border-top: 0;
    padding-top: 0;
  }

  .stats-funds-use-item:last-child {
    padding-bottom: 0;
  }

  .account-panel {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: 640px;
    max-height: calc(100dvh - 16px);
    margin: auto auto 0;
    border-radius: 20px 20px 0 0;
    padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 520px) {
  .financial-alert-inner {
    grid-template-columns: 22px minmax(0, 1fr) 36px;
    gap: 8px;
    padding-inline: 12px;
    font-size: var(--text-ui);
  }

  .financial-alert-icon {
    width: 22px;
    height: 22px;
  }

  .is-standalone .topbar-inner {
    padding: 14px 16px;
  }

  .is-standalone .topbar-inner h1 {
    font-size: var(--text-title);
    white-space: nowrap;
  }

  .is-standalone .page {
    padding: 16px 12px 48px;
  }

  .is-standalone .capture-card {
    padding: 20px 18px;
  }

  .is-standalone .push-card {
    width: calc(100% - 24px);
    max-height: calc(100dvh - 24px);
    padding: 24px 20px 20px;
  }

  .is-standalone .push-actions {
    justify-content: flex-start;
  }

  .is-standalone .capture-card .segmented {
    margin-bottom: 12px;
  }

  .is-standalone .capture-card .field {
    margin-bottom: 12px;
  }

  .is-standalone .capture-card .quick-categories {
    margin-top: 0;
    margin-bottom: 12px;
  }

  .is-standalone .capture-card .primary {
    margin-top: 4px;
  }

  .is-standalone .capture-form-actions .primary {
    margin-top: 0;
    padding-inline: 10px;
    font-size: var(--text-ui);
  }

  .is-standalone #form-status:empty {
    display: none;
  }

  .stats-kpis,
  .stats-reference-note {
    grid-template-columns: 1fr;
  }

  .stats-kpi p {
    overflow-wrap: anywhere;
  }

  .stats-kpi {
    min-height: 190px;
    padding: 24px;
  }

  .stats-category-row {
    grid-template-columns: 10px minmax(0, 1fr) 92px;
    gap: 9px;
  }

  .stats-category-row span:first-of-type {
    display: none;
  }

  .stats-chart-card {
    padding: 24px 20px;
  }

  .stats-heading {
    padding-right: 0;
    padding-left: 0;
  }

  .stats-method {
    padding: 24px 20px;
  }

  .stats-reference-note > p {
    grid-column: 1;
  }
}

@media (max-width: 360px) {
  .confirm-actions {
    flex-direction: column;
  }

  .confirm-actions .primary,
  .confirm-actions .link-btn {
    width: 100%;
  }

  .stats-kpi strong {
    font-size: 2.2rem;
  }
}

@media (max-width: 480px) {
  .weekly-check-summary {
    grid-template-columns: 1fr;
  }

  .weekly-check-card.is-combined .weekly-check-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .weekly-check-card.is-combined .weekly-check-stat {
    padding: 10px 8px;
  }

  .weekly-check-card.is-combined .weekly-check-stat strong {
    font-size: var(--text-sm);
  }
}

/* ── Jahres-Matrix ── */

.control-breakdown-card {
  position: relative;
}

.year-fullscreen-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 4;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.year-fullscreen-toggle[hidden],
.fullscreen-icon[hidden] {
  display: none;
}

.year-fullscreen-toggle:hover {
  background: var(--gray);
  border-color: var(--gray-mid);
  color: var(--navy);
}

.year-fullscreen-toggle:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.year-fullscreen-toggle:disabled {
  cursor: wait;
  opacity: 0.65;
}

.fullscreen-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.control-breakdown-card > #control-breakdown > .breakdown-block:first-child > h3 {
  padding-right: 44px;
}

#control-breakdown {
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
  padding-bottom: 8px;
}

#control-breakdown .breakdown-block {
  min-width: 0;
  overflow: visible;
}

.matrix-scroll {
  width: 100%;
  min-width: 2000px;
}

/* Gemeinsames Grid für alle Zeilen-Typen */
.matrix-head,
.matrix-row,
.matrix-sub,
.matrix-total {
  display: grid;
  grid-template-columns: minmax(200px, 1.8fr) repeat(2, minmax(120px, 1fr)) repeat(12, minmax(85px, 1fr)) minmax(170px, 1.2fr) minmax(65px, 0.7fr);
  gap: 4px 6px;
  align-items: center;
  text-align: right;
  justify-content: stretch;
  justify-items: stretch;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* summary als Grid: globale summary-Regeln zurücksetzen */
summary.matrix-row {
  display: grid !important;
  justify-content: stretch;
  align-items: center;
  gap: 4px 6px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
  font-size: var(--text-sm);
  font-weight: 700;
}

.matrix-head {
  color: var(--muted);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  font-weight: 600;
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
  text-transform: none;
}

.matrix-head span:first-child,
.matrix-row > span:first-child,
.matrix-total > span:first-child {
  text-align: left;
}

.matrix-row .cat-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: var(--text-sm);
}

summary.matrix-row .cat-label,
#control-breakdown summary.matrix-row .matrix-diff.positive,
#control-breakdown summary.matrix-row .matrix-diff.negative,
summary.matrix-row .matrix-pct.over {
  font-weight: 700;
}

.matrix-subs {
  margin: 0;
  padding: 0;
  list-style: none;
  width: 100%;
}

.matrix-sub {
  font-size: var(--text-sm);
  padding: 4px 0;
  color: var(--muted);
}

.matrix-extra-row {
  border-top: 1px solid var(--line);
  padding: 10px 0;
  font-size: var(--text-sm);
  font-weight: 400;
}

.matrix-sub .matrix-label {
  text-align: left;
  padding-left: 20px;
}

.matrix-budget,
.matrix-month,
.matrix-year-ist,
.matrix-diff,
.matrix-pct {
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 2px 6px;
  text-align: right;
  white-space: nowrap;
}

.matrix-month {
  border-radius: 4px;
}

.matrix-year-ist,
.matrix-diff {
  padding: 0;
}

.matrix-year-ist > .value-fill,
.matrix-diff > .value-fill {
  display: inline-block;
  box-sizing: border-box;
  min-width: 50%;
  border-radius: 4px;
  padding: 2px 6px;
}

.matrix-head > span {
  box-sizing: border-box;
  padding: 2px 6px;
  white-space: nowrap;
}

.matrix-head > .matrix-year-difference-label,
.cashflow-head > .matrix-year-difference-label {
  line-height: 1.15;
  white-space: normal;
}

.matrix-head .is-forecast,
.cashflow-head .is-forecast {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  color: var(--muted);
}

.matrix-forecast-label {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.1;
}

.matrix-month.matrix-forecast,
.cashflow-value.matrix-forecast {
  border: 1px dashed var(--line);
  background: var(--gray);
  color: var(--muted);
}

.matrix-ist-ok {
  background: var(--ist-ok);
}

.matrix-ist-good {
  background: var(--ist-good);
}

.matrix-ist-warn {
  background: var(--ist-warn);
}

.matrix-ist-over {
  background: var(--ist-over);
}

.matrix-year-ist.matrix-ist-ok,
.matrix-year-ist.matrix-ist-good,
.matrix-year-ist.matrix-ist-warn,
.matrix-year-ist.matrix-ist-over,
.matrix-diff.matrix-ist-ok,
.matrix-diff.matrix-ist-good,
.matrix-diff.matrix-ist-warn,
.matrix-diff.matrix-ist-over {
  background: transparent;
}

.matrix-year-ist.matrix-ist-ok > .value-fill,
.matrix-diff.matrix-ist-ok > .value-fill {
  background: var(--ist-ok);
}

.matrix-year-ist.matrix-ist-good > .value-fill,
.matrix-diff.matrix-ist-good > .value-fill {
  background: var(--ist-good);
}

.matrix-year-ist.matrix-ist-warn > .value-fill,
.matrix-diff.matrix-ist-warn > .value-fill {
  background: var(--ist-warn);
}

.matrix-year-ist.matrix-ist-over > .value-fill,
.matrix-diff.matrix-ist-over > .value-fill {
  background: var(--ist-over);
}

.matrix-pct.over {
  color: var(--danger);
  font-weight: 600;
}

/* Trennlinien: nur zwischen Kategorien, volle Breite */
.matrix-scroll > details {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  padding: 0;
  display: block;
  width: 100%;
}

.matrix-scroll > details:last-of-type {
  border-bottom: 1px solid var(--line);
}

.matrix-total {
  padding: 10px 0;
  border-top: 2px solid var(--navy);
  margin-top: 8px;
  font-weight: 700;
  font-size: var(--text-sm);
}

.matrix-total .matrix-budget,
.matrix-total .matrix-month,
.matrix-total .matrix-year-ist,
.matrix-total .matrix-diff,
.matrix-total .matrix-pct {
  font-weight: 700;
}

#control-breakdown .matrix-row .icon {
  width: 14px;
  height: 14px;
}

.cashflow-head,
.cashflow-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.8fr) repeat(2, minmax(120px, 1fr)) repeat(12, minmax(85px, 1fr)) minmax(170px, 1.2fr) minmax(65px, 0.7fr);
  gap: 4px 6px;
  align-items: center;
  width: 100%;
  min-width: 0;
  text-align: right;
}

.cashflow-head {
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.cashflow-head > span,
.cashflow-row > span {
  min-width: 0;
  padding: 2px 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cashflow-value {
  border-radius: 4px;
}

.cashflow-row > .matrix-year-ist {
  padding: 0;
}

.cashflow-head > span:first-child,
.cashflow-row > span:first-child {
  text-align: left;
}

.cashflow-row {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--text-xs);
  font-weight: 700;
}

.cashflow-row > span:first-child,
.cashflow-result {
  font-weight: 700;
}

.cashflow-cumulative {
  border-top: 2px solid var(--navy);
  border-bottom: 0;
  margin-top: 4px;
  padding-top: 10px;
}

.cashflow-result > span:first-child,
.cashflow-cumulative > span:first-child {
  line-height: 1.2;
}

.control-breakdown-card:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  padding: 20px 16px 24px;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 0;
  background: var(--white);
}

.control-breakdown-card:fullscreen #control-breakdown {
  overflow: visible;
  padding-bottom: 0;
}

.control-breakdown-card:fullscreen .matrix-scroll {
  min-width: 0;
}

.control-breakdown-card:fullscreen .matrix-head,
.control-breakdown-card:fullscreen .matrix-row,
.control-breakdown-card:fullscreen .matrix-sub,
.control-breakdown-card:fullscreen .matrix-total {
  grid-template-columns: minmax(150px, 1.7fr) repeat(2, minmax(72px, 0.9fr)) repeat(12, minmax(54px, 0.72fr)) minmax(100px, 1.15fr) minmax(36px, 0.42fr);
  column-gap: 3px;
}

.control-breakdown-card:fullscreen .matrix-head {
  position: sticky;
  top: 0;
  z-index: 3;
  padding-top: 8px;
  background: var(--white);
  font-size: clamp(0.68rem, 0.62vw, 0.75rem);
}

.control-breakdown-card:fullscreen summary.matrix-row,
.control-breakdown-card:fullscreen .matrix-sub,
.control-breakdown-card:fullscreen .matrix-extra-row,
.control-breakdown-card:fullscreen .matrix-total {
  font-size: clamp(0.68rem, 0.62vw, 0.75rem);
}

.control-breakdown-card:fullscreen .matrix-row .cat-label {
  gap: 4px;
  font-size: clamp(0.68rem, 0.62vw, 0.75rem);
}

.control-breakdown-card:fullscreen .matrix-budget,
.control-breakdown-card:fullscreen .matrix-month,
.control-breakdown-card:fullscreen .matrix-year-ist > .value-fill,
.control-breakdown-card:fullscreen .matrix-diff > .value-fill,
.control-breakdown-card:fullscreen .matrix-pct,
.control-breakdown-card:fullscreen .matrix-head > span {
  padding-right: 3px;
  padding-left: 3px;
}

.control-breakdown-card:fullscreen .matrix-sub .matrix-label {
  padding-left: 16px;
}

.control-breakdown-card:fullscreen .cashflow-head,
.control-breakdown-card:fullscreen .cashflow-row {
  grid-template-columns: minmax(150px, 1.7fr) repeat(2, minmax(72px, 0.9fr)) repeat(12, minmax(54px, 0.72fr)) minmax(100px, 1.15fr) minmax(36px, 0.42fr);
  column-gap: 3px;
  font-size: clamp(0.68rem, 0.62vw, 0.75rem);
}

.control-breakdown-card:fullscreen .cashflow-head {
  position: sticky;
  top: 0;
  z-index: 3;
  padding-top: 8px;
  background: var(--white);
  font-size: clamp(0.68rem, 0.62vw, 0.75rem);
}

.control-breakdown-card:fullscreen .cashflow-head > span,
.control-breakdown-card:fullscreen .cashflow-row > span {
  padding-right: 3px;
  padding-left: 3px;
}

.control-breakdown-card:fullscreen .cashflow-row > .matrix-year-ist {
  padding-right: 0;
  padding-left: 0;
}
