:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #5f6670;
  --accent: #0b6e4f;
  --accent-text: #ffffff;
  --error: #b42318;
  --border: #d7dbe0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --card: #1f2226;
    --text: #e8eaed;
    --muted: #a0a6ad;
    --accent: #3fb68b;
    --accent-text: #0d1f18;
    --error: #ff8a80;
    --border: #353a40;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}
h1 { margin: 0; font-size: 24px; }
h1 a { color: inherit; text-decoration: none; }
h2 { margin: 24px 0 8px; font-size: 20px; }
h3 { margin: 20px 0 8px; font-size: 17px; }
a { color: var(--accent); }
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.who { color: var(--muted); font-size: 14px; text-align: right; }
button.link {
  width: auto; margin: 0; padding: 0; background: none; border: 0;
  color: var(--accent); font-size: inherit; font-weight: 400; text-decoration: underline;
}
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row > *, .row input, .row select { min-width: 0; }   /* date inputs have a wide intrinsic size */
input:disabled, select:disabled { opacity: 1; color: var(--text); }
.list a.expense { display: flex; justify-content: space-between; gap: 12px; width: 100%; color: inherit; text-decoration: none; }
.amount { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals { font-variant-numeric: tabular-nums; }
button.danger { color: var(--error); border-color: var(--error); }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
label.check input[type=checkbox], label.check input[type=radio] { width: auto; margin: 0; }
.seg, .people { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.people { margin-top: 8px; }
.item { border: 1px solid var(--border); border-radius: 8px; padding: 0 12px 12px; margin-top: 12px; }
.item .seg { margin-top: 12px; }
input.pct { width: 4.5em; padding: 6px 8px; }
.item .remove-item { margin-top: 12px; }
#shares .list li { padding: 6px 0; }
@media (max-width: 400px) { .row { grid-template-columns: 1fr; gap: 0; } }
a.button {
  display: block; margin-top: 16px; padding: 12px; text-align: center; font-weight: 600;
  color: var(--accent-text); background: var(--accent); border-radius: 8px; text-decoration: none;
}
label { display: block; margin: 16px 0 6px; font-weight: 600; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
input, select {
  width: 100%;
  padding: 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
button {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: 0.6; cursor: default; }
.message { min-height: 1.5em; color: var(--error); }
.hint { color: var(--muted); font-size: 14px; }
.warning { color: var(--error); }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--accent); }
table.balances { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; font-variant-numeric: tabular-nums; }
table.balances th, table.balances td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--border); }
table.balances th:first-child, table.balances td:first-child { text-align: left; overflow-wrap: anywhere; }
table.balances td.plus { color: var(--accent); font-weight: 600; }
table.balances td.minus { color: var(--error); font-weight: 600; }
.list li.rate { display: block; }
.rate-line { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
.rate-form { display: flex; gap: 8px; margin-top: 8px; }
.rate-form input { flex: 1 1 6em; min-width: 0; padding: 8px 10px; }
.rate-form button { width: auto; margin: 0; padding: 8px 12px; white-space: nowrap; }
