/* Uma coluna estreita: os números no topo, a lista de integrantes como peça principal e a explicação como documento simples abaixo. */
:root {
  --bg: #F2F4F8;
  --surface: #FFFFFF;
  --ink: #131A26;
  --muted: #5A6577;
  --line: #D8DEE8;
  --accent: #2450C8;
  --accent-ink: #FFFFFF;
  --paid: #12714A;
  --paid-bg: #DCF2E5;
  --due: #8A5200;
  --due-bg: #FAEACB;
  --danger: #B3261E;
  --danger-bg: #FBE4E2;
  --track-off: #B4BECD;
  --thumb: #FFFFFF;
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F131A;
    --surface: #181E29;
    --ink: #E8ECF2;
    --muted: #98A3B3;
    --line: #2B3442;
    --accent: #8AABFF;
    --accent-ink: #0F131A;
    --paid: #62D39C;
    --paid-bg: #143324;
    --due: #F0B95C;
    --due-bg: #3A2B0F;
    --danger: #FF8A80;
    --danger-bg: #3D1B19;
    --track-off: #414D5E;
    --thumb: #E8ECF2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 56px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
body.narrow .wrap { max-width: 440px; padding-top: 12vh; gap: 16px; }

h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); font-weight: 700; letter-spacing: -0.02em; }
body.narrow h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.eyebrow { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.top { display: flex; flex-direction: column; gap: 10px; }
.lede { color: var(--muted); max-width: 60ch; }
.hint { font-size: 0.85rem; color: var(--muted); }
.foot { font-size: 0.85rem; color: var(--muted); }

/* Resumo */
.summary, .card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.figures { display: flex; flex-wrap: wrap; gap: 16px 36px; align-items: flex-end; }
.fig { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fig .label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.fig .value { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.fig.main .value { font-size: clamp(2.2rem, 9vw, 3rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.fig .sub { font-size: 0.85rem; color: var(--muted); }
.progress { display: flex; flex-direction: column; gap: 8px; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--paid); border-radius: 999px; }
.progress-text { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: space-between; font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-text strong { color: var(--ink); font-weight: 600; }
.paynote { border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; overflow-wrap: anywhere; }
.paynote .label { display: block; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* Lista */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.seg a { color: var(--muted); font-size: 0.85rem; font-weight: 500; padding: 6px 12px; border-radius: 999px; white-space: nowrap; text-decoration: none; }
.seg a[aria-current] { background: var(--ink); color: var(--bg); }

.roll { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.roll li {
  display: grid;
  grid-template-columns: 2ch minmax(0, 1fr) auto auto;
  grid-template-areas: "num name amount status";
  align-items: center;
  gap: 4px 14px;
  padding: 10px 16px;
  min-height: 56px;
  border-top: 1px solid var(--line);
}
.roll li:first-child { border-top: 0; }
.roll li.empty-row { display: block; padding: 22px 16px; color: var(--muted); text-align: center; }
.roll .num { grid-area: num; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; text-align: right; }
.roll .name { grid-area: name; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.roll .amount { grid-area: amount; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.92rem; white-space: nowrap; }
.roll .status { grid-area: status; display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.roll .status form { display: flex; }
.roll li.is-paid .name { color: var(--muted); }
.roll li.is-out .name { color: var(--muted); text-decoration: line-through; }
@media (max-width: 520px) {
  .roll li {
    grid-template-columns: 2ch minmax(0, 1fr) auto;
    grid-template-areas: "num name status" "num amount status";
    gap: 0 12px;
  }
  .roll .amount { font-size: 0.85rem; }
  .roll.can-edit li {
    grid-template-areas: "num name amount" "num status status";
    gap: 2px 12px;
  }
  .roll.can-edit .status { justify-content: space-between; }
}

.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; font-weight: 600; padding: 5px 11px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.paid { background: var(--paid-bg); color: var(--paid); }
.pill.due { background: var(--due-bg); color: var(--due); }
.pill.out { background: var(--line); color: var(--muted); }

.switch {
  display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; font: inherit; cursor: pointer;
  padding: 8px 2px; min-height: 44px; color: var(--due); border-radius: 999px;
}
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--track-off); position: relative; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--thumb); }
.switch .lbl { width: 4.8em; text-align: left; font-size: 0.85rem; font-weight: 600; }
.switch[aria-checked="true"] { color: var(--paid); }
.switch[aria-checked="true"] .track { background: var(--paid); }
.switch[aria-checked="true"] .track::after { transform: translateX(18px); }

/* Botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.9rem; font-weight: 500;
  padding: 8px 14px; border-radius: 10px; cursor: pointer; min-height: 40px; width: fit-content;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.link-btn {
  border: 1px solid var(--line); background: none; color: var(--muted); font: inherit; font-size: 0.82rem; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; cursor: pointer; min-height: 36px; white-space: nowrap;
}
.link-btn:hover { color: var(--ink); border-color: var(--muted); }
.field {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%; min-width: 0; min-height: 40px;
}
textarea.field { resize: vertical; line-height: 1.45; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.rows { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.items { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.4fr) 7.5em; }
.field.money { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) {
  .row.items { grid-template-columns: minmax(0, 1fr) 7em; }
  .row.items .field:nth-child(2) { grid-column: 1 / -1; order: 3; }
}

.flash { padding: 10px 14px; border-radius: 10px; font-weight: 500; font-size: 0.92rem; }
.flash.ok { background: var(--paid-bg); color: var(--paid); }
.flash.err { background: var(--danger-bg); color: var(--danger); }

/* Barra do painel */
.adminbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.adminbar .inner { max-width: 720px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.adminbar .brand { font-family: var(--font-display); }
.adminbar nav { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.88rem; }
.adminbar nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.adminbar nav a:hover { color: var(--ink); }
.adminbar .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.adminbar .right form { display: flex; }
body.admin section { display: flex; flex-direction: column; gap: 12px; }
body.admin .section-head { margin-bottom: 0; }

/* Explicação */
.doc { display: flex; flex-direction: column; gap: 16px; border-top: 1px solid var(--line); padding-top: 28px; }
.doc p, .doc li { max-width: 65ch; }
.doc ul { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.table-scroll { overflow-x: auto; }
table.order { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.order th, table.order td { text-align: left; padding: 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.order th { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
table.order td:last-child, table.order th:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; padding-left: 16px; }
table.order tfoot td { font-weight: 600; border-bottom: 0; font-family: var(--font-display); font-size: 1.05rem; }
table.order .detail { display: block; color: var(--muted); font-size: 0.85rem; font-family: var(--font-body); font-weight: 400; }
.calc {
  font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 1.15rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; width: fit-content; max-width: 100%;
}
