/* ================================ CCR — site + painel ================================
   Estética: cockpit de rally à noite. A "amarela" (linha de setor) é o elemento de
   assinatura; instrumentos em mono; display em Chakra Petch. */

:root {
  --asphalt: #0d1014;
  --asphalt-2: #10141a;
  --surface: #161a21;
  --surface-2: #1e232c;
  --ink: #eef1f5;
  --muted: #8b94a3;
  --muted-2: #5c6472;
  --amarela: #f2c200;   /* linha de setor / acento principal */
  --azul: #3d7bff;      /* azul do roadbook */
  --verde: #35c26b;     /* dentro do ideal / adiantado ok */
  --vermelho: #ff5a4d;  /* atraso / penalidade */
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --radius: 14px;
  --maxw: 1140px;
  --disp: "Chakra Petch", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* o atributo hidden precisa vencer os display:flex de .modal/.form/etc. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(61, 123, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(242, 194, 0, 0.06), transparent 55%),
    var(--asphalt);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 { font-family: var(--disp); font-weight: 600; letter-spacing: -0.01em; margin: 0; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amarela);
  margin: 0 0 0.9rem;
}

/* -------- botões -------- */
.btn {
  font-family: var(--disp);
  font-weight: 600;
  font-size: 0.98rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.72rem 1.4rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.btn:active { transform: translateY(1px); }
.btn-amber { background: var(--amarela); color: #1a1400; }
.btn-amber:hover { background: #ffd21f; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--amarela); color: var(--amarela); }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.88rem; }
.btn-block { width: 100%; justify-content: center; margin-top: 0.4rem; }

/* -------- marca -------- */
.brand { display: inline-flex; align-items: center; gap: 0.55rem; }
.brand-word { font-family: var(--disp); font-weight: 700; font-size: 1.35rem; letter-spacing: 0.02em; }
.brand-tick { width: 4px; height: 22px; background: var(--amarela); border-radius: 2px; display: inline-block; box-shadow: 0 0 12px rgba(242, 194, 0, 0.5); }
.brand-panel {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line-2); padding: 0.15rem 0.5rem; border-radius: 6px; margin-left: 0.4rem;
}

/* -------- navbar -------- */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--maxw); margin: 0 auto; padding: 1.2rem 1.5rem;
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(10px);
  background: linear-gradient(var(--asphalt), rgba(13, 16, 20, 0.6));
}
.nav-links { display: flex; gap: 1.6rem; font-size: 0.95rem; color: var(--muted); }
.nav-links a:hover { color: var(--ink); }
.nav-user { display: flex; align-items: center; gap: 0.9rem; }
.user-name { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }

/* ================================ HERO ================================ */
.hero {
  max-width: var(--maxw); margin: 0 auto; padding: 3.5rem 1.5rem 4rem;
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 3rem; align-items: center;
}
.hero-title { font-size: clamp(2.4rem, 5vw, 3.7rem); line-height: 1.03; font-weight: 700; }
.hero-sub { color: var(--muted); font-size: 1.08rem; max-width: 34ch; margin: 1.3rem 0 1.8rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.hero-note { font-family: var(--mono); font-size: 0.78rem; color: var(--muted-2); margin-top: 1.2rem; }

/* -------- instrumento (assinatura) -------- */
.instrument {
  background: linear-gradient(160deg, var(--surface-2), var(--asphalt-2));
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 1.6rem 1.7rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
  overflow: hidden;
}
.inst-sector {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.14em; color: var(--muted);
}
.inst-live { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--verde); }
.inst-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--verde); box-shadow: 0 0 8px var(--verde); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.inst-label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.2em; color: var(--muted-2); text-transform: uppercase; }
.inst-odo { margin-top: 1.1rem; }
.inst-odo-val { display: flex; align-items: baseline; gap: 0.4rem; }
.odo-num { font-family: var(--mono); font-weight: 700; font-size: 3.4rem; line-height: 1; letter-spacing: -0.02em; }
.odo-unit { font-family: var(--mono); color: var(--muted); font-size: 1.1rem; }
.inst-sectorline { height: 4px; background: var(--amarela); border-radius: 2px; margin: 1.2rem 0; box-shadow: 0 0 16px rgba(242, 194, 0, 0.45); }
.inst-tnav-val { font-family: var(--mono); font-weight: 700; font-size: 2.6rem; line-height: 1.1; color: var(--amarela); }
.inst-tnav-hint { font-size: 0.82rem; color: var(--muted); }
.inst-regime { display: flex; align-items: center; justify-content: space-between; margin: 1.2rem 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.inst-regime-val { font-family: var(--mono); font-weight: 700; font-size: 1.5rem; }
.inst-regime-val em { font-style: normal; font-size: 0.85rem; color: var(--muted); }
.inst-tulip { display: flex; align-items: center; gap: 0.9rem; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem 1rem; }
.tulip-glyph { width: 42px; height: 42px; flex: none; fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.tulip-glyph circle { fill: var(--amarela); stroke: none; }
.inst-tulip-main { font-family: var(--disp); font-weight: 600; font-size: 0.98rem; }
.inst-tulip-sub { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }

/* ================================ BAND ================================ */
.band {
  max-width: var(--maxw); margin: 0 auto; padding: 0 1.5rem 1rem;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.band-item { background: var(--surface); padding: 1.3rem 1.4rem; }
.band-num { font-family: var(--disp); font-weight: 700; font-size: 1.15rem; color: var(--amarela); }
.band-lab { font-size: 0.86rem; color: var(--muted); margin-top: 0.2rem; }

/* ================================ SECTIONS ================================ */
.section { max-width: var(--maxw); margin: 0 auto; padding: 5rem 1.5rem; }
.section-title { font-size: clamp(1.7rem, 3.2vw, 2.5rem); max-width: 22ch; margin-bottom: 2.6rem; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.7rem; position: relative;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--line-2); transform: translateY(-3px); }
.card-mark { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 1.2rem; }
.card h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.card p { color: var(--muted); font-size: 0.95rem; margin: 0; }
.card-amber { border-color: rgba(242, 194, 0, 0.35); background: linear-gradient(180deg, rgba(242, 194, 0, 0.06), var(--surface)); }
.card-amber .card-mark { color: var(--amarela); }

/* -------- passos -------- */
.section-steps { border-top: 1px solid var(--line); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; counter-reset: none; }
.step { position: relative; padding-top: 1.6rem; border-top: 3px solid var(--amarela); }
.step-n { font-family: var(--mono); font-weight: 700; font-size: 0.95rem; color: #1a1400; background: var(--amarela); width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 0.9rem; }
.step h3 { font-size: 1.25rem; margin-bottom: 0.4rem; }
.step p { color: var(--muted); font-size: 0.96rem; margin: 0; }

/* -------- download -------- */
.download { text-align: center; }
.download-inner {
  background: linear-gradient(160deg, var(--surface-2), var(--asphalt-2));
  border: 1px solid var(--line-2); border-radius: 22px; padding: 3.5rem 2rem;
}
.download-inner .section-title { margin-left: auto; margin-right: auto; max-width: 18ch; }
.download-inner .hero-cta { justify-content: center; }
.download-sub { color: var(--muted); margin: 0 0 1.8rem; }

/* -------- footer -------- */
.footer { max-width: var(--maxw); margin: 0 auto; padding: 3rem 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.footer .brand { margin-bottom: 0.7rem; }
.footer-dim { color: var(--muted-2); font-size: 0.82rem; }

/* ================================ PAINEL ================================ */
.nav-app { border-bottom: 1px solid var(--line); }
.dash { max-width: var(--maxw); margin: 0 auto; padding: 2.5rem 1.5rem 5rem; }
.dash-hello { margin-bottom: 2rem; }
.dash-title { font-size: clamp(1.8rem, 4vw, 2.6rem); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 3rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.4rem;
  position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--amarela); }
.stat-val { font-family: var(--mono); font-weight: 700; font-size: 2rem; line-height: 1; }
.stat-lab { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.stat-sub { font-family: var(--mono); font-size: 0.72rem; color: var(--muted-2); margin-top: 0.2rem; }

.dash-block { margin-bottom: 3rem; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.2rem; gap: 1rem; flex-wrap: wrap; }
.block-head h2 { font-size: 1.35rem; }
.block-hint { font-family: var(--mono); font-size: 0.76rem; color: var(--muted-2); }

/* -------- eventos -------- */
.events { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.1rem; }
.event {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.5rem;
  transition: border-color 0.15s ease;
}
.event:hover { border-color: var(--line-2); }
.event-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.event-name { font-family: var(--disp); font-weight: 600; font-size: 1.2rem; }
.event-local { font-size: 0.88rem; color: var(--muted); margin-top: 0.15rem; }
.event-badge { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amarela); border: 1px solid rgba(242, 194, 0, 0.35); padding: 0.2rem 0.5rem; border-radius: 6px; white-space: nowrap; }
.event-meta { display: flex; gap: 1.6rem; margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.event-metric .m-val { font-family: var(--mono); font-weight: 700; font-size: 1.25rem; }
.event-metric .m-lab { font-size: 0.74rem; color: var(--muted); }
.m-best { color: var(--verde); }

/* -------- performance -------- */
.perf { display: flex; flex-direction: column; gap: 0.5rem; }
.perf-row {
  display: grid; grid-template-columns: 1.6fr 1fr 0.7fr 0.7fr 0.9fr auto; gap: 1rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1.2rem;
  cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease;
}
.perf-row:hover { border-color: var(--amarela); background: var(--surface-2); }
.perf-name { font-family: var(--disp); font-weight: 600; }
.perf-date, .perf-cell { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.perf-pts { font-family: var(--mono); font-weight: 700; font-size: 1.1rem; }
.perf-head { background: transparent; border: none; padding: 0.2rem 1.2rem; cursor: default; }
.perf-head:hover { background: transparent; border: none; }
.perf-head span { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); }
.perf-go { color: var(--muted-2); font-family: var(--mono); }

/* -------- estado vazio -------- */
.empty { background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 2.5rem; text-align: center; color: var(--muted); }
.empty strong { display: block; font-family: var(--disp); color: var(--ink); font-size: 1.1rem; margin-bottom: 0.4rem; }

/* ================================ ADMIN ================================ */
.admin-grant {
  display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.3rem 1.4rem; margin-bottom: 1.1rem;
}
.admin-grant .field { flex: 1 1 200px; }
.admin-grant select {
  background: var(--asphalt); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 0.7rem 0.85rem; color: var(--ink); font-family: var(--body); font-size: 0.95rem;
}
.admin-grant select:focus { outline: none; border-color: var(--amarela); box-shadow: 0 0 0 3px rgba(242, 194, 0, 0.15); }
.admin-users { display: flex; flex-direction: column; gap: 0.5rem; }
.admin-user {
  display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1.2rem;
}
.admin-user-id { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.admin-user-name { font-family: var(--disp); font-weight: 600; }
.admin-user-mail { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.admin-badge { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: #1a1400; background: var(--amarela); padding: 0.1rem 0.4rem; border-radius: 5px; }
.admin-user-events { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 0.25rem 0.35rem 0.25rem 0.7rem; }
.chip-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.72rem; line-height: 1; padding: 0.15rem 0.3rem; border-radius: 50%; }
.chip-x:hover { color: var(--vermelho); background: rgba(255, 90, 77, 0.12); }
.chip-empty { font-family: var(--mono); font-size: 0.76rem; color: var(--muted-2); }

/* ================================ MODAL / DRAWER ================================ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 6, 9, 0.78); backdrop-filter: blur(4px); }
.modal-card {
  position: relative; z-index: 1; width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; padding: 2rem 1.9rem 2.2rem;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
}
.modal-x { position: absolute; top: 1rem; right: 1rem; background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.modal-x:hover { color: var(--ink); }
.modal-brand { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.4rem; }
.modal-brand .brand-word { font-size: 1.15rem; }
.tabs { display: flex; gap: 0.4rem; background: var(--asphalt); border: 1px solid var(--line); border-radius: 10px; padding: 0.3rem; margin-bottom: 1.4rem; }
.tab { flex: 1; background: none; border: none; color: var(--muted); font-family: var(--disp); font-weight: 600; font-size: 0.92rem; padding: 0.55rem; border-radius: 7px; cursor: pointer; }
.tab.is-active { background: var(--surface-2); color: var(--ink); }
.modal-title { font-size: 1.35rem; margin-bottom: 1.2rem; }

.form { display: flex; flex-direction: column; gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field span { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.field input {
  background: var(--asphalt); border: 1px solid var(--line-2); border-radius: 9px; padding: 0.7rem 0.85rem;
  color: var(--ink); font-family: var(--body); font-size: 1rem;
}
.field input:focus { outline: none; border-color: var(--amarela); box-shadow: 0 0 0 3px rgba(242, 194, 0, 0.15); }
.form-help { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.2rem; }
.form-error { background: rgba(255, 90, 77, 0.12); border: 1px solid rgba(255, 90, 77, 0.4); color: #ff8a80; border-radius: 9px; padding: 0.6rem 0.8rem; font-size: 0.88rem; margin: 0 0 1rem; }
.link-btn { background: none; border: none; color: var(--azul); font-family: var(--body); font-size: 0.88rem; cursor: pointer; padding: 0.2rem; align-self: center; }
.link-btn:hover { text-decoration: underline; }

/* drawer detalhe */
.drawer { position: fixed; inset: 0; z-index: 100; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(4, 6, 9, 0.78); backdrop-filter: blur(4px); }
.drawer-card {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--surface); border-left: 1px solid var(--line-2); padding: 2.2rem 2rem; overflow-y: auto;
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
}
.drawer-title { font-size: 1.5rem; margin-bottom: 0.3rem; }
.drawer-sub { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); margin-bottom: 1.6rem; }
.drawer-total { display: flex; gap: 2rem; padding: 1.2rem 1.4rem; background: var(--asphalt); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 1.6rem; }
.drawer-total .m-val { font-family: var(--mono); font-weight: 700; font-size: 1.8rem; }
.drawer-total .m-lab { font-size: 0.78rem; color: var(--muted); }
.pc-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.pc-table th { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-2); text-align: right; padding: 0.6rem 0.4rem; border-bottom: 1px solid var(--line-2); }
.pc-table th:first-child { text-align: left; }
.pc-table td { font-family: var(--mono); text-align: right; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); }
.pc-table td:first-child { text-align: left; font-weight: 700; color: var(--ink); }
.pc-dev-pos { color: var(--vermelho); }
.pc-dev-neg { color: var(--azul); }
.pc-missed { color: var(--vermelho); font-family: var(--mono); font-size: 0.75rem; }

/* toast */
.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink);
  padding: 0.8rem 1.3rem; border-radius: 10px; font-size: 0.9rem; z-index: 200;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* ================================ RESPONSIVO ================================ */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 2.4rem; padding-top: 2rem; }
  .instrument { order: -1; }
  .band { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .events { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}
@media (max-width: 560px) {
  .band { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .perf-row { grid-template-columns: 1fr auto; gap: 0.4rem 1rem; }
  .perf-date, .perf-cell:nth-child(n+3) { display: none; }
  .section { padding: 3.5rem 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto; transition: none !important; }
}

:focus-visible { outline: 2px solid var(--amarela); outline-offset: 2px; }
