:root {
  color-scheme: light dark;
  --bg: light-dark(oklch(.968 .003 265), oklch(.165 .006 265));
  --surface: light-dark(oklch(.998 .001 265), oklch(.222 .007 265));
  --ink: light-dark(oklch(.185 .010 265), oklch(.975 .002 265));
  --secondary: light-dark(oklch(.51 .014 265), oklch(.73 .014 265));
  --sep: light-dark(oklch(.885 .005 265), oklch(.34 .008 265));
  --accent: light-dark(oklch(.53 .205 258), oklch(.73 .15 258));
  --button-bg: light-dark(oklch(.53 .205 258), oklch(.56 .19 258));
  --income: light-dark(oklch(.49 .13 150), oklch(.76 .17 152));
  --danger: light-dark(oklch(.52 .20 27), oklch(.73 .16 25));
  --fill: light-dark(oklch(.926 .005 265), oklch(.30 .008 265));
  --ease: cubic-bezier(.32,.72,0,1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
html.sheet-open { overflow: hidden; overscroll-behavior: none; }
html.sheet-open body { position: fixed; top: var(--page-top); left: var(--page-left); width: 100%; padding-right: var(--scrollbar-gap); overflow: hidden; }
button, input, select { font: inherit; }
button, a, input, select { touch-action: manipulation; }
button { cursor: pointer; color: inherit; }
button:disabled { opacity: .45; cursor: default; }
button, input, select { -webkit-appearance: none; appearance: none; }
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.app { max-width: 960px; margin: auto; padding: calc(24px + env(safe-area-inset-top)) 32px calc(110px + env(safe-area-inset-bottom)); }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.app-name { font-size: 14px; color: var(--secondary); margin: 0 0 4px; }
h1 { margin: 0; font-size: 34px; line-height: 1.1; letter-spacing: -.025em; }
h2 { font-size: 19px; line-height: 1.3; margin: 0; letter-spacing: -.015em; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 10px; color: var(--secondary); }
p { margin: 0; }
.primary { border: 0; border-radius: 12px; background: var(--button-bg); color: oklch(.99 .002 265); font-size: 17px; font-weight: 600; min-height: 48px; padding: 12px 20px; }
.primary:active { filter: brightness(.9); }
.add-button { display: flex; align-items: center; gap: 4px; padding: 10px 17px; min-height: 44px; }
.add-button span { font-size: 25px; font-weight: 400; line-height: 1; }
.text-button { border: 0; background: none; color: var(--accent); padding: 10px 4px; min-height: 44px; font-weight: 500; font-size: 15px; }
.icon-button { background: none; border: 0; width: 44px; height: 44px; color: var(--accent); font-size: 29px; line-height: 1; }
.period-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px -8px 20px; }
.month-picker { display: flex; align-items: center; }
input[type=month] { border: 0; background: transparent; color: var(--ink); padding: 8px 0; width: 166px; min-height: 44px; font-size: 15px; font-weight: 600; text-align: center; }
input[type=month]::-webkit-calendar-picker-indicator { width: 16px; opacity: .6; }
.privacy-note { font-size: 13px; color: var(--secondary); padding-right: 8px; }
.sync-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: var(--secondary); margin: -16px 0 16px; min-height: 36px; }
.sync-line.error { color: var(--danger); }
.sync-line span { flex: 1; }
.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 40px; align-items: start; }
.overview { display: flex; flex-direction: column; gap: 24px; }
.headline-number { padding: 8px 0 0; }
.metric-label { color: var(--secondary); font-size: 15px; margin-bottom: 6px; }
.big-money { font-size: 44px; font-weight: 600; letter-spacing: -.035em; line-height: 1.15; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metric-caption { font-size: 13px; color: var(--secondary); margin-top: 8px; }
.group { background: var(--surface); border-radius: 13px; overflow: hidden; }
.summary-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px; font-size: 15px; align-items: baseline; }
.summary-row + .summary-row { border-top: .5px solid var(--sep); }
.summary-row span:first-child { min-width: 0; overflow-wrap: anywhere; }
.summary-row strong { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.summary-row.total { font-weight: 600; }
.summary-row.total strong { font-weight: 600; }
.income { color: var(--income); }
.balance-box { padding: 16px; }
.balance-box .balance-label { color: var(--secondary); font-size: 13px; margin-bottom: 6px; }
.balance-box .balance-text { font-size: 19px; font-weight: 600; letter-spacing: -.02em; overflow-wrap: anywhere; }
.balance-box .balance-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.balance-box .text-button { text-align: left; }
.balance-box .settled { font-weight: 500; }
.secondary { background: var(--fill); color: var(--accent); border: 0; border-radius: 10px; padding: 10px 14px; min-height: 44px; font-weight: 500; font-size: 15px; }
.small-note { font-size: 13px; color: var(--secondary); line-height: 1.5; margin-top: 8px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; min-height: 32px; }
.section-heading h2 { font-size: 20px; }
.section-heading span { font-size: 13px; color: var(--secondary); }
.day { margin-bottom: 24px; }
.day-label { color: var(--secondary); font-size: 13px; font-weight: 500; margin: 0 4px 8px; }
.entry { width: 100%; border: 0; background: var(--surface); display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 16px; min-height: 76px; }
.entry + .entry { border-top: .5px solid var(--sep); }
.entry-icon { color: var(--accent); width: 24px; flex: 0 0 24px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.entry-body { min-width: 0; flex: 1; }
.entry-title { font-size: 16px; font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-meta { font-size: 13px; color: var(--secondary); display: block; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-number { text-align: right; flex: 0 0 auto; max-width: 50%; font-size: 16px; font-variant-numeric: tabular-nums; }
.entry-number small { display: block; font-size: 12px; color: var(--secondary); margin-top: 3px; }
.empty { padding: 32px 20px; background: var(--surface); border-radius: 13px; }
.empty h2 { margin-bottom: 8px; }
.empty p { color: var(--secondary); font-size: 15px; line-height: 1.5; max-width: 42ch; }
.empty button { margin-top: 20px; }
.setup { max-width: 540px; padding: 24px 0; }
.setup-art { margin-bottom: 24px; color: var(--accent); }
.setup-art svg { width: 40px; height: 40px; stroke-width: 1.2; }
.setup h2 { font-size: 27px; letter-spacing: -.025em; margin-bottom: 12px; }
.setup > p { color: var(--secondary); max-width: 42ch; line-height: 1.55; }
.setup .setup-example { margin: 24px 0; }
.setup .primary { width: 100%; }
.setup .text-button { width: 100%; margin-top: 8px; }
.utility-link { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; font-size: 15px; min-height: 48px; }
.utility-link span:last-child { font-size: 22px; color: var(--secondary); }
.activity > .utility-link { margin-top: 24px; }
.tabbar { position: fixed; z-index: 30; inset: auto 0 0; background: color-mix(in oklch, var(--bg) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: .5px solid var(--sep); padding-bottom: env(safe-area-inset-bottom); }
.tabbar > div { display: flex; max-width: 560px; margin: auto; }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; color: var(--secondary); font-size: 12px; font-weight: 500; padding: 10px; min-height: 64px; }
.tabbar button[aria-current] { color: var(--accent); }
.tabbar button[aria-current] svg { stroke-width: 2.1; }
dialog { position: fixed; inset: auto 0 0; padding: 0; margin: 0 auto; width: 100%; max-width: 560px; max-height: 94dvh; border: 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink); overflow: auto; overscroll-behavior: contain; }
dialog::backdrop { background: oklch(.12 .01 265 / .42); }
dialog[open] { animation: sheet-in .24s var(--ease); }
dialog.sheet-dragging { animation: none; }
@keyframes sheet-in { from { transform: translateY(32px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet-body { padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet-body:focus { outline: none; }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--sep); margin: 0 auto 6px; touch-action: none; }
.sheet-header { position: sticky; top: 0; z-index: 2; background: var(--surface); display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; margin: 0 -4px 16px; padding: 4px; }
.sheet-header .text-button { text-align: left; font-size: 17px; }
.sheet-header h2 { text-align: center; font-size: 17px; }
.sheet-header, .grabber { cursor: grab; user-select: none; -webkit-user-select: none; }
.sheet-dragging .sheet-header, .sheet-dragging .grabber { cursor: grabbing; }
.sheet-header button { padding-left: 0; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > label, .field > legend { font-size: 14px; font-weight: 500; }
.field input, .field select { width: 100%; min-height: 48px; border: 1px solid var(--sep); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 11px 12px; min-width: 0; }
.field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23808088' stroke-width='1.6'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-position: right 10px center; background-repeat: no-repeat; padding-right: 34px; }
.field input::placeholder { color: var(--secondary); opacity: .8; }
.field input:disabled { opacity: .6; }
.fields-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.amount-input { display: flex; justify-content: center; align-items: baseline; gap: 8px; padding: 8px 0 20px; }
.amount-input label { color: var(--secondary); font-size: 28px; }
.amount-input input { font-size: 36px; font-weight: 400; letter-spacing: -.025em; line-height: 1.2; width: 230px; max-width: 78%; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--ink); caret-color: var(--secondary); font-variant-numeric: tabular-nums; padding: 4px; text-align: center; }
.amount-input input:focus { outline: none; border-bottom-color: var(--accent); }
.amount-input input::placeholder { color: var(--secondary); opacity: .65; }
.segments { display: flex; background: var(--fill); border-radius: 10px; padding: 3px; margin-bottom: 20px; gap: 2px; border: 0; min-width: 0; }
.segments label { flex: 1; position: relative; text-align: center; padding: 9px 4px; min-height: 40px; border-radius: 7px; font-size: 14px; cursor: pointer; }
.segments input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segments label:has(input:checked) { background: var(--surface); font-weight: 600; }
.segments label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.segments label:has(input:disabled) { opacity: .45; }
.form-summary { font-size: 14px; color: var(--secondary); line-height: 1.55; margin: 0 0 16px; padding: 12px 14px; border-radius: 10px; background: var(--fill); }
.form-summary strong { font-weight: 600; color: var(--ink); }
details { margin-bottom: 20px; }
summary { color: var(--accent); font-size: 15px; cursor: pointer; padding: 8px 0; min-height: 44px; }
details[open] summary { margin-bottom: 8px; }
.form-submit { width: 100%; margin-top: 4px; }
.form-error { color: var(--danger); font-size: 14px; margin: 8px 0 16px; }
.danger { color: var(--danger); }
.detail-amount { text-align: center; margin: 8px 0 24px; }
.detail-amount p { margin-top: 8px; color: var(--secondary); font-size: 15px; overflow-wrap: anywhere; }
.detail-actions { display: flex; gap: 12px; margin-top: 20px; }
.detail-actions > * { flex: 1; }
.detail-actions button { min-height: 48px; }
.details-list { margin-top: 12px; background: var(--bg); }
.toast { position: fixed; z-index: 100; bottom: calc(82px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; background: var(--ink); color: var(--bg); font-size: 14px; border-radius: 10px; text-align: center; }
.invite-field { font-size: 14px; }
.export-note { margin-top: 16px; }
@media (hover:hover) {
  button:not(:disabled):hover, .utility-link:hover { filter: brightness(.95); }
  .entry:hover { background: var(--fill); }
}
@media (max-width: 740px) {
  .app { max-width: 560px; padding: calc(20px + env(safe-area-inset-top)) 20px calc(100px + env(safe-area-inset-bottom)); }
  .layout { grid-template-columns: 1fr; gap: 32px; }
  .overview { gap: 20px; }
  .headline-number { padding-top: 0; }
  .period-bar { margin-top: 20px; margin-bottom: 16px; }
  .activity { min-width: 0; }
}
@media (max-width: 360px) {
  .period-bar { gap: 4px; }
  input[type=month] { width: 140px; }
  .app { padding-left: 16px; padding-right: 16px; }
  .sheet-body { padding-left: 16px; padding-right: 16px; }
  .entry { padding: 12px; gap: 8px; }
  .entry-icon { display: none; }
  .fields-pair { grid-template-columns: 1fr; gap: 0; }
  .privacy-note { font-size: 12px; }
}
@media (min-width: 741px) { .overview { position: sticky; top: 24px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
