:root {
  color-scheme: light;
  --ink: #23322e;
  --muted: #85908b;
  --line: #e9e9e2;
  --paper: #f6f5f0;
  --card: #fffefa;
  --green: #176b53;
  --green-deep: #14543f;
  --green-soft: #eaf3ed;
  --coral: #d77e68;
  --coral-soft: #faeee9;
  --yellow: #f2d489;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button { color: inherit; }
.app-shell { width: min(1160px, calc(100% - 56px)); margin: 0 auto; }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e8e7df; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.header-action { display: inline-flex; align-items: center; min-height: 31px; padding: 0 9px; border: 1px solid #e3e7df; border-radius: 8px; background: #fffefa; color: #65716a; cursor: pointer; text-decoration: none; font-size: 10px; font-weight: 600; }
.header-action:hover, .header-action:focus-visible { border-color: #b7c9bb; color: var(--green); }
.account-email { max-width: 145px; overflow: hidden; color: #77827b; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--green-deep); text-decoration: none; font: 800 20px 'Manrope', sans-serif; letter-spacing: -1.1px; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px 10px 10px 4px; background: var(--green); color: white; font-size: 26px; line-height: 1; }
.brand-light { font-weight: 500; color: #78847d; }
.privacy-note { display: flex; align-items: center; gap: 8px; color: #76827c; font-size: 12px; }
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: #6aa582; box-shadow: 0 0 0 3px #e4efe7; }
.privacy-dot.syncing { background: #d7a84a; box-shadow: 0 0 0 3px #f7efd9; }
.privacy-dot.error { background: #c76856; box-shadow: 0 0 0 3px #f8e8e3; }
.auth-screen { display: grid; min-height: 100svh; place-items: center; padding: 24px; background: var(--paper); }
.auth-card { width: min(100%, 390px); padding: 30px; border: 1px solid #eae9e2; border-radius: 17px; background: var(--card); box-shadow: 0 10px 34px rgba(35, 50, 46, .06); }
.auth-brand { margin-bottom: 29px; }
.auth-card h1 { margin-bottom: 8px; font-size: 27px; }
.auth-card .subtitle { margin-bottom: 24px; line-height: 1.5; }
#login-email, #login-password { display: block; width: 100%; height: 42px; margin-bottom: 17px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: white; color: var(--ink); font-size: 13px; }
#login-email:focus, #login-password:focus { border-color: #9ab6a5; outline: 3px solid #176b5313; }
.auth-submit { width: 100%; min-height: 43px; margin-top: 3px; }
main { padding: 39px 0 20px; }
.welcome-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.eyebrow { margin: 0 0 9px; color: #8a948e; font-size: 10px; font-weight: 700; letter-spacing: 1.2px; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; letter-spacing: -0.8px; }
h1 { margin-bottom: 7px; font-size: clamp(27px, 4vw, 35px); line-height: 1.17; }
.subtitle { margin-bottom: 0; color: #7b8680; font-size: 14px; }
.month-picker { display: inline-flex; align-items: center; gap: 9px; min-width: 154px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); color: var(--green); }
.month-picker input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; font-weight: 600; }
.summary-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.summary-card, .panel { border: 1px solid #eae9e2; border-radius: 15px; background: var(--card); box-shadow: 0 4px 18px rgba(35, 50, 46, .025); }
.summary-card { min-height: 135px; padding: 18px 21px; }
.balance-card { background: var(--green); border-color: var(--green); color: white; }
.summary-heading { display: flex; align-items: center; justify-content: space-between; color: #77837c; font-size: 12px; font-weight: 600; }
.balance-card .summary-heading, .balance-card .summary-footnote { color: #d1e2d9; }
.summary-icon { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; background: #f2f3ed; color: #738078; font-size: 15px; }
.income-icon { color: var(--green); background: var(--green-soft); }
.expense-icon { color: var(--coral); background: var(--coral-soft); }
.balance-card .summary-icon { color: white; background: rgba(255,255,255,.15); }
.summary-amount { margin: 14px 0 3px; font: 700 26px -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; letter-spacing: -.7px; }
.summary-footnote { margin: 0; color: #9aa19a; font-size: 11px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .85fr); align-items: start; gap: 18px; }
.panel { padding: 21px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading h2 { margin: 0; font-size: 17px; line-height: 1.25; }
.transactions-heading { margin-bottom: 8px; }
.filter-tabs { display: flex; gap: 3px; padding: 3px; border-radius: 9px; background: #f4f4ef; }
.filter-tab { border: 0; border-radius: 7px; background: transparent; padding: 7px 9px; color: #818a84; cursor: pointer; font-size: 10px; font-weight: 600; }
.filter-tab.active { background: white; color: var(--green); box-shadow: 0 1px 4px #25352d12; }
.transaction-list { min-height: 170px; }
.transaction-row { display: grid; grid-template-columns: 38px minmax(0,1fr) auto auto; align-items: center; gap: 11px; min-height: 65px; border-bottom: 1px solid #f0f0eb; }
.transaction-row:last-child { border-bottom: 0; }
.transaction-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--green-soft); color: var(--green); font-size: 15px; }
.transaction-icon.expense { background: var(--coral-soft); color: var(--coral); }
.transaction-main { min-width: 0; }
.transaction-title { overflow: hidden; margin: 0 0 4px; color: #34413b; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.transaction-meta { margin: 0; color: #9aa19a; font-size: 10px; }
.transaction-amount { white-space: nowrap; font-size: 12px; font-weight: 700; }
.transaction-amount.income { color: var(--green); }
.transaction-amount.expense { color: #bd6d5a; }
.row-actions { display: flex; gap: 2px; opacity: .5; }
.row-action { width: 27px; height: 27px; border: 0; border-radius: 7px; background: transparent; color: #68756e; cursor: pointer; font-size: 14px; }
.row-action:hover, .row-action:focus-visible { background: #f1f2ed; opacity: 1; }
.empty-state { display: grid; place-items: center; min-height: 165px; padding: 20px; text-align: center; }
.empty-illustration { display: grid; place-items: center; width: 39px; height: 39px; margin-bottom: 10px; border-radius: 14px; background: #f1f3ec; color: var(--green); font-size: 19px; }
.empty-state strong { margin-bottom: 4px; font-size: 12px; }
.empty-state span { color: #98a099; font-size: 11px; }
.side-column { display: grid; gap: 16px; }
.form-panel { padding: 20px; }
.form-panel .panel-heading { margin-bottom: 18px; }
.form-sparkle { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: #f6f0dc; color: #b48b35; }
.type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 18px; padding: 4px; border: 0; border-radius: 10px; background: #f3f3ee; }
.type-option { display: block; cursor: pointer; }
.type-option input { position: absolute; opacity: 0; pointer-events: none; }
.type-option span { display: block; padding: 9px; border-radius: 7px; color: #818a84; text-align: center; font-size: 11px; font-weight: 600; }
.type-option.selected span { background: white; color: var(--green); box-shadow: 0 1px 4px #25352d12; }
.field-label { display: block; margin: 0 0 7px; color: #68756e; font-size: 10px; font-weight: 700; }
.optional { color: #a1a8a1; font-weight: 400; }
.amount-wrap { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: #8c968f; }
.amount-hint { margin: -8px 0 13px; color: #8c968f; font-size: 10px; line-height: 1.4; }
.amount-wrap:focus-within, .field-group input:focus, .field-group select:focus, #description:focus { border-color: #9ab6a5; outline: 3px solid #176b5313; }
.amount-wrap input { width: 100%; border: 0; outline: 0; color: var(--ink); font: 700 19px -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.amount-wrap input::placeholder { color: #c4c9c2; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 14px; }
.field-group { min-width: 0; }
.field-group input, .field-group select, #description { width: 100%; min-width: 0; height: 38px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: white; color: #46534c; font-size: 11px; }
.payment-section { margin-bottom: 14px; }
.payment-section > select, .installment-options > select { width: 100%; height: 38px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: white; color: #46534c; font-size: 11px; }
.payment-section select:focus { border-color: #9ab6a5; outline: 3px solid #176b5313; }
.installment-options { margin-top: 13px; }
.installment-note { margin: 7px 0 0; color: #8c968f; font-size: 10px; line-height: 1.4; }
#description { margin-bottom: 15px; }
.form-actions { display: flex; gap: 7px; }
.button { min-height: 39px; border: 0; border-radius: 9px; cursor: pointer; font-size: 11px; font-weight: 700; }
.button-primary { flex: 1; background: var(--green); color: white; }
.button-primary:hover { background: var(--green-deep); }
.button-primary span { margin-left: 6px; }
.button-quiet { padding: 0 12px; background: #f1f2ed; color: #65716a; }
.hidden { display: none !important; }
.form-feedback { min-height: 12px; margin: 8px 0 0; color: var(--green); font-size: 10px; }
.compact-heading { margin-bottom: 17px; }
.fixed-heading { margin-bottom: 13px; }
.add-fixed-button { flex: 0 0 auto; padding: 8px 10px; border: 1px solid #e4ebe3; border-radius: 8px; background: #f4f7f1; color: var(--green); cursor: pointer; font-size: 10px; font-weight: 700; }
.fixed-summary { margin: 0 0 12px; color: #818c85; font-size: 10px; }
.fixed-form { margin: 0 0 14px; padding: 13px; border: 1px solid #eeeee7; border-radius: 10px; background: #fbfbf7; }
.fixed-form > input { width: 100%; height: 37px; margin-bottom: 12px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: white; color: #46534c; font-size: 11px; }
.fixed-form input:focus, .fixed-form select:focus { border-color: #9ab6a5; outline: 3px solid #176b5313; }
.fixed-amount-wrap { margin-bottom: 12px; padding: 7px 9px; }
.fixed-amount-wrap input { font-size: 16px; }
.fixed-fields-row { display: grid; grid-template-columns: 1fr .75fr; gap: 9px; margin-bottom: 13px; }
.fixed-expense-list { display: grid; gap: 8px; }
.fixed-expense-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 10px; padding: 10px 0; border-top: 1px solid #f0f0eb; }
.fixed-expense-main { min-width: 0; }
.fixed-expense-name { overflow: hidden; margin: 0 0 4px; color: #34413b; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.fixed-expense-meta { margin: 0; color: #929c95; font-size: 10px; }
.fixed-expense-side { display: flex; align-items: center; gap: 8px; }
.fixed-expense-amount { white-space: nowrap; color: #46534c; font-size: 11px; font-weight: 700; }
.fixed-status { padding: 4px 6px; border-radius: 6px; background: #fbf0de; color: #aa7c2e; font-size: 9px; font-weight: 700; }
.fixed-status.paid { background: #e9f3eb; color: var(--green); }
.fixed-row-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; }
.fixed-action-button { padding: 5px 7px; border: 1px solid #e8eae4; border-radius: 6px; background: white; color: #69766f; cursor: pointer; font-size: 9px; }
.fixed-action-button.primary { border-color: #d6e6da; background: #eff6f0; color: var(--green); font-weight: 700; }
.fixed-action-button.archive { margin-left: auto; border-color: transparent; background: transparent; color: #9aa19a; }
.fixed-empty { padding: 14px 2px 4px; color: #9aa19a; font-size: 11px; line-height: 1.5; }
.category-breakdown { display: grid; gap: 13px; }
.category-line { display: grid; grid-template-columns: minmax(75px, .8fr) minmax(60px, 1.2fr) auto; align-items: center; gap: 9px; }
.category-name { overflow: hidden; color: #69766f; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.category-track { height: 6px; overflow: hidden; border-radius: 8px; background: #f0f1eb; }
.category-fill { height: 100%; border-radius: inherit; background: #8cb59b; }
.category-line:nth-child(2n) .category-fill { background: #e8bf75; }
.category-line:nth-child(3n) .category-fill { background: #d9917d; }
.category-value { color: #59665f; font-size: 10px; font-weight: 600; }
.category-empty { margin: 0; color: #9aa19a; font-size: 11px; }
.page-footer { display: flex; justify-content: space-between; padding: 21px 2px 10px; color: #a1a7a0; font-size: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 780px) {
  .app-shell { width: min(100% - 34px, 620px); }
  .topbar { min-height: 68px; height: auto; gap: 12px; padding: 12px 0; }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  main { padding-top: 29px; }
  .content-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: 1fr 1fr; align-items: start; }
}
@media (max-width: 540px) {
  .app-shell { width: calc(100% - 28px); }
  .topbar { align-items: flex-start; }
  .brand { gap: 7px; font-size: 17px; }
  .brand-mark { width: 27px; height: 27px; }
  .topbar-actions { max-width: 220px; }
  .privacy-note { width: 100%; justify-content: flex-end; font-size: 9px; }
  .header-action { min-height: 29px; padding: 0 7px; font-size: 9px; }
  .account-email { max-width: 110px; }
  .welcome-row { align-items: flex-start; flex-direction: column; gap: 16px; }
  .month-picker { align-self: flex-start; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .summary-card { min-height: 119px; padding: 14px; }
  .balance-card { grid-column: 1 / -1; min-height: 111px; }
  .summary-amount { font-size: 21px; }
  .panel { padding: 16px; }
  .transactions-heading { align-items: flex-start; flex-direction: column; }
  .filter-tabs { align-self: stretch; }
  .filter-tab { flex: 1; }
  .side-column { grid-template-columns: 1fr; }
  .page-footer { gap: 10px; font-size: 9px; }
  .transaction-row { grid-template-columns: 34px minmax(0,1fr) auto; gap: 8px; }
  .transaction-icon { width: 33px; height: 33px; }
  .row-actions { grid-column: 2 / -1; grid-row: 2; justify-self: start; margin-top: -8px; margin-bottom: 4px; opacity: .8; }
  .transaction-row { padding: 6px 0; }
  .transaction-amount { grid-column: 3; grid-row: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .summary-card, .panel { animation: appear .3s ease both; }
  .summary-grid .summary-card:nth-child(2) { animation-delay: .04s; }
  .summary-grid .summary-card:nth-child(3) { animation-delay: .08s; }
  @keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
}
