:root {
  --cor: #ff5a1f;
  --cor-esc: #e04812;
  --cor-suave: #fff1eb;
  --side: #14161c;
  --side-2: #1d2029;
  --texto: #1b1e27;
  --muted: #6b7280;
  --borda: #e7e9ee;
  --fundo: #f4f5f8;
  --raio: 14px;
  --bs-primary: var(--cor);
  --bs-primary-rgb: 255, 90, 31;
  --bs-link-color: var(--cor-esc);
  --bs-link-hover-color: #b83a0d;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-body-color: var(--texto);
  --bs-border-color: var(--borda);
}
body { background: var(--fundo); font-size: .925rem; }
a { text-decoration: none; }

/* ---------- layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--side); color: #c9ccd6;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 1040;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.25rem 1.25rem 1rem; color: #fff; }
.brand img { width: 38px; height: 38px; object-fit: contain; border-radius: 10px; background: #fff; }
.brand-icon { width: 38px; height: 38px; border-radius: 11px; background: var(--cor); display: grid; place-items: center; font-size: 1.2rem; color: #fff; }
.brand-name { font-weight: 800; font-size: 1.02rem; line-height: 1.15; }
.nav-side { flex: 1; overflow-y: auto; padding: .5rem .75rem; }
.nav-side a {
  display: flex; align-items: center; gap: .75rem; color: #aeb2bf; padding: .62rem .85rem;
  border-radius: 10px; margin-bottom: 2px; font-weight: 500; transition: .15s;
}
.nav-side a i { font-size: 1.1rem; width: 1.2rem; text-align: center; }
.nav-side a:hover { background: var(--side-2); color: #fff; }
.nav-side a.active { background: var(--cor); color: #fff; box-shadow: 0 6px 18px rgba(255, 90, 31, .35); }
.side-user { border-top: 1px solid #262a35; padding: .9rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.side-user-info { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.side-user-info strong { display: block; color: #fff; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.side-user-info small { color: #8b90a0; font-size: .75rem; }
.btn-side { background: var(--side-2); color: #c9ccd6; border: 0; }
.btn-side:hover { background: #2a2e3a; color: #fff; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.75rem; background: rgba(244, 245, 248, .9);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 1020;
}
.page-title { font-size: 1.35rem; font-weight: 800; margin: 0; flex: 1; letter-spacing: -.01em; }
.topsearch { align-items: center; background: #fff; border: 1px solid var(--borda); border-radius: 999px; padding: 0 1rem; width: 380px; }
.topsearch input { border: 0; outline: 0; padding: .55rem .6rem; width: 100%; background: transparent; }
.topsearch i { color: var(--muted); }
.page { padding: .5rem 1.75rem 2rem; flex: 1; }
.foot { padding: 1rem 1.75rem; color: var(--muted); font-size: .78rem; }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: -260px; transition: left .2s; }
  body.menu-aberto .sidebar { left: 0; }
  body.menu-aberto .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 1030; }
  .topbar, .page { padding-left: 1rem; padding-right: 1rem; }
}

/* ---------- componentes */
.card { border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--borda); font-weight: 700; padding: .9rem 1.1rem; border-radius: var(--raio) var(--raio) 0 0 !important; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-body { padding: 1.1rem; }
.btn { border-radius: 10px; font-weight: 600; }
.btn-primary { --bs-btn-bg: var(--cor); --bs-btn-border-color: var(--cor); --bs-btn-hover-bg: var(--cor-esc); --bs-btn-hover-border-color: var(--cor-esc); --bs-btn-active-bg: var(--cor-esc); --bs-btn-active-border-color: var(--cor-esc); --bs-btn-disabled-bg: var(--cor); --bs-btn-disabled-border-color: var(--cor); }
.btn-outline-primary { --bs-btn-color: var(--cor-esc); --bs-btn-border-color: var(--cor); --bs-btn-hover-bg: var(--cor); --bs-btn-hover-border-color: var(--cor); --bs-btn-active-bg: var(--cor-esc); }
.form-control, .form-select { border-radius: 10px; border-color: #dcdfe6; }
.form-control:focus, .form-select:focus { border-color: var(--cor); box-shadow: 0 0 0 .2rem rgba(255, 90, 31, .15); }
.form-check-input:checked { background-color: var(--cor); border-color: var(--cor); }
.form-label { font-weight: 600; font-size: .82rem; color: #374151; margin-bottom: .3rem; }
.table { --bs-table-hover-bg: #fafafb; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .7rem .8rem; vertical-align: middle; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: #fafbfc; border-bottom-width: 1px; white-space: nowrap; }
.nav-tabs .nav-link { color: var(--muted); font-weight: 600; border: 0; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--cor-esc); border-bottom-color: var(--cor); background: transparent; }
.nav-tabs { border-bottom: 1px solid var(--borda); }
.badge { font-weight: 600; padding: .4em .65em; border-radius: 7px; }
.bg-suave-success { background: #e7f8ee; color: #137a3d; }
.bg-suave-danger { background: #fdecec; color: #b42318; }
.bg-suave-warning { background: #fff5db; color: #9a6700; }
.bg-suave-secondary { background: #eef0f3; color: #4b5563; }
.bg-suave-primary { background: var(--cor-suave); color: var(--cor-esc); }
.bg-suave-info { background: #e6f4ff; color: #0b63b6; }
.text-muted-2 { color: var(--muted); }
.section-title { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.4rem 0 .8rem; }
.section-title:first-child { margin-top: 0; }

/* avatares */
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; display: inline-grid; place-items: center; }
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-lg { width: 120px; height: 120px; border-radius: 22px; object-fit: cover; font-size: 2.2rem; display: inline-grid; place-items: center; }
.avatar-xl { width: 180px; height: 180px; border-radius: 26px; object-fit: cover; font-size: 3rem; display: inline-grid; place-items: center; }
.avatar-ini { background: linear-gradient(135deg, #ffd6c4, #ffb08e); color: #8a2c08; font-weight: 800; }

/* KPIs */
.kpi { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: 1.1rem 1.2rem; display: flex; gap: 1rem; align-items: center; height: 100%; }
.kpi-icon { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.kpi-valor { font-size: 1.45rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.kpi-rotulo { color: var(--muted); font-size: .8rem; font-weight: 500; }
a.kpi:hover { border-color: #d5d8df; box-shadow: 0 4px 14px rgba(16, 24, 40, .06); }

/* gráfico de barras */
.bars { display: flex; align-items: flex-end; gap: .75rem; height: 190px; padding-top: 1.2rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 46px; background: var(--cor); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; transition: .2s; }
.bar:hover { background: var(--cor-esc); }
.bar-val { position: absolute; top: -1.25rem; left: 50%; transform: translateX(-50%); font-size: .7rem; font-weight: 700; white-space: nowrap; color: var(--texto); }
.bar-lbl { margin-top: .45rem; font-size: .75rem; color: var(--muted); }

/* listas */
.lista-item { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.1rem; border-bottom: 1px solid #f0f1f4; color: inherit; }
.lista-item:last-child { border-bottom: 0; }
a.lista-item:hover { background: #fafafb; }
.lista-item .grow { flex: 1; min-width: 0; }
.lista-item .grow strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista-item small { color: var(--muted); }
.vazio { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.vazio i { font-size: 2rem; display: block; margin-bottom: .4rem; opacity: .5; }

/* perfil do aluno */
.perfil-head { display: flex; gap: 1.4rem; align-items: flex-start; flex-wrap: wrap; }
.perfil-head h2 { font-size: 1.5rem; font-weight: 800; margin: 0 0 .25rem; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .9rem 1.4rem; }
.info-grid dt { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.info-grid dd { margin: 0; font-weight: 500; }

/* foto no formulário */
.foto-box { width: 180px; height: 180px; border-radius: 22px; overflow: hidden; background: #f0f1f4; border: 2px dashed #d5d8df; display: grid; place-items: center; color: var(--muted); }
.foto-box img { width: 100%; height: 100%; object-fit: cover; }
#webcamVideo, #webcamCanvas { width: 100%; border-radius: 12px; background: #000; }

/* ficha de treino */
.divisao-tabs .nav-link { font-weight: 800; }
.ex-row td { padding: .4rem !important; }
.ex-row input { font-size: .85rem; padding: .35rem .5rem; }
.ex-row .handle { cursor: grab; color: var(--muted); }

/* check-in */
.checkin-box { max-width: 720px; margin: 0 auto; }
.checkin-search { font-size: 1.25rem; padding: .9rem 1.2rem; border-radius: 14px; }
.checkin-card { border-radius: 20px; padding: 1.5rem; display: flex; gap: 1.5rem; align-items: center; color: #fff; }
.checkin-ok { background: linear-gradient(135deg, #17a34a, #0f7a37); }
.checkin-alerta { background: linear-gradient(135deg, #f59e0b, #d97706); }
.checkin-bloq { background: linear-gradient(135deg, #e5484d, #b42318); }
.checkin-card h2 { font-weight: 800; margin: 0; }

/* login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-art { background: radial-gradient(circle at 20% 20%, #ff7a45 0, #ff5a1f 30%, #c2370a 100%); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { font-size: 2.6rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.login-form { display: grid; place-items: center; padding: 2rem; background: #fff; }
.login-form form { width: 100%; max-width: 380px; }
@media (max-width: 767.98px) { .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; } }

.pagination .page-link { color: var(--texto); border-radius: 8px !important; margin: 0 2px; border: 0; }
.pagination .active .page-link { background: var(--cor); color: #fff; }
.filtros { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: .9rem; margin-bottom: 1rem; }
.cursor-pointer { cursor: pointer; }
.nowrap { white-space: nowrap; }

/* impressão */
@media print {
  .sidebar, .topbar, .foot, .no-print, .btn, .alert { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; }
  .card { border: 0; box-shadow: none; }
}

/* ---------- celular / tablet */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035; background: #fff; border-top: 1px solid var(--borda);
  display: flex; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(16, 24, 40, .06);
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0 .45rem; color: var(--muted); font-size: .68rem; font-weight: 600; }
.bottom-nav a i { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--cor-esc); }
@media (max-width: 991.98px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .sidebar { padding-top: env(safe-area-inset-top); }
  .topbar { padding-top: max(.75rem, env(safe-area-inset-top)); padding-bottom: .75rem; }
  .page-title { font-size: 1.15rem; }
}
@media (max-width: 575.98px) {
  body { font-size: .9rem; }
  .page { padding: .25rem .75rem 1.5rem; }
  .topbar { padding-left: .75rem; padding-right: .75rem; }
  .card-body { padding: .9rem; }
  .card-header { padding: .75rem .9rem; flex-wrap: wrap; }
  .kpi { padding: .8rem; gap: .65rem; flex-direction: column; align-items: flex-start; }
  .kpi-icon { width: 38px; height: 38px; font-size: 1.1rem; border-radius: 11px; }
  .kpi-valor { font-size: 1.15rem; }
  .kpi-rotulo { font-size: .74rem; }
  .table > :not(caption) > * > * { padding: .55rem .5rem; }
  .lista-item { padding: .65rem .9rem; }
  .perfil-head { gap: 1rem; }
  .perfil-head .avatar-lg { width: 84px; height: 84px; border-radius: 18px; }
  .perfil-head h2 { font-size: 1.2rem; }
  .avatar-xl { width: 110px; height: 110px; border-radius: 20px; }
  .checkin-card { padding: 1.1rem; gap: 1rem; }
  .checkin-card h2 { font-size: 1.3rem; }
  .foot { display: none; }
  .modal-dialog { margin: .5rem; }
  .bars { gap: .35rem; }
  /* campos com 16px evitam o zoom automático do iPhone */
  .form-control, .form-select { font-size: 16px; }
  .btn { padding: .5rem .8rem; }
  .btn-sm { padding: .4rem .6rem; }
  .filtros { padding: .75rem; }
}
/* toque: alvos maiores em telas sensíveis ao toque */
@media (pointer: coarse) {
  .dropdown-item { padding: .6rem 1rem; }
  .nav-side a { padding: .8rem .9rem; }
}
.bar-col > .d-flex { min-width: 0; }
.bar-col > .d-flex > .bar { flex: 1 1 0; min-width: 0; }
@media (max-width: 575.98px) {
  .acoes-rapidas { display: grid !important; grid-template-columns: 1fr 1fr; }
  .acoes-rapidas .btn { font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
.nav-pills .nav-link { color: var(--texto); font-weight: 700; border-radius: 10px; }
.nav-pills .nav-link.active { background: var(--cor); color: #fff; }
