:root {
  --bg-primary: #22272e;
  --bg-secondary: #2d333b;
  --bg-elevated: #373e47;
  --border: #444c56;
  --text-primary: #fdfdfd;
  --text-secondary: #fdfdfd;
  --text-muted: #adbac7;
  --text-on-action: #f0f6fc;
  --accent-primary: #539bf5; /*539bf5*/
  --success: #57ab5a;
  --danger: #e5534b;
  --warning: #c69026;
  --chart-red: #d1343f;
  --chart-yellow: #c79800;
  --chart-orange: #d97706;
  --chart-green: #2f9e44;
  --chart-blue: #2f81f7;
  --chart-purple: #8250df;
  --chart-cyan: #0f9bb0;
  --chart-pink: #c33c8a;
  --background: var(--bg-primary);
  --surface: var(--bg-secondary);
  --surface-raised: var(--bg-elevated);
  --surface-hover: #3d444d;
  --control-fill: var(--surface-raised);
  --text: var(--text-primary);
  --muted: var(--text-secondary);
  --line: var(--border);
  --primary: var(--accent-primary);
  --primary-hover: #6cb6ff;
  --tab-expense: #a87a14;
  --tab-expense-active: #6b4b06;
  --tab-income: #3978bf;
  --tab-income-active: #24517f;
  --tab-overdue: #b94a45;
  --tab-overdue-active: #7c302d;
  --tab-paid: #478b4a;
  --tab-paid-active: #2d5e30;
  --dashboard-action: #168fa1;
  --dashboard-action-hover: #0b6572;
  --card-carried: #a78bfa;
  --card-income: #6cb6ff;
  --card-expense: #f4a261;
  --card-available-positive: var(--income);
  --card-available-negative: #7c302d;
  --primary-soft: #1f3b5a;
  --link: var(--accent-primary);
  --text-link: var(--text-primary);
  --income: #75c878;
  --expense: #ff938a;
  --focus: var(--accent-primary);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgb(20 24 29 / 20%), 0 3px 8px rgb(20 24 29 / 16%);
  --shadow-raised: 0 10px 24px rgb(20 24 29 / 24%);
}

* { box-sizing: border-box; }
html { background: var(--background); color-scheme: dark; }
body {
  min-width: 0;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 400 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a, button, input, select, textarea { font: inherit; }
a { color: var(--text-link); }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  transform: translateY(-180%);
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-raised);
}
.skip-link:focus { transform: translateY(0); }

header {
  min-height: 72px;
  padding: 0 max(20px, calc((100vw - 1120px) / 2));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 0 rgb(20 24 29 / 20%);
}
.brand {
  justify-self: start;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -.01em;
  text-decoration: none;
}
header .main-nav { display: flex; grid-column: 2; flex-wrap: wrap; align-items: center; justify-self: center; gap: 6px; }
header .main-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .94rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
header .main-nav a::after {
  position: absolute;
  right: 10px;
  bottom: 3px;
  left: 10px;
  height: 2px;
  border-radius: 999px;
  background: rgb(255 255 255 / 76%);
  box-shadow: 0 2px 4px rgb(255 255 255 / 0%);
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: scaleX(.82);
  transition: opacity .16s ease, box-shadow .16s ease, transform .16s ease;
}
header .main-nav a:hover { color: var(--text); background: var(--surface-hover); }
header .main-nav a:not([aria-current="page"]):hover {
  box-shadow: 0 2px 4px rgb(255 255 255 / 6%);
}
header .main-nav a:not([aria-current="page"]):hover::after {
  box-shadow: 0 2px 4px rgb(255 255 255 / 18%);
  opacity: .62;
  transform: scaleX(.94);
}
header .main-nav a:not([aria-current="page"]):active {
  box-shadow: none;
  transform: translateY(1px);
}
header .main-nav a:not([aria-current="page"]):active::after {
  box-shadow: 0 1px 2px rgb(255 255 255 / 12%);
  opacity: .46;
}
header .main-nav a[aria-current="page"] {
  background: var(--surface-hover);
  box-shadow: 0 2px 5px rgb(255 255 255 / 8%);
  color: var(--text);
  font-weight: 600;
}
header .main-nav a[aria-current="page"]::after {
  box-shadow: 0 3px 5px rgb(255 255 255 / 28%);
  opacity: 1;
  transform: scaleX(1);
}
header .main-nav a[aria-current="page"]:hover {
  box-shadow: 0 2px 5px rgb(255 255 255 / 12%);
}
header .main-nav a[aria-current="page"]:hover::after {
  box-shadow: 0 3px 5px rgb(255 255 255 / 34%);
}
header .main-nav a[aria-current="page"]:active {
  transform: translateY(1px);
}
header .main-nav a[aria-current="page"]:active::after {
  box-shadow: 0 1px 3px rgb(255 255 255 / 20%);
}
.header-logout { grid-column: 3; justify-self: end; margin: 0; }
.header-logout button { min-height: 44px; padding: 0 12px; border-color: transparent; background: transparent; color: var(--text); font-size: .94rem; font-weight: 500; box-shadow: none; }
.header-logout button:hover { border-color: var(--line); background: var(--surface-hover); color: var(--text); box-shadow: none; }

main { max-width: 1120px; margin: 0 auto; padding: 40px max(20px, env(safe-area-inset-right)) max(64px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(1.45rem, 2.5vw, 1.8rem); font-weight: 700; line-height: 1.25; letter-spacing: -.02em; }
h2 { margin-bottom: 4px; font-size: 1.15rem; font-weight: 650; line-height: 1.35; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: .94rem; }
.notice { margin-bottom: 28px; padding: 13px 15px; border: 1px solid var(--income); border-radius: var(--radius); background: var(--primary-soft); color: var(--text); box-shadow: var(--shadow); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.cycle {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto minmax(140px, 1fr);
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  text-align: center;
}
.cycle > div p { margin-bottom: 2px; color: var(--muted); font-size: .81rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.cycle > a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text); font-size: .92rem; font-weight: 600; text-decoration: none; }
.cycle > a:last-child { justify-content: flex-end; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 40px; }
.cards article { min-width: 0; min-height: 124px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); text-align: center; transition: border-color .18s ease, box-shadow .18s ease; }
.cards span { display: block; margin-bottom: 12px; color: var(--muted); font-size: .8rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.cards strong, .cards strong > span { display: block; font-size: clamp(1.8rem, 3.2vw, 2.2rem); font-weight: 650; line-height: 1.12; letter-spacing: -.03em; white-space: nowrap; }
.income { color: var(--income); }
.expense { color: var(--expense); }

.table-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin: 0 0 14px; }
.table-head .muted { margin: 0; }
.table-head > .button { align-self: flex-start; }
.button.dashboard-create, .button.account-create { border-color: var(--dashboard-action); background: var(--dashboard-action); }
.button.dashboard-create:hover, .button.account-create:hover { border-color: var(--dashboard-action-hover); background: var(--dashboard-action-hover); }
.compact-action { gap: 4px; }
.action-symbol { line-height: 1; }
.entries-head { display: grid; grid-template-columns: minmax(0, 1fr) max-content minmax(0, 1fr); align-items: center; gap: 12px; margin-bottom: 14px; }
.entries-head > .entries-copy, .accounts-section-head > .section-copy { grid-column: 1; }
.transaction-toolbar { display: contents; }
.transaction-toolbar .entry-tabs { grid-column: 2; margin-top: 0; }
.transaction-toolbar > .button, .accounts-section-head > .button { grid-column: 3; justify-self: end; align-self: center; }
.entry-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.entry-tabs a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 12px; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text-on-action); font-size: .9rem; font-weight: 600; text-decoration: none; }
.entry-tab-expenses { background: var(--tab-expense); }
.entry-tab-income { background: var(--tab-income); }
.entry-tab-overdue { background: var(--tab-overdue); }
.entry-tab-paid { background: var(--tab-paid); }
.entry-tab-expenses:hover, .entry-tab-expenses:active, .entry-tab-expenses[aria-current="page"] { background: var(--tab-expense-active); }
.entry-tab-income:hover, .entry-tab-income:active, .entry-tab-income[aria-current="page"] { background: var(--tab-income-active); }
.entry-tab-overdue:hover, .entry-tab-overdue:active, .entry-tab-overdue[aria-current="page"] { background: var(--tab-overdue-active); }
.entry-tab-paid:hover, .entry-tab-paid:active, .entry-tab-paid[aria-current="page"] { background: var(--tab-paid-active); }
.entry-tabs a[aria-current="page"] { border: 3px solid var(--text); }
.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--text-on-action);
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.button:hover, button:hover { border-color: var(--primary-hover); background: var(--primary-hover); color: var(--text-on-action); box-shadow: 0 3px 8px rgb(20 24 29 / 24%); }
.button:disabled, button:disabled, .button[aria-disabled="true"] { border-color: var(--line); background: var(--surface-hover); color: var(--text-on-action); cursor: not-allowed; opacity: .72; box-shadow: none; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); scrollbar-color: var(--muted) transparent; }
table { width: 100%; min-width: 680px; border-collapse: collapse; }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-hover); }
th { color: var(--muted); font-size: .74rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
td.amount { white-space: nowrap; }
.link { min-height: 36px; padding: 5px 0; border: 0; background: none !important; color: var(--text-link) !important; font-size: .9rem; text-decoration: underline; box-shadow: none !important; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }

.accounts { max-width: 640px; margin-top: 44px; content-visibility: auto; contain-intrinsic-size: auto 320px; }
.accounts.accounts-panel { max-width: none; margin-top: 0; }
.accounts-section { margin-top: 36px; }
.accounts ul { margin: 0; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); list-style: none; }
.accounts li { display: grid; grid-template-columns: minmax(0, 1fr) max-content auto; align-items: center; column-gap: 16px; padding: 16px; border-bottom: 1px solid var(--line); }
.accounts li:last-child { border: 0; }
.accounts li > span:first-child { display: grid; min-width: 0; gap: 3px; }
.accounts li > strong { justify-self: end; text-align: right; white-space: nowrap; }
.accounts li > .entry-actions { justify-content: flex-end; width: max-content; }
.accounts small, .form label small { color: var(--muted); font-weight: 400; }
.accounts .total { background: var(--surface-raised); font-weight: 650; }

.form-hint { margin: 18px 0 10px; color: var(--muted); font-size: .9rem; }
.form-hint span, .form label > span { color: var(--expense); }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 760px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.form label { display: block; min-width: 0; color: var(--text); font-size: .9rem; font-weight: 600; }
.form label > span { display: inline; margin-left: 2px; }
.form input, .form select, .form textarea { display: block; box-sizing: border-box; width: 100%; min-height: 44px; height: 44px; margin-top: 7px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-raised); color: var(--text); font-size: 1rem; font-weight: 400; line-height: 1.25; transition: border-color .18s ease, box-shadow .18s ease; }
.form textarea { min-height: 108px; resize: vertical; }
.form input::placeholder { color: var(--text-muted); }
.form input:hover, .form select:hover, .form textarea:hover { border-color: var(--muted); }
.form option { background: var(--surface); color: var(--text); }

.full { grid-column: 1 / -1; }
.actions { display: flex !important; align-items: center; justify-content: space-between; gap: 16px; margin-top: 4px; }
.actions a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; }
.page-heading { max-width: 680px; margin-bottom: 24px; }
.page-heading .muted { margin-bottom: 0; }
.profile-page { display: grid; gap: 20px; }
.profile-form { max-width: 760px; }
.profile-form h2 { margin: 0; }
.security-form { margin-top: 20px; }
.members { max-width: 860px; }
.member-list { display: grid; gap: 8px; margin: 0 0 32px; padding: 0; list-style: none; }
.member-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.member-identity { display: grid; min-width: 0; gap: 5px; }
.member-identity strong { color: var(--text); font-size: 1rem; font-weight: 650; }
.member-identity span { overflow-wrap: anywhere; color: var(--muted); font-size: .9rem; }
.member-identity .member-summary-meta { color: var(--text-secondary); font-size: .84rem; font-weight: 600; }
.member-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.member-actions form { margin: 0; }
.member-danger { border-color: var(--danger); background: transparent; color: var(--text); }
.member-danger:hover { border-color: var(--danger); background: var(--danger); color: var(--text-on-action); }
.member-password { position: relative; }
.member-password summary { display: inline-flex; min-height: 40px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); cursor: pointer; font-size: .88rem; font-weight: 600; }
.member-password[open] summary { background: var(--surface-hover); }
.member-password form { position: absolute; z-index: 5; top: calc(100% + 8px); right: 0; display: grid; width: min(280px, calc(100vw - 48px)); gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-raised); box-shadow: var(--shadow-raised); }
.member-password label { color: var(--text); font-size: .86rem; font-weight: 600; }
.member-password input { display: block; width: 100%; height: 40px; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.member-password button { min-height: 40px; padding: 8px 12px; }
.member-add { padding-top: 24px; border-top: 1px solid var(--line); }
.member-add h2 { margin-bottom: 4px; }
#bank-suggestions { display: none; max-height: 192px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-raised); }
.bank-suggestion { display: block; width: 100%; min-height: 44px; padding: 10px 12px; border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; background: var(--surface) !important; color: var(--text) !important; font-weight: 500 !important; text-align: left !important; }
.bank-suggestion:last-child { border-bottom: 0 !important; }
.bank-suggestion:hover, .bank-suggestion:focus-visible { background: var(--primary-soft) !important; }

.payment-dialog { width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-raised); }
.payment-dialog::backdrop { background: rgb(20 24 29 / 68%); }
.payment-modal { padding: 22px; }
.payment-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.payment-modal-head h2 { margin-bottom: 4px; }
.payment-modal-head .icon-button { flex: 0 0 44px; }
#payment-allocations { display: grid; gap: 12px; }
.payment-source-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, .55fr) 44px; align-items: end; gap: 10px; }
.payment-source-row label { color: var(--text); font-size: .9rem; font-weight: 600; }
.payment-source-row select, .payment-source-row input { display: block; box-sizing: border-box; width: 100%; height: 44px; margin-top: 7px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-raised); color: var(--text); font: inherit; }
.payment-remaining { min-height: 24px; margin: 16px 0; color: var(--expense); font-size: .9rem; font-weight: 600; }
.payment-remaining.is-valid { color: var(--income); }
.payment-modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.installment-dialog { width: min(620px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-raised); }
.installment-dialog::backdrop { background: rgb(20 24 29 / 68%); }
.installment-modal { padding: 22px; overflow-y: auto; }
.installment-modal ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.installment-item { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 4px 16px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.installment-item strong { justify-self: end; white-space: nowrap; }
.installment-status { grid-column: 1 / -1; font-size: .86rem; font-weight: 600; }
.installment-item.paid { color: var(--muted); text-decoration: line-through; opacity: .72; }
.installment-item.paid .installment-status { text-decoration: none; }
.installment-item.current { border-color: var(--expense); color: var(--expense); }
.installment-item.future { border-color: var(--accent-primary); color: var(--accent-primary); }
.installment-item.overdue { border-color: var(--danger); background: var(--primary-soft); color: var(--expense); font-weight: 600; }

.analytics-heading { margin-bottom: 28px; }
.analytics-heading h1 { margin-bottom: 0; }
.eyebrow { margin-bottom: 6px; color: var(--text); font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.analytics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-card { min-width: 0; margin: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.chart-card figcaption { margin-bottom: 14px; }
.chart-card h2 { margin-bottom: 4px; }
.chart-card figcaption .muted { margin-bottom: 0; }
.chart-wide { grid-column: 1 / -1; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg text { fill: var(--muted); font-size: 12px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { stroke: var(--text-secondary); stroke-width: 1.5; }
.chart-axis-label { fill: var(--text-secondary) !important; font-size: 12px; font-weight: 600; }
.chart-bar { fill: var(--chart-red); opacity: .92; }
.chart-line { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.chart-line-income { stroke: var(--chart-green); }
.chart-line-expense { stroke: var(--chart-red); }
.chart-empty { display: grid; min-height: 204px; place-items: center; padding: 20px; border: 1px dashed var(--line); border-radius: var(--radius-sm); color: var(--muted); text-align: center; }
.chart-detail { margin-top: 14px; color: var(--muted); font-size: .86rem; }
.chart-pie { display: block; width: min(100%, 240px); height: auto; margin: 0 auto; }
.chart-pie-track, .chart-pie-slice { fill: none; stroke-width: 24; transform: rotate(-90deg); transform-origin: 50% 50%; }
.chart-pie-track { stroke: var(--surface-raised); }
.chart-pie-slice { stroke-linecap: butt; }
.chart-pie text { fill: var(--muted); font-size: 12px; }
.chart-pie .chart-pie-total { fill: var(--text); font-size: 14px; font-weight: 650; }
.chart-tone-0 { stroke: var(--chart-red); background: var(--chart-red); }
.chart-tone-1 { stroke: var(--chart-yellow); background: var(--chart-yellow); }
.chart-tone-2 { stroke: var(--chart-orange); background: var(--chart-orange); }
.chart-tone-3 { stroke: var(--chart-green); background: var(--chart-green); }
.chart-tone-4 { stroke: var(--chart-blue); background: var(--chart-blue); }
.chart-tone-5 { stroke: var(--chart-purple); background: var(--chart-purple); }
.chart-tone-6 { stroke: var(--chart-cyan); background: var(--chart-cyan); }
.chart-tone-7 { stroke: var(--chart-pink); background: var(--chart-pink); }
.chart-legend { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chart-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.chart-legend strong { color: var(--text); font-size: .86rem; font-weight: 600; white-space: nowrap; }
.chart-swatch { width: 10px; height: 10px; border-radius: 50%; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

@media (max-width: 960px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  header { min-height: unset; padding: 14px 16px 10px; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; }
  header .main-nav { grid-column: 1 / -1; grid-row: 2; width: 100%; justify-content: center; }
  header .main-nav a { flex: 1; justify-content: center; padding: 0 8px; }
  .header-logout { grid-column: 2; grid-row: 1; }
  main { padding: 28px max(16px, env(safe-area-inset-right)) max(48px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .cycle { grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-bottom: 26px; }
  .cycle > div { grid-column: 1 / -1; grid-row: 1; }
  .cycle > a { grid-row: 2; font-size: .86rem; }
  .cycle > a:last-child { justify-content: flex-end; }
  .cards { gap: 12px; margin-bottom: 32px; }
  .cards article { min-height: 108px; padding: 16px; }
  .cards span { margin-bottom: 10px; font-size: .73rem; }
  .table-head { align-items: flex-start; gap: 14px; }
  .table-head .button { flex: 0 0 auto; }
  .entries-head { grid-template-columns: 1fr; }
  .entries-head > .entries-copy { grid-column: 1; }
  .transaction-toolbar {
    grid-column: 1;
    display: flex;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding: 2px;
  }
  .transaction-toolbar .entry-tabs { display: flex; flex: 1 1 0; flex-wrap: nowrap; gap: 4px; min-width: 260px; margin: 0; }
  .transaction-toolbar .entry-tabs a {
    flex: 1 1 0;
    min-width: 0;
    padding-right: 6px;
    padding-left: 6px;
    font-size: .78rem;
    white-space: nowrap;
  }
  .transaction-toolbar > .compact-action, .accounts-section-head > .compact-action {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }
  .compact-action .action-label { display: none; }
  .accounts-section-head { grid-template-columns: minmax(0, 1fr) max-content; align-items: start; }
  .accounts-section-head > .section-copy { grid-column: 1; grid-row: 1; }
  .accounts-section-head > .compact-action { grid-column: 2; grid-row: 1; justify-self: end; align-self: start; }
  .table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  table, tbody, tr, td { display: block; min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  tbody { display: grid; gap: 12px; }
  tbody tr { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
  tbody tr:hover { background: var(--surface); }
  td { display: grid; grid-template-columns: minmax(100px, 38%) 1fr; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  td::before { content: attr(data-label); color: var(--muted); font-size: .73rem; font-weight: 600; letter-spacing: .035em; text-transform: uppercase; }
  td.amount { align-items: center; }
  td:last-child { border: 0; }
  td.empty { display: block; }
  td.empty::before { content: none; }
  .entry-actions { justify-content: flex-end; }
  .accounts { max-width: none; margin-top: 36px; }
  .accounts-section { margin-top: 32px; }
  .analytics-grid { grid-template-columns: 1fr; gap: 14px; }
  .chart-wide { grid-column: auto; }
  .form { grid-template-columns: 1fr; gap: 16px; padding: 20px; }
  .payment-source-row { grid-template-columns: 1fr 1fr 44px; }
  .actions { margin-top: 2px; }
  .member-row { grid-template-columns: minmax(0, 1fr) max-content; }
  .member-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 430px) {
  .cards { grid-template-columns: 1fr; }
  .table-head { flex-direction: column; }
  .table-head .button { width: 100%; }
  .transaction-toolbar > .compact-action, .accounts-section-head > .compact-action { width: 44px; }
  .accounts-section-head > .compact-action { grid-column: 2; grid-row: 1; justify-self: end; }
  .actions { align-items: stretch !important; flex-direction: column-reverse; }
  .actions a, .actions button { width: 100%; justify-content: center; }
  .payment-modal { padding: 18px; }
  .payment-source-row { grid-template-columns: 1fr 44px; }
  .payment-source-row label:first-child { grid-column: 1 / -1; }
  .payment-modal-actions { align-items: stretch; flex-direction: column-reverse; }
  .payment-modal-actions .link, .payment-modal-actions button { width: 100%; justify-content: center; }
  .installment-modal { padding: 18px; }
  .accounts li { grid-template-columns: minmax(0, 1fr) max-content; gap: 12px; padding: 14px; }
  .accounts li > .entry-actions { grid-column: 1 / -1; }
  .header-logout button { width: 100%; justify-content: center; }
  .member-row { grid-template-columns: 1fr; gap: 12px; }
  .member-actions { grid-column: auto; width: 100%; }
  .member-actions > *, .member-actions button, .member-password { flex: 1; }
  .member-password summary { justify-content: center; width: 100%; }
  .member-password form { right: auto; left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
