:root {
  --bg: #f6f1e7; --card: #fffdf8; --ink: #1f2a24; --muted: #6b726c; --line: #e4dccb;
  --green: #0f5c4d; --green-soft: #dcebe4; --terra: #c4521f; --terra-soft: #f8e1d5;
  --gold: #b7791f; --gold-soft: #f6e8c8;
  --radius: 10px;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; padding-bottom: env(safe-area-inset-bottom, 0); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 80px; }
.loading { padding: 40px 16px; color: var(--muted); }
h1, h2, h3 { font-family: Georgia, "Iowan Old Style", serif; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; line-height: 1.15; }
h2 { font-size: 1.15rem; margin-bottom: 10px; }
.num { font-variant-numeric: tabular-nums; }

header.top { background: var(--green); color: #f6f1e7; padding: calc(env(safe-area-inset-top, 0px) + 18px) 0 22px; }
header.top .wrap { padding-bottom: 0; display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
header.top p { margin: 4px 0 0; opacity: .85; font-size: .9rem; }
.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; min-height: 38px; }
.btn:hover { border-color: var(--green); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--terra); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
header .btn { background: transparent; color: #f6f1e7; border-color: rgba(246,241,231,.5); white-space: nowrap; }
.btn.link { border: 0; background: none; color: var(--green); padding: 4px 0; text-decoration: underline; min-height: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat small { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 1.25rem; font-weight: 600; }
.stat.big { grid-column: 1 / -1; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 2px; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 99px; }

nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 16px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
nav.tabs button { font: inherit; background: none; border: 0; padding: 12px 14px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; }
nav.tabs button[aria-selected="true"] { color: var(--green); border-bottom-color: var(--green); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.member { cursor: pointer; }
.member .name { font-weight: 600; }
.pill { font-size: .75rem; padding: 2px 9px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.pill.aldia, .pill.completo, .pill.adelantado { background: var(--green-soft); color: var(--green); }
.pill.atrasado { background: var(--terra-soft); color: var(--terra); }
.meta { color: var(--muted); font-size: .85rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: .75rem; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--muted); }
.chip.ok { background: var(--green); border-color: var(--green); color: #fff; }
.chip.partial { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.chip.late { background: var(--terra-soft); border-color: var(--terra); color: var(--terra); }

form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
label { display: grid; gap: 4px; font-size: .8rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 40px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, nav.tabs button:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.span2 { grid-column: 1 / -1; }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
td.r, th.r { text-align: right; }
tfoot td { font-weight: 600; border-bottom: 0; }
.editrow { display: grid; grid-template-columns: 1fr 120px 36px; gap: 6px; margin-bottom: 6px; }
.editrow.m { grid-template-columns: 1fr 36px; }
.editrow button { min-height: 40px; }

.notice { background: var(--gold-soft); border: 1px solid #e6cf9b; border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; font-size: .9rem; }
.notice.err { background: var(--terra-soft); border-color: #e9b79f; }
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 20; max-width: 90vw; }
textarea.share { min-height: 170px; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
@media (max-width: 420px) { h1 { font-size: 1.4rem; } nav.tabs button { padding: 12px 10px; } }
@media (prefers-reduced-motion: no-preference) { .bar > i { transition: width .5s ease; } }
