:root {
  --brand: #c8102e;
  --brand-strong: #a50d26;
  --brand-soft: #fbe9ec;
  --on-brand: #ffffff;
  --bg: #f5f5f6;
  --surface: #ffffff;
  --surface-2: #f0f0f2;
  --border: #e2e2e6;
  --text: #17171a;
  --text-2: #55555e;
  --muted: #8a8a94;
  --green: #1f9d55;
  --yellow: #e0a100;
  --red: #d42a2a;
  --grey: #9a9aa3;
  --green-soft: #e3f5ea;
  --yellow-soft: #fdf3d6;
  --red-soft: #fbe3e3;
  --grey-soft: #ececef;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
  --radius: 14px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #e5334d;
    --brand-strong: #ff4d66;
    --brand-soft: #3a1820;
    --bg: #111114;
    --surface: #1b1b1f;
    --surface-2: #24242a;
    --border: #303037;
    --text: #f2f2f4;
    --text-2: #b9b9c2;
    --muted: #85858f;
    --green: #3ccf7a;
    --yellow: #f3c234;
    --red: #ff5b5b;
    --grey: #7d7d87;
    --green-soft: #143222;
    --yellow-soft: #3a3012;
    --red-soft: #3d1717;
    --grey-soft: #2a2a30;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 750; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { min-height: 100vh; display: flex; }
.sidebar {
  width: 240px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand b { display: block; font-size: 14px; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 550; margin-bottom: 2px;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav svg { width: 20px; height: 20px; flex: none; }
.sidebar .spacer { flex: 1; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  display: flex; align-items: center; gap: 10px; padding: 12px 24px;
  padding-top: max(12px, env(safe-area-inset-top));
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .mobile-brand { display: none; }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.badge-dot {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--brand); color: var(--on-brand); font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.content { padding: 8px 24px 40px; max-width: 1280px; width: 100%; }
.bottomnav { display: none; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar .mobile-brand { display: block; width: 32px; height: 32px; }
  .content { padding: 4px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
  h1 { font-size: 21px; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: var(--nav-h); font-size: 10.5px; font-weight: 600; color: var(--muted);
  }
  .bottomnav a.active { color: var(--brand); }
  .bottomnav svg { width: 22px; height: 22px; }
}

/* ---------- componentes ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 8px 0 18px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card + .card, .section + .section { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.stack > .card + .card { margin-top: 10px; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 26px 0 10px; }
.section-title h2 { flex: 1; }
.grid { display: grid; gap: 12px; }
.grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.list-link { display: block; cursor: pointer; transition: border-color .15s, transform .15s; }
.list-link:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); }
.list-link:active { transform: scale(.995); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--border); background: var(--surface); font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-strong); }
.btn.danger { color: var(--red); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .55; cursor: default; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px;
  font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.yellow { background: var(--yellow-soft); color: color-mix(in srgb, var(--yellow) 70%, var(--text)); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.grey { background: var(--grey-soft); color: var(--text-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--grey); }
.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 13px; font-size: 12.5px;
  font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid transparent;
}
.chip.toggle { cursor: pointer; height: 36px; padding: 0 14px; font-size: 13.5px; border-color: var(--border); background: var(--surface); }
.chip.toggle.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

.score {
  display: inline-grid; place-items: center; min-width: 46px; height: 46px; border-radius: 12px; padding: 0 6px;
  background: var(--surface-2); font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums;
}
.score small { display: block; font-size: 10px; font-weight: 600; color: var(--muted); margin-top: -4px; }
.score.lg { min-width: 72px; height: 72px; font-size: 28px; border-radius: 16px; }
.stat .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .l { font-size: 12.5px; color: var(--muted); font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 14px; }
.banner.brand { background: var(--brand-soft); }
.banner.red { background: var(--red-soft); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- formulários ---------- */
label.field { display: block; }
label.field > span { display: block; font-size: 13px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  padding: 0 12px; outline: none;
}
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 599px) { .form-grid { grid-template-columns: 1fr; } }
.check-list { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.check-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; background: var(--surface);
}
.check-item input { width: 18px; height: 18px; accent-color: var(--brand); }
.check-item.on { border-color: var(--brand); background: var(--brand-soft); }
.score-input { width: 84px; text-align: center; font-weight: 700; font-size: 17px; }
.error-msg { color: var(--red); font-weight: 600; font-size: 13.5px; }

/* ---------- semana ---------- */
.week-nav { display: flex; align-items: center; gap: 6px; }
.week { display: grid; grid-template-columns: repeat(var(--cols, 7), minmax(0, 1fr)); gap: 10px; align-items: start; }
.day { min-width: 0; }
.day-head { display: flex; align-items: baseline; gap: 6px; padding: 6px 4px 8px; }
.day-head b { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.day-head span { font-size: 13px; color: var(--muted); }
.day.today .day-head b { color: var(--brand); }
.day.today .day-head .num { background: var(--brand); color: var(--on-brand); border-radius: 8px; padding: 0 6px; }
.session {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 8px;
  box-shadow: var(--shadow); border-left: 4px solid var(--brand);
}
.session .time { font-weight: 750; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.session .meta { font-size: 12.5px; color: var(--muted); }
.session .coach {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-top: 6px; border-radius: 8px;
  background: var(--surface-2); font-size: 13px; font-weight: 600; cursor: pointer;
}
.session .coach:hover { outline: 1px solid var(--border); }
.session .coach.mine { background: var(--brand-soft); }
.session .coach .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session.dim { opacity: .45; }
.day-empty { font-size: 12.5px; color: var(--muted); padding: 10px 4px; border: 1px dashed var(--border); border-radius: 10px; text-align: center; }
@media (max-width: 1099px) {
  .week { grid-template-columns: 1fr; gap: 4px; }
  .day-head { padding-top: 12px; }
  .day .sessions { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .session { margin-bottom: 0; }
}

/* ---------- unidade ---------- */
.unit-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
.attachment-preview { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); margin-top: 8px; }
.gk-score-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.gk-score-row:last-child { border-bottom: 0; }

/* ---------- gr ---------- */
.avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 15px;
}
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 64px; gap: 10px; align-items: center; font-size: 13.5px; margin: 8px 0; }
.bar-track { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; }
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12.5px;
  padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s;
}
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* ---------- repositório ---------- */
.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 10px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.report { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; color: var(--text-2); }

/* ---------- modal / toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.45); display: flex; align-items: center;
  justify-content: center; padding: 16px; animation: fade .15s;
}
.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 620px; max-height: calc(100vh - 32px);
  overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.modal-head h2 { flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
@media (max-width: 599px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
.toast-wrap { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
@media (min-width: 900px) { .toast-wrap { bottom: 24px; } }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.25); animation: fade .2s; }
.toast.error { background: var(--red); color: #fff; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  linear-gradient(160deg, var(--brand) 0 38%, var(--bg) 38%); }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .logo { width: 64px; height: 64px; margin-bottom: 12px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.notif { display: flex; gap: 12px; align-items: flex-start; padding: 12px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif:last-child { border-bottom: 0; }
.notif .dot { margin-top: 6px; }
.notif.unread b { color: var(--text); }
.notif.unread { background: linear-gradient(90deg, var(--brand-soft), transparent 60%); border-radius: 8px; }

.lrow { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--border); }
.lrow:last-child { border-bottom: 0; }
.lrow .grow { flex: 1; min-width: 0; }
.lrow:hover { background: var(--surface-2); }
@media (max-width: 599px) { .hide-sm { display: none; } }
@media (max-width: 599px) {
  .filters { grid-template-columns: 1fr 1fr; gap: 8px; }
  .filters .f-wide { grid-column: 1 / -1; }
  .filters .input { height: 38px; padding: 0 8px; font-size: 14px; }
  .filters label.field > span { margin-bottom: 3px; font-size: 12px; }
  .chip.toggle { height: 32px; padding: 0 11px; font-size: 12.5px; }
}

img.avatar { object-fit: cover; background: var(--surface-2); }
.avatar.sm { width: 34px; height: 34px; font-size: 12px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.nav a .avatar.xs { flex: none; }
.dot.brand-dot { background: var(--brand); }
.session.no-gk { border-left-color: var(--border); }
.session .coach.none { background: transparent; border: 1px dashed var(--border); color: var(--muted); font-weight: 500; cursor: default; }

.session .time, .session .meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session .meta.hc { font-size: 11.5px; }

.sdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; flex: none; }
.session { background: linear-gradient(90deg, color-mix(in srgb, var(--space, transparent) 9%, var(--surface)), var(--surface) 70%); }
.space-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.space-chip { cursor: pointer; border: 1px solid var(--border); background: var(--surface); }
.space-chip.on { border-color: var(--text); background: var(--surface-2); }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
.color-input { width: 38px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; }
.space-chip .muted { margin-left: 5px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 22px 0 16px; }
.tab { background: none; border: 0; padding: 10px 14px; font-weight: 650; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.result { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--surface-2); font-weight: 700; font-variant-numeric: tabular-nums; }
