:root {
  --bg: #f6f1e4;
  --bg-soft: #fbf6ea;
  --ink: #1c2a24;
  --ink-soft: #3a4a3f;
  --muted: #6b7a72;
  --line: #d9cfb6;
  --accent: #0f3d2e;
  --accent-ink: #f6e7c1;
  --card: #fffaf0;
  --card-alt: #f1e8d2;
  --ok: #2f7a5e;
  --warn: #b4621a;
  --shadow: 0 1px 2px rgba(28, 42, 36, 0.06), 0 8px 24px rgba(28, 42, 36, 0.06);
  --radius: 14px;
  --radius-sm: 8px;
  --max: 1100px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

.topbar {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent-ink); font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; }
.brand-text { letter-spacing: 0.2px; }
.topnav { display: flex; gap: 14px; flex-wrap: wrap; }
.topnav a { color: var(--accent-ink); opacity: 0.9; font-size: 0.95rem; }
.topnav a:hover { opacity: 1; text-decoration: none; }

main { padding: 32px 0 64px; }

.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 28px;
  align-items: center;
  margin-bottom: 40px;
}
.hero h1 {
  font-size: clamp(1.8rem, 3.2vw, 2.6rem);
  line-height: 1.15;
  margin: 0 0 12px;
  color: var(--ink);
}
.hero p { color: var(--ink-soft); font-size: 1.05rem; max-width: 52ch; }
.hero-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.pot-tag { background: var(--accent); color: var(--accent-ink); padding: 4px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.pot-total { font-size: 1.4rem; font-weight: 700; color: var(--ink); }
.mini-ledger { list-style: none; padding: 0; margin: 0 0 14px; }
.mini-ledger li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 0.95rem; }
.mini-ledger li:last-child { border-bottom: none; }
.mini-ledger .paid { color: var(--ok); font-weight: 600; }
.mini-settle { display: flex; justify-content: space-between; align-items: center; background: var(--card-alt); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 0.9rem; }
.mini-settle .hint { font-weight: 700; color: var(--accent); }

.section-head { margin-bottom: 20px; }
.section-head h2 { margin: 0 0 6px; font-size: 1.5rem; }
.section-head p { color: var(--ink-soft); margin: 0; max-width: 60ch; }

.pots-section, .ledger-section, .settle-section, .notes-section { margin-top: 48px; }

.presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.preset {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.preset:hover { background: var(--card-alt); }
.preset.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.new-pot {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: end;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.new-pot label { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 4px; }
.new-pot input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 0.95rem;
}
.new-pot input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #0a2d22; border-color: #0a2d22; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--card-alt); }
.btn.danger { color: #a03b2b; border-color: #e7c0b6; }
.btn.danger:hover { background: #f8e3dd; }

.pot-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.pot-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.pot-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.pot-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(15, 61, 46, 0.15); }
.pot-card h4 { margin: 0; font-size: 1.05rem; }
.pot-card .muted { color: var(--muted); font-size: 0.85rem; }
.pot-card .pot-card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.pot-card .delete-btn { background: none; border: none; color: #a03b2b; cursor: pointer; font-size: 0.85rem; padding: 4px 6px; border-radius: var(--radius-sm); }
.pot-card .delete-btn:hover { background: #f8e3dd; }

.active-pot { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.active-pot-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.active-pot h3 { margin: 0 0 4px; font-size: 1.3rem; }
.active-pot-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--accent); }

.expense-form, .person-form { display: grid; gap: 10px; margin-bottom: 18px; }
.expense-form { grid-template-columns: 1fr 1fr; }
.expense-form label, .person-form label { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.expense-form input, .expense-form select, .person-form input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 0.95rem;
  width: 100%;
}
.expense-form input:focus, .expense-form select:focus, .person-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.expense-form #exp-desc { grid-column: 1 / -1; }
.split-fieldset { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--bg-soft); }
.split-fieldset legend { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); padding: 0 6px; }
.split-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.split-checks label { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); padding: 6px 10px; border-radius: 999px; font-size: 0.9rem; cursor: pointer; }
.split-checks input[type="checkbox"] { accent-color: var(--accent); }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }

.expense-list-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.expense-list-head h4 { margin: 0; font-size: 1rem; }
.expense-list { list-style: none; padding: 0; margin: 0; }
.expense-list li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.expense-list li:last-child { border-bottom: none; }
.expense-list .desc { font-weight: 600; }
.expense-list .meta { color: var(--muted); font-size: 0.85rem; }
.expense-list .amount { font-weight: 700; color: var(--ink); }
.expense-list .remove-btn { background: none; border: none; color: #a03b2b; cursor: pointer; font-size: 0.85rem; padding: 4px 6px; border-radius: var(--radius-sm); }
.expense-list .remove-btn:hover { background: #f8e3dd; }

.person-form { grid-template-columns: 1fr auto; align-items: end; }
.person-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.person-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.person-list .remove-person { background: none; border: none; color: #a03b2b; cursor: pointer; font-size: 0.85rem; padding: 4px 6px; border-radius: var(--radius-sm); }
.person-list .remove-person:hover { background: #f8e3dd; }

.summary-balance { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 18px; }
.balance-card { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.balance-card .name { font-weight: 600; font-size: 0.95rem; }
.balance-card .amount { font-size: 1.2rem; font-weight: 700; margin-top: 4px; }
.balance-card .amount.positive { color: var(--ok); }
.balance-card .amount.negative { color: #a03b2b; }

.summary-settle { background: var(--card-alt); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.summary-settle h4 { margin: 0 0 8px; }
.summary-settle ul { list-style: none; padding: 0; margin: 0; }
.summary-settle li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.summary-settle li:last-child { border-bottom: none; }

.settle-output { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.settle-output ul { list-style: none; padding: 0; margin: 12px 0 0; }
.settle-output li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.settle-output li:last-child { border-bottom: none; }

.empty-ledger { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 32px 20px; text-align: center; color: var(--ink-soft); }
.empty-ledger h3 { margin: 0 0 6px; color: var(--ink); }

.notes-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.prose h3 { margin-top: 22px; margin-bottom: 6px; font-size: 1.15rem; color: var(--accent); }
.prose p, .prose li { color: var(--ink-soft); }
.prose ul { padding-left: 22px; }
.prose li { margin: 4px 0; }
.last-updated { color: var(--muted); font-size: 0.85rem; margin-top: 24px; border-top: 1px dashed var(--line); padding-top: 12px; }

.muted { color: var(--muted); font-size: 0.9rem; }

.footer { background: var(--accent); color: var(--accent-ink); padding: 24px 0; margin-top: 48px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer nav { display: flex; gap: 14px; flex-wrap: wrap; }
.footer a { color: var(--accent-ink); opacity: 0.9; font-size: 0.9rem; }
.footer a:hover { opacity: 1; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .new-pot { grid-template-columns: 1fr; }
  .expense-form { grid-template-columns: 1fr; }
  .person-form { grid-template-columns: 1fr; }
  .expense-list li { grid-template-columns: 1fr auto; }
  .expense-list .meta { grid-column: 1 / -1; }
  .topnav { gap: 10px; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.6rem; }
  .active-pot-actions .btn { flex: 1; }
  .form-actions .btn { flex: 1; }
}

@media print {
  .topbar, .footer, .hero-actions, .active-pot-actions, .presets, .new-pot, .expense-form, .person-form, .btn, .remove-btn, .remove-person, .notes-section, .settle-section { display: none !important; }
  .active-pot { box-shadow: none; border: none; padding: 0; }
  .tab-panel { display: block !important; }
  body { background: #fff; color: #000; }
}


/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
