/* Tema do portal: claro, fundo #E3E3E3, menu lateral um tom mais escuro. */
:root {
  --bg: #e3e3e3;
  --side: #d4d4d4;
  --side-hover: #c9c9c9;
  --surface: #fcfcfb;
  --surface-2: #f3f3f1;
  --line: #e4e3df;
  --grid: #ecebe7;
  --ink: #1b1e24;              /* texto do portal */
  --ink-2: #4b515c;
  --muted: #6f7682;            /* um tom mais escuro que o #848C98 do portal, para leitura */
  --accent: #2b6cd8;           /* azul dos destaques (botões, seleções, links, seletor de datas) */
  --accent-hover: #1f58b8;
  --accent-ink: #1d55ad;       /* links */
  --accent-soft: #e3edfb;      /* o rosa do portal fica só nos dados dos gráficos */
  --brand-1: #f2506d; --brand-2: #c42a8a; --brand-3: #9936e7;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-ink: #006300; --critical-ink: #a32626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 1px rgba(0,0,0,.03);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  font-size: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--side) 232px, var(--bg) 232px); }
.sidebar { background: var(--side); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--ink-2); font-size: 12px; }
/* Símbolo do portal (marca.png); se o arquivo não existir, aparece o degradê das cores do portal */
.brand-mark { width: 32px; height: 32px; flex: none; background: url(/static/marca.png) center / contain no-repeat; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a { color: var(--ink); text-decoration: none; padding: 9px 10px; border-radius: 7px; font-weight: 500; }
.sidebar nav a:hover { background: var(--side-hover); }
.sidebar nav a.active { background: var(--surface); box-shadow: var(--shadow); color: var(--accent-ink); font-weight: 600; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); padding: 16px 10px 6px; }
.me { border-top: 1px solid rgba(0,0,0,.08); padding: 12px 8px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { min-width: 0; padding: 18px 24px 40px; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; flex: 1; }
.menu-btn { display: none; }
.update { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.update .quando b { font-weight: 600; color: var(--ink); }
.update .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; margin-right: 6px; }
.update .dot.err { background: var(--critical); }
.update .dot.run { background: var(--warning); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- filtros ---------- */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.filters-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.filters:empty { display: none; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
input, select, button, textarea { font: inherit; color: inherit; }
input[type=text], input[type=date], input[type=email], input[type=password], input[type=number], select {
  background: var(--surface); border: 1px solid #cfcdc7; border-radius: 7px; padding: 7px 9px; min-height: 36px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid #cfcdc7; background: var(--surface); border-radius: 999px; padding: 6px 11px; cursor: pointer; font-size: 13px; }
.chip[aria-pressed=true] { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid #cfcdc7; border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 11px; cursor: pointer; font-size: 13px; }
.seg button + button { border-left: 1px solid #cfcdc7; }
.seg button[aria-pressed=true] { background: var(--accent); color: #fff; }
.btn { border: 1px solid #cfcdc7; background: var(--surface); border-radius: 7px; padding: 7px 12px; cursor: pointer; min-height: 36px; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { opacity: .55; cursor: default; }
button.link { background: none; border: 0; color: var(--accent-ink); cursor: pointer; padding: 0; }
.spacer { flex: 1; }

/* ---------- cards e grade ---------- */
.content { display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.g-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-2e { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card h2 { font-size: 15px; margin-bottom: 2px; }
.card .sub { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.kpi .label { color: var(--ink-2); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .delta { font-size: 12px; margin-top: 4px; color: var(--ink-2); }
.delta .up { color: var(--good-ink); font-weight: 600; }
.delta .down { color: var(--critical-ink); font-weight: 600; }

/* ---------- tabela ---------- */
.table-wrap { overflow: auto; max-height: 620px; border-radius: 8px; border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 9px; line-height: 1.35; white-space: nowrap; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--ink-2); font-size: 12px; cursor: pointer; user-select: none; white-space: nowrap; z-index: 1; }
th.num { text-align: right; }
th[aria-sort=ascending]::after { content: " ▲"; font-size: 9px; }
th[aria-sort=descending]::after { content: " ▼"; font-size: 9px; }
tbody tr:hover { background: #f6f6f3; }
td.nome { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }

/* ---------- status (cor + ícone + texto, nunca só cor) ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 2px; flex: none; }
.st-critical::before { background: var(--critical); }
.st-serious::before { background: var(--serious); transform: rotate(45deg); }
.st-warning::before { background: var(--warning); border-radius: 50%; }
.st-good::before { background: var(--good); border-radius: 50%; }
.st-none::before { background: #b9b7b0; border-radius: 50%; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); font-size: 12px; color: var(--ink-2); }
.diff { color: var(--critical-ink); font-weight: 600; }

/* ---------- comparação Excel x corrigido ---------- */
.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.compare .col { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.compare .col.main { border-color: var(--accent); }
.compare h3 { font-size: 13px; margin-bottom: 8px; display: flex; justify-content: space-between; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.note { font-size: 12px; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; line-height: 1.5; }
.alert { background: #fbe9e9; color: var(--critical-ink); border-radius: 8px; padding: 10px 12px; }
.ok-msg { background: #e6f5e6; color: var(--good-ink); border-radius: 8px; padding: 10px 12px; }

/* ---------- gráficos ---------- */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.chart .axis line, .chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: #cfcdc7; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.bar { height: 10px; width: 10px; border-radius: 2px; }
.tooltip { position: fixed; pointer-events: none; background: #1b1e24; color: #fff; border-radius: 7px; padding: 8px 10px; font-size: 12px; line-height: 1.5; opacity: 0; transition: opacity .08s; z-index: 50; max-width: 280px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.tooltip b { font-weight: 600; }
.tooltip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); border-radius: 14px; box-shadow: 0 2px 12px rgba(0,0,0,.06); padding: 28px; width: min(380px, 100%); display: grid; gap: 14px; }
.login-card .brand { padding: 0 0 6px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }

/* ---------- formulários admin ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid label { display: grid; gap: 5px; font-size: 13px; color: var(--ink-2); }
.form-grid small { color: var(--muted); font-size: 11px; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 6px; }
.checks label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
dialog { border: 0; border-radius: 12px; padding: 0; width: min(560px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.3); }
dialog form { padding: 22px; display: grid; gap: 14px; }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) { .g-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .seg { flex-wrap: wrap; }
  .seg button + button { border-left: 0; }
  .field, .field input[type=text] { min-width: 0 !important; max-width: 100%; }
  #skuInput { width: 100%; }
  html, body { overflow-x: hidden; }
  .menu-btn { display: inline-flex; border: 0; background: var(--surface); border-radius: 7px; padding: 6px 10px; font-size: 18px; cursor: pointer; }
  .main { padding: 14px 16px 32px; }
  .g-2e, .compare { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 19px; }
  .kpi .value { font-size: 22px; }
}

/* ---------- seletor de datas ---------- */
.dp { position: relative; }
.dp-field { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; min-width: 230px; padding: 7px 11px; background: var(--surface);
  border: 1px solid #cfcdc7; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--ink); text-align: left; }
.dp-field:hover { background: var(--surface-2); }
.dp-field.ativo { background: var(--accent); color: #fff; border-color: var(--accent); }
.dp-ico { width: 14px; height: 14px; border: 1.6px solid currentColor; border-radius: 3px; position: relative; flex: none; }
.dp-ico::before { content: ""; position: absolute; left: 0; right: 0; top: 3px; border-top: 1.6px solid currentColor; }
.dp-text { flex: 1; white-space: nowrap; }
.dp-caret { font-size: 11px; opacity: .7; }
.dp-pop { position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; width: 300px; background: var(--surface); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 14px; display: grid; gap: 10px; }
.dp-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dp-inputs label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.dp-inputs input { width: 100%; min-width: 0; }
.dp-head { display: flex; align-items: center; justify-content: space-between; }
.dp-nav { border: 0; background: var(--surface-2); width: 30px; height: 30px; border-radius: 7px; cursor: pointer; font-size: 18px; line-height: 1; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 0; }
.dp-day { border: 0; background: none; height: 34px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.dp-day:hover:not(:disabled) { background: var(--surface-2); }
.dp-day.fora { color: #b3b1ab; }
.dp-day.meio { background: var(--accent-soft); border-radius: 0; }
.dp-day.sel { background: var(--accent); color: #fff; }
.dp-day:disabled { color: #d0cec8; cursor: default; }
.dp-msg { margin: 0; font-size: 12px; color: var(--critical-ink); min-height: 0; }
.dp-msg:empty { display: none; }
.dp-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- botão de download ---------- */
.btn.download { margin: 2px 0 12px; }
.dl-ico { width: 12px; height: 12px; position: relative; flex: none; border-bottom: 2px solid currentColor; }
.dl-ico::before { content: ""; position: absolute; left: 5px; top: 0; height: 8px; border-left: 2px solid currentColor; }
.dl-ico::after { content: ""; position: absolute; left: 2px; top: 3px; width: 5px; height: 5px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }

/* ---------- destaques, alertas e etiquetas ---------- */
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lista { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.lista li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; min-width: 0; }
.lista li:last-child { border-bottom: 0; }
.lista a { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.lista a:hover { color: var(--accent-ink); text-decoration: underline; }
.lista b { font-weight: 600; margin-right: 4px; }
.lista span { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; flex: none; }
.g-3 > .card, .g-2 > .card { min-width: 0; overflow: hidden; }
.ver-mais { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 500; text-decoration: none; }
.tend { font-weight: 600; white-space: nowrap; }
.tend.up { color: var(--good-ink); }
.tend.down { color: var(--critical-ink); }
.tend.flat { color: var(--ink-2); }
.kpi .value .tend { font-size: 22px; }
.curva { font-weight: 600; }
.pill.warn { background: #fdf0e8; color: #a14a1d; }
th .help { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: #e2e1dc; color: var(--ink-2); font-size: 10px; margin-left: 3px; }
tr.clicavel { cursor: pointer; }
tr.clicavel:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 1100px) { .g-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .dp-pop { width: min(300px, calc(100vw - 32px)); } .dp-field { min-width: 0; width: 100%; } }
