/* ==========================================================
   Plataforma de treinamento — estilos
   Paleta: papel, tinta, pinho (ações) e latão (prêmios/ranking)
   ========================================================== */

:root {
  --paper: #f6f7f5;
  --surface: #ffffff;
  --ink: #17202a;
  --ink-2: #4a5560;
  --ink-3: #7b858e;
  --line: #e1e6e2;
  --line-2: #cfd6d1;
  --pine: #1f5c4a;
  --pine-dark: #164536;
  --pine-soft: #e6efeb;
  --brass: #b07d1a;
  --brass-soft: #f6eedb;
  --danger: #a8322a;
  --danger-soft: #f7e6e4;
  --warn: #8a5a00;
  --warn-soft: #fbf1dc;

  --font-ui: "Albert Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-num: "Fraunces", Georgia, "Times New Roman", serif;

  --r-sm: 6px;
  --r-md: 10px;
  --sidebar: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--pine); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; border-radius: 4px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; align-items: start; background: linear-gradient(to right, var(--surface) calc(var(--sidebar) - 1px), var(--line) calc(var(--sidebar) - 1px), var(--line) var(--sidebar), var(--paper) var(--sidebar)); }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 28px 18px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
}
.brand { font-family: var(--font-num); font-size: 22px; font-weight: 600; color: var(--ink); padding: 0 10px; }
.brand small { display: block; font-family: var(--font-ui); font-size: 12px; font-weight: 400; color: var(--ink-3); margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--paper); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--pine-soft); color: var(--pine-dark); }
.nav .count { font-size: 12px; background: var(--brass); color: #fff; border-radius: 99px; padding: 1px 8px; }
.sidebar-foot { margin-top: auto; padding: 0 10px; font-size: 13px; color: var(--ink-3); }
.sidebar-foot strong { display: block; color: var(--ink); font-weight: 600; }
.sidebar-foot button { margin-top: 8px; }

.main { padding: 40px 48px 80px; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); }
.back { display: inline-block; font-size: 13px; margin-bottom: 10px; color: var(--ink-3); }

/* Barra superior do colaborador */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 32px; height: 64px; display: flex; align-items: center; gap: 32px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { padding: 0; font-size: 20px; }
.topbar .nav { flex-direction: row; gap: 4px; }
.topbar .nav a { white-space: nowrap; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-2); }
.colab-main { max-width: 960px; margin: 0 auto; padding: 40px 32px 80px; }
.btn.menu-toggle { display: none; }

/* ---------- Blocos ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 24px; }
.panel + .panel { margin-top: 20px; }
.grid > .panel + .panel { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; gap: 12px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack > * + * { margin-top: 20px; }

/* Indicadores: número grande, rótulo discreto */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); margin-bottom: 24px; }
.stat { padding: 20px 22px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .value { font-family: var(--font-num); font-size: 32px; font-weight: 500; line-height: 1.1; }
.stat .label { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.stat a.value { color: var(--ink); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.right, th.right { text-align: right; }
tr.me td { background: var(--pine-soft); }
.empty { padding: 36px 16px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; font-weight: 600; }

/* ---------- Etiquetas ---------- */
.tag { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 99px; background: var(--paper); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.ok { background: var(--pine-soft); color: var(--pine-dark); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.gold { background: var(--brass-soft); color: var(--brass); border-color: transparent; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; font-size: 14px;
  padding: 9px 16px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--paper); text-decoration: none; }
.btn.primary { background: var(--pine); border-color: var(--pine); color: #fff; }
.btn.primary:hover { background: var(--pine-dark); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.link { border: 0; background: none; color: var(--pine); padding: 4px 6px; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Formulários ---------- */
.form { display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
label.field .hint { font-weight: 400; color: var(--ink-3); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], select, textarea {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 9px 12px; width: 100%;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pine); box-shadow: 0 0 0 3px var(--pine-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--pine); }
.checklist { border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 8px 12px; max-height: 190px; overflow: auto; display: grid; gap: 6px; background: var(--surface); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters > input, .filters > select { width: auto; min-width: 160px; }
.filters input[type=search] { min-width: 260px; }
.form-error { color: var(--danger); font-size: 14px; }

/* ---------- Editor de questões ---------- */
.q-card { border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; background: var(--surface); }
.q-card + .q-card { margin-top: 14px; }
.q-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.q-head .q-num { font-family: var(--font-num); font-size: 20px; color: var(--ink-3); min-width: 28px; }
.q-head select { width: auto; }
.q-head .pts { width: 90px; }
.q-head .spacer { flex: 1; }
.opt-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin-top: 8px; }
.opt-row input[type=radio], .opt-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--pine); }

/* ---------- Resolução da avaliação ---------- */
.take-head { position: sticky; top: 64px; z-index: 5; background: var(--paper); padding: 14px 0; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.progress { flex: 1; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--pine); transition: width .25s; }
.timer { font-family: var(--font-num); font-size: 20px; min-width: 70px; text-align: right; }
.timer.low { color: var(--danger); }
.question { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 26px; margin-bottom: 16px; }
.question .statement { font-size: 17px; margin-bottom: 16px; white-space: pre-wrap; }
.question .meta { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; margin-top: 8px; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--line-2); }
.choice input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--pine); flex: none; }
.choice.selected { border-color: var(--pine); background: var(--pine-soft); }
.choice.right { border-color: var(--pine); background: var(--pine-soft); }
.choice.wrong { border-color: var(--danger); background: var(--danger-soft); }
.explain { margin-top: 14px; padding: 12px 14px; background: var(--paper); border-radius: var(--r-sm); font-size: 14px; color: var(--ink-2); }

/* ---------- Resultado ---------- */
.result-hero { text-align: center; padding: 48px 24px; }
.result-hero .big { font-family: var(--font-num); font-size: 88px; line-height: 1; font-weight: 500; }
.result-hero .big small { font-size: 36px; color: var(--ink-3); }
.result-hero p { margin-top: 12px; color: var(--ink-2); }

/* ---------- Gamificação ---------- */
.hello { margin-bottom: 32px; }
.hello h1 { font-size: 30px; }
.level-card { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; }
.level-card .points { font-family: var(--font-num); font-size: 64px; line-height: 1; font-weight: 500; }
.level-card .points small { display: block; font-family: var(--font-ui); font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.level-bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.level-bar span { display: block; height: 100%; background: var(--brass); }

/* Pódio: o elemento marcante da plataforma */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 14px; margin: 8px 0 28px; }
.podium .step { text-align: center; }
.podium .who { font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .pts { font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.podium .block { border-radius: var(--r-md) var(--r-md) 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 14px; font-family: var(--font-num); font-size: 44px; font-weight: 500; }
.podium .p1 .block { height: 150px; background: var(--brass); color: #fff; }
.podium .p2 .block { height: 112px; background: var(--brass-soft); color: var(--brass); }
.podium .p3 .block { height: 84px; background: var(--paper); color: var(--ink-3); border: 1px solid var(--line); border-bottom: 0; }
.podium .step.me .who { color: var(--pine); }
.rank-pos { font-family: var(--font-num); font-size: 18px; width: 40px; }

.campaign { border: 1px solid var(--line); border-radius: var(--r-md); padding: 22px; background: var(--surface); }
.campaign + .campaign { margin-top: 14px; }
.campaign h3 { margin-bottom: 4px; }
.prize-list { display: grid; gap: 6px; margin: 14px 0; }
.prize { display: flex; gap: 12px; align-items: baseline; font-size: 14px; }
.prize .place { font-family: var(--font-num); color: var(--brass); min-width: 28px; }
.my-standing { display: flex; gap: 28px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.my-standing div { font-size: 13px; color: var(--ink-3); }
.my-standing strong { display: block; font-family: var(--font-num); font-size: 24px; color: var(--ink); font-weight: 500; }

.list-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item h3 { font-size: 15px; }
.list-item .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

/* ---------- Gráficos ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); }
.chart .lbl { fill: var(--ink-3); font-size: 11px; font-family: var(--font-ui); }
.chart .line { fill: none; stroke: var(--pine); stroke-width: 2; }
.chart .dot { fill: var(--surface); stroke: var(--pine); stroke-width: 2; }
.chart .val { fill: var(--ink); font-size: 11px; font-family: var(--font-ui); }
.hbar { display: grid; grid-template-columns: 140px 1fr 50px; gap: 12px; align-items: center; font-size: 14px; padding: 6px 0; }
.hbar .track { height: 8px; background: var(--paper); border-radius: 99px; overflow: hidden; }
.hbar .track, .hbar .fill { display: block; }
.hbar .fill { height: 100%; background: var(--pine); border-radius: 99px; }
.hbar .fill.low { background: var(--danger); }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--ink); color: #e9ecea; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brand { color: #fff; padding: 0; font-size: 26px; }
.auth-side blockquote { margin: 0; font-family: var(--font-num); font-size: 34px; line-height: 1.2; font-weight: 400; max-width: 460px; }
.auth-side .foot { font-size: 13px; color: #9aa5ae; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h1 { margin-bottom: 6px; }
.auth-form p.lead { color: var(--ink-2); margin-bottom: 28px; }

/* ---------- Modal e avisos ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(23, 32, 42, .45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border-radius: var(--r-md); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 28px; }
.modal h2 { margin-bottom: 12px; }
.modal .btn-row { justify-content: flex-end; margin-top: 22px; }
.secret { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 22px; letter-spacing: .06em; background: var(--paper); border: 1px dashed var(--line-2); border-radius: var(--r-sm); padding: 14px; text-align: center; margin: 14px 0; user-select: all; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: var(--r-sm); font-size: 14px; z-index: 60; max-width: 90vw; }
.toast.error { background: var(--danger); }
.notice { padding: 12px 16px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); font-size: 14px; margin-bottom: 20px; }
.notice.info { background: var(--pine-soft); color: var(--pine-dark); }
.loading { padding: 60px; text-align: center; color: var(--ink-3); }

/* ---------- Responsivo ---------- */
@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; background: var(--paper); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(23,32,42,.35); }
  .btn.menu-toggle { display: inline-flex; margin-bottom: 16px; }
  .main { padding: 24px 18px 60px; }
  .topbar { padding: 0 16px; gap: 12px; height: auto; min-height: 60px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .topbar .nav { order: 3; width: 100%; overflow-x: auto; }
  .take-head { top: 0; }
  .colab-main { padding: 24px 16px 60px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .level-card { grid-template-columns: 1fr; gap: 12px; }
  .hbar { grid-template-columns: 100px 1fr 44px; }
  .podium .block { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
