:root {
  color-scheme: light;
  --ink: #1d2925;
  --muted: #78827d;
  --line: #e8ebe7;
  --paper: #f5f6f2;
  --white: #fff;
  --green: #27765b;
  --green-dark: #1e614a;
  --green-soft: #eaf3ed;
  --coral: #e88973;
  --shadow: 0 8px 26px rgba(29, 41, 37, .045);
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 3; display: flex; width: 246px; flex-direction: column; padding: 28px 18px 22px; background: #fff; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 38px; color: var(--ink); text-decoration: none; }
.brand strong { display: block; font-family: "Segoe UI", Arial, sans-serif; font-size: 19px; letter-spacing: -.7px; }
.brand small { display: block; padding-top: 2px; color: #9aa39e; font-size: 9px; font-weight: 700; letter-spacing: 1.4px; }
.brand-mark { display: inline-grid; width: 37px; height: 37px; flex: 0 0 auto; place-items: center; border-radius: 12px; background: var(--green); color: white; font-family: "Segoe UI", Arial, sans-serif; font-size: 21px; font-weight: 800; }
.nav-caption, .eyebrow { margin: 0; color: #929b96; font-size: 10px; font-weight: 700; letter-spacing: 1.35px; }
.nav-caption { padding: 0 12px 12px; }
.main-nav { display: grid; gap: 5px; }
.nav-link { display: flex; min-height: 45px; align-items: center; gap: 12px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: #65716b; text-align: left; font-size: 13px; font-weight: 600; transition: background .15s, color .15s; }
.nav-link:hover { background: #f5f7f4; color: var(--ink); }
.nav-link.active { background: var(--green-soft); color: var(--green-dark); }
.nav-icon { display: inline-grid; width: 21px; place-items: center; font-size: 17px; }
.sidebar-bottom { margin-top: auto; }
.privacy-note { display: flex; align-items: center; gap: 10px; margin: 0 2px 16px; padding: 12px 10px; border: 1px solid var(--line); border-radius: 9px; }
.privacy-note strong, .privacy-note small { display: block; }
.privacy-note strong { font-size: 11px; }
.privacy-note small { margin-top: 3px; color: var(--muted); font-size: 9px; }
#sidebar-username { overflow-wrap: anywhere; color: var(--ink); font-size: 10px; font-weight: 600; }
.privacy-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #4b9d76; box-shadow: 0 0 0 3px #e9f4ed; }
.account-setup-link { display: block; margin: -8px 0 7px 10px; padding: 3px 0; border: 0; background: transparent; color: var(--green); text-align: left; font-size: 10px; font-weight: 600; }
.account-setup-link:hover { color: var(--green-dark); text-decoration: underline; }
.logout-button { border: 0; background: transparent; color: #78827d; font-size: 12px; font-weight: 600; }
.logout-button:hover { color: #aa5145; }
.sidebar-bottom > .logout-button { padding: 7px 10px; }
.main-content { max-width: 1640px; min-height: 100vh; margin-left: 246px; padding: 0 42px 50px; }
.topbar { display: flex; height: 69px; align-items: center; justify-content: flex-end; border-bottom: 1px solid #e8ebe7; }
.today-label { margin: 0; color: #77827c; font-size: 11px; font-weight: 500; text-transform: capitalize; }
.mobile-brand, .mobile-logout { display: none; }
.page { display: none; padding-top: 36px; }
.page.active { display: block; animation: appear .2s ease-out; }
@keyframes appear { from { opacity: .6; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.page-heading h1 { margin: 7px 0 5px; font-family: "Segoe UI", Arial, sans-serif; font-size: clamp(26px, 3vw, 33px); font-weight: 700; letter-spacing: -1.2px; }
.muted { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.heading-chip { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 3px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #69756e; font-size: 10px; font-weight: 600; white-space: nowrap; }
.income-chip { color: var(--green-dark); }
.poker-chip { color: #6a6240; }
.account-icon { background: #edf3ee; color: var(--green); }
.content-grid { display: grid; grid-template-columns: minmax(290px, .75fr) minmax(400px, 1.25fr); gap: 18px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: 12px; background: var(--white); box-shadow: var(--shadow); }
.form-card, .list-card, .poker-summary-card { padding: 23px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.card-heading h2 { margin: 5px 0 0; font-family: "Segoe UI", Arial, sans-serif; font-size: 16px; font-weight: 700; letter-spacing: -.35px; }
.card-icon { display: inline-grid; width: 34px; height: 34px; place-items: center; border-radius: 9px; background: #fbeeea; color: #d77862; font-size: 17px; }
.income-icon { background: var(--green-soft); color: var(--green); }
.poker-icon { background: #f4f1e7; color: #887b4d; }
label { display: block; margin: 0 0 7px; color: #414d47; font-size: 11px; font-weight: 600; }
.form-card > label, .form-card > .input-affix, .form-card > input, .form-card > select, .form-card > .form-row { margin-bottom: 15px; }
.optional { color: #9ba39e; font-weight: 400; }
input, select { width: 100%; height: 39px; padding: 0 11px; border: 1px solid #e4e8e4; border-radius: 7px; outline: none; background-color: white; color: var(--ink); font-size: 11px; transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: #a7afaa; }
input:focus, select:focus { border-color: #77aa91; box-shadow: 0 0 0 3px rgba(39, 118, 91, .09); }
.suggestion-field { position: relative; margin-bottom: 15px; }
.suggestion-field > input { padding-right: 40px; }
.suggestion-toggle { position: absolute; top: 4px; right: 4px; display: grid; width: 31px; height: 31px; place-items: center; border: 0; border-radius: 5px; background: transparent; color: #78827d; font-size: 17px; }
.suggestion-toggle:hover, .suggestion-toggle[aria-expanded="true"] { background: #f2f5f1; color: var(--green-dark); }
.suggestion-menu { position: absolute; top: calc(100% + 4px); right: 0; left: 0; z-index: 4; max-height: 190px; overflow-y: auto; padding: 4px; border: 1px solid #e4e8e4; border-radius: 8px; background: white; box-shadow: 0 8px 20px rgba(29, 41, 37, .12); }
.suggestion-option { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--ink); text-align: left; font-size: 11px; }
.suggestion-option:hover, .suggestion-option:focus { outline: none; background: var(--green-soft); color: var(--green-dark); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row > div { min-width: 0; }
.input-affix { position: relative; }
.input-affix input { padding-right: 34px; }
.input-affix > span { position: absolute; top: 50%; right: 12px; color: #8e9992; font-size: 11px; transform: translateY(-50%); pointer-events: none; }
.button { display: inline-flex; min-height: 39px; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 0; border-radius: 7px; font-size: 11px; font-weight: 700; transition: background .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--green); color: white; }
.button-primary:hover { background: var(--green-dark); }
.button-dark { background: #26342e; color: white; }
.button-dark:hover { background: #17231d; }
.button-wide { width: 100%; margin-top: 5px; }
.expense-form-actions { display: grid; gap: 8px; }
.expense-form-actions .button-wide { margin-top: 5px; }
.button-cancel { border: 1px solid var(--line); background: #f7f8f6; color: #647068; }
.button-cancel:hover { background: #ecefea; }
.count-pill { display: inline-grid; min-width: 25px; height: 25px; place-items: center; padding: 0 7px; border-radius: 20px; background: #f2f5f1; color: #617067; font-size: 10px; font-weight: 700; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 10px 8px; border-bottom: 1px solid var(--line); color: #99a19c; font-size: 9px; font-weight: 700; letter-spacing: .55px; text-transform: uppercase; white-space: nowrap; }
td { padding: 12px 8px; border-bottom: 1px solid #f0f2ef; color: #58645d; font-size: 10px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td strong { display: block; color: #303d36; font-size: 11px; font-weight: 600; }
td small { display: block; margin-top: 3px; color: #9aa39e; font-size: 9px; }
.align-right { text-align: right; }
.amount-cell { color: #bc6758; font-weight: 700; text-align: right; }
.amount-positive { color: var(--green); }
.amount-negative { color: #c76b58; }
.delete-button { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #a7afaa; font-size: 15px; }
.delete-button:hover { background: #fff1ee; color: #bd5d4e; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.edit-button { min-height: 27px; padding: 0 8px; border: 1px solid #e8ece8; border-radius: 6px; background: #fff; color: #53645a; font-size: 9px; font-weight: 600; }
.edit-button:hover { border-color: #b7d0bf; background: #f2f7f3; color: var(--green-dark); }
.empty-state, .chart-empty { margin: 22px 0; color: #909b94; font-size: 11px; text-align: center; }
.list-footnote { margin: 12px 0 0; color: #a1a9a4; font-size: 9px; }
.filter-card { padding: 17px 19px 19px; margin-bottom: 17px; }
.filter-title { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 11px; }
.filter-icon { display: inline-grid; width: 25px; height: 25px; place-items: center; border-radius: 6px; background: #f1f5f1; color: var(--green); font-size: 15px; }
.filter-fields { display: grid; grid-template-columns: repeat(4, minmax(110px, 1fr)) auto; align-items: end; gap: 10px; }
.filter-fields > div { min-width: 0; }
.filter-fields .button { min-width: 90px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 17px; }
.stat-card { position: relative; overflow: hidden; min-height: 112px; padding: 17px 18px; border: 1px solid var(--line); border-radius: 11px; background: white; box-shadow: var(--shadow); }
.stat-label { display: block; margin-bottom: 8px; color: #89938d; font-size: 9px; font-weight: 700; letter-spacing: 1px; }
.stat-card > strong { display: block; font-family: "Segoe UI", Arial, sans-serif; font-size: 22px; font-weight: 700; letter-spacing: -.6px; }
.stat-detail { display: block; margin-top: 5px; color: #9aa39e; font-size: 9px; }
.stat-symbol { position: absolute; top: 15px; right: 16px; display: grid; width: 29px; height: 29px; place-items: center; border-radius: 8px; font-size: 15px; }
.income-symbol { background: #eaf4ed; color: var(--green); }
.expense-symbol { background: #fcf0ed; color: #d87965; }
.balance-symbol { background: #f1f2eb; color: #7e865d; }
.charts-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 14px; }
.chart-card { min-width: 0; padding: 20px; }
.chart-card .card-heading { align-items: flex-start; margin-bottom: 9px; }
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: #839087; font-size: 9px; }
.chart-legend i { width: 7px; height: 7px; border-radius: 2px; }
.legend-income { background: var(--green); }
.legend-expense { margin-left: 5px; background: var(--coral); }
canvas { display: block; width: 100%; height: 225px; }
.chart-card:nth-child(2) canvas { height: 225px; }
.chart-empty { margin: 5px 0 18px; }
.poker-content-grid { grid-template-columns: minmax(400px, 1.35fr) minmax(270px, .65fr); margin-bottom: 18px; }
.poker-summary-card { min-height: 100%; }
.poker-summary-card .card-heading { margin-bottom: 19px; }
.poker-stat { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f2ef; color: #707c75; font-size: 11px; }
.poker-stat strong { color: #303d36; font-size: 13px; }
.hourly-card { margin: 15px 0 6px; padding: 15px; border-radius: 9px; background: var(--green-soft); }
.hourly-card > span { display: block; margin-bottom: 7px; color: #6b8977; font-size: 9px; font-weight: 700; letter-spacing: .8px; }
.hourly-card > strong { color: var(--green-dark); font-family: "Segoe UI", Arial, sans-serif; font-size: 24px; }
.hourly-card small { font-family: "Segoe UI", Arial, sans-serif; font-size: 11px; font-weight: 500; }
.poker-chart-section { padding: 20px; }
.poker-filter-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.poker-filter-row .card-heading { margin-bottom: 7px; }
.inline-filters { display: flex; align-items: flex-end; gap: 8px; }
.inline-filters label { margin: 0; color: #78827d; font-size: 9px; }
.inline-filters input { display: block; width: 135px; height: 34px; margin-top: 5px; font-size: 10px; }
.inline-filters .button { min-height: 34px; }
.poker-chart-section canvas { height: 220px; }
.poker-table-wrap { margin-top: 12px; border-top: 1px solid var(--line); }
.mortgage-content-grid { grid-template-columns: minmax(280px, .75fr) minmax(430px, 1.25fr); margin-bottom: 18px; }
.mortgage-chip { color: var(--green-dark); }
.mortgage-icon { background: #edf3ee; color: var(--green); }
.mortgage-summary-card, .mortgage-schedule-card { padding: 22px; }
.mortgage-summary-card { min-width: 0; }
.mortgage-summary-card .card-heading { margin-bottom: 18px; }
.mortgage-unconfigured { padding: 18px; border: 1px dashed #dce5dd; border-radius: 9px; background: #f8faf8; color: #78827d; font-size: 11px; line-height: 1.7; }
.mortgage-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mortgage-kpi { min-width: 0; padding: 14px; border: 1px solid #edf0ed; border-radius: 9px; background: #fbfcfa; }
.mortgage-kpi > span { display: block; min-height: 23px; margin-bottom: 6px; color: #87928b; font-size: 9px; font-weight: 700; letter-spacing: .55px; line-height: 1.4; }
.mortgage-kpi > strong { display: block; overflow-wrap: anywhere; color: #303d36; font-family: "Segoe UI", Arial, sans-serif; font-size: clamp(14px, 1.6vw, 20px); font-weight: 700; }
.mortgage-kpi.mortgage-payoff-kpi { background: var(--green-soft); }
.mortgage-payoff-kpi > strong { color: var(--green-dark); }
.mortgage-warning { margin: 14px 0 0; padding: 11px 13px; border: 1px solid #f1d7ae; border-radius: 8px; background: #fff8e9; color: #835924; font-size: 10px; line-height: 1.6; }
.form-hint { margin: -4px 0 14px; color: #869189; font-size: 10px; line-height: 1.6; }
.account-dialog { position: fixed; width: min(440px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 32px); padding: 26px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 15px 48px rgba(29, 41, 37, .16); color: var(--ink); }
.account-dialog::backdrop { background: rgba(25, 36, 30, .35); }
.dialog-close { position: absolute; top: 11px; right: 13px; width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: #78827d; font-size: 22px; }
.dialog-close:hover { background: #f2f5f1; }
.account-dialog-form .card-heading { padding-right: 20px; }
.account-dialog-form > label { margin-bottom: 7px; }
.account-dialog-form > input { margin-bottom: 15px; }
.account-dialog-copy { margin: -8px 0 18px; }
.account-dialog-form .form-error { margin: 10px 0 0; }
.mortgage-chart-wrap { margin-top: 7px; }
.mortgage-chart-wrap canvas { height: 195px; }
.mortgage-schedule-card { margin-bottom: 20px; }
.mortgage-schedule-card .card-heading { margin-bottom: 14px; }
.mortgage-schedule-card td { font-variant-numeric: tabular-nums; }
.mortgage-more { display: flex; margin: 14px auto 0; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 5; max-width: min(390px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 8px; background: #26342e; box-shadow: 0 8px 24px rgba(0,0,0,.15); color: white; font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: none; }
.toast.error { background: #a34f43; }
.login-screen { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: radial-gradient(ellipse at 75% 16%, #e7f0e9 0, transparent 37%), var(--paper); }
.login-card { width: min(100%, 390px); padding: 34px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 15px 48px rgba(29, 41, 37, .08); }
.login-card .brand-mark { margin-bottom: 25px; }
.login-card h1 { margin: 8px 0; font-family: "Segoe UI", Arial, sans-serif; font-size: 25px; letter-spacing: -.8px; }
.login-card .muted { margin-bottom: 25px; }
.login-card label { margin-bottom: 7px; }
.login-card input { margin-bottom: 15px; }
.form-error { min-height: 16px; margin: 10px 0 0; color: #a34f43; font-size: 10px; }

@media (max-width: 1100px) {
  .main-content { padding-right: 25px; padding-left: 25px; }
  .content-grid { grid-template-columns: minmax(260px, .8fr) minmax(350px, 1.2fr); gap: 13px; }
  .form-card, .list-card, .poker-summary-card { padding: 18px; }
  .filter-fields { grid-template-columns: repeat(2, 1fr) auto; }
  .filter-fields > div:nth-child(3) { grid-column: 1; }
}
@media (max-width: 800px) {
  .sidebar { width: 70px; align-items: center; padding: 17px 8px; }
  .brand { padding: 0 0 30px; }
  .brand > span:last-child, .nav-caption, .privacy-note, .sidebar-bottom > .logout-button { display: none; }
  .main-nav { width: 100%; }
  .nav-link { justify-content: center; width: 52px; height: 47px; padding: 0; font-size: 0; }
  .nav-icon { font-size: 17px; }
  .sidebar-bottom { display: none; }
  .main-content { margin-left: 70px; padding-right: 22px; padding-left: 22px; }
  .content-grid, .poker-content-grid, .mortgage-content-grid { grid-template-columns: 1fr; }
  .form-card { max-width: none; }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card:nth-child(2) canvas { height: 205px; }
  .poker-filter-row { flex-direction: column; }
}
@media (max-width: 540px) {
  .sidebar { position: fixed; inset: auto 0 0; width: 100%; height: 61px; flex-direction: row; justify-content: center; padding: 5px 8px; border-top: 1px solid var(--line); border-right: 0; }
  .brand, .sidebar-bottom { display: none; }
  .main-nav { display: flex; width: 100%; justify-content: space-around; gap: 3px; }
  .nav-link { width: auto; min-width: 54px; height: 48px; flex-direction: column; justify-content: center; gap: 2px; font-size: 8px; }
  .nav-icon { height: 20px; font-size: 15px; }
  .nav-link[data-page="poker"] { font-size: 8px; }
  .main-content { margin: 0; padding: 0 14px 82px; }
  .topbar { height: 58px; justify-content: space-between; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-family: "Segoe UI", Arial, sans-serif; font-size: 14px; }
  .mobile-brand .brand-mark { width: 29px; height: 29px; border-radius: 9px; font-size: 16px; }
  .today-label { display: none; }
  .mobile-logout { display: inline; }
  .page { padding-top: 24px; }
  .page-heading { align-items: flex-start; margin-bottom: 18px; }
  .page-heading h1 { font-size: 27px; }
  .heading-chip { display: none; }
  .content-grid, .poker-content-grid { gap: 12px; }
  .form-card, .list-card, .poker-summary-card, .chart-card, .poker-chart-section { padding: 16px; }
  .card-heading { margin-bottom: 17px; }
  .filter-card { padding: 14px; }
  .filter-fields { grid-template-columns: 1fr 1fr; }
  .filter-fields > div:nth-child(3) { grid-column: auto; }
  .filter-fields .button { grid-column: 1 / -1; }
  .stats-grid { grid-template-columns: 1fr; gap: 8px; }
  .stat-card { min-height: 88px; padding: 13px 15px; }
  .stat-card > strong { font-size: 19px; }
  .stat-symbol { top: 13px; }
  .chart-legend { font-size: 8px; }
  canvas { height: 205px; }
  .inline-filters { width: 100%; flex-wrap: wrap; }
  .inline-filters label { flex: 1 1 40%; }
  .inline-filters input { width: 100%; }
  .inline-filters .button { flex: 1; }
  .poker-chart-section canvas { height: 190px; }
  .mortgage-summary-card, .mortgage-schedule-card { padding: 16px; }
  .mortgage-kpis { gap: 7px; }
  .mortgage-kpi { padding: 11px; }
  .mortgage-kpi > strong { font-size: 15px; }
  .mortgage-chart-wrap canvas { height: 175px; }
  .login-card { padding: 26px 22px; }
}
