:root {
  --navy: #081a2c;
  --navy-2: #102d48;
  --green: #12b981;
  --blue: #2563eb;
  --ink: #132437;
  --muted: #64748b;
  --line: #dce4ec;
  --canvas: #f3f6f9;
  --white: #fff;
  --danger: #dc2626;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --hero: #eef2f7;
  --shadow: #0f172a0c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
html[data-theme="dark"] {
  --navy: #f4f7ff;
  --navy-2: #dbe6ff;
  --green: #33d39d;
  --blue: #5b8cff;
  --ink: #edf3ff;
  --muted: #9eacc1;
  --line: #28364b;
  --canvas: #090f1c;
  --white: #111a2b;
  --surface: #111a2b;
  --surface-2: #0d1626;
  --hero: #0f1728;
  --shadow: #00000050;
}

html[data-theme="dark"] .contributor-card:nth-child(4n+1) { background: #13254a; border-color: #244377; color: #9bb7ff; }
html[data-theme="dark"] .contributor-card:nth-child(4n+2) { background: #352715; border-color: #66502a; color: #f4bd68; }
html[data-theme="dark"] .contributor-card:nth-child(4n+3) { background: #301b3d; border-color: #5c3470; color: #d89bea; }
html[data-theme="dark"] .contributor-card:nth-child(4n+4) { background: #153329; border-color: #285b49; color: #79d6ae; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.topbar { height: 72px; background: var(--surface); color: var(--ink); display: flex; align-items: center; justify-content: space-between; padding: 0 max(20px, calc((100vw - 1120px) / 2)); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand > span:last-child { display: flex; flex-direction: column; }
.brand strong { font-size: 17px; }
.brand small { color: var(--muted); margin-top: 2px; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; background: #0b1020; color: #3b73f1; font-size: 18px; }
.header-actions { display: flex; gap: 8px; }
.ghost, .icon-btn { border: 1px solid var(--line); color: var(--ink); background: var(--surface); border-radius: 999px; padding: 9px 13px; }
.install-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 750; }
.install-btn > span:first-child { color: var(--blue); font-size: 18px; line-height: 1; }
.icon-btn { width: 42px; font-weight: 800; letter-spacing: 2px; }
.icon-btn { border-radius: 10px; }
.hero { background: var(--hero); color: var(--ink); padding: 34px 20px 84px; border-bottom: 1px solid var(--line); }
.hero-inner { max-width: 1120px; margin: auto; display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 6px; color: #3b73f1; font-size: 12px; letter-spacing: .15em; font-weight: 800; }
h1 { margin: 0; font-size: clamp(30px, 5vw, 44px); letter-spacing: -.04em; }
.month-picker { display: flex; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 4px; box-shadow: 0 1px 2px var(--shadow); }
.month-picker button { width: 42px; height: 38px; border: 0; color: var(--ink); background: transparent; font-size: 26px; border-radius: 9px; }
.month-picker button:hover { background: var(--surface-2); }
.month-picker span { min-width: 150px; text-align: center; font-size: 14px; font-weight: 700; }
.shell { width: min(1120px, calc(100% - 32px)); margin: -52px auto 60px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.summary-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 28px var(--shadow); }
.summary-card { padding: 20px; }
.summary-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; font-weight: 900; }
.summary-icon.blue { background: #eff6ff; color: #2563eb; }
.summary-icon.navy { background: #eef2f6; color: var(--navy); }
.summary-icon.green { background: #ecfdf5; color: #059669; }
html[data-theme="dark"] .summary-icon.navy { background: #20314a; color: #c9daf8; border: 1px solid #344a69; }
.summary-card p { margin: 16px 0 5px; color: var(--muted); font-size: 14px; }
.summary-card > div:last-child { display: flex; align-items: end; justify-content: space-between; gap: 8px; }
.summary-card strong { font-size: 24px; letter-spacing: -.03em; }
.text-btn { padding: 0; border: 0; background: transparent; color: var(--blue); font-size: 12px; font-weight: 700; }
.panel { margin-top: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 22px 24px; border-bottom: 1px solid #edf1f5; }
.panel-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.contributors-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 20px 24px 24px; }
.contributor-card { border: 1px solid; border-radius: 14px; padding: 16px; }
.contributor-card:nth-child(4n+1) { background: #eff6ff; border-color: #dbeafe; color: #1d4ed8; }
.contributor-card:nth-child(4n+2) { background: #fffbeb; border-color: #fef3c7; color: #b45309; }
.contributor-card:nth-child(4n+3) { background: #fdf4ff; border-color: #fae8ff; color: #a21caf; }
.contributor-card:nth-child(4n+4) { background: #ecfdf5; border-color: #d1fae5; color: #047857; }
.contributor-name { font-weight: 800; }
.contributor-total { margin-top: 10px; font-size: 24px; font-weight: 850; letter-spacing: -.03em; }
.contributor-meta { margin-top: 3px; font-size: 13px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.primary-btn, .secondary-btn, .danger-btn { min-height: 40px; border-radius: 10px; padding: 9px 14px; font-weight: 750; border: 1px solid transparent; }
.primary-btn { background: #2563eb; color: #fff; }
.primary-btn:hover { background: #1d4ed8; }
.primary-btn:disabled { background: #dbe3ee; border-color: #c4cfdd; color: #526176; cursor: not-allowed; opacity: 1; }
html[data-theme="dark"] .primary-btn:disabled { background: #26364d; border-color: #40516a; color: #b8c6da; }
.secondary-btn { background: var(--surface); border-color: var(--line); color: var(--ink); }
.danger-btn { background: var(--danger); color: white; }
.progress { height: 8px; margin: 20px 24px 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress span { display: block; width: 0; height: 100%; background: #3b73f1; transition: width .25s ease; }
.bills-list { display: grid; gap: 12px; padding: 18px 20px 22px; }
.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 50px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 17px; }
.bill { border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.bill.complete { border-color: #bbf7d0; background: #f0fdf7; }
.bill-top { display: flex; justify-content: space-between; gap: 14px; }
.bill-title { min-width: 0; }
.bill-title h3 { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 17px; }
.bill-title p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.bill-amount { text-align: right; }
.bill-amount strong { display: block; font-size: 18px; }
.bill-actions { margin-top: 5px; display: flex; gap: 10px; justify-content: end; }
.bill-actions button { border: 0; padding: 0; background: transparent; color: var(--blue); font-size: 12px; font-weight: 700; }
.bill-actions .remove { color: #94a3b8; }
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.share { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: var(--surface-2); color: var(--ink); text-align: left; }
.share.is-paid { background: #dff8ed; border-color: #a7e8cc; color: #047857; }
.share.zero { opacity: .48; cursor: default; }
.check { width: 20px; height: 20px; flex: 0 0 20px; display: grid; place-items: center; border: 1.5px solid currentColor; border-radius: 6px; font-size: 12px; }
.share-name { overflow: hidden; text-overflow: ellipsis; }
.share-amount { margin-left: auto; font-weight: 800; }
.privacy-note { text-align: center; color: var(--muted); font-size: 13px; }
dialog { width: min(560px, calc(100% - 28px)); max-height: 90vh; overflow: auto; border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px #0f172a40; }
dialog::backdrop { background: #07162699; backdrop-filter: blur(3px); }
dialog form { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; gap: 16px; }
.dialog-head h2 { margin: 0; font-size: 22px; }
.dialog-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.close-btn { width: 38px; height: 38px; flex: 0 0 38px; border: 0; border-radius: 10px; background: var(--surface-2); font-size: 24px; color: var(--muted); }
.form-grid { display: grid; gap: 16px; margin-top: 22px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 700; }
input, select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); background: var(--surface); font-size: 16px; }
input:focus, select:focus { outline: 3px solid #3b73f125; border-color: #3b73f1; }
.split-box { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 14px; }
.split-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.split-head strong { font-size: 14px; }
.split-status { font-size: 12px; font-weight: 750; color: #b45309; }
.split-status.ok { color: #047857; }
.split-inputs { display: grid; gap: 10px; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 22px; }
.people-list { display: grid; gap: 8px; margin-top: 18px; }
.person-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; }
.person-row button { border: 0; background: transparent; color: var(--danger); font-weight: 700; }
.add-person-row { display: flex; gap: 8px; margin-top: 12px; }
.settings-list { display: grid; margin-top: 18px; }
.settings-list button { display: flex; align-items: center; gap: 12px; border: 0; border-top: 1px solid var(--line); background: var(--surface); padding: 15px 4px; text-align: left; color: var(--ink); }
.settings-list button > span:first-child { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); }
.settings-list button > span:last-child { display: grid; gap: 3px; }
.settings-list small { color: var(--muted); }
.settings-list .danger-item { color: var(--danger); }
.install-steps { margin-top: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink); line-height: 1.55; }
.install-steps strong { display: block; margin-bottom: 6px; }
.install-steps ol { margin: 8px 0 0; padding-left: 22px; }
.install-steps li + li { margin-top: 6px; }
#toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--navy); color: white; padding: 11px 16px; border-radius: 10px; box-shadow: 0 12px 35px #0f172a35; transition: .2s ease; font-size: 14px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 800px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .contributors-grid { grid-template-columns: 1fr 1fr; }
  .share-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar { padding: 0 16px; }
  .brand strong { font-size: 15px; }
  .install-btn { width: 42px; padding: 9px; }
  .install-label { display: none; }
  .hero { padding: 28px 16px 78px; }
  .hero-inner { align-items: stretch; flex-direction: column; }
  .month-picker { align-self: stretch; justify-content: space-between; }
  .shell { width: calc(100% - 24px); margin-top: -48px; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .summary-card { padding: 15px; }
  .summary-card strong { font-size: 19px; }
  .summary-card p { margin-top: 12px; }
  .panel-head { align-items: stretch; flex-direction: column; padding: 18px; }
  .contributors-grid { grid-template-columns: 1fr; padding: 14px 18px 18px; }
  .action-row > button { flex: 1; }
  .action-row .primary-btn { flex-basis: 100%; }
  .progress { margin-left: 18px; margin-right: 18px; }
  .bills-list { padding: 14px; }
  .two-col { grid-template-columns: 1fr; }
  dialog form { padding: 20px; }
}
@media print {
  @page { margin: 12mm; }
  body { background: white; }
  .no-print { display: none !important; }
  .hero { background: white; color: var(--ink); padding: 0 0 18px; }
  .shell { width: 100%; margin: 0; }
  .summary-card, .panel { box-shadow: none; break-inside: avoid; }
  .panel { margin-top: 12px; }
  .bill { break-inside: avoid; }
  .bill-actions { display: none; }
}
