/* ============================================================
   AppCVO — Design System (mobile-first)
   Paleta do clube: 1F4E78 / 2F75B5 / EAF2F8
   ============================================================ */

:root {
  --brand-900: #12324f;
  --brand-800: #1F4E78;
  --brand-700: #285f92;
  --brand-600: #2F75B5;
  --brand-300: #8fbce0;
  --brand-100: #EAF2F8;

  --accent: #f0a202;      /* voleibol / bola */
  --green: #1f9d55;
  --amber: #d97706;
  --red:   #d6455d;
  --purple:#7c5cbf;

  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --surface-2: #f7f9fc;
  --border:    #e2e8f0;
  --text:      #16202b;
  --text-2:    #5b6675;
  --text-3:    #8a94a3;

  --radius:   16px;
  --radius-sm:10px;
  --radius-lg:22px;
  --shadow-1: 0 1px 2px rgba(16,32,48,.06), 0 2px 8px rgba(16,32,48,.06);
  --shadow-2: 0 6px 24px rgba(16,32,48,.14);

  --tap: 48px;            /* área tátil mínima */
  --header-h: 56px;
  --nav-h: 64px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --ff: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f1620;
    --surface:   #17212e;
    --surface-2: #1d2937;
    --border:    #2a3849;
    --text:      #eaf0f6;
    --text-2:    #9fb0c2;
    --text-3:    #6b7a8c;
    --brand-100: #17303f;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 8px 28px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--ff);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; }
a { color: var(--brand-600); text-decoration: none; }
img { max-width: 100%; }

/* default inline icon sizing (overridden by component rules below) */
svg { width: 1.1em; height: 1.1em; flex-shrink: 0; vertical-align: -0.15em; }
.avatar svg { width: 54%; height: 54%; }
.badge svg { width: 13px; height: 13px; }
.chev svg { width: 20px; height: 20px; }

/* ---------- App layout ---------- */
.app-root { min-height: 100%; display: flex; flex-direction: column; }

.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
}
.screen.active { display: flex; }
.screen.no-nav { padding-bottom: var(--safe-bottom); }

/* ---------- Top app bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 8px) 14px 8px;
  min-height: calc(var(--header-h) + var(--safe-top));
  background: var(--brand-800);
  color: #fff;
  box-shadow: var(--shadow-1);
}
.appbar.plain { background: var(--surface); color: var(--text); border-bottom: 1px solid var(--border); }
.appbar .title { font-size: 1.12rem; font-weight: 700; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .subtitle { font-size: .74rem; opacity: .85; font-weight: 500; }
.appbar .icon-btn { color: inherit; }

.icon-btn {
  width: var(--tap); height: var(--tap);
  min-width: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: inherit; cursor: pointer;
  border-radius: 12px; padding: 0;
}
.icon-btn:active { background: rgba(127,127,127,.16); }
.icon-btn svg { width: 24px; height: 24px; }

/* ---------- Content ---------- */
.content { flex: 1; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.content.tight { gap: 10px; }
.section-title { font-size: .78rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3); margin: 4px 2px 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card-pad { padding: 14px; }
.card-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; width: 100%; text-align: left;
  background: none; border: none; color: inherit; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.card-row:last-child { border-bottom: none; }
.card-row:active { background: var(--surface-2); }
.card-row .grow { flex: 1; min-width: 0; }
.card-row .rp-title { font-weight: 650; font-size: .98rem; }
.card-row .rp-sub { font-size: .8rem; color: var(--text-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--text-3); flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border-radius: 14px; border: 1px solid transparent;
  font-size: 1rem; font-weight: 650; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border-color: var(--border);
  transition: transform .06s ease;
}
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.primary { background: var(--brand-600); color: #fff; border-color: transparent; }
.btn.brand   { background: var(--brand-800); color: #fff; border-color: transparent; }
.btn.success { background: var(--green); color: #fff; border-color: transparent; }
.btn.danger  { background: var(--red); color: #fff; border-color: transparent; }
.btn.ghost   { background: transparent; border-color: var(--border); }
.btn.lg { min-height: 56px; font-size: 1.06rem; border-radius: 16px; }
.btn svg { width: 20px; height: 20px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* sticky bottom action bar within a flow */
.action-bar {
  position: sticky; bottom: 0; z-index: 20;
  padding: 12px 14px calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--surface) 70%, transparent);
  display: flex; gap: 10px;
}
.action-bar .btn { flex: 1; }

/* FAB */
.fab {
  position: fixed; right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  z-index: 25;
  width: 56px; height: 56px; border-radius: 20px;
  background: var(--brand-600); color: #fff; border: none;
  box-shadow: var(--shadow-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.fab svg { width: 26px; height: 26px; }

/* ---------- Chips / segmented ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--text); font-size: .9rem; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.chip.on { background: var(--brand-800); color: #fff; border-color: var(--brand-800); }
.chip svg { width: 16px; height: 16px; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button {
  flex: 1; min-height: 40px; border: none; background: transparent; cursor: pointer;
  border-radius: 9px; font-weight: 650; color: var(--text-2); font-size: .9rem;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  background: var(--brand-100); color: var(--brand-700);
  line-height: 1.3;
}
.badge.dot::before { content:""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.green  { background: rgba(31,157,85,.14); color: var(--green); }
.badge.amber  { background: rgba(217,119,6,.15); color: var(--amber); }
.badge.red    { background: rgba(214,69,93,.15); color: var(--red); }
.badge.grey   { background: rgba(120,130,145,.16); color: var(--text-2); }
.badge.purple { background: rgba(124,92,191,.16); color: var(--purple); }

/* source tag (rastreabilidade) */
.src { font-size: .66rem; font-weight: 700; padding: 2px 6px; border-radius: 6px; letter-spacing:.02em; }
.src.auto   { background: rgba(120,130,145,.16); color: var(--text-2); }
.src.conf   { background: rgba(31,157,85,.14); color: var(--green); }
.src.chg    { background: rgba(217,119,6,.16); color: var(--amber); }

/* ---------- Avatar ---------- */
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 750; color: #fff; font-size: .95rem; flex-shrink: 0;
  background: var(--brand-600);
}
.avatar.sm { width: 34px; height: 34px; font-size: .78rem; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; }

/* ---------- Athlete row (presenças / avaliação) ---------- */
.athlete-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.athlete-row:last-child { border-bottom: none; }
.athlete-row .num { font-weight: 800; color: var(--text-3); width: 26px; text-align: center; flex-shrink: 0; }
.athlete-row .ainfo { flex: 1; min-width: 0; }
.athlete-row .ainfo .an { font-weight: 650; font-size: .96rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.athlete-row .ainfo .ap { font-size: .76rem; color: var(--text-2); }

/* state toggle buttons for attendance */
.state-btn {
  min-width: 44px; height: 44px; padding: 0 10px;
  border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); font-weight: 700; font-size: .8rem; cursor: pointer;
  color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.state-btn svg { width: 18px; height: 18px; }
.state-btn.present { background: rgba(31,157,85,.14); color: var(--green); border-color: transparent; }
.state-btn.exception { background: rgba(214,69,93,.14); color: var(--red); border-color: transparent; }
.state-btn.late { background: rgba(217,119,6,.16); color: var(--amber); border-color: transparent; }
.state-btn.partial { background: rgba(124,92,191,.16); color: var(--purple); border-color: transparent; }

/* evaluation scale buttons */
.scale {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.scale button {
  min-height: 46px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 700; font-size: .82rem;
  color: var(--text-2); padding: 4px 2px; display:flex; align-items:center; justify-content:center;
}
.scale button.on.s0 { background: rgba(120,130,145,.18); color: var(--text-2); border-color: transparent; }
.scale button.on.s1 { background: rgba(214,69,93,.16); color: var(--red); border-color: transparent; }
.scale button.on.s2 { background: rgba(47,117,181,.16); color: var(--brand-600); border-color: transparent; }
.scale button.on.s3 { background: rgba(31,157,85,.16); color: var(--green); border-color: transparent; }

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow-1);
}
.stat .sv { font-size: 1.55rem; font-weight: 800; line-height: 1.1; }
.stat .sl { font-size: .76rem; color: var(--text-2); margin-top: 2px; }
.stat .st { font-size: .72rem; font-weight: 700; margin-top: 6px; }
.stat.accent { background: var(--brand-800); color: #fff; border-color: transparent; }
.stat.accent .sl { color: rgba(255,255,255,.82); }

/* progress bar */
.bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand-600); border-radius: 999px; }
.bar.green > i { background: var(--green); }
.bar.amber > i { background: var(--amber); }
.bar.red > i { background: var(--red); }

/* ---------- List / meta ---------- */
.meta-list { display: flex; flex-direction: column; }
.meta-list .mrow { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.meta-list .mrow:last-child { border-bottom: none; }
.meta-list .mk { color: var(--text-2); min-width: 120px; }
.meta-list .mv { font-weight: 600; flex: 1; }

/* spinner */
.spinner { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto;
  border: 3px solid var(--border); border-top-color: var(--brand-600); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* empty state */
.empty { text-align: center; color: var(--text-3); padding: 40px 20px; }
.empty svg { width: 46px; height: 46px; opacity: .4; margin-bottom: 10px; }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
}
.bottom-nav.hidden { display: none; }
.nav-item {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: .66rem; font-weight: 650; padding: 6px 2px;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.on { color: var(--brand-600); }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60;
  pointer-events: none;
}
.toast {
  background: #16202b; color: #fff; padding: 11px 16px; border-radius: 12px;
  font-size: .88rem; font-weight: 600; box-shadow: var(--shadow-2);
  max-width: 90%; display: flex; align-items: center; gap: 10px;
  animation: toastin .25s ease;
}
.toast .undo { color: var(--accent); font-weight: 800; pointer-events: auto; cursor: pointer; }
.toast svg { width: 18px; height: 18px; }
@keyframes toastin { from { transform: translateY(12px); opacity: 0; } }

/* ---------- Modal / sheet ---------- */
.modal-host { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; justify-content: center; }
/* Quando escondido, não deve capturar cliques (o [hidden] do UA é sobreposto pelo display acima). */
.modal-host[hidden] { display: none; }
.modal-host::before { content:""; position: absolute; inset: 0; background: rgba(10,18,28,.5); }
.sheet {
  position: relative; width: 100%; max-width: 520px;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(16px + var(--safe-bottom));
  box-shadow: var(--shadow-2); animation: sheetin .28s cubic-bezier(.2,.8,.2,1);
  max-height: 88vh; overflow-y: auto;
}
@keyframes sheetin { from { transform: translateY(100%); } }
.sheet .grip { width: 40px; height: 4px; border-radius: 999px; background: var(--border); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 4px; font-size: 1.1rem; }
.sheet .sheet-sub { color: var(--text-2); font-size: .86rem; margin: 0 0 14px; }
.sheet .opt {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 6px; border: none; background: none; cursor: pointer; text-align: left;
  border-bottom: 1px solid var(--border); color: inherit; font-size: 1rem; font-weight: 600;
}
.sheet .opt:last-of-type { border-bottom: none; }
.sheet .opt .oi { width: 30px; display: flex; }
.sheet .opt.sel { color: var(--brand-600); }

/* inputs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: .82rem; font-weight: 650; color: var(--text-2); }
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-2);
  color: var(--text); font-size: 1rem; font-family: inherit;
}
.field textarea { min-height: 84px; resize: vertical; }

/* ---------- Net banner ---------- */
.net-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  padding: calc(var(--safe-top) + 6px) 12px 6px; text-align: center;
  font-size: .78rem; font-weight: 700; color: #fff;
}
.net-banner.offline { background: var(--amber); }
.net-banner.syncing { background: var(--brand-600); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: 24px 22px calc(24px + var(--safe-bottom));
  background: linear-gradient(160deg, var(--brand-900), var(--brand-700));
  color: #fff;
}
.login-logo { width: 84px; height: 84px; margin: 0 auto 16px; }
.login-wrap h1 { text-align: center; font-size: 1.6rem; margin: 0 0 2px; }
.login-wrap .tag { text-align: center; opacity: .85; margin: 0 0 30px; font-size: .92rem; }
.login-card { background: var(--surface); color: var(--text); border-radius: 20px; padding: 18px; box-shadow: var(--shadow-2); }
.role-pick { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.role-pick button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 56px; padding: 8px 14px; border-radius: 14px;
  border: 1.5px solid var(--border); background: var(--surface-2); cursor: pointer;
  color: var(--text); text-align: left;
}
.role-pick button .rn { font-weight: 700; }
.role-pick button .rd { font-size: .76rem; color: var(--text-2); }

/* matriz de acompanhamento */
.mtx { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mtx-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 6px; text-align: center; }
.mtx-cell .mv { font-size: 1.05rem; font-weight: 800; line-height: 1.1; }
.mtx-cell .ml { font-size: .64rem; color: var(--text-2); margin-top: 3px; }

/* helper */
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.small { font-size: .82rem; }
.center { text-align: center; }
.mt { margin-top: 8px; }
.hint {
  background: var(--brand-100); color: var(--brand-700);
  border-radius: 12px; padding: 10px 12px; font-size: .82rem; display: flex; gap: 8px;
}
.hint svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.divider { height: 1px; background: var(--border); margin: 2px 0; }
