:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17211f;
  background: #f5f7f6;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --green: #16785d;
  --green-dark: #105941;
  --green-soft: #e7f4ef;
  --ink: #17211f;
  --muted: #78827f;
  --line: #e8edeb;
  --surface: #fff;
  --red: #c44949;
  --shadow: 0 12px 32px rgb(22 44 36 / 6%);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.boot-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; color: #fff; background: var(--green); font-size: 24px; font-weight: 800; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr); background: #fff; }
.auth-story { display: flex; flex-direction: column; justify-content: space-between; padding: 48px clamp(36px, 7vw, 100px); color: #fff; background: radial-gradient(circle at 16% 90%, #2f8d70 0, transparent 37%), linear-gradient(145deg, #123f34, #0d2826); }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; }
.auth-brand .brand-mark { color: var(--green-dark); background: #fff; }
.auth-story-copy { max-width: 480px; margin: auto 0; }
.eyebrow { color: #82cfb2; font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.auth-story h1 { margin: 16px 0; font-size: clamp(36px, 4vw, 58px); line-height: 1.08; letter-spacing: -.045em; }
.auth-story p { max-width: 420px; color: #c4d9d2; font-size: 16px; line-height: 1.75; }
.auth-foot { color: #a7c3ba; font-size: 12px; }
.auth-panel { display: grid; place-items: center; padding: 36px; }
.auth-card { width: min(100%, 430px); }
.auth-mark { margin-bottom: 20px; }
.auth-card h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.04em; }
.auth-card > p { margin: 0 0 28px; color: var(--muted); }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field label { color: #47514e; font-size: 13px; font-weight: 700; }
.field input, .field select, .search-input { min-height: 46px; width: 100%; padding: 0 13px; border: 1px solid #dfe6e3; border-radius: 10px; outline: none; background: #fff; color: var(--ink); }
.field input:focus, .field select:focus, .search-input:focus { border-color: #4aa484; box-shadow: 0 0 0 3px rgb(37 143 105 / 12%); }
.auth-switch { margin-top: 20px !important; color: var(--muted); text-align: center; font-size: 14px; }
.link-button { padding: 0; border: 0; color: var(--green); background: transparent; font-weight: 800; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 3; display: flex; width: 248px; flex-direction: column; padding: 26px 17px 18px; color: #d7e4df; background: #14251f; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 34px; color: #fff; font-size: 18px; font-weight: 800; }
.sidebar-brand .brand-mark { width: 38px; height: 38px; border-radius: 12px; color: var(--green-dark); background: #d8f2e7; font-size: 20px; }
.nav-caption { padding: 0 11px 10px; color: #789087; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.nav-list { display: grid; gap: 5px; }
.nav-button { display: flex; min-height: 44px; align-items: center; gap: 12px; padding: 0 12px; border: 0; border-radius: 9px; color: #abc0b7; background: transparent; text-align: left; font-size: 13px; font-weight: 650; }
.nav-button:hover { color: #fff; background: #203b31; }
.nav-button.active { color: #fff; background: #245541; }
.nav-icon { width: 20px; color: #9dcbb8; text-align: center; font-size: 17px; }
.sidebar-bottom { margin-top: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 14px 8px; border-top: 1px solid #294037; }
.user-copy { min-width: 0; }
.user-avatar { display: grid; width: 35px; height: 35px; flex: 0 0 35px; place-items: center; border-radius: 50%; color: #154b39; background: #c8ecdc; font-size: 12px; font-weight: 800; }
.user-name { overflow: hidden; color: #eef4f1; font-size: 12px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.user-email { overflow: hidden; margin-top: 3px; color: #86a095; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.logout-button { width: 100%; justify-content: flex-start; }

.main-area { min-height: 100vh; margin-left: 248px; }
.topbar { display: flex; min-height: 74px; align-items: center; justify-content: space-between; gap: 20px; padding: 0 38px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 90%); }
.topbar-title { color: #34413d; font-size: 13px; font-weight: 700; }
.topbar-date { color: var(--muted); font-size: 12px; }
.main-content { width: min(1440px, 100%); margin: 0 auto; padding: 34px 38px 56px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; color: var(--ink); font-size: 28px; letter-spacing: -.045em; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.button { display: inline-flex; min-height: 41px; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; color: #fff; background: var(--green); font-size: 12px; font-weight: 800; transition: background .15s, transform .15s; }
.button:hover { background: var(--green-dark); transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; }
.button.secondary { border-color: #dfe7e3; color: #40504a; background: #fff; }
.button.secondary:hover { background: #f4f8f6; }
.button.danger { border-color: #f1dada; color: var(--red); background: #fff; }
.button.small { min-height: 32px; padding: 0 10px; font-size: 11px; }
.button.full { width: 100%; min-height: 47px; }
.error-banner { margin: 0 0 18px; padding: 12px 14px; border: 1px solid #f1d1d1; border-radius: 9px; color: #9e3434; background: #fff5f5; font-size: 13px; }
.success-banner { margin: 0 0 18px; padding: 12px 14px; border: 1px solid #d0e9dc; border-radius: 9px; color: #176447; background: #f0faf5; font-size: 13px; }

.account-switch { display: flex; gap: 8px; overflow-x: auto; margin: -4px 0 18px; padding: 3px 1px 5px; }
.account-option { flex: 0 0 auto; min-height: 35px; padding: 0 14px; border: 1px solid #e0e8e4; border-radius: 20px; color: #64716c; background: #fff; font-size: 11px; font-weight: 750; }
.account-option:hover { border-color: #a6cbbb; }
.account-option.active { border-color: #1d795b; color: #fff; background: #1d795b; }
.balance-banner { position: relative; overflow: hidden; display: flex; min-height: 190px; align-items: center; justify-content: space-between; gap: 24px; padding: 28px 34px; border-radius: 15px; color: #fff; background: linear-gradient(115deg, #145d49, #208363); box-shadow: 0 14px 30px rgb(21 108 79 / 16%); }
.balance-banner::after { position: absolute; top: -110px; right: 7%; width: 290px; height: 290px; border: 1px solid rgb(255 255 255 / 12%); border-radius: 50%; box-shadow: 0 0 0 35px rgb(255 255 255 / 4%), 0 0 0 72px rgb(255 255 255 / 3%); content: ""; pointer-events: none; }
.balance-copy, .balance-numbers { position: relative; z-index: 1; }
.balance-label { color: #c4e5d7; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.balance-amount { margin: 11px 0 8px; font-size: clamp(34px, 4vw, 48px); font-weight: 800; letter-spacing: -.05em; }
.balance-note { color: #c4e5d7; font-size: 11px; }
.balance-numbers { display: flex; gap: clamp(25px, 5vw, 68px); padding-right: 8%; }
.balance-number-label { color: #c4e5d7; font-size: 11px; }
.balance-number-value { margin-top: 8px; font-size: 19px; font-weight: 800; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.metric-card, .panel, .household-card, .budget-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.metric-card { min-height: 105px; padding: 17px 19px; }
.metric-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-icon { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 9px; color: #1d795b; background: var(--green-soft); font-size: 14px; }
.metric-icon.expense-icon { color: #b34d4d; background: #fbefef; }
.metric-value { margin-top: 12px; color: var(--ink); font-size: 23px; font-weight: 800; letter-spacing: -.035em; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .9fr); gap: 16px; align-items: start; }
.panel { overflow: hidden; }
.panel-heading { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 14px; letter-spacing: -.015em; }
.panel-heading .muted { color: var(--muted); font-size: 11px; }
.panel-body { padding: 8px 18px 14px; }
.transaction-row { display: grid; grid-template-columns: 39px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 66px; border-bottom: 1px solid #eff2f1; }
.transaction-row:last-child { border-bottom: 0; }
.transaction-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; color: #247557; background: #edf7f2; font-weight: 800; }
.transaction-icon.expense { color: #bd5555; background: #fbefef; }
.transaction-copy { min-width: 0; }
.transaction-title { overflow: hidden; color: #2a3531; font-size: 12px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.transaction-meta { overflow: hidden; margin-top: 4px; color: #89928f; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.transaction-amount { color: #26332e; font-size: 12px; font-weight: 800; white-space: nowrap; }
.transaction-amount.income { color: #1c7959; }
.transaction-amount.expense { color: #b34d4d; }
.empty-state { padding: 34px 16px; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.6; }
.budget-progress { margin: 14px 0 18px; }
.budget-progress:last-child { margin-bottom: 8px; }
.budget-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.budget-name { overflow: hidden; color: #34413b; font-size: 11px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.budget-total { color: #697670; font-size: 10px; white-space: nowrap; }
.progress-track { overflow: hidden; height: 6px; margin: 9px 0 6px; border-radius: 9px; background: #edf1ef; }
.progress-fill { height: 100%; border-radius: inherit; background: #36a17b; }
.progress-fill.over { background: #d05e5e; }
.budget-meter { display: block; width: 100%; height: 7px; margin: 9px 0 6px; border: 0; border-radius: 9px; appearance: none; background: #edf1ef; }
.budget-meter::-webkit-progress-bar { border-radius: 9px; background: #edf1ef; }
.budget-meter::-webkit-progress-value { border-radius: 9px; background: #36a17b; }
.budget-meter::-moz-progress-bar { border-radius: 9px; background: #36a17b; }
.budget-meter.over::-webkit-progress-value { background: #d05e5e; }
.budget-meter.over::-moz-progress-bar { background: #d05e5e; }
.budget-foot { display: flex; justify-content: space-between; color: #89928f; font-size: 10px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar-left { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 10px; }
.search-input { width: min(320px, 100%); min-height: 39px; font-size: 12px; }
.filter-select { min-height: 39px; padding: 0 32px 0 11px; border: 1px solid #dfe6e3; border-radius: 9px; color: #47514e; background: #fff; font-size: 11px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { padding: 12px 14px; color: #858f8b; background: #fafcfb; font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.data-table td { padding: 13px 14px; border-top: 1px solid #edf1ef; color: #48534f; font-size: 11px; }
.data-table tr:hover td { background: #fbfdfc; }
.table-actions { display: flex; justify-content: flex-end; gap: 6px; }
.inline-actions { margin-top: 5px; }
.pill { display: inline-flex; padding: 5px 8px; border-radius: 20px; color: #416554; background: #edf7f2; font-size: 9px; font-weight: 800; }
.pill.private { color: #63716a; background: #f0f2f1; }
.pill.expense { color: #a34a4a; background: #fbefef; }

.budget-grid, .household-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.budget-card { padding: 19px; }
.budget-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.budget-card h3, .household-card h3 { margin: 0; font-size: 14px; }
.budget-card p, .household-card p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.budget-big { margin: 18px 0 0; font-size: 23px; font-weight: 800; letter-spacing: -.035em; }
.budget-big small { color: var(--muted); font-size: 11px; font-weight: 600; }
.budget-card-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.household-card { padding: 19px; }
.panel-spaced { margin-top: 16px; }
.household-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.member-list { display: grid; gap: 11px; margin: 17px 0; padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.member { display: flex; align-items: center; gap: 9px; color: #53605a; font-size: 11px; }
.member-dot { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; color: #22674e; background: #e7f4ef; font-size: 9px; font-weight: 800; }
.inline-form { display: flex; gap: 9px; margin: 0 0 18px; }
.inline-form input { flex: 1; min-width: 160px; }
.invite-code { color: #17694e; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; letter-spacing: .08em; }
.modal { width: min(520px, calc(100vw - 28px)); max-height: min(90vh, 760px); padding: 0; border: 0; border-radius: 15px; box-shadow: 0 28px 80px rgb(0 0 0 / 28%); }
.modal::backdrop { background: rgb(12 27 21 / 48%); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 8px; color: #64716c; background: transparent; font-size: 20px; }
.icon-button:hover { background: #f0f4f2; }
.modal-form { overflow: auto; max-height: calc(90vh - 70px); padding: 19px 22px 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.form-error { display: none; margin: 12px 0 0; color: #a43e3e; font-size: 12px; }
.form-error.visible { display: block; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: min(420px, calc(100vw - 32px)); padding: 13px 17px; border-radius: 10px; color: #fff; background: #1c3e31; box-shadow: var(--shadow); font-size: 12px; }

@media (max-width: 1050px) {
  .sidebar { width: 210px; }
  .main-area { margin-left: 210px; }
  .topbar { padding: 0 24px; }
  .main-content { padding: 28px 24px 48px; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-story { display: none; }
  .auth-panel { min-height: 100vh; padding: 24px; }
  .sidebar { position: fixed; inset: auto 0 0; width: 100%; height: 64px; flex-direction: row; align-items: center; justify-content: space-around; padding: 5px 8px; }
  .sidebar-brand, .nav-caption, .sidebar-bottom { display: none; }
  .nav-list { display: flex; width: 100%; justify-content: space-around; }
  .nav-button { min-width: 62px; min-height: 50px; flex-direction: column; justify-content: center; gap: 2px; padding: 4px; font-size: 9px; }
  .nav-icon { font-size: 16px; }
  .main-area { margin-left: 0; padding-bottom: 64px; }
  .topbar { min-height: 58px; padding: 0 17px; }
  .main-content { padding: 23px 16px 34px; }
  .page-heading h1 { font-size: 24px; }
  .balance-banner { min-height: unset; align-items: flex-start; flex-direction: column; padding: 24px; }
  .balance-numbers { width: 100%; justify-content: space-between; padding: 15px 0 0; border-top: 1px solid rgb(255 255 255 / 18%); }
  .metric-grid { grid-template-columns: 1fr; gap: 9px; }
  .metric-card { min-height: 86px; }
  .metric-value { margin-top: 5px; }
  .budget-grid, .household-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-left { align-items: stretch; flex-direction: column; }
  .search-input { width: 100%; }
  .topbar-date { font-size: 10px; }
}
