/* [24/07/2026 - Alexandre Carvalho] Painel de RH Quality v2 — tema claro/escuro, paleta dataviz validada. */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --st-good: #0ca30c; --st-warn: #fab219; --st-serious: #ec835a; --st-crit: #d03b3b;
  --delta-good: #006300;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95;
  --card-shadow: 0 1px 2px rgba(11,11,11,.04), 0 4px 16px rgba(11,11,11,.05);
  --card-shadow-hover: 0 2px 4px rgba(11,11,11,.06), 0 10px 28px rgba(11,11,11,.09);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --baseline: #383835; --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --delta-good: #0ca30c;
    --seq-1: #10315c; --seq-2: #184f95; --seq-3: #256abf; --seq-4: #3987e5; --seq-5: #6da7ec; --seq-6: #9ec5f4;
    --card-shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
    --card-shadow-hover: 0 2px 4px rgba(0,0,0,.5), 0 10px 28px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --baseline: #383835; --border: rgba(255, 255, 255, 0.10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --delta-good: #0ca30c;
  --seq-1: #10315c; --seq-2: #184f95; --seq-3: #256abf; --seq-4: #3987e5; --seq-5: #6da7ec; --seq-6: #9ec5f4;
  --card-shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  --card-shadow-hover: 0 2px 4px rgba(0,0,0,.5), 0 10px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px;
}
button { font-family: inherit; }

/* ---------- Login (padrao visual CCS DataVision — sempre claro) ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(to bottom right, #0c1c3a, #11264a, #0a1733);
}
.login-card {
  background: #ffffff; border-radius: 16px; width: 100%; max-width: 448px;
  padding: 40px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); color-scheme: light;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 24px; }
.login-logo img { height: 80px; object-fit: contain; }
.login-card h1 { margin: 0; font-size: 30px; font-weight: 700; color: #1e293b; text-align: center; }
.login-sub { margin: 4px 0 28px; font-size: 14px; color: #64748b; text-align: center; }
.login-card label { display: block; margin-bottom: 16px; }
.login-card label span { display: block; font-size: 14px; font-weight: 600; color: #334155; }
.login-card input {
  margin-top: 6px; width: 100%; border-radius: 8px; border: 1px solid #cbd5e1;
  background: #ffffff; color: #1e293b; padding: 12px 16px; font-size: 15px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px #bfdbfe; }
#loginBtn {
  width: 100%; border: 0; border-radius: 8px; background: #2563eb; color: #ffffff;
  font-weight: 600; font-size: 15px; padding: 12px; cursor: pointer; transition: background .15s; margin-top: 4px;
}
#loginBtn:hover { background: #1d4ed8; }
#loginBtn:disabled { opacity: .6; cursor: wait; }
.login-esqueci { text-align: center; margin-top: 16px; }
.login-esqueci button { border: 0; background: none; font-size: 14px; color: #2563eb; cursor: pointer; padding: 0; }
.login-esqueci button:hover { color: #1d4ed8; text-decoration: underline; }
.login-erro { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; font-size: 14px; border-radius: 8px; padding: 10px; margin-bottom: 16px; }
.login-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; font-size: 14px; border-radius: 8px; padding: 10px; margin-bottom: 16px; }

/* ---------- Layout com menu lateral ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 18px 12px 14px; gap: 20px; z-index: 30;
}
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 2px 0 8px; }
.side-brand img { height: 38px; object-fit: contain; }
#btnMenu {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  padding: 6px; border-radius: 8px; display: flex;
}
#btnMenu:hover { background: color-mix(in srgb, var(--s1) 10%, transparent); color: var(--ink); }
#btnMenu svg { width: 18px; height: 18px; transition: transform .2s; }
.logo-escuro { display: none; }
:root[data-theme="dark"] .logo-claro { display: none; }
:root[data-theme="dark"] .logo-escuro { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-claro { display: none; }
  :root:not([data-theme="light"]) .logo-escuro { display: block; }
}
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px;
  text-decoration: none; color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.side-nav a:hover { background: color-mix(in srgb, var(--s1) 10%, transparent); color: var(--ink); }
.side-nav a.ativo { background: var(--s1); color: #fff; }
.side-nav .mi { width: 20px; display: flex; justify-content: center; opacity: .75; }
.side-nav .mi svg { width: 17px; height: 17px; }
.side-nav a.ativo .mi, .side-nav a:hover .mi { opacity: 1; }
.side-nav .ml { white-space: nowrap; }

/* ---------- Menu recolhido ---------- */
.sidebar { transition: width .2s ease; }
.sidebar.recolhida { width: 62px; padding-left: 8px; padding-right: 8px; }
.sidebar.recolhida .side-brand,
.sidebar.recolhida .ml,
.sidebar.recolhida .topo-user { display: none; }
.sidebar.recolhida .side-top { justify-content: center; padding: 0; }
.sidebar.recolhida #btnMenu svg { transform: rotate(180deg); }
.sidebar.recolhida .side-nav a { justify-content: center; padding: 10px 0; }
.sidebar.recolhida .side-foot { justify-content: center; padding-left: 0; padding-right: 0; }
.side-foot {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 8px 0; border-top: 1px solid var(--border);
}
.side-foot button {
  padding: 6px 12px; border: 1px solid var(--baseline); border-radius: 8px;
  background: var(--surface); color: var(--ink); cursor: pointer; font-size: 12.5px;
}
.side-foot button:hover { background: var(--page); }
.conteudo { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topo ---------- */
.topo {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 12px 22px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.topo h1 { margin: 0; font-size: 17px; }
.topo-cliente { color: var(--muted); font-weight: 400; }
.topo-sub { color: var(--muted); font-size: 11.5px; }
.topo-acoes { display: flex; align-items: center; gap: 8px; }
.topo-user { color: var(--ink-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.topo-acoes button {
  padding: 6px 11px; border: 1px solid var(--baseline); border-radius: 8px;
  background: var(--surface); color: var(--ink); cursor: pointer; font-size: 13px; transition: background .15s;
}
.topo-acoes button:hover { background: var(--page); }

/* ---------- Filtros ---------- */
.filtros {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 62px; z-index: 15;
}
.filtros-titulo { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.filtros select {
  padding: 6px 8px; border: 1px solid var(--baseline); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 12.5px; max-width: 190px;
}
.filtros select.ativo { border-color: var(--s1); box-shadow: 0 0 0 1px var(--s1); }
.btn-ghost {
  padding: 6px 10px; border: 1px solid var(--baseline); border-radius: 8px;
  background: none; color: var(--ink-2); cursor: pointer; font-size: 12.5px;
}
.btn-ghost:hover { background: var(--page); }
.visoes { margin-left: auto; display: flex; gap: 8px; }
.visoes select { max-width: 160px; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  padding: 10px 22px 0; font-size: 13px; color: var(--muted);
  display: flex; gap: 6px; align-items: center;
}
.breadcrumb a { color: var(--s1); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
main { padding: 16px 22px 48px; max-width: 1560px; margin: 0 auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 13px 15px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--card-shadow); transition: box-shadow .2s, transform .2s;
  animation: fadeUp .35s ease both; position: relative;
}
.tile:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-1px); }
.tile .t-label { color: var(--ink-2); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.tile .t-value { font-size: 24px; font-weight: 650; line-height: 1.25; }
.tile .t-delta { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.tile .up { color: var(--delta-good); font-weight: 600; }
.tile .down { color: var(--st-crit); font-weight: 600; }
.tile.alerta .t-value { color: var(--st-crit); }
.tile .spark { position: absolute; right: 12px; bottom: 10px; opacity: .9; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; overflow: hidden; box-shadow: var(--card-shadow);
  transition: box-shadow .2s; animation: fadeUp .4s ease both; position: relative;
}
.card:hover { box-shadow: var(--card-shadow-hover); }
.card-wide { grid-column: span 2; }
.card-full { grid-column: 1 / -1; }
@media (max-width: 980px) { .card-wide { grid-column: span 1; } }
.card h2 { margin: 0 0 10px; font-size: 15px; padding-right: 56px; }
.card-sub { color: var(--muted); font-weight: 400; font-size: 12px; }
.card-acoes { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; }
.card-acoes button {
  width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--muted); cursor: pointer; font-size: 12px; line-height: 1;
}
.card-acoes button:hover { color: var(--ink); border-color: var(--baseline); }
.card.fullscreen {
  position: fixed; inset: 24px; z-index: 60; overflow: auto; box-shadow: 0 24px 80px rgba(0,0,0,.4);
}
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.clicavel { cursor: pointer; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* legenda */
.legend { display: flex; gap: 16px; margin: 2px 0 8px; flex-wrap: wrap; }
.legend .li { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12.5px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- Alertas / insights ---------- */
.alertas { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; margin-bottom: 14px; }
.alerta-card {
  border-radius: 12px; padding: 11px 14px; font-size: 13px; display: flex; gap: 9px; align-items: flex-start;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--card-shadow);
  animation: fadeUp .4s ease both;
}
.alerta-card .ico { font-size: 15px; margin-top: 1px; }
.alerta-card.crit { border-left: 4px solid var(--st-crit); }
.alerta-card.warn { border-left: 4px solid var(--st-warn); }
.insights { margin-bottom: 14px; }
.insights .card { padding: 14px 18px; }
.insights ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; line-height: 1.75; }
.insights .tag {
  font-size: 11px; font-weight: 700; letter-spacing: .05em; color: var(--s1);
  text-transform: uppercase;
}

/* ---------- Tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--grid); position: sticky; top: 0; background: var(--surface); }
td { padding: 6px 8px; border-bottom: 1px solid var(--grid); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr.clicavel:hover td { background: color-mix(in srgb, var(--s1) 7%, transparent); }
.scroll { max-height: 420px; overflow-y: auto; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--border); }
.chip.crit { color: var(--st-crit); border-color: var(--st-crit); }
.chip.warn { color: #8a6100; border-color: var(--st-warn); }
.chip.good { color: var(--delta-good); border-color: var(--st-good); }

/* ---------- Controles de Eventos ---------- */
.ev-controles { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ev-controles input, .ev-controles select {
  padding: 8px 10px; border: 1px solid var(--baseline); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 13px;
}
.ev-controles input { width: 180px; }
.ev-controles #evSel { max-width: 380px; }
.ev-controles label { display: flex; gap: 6px; align-items: center; color: var(--ink-2); font-size: 13px; }

/* ---------- Heatmap ---------- */
.heat-legend { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.heat-legend .step { width: 22px; height: 10px; border-radius: 2px; }

/* ---------- Ficha ---------- */
.ficha-head { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.ficha-avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--s1); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700;
}
.ficha-head h2 { margin: 0; font-size: 20px; }
.ficha-meta { color: var(--ink-2); font-size: 13px; }

/* ---------- Busca global ---------- */
.busca-global { position: relative; flex: 1; max-width: 360px; }
.busca-global input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--baseline); border-radius: 9px;
  background: var(--page); color: var(--ink); font-size: 13px;
}
.busca-global input:focus { outline: none; border-color: var(--s1); box-shadow: 0 0 0 1px var(--s1); }
.busca-res {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 70;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .3); max-height: 380px; overflow-y: auto;
}
.busca-res .br-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--grid); }
.busca-res .br-item:last-child { border-bottom: 0; }
.busca-res .br-item:hover { background: color-mix(in srgb, var(--s1) 10%, transparent); }
.busca-res .br-nome { font-weight: 600; font-size: 13px; }
.busca-res .br-info { color: var(--muted); font-size: 11.5px; }
.busca-res .br-vazio { padding: 10px 12px; color: var(--muted); font-size: 12.5px; }

/* ---------- Tabela analitica ---------- */
.ta-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.ta-toolbar input {
  padding: 7px 10px; border: 1px solid var(--baseline); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 13px; width: 230px;
}
.ta-conta { color: var(--muted); font-size: 12.5px; }
.ta-scroll { max-height: 560px; overflow: auto; border: 1px solid var(--grid); border-radius: 10px; }
.ta-scroll table { font-size: 12.5px; }
.ta-scroll th { cursor: pointer; user-select: none; white-space: nowrap; }
.ta-scroll th:hover { color: var(--ink); }
.ta-scroll th .seta { font-size: 10px; margin-left: 3px; }
.ta-scroll td { white-space: nowrap; }
.ta-totais td { font-weight: 700; border-top: 2px solid var(--baseline); position: sticky; bottom: 0; background: var(--surface); }

/* ---------- Sobre o indicador ---------- */
.sobre { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.sobre .s-item .s-k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.sobre .s-item .s-v { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }

/* ---------- Cabecalho de impressao (PDF executivo) ---------- */
.print-head { display: none; }
@media print {
  .print-head {
    display: block; padding: 10px 22px 14px; border-bottom: 2px solid #333; margin-bottom: 12px;
  }
  .print-head .ph-t { font-size: 20px; font-weight: 700; }
  .print-head .ph-s { font-size: 12px; color: #444; margin-top: 3px; }
}

/* ---------- Tooltip / toast ---------- */
.tooltip {
  position: fixed; z-index: 80; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 12.5px; color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18); max-width: 280px;
}
.tooltip .tt-t { color: var(--muted); margin-bottom: 2px; }
.tooltip .tt-v { font-weight: 600; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: var(--ink); color: var(--page); border-radius: 10px; padding: 9px 16px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

/* ---------- Skeleton ---------- */
.skeleton { display: grid; gap: 12px; }
.skeleton .sk {
  height: 120px; border-radius: 14px; background: linear-gradient(100deg, var(--surface) 40%, color-mix(in srgb, var(--ink) 4%, var(--surface)) 50%, var(--surface) 60%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Print ---------- */
@media print {
  .topo-acoes, .filtros, .card-acoes, .sidebar { display: none !important; }
  .topo { position: static; }
  body { background: #fff; }
  .card, .tile { box-shadow: none; break-inside: avoid; }
}
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row; align-items: center;
    padding: 10px 14px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .side-brand img { height: 30px; }
  .side-top { padding: 0; }
  #btnMenu { display: none; }
  .sidebar.recolhida { width: 100%; }
  .sidebar.recolhida .side-brand, .sidebar.recolhida .ml { display: block; }
  .side-nav { flex-direction: row; overflow-x: auto; flex: 1; }
  .side-nav a { padding: 7px 10px; white-space: nowrap; }
  .side-nav .mi { width: auto; }
  .side-foot { margin-top: 0; border-top: 0; padding: 0; }
  .grid { grid-template-columns: 1fr; }
  .visoes { margin-left: 0; }
  .filtros { top: auto; position: static; }
}
