/* ============================================================================
   Orelhão 2.0 — Design System do painel (tema CLARO, estilo referência admin)
   Estrutura: sidebar fixa à esquerda + topbar + conteúdo em cards brancos.
   Accent da marca: vermelho #dc2626 · status: verde/âmbar/vermelho/azul.
   As views usam as classes .oe-* — mudar aqui re-estiliza o painel inteiro.
   ========================================================================== */

:root {
  --oe-brand: #dc2626;             /* vermelho Orelhão 2.0 (referência) */
  --oe-brand-hover: #b91c1c;
  --oe-brand-soft: #fee2e2;
  --oe-bg: #f8fafc;                /* fundo geral (cinza-azulado clarís.) */
  --oe-surface: #ffffff;           /* cards */
  --oe-surface-2: #f1f5f9;         /* hover/inputs */
  --oe-border: #e2e8f0;
  --oe-text: #0f172a;              /* slate-900 */
  --oe-text-muted: #64748b;        /* slate-500 */
  --oe-ok: #16a34a;   --oe-ok-soft: #dcfce7;
  --oe-warn: #d97706; --oe-warn-soft: #fef3c7;
  --oe-err: #dc2626;  --oe-err-soft: #fee2e2;
  --oe-info: #2563eb; --oe-info-soft: #dbeafe;
  --oe-radius: 12px;
  --oe-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --oe-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --oe-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --oe-sidebar-w: 232px;
}

/* ---------- Base clara (sobrepõe o Pico dark/claro) ---------- */
html { background: var(--oe-bg); }
body {
  font-family: var(--oe-font);
  background: var(--oe-bg) !important;
  color: var(--oe-text) !important;
  font-size: 15px;
}
:where(h1,h2,h3,h4) { color: var(--oe-text); font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: 1.7rem; margin-bottom: .15rem; }
h2 { font-size: 1.1rem; }
a { color: var(--oe-info); }
small, .muted { color: var(--oe-text-muted); }

/* ---------- Estrutura: sidebar + área principal ---------- */
.oe-shell { display: flex; min-height: 100dvh; }

.oe-sidebar {
  width: var(--oe-sidebar-w); flex: 0 0 var(--oe-sidebar-w);
  background: var(--oe-surface);
  border-right: 1px solid var(--oe-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh;
}
.oe-sidebar .brand {
  font-weight: 800; font-size: 1.15rem; color: var(--oe-text); text-decoration: none;
  padding: 1.05rem 1.2rem .9rem;
}
.oe-sidebar .brand em { color: var(--oe-brand); font-style: normal; }
.oe-sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .6rem; }
.oe-sidebar nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .7rem; border-radius: 9px;
  color: var(--oe-text-muted); text-decoration: none; font-size: .92rem; font-weight: 550;
  border-left: 3px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.oe-sidebar nav a svg { width: 18px; height: 18px; flex: 0 0 18px; }
.oe-sidebar nav a:hover { background: var(--oe-surface-2); color: var(--oe-text); }
.oe-sidebar nav a.active {
  color: var(--oe-text); background: var(--oe-surface-2);
  border-left-color: var(--oe-brand); font-weight: 650;
}
.oe-sidebar .side-footer {
  margin-top: auto; padding: .9rem 1.2rem;
  border-top: 1px solid var(--oe-border);
  font-size: .78rem; color: var(--oe-text-muted);
}

.oe-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.oe-topbar {
  background: var(--oe-surface); border-bottom: 1px solid var(--oe-border);
  padding: .6rem 1.4rem;
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 100;
}
.oe-topbar .spacer { flex: 1; }
.oe-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--oe-brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; letter-spacing: .02em;
}
.oe-userbox { display: flex; align-items: center; gap: .6rem; }
.oe-userbox .who { line-height: 1.15; }
.oe-userbox .who b { font-size: .85rem; display: block; }
.oe-userbox .who small { font-size: .72rem; }
.oe-topbar form { margin: 0; }

/* ---------- Conteúdo ---------- */
.oe-content { padding: 1.4rem 1.6rem 2.2rem; max-width: 1320px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head small { font-size: .92rem; }

/* ---------- Cards / KPI (estilo referência) ---------- */
.oe-grid { display: grid; gap: 1rem; }
.oe-grid.kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.oe-grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .oe-grid.two { grid-template-columns: 1fr; } }

.oe-card {
  background: var(--oe-surface);
  border: 1px solid var(--oe-border);
  border-radius: var(--oe-radius);
  box-shadow: var(--oe-shadow);
  padding: 1.15rem 1.25rem;
}
.oe-card h3 {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--oe-text-muted); margin: 0 0 .55rem; font-weight: 650;
}
.oe-kpi {
  font-size: 2.15rem; font-weight: 800; line-height: 1.05; margin: 0 0 .35rem;
  font-variant-numeric: tabular-nums; color: var(--oe-text);
}
.oe-kpi small { font-size: .95rem; font-weight: 550; margin-left: .25rem; }
.oe-kpi.ok { color: var(--oe-ok); } .oe-kpi.warn { color: var(--oe-warn); } .oe-kpi.brand { color: var(--oe-brand); }

/* pill de variação/nota sob o KPI (ex.: +3,2% vs. semana anterior) */
.oe-delta { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 650;
  padding: .12rem .5rem; border-radius: 999px; }
.oe-delta.up { color: var(--oe-ok); background: var(--oe-ok-soft); }
.oe-delta.down { color: var(--oe-err); background: var(--oe-err-soft); }

/* ---------- Tabelas ---------- */
table { font-size: .9rem; background: transparent; }
table th { color: var(--oe-text-muted); font-weight: 650; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
table td { font-variant-numeric: tabular-nums; }
table tbody tr { transition: background .12s ease; }
table tbody tr:hover { background: var(--oe-surface-2); }
:where(table) tbody td, :where(table) thead th { background: transparent !important; color: inherit !important; }

/* ---------- Badges de status (pill com bolinha) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .74rem; font-weight: 650; padding: .16rem .6rem; border-radius: 999px;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok    { color: var(--oe-ok);   background: var(--oe-ok-soft); }
.badge.warn  { color: var(--oe-warn); background: var(--oe-warn-soft); }
.badge.err   { color: var(--oe-err);  background: var(--oe-err-soft); }
.badge.info  { color: var(--oe-info); background: var(--oe-info-soft); }
.badge.muted { color: var(--oe-text-muted); background: var(--oe-surface-2); }

/* ---------- Botões ---------- */
button, [role=button], input[type=submit] {
  border-radius: 9px; font-weight: 650; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
button.primary, .btn-brand {
  background: var(--oe-brand) !important; border-color: var(--oe-brand) !important; color: #fff !important;
}
button.primary:hover, .btn-brand:hover { background: var(--oe-brand-hover) !important; border-color: var(--oe-brand-hover) !important; }
button.slim { padding: .32rem .75rem; font-size: .82rem; width: auto; margin: 0; }
button.ghost, a.ghost[role=button] {
  background: var(--oe-surface) !important; border: 1px solid var(--oe-border) !important; color: var(--oe-text) !important;
}
button.ghost:hover, a.ghost[role=button]:hover { background: var(--oe-surface-2) !important; }
button.danger { background: var(--oe-surface) !important; border: 1px solid #fca5a5 !important; color: var(--oe-err) !important; }
button.danger:hover { background: var(--oe-err-soft) !important; }
form.inline { display: inline; margin: 0; }

/* ---------- Formulários ---------- */
input, select, textarea {
  background: var(--oe-surface) !important;
  border: 1px solid var(--oe-border) !important;
  color: var(--oe-text) !important;
  border-radius: 9px !important;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--oe-brand) !important;
  box-shadow: 0 0 0 3px var(--oe-brand-soft) !important;
}
label { font-size: .84rem; font-weight: 600; color: var(--oe-text); }
fieldset { border: 1px solid var(--oe-border); border-radius: var(--oe-radius); padding: 1.1rem; margin-bottom: 1rem; background: var(--oe-surface); }
legend { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--oe-text-muted); padding: 0 .5rem; }

/* ---------- Flash ---------- */
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 550; border: 1px solid; }
.flash.success { background: var(--oe-ok-soft); border-color: #86efac; color: #166534; }
.flash.error   { background: var(--oe-err-soft); border-color: #fca5a5; color: #991b1b; }
.flash.info    { background: var(--oe-info-soft); border-color: #93c5fd; color: #1e40af; }

/* ---------- Banner de impersonation (mantém alto contraste) ---------- */
.oe-impersonation {
  background: repeating-linear-gradient(45deg, #7c2d12, #7c2d12 12px, #9a3412 12px, #9a3412 24px);
  color: #fff; padding: .55rem 1.4rem; display: flex; align-items: center; gap: 1rem;
  font-weight: 600; position: sticky; top: 0; z-index: 1000;
}
.oe-impersonation button { margin: 0; padding: .25rem .8rem; font-size: .85rem; width: auto;
  background: #fff !important; color: #7c2d12 !important; border: 0 !important; }

/* ---------- Login (tema claro) ---------- */
.oe-login { max-width: 430px; margin: 9vh auto; padding: 0 1rem; }
.oe-login .oe-card { padding: 2rem; }
.oe-login .brand { font-weight: 800; font-size: 1.5rem; text-align: center; display: block; margin-bottom: 1.3rem; color: var(--oe-text); text-decoration: none; }
.oe-login .brand em { color: var(--oe-brand); font-style: normal; }

/* ---------- Gráficos ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }

/* ---------- Segredos exibidos uma vez ---------- */
.oe-secret {
  font-family: var(--oe-mono); font-size: .8rem; word-break: break-all;
  background: #fff7ed; border: 1px dashed var(--oe-brand); border-radius: 10px; padding: .85rem;
  color: #7c2d12;
}

/* ---------- Utilidades ---------- */
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.actions-cell { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ---------- Central de Ajuda ---------- */
.help-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.2rem; align-items: start; }
.help-toc {
  position: sticky; top: 4rem;
  background: var(--oe-surface); border: 1px solid var(--oe-border);
  border-radius: var(--oe-radius); box-shadow: var(--oe-shadow);
  padding: .9rem; max-height: calc(100dvh - 6rem); overflow-y: auto;
}
.help-toc input[type=search] { margin-bottom: .8rem; }
.help-toc-section { margin-bottom: 1rem; }
.help-toc-section h4 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--oe-text-muted); margin: 0 0 .35rem; font-weight: 700;
}
.help-toc-section ul { list-style: none; margin: 0; padding: 0; }
.help-toc-section li { margin: 0; }
.help-toc-section a {
  display: block; padding: .38rem .55rem; border-radius: 8px;
  color: var(--oe-text); text-decoration: none; font-size: .9rem;
  border-left: 3px solid transparent;
}
.help-toc-section a:hover { background: var(--oe-surface-2); }
.help-toc-section a.active {
  background: var(--oe-brand-soft); border-left-color: var(--oe-brand);
  color: var(--oe-brand); font-weight: 650;
}
.help-empty { padding: .5rem; font-size: .85rem; }

.help-article { padding: 1.6rem 1.9rem; max-width: 820px; }
.help-crumb { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .2rem; }
.help-article h2 { font-size: 1.6rem; margin: 0 0 1rem; }
.help-body { font-size: 1rem; line-height: 1.7; color: #1f2937; }
.help-body h3 { font-size: 1.15rem; margin: 1.6rem 0 .5rem; }
.help-body p { margin: 0 0 .9rem; }
.help-body ul, .help-body ol { margin: 0 0 1rem; padding-left: 1.4rem; }
.help-body li { margin: .3rem 0; }
.help-body ol { counter-reset: step; }
.help-body code { background: var(--oe-surface-2); padding: .1rem .35rem; border-radius: 5px; font-size: .88em; }
.help-body .help-tip {
  background: var(--oe-info-soft); border: 1px solid #93c5fd; border-radius: 10px;
  padding: .8rem 1rem; margin: 1rem 0; font-size: .95rem;
}
.help-body .help-tip b { color: #1e40af; }
.help-body .help-step {
  background: var(--oe-surface-2); border-radius: 10px; padding: 1rem 1.1rem; margin: 1rem 0;
}
.help-body .help-cmd {
  font-family: var(--oe-mono); font-size: .84rem; background: #0f172a; color: #e2e8f0;
  padding: .7rem .9rem; border-radius: 8px; overflow-x: auto; margin: .8rem 0;
}
.help-nav {
  display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem;
  padding-top: 1.2rem; border-top: 1px solid var(--oe-border);
}
.help-nav a { text-decoration: none; font-weight: 600; font-size: .92rem; }
.help-nav .help-next { margin-left: auto; text-align: right; }

@media (max-width: 860px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-toc { position: static; max-height: none; }
}

/* ---------- Responsivo: sidebar vira topo no mobile ---------- */
@media (max-width: 820px) {
  .oe-shell { flex-direction: column; }
  .oe-sidebar { width: 100%; flex: none; height: auto; position: static; }
  .oe-sidebar nav { flex-direction: row; flex-wrap: wrap; padding-bottom: .6rem; }
  .oe-sidebar nav a { border-left: 0; border-bottom: 2px solid transparent; }
  .oe-sidebar nav a.active { border-bottom-color: var(--oe-brand); }
  .oe-sidebar .side-footer { display: none; }
}

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