:root {
  color-scheme: light;
  font: 16px/1.45 system-ui, sans-serif;
  color: #17202d;
  background: #f6f7f8;
  --purple: #39624d;
  --muted: #606b7b;
  --line: #dfe3e7;
}
* { box-sizing: border-box; }
body { margin: 0; }
.wrap { width: min(100% - 32px, 880px); margin-inline: auto; }
header { border-bottom: 1px solid var(--line); background: #fff9; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 0; padding-top: max(14px, env(safe-area-inset-top)); font-weight: 800; font-size: 1.18rem; }
.logo { background: var(--purple); color: white; display: grid; place-items: center; border-radius: 11px; width: 36px; height: 36px; }
main { padding: 16px 0 calc(148px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; }
button { cursor: pointer; min-height: 44px; border: 0; border-radius: 12px; color: var(--purple); background: #edf0f2; padding: 8px 12px; font-weight: 700; }
:is(button, input, select, textarea):focus { outline: none; }
.primary { background: var(--purple); color: white; }
.wide { width: 100%; }
.month { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 8px; max-width: 350px; margin-bottom: 18px; }
.month input { width: 100%; min-width: 0; min-height: 44px; text-align: center; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.55rem; line-height: 1.15; overflow-wrap: anywhere; }
h2 { font-size: 1.08rem; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.heading button { flex-shrink: 0; }
.heading-add { min-width: 44px; padding: 0; background: transparent; font-size: 1.5rem; line-height: 1; }
.panel { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.panel { margin-bottom: 12px; }
strong, .row > div { overflow-wrap: anywhere; }
small, .muted { color: var(--muted); }
.row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border: 0; padding-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.progress { height: 7px; border-radius: 10px; background: #e6ece8; margin-top: 8px; overflow: hidden; }
.progress span { height: 100%; display: block; border-radius: inherit; background: #578269; }
.late { color: #a31d48; }
.done { color: #23684e; }
nav { padding: 3px 0 calc(5px + env(safe-area-inset-bottom)); }
nav .wrap { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 4px; }
nav button { padding-inline: 0; font-size: .85rem; background: transparent; color: var(--muted); }
nav [aria-current="page"] { background: #e9eeeb; color: var(--purple); }
dialog { width: min(calc(100% - 24px), 480px); max-height: 88dvh; border: 1px solid var(--line); border-radius: 20px; padding: 18px; color: inherit; }
dialog::backdrop { background: #17202d66; }
label { display: block; font-weight: 650; }
#fields { display: grid; gap: 10px; margin-bottom: 16px; }
input, select { display: block; width: 100%; min-height: 44px; border: 1px solid #dfe3e7; border-radius: 10px; background: #fff; color: inherit; padding: 8px; }
#form-error { color: #a31d48; }
#status { position: fixed; z-index: 3; bottom: calc(126px + env(safe-area-inset-bottom)); inset-inline: 16px; margin: auto; width: fit-content; max-width: calc(100% - 32px); background: #25352d; color: white; border-radius: 12px; padding: 9px 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

[hidden] { display: none !important; }
.wrap { width: min(100% - 28px, 660px); }
.brand { font-weight: 750; }
.logo { width: 30px; height: 30px; background: #e7eee9; color: #39624d; }
.month { margin-bottom: 12px; }
.panel { box-shadow: 0 1px 2px #17202d05; }
.balance > strong { display: block; font-size: clamp(1.85rem, 8vw, 2.65rem); line-height: 1.15; margin: 5px 0 12px; font-variant-numeric: tabular-nums; }
.flow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; font-size: .9rem; color: var(--muted); }
.flow strong { display: block; font-size: 1.1rem; margin-top: 3px; }
.outgoing { color: #a43124; }
.line-link { width: 100%; background: transparent; text-align: left; color: inherit; font-weight: 550; border-radius: 0; border-bottom: 1px solid var(--line); padding: 8px 0; }
.line-link:last-child { border-bottom: 0; }
.link-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.section-title { margin: 16px 0 8px; }
.entry-card { display: block; width: 100%; text-align: left; color: inherit; }
.entry-card small { display: block; font-weight: 450; margin-top: 3px; }
.account-item { display: block; }
.dock { position: fixed; z-index: 2; bottom: 0; inset-inline: 0; background: #fff; border-top: 1px solid var(--line); }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; padding-top: 8px; }
.quick button { min-height: 48px; padding-inline: 2px; font-size: clamp(.8rem, 3.7vw, 1rem); white-space: nowrap; }
.quick .quick-expense { background: #5d352a; color: #ffd0bd; }
.quick .quick-income { background: #39624d; color: #c2f2d2; }
.quick .quick-transfer { background: #626767; color: #fff; }

.balance > strong { margin-bottom: 0; }
.payment-line { display: block; width: 100%; background: transparent; color: inherit; text-align: left; padding: 0; }
.payment-line small { display: block; margin-top: 4px; font-weight: 450; }
.expense-editor { --purple: #5d352a; background: #f6f7f8; }
.expense-total input { font-size: 1.7rem; font-weight: 750; min-height: 54px; }
.editor-footer { background: inherit; }
.expense-editor [type=submit] { min-height: 50px; background: #5d352a; color: #ffd0bd; }
button:disabled { opacity: .55; cursor: default; }
@media (max-width: 520px) {
  .expense-editor { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; padding-top: max(14px, env(safe-area-inset-top)); }
  .expense-editor::backdrop { background: #f6f7f8; }
}
.settings-button { margin-inline-start: auto; min-width: 44px; font-size: 1.2rem; }
.category-setting { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.category-setting:last-child { border-bottom: 0; }
.category-setting button { min-width: 44px; padding: 4px; background: transparent; }
.category-setting button:first-child { flex: 1; min-width: 0; text-align: left; color: inherit; overflow-wrap: anywhere; }
.category-setting button[aria-pressed="true"] { background: #e7eee9; }
.expense-editor .heading { align-items: center; gap: 6px; }
.expense-editor .heading h2 { margin-right: auto; min-width: 0; font-size: clamp(1rem, 4.4vw, 1.25rem); }
#expense-header-date {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  clip-path: inset(0 round 10px);
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#expense-header-date input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
#expense-header-date input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; }
.expense-editor .heading #close { min-width: 44px; }
.expense-section { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.expense-section input, .expense-section select, .expense-section button { min-height: 46px; }
.expense-remainder { padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); }
.expense-section input[name="positionAmount"]::placeholder { color: #39624d; opacity: 1; }
.expense-remainder strong { color: #17202d; font-size: 1.15rem; }
.expense-editor .editor-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
#dialog.with-number-pad { padding-bottom: calc(var(--pad-height, 290px) + 16px); }
#number-pad {
  position: fixed; z-index: 4; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100%, 480px); color: #fff; background: #292b2d;
  border-radius: 15px 15px 0 0; padding: 0 6px max(8px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px #0003;
}
#number-display { display: block; min-height: 30px; padding: 4px 10px; text-align: right; overflow-wrap: anywhere; }
.number-operators, .number-keys { display: grid; gap: 5px; }
.number-operators { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.number-keys { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: 5px; }
#number-pad button { min-height: 44px; color: #fff; font-size: 1.35rem; padding: 3px; touch-action: manipulation; }
.number-operators button { background: transparent; border-radius: 0; border-inline-end: 1px solid #626467; }
.number-operators button:last-child { border: 0; }
.number-keys button { background: #5b5d5f; font-size: 1.65rem !important; }
#number-pad button:active { background: #737679; }

.expense-editor .expense-section { background: transparent; border: 0; border-radius: 0; padding: 0; }
.expense-editor .expense-section + .expense-section { padding-top: 10px; border-top: 1px solid var(--line); }
.expense-part { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 44px; gap: 6px; align-items: center; border-bottom: 1px solid var(--line); }
.expense-part input, .expense-total input { background: transparent; border: 0; border-radius: 0; padding-inline: 4px; font-weight: 600; }
.expense-part input { text-align: right; border-inline-start: 1px solid var(--line); }
.expense-part input[name="positionAmount"]::placeholder { color: var(--muted); font-weight: 500; }
.expense-part button { background: transparent; color: var(--muted); }
.expense-part:only-child [data-action="remove-part"] { visibility: hidden; }
.expense-total { border-bottom: 1px solid var(--line); }
.expense-section [data-action="add-part"] { justify-self: start; background: transparent; padding-inline: 4px; }

/* Today, statistics and shared navigation */
:is(#screen, .swipe-preview-screen) > .heading h1 { font-size: clamp(1.6rem, 7.5vw, 2rem); }
.today-date { margin: -4px 0 16px; }
.today-date::first-letter { text-transform: uppercase; }
.today-header { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; gap: 12px; margin-bottom: 12px; }
.today-heading { display: block; margin: 0; }
.today-heading .today-date { margin: 0 0 5px; }
.today-total { display: block; margin: 0; color: #111; overflow-wrap: anywhere; }
.account-summary { padding-block: 4px; }
.account-summary .row { align-items: baseline; padding-block: 10px; }
.account-summary .row + .row { border-top: 1px solid var(--line); }
.account-summary .row > strong:last-child { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.account-summary small { display: block; margin-top: 4px; color: var(--muted); }
.account-summary-total { font-size: 1.2rem; }
.investment-confirmation { background: #e9eeeb; border-color: #cbd9d0; }
.daily-entries .investment-confirmation { margin: 8px 0; }
.investment-confirmation.investment-overdue { background: #fff0ee; border-color: #efc0b9; }
.investment-overdue-label { display: block; margin-top: 6px; color: #a43124; }
.investment-confirmation-actions { align-items: center; flex-wrap: wrap; }
.investment-details { display: grid; gap: 4px; margin-block: 8px; }
label.investment-switch { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.investment-switch input { width: 20px; min-height: 20px; margin: 0; accent-color: var(--purple); }
.flow-summary strong { font-size: clamp(1.06rem, 4.9vw, 1.55rem); line-height: 1.2; }
.flow-summary > div + div { border-inline-start: 1px solid var(--line); padding-inline-start: 12px; }
.daily-entries { padding-block: 4px; }
.daily-entries > p { padding-block: 10px; }
.daily-entry {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 7px;
  width: 100%;
  padding: 10px 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}
.daily-entry + .daily-entry { border-top: 1px solid var(--line); }
.daily-entry > .muted:first-child, .daily-entry small { font-weight: 450; font-size: .8rem; }
.daily-entry small { display: block; margin-top: 2px; overflow-wrap: anywhere; }
.daily-entry > strong { text-align: right; }
.report-filters, .report-modes { display: grid; gap: 8px; margin-bottom: 14px; }
.report-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.report-filters :is(input, .select-trigger) {
  min-width: 0;
  background: #edf0f2;
  border: 0;
  border-radius: 12px;
  color: var(--purple);
  font-size: .88rem;
  font-weight: 700;
}
.report-modes { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 3px; background: #edf0f2; border-radius: 12px; }
.report-modes button { min-height: 38px; padding: 4px 2px; background: transparent; font-size: .9rem; }
.report-modes button[aria-pressed="true"] { background: var(--purple); color: white; }
.report-category .progress { display: block; height: 5px; }
.report-category-link { display: block; width: 100%; border-radius: 0; padding-inline: 0; background: transparent; color: inherit; text-align: left; }
.report-category-link .row::after {
  content: "";
  order: 1;
  flex: 0 0 7px;
  height: 7px;
  align-self: center;
  margin-inline: 2px 3px;
  border: solid var(--muted);
  border-width: 1.5px 1.5px 0 0;
  transform: rotate(45deg);
}
.report-category-link .row strong:last-child { margin-inline-start: auto; }
.report-category .row > strong:last-child { text-align: right; }
.report-day { display: grid; grid-template-columns: minmax(0, 1fr) repeat(2, minmax(0, 1.15fr)); gap: 6px; font-size: .9rem; }
.report-day strong { text-align: right; }
.dock nav { padding-top: 14px; }
#tabs button { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 46px; padding: 4px 0; font-size: clamp(.69rem, 3.4vw, .85rem); }
#tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Expense form in the order shown in the approved SVG. */
.expense-editor .heading h2 { font-size: clamp(1.05rem, 5.3vw, 1.65rem); }
.expense-editor .heading #close { position: relative; z-index: 1; flex: 0 0 44px; padding-inline: 0; }
.expense-editor .heading { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.expense-editor #fields { gap: 17px; }
.expense-summary { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 10px; align-items: center; margin: 0; }
.expense-total { border: 0; }
.expense-total label { color: var(--muted); font-size: .9rem; font-weight: 500; }
.expense-total input { padding: 0; min-height: 45px; font-size: clamp(1.65rem, 7vw, 2.35rem); }
.expense-remainder { padding: 0 0 0 10px; border: 0; border-inline-start: 1px solid var(--line); font-size: .84rem; }
.expense-remainder strong { display: block; margin-top: 7px; font-size: 1.3rem; }
.expense-remainder .done { color: #23684e; }
.expense-remainder .outgoing { color: #a43124; }
.expense-editor .expense-section + .expense-section { padding-top: 5px; border: 0; }
.expense-details .select-trigger { padding-inline: 12px; }
.expense-categories #expense-parts { margin: 0; padding-block: 0; }
.expense-categories .expense-part { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr) 34px; }
.expense-categories .expense-part:last-child { border-bottom: 0; }
.expense-categories .expense-part input { border: 0; }
.expense-categories .expense-part [data-action="remove-part"] { min-height: 36px; padding: 4px; background: #f6f7f8; }
.expense-categories [data-action="fill-remainder"] {
  grid-column: 1 / -1;
  justify-self: end;
  min-height: 44px;
  margin-bottom: 7px;
  background: #e9eeeb;
  color: #39624d;
  font-size: .87rem;
}
.expense-categories [data-action="add-part"] { justify-self: stretch; background: #ede9e7; }
.expense-editor .editor-footer { position: sticky; bottom: 0; padding-top: 8px; background: #f6f7f8; }
.expense-editor.with-number-pad .editor-footer { position: static; }
.expense-editor #form-error:empty { display: none; }
.expense-editor [type=submit] { color: #fff; }
.income-editor { --purple: #39624d; }
.income-editor [type=submit] { background: var(--purple); }
.expense-total, .expense-part > label:nth-child(2) { position: relative; }
.expense-total input, .expense-categories .expense-part input { padding-inline-end: 1.1em; color: var(--ink, #17202d); }
.expense-currency { position: absolute; inset-inline-end: 3px; bottom: 0; display: grid; place-items: center; height: 46px; font-weight: 650; pointer-events: none; }
.expense-total .expense-currency { height: 45px; font-size: 1.15rem; }
@media (max-width: 520px) {
  .expense-editor #editor { min-height: 100%; display: flex; flex-direction: column; }
  .expense-editor #editor > .heading { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 3; background: #f6f7f8; }
  .expense-editor .editor-footer { margin-top: auto; }
}


.select-field, .select-control { min-width: 0; }
.select-field > span { font-weight: 650; }
.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  text-align: left;
}
.select-trigger::after {
  content: "";
  flex: 0 0 7px;
  height: 7px;
  margin: -4px 3px 0 0;
  border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-categories .select-trigger { min-height: 46px; padding-inline: 4px; border: 0; background: transparent; }
#select-menu {
  position: fixed;
  inset: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  color: #17202d;
  box-shadow: 0 6px 18px #17202d20;
}
#category-query { font-size: 16px; }
#category-search { margin-bottom: 4px; }
#select-options { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.select-option { display: block; width: 100%; border-radius: 0; color: inherit; background: #fff; text-align: left; overflow-wrap: anywhere; }
.select-option + .select-option { border-top: 1px solid var(--line); }
.select-option[aria-current="true"] { color: #39624d; background: #e9eeeb; border-radius: 8px; }
.select-option:focus-visible { color: #39624d; background: #edf0f2; }
.select-empty { padding: 12px 8px; }
#dialog:has(#select-menu:not([hidden])) #editor { padding-bottom: var(--select-scroll-space, 0px); }

#category-picker { width: min(calc(100% - 28px), 430px); padding: 14px; overflow: hidden; }
#category-picker #select-menu { position: static; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
#category-picker #select-options { max-height: min(44dvh, 330px); }
@media (max-width: 520px) {
  #category-picker { margin: max(12px, env(safe-area-inset-top)) auto 0; }
  #category-picker #select-options { max-height: min(34dvh, 280px); }
}

@keyframes dds-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  #number-pad:not([hidden]), #select-menu:not([hidden]) { animation: dds-appear 130ms ease-out; }
  #category-picker #select-menu { animation: none; }

  @supports (transition-behavior: allow-discrete) {
    dialog {
      opacity: 0;
      transition: opacity 140ms ease-out, display 140ms allow-discrete, overlay 140ms allow-discrete;
    }
    dialog[open] { opacity: 1; }

    @starting-style {
      dialog[open] { opacity: 0; }
    }
  }

  @supports not (transition-behavior: allow-discrete) {
    dialog[open] { animation: dds-appear 140ms ease-out; }
  }
}

.back-dragging { translate: var(--back-offset, 0px); }
html:has(main.back-dragging) { overflow-x: clip; }
main.back-dragging { position: relative; z-index: 1; }
main.back-dragging::before {
  content: "";
  position: absolute;
  inset: 0 50%;
  z-index: -1;
  width: 100vw;
  min-height: 100dvh;
  transform: translateX(-50%);
  background: #f6f7f8;
}
dialog.back-dragging::backdrop { background: rgb(23 32 45 / var(--back-shade, 0)); }
dialog:is(.back-dragging, .system-back-close):not([open]) { display: none; transition: none; }
.swipe-underlay {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #f6f7f8;
  pointer-events: none;
}
.swipe-underlay > main { transform: translateX(var(--back-preview-offset, 0px)); }
.swipe-underlay.settling > main { transition: transform 170ms ease-out; }

.available-card { background: #e9eeeb; }
.report-shortcuts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.report-shortcuts button { font-size: .9rem; }
.limit-amount { margin-top: 5px; }
.limit-amount > strong { font-size: clamp(1.4rem, 6vw, 2.1rem); line-height: 1.25; }
.limit-footer { align-items: center; flex-wrap: wrap; margin-top: 8px; }
.limit-footer button { margin-inline-start: auto; }
.category-limit-card .over-limit { background: #a43124; }
.expense-record-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.expense-record-actions [data-action="repeat-expense"] { color: #39624d; background: #e9eeeb; }

.account-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 4px 0; }
.account-line + .account-line { border-top: 1px solid var(--line); }
.account-line .account-item { min-width: 0; border: 0; }
.account-line [data-action="reconcile-account"] { background: #e9eeeb; font-size: .88rem; }

.auth-view { max-width: 430px; padding: max(22px, env(safe-area-inset-top)) 0 32px; }
.auth-view .brand { padding: 10px 0 32px; }
.auth-view h1 { margin-bottom: 12px; }
.auth-view > .muted { margin-bottom: 16px; }
#auth-form { display: grid; gap: 16px; margin-top: 22px; }
#auth-form input { margin-top: 4px; min-height: 48px; font-size: 16px; }
#auth-form button[type="submit"] { min-height: 48px; margin-top: 4px; }
.auth-password { display: block; position: relative; }
.auth-password input { padding-inline-end: 94px; }
.auth-password button { position: absolute; right: 3px; top: 2px; background: transparent; font-size: .82rem; }
.auth-link { background: transparent; }
#auth-error { color: #a43124; }
#auth-error:empty { display: none; }
.auth-invite { background: #e9eeeb; }
.auth-invite small { display: block; margin-top: 4px; }
.family-members .row { align-items: center; }
.family-members .item small { display: block; }
.family-invitation input { font-size: 16px; }
.family-invitation .actions { align-items: center; }
.panel-actions > button { width: 100%; margin-bottom: 12px; }
