/* ====================================================================
   IDENTIDADE VISUAL — Painel de Vendas
   Fundo petróleo profundo, cards mais claros, bordas sutis, raio 14px.
   Paleta de indicadores: apenas CIANO (#16D6E8) e BRANCO (#FFFFFF).
   Cor sólida da marca (#018997) nos botões primários.
   ==================================================================== */
:root {
  --bg: #06181c;              /* petróleo profundo */
  --bg-2: #0a2126;            /* fundo secundário */
  --card: #0e2a30;            /* cards levemente mais claros */
  --card-2: #123840;          /* card interno / hover */
  --border: #1c454d;          /* bordas sutis */
  --border-soft: #163a41;
  --text: #eaf6f7;            /* texto principal */
  --text-dim: #8fb3b8;        /* texto secundário */
  --text-faint: #5f8a90;      /* texto discreto */
  --cyan: #16d6e8;            /* ciano vivo (indicadores) */
  --white: #ffffff;           /* branco (indicadores) */
  --brand: #018997;           /* cor sólida da marca (botões) */
  --brand-hi: #02a3b4;
  --radius: 14px;
  --gap: 18px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.num, .mono {
  font-family: "IBM Plex Mono", "Consolas", ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--text-dim);
  margin: 0 0 12px;
}

h1, h2, h3 { font-weight: 700; margin: 0; }

button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .1s var(--ease);
}
button:hover { background: var(--card-2); border-color: var(--brand); }
button:active { transform: translateY(1px); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-hi); border-color: var(--brand-hi); }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }

button:focus-visible,
select:focus-visible,
input:focus-visible,
th[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

select, input[type="number"], input[type="date"], input[type="text"], input[type="password"] {
  font-family: inherit;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
}
input.num-field {
  font-family: "IBM Plex Mono", "Consolas", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.app { max-width: 1180px; margin: 0 auto; padding: 20px 20px 60px; }

/* ============================ CABEÇALHO ============================ */
header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 22px;
}
.brand-wrap { display: flex; align-items: center; gap: 14px; min-height: 40px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 16px; height: 16px; }
.brand-sep { width: 1px; height: 28px; background: var(--border); }
.brand-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-field { display: flex; align-items: center; gap: 7px; }
.date-field label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-faint); }

/* ====================== PAINÉIS RECOLHÍVEIS ====================== */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 22px;
  overflow: hidden;
}
.panel > .panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; cursor: pointer; user-select: none;
}
.panel > .panel-head h2 { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-dim); }
.panel > .panel-head .chev { transition: transform .2s var(--ease); color: var(--text-faint); }
.panel.collapsed > .panel-head .chev { transform: rotate(-90deg); }
.panel > .panel-body { padding: 4px 16px 18px; }
.panel.collapsed > .panel-body { display: none; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); }
.field .hint { font-size: 11px; color: var(--text-faint); }

/* ============================ GRID GERAL ============================ */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.block { margin-bottom: 26px; }

/* ======================== MEDIDORES EM ARCO ======================== */
.gauge { display: flex; flex-direction: column; align-items: center; text-align: center; }
.gauge svg { width: 100%; max-width: 260px; height: auto; overflow: visible; }
.gauge .track { stroke: rgba(255,255,255,.09); }
.gauge .value-arc { transition: stroke-dashoffset 1s var(--ease); stroke-linecap: round; }

.gauge.white .value-arc { stroke: var(--white); animation: glowWhite 2.4s ease-in-out infinite; }
.gauge.white .center-num { fill: var(--white); animation: glowTextWhite 2.4s ease-in-out infinite; }
.gauge.cyan .value-arc { stroke: var(--cyan); animation: glowCyan 2.4s ease-in-out infinite; }
.gauge.cyan .center-num { fill: var(--cyan); animation: glowTextCyan 2.4s ease-in-out infinite; }

.gauge .center-num {
  font-family: "IBM Plex Mono", "Consolas", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 30px;
}
.gauge .caption { font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em; color: var(--text-dim); margin-top: 10px; }
.gauge .pill {
  margin-top: 9px;
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
}
.gauge .pill.good { border-color: var(--cyan); color: var(--cyan); }
.gauge .ritmo-marker { stroke: var(--cyan); stroke-width: 3; }

@keyframes glowWhite {
  0%,100% { filter: drop-shadow(0 0 2px rgba(255,255,255,.35)); }
  50%     { filter: drop-shadow(0 0 9px rgba(255,255,255,.9)); }
}
@keyframes glowTextWhite {
  0%,100% { filter: drop-shadow(0 0 1px rgba(255,255,255,.3)); }
  50%     { filter: drop-shadow(0 0 6px rgba(255,255,255,.75)); }
}
@keyframes glowCyan {
  0%,100% { filter: drop-shadow(0 0 2px rgba(22,214,232,.35)); }
  50%     { filter: drop-shadow(0 0 10px rgba(22,214,232,.95)); }
}
@keyframes glowTextCyan {
  0%,100% { filter: drop-shadow(0 0 1px rgba(22,214,232,.3)); }
  50%     { filter: drop-shadow(0 0 6px rgba(22,214,232,.8)); }
}

/* ============================= PÓDIOS ============================= */
.podiums { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.podium h3 { font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em; color: var(--text-dim); margin-bottom: 14px; }
.podium-row { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-top: 1px solid var(--border-soft); }
.podium-row:first-of-type { border-top: none; }
.podium-row .who { flex: 1; min-width: 0; }
.podium-row .who .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium-row.me .name { color: var(--cyan); }
.podium-row .metric { font-family: "IBM Plex Mono", "Consolas", ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-dim); }

.medal {
  flex-shrink: 0;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-family: "IBM Plex Mono", "Consolas", ui-monospace, monospace;
  font-size: 12px; font-weight: 600;
  line-height: 1;
}
.medal.m1 { background: var(--cyan); color: #06181c; box-shadow: 0 0 0 0 rgba(22,214,232,.6); animation: ringPulse 2.4s ease-in-out infinite; }
.medal.m2 { background: var(--white); color: #06181c; }
.medal.m3 { background: transparent; color: var(--white); border: 1.5px solid var(--white); }
.medal.mx { background: transparent; color: var(--text-faint); border: 1px solid var(--border); }
@keyframes ringPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(22,214,232,.55); }
  50%     { box-shadow: 0 0 0 7px rgba(22,214,232,0); }
}
.medal-sm { width: 24px; height: 24px; font-size: 10.5px; }

/* ===================== GRÁFICO DIA A DIA ===================== */
.daily-wrap { position: relative; }
.daily-chart {
  display: flex; align-items: flex-end; gap: 10px;
  height: 240px; padding: 26px 6px 4px;
  position: relative;
  overflow-x: auto;
}
.daily-100 {
  position: absolute; left: 0; right: 0;
  border-top: 1px dashed rgba(255,255,255,.35);
  pointer-events: none;
}
.daily-100 span {
  position: absolute; right: 4px; top: -16px;
  font-size: 10px; font-family: "IBM Plex Mono", "Consolas", ui-monospace, monospace; color: var(--text-faint);
}
.day-col {
  flex: 1; min-width: 26px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  height: 100%;
  position: relative;
  cursor: pointer;
}
.day-bar {
  width: 100%;
  max-width: 46px;
  border-radius: 6px 6px 3px 3px;
  transition: height 1s var(--ease);
  position: relative;
}
.day-bar.hit { background: var(--cyan); box-shadow: 0 0 10px rgba(22,214,232,.55); }
.day-bar.miss { background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.35); }
.day-col.selected .day-bar { outline: 2px solid var(--cyan); outline-offset: 2px; animation: dayPulse 1.8s ease-in-out infinite; }
@keyframes dayPulse {
  0%,100% { outline-color: rgba(22,214,232,1); }
  50%     { outline-color: rgba(22,214,232,.25); }
}
.day-pct {
  position: absolute; top: -20px;
  font-family: "IBM Plex Mono", "Consolas", ui-monospace, monospace; font-size: 10.5px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.day-pct.hit { color: var(--cyan); }
.day-pct.miss { color: rgba(255,255,255,.7); }
.day-num { margin-top: 7px; font-family: "IBM Plex Mono", "Consolas", ui-monospace, monospace; font-size: 11px; color: var(--text-faint); }

.chart-tooltip {
  position: fixed;
  z-index: 60;
  background: #04262c;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
  white-space: nowrap;
}
.chart-tooltip .num { color: var(--cyan); }

/* ======================== TABELA RANKING ======================== */
.rank-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.rank { width: 100%; border-collapse: collapse; min-width: 620px; }
table.rank th, table.rank td { padding: 12px 14px; text-align: left; }
table.rank thead th {
  font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--text-dim);
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  cursor: pointer; white-space: nowrap; user-select: none;
}
table.rank thead th .sort-caret { color: var(--cyan); font-size: 9px; margin-left: 4px; }
table.rank tbody tr { border-bottom: 1px solid var(--border-soft); }
table.rank tbody tr:last-child { border-bottom: none; }
table.rank tbody tr:hover { background: rgba(255,255,255,.02); }
table.rank tbody tr.me { background: rgba(22,214,232,.06); }
.cell-name { font-weight: 600; }
.cell-name.me { color: var(--cyan); }
.prop-bar { margin-top: 6px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.08); overflow: hidden; max-width: 180px; }
.prop-bar > i { display: block; height: 100%; background: var(--cyan); border-radius: 2px; transition: width 1s var(--ease); }
.cell-metric { display: flex; align-items: center; gap: 9px; }
.cell-metric .val { font-family: "IBM Plex Mono", "Consolas", ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 13px; }
.cell-metric .frac { font-family: "IBM Plex Mono", "Consolas", ui-monospace, monospace; font-size: 11px; color: var(--text-faint); display: block; }

/* ============================ RODAPÉ ============================ */
footer.foot {
  margin-top: 30px; padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px; color: var(--text-faint);
  display: flex; gap: 18px; flex-wrap: wrap;
}
footer.foot .num { color: var(--text-dim); }

/* ============================ ESTADO VAZIO ============================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
}
.empty-state h2 { font-size: 18px; color: var(--text); margin-bottom: 8px; }
.empty-state p { max-width: 440px; margin: 6px auto; font-size: 13.5px; }
.empty-state .cta { margin-top: 18px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
[hidden] { display: none !important; }

/* ============================ CALENDÁRIO DE METAS ============================ */
.calendar-header {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 10px;
}
.calendar-mes { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; min-width: 160px; text-align: center; }
.calendar-header button { padding: 6px 12px; font-size: 15px; }
.calendar-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 10.5px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px;
}
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-day {
  aspect-ratio: 1 / 1;
  min-height: 52px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  padding: 4px;
}
.calendar-day:hover { border-color: var(--brand); }
.calendar-day.vazio { visibility: hidden; cursor: default; }
.calendar-day .num-dia { font-size: 12px; color: var(--text-dim); }
.calendar-day .meta-dia { font-family: "IBM Plex Mono", "Consolas", ui-monospace, monospace; font-size: 11px; font-weight: 600; }
.calendar-day.tem-meta { border-color: var(--border-soft); background: var(--card-2); }
.calendar-day.tem-valor.bateu { border-color: var(--cyan); }
.calendar-day.tem-valor.bateu .meta-dia { color: var(--cyan); }
.calendar-day.tem-valor.nao-bateu { border-color: rgba(255,255,255,.4); }
.calendar-day.hoje { outline: 2px solid var(--cyan); outline-offset: 1px; }

.day-popover {
  position: fixed;
  z-index: 90;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  width: 260px;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.day-popover h3 { font-size: 13px; margin-bottom: 12px; }
.day-popover .field { margin-bottom: 10px; }
.day-popover .field input { width: 100%; }
.day-popover .modal-actions { margin-top: 4px; }

/* ============================ MODAL MAPEAMENTO ============================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(2, 12, 14, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  padding: 22px;
}
.modal h2 { font-size: 15px; margin-bottom: 4px; }
.modal p.sub { font-size: 12.5px; color: var(--text-dim); margin: 0 0 16px; }
.map-row { display: grid; grid-template-columns: 1fr 1.2fr; gap: 10px; align-items: center; margin-bottom: 10px; }
.map-row label { font-size: 12.5px; }
.map-row label .req { color: var(--cyan); }
.map-row select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

/* ============================ TOASTS ============================ */
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: #04262c;
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: 9px;
  padding: 11px 15px;
  font-size: 13px;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: toastIn .25s var(--ease);
}
.toast.err { border-left-color: var(--white); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================ LOGIN ============================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
}
.login-card .brand-wrap { justify-content: center; margin-bottom: 22px; }
.login-card h1 { font-size: 15px; text-align: center; letter-spacing: .12em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 22px; }
.login-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.login-field label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); }
.login-field input { width: 100%; padding: 10px 12px; }
.login-erro { color: var(--white); background: rgba(255,255,255,.08); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px; }
.login-card button[type="submit"] { width: 100%; padding: 11px; margin-top: 6px; }

/* ============================ RESPONSIVO ============================ */
@media (max-width: 860px) {
  .grid-3, .podiums { grid-template-columns: 1fr; }
  header.top { align-items: flex-start; }
}
@media (max-width: 560px) {
  .app { padding: 14px 12px 48px; }
  .day-num { display: none; }
  .day-pct { display: none; }
  .gauge .center-num { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
