:root {
  --ink: #172522;
  --muted: #667570;
  --line: #dfe7e4;
  --surface: #ffffff;
  --canvas: #f5f7f6;
  --brand: #173b35;
  --brand-2: #285d52;
  --mint: #dcebe5;
  --green: #257453;
  --red: #a8473c;
  --blue: #416b8c;
  --shadow: 0 12px 32px rgba(23, 59, 53, .07);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid #74ad9e; outline-offset: 2px; }
.skip-link { position: fixed; z-index: 100; left: 1rem; top: -5rem; background: #fff; padding: .8rem 1rem; border-radius: 8px; }
.skip-link:focus { top: 1rem; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; padding: 28px 18px; background: var(--brand); color: #f6fbf9; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 750; font-size: 1.14rem; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: var(--brand); background: #e8f4ef; font-family: Georgia, serif; font-weight: 800; }
.desktop-nav { display: grid; gap: 7px; margin-top: 44px; }
.desktop-nav a { display: flex; align-items: center; gap: 13px; min-height: 48px; padding: 0 14px; border-radius: 11px; text-decoration: none; color: #c8d9d4; font-weight: 620; }
.desktop-nav a span { width: 20px; text-align: center; font-size: 1.25rem; }
.desktop-nav a:hover, .desktop-nav a.active { color: #fff; background: rgba(255,255,255,.11); }
.sidebar-user { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.14); display: grid; grid-template-columns: 34px 1fr 34px; gap: 10px; align-items: center; }
.sidebar-user small { display: block; color: #abc0ba; margin-top: 2px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--brand); background: #cde2da; font-weight: 750; }
.icon-button { min-width: 34px; min-height: 34px; border: 0; border-radius: 9px; color: #e3eeeb; background: transparent; cursor: pointer; font-size: 1.2rem; }
.icon-button:hover { background: rgba(255,255,255,.1); }
.main-content { margin-left: 232px; padding: 38px clamp(24px, 4vw, 64px) 70px; max-width: 1700px; min-height: 100vh; }
.mobile-nav { display: none; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 3.5vw, 2.8rem); line-height: 1.05; letter-spacing: -.035em; }
h2 { margin-bottom: 4px; font-size: 1.2rem; letter-spacing: -.02em; }
.page-header p:not(.eyebrow), .form-page header > p:last-child { margin: 8px 0 0; color: var(--muted); }
.eyebrow { margin-bottom: 7px; font-size: .72rem; font-weight: 780; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.month-bar { display: grid; grid-template-columns: 44px minmax(170px, 220px) 44px; align-items: center; gap: 7px; position: relative; }
.month-arrow { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none; font-size: 1.7rem; box-shadow: 0 4px 14px rgba(23,59,53,.04); }
.month-picker { min-height: 56px; position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 6px 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); cursor: pointer; }
.month-picker .eyebrow { margin: 0 0 2px; font-size: .62rem; color: var(--blue); }
.month-name { font-weight: 760; }
.month-picker input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.today-link { position: absolute; top: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: .75rem; font-weight: 700; color: var(--brand-2); }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.summary-card { min-width: 0; min-height: 145px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.summary-card > span { font-size: .86rem; color: var(--muted); font-weight: 650; }
.summary-card strong { margin: auto 0 8px; font-size: clamp(1.5rem, 2.5vw, 2.1rem); letter-spacing: -.045em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-card small { color: var(--muted); }
.summary-card.income { border-top: 4px solid #4c9a75; }
.summary-card.automatic { border-top: 4px solid #7096b3; }
.summary-card.hero { background: var(--brand); color: #fff; border-color: var(--brand); }
.summary-card.hero > span, .summary-card.hero small { color: #bed3cc; }
.summary-card.hero.negative { background: #813b33; border-color: #813b33; }
.content-grid { display: grid; gap: 18px; }
.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-header { padding: 20px 22px 16px; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.panel-header .eyebrow { margin-bottom: 4px; }
.button { min-height: 44px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 11px; text-decoration: none; font-weight: 720; cursor: pointer; }
.button.small { min-height: 40px; padding: 0 14px; color: var(--brand); border-color: #cddbd7; background: #f9fbfa; }
.button.primary { color: #fff; background: var(--brand); }
.button.primary:hover { background: var(--brand-2); }
.button.ghost { color: var(--brand); border-color: var(--line); background: var(--surface); }
.button.light { color: var(--brand); background: #eff7f4; border-color: rgba(255,255,255,.2); }
.button.danger { color: #fff; background: var(--red); }
.entry-list { border-top: 1px solid var(--line); }
.entry-row { min-height: 68px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 11px 20px; border-bottom: 1px solid var(--line); text-decoration: none; }
.entry-row:hover { background: #f8faf9; }
.entry-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; font-weight: 800; }
.income-icon { color: var(--green); background: #e3f2ea; }
.expense-icon { color: #8a544f; background: #f5e9e7; }
.auto-icon { color: var(--blue); background: #e6eef4; }
.entry-copy { min-width: 0; }
.entry-copy strong, .entry-copy small { display: block; overflow-wrap: anywhere; }
.entry-copy small { margin-top: 4px; color: var(--muted); }
.entry-amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.automatic-row { background: #f6f9fb; }
.panel-total { display: flex; justify-content: space-between; gap: 20px; padding: 17px 20px; background: #fafcfb; border-radius: 0 0 var(--radius) var(--radius); font-weight: 700; }
.empty-state { min-height: 110px; padding: 24px; display: grid; place-items: center; align-content: center; gap: 6px; color: var(--muted); text-align: center; }
.empty-state span { font-size: 1.5rem; }
.empty-state p { margin: 0; }
.joint-hero { padding: clamp(22px, 4vw, 34px); border-radius: 22px; background: var(--brand); color: #fff; display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(240px, 1fr) auto; gap: 32px; align-items: center; }
.joint-hero > div:first-child { display: flex; flex-direction: column; }
.joint-hero > div:first-child span { color: #bcd1ca; font-weight: 650; }
.joint-hero > div:first-child strong { margin: 5px 0; font-size: clamp(2.2rem, 5vw, 3.6rem); letter-spacing: -.055em; }
.joint-hero small { color: #bcd1ca; }
.contribution-list { border-left: 1px solid rgba(255,255,255,.18); padding-left: 28px; display: grid; gap: 10px; }
.contribution-list div { display: flex; justify-content: space-between; gap: 25px; }
.contribution-list span { color: #bcd1ca; }
.folder-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 14px 0 22px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.folder-summary div { padding: 15px 20px; display: flex; justify-content: space-between; gap: 12px; border-right: 1px solid var(--line); }
.folder-summary div:last-child { border: 0; }
.folder-summary span { color: var(--muted); }
.folder-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.folder-card .entry-row { grid-template-columns: auto minmax(0, 1fr) auto auto; padding-inline: 18px; }
.folder-add { min-height: 48px; padding: 13px 18px; display: block; border-radius: 0 0 var(--radius) var(--radius); text-align: center; color: var(--brand-2); font-weight: 720; text-decoration: none; }
.form-page { max-width: 780px; margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: 24px; color: var(--brand-2); font-weight: 700; text-decoration: none; }
.form-page > header { margin-bottom: 22px; }
.stack-form { display: grid; gap: 18px; }
.entry-form { padding: 24px; }
.custom-expense-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.custom-expense-fields[hidden] { display: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
label, legend { font-weight: 680; font-size: .9rem; }
input, select, textarea { width: 100%; min-height: 48px; margin-top: 7px; padding: 10px 12px; border: 1px solid #cad6d2; border-radius: 10px; color: var(--ink); background: #fff; font-size: 1rem; }
textarea { resize: vertical; }
input:disabled, select:disabled { color: var(--muted); background: #eef2f0; }
label > small { display: block; margin-top: 5px; color: var(--muted); font-weight: 400; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.span-2 { grid-column: 1 / -1; }
.optional { color: var(--muted); font-weight: 450; }
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.segmented label { min-height: 48px; padding: 10px 13px; display: flex; align-items: center; gap: 9px; border: 1px solid #cad6d2; border-radius: 10px; cursor: pointer; }
.segmented input, .choice-cards input { width: 19px; height: 19px; min-height: auto; margin: 0; flex: 0 0 auto; accent-color: var(--brand); }
.end-month { display: block; margin-top: 13px; max-width: 260px; }
.choice-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.choice-cards label { padding: 14px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid #cad6d2; border-radius: 12px; cursor: pointer; }
.choice-cards strong, .choice-cards small { display: block; }
.choice-cards small { margin-top: 4px; color: var(--muted); line-height: 1.35; font-weight: 450; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.notice { margin-bottom: 14px; padding: 14px 17px; border: 1px solid #c7dbe5; border-radius: 12px; color: #2c556f; background: #eff6f9; }
.action-panel { margin-top: 16px; padding: 20px 24px; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.danger-zone { margin-top: 24px; padding: 18px 22px; border: 1px solid #e3cac7; border-radius: 14px; background: #fff8f7; }
.danger-zone summary { min-height: 30px; cursor: pointer; color: #8a3830; font-weight: 750; }
.danger-zone form { max-width: 440px; display: grid; gap: 14px; }
.history-panel { overflow: hidden; }
.history-head, .history-row { display: grid; grid-template-columns: minmax(160px, 1.3fr) minmax(110px, .8fr) minmax(120px, .8fr) 20px; gap: 20px; align-items: center; padding: 15px 22px; }
.history-head { color: var(--muted); background: #f3f6f5; font-size: .77rem; font-weight: 760; text-transform: uppercase; letter-spacing: .06em; }
.history-row { min-height: 70px; border-top: 1px solid var(--line); text-decoration: none; }
.history-row:hover { background: #fafcfb; }
.history-row span:first-child small { display: block; margin-top: 4px; color: var(--muted); }
.negative-text { color: var(--red); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-card { padding: 23px; }
.settings-card > p { color: var(--muted); }
.settings-card .panel-header { padding: 0 0 10px; }
.span-card { grid-column: 1 / -1; }
.split-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.badge { padding: 6px 10px; border-radius: 999px; color: var(--blue); background: #e8f0f5; font-size: .8rem; font-weight: 720; }
.folder-settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.folder-settings form { padding: 15px; border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 10px; }
.muted { color: var(--muted); }
.flash-stack { position: fixed; z-index: 50; top: 18px; right: 20px; width: min(380px, calc(100vw - 40px)); display: grid; gap: 8px; }
.flash { padding: 13px 16px; border: 1px solid #c8d9d4; border-radius: 11px; background: #fff; box-shadow: var(--shadow); }
.flash.success { border-left: 4px solid var(--green); }
.flash.error { border-left: 4px solid var(--red); }
.flash.warning { border-left: 4px solid #b5802b; }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 520px) 1fr; }
.login-panel { padding: clamp(28px, 7vw, 80px); display: flex; flex-direction: column; justify-content: center; background: #fff; }
.login-brand { position: absolute; top: 34px; color: var(--brand); }
.login-copy { margin-bottom: 28px; }
.login-copy h1 { font-size: clamp(2.5rem, 5vw, 3.6rem); }
.login-copy > p:last-child { max-width: 390px; color: var(--muted); line-height: 1.55; }
.login-panel .stack-form { max-width: 390px; }
.secure-note { margin: 24px 0 0; color: var(--muted); font-size: .86rem; }
.secure-note span { color: var(--green); }
.login-visual { padding: 8vw; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #3e7165 0, var(--brand) 56%); }
.preview-card { width: min(500px, 100%); padding: clamp(30px, 5vw, 55px); border-radius: 28px; color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); box-shadow: 0 30px 70px rgba(0,0,0,.18); backdrop-filter: blur(10px); }
.preview-card > span { color: #c3dad3; font-size: .75rem; letter-spacing: .13em; font-weight: 800; }
.preview-card h2 { margin: 12px 0 50px; font-family: Georgia, serif; font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 500; }
.preview-total { display: flex; flex-direction: column; padding-bottom: 28px; border-bottom: 1px solid rgba(255,255,255,.2); }
.preview-total small, .preview-grid small { color: #c3dad3; }
.preview-total strong { margin-top: 7px; font-size: clamp(2rem, 5vw, 3.4rem); }
.preview-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; padding-top: 25px; }
.preview-grid small, .preview-grid b { display: block; }
.preview-grid b { margin-top: 5px; font-size: 1.3rem; }

@media (max-width: 1199px) {
  .folder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .joint-hero { grid-template-columns: minmax(180px, 1fr) minmax(230px, 1fr); }
  .joint-hero .button { grid-column: 1 / -1; justify-self: start; }
}
@media (max-width: 899px) {
  .sidebar { width: 88px; padding-inline: 15px; align-items: center; }
  .sidebar .brand > span:last-child, .desktop-nav a:not(.active)::after, .desktop-nav a { font-size: 0; }
  .desktop-nav a { justify-content: center; width: 52px; padding: 0; }
  .desktop-nav a span { font-size: 1.25rem; }
  .sidebar-user { grid-template-columns: 34px; }
  .sidebar-user > div:nth-child(2), .sidebar-user form { display: none; }
  .main-content { margin-left: 88px; padding-inline: 28px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .joint-hero { grid-template-columns: 1fr 1fr; }
  .folder-grid { grid-template-columns: 1fr; }
  .folder-settings { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
}
@media (max-width: 599px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .main-content { margin: 0; padding: 24px 14px 28px; }
  .mobile-nav { position: fixed; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); left: 0; right: 0; bottom: 0; min-height: 64px; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); box-shadow: 0 -8px 24px rgba(23,59,53,.07); }
  .mobile-nav a { min-width: 0; min-height: 62px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 1.2rem; }
  .mobile-nav a small { font-size: .69rem; font-weight: 650; }
  .mobile-nav a.active { color: var(--brand); }
  .page-header { align-items: flex-start; flex-direction: column; margin-bottom: 20px; }
  .page-header > div:first-child { width: 100%; }
  h1 { font-size: 2rem; }
  .month-bar { width: 100%; grid-template-columns: 44px 1fr 44px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .summary-card { min-height: 116px; padding: 15px; border-radius: 14px; }
  .summary-card strong { font-size: clamp(1.3rem, 6.6vw, 1.7rem); }
  .summary-card small { font-size: .74rem; }
  .two-column { grid-template-columns: 1fr; }
  .panel-header { padding: 17px 16px 13px; }
  .entry-row { padding-inline: 14px; gap: 9px; }
  .entry-icon { width: 30px; height: 30px; }
  .joint-hero { grid-template-columns: 1fr; gap: 22px; padding: 22px; }
  .joint-hero .button { grid-column: auto; width: 100%; }
  .contribution-list { padding: 18px 0 0; border-left: 0; border-top: 1px solid rgba(255,255,255,.18); }
  .folder-summary { grid-template-columns: 1fr; }
  .folder-summary div { border-right: 0; border-bottom: 1px solid var(--line); }
  .folder-summary div:last-child { border-bottom: 0; }
  .folder-card .entry-row { padding-inline: 15px; }
  .form-page { width: 100%; }
  .entry-form { padding: 18px 15px; }
  .custom-expense-fields { grid-template-columns: 1fr; }
  .form-grid, .choice-cards, .settings-grid, .split-grid { grid-template-columns: 1fr; }
  .span-2, .span-card { grid-column: auto; }
  .form-actions { position: sticky; bottom: 74px; z-index: 5; margin-inline: -15px; padding: 12px 15px calc(12px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.97); box-shadow: 0 -7px 18px rgba(23,59,53,.08); }
  .form-actions .button { flex: 1; }
  .action-row, .action-row form, .action-row .button { width: 100%; }
  .history-head { display: none; }
  .history-row { grid-template-columns: minmax(0, 1fr) auto 18px; gap: 10px; padding: 14px 16px; }
  .history-row > strong:first-of-type { display: none; }
  .settings-card { padding: 18px 16px; }
  .flash-stack { top: 10px; right: 10px; width: calc(100vw - 20px); }
  .login-page { min-height: calc(100vh - 68px); }
  .login-panel { padding: 95px 24px 40px; justify-content: flex-start; }
  .login-brand { top: 28px; }
}
@media (max-width: 360px) {
  .main-content { padding-inline: 10px; }
  .summary-card { padding: 13px 11px; }
  .summary-card > span { font-size: .77rem; }
  .summary-card strong { font-size: 1.25rem; }
  .month-picker { padding-inline: 8px; }
  .month-name { font-size: .92rem; }
  .entry-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .entry-row > span:last-child { display: none; }
  .entry-row .entry-amount { font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
