:root {
  font-family: "DM Sans", sans-serif;
  color: #202a27;
  background: #f4f3ee;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #202a27;
  --muted: #78827d;
  --line: #e4e5dc;
  --paper: #fffefa;
  --canvas: #f4f3ee;
  --green: #315f4a;
  --green-dark: #244835;
  --green-wash: #e8f0e9;
  --orange: #d9794b;
  --orange-wash: #f8ece5;
  --yellow-wash: #f6f0d9;
  --red: #a8483c;
  --shadow: 0 16px 40px rgba(38, 53, 46, .055);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { background: #e9eee8; border-right: 1px solid #dce3dc; padding: 27px 18px 20px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 9px; color: var(--ink); text-decoration: none; font: 800 21px Manrope, sans-serif; letter-spacing: 0; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; background: var(--green); color: white; border-radius: 9px 9px 9px 2px; font: 800 17px Manrope, sans-serif; }
.brand-period { color: var(--orange); }
.workspace-label { display: flex; justify-content: space-between; align-items: center; margin: 43px 10px 12px; color: #7b8980; font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.workspace-label span { color: var(--green); background: #d9e6d9; border-radius: 12px; padding: 4px 7px; letter-spacing: 0; }
.primary-nav { display: grid; gap: 5px; }
.nav-item { width: 100%; border: 0; background: transparent; display: flex; gap: 13px; align-items: center; border-radius: 7px; padding: 12px 11px; color: #59665e; text-align: left; font-size: 13px; font-weight: 600; }
.nav-item:hover { background: rgba(255,255,255,.58); color: var(--ink); }
.nav-item.active { color: var(--green-dark); background: #d8e5d8; }
.nav-icon { width: 17px; text-align: center; font-size: 17px; line-height: 1; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 14px; border-top: 1px solid #d8e0d7; padding: 18px 10px 0; }
.storage-note { display: flex; gap: 8px; align-items: center; color: #68766d; font-size: 11px; }
.status-dot { height: 7px; width: 7px; border-radius: 50%; background: #548e65; }
.text-button { width: fit-content; border: 0; padding: 0; background: transparent; color: #52645a; font-size: 12px; font-weight: 600; text-align: left; }
.text-button:hover { color: var(--green-dark); }
.import-button { cursor: pointer; }
.import-button input { display: none; }
.main-area { min-width: 0; }
.topbar { height: 76px; padding: 0 clamp(22px, 4vw, 56px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; background: rgba(255,254,250,.7); color: #4f5b54; font-size: 13px; }
.eyebrow { color: #839087; font-size: 10px; font-weight: 700; letter-spacing: 1.15px; }
.topbar-separator { padding: 0 11px; color: #b8beb8; }
.primary-button { border: 0; border-radius: 6px; background: var(--green); color: white; padding: 11px 15px; font-size: 12px; font-weight: 700; box-shadow: 0 4px 9px rgba(49,95,74,.12); }
.primary-button:hover { background: var(--green-dark); }
.top-add span { font-size: 16px; padding-right: 4px; vertical-align: -1px; }
.page-content { max-width: 1200px; margin: 0 auto; padding: 39px clamp(22px, 4vw, 56px) 64px; animation: arrive .32s ease-out both; }
@keyframes arrive { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.page-heading h1 { margin: 0; font: 700 27px Manrope, sans-serif; letter-spacing: 0; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.date-label { color: var(--muted); font-size: 12px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.metric { min-height: 118px; background: var(--paper); border: 1px solid #e9e9e1; border-radius: 6px; padding: 18px 18px 15px; box-shadow: 0 3px 12px rgba(38,53,46,.025); }
.metric-label { color: #7b8580; font-size: 11px; font-weight: 600; }
.metric-value { margin-top: 13px; font: 700 25px Manrope, sans-serif; letter-spacing: 0; }
.metric-caption { margin-top: 4px; color: #8b938d; font-size: 10px; }
.metric.accent { background: #e3ede4; border-color: #dbe7dc; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(270px, .8fr); gap: 15px; }
.panel { background: var(--paper); border: 1px solid #e9e9e1; border-radius: 6px; box-shadow: 0 3px 12px rgba(38,53,46,.025); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid #eeeee8; }
.panel-header h2 { margin: 0; font: 700 14px Manrope, sans-serif; }
.panel-link { border: 0; background: transparent; color: var(--green); font-size: 11px; font-weight: 700; }
.panel-body { padding: 9px 20px 15px; }
.person-row, .break-row, .settlement-row { display: flex; align-items: center; gap: 11px; padding: 12px 0; border-bottom: 1px solid #f0f0ea; }
.person-row:last-child, .break-row:last-child, .settlement-row:last-child { border-bottom: 0; }
.avatar { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #e8eee7; color: #46644f; font: 700 11px Manrope, sans-serif; }
.avatar.orange { background: #f8ece3; color: #9c5d3c; }
.avatar.yellow { background: #f5f0d9; color: #887538; }
.row-main { min-width: 0; flex: 1; }
.row-name { overflow: hidden; color: #303b35; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { margin-top: 4px; color: #8a938d; font-size: 10px; }
.row-amount { font-size: 12px; font-weight: 700; white-space: nowrap; }
.amount-positive { color: var(--green); }
.amount-negative { color: var(--orange); }
.amount-neutral { color: #8b938d; }
.empty-state { padding: 33px 20px; text-align: center; color: #78827d; font-size: 12px; }
.empty-state strong { display: block; margin-bottom: 6px; color: #344039; font: 700 13px Manrope, sans-serif; }
.inline-link { color: var(--green); font-weight: 700; text-decoration: none; }
.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th { padding: 12px 17px; background: #fafaf6; color: #818b84; font-size: 10px; font-weight: 700; }
td { padding: 14px 17px; border-top: 1px solid #eeeee8; color: #526058; font-size: 11px; }
td strong { color: #303b35; font-size: 11px; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.form-panel { padding: 22px; }
.form-section + .form-section { margin-top: 25px; padding-top: 22px; border-top: 1px solid #ecece6; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.section-heading h2 { margin: 0; font: 700 14px Manrope, sans-serif; }
.section-heading span { color: #89938c; font-size: 10px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field label, .select-field label { display: block; margin-bottom: 7px; color: #647168; font-size: 11px; font-weight: 700; }
.field input, .field textarea, .select-field select { width: 100%; border: 1px solid #dfe3db; border-radius: 5px; background: #fff; color: var(--ink); padding: 10px 11px; font-size: 12px; outline: none; }
.field input:focus, .field textarea:focus, .select-field select:focus { border-color: #78947d; box-shadow: 0 0 0 3px rgba(87,130,95,.1); }
.field textarea { min-height: 76px; resize: vertical; }
.member-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.member-choice { min-width: 0; display: flex; align-items: center; gap: 9px; border: 1px solid #e7e9e2; border-radius: 5px; padding: 8px 9px; background: #fff; }
.member-choice:has(input:checked) { background: #f0f5ef; border-color: #cdddcf; }
.member-choice input { accent-color: var(--green); margin: 0; }
.member-choice .choice-name { min-width: 0; flex: 1; overflow: hidden; color: #47534b; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.member-choice select { width: 145px; min-width: 0; border: 1px solid #dfe3db; border-radius: 4px; background: white; color: #536158; padding: 6px 5px; font-size: 10px; }
.member-choice select:disabled { background: #f5f5f0; color: #a0a8a1; }
.selected-count { color: var(--green); font-weight: 700; }
.select-field select { appearance: auto; }
.summary-card { position: sticky; top: 18px; padding: 20px; background: #e7efe7; border: 1px solid #dbe6da; border-radius: 6px; }
.summary-card h2 { margin: 0 0 17px; font: 700 14px Manrope, sans-serif; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; color: #617068; font-size: 11px; border-bottom: 1px solid #d6e1d6; }
.summary-line strong { color: #2e4836; }
.summary-line.total { padding-top: 14px; color: #304438; font-weight: 700; }
.summary-message { margin: 14px 0; color: #68766d; font-size: 10px; line-height: 1.5; }
.summary-card .primary-button { width: 100%; }
.coffee-photo { margin: -20px -20px 18px; overflow: hidden; background: #dedbd2; border-radius: 6px 6px 0 0; }
.coffee-photo img { display: block; width: 100%; aspect-ratio: 1.5; object-fit: cover; }
.coffee-photo figcaption { padding: 7px 10px; background: #f4f3ee; color: #758078; font-size: 9px; line-height: 1.4; }
.coffee-photo a { color: var(--green); }
.form-error { display: none; margin: 0 0 12px; color: var(--red); font-size: 11px; line-height: 1.45; }
.form-error.visible { display: block; }
.settle-intro { background: #e8efe8; border-left: 3px solid var(--green); border-radius: 3px; padding: 15px 18px; margin: 0 0 17px; color: #5f6e64; font-size: 12px; line-height: 1.5; }
.settle-intro strong { color: #344e3b; }
.settle-amount { font: 700 12px Manrope, sans-serif; white-space: nowrap; }
.settle-arrow { color: #9aa39c; font-size: 16px; }
.roster-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.roster-edit { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--paper); border: 1px solid #e9e9e1; border-radius: 5px; }
.roster-edit .field { flex: 1; min-width: 0; }
.roster-edit input { margin: 0; }
.roster-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 17px; }
.secondary-button { border: 1px solid #dfe3db; border-radius: 5px; background: #fffefa; color: #59675e; padding: 10px 13px; font-size: 11px; font-weight: 700; }
.toast { position: fixed; z-index: 5; right: 22px; bottom: 22px; max-width: min(380px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 5px; background: #294936; color: #fff; font-size: 12px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.danger-button { border: 0; background: transparent; color: #a65c4c; font-size: 11px; font-weight: 700; }
.balance-legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 0 20px 14px; color: #7f8982; font-size: 10px; }
.legend-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--green); }
.legend-dot.negative { background: var(--orange); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 206px minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
  .form-layout { grid-template-columns: 1fr; }
  .summary-card { position: static; order: -1; }
}
@media (max-width: 650px) {
  .app-shell { display: block; padding-bottom: 66px; }
  .sidebar { position: fixed; z-index: 3; left: 0; right: 0; bottom: 0; height: 64px; padding: 0 8px; border: 0; border-top: 1px solid #dce3dc; background: #eef1ec; }
  .brand, .workspace-label, .sidebar-bottom { display: none; }
  .primary-nav { height: 100%; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; align-items: stretch; }
  .nav-item { flex-direction: column; justify-content: center; gap: 4px; border-radius: 0; padding: 4px 1px; text-align: center; font-size: 9px; }
  .nav-icon { font-size: 17px; }
  .topbar { height: 62px; padding: 0 17px; }
  .top-add { padding: 9px 11px; font-size: 10px; }
  .page-content { padding: 27px 16px 32px; }
  .page-heading { align-items: start; margin-bottom: 19px; }
  .page-heading h1 { font-size: 23px; }
  .page-heading p { font-size: 11px; }
  .date-label { display: none; }
  .metrics { gap: 8px; margin-bottom: 14px; }
  .metric { min-height: 98px; padding: 13px 12px; }
  .metric-label { font-size: 10px; }
  .metric-value { font-size: 21px; margin-top: 11px; }
  .metric-caption { font-size: 9px; }
  .panel-header { padding: 15px; }
  .panel-body { padding: 7px 15px 11px; }
  .form-layout { grid-template-columns: 1fr; }
  .summary-card { position: static; order: -1; }
  .form-panel { padding: 16px; }
  .field-grid { grid-template-columns: 1fr; }
  .member-list { grid-template-columns: 1fr; }
  .member-choice select { width: 152px; }
  .roster-grid { grid-template-columns: 1fr; }
  .settle-intro { font-size: 11px; }
  .toast { bottom: 76px; right: 12px; }
}

.topbar-actions { display: flex; align-items: center; gap: 17px; }
button:disabled { cursor: wait; opacity: .65; }
body.auth-view .app-shell { display: block; }
body.auth-view .sidebar, body.auth-view .topbar { display: none; }
body.auth-view .page-content { display: grid; min-height: 100vh; max-width: none; place-items: center; padding: 24px; background: radial-gradient(ellipse at 15% 15%, rgba(221, 235, 221, .75), transparent 48%), #f4f3ee; }
.auth-panel { width: min(100%, 440px); padding: 32px; border: 1px solid #e3e7df; border-radius: 7px; background: var(--paper); box-shadow: var(--shadow); }
.auth-panel .brand-mark { margin-bottom: 22px; }
.auth-panel .eyebrow { margin: 0 0 9px; }
.auth-panel h1 { margin: 0; color: var(--ink); font: 700 25px Manrope, sans-serif; }
.auth-panel > p:not(.eyebrow) { margin: 10px 0 22px; color: #707c74; font-size: 12px; line-height: 1.6; }
.auth-panel .field + .field { margin-top: 15px; }
.auth-panel form > .primary-button { width: 100%; margin-top: 9px; }
.auth-footnote { padding-top: 15px; border-top: 1px solid var(--line); font-size: 10px !important; }
.auth-message { min-height: 18px; margin: 12px 0 0; color: var(--red); font-size: 11px; }