:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f5f7fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
.shell { width: min(100% - 32px, 980px); margin: 0 auto; padding: 30px 0 56px; }
.topbar, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar { margin-bottom: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.7rem, 4vw, 2.2rem); letter-spacing: -0.04em; }
h2 { margin-bottom: 18px; font-size: 1.15rem; }
h3 { margin: 24px 0 12px; font-size: 0.95rem; }
.eyebrow { margin-bottom: 7px; color: #64748b; font-size: 0.7rem; font-weight: 750; letter-spacing: 0.12em; }
.muted { color: #64748b; }
.small { font-size: 0.82rem; }
.card { padding: 22px; border: 1px solid #e7ebf2; border-radius: 16px; background: #fff; box-shadow: 0 5px 20px #1d2b4408; }
.auth-card { max-width: 460px; margin: 7vh auto; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #344054; font-size: 0.88rem; font-weight: 600; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #d9e0ea; border-radius: 9px; background: white; color: #172033; }
input:focus, select:focus { outline: 3px solid #bfdbfe; border-color: #3b82f6; }
.button { min-height: 44px; padding: 10px 16px; border: 0; border-radius: 9px; background: #2563eb; color: white; font-weight: 700; cursor: pointer; }
.button:hover { background: #1d4ed8; }
.button.secondary { background: #eaf0ff; color: #1d4ed8; }
.button:disabled, button:disabled, input:disabled { cursor: not-allowed; opacity: 0.6; }
.text-button { display: inline-block; margin-top: 14px; padding: 4px 0; border: 0; background: none; color: #2563eb; font-weight: 650; text-decoration: none; cursor: pointer; }
.summary { margin-bottom: 18px; }
.dashboard-controls { margin-bottom: 18px; }
.dashboard-controls label { margin-bottom: 8px; }
.summary .section-heading { align-items: flex-start; }
.summary h2 { margin-bottom: 0; }
.summary input { width: auto; }
.amount-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 24px 0 18px; }
.amount-grid div { display: grid; gap: 7px; }
.amount-grid strong { font-size: clamp(1.45rem, 4vw, 2rem); letter-spacing: -0.04em; }
.progress-track { height: 9px; overflow: hidden; border-radius: 9px; background: #e9edf4; }
.progress { width: 0; height: 100%; border-radius: inherit; background: #2563eb; transition: width .2s ease; }
.progress.warning { background: #f59e0b; }
.progress.over { background: #dc2626; }
.download { margin-top: 8px; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.family-trends { margin-bottom: 18px; }
.family-trends-heading { margin-bottom: 12px; }
.family-trends-heading h2 { margin-bottom: 0; }
.family-trends-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.family-balance-trend-card { grid-column: 1 / -1; }
.chart-card { min-width: 0; }
.chart-card h2 { margin-bottom: 0; }
.chart-card .section-heading { margin-bottom: 18px; }
.chart-card .section-heading > strong { color: #344054; white-space: nowrap; }
.bar-chart { display: grid; gap: 14px; }
.chart-row { display: grid; gap: 6px; }
.chart-row-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.86rem; font-weight: 650; }
.chart-row-heading strong { white-space: nowrap; }
.chart-row-meta { color: #64748b; font-size: 0.75rem; }
.chart-track { height: 9px; overflow: hidden; border-radius: 8px; background: #e9edf4; }
.chart-bar { height: 100%; min-width: 0; border-radius: inherit; background: var(--chart-color, #2563eb); transition: width .2s ease; }
.chart-row.over-budget .chart-bar { background: #dc2626; }
.chart-budget-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chart-budget-form label { color: #64748b; font-size: 0.76rem; white-space: nowrap; }
.chart-budget-form input { width: 120px; min-height: 34px; padding: 5px 8px; font-size: 0.8rem; }
.chart-budget-form .text-button { margin: 0; font-size: 0.8rem; }
.chart-empty { color: #64748b; font-size: 0.85rem; }
.line-chart { min-width: 0; }
.line-chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.line-chart-tick line { stroke: #e9edf4; stroke-width: 1; }
.line-chart-tick text, .line-chart-month { fill: #64748b; font-size: 11px; }
.line-chart-path { fill: none; stroke: var(--line-color, #2563eb); stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.line-chart-point { fill: var(--line-color, #2563eb); stroke: white; stroke-width: 2; }
.line-chart-zero { stroke: #475467; stroke-dasharray: 5 4; stroke-width: 1.5; }
.line-chart-negative .line-chart-path, .line-chart-negative .line-chart-point { stroke: #dc2626; }
.line-chart-negative .line-chart-point { fill: #dc2626; }
.line-chart-positive .line-chart-path, .line-chart-positive .line-chart-point { stroke: #16a34a; }
.line-chart-positive .line-chart-point { fill: #16a34a; }
.line-chart-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; }
.line-chart-legend-item { display: inline-flex; align-items: center; gap: 7px; color: #475467; font-size: 0.8rem; }
.line-chart-legend-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-color); }
.compact { gap: 10px; }
.category-list, .expense-list { display: grid; gap: 10px; }
.category-row, .expense-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.category-row { font-size: 0.88rem; }
.category-name { display: flex; align-items: center; gap: 8px; }
.category-spend { display: grid; justify-items: end; gap: 3px; }
.category-budget-form { display: flex; align-items: center; gap: 6px; }
.category-budget-form input { width: 110px; min-height: 34px; padding: 5px 8px; font-size: 0.8rem; }
.category-budget-form .text-button { margin: 0; font-size: 0.8rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.category-budget { display: block; margin-top: 3px; color: #64748b; font-size: 0.76rem; }
.family-balance { margin-bottom: 18px; }
.family-user-category-cards { display: grid; gap: 10px; margin-top: 20px; }
.family-user-card { border: 1px solid #e7ebf2; border-radius: 12px; background: #fff; }
.family-user-card-summary { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; font-weight: 650; cursor: pointer; list-style: none; }
.family-user-card-summary::-webkit-details-marker { display: none; }
.family-user-card-summary::after { content: "+"; color: #2563eb; font-size: 1.1rem; }
.family-user-card[open] .family-user-card-summary::after { content: "−"; }
.family-user-category-list { display: grid; gap: 14px; padding: 0 16px 16px; }
.family-user-category { display: grid; gap: 6px; }
.family-user-category-heading, .family-user-category-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.family-user-category-heading { font-size: 0.82rem; }
.family-user-category-heading strong { text-align: right; }
.family-user-category-meta { color: #64748b; font-size: 0.74rem; }
.family-user-category.over-budget .chart-bar { background: #dc2626; }
.collapsible-card { min-width: 0; }
.collapsible-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; }
.collapsible-summary::-webkit-details-marker { display: none; }
.collapsible-summary::after { content: "+"; flex: 0 0 auto; color: #2563eb; font-size: 1.2rem; }
.collapsible-card[open] > .collapsible-summary::after,
.contributions-details[open] > .collapsible-summary::after { content: "−"; }
.collapsible-card[open] > .collapsible-summary { margin-bottom: 18px; }
.collapsible-summary h2, .collapsible-summary h3 { margin: 0; }
.collapsible-summary .eyebrow { margin-bottom: 7px; }
.budget-summary { justify-content: flex-start; }
.contributions-details { margin-top: 20px; padding-top: 8px; border-top: 1px solid #e7ebf2; }
.contributions-details .collapsible-summary { padding: 8px 0; }
.contributions-details .collapsible-summary h3 { margin: 8px 0; }
.contributions-details[open] .collapsible-summary { margin-bottom: 10px; }
.expense-entry-card { position: fixed; right: max(18px, calc((100vw - 980px) / 2)); bottom: max(18px, env(safe-area-inset-bottom, 0px)); z-index: 20; display: flex; align-items: center; width: max-content; max-width: calc(100vw - 36px); padding: 0; border: 0; background: transparent; box-shadow: none; }
.expense-entry-card .button { width: auto; min-height: 52px; padding: 12px 20px; border-radius: 999px; box-shadow: 0 8px 24px #17203333; }
.expense-modal { width: min(100% - 32px, 480px); max-height: min(90vh, 760px); padding: 24px; overflow-y: auto; border: 1px solid #e7ebf2; border-radius: 16px; background: #fff; color: #172033; box-shadow: 0 20px 60px #10182833; }
.expense-modal::backdrop { background: #10182880; }
.expense-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.expense-modal-header h2 { margin: 0; }
.modal-close { width: 36px; height: 36px; border: 0; border-radius: 8px; background: #f1f5f9; color: #344054; font-size: 1.5rem; line-height: 1; cursor: pointer; }
.modal-close:hover { background: #e2e8f0; }
.fund-card { margin-bottom: 18px; }
.fund-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fund-list { display: grid; gap: 16px; }
.fund-row { display: grid; gap: 7px; padding-top: 14px; border-top: 1px solid #eef1f5; }
.fund-row-heading, .fund-row-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fund-row-heading { font-size: 0.88rem; }
.fund-row-heading > strong { white-space: nowrap; }
.fund-row-meta { color: #64748b; font-size: 0.76rem; }
.fund-row.over-fund .chart-bar { background: #dc2626; }
.fund-contribution-section { margin-top: 24px; padding-top: 8px; border-top: 1px solid #e7ebf2; }
.fund-contribution-section h3 { margin-top: 16px; }
.contribution-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 12px; }
.contribution-list { display: grid; gap: 0; }
.user-balance-list { display: grid; gap: 16px; }
.user-balance-row { display: grid; gap: 8px; }
.user-balance-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.user-balance-heading strong { white-space: nowrap; }
.user-balance-meta { display: flex; justify-content: space-between; gap: 10px; color: #64748b; font-size: 0.78rem; }
.balance-track { height: 8px; overflow: hidden; border-radius: 8px; background: #e9edf4; }
.balance-bar { height: 100%; border-radius: inherit; background: #2563eb; }
.balance-difference { font-size: 0.8rem; font-weight: 650; }
.balance-difference.positive { color: #b42318; }
.balance-difference.negative { color: #15803d; }
.expense-row { padding: 12px 0; border-bottom: 1px solid #eef1f5; }
.expense-row:last-child { border-bottom: 0; }
.expense-details { margin-bottom: 18px; }
.expense-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; }
.expense-summary::-webkit-details-marker { display: none; }
.expense-summary h2 { margin: 0; }
.expense-summary::after { content: "+"; color: #2563eb; font-size: 1.25rem; }
.expense-details[open] .expense-summary { margin-bottom: 12px; }
.expense-details[open] .expense-summary::after { content: "−"; }
.expense-meta { min-width: 0; }
.expense-title { overflow: hidden; margin-bottom: 4px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.expense-subtitle { color: #64748b; font-size: 0.8rem; }
.expense-actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.delete-button { border: 0; background: none; color: #b42318; cursor: pointer; }
.message { position: fixed; right: 16px; bottom: 88px; max-width: min(440px, calc(100vw - 32px)); padding: 13px 16px; border-radius: 10px; background: #172033; color: white; box-shadow: 0 8px 24px #17203333; }
.hidden { display: none !important; }

@media (max-width: 680px) {
  .shell { width: min(100% - 22px, 520px); padding-top: 20px; }
  .card { padding: 18px; border-radius: 13px; }
  .columns { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .family-trends-grid { grid-template-columns: 1fr; }
  .family-balance-trend-card { grid-column: auto; }
  .amount-grid { gap: 12px; }
  .fund-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contribution-form { grid-template-columns: 1fr; }
  .fund-row-meta { align-items: flex-start; flex-direction: column; gap: 4px; }
  .family-user-card-summary, .family-user-category-heading, .family-user-category-meta { align-items: flex-start; flex-direction: column; }
}
