:root {
  --ink: #332c29;
  --muted: #766b64;
  --brand: #aa5c49;
  --brand-dark: #784136;
  --sea: #e6ece2;
  --sky: #f2ece5;
  --canvas: #fbf7f1;
  --paper: #fffdf9;
  --line: #e5dbd0;
  --green: #607a62;
  --amber: #b88444;
  --red: #b9624d;
  --dark-red: #8e4336;
  --shadow: 0 10px 28px rgba(71, 51, 39, .06);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: transparent; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.45rem; letter-spacing: 0; }
h2 { font-size: 1.16rem; letter-spacing: 0; }
h3 { font-size: .95rem; letter-spacing: 0; }
.hidden { display: none !important; }
.eyebrow { color: var(--brand); font-size: .72rem; font-weight: 700; text-transform: uppercase; margin-bottom: .35rem; }
.quiet { color: var(--muted); font-size: .83rem; line-height: 1.45; }
.error { color: var(--dark-red); background: #fae9e7; border-radius: 6px; padding: .7rem; font-size: .86rem; }
.primary { background: var(--brand); color: white; border-radius: 14px; padding: .82rem 1.1rem; font-weight: 650; }
.primary:hover { background: var(--brand-dark); }
.primary.small { padding: .55rem .85rem; }
.secondary { border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: .68rem .9rem; font-weight: 600; }
.danger { background: #f7e5df; color: var(--dark-red); border-radius: 12px; padding: .7rem .9rem; font-weight: 650; }
.text-button { color: var(--brand-dark); padding: .45rem .2rem; font-weight: 650; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.auth-card { background: var(--paper); border: 1px solid var(--line); border-radius: 24px; padding: 2.35rem; width: min(480px, 100%); box-shadow: var(--shadow); display: grid; gap: 1.15rem; }
.auth-copy { color: var(--muted); line-height: 1.52; }
.brand-mark { width: 52px; height: 52px; border-radius: 18px; background: var(--sky); display: grid; place-items: center; color: var(--brand); }
.brand-mark svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.auth-preview { background: #3e3733; color: #fffaf5; border-radius: 18px; padding: 1.15rem; display: grid; gap: .22rem; box-shadow: 0 10px 24px rgba(71, 51, 39, .08); }
.auth-preview span { color: #d9c9bd; font-size: .73rem; font-weight: 700; text-transform: uppercase; }
.auth-preview strong { font-size: .72rem; letter-spacing: .03em; }
.auth-preview b { font-size: 2.2rem; line-height: 1.05; letter-spacing: 0; }
.auth-preview small { color: #eadfd7; font-size: .86rem; }
.trust-line { color: var(--brand-dark); font-weight: 700; text-align: center; font-size: .9rem; }
.google-button { width: 100%; }
.app { min-height: 100vh; padding-bottom: 74px; }
.topbar { background: var(--paper); border-bottom: 1px solid var(--line); padding: 1rem max(1rem, calc((100vw - 1160px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.account { display: flex; align-items: center; gap: .8rem; }
.sync-pill { color: var(--green); font-size: .8rem; font-weight: 600; }
.desktop-nav { display: none; }
.view { max-width: 1160px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.cycle-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem; flex-wrap: wrap; }
.cycle-label { color: var(--muted); font-size: .85rem; margin-top: .26rem; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.card-pad { padding: 1rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .92rem 1rem; border-bottom: 1px solid var(--line); }
.section-header .quiet { white-space: nowrap; }
.hero { background: #3e3733; color: #fffaf5; padding: 1.45rem 1.15rem; border: 0; }
.hero-label { font-size: .75rem; font-weight: 650; opacity: .86; text-transform: uppercase; }
.hero-value { font-size: clamp(2.3rem, 8vw, 3.2rem); font-weight: 750; margin: .35rem 0; letter-spacing: 0; }
.hero p { opacity: .9; line-height: 1.45; font-size: .86rem; }
.hero button { color: white; text-decoration: underline; padding: .55rem 0 0; font-size: .84rem; }
.metrics { display: grid; gap: .75rem; }
.metric { padding: .9rem 1rem; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; }
.metric-label { color: var(--muted); font-size: .78rem; font-weight: 600; }
.metric-value { font-size: 1.35rem; font-weight: 700; margin-top: .35rem; }
.match { color: var(--green); font-weight: 650; font-size: .85rem; }
.mismatch { color: var(--red); font-weight: 650; font-size: .85rem; }
.compact-list { list-style: none; margin: 0; padding: 0; }
.compact-list li { padding: .82rem 1rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.compact-list li:last-child { border-bottom: 0; }
.item-title { font-weight: 650; font-size: .91rem; }
.item-detail { color: var(--muted); font-size: .77rem; line-height: 1.45; margin-top: .2rem; }
.amount { font-weight: 700; text-align: right; white-space: nowrap; }
.tag { display: inline-flex; padding: .2rem .42rem; border-radius: 5px; font-size: .72rem; font-weight: 650; margin-top: .3rem; }
.tag.green { color: var(--green); background: #e6ece2; }
.tag.amber { color: #936127; background: #f8eedc; }
.tag.red { color: var(--red); background: #f5e5df; }
.tag.dark-red { color: var(--dark-red); background: #edd9d3; }
.tag.tracked { color: var(--brand); background: var(--sea); }
.toolbar { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
.toolbar select, .toolbar input { width: auto; min-width: 0; }
.wide-action { width: 100%; margin-top: .75rem; }
.bar-row { padding: .68rem 1rem; }
.bar-head { display: flex; justify-content: space-between; gap: .7rem; font-size: .88rem; font-weight: 650; margin-bottom: .35rem; }
.progress { height: 8px; border-radius: 10px; background: #e6eceb; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: inherit; min-width: 0; }
.progress > span.amber { background: var(--amber); }
.progress > span.red { background: var(--red); }
.progress > span.dark-red { background: var(--dark-red); }
.grid-panels { display: grid; gap: 1rem; }
.form-grid { display: grid; gap: .8rem; }
label { display: grid; gap: .34rem; color: var(--muted); font-size: .8rem; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #dfd3c7; border-radius: 12px; background: white; padding: .72rem .7rem; min-height: 44px; }
textarea { resize: vertical; min-height: 76px; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.segmented button { flex: 1; min-height: 42px; padding: .55rem .35rem; font-size: .81rem; color: var(--muted); border-right: 1px solid var(--line); }
.segmented button:last-child { border-right: 0; }
.segmented button.selected { background: var(--sea); color: var(--brand-dark); font-weight: 700; }
.tabs { display: flex; gap: .38rem; overflow-x: auto; padding: .55rem; background: var(--sky); border-radius: 16px; }
.tabs button { white-space: nowrap; padding: .65rem .78rem; color: var(--muted); font-weight: 650; border-radius: 6px; }
.tabs button.active { background: var(--paper); color: var(--brand-dark); border: 1px solid var(--line); }
.timeline-group { padding: .85rem 1rem .38rem; color: var(--muted); font-size: .72rem; font-weight: 750; text-transform: uppercase; }
.transaction-edit { flex-shrink: 0; }
.goal-card { padding: 1rem; display: grid; gap: .6rem; border-bottom: 1px solid var(--line); }
.goal-card:last-child { border: 0; }
.priority { font-size: .72rem; font-weight: 700; border-radius: 5px; padding: .2rem .42rem; color: var(--muted); background: var(--sky); }
.priority.High { color: var(--dark-red); background: #edd9d3; }
.priority.Medium { color: #936127; background: #f8eedc; }
.owed-total { font-size: 2rem; font-weight: 750; margin: .3rem 0; }
.report-action { display: grid; gap: .7rem; padding: 1rem; }
.more-menu button { display: block; width: 100%; padding: 1rem; text-align: left; border-bottom: 1px solid var(--line); font-weight: 650; }
.modal { border: 0; padding: 0; max-width: none; width: 100%; height: 100%; margin: 0; background: var(--canvas); z-index: 50; }
.modal::backdrop { background: rgba(13, 29, 35, .45); }
.modal-head { position: sticky; top: 0; z-index: 1; background: var(--paper); border-bottom: 1px solid var(--line); padding: 1rem; display: flex; justify-content: space-between; align-items: center; }
.modal-content { padding: 1rem; max-width: 640px; margin: 0 auto; display: grid; gap: 1rem; }
.type-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.type-picker button { border: 1px solid var(--line); background: white; padding: .9rem .5rem; border-radius: 12px; font-weight: 650; }
.type-picker button.selected { border-color: var(--brand); background: var(--sea); }
.summary-box { background: var(--sea); border-radius: 12px; padding: .9rem; color: #4f654f; font-size: .85rem; line-height: 1.5; }
.optional-fields { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .75rem 0; }
.optional-fields summary { color: var(--brand-dark); cursor: pointer; font-weight: 650; }
.optional-fields[open] summary { margin-bottom: .75rem; }
.modal-actions { display: flex; gap: .65rem; padding-top: .4rem; }
.modal-actions button { flex: 1; }
.mobile-nav { height: calc(66px + env(safe-area-inset-bottom)); padding: 0 .4rem env(safe-area-inset-bottom); position: fixed; z-index: 5; bottom: 0; left: 0; right: 0; background: var(--paper); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
.mobile-nav button { min-height: 52px; color: var(--muted); font-size: .76rem; font-weight: 650; }
.mobile-nav button.active { color: var(--brand); }
.mobile-nav .add-button { background: var(--brand); color: white; height: 52px; width: 52px; min-height: 52px; justify-self: center; border-radius: 50%; font-size: 1.9rem; line-height: 1; transform: translateY(-12px); box-shadow: 0 7px 16px rgba(170, 92, 73, .26); }
.print-report { display: none; }
@media (max-width: 759px) {
  .topbar h1 { font-size: 1.25rem; white-space: nowrap; }
  .topbar .eyebrow { font-size: .66rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: .82rem .8rem; }
  .metric-value { font-size: 1.2rem; }
  .modal { position: fixed; inset: 0; max-width: 100%; max-height: 100svh; height: 100svh; padding-bottom: env(safe-area-inset-bottom); }
  .modal-content { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
}

@media (min-width: 760px) {
  .app { padding-bottom: 0; }
  .topbar { padding-top: 1.2rem; padding-bottom: 1.2rem; }
  .desktop-nav { max-width: 1160px; margin: .9rem auto 0; padding: 0 1rem; display: flex; align-items: center; gap: .35rem; }
  .desktop-nav button:not(.primary) { padding: .72rem 1rem; border-radius: 7px; font-weight: 650; color: var(--muted); }
  .desktop-nav button.active:not(.primary) { color: var(--brand-dark); background: var(--sea); }
  .desktop-nav .primary { margin-left: auto; }
  .mobile-nav { display: none; }
  .view { padding-top: 1.15rem; }
  .dashboard-grid { display: grid; grid-template-columns: 1.3fr .85fr .85fr; gap: 1rem; }
  .hero { grid-row: span 2; min-height: 190px; display: flex; flex-direction: column; justify-content: center; padding: 1.5rem; }
  .metrics { grid-template-columns: repeat(2, 1fr); grid-column: 2 / 4; }
  .grid-panels { grid-template-columns: 1fr 1fr; }
  .activity-table { display: table; width: 100%; border-collapse: collapse; }
  .activity-table .compact-list { display: table-row-group; }
  .activity-table li { display: table-row; }
  .activity-table li > * { display: table-cell; padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .form-grid.two { grid-template-columns: repeat(2, 1fr); }
  .modal { width: min(680px, calc(100% - 2rem)); height: auto; max-height: calc(100vh - 3rem); margin: auto; border-radius: 20px; box-shadow: var(--shadow); }
  .modal-content { overflow-y: auto; max-height: calc(100vh - 74px - 3rem); }
  .goal-grid { display: grid; grid-template-columns: repeat(2, 1fr); }
  .goal-card:nth-last-child(2) { border-bottom: 0; }
}

@media print {
  body { background: white; }
  .topbar, .desktop-nav, .mobile-nav, #view { display: none !important; }
  .print-report { display: block; font-size: 10.5pt; color: #142a34; }
  .report-page { page-break-after: always; padding: 14mm; min-height: 268mm; }
  .report-page:last-child { page-break-after: auto; }
  .report-title { border-bottom: 2px solid #aa5c49; padding-bottom: 8mm; margin-bottom: 8mm; }
  .report-title h1 { font-size: 23pt; }
  .report-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5mm; margin: 7mm 0; }
  .report-stat { border: 1px solid #d9e2e2; padding: 4mm; }
  .report-stat strong { display: block; font-size: 17pt; margin-top: 2mm; }
  .report-section { margin-top: 8mm; }
  .report-table { width: 100%; border-collapse: collapse; margin-top: 3mm; }
  .report-table th, .report-table td { border-bottom: 1px solid #d9e2e2; padding: 2.5mm 2mm; text-align: left; }
  .report-table th { background: #f2ece5; }
}
