:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #1d2420;
  --ink-2: #5a645e;
  --ink-3: #8b948e;
  --line: #e4e0d6;
  --brand: #1f6b4a;
  --brand-ink: #ffffff;
  --brand-soft: #e3f0e8;
  --accent: #e0702f;
  --accent-soft: #fbe9dd;
  --pos: #1f7a4d;
  --neg: #c2412d;
  --neg-soft: #fbe4df;
  --warn: #a8670e;
  --warn-soft: #fbefd6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 36, 32, .05), 0 4px 16px rgba(29, 36, 32, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1a201d;
    --surface-2: #161b18;
    --ink: #e9eeea;
    --ink-2: #a9b3ad;
    --ink-3: #78837c;
    --line: #2a322e;
    --brand: #4fb486;
    --brand-ink: #0d1a13;
    --brand-soft: #1d3329;
    --accent: #f08a4b;
    --accent-soft: #3a2619;
    --pos: #5cc493;
    --neg: #f07a66;
    --neg-soft: #3a201b;
    --warn: #e2a64a;
    --warn-soft: #362a16;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 232px; flex: none; padding: 22px 14px; border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; flex: none;
}
.brand b { display: block; font-size: 15px; line-height: 1.2; }
.brand small { color: var(--ink-3); font-size: 12px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-weight: 600;
}
.nav-link:hover { background: var(--surface); color: var(--ink); }
.nav-link.on { background: var(--brand-soft); color: var(--brand); }
.nav-link svg { width: 20px; height: 20px; flex: none; }
.side .spacer { flex: 1; }
main { flex: 1; min-width: 0; padding: 28px 32px 60px; max-width: 1040px; }
.topbar { display: none; }
.tabbar { display: none; }

@media (max-width: 820px) {
  .side { display: none; }
  main { padding: 16px 16px 96px; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 16px; position: sticky; top: 0; z-index: 5; background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .topbar .brand { padding: 0; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px;
    text-decoration: none; color: var(--ink-3); font-size: 11px; font-weight: 700;
  }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--brand); }
  .shell { display: block; }
}

/* ---------- elementos ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; line-height: 1.15; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -.01em; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card + .card, .stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 820px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: 9px 14px; border-radius: 10px; font-weight: 700;
  cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 40px;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--neg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.icon-btn { border: 0; background: transparent; color: var(--ink-2); padding: 6px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

label.field { display: block; }
label.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 9px 12px; min-height: 42px; outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap;
}
.pill.ok { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill.bad { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.orange { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
button.pill { cursor: pointer; }

/* destaque do saldo */
.hero {
  background: var(--brand); color: var(--brand-ink); border-radius: 18px; padding: 22px; position: relative; overflow: hidden;
}
.hero .label { font-weight: 700; opacity: .85; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.hero .big { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin: 6px 0 4px; }
.hero .sub { opacity: .85; font-size: 13px; }
.hero svg.feather { position: absolute; right: -10px; top: -14px; width: 150px; height: 150px; opacity: .14; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 820px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .k { font-size: 12px; color: var(--ink-2); font-weight: 700; }
.kpi .v { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* listas */
.list { margin: 0; padding: 0; list-style: none; }
.list > li, .list > a {
  display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-top: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.list > li:first-child, .list > a:first-child { border-top: 0; }
.list > a:hover { background: var(--surface-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--ink-2); flex: none;
}
.avatar.m { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.date-badge {
  width: 46px; flex: none; text-align: center; border: 1px solid var(--line); border-radius: 10px; padding: 4px 0; background: var(--surface-2);
}
.date-badge b { display: block; font-size: 17px; line-height: 1.1; }
.date-badge small { display: block; font-size: 10px; text-transform: uppercase; color: var(--ink-3); font-weight: 800; letter-spacing: .05em; }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t .r { text-align: right; }
.scroll-x { overflow-x: auto; }

/* grade de mensalidades */
.mgrid td, .mgrid th { text-align: center; }
.mgrid td:first-child, .mgrid th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
.dot { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 13px; font-weight: 800; }
.dot.ok { background: var(--brand-soft); color: var(--brand); }
.dot.no { background: var(--neg-soft); color: var(--neg); }
.dot.na { color: var(--ink-3); }

/* formulário do jogo */
.player-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pick {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; text-align: left; min-height: 44px;
}
.pick.on { border-color: var(--brand); background: var(--brand-soft); }
.pick .box { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--ink-3); flex: none; display: grid; place-items: center; }
.pick.on .box { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pick .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.pick .tag { margin-left: auto; font-size: 10px; font-weight: 800; color: var(--brand); }
.selected-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); }
.selected-row:first-child { border-top: 0; }
@media (max-width: 560px) {
  .selected-row { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 6px; }
  .selected-row > b { grid-column: 1 / -1; }
}
.money-in { width: 86px; text-align: right; }
.court-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.summary-box { position: sticky; top: 16px; }
.sum-line { display: flex; justify-content: space-between; padding: 6px 0; }
.sum-line.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-weight: 800; font-size: 17px; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 960px) { .game-layout { grid-template-columns: minmax(0, 1fr); } .summary-box { position: static; } }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface-2); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }

.empty { text-align: center; color: var(--ink-3); padding: 28px 10px; }

/* modal e aviso */
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 12, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 460px; padding: 20px; max-height: 90vh; overflow: auto; border: 1px solid var(--line); }
.modal h2 { font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@media (max-width: 820px) { .modal-back { place-items: end center; padding: 0; } .modal { border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); } }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 60; background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: calc(100% - 32px);
}
.toast.err { background: var(--neg); color: #fff; }
@media (max-width: 820px) { .toast { bottom: 84px; } }
.loading { padding: 60px 0; text-align: center; color: var(--ink-3); }
.notice { border-radius: 12px; padding: 12px 14px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.notice.info { background: var(--brand-soft); color: var(--brand); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { padding: 0 0 22px; justify-content: center; flex-direction: column; text-align: center; }
.login-card .brand-mark { width: 54px; height: 54px; border-radius: 16px; }
.login-card .brand-mark svg { width: 30px; height: 30px; }
.err-msg { color: var(--neg); font-weight: 700; font-size: 14px; min-height: 20px; margin-top: 10px; }
