/* Painel Comercial Bexper: visual com tema claro e escuro e as cores de cada cliente.
   As cores da marca vêm de --c-primary e --c-accent (definidas por cliente na administração);
   o resto da paleta é derivado delas, nos dois temas. */
:root {
  color-scheme: light;
  --c-primary: #2a78d6;
  --c-accent: #eb6834;

  --brand: var(--c-primary);
  --brand-strong: color-mix(in srgb, var(--c-primary) 62%, #000);
  --brand-soft: color-mix(in srgb, var(--c-primary) 10%, #fff);
  --brand-ink: #ffffff;
  --accent: var(--c-accent);
  --link: color-mix(in srgb, var(--c-primary) 85%, #000);

  --surface-0: color-mix(in srgb, var(--c-primary) 4%, #f3f5f8);
  --surface-1: #ffffff;
  --surface-2: color-mix(in srgb, var(--c-primary) 3%, #f7f8fa);
  --border: #dfe4ec;
  --grid: #ebeef3;
  --text-primary: #0f1724;
  --text-secondary: #455164;
  --text-muted: #75808f;
  --shadow: 0 1px 2px rgba(15, 23, 36, .05), 0 10px 28px rgba(15, 23, 36, .07);

  --series-1: var(--brand);
  --series-2: var(--accent);
  --good: #0a8f3c;
  --warning: #b77a00;
  --critical: #d03b3b;
  --tooltip-bg: #0f1724;
  --tooltip-fg: #ffffff;

  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: color-mix(in srgb, var(--c-primary) 80%, #fff);
    --brand-strong: color-mix(in srgb, var(--c-primary) 45%, #000);
    --brand-soft: color-mix(in srgb, var(--c-primary) 22%, #0b111b);
    --accent: color-mix(in srgb, var(--c-accent) 82%, #fff);
    --link: color-mix(in srgb, var(--c-primary) 50%, #fff);
    --surface-0: color-mix(in srgb, var(--c-primary) 6%, #090d14);
    --surface-1: color-mix(in srgb, var(--c-primary) 7%, #111722);
    --surface-2: color-mix(in srgb, var(--c-primary) 9%, #161d2a);
    --border: color-mix(in srgb, var(--c-primary) 12%, #262f3e);
    --grid: color-mix(in srgb, var(--c-primary) 8%, #1d2533);
    --text-primary: #eef2f8;
    --text-secondary: #b8c2d1;
    --text-muted: #8893a5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .3);
    --good: #2fc46c;
    --warning: #e0a526;
    --critical: #ef6b6b;
    --tooltip-bg: #eef2f8;
    --tooltip-fg: #0b111b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: color-mix(in srgb, var(--c-primary) 80%, #fff);
  --brand-strong: color-mix(in srgb, var(--c-primary) 45%, #000);
  --brand-soft: color-mix(in srgb, var(--c-primary) 22%, #0b111b);
  --accent: color-mix(in srgb, var(--c-accent) 82%, #fff);
  --link: color-mix(in srgb, var(--c-primary) 50%, #fff);
  --surface-0: color-mix(in srgb, var(--c-primary) 6%, #090d14);
  --surface-1: color-mix(in srgb, var(--c-primary) 7%, #111722);
  --surface-2: color-mix(in srgb, var(--c-primary) 9%, #161d2a);
  --border: color-mix(in srgb, var(--c-primary) 12%, #262f3e);
  --grid: color-mix(in srgb, var(--c-primary) 8%, #1d2533);
  --text-primary: #eef2f8;
  --text-secondary: #b8c2d1;
  --text-muted: #8893a5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .3);
  --good: #2fc46c;
  --warning: #e0a526;
  --critical: #ef6b6b;
  --tooltip-bg: #eef2f8;
  --tooltip-fg: #0b111b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 14px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 20px; padding-block: 24px 56px; }

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo { height: 40px; width: auto; display: block; }
.brand .logo-fallback { font-weight: 800; letter-spacing: .02em; color: var(--brand); font-size: 18px; }
/* Logo: versão original no claro, versão com letras brancas no escuro */
.logo-escuro { display: none !important; }
:root[data-theme="dark"] .logo-claro { display: none !important; }
:root[data-theme="dark"] .logo-escuro { display: block !important; }
.brand .divider { width: 1px; height: 26px; background: var(--border); }
.brand h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand .subtitle { font-size: 12px; color: var(--text-muted); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
@media (max-width: 640px) {
  .brand .divider, .brand .subtitle { display: none; }
  .topbar-inner { padding: 10px 16px; }
}

/* ---------- filtros ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; color: var(--text-secondary); cursor: pointer; font: inherit; font-weight: 600; font-size: 13px; transition: background .15s, color .15s; }
.seg button:hover { color: var(--text-primary); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
input[type="date"], select, .btn {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  border-radius: 10px; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 600; max-width: 100%;
}
.btn { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.icon { padding: 7px 9px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn svg { width: 16px; height: 16px; }

/* ---------- seções e cartões ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px 22px; min-width: 0; box-shadow: var(--shadow);
}
.span-12 { grid-column: span 12; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-8 { grid-column: span 8; }
.span-3 { grid-column: span 3; }
@media (max-width: 900px) { .span-6, .span-4, .span-8, .span-3 { grid-column: span 12; } }

.section-title { font-size: 19px; font-weight: 800; letter-spacing: -.015em; margin: 36px 0 14px; text-wrap: balance; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.section-title::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: linear-gradient(var(--brand), var(--accent)); align-self: center; }
.section-title:first-child { margin-top: 8px; }
.section-sub { font-size: 13px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; }
.section-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin: 36px 0 14px; }
.section-head .section-title { margin: 0; }
.card h2, .card h3 { font-size: 15px; margin: 0 0 2px; font-weight: 700; letter-spacing: -.005em; }
.card .hint { color: var(--text-muted); font-size: 12.5px; margin: 0 0 14px; }

/* ---------- números de destaque ---------- */
.hero { display: flex; flex-wrap: wrap; gap: 24px 40px; align-items: stretch; }
.hero-main {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: var(--brand-ink); border-radius: 14px; padding: 20px 24px; min-width: 260px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.hero-main::after { content: ""; position: absolute; right: -40px; bottom: -40px; width: 140px; height: 140px; border-radius: 50%; border: 18px solid var(--accent); opacity: .22; }
.hero-main > * { position: relative; }
.hero-main .label { color: inherit; opacity: .85; font-size: 13px; font-weight: 600; }
.hero-main .big { font-size: 52px; font-weight: 800; line-height: 1.05; letter-spacing: -.03em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.hero-main .sub { color: inherit; opacity: .8; font-size: 12.5px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; flex: 1; min-width: 280px; align-content: center; }
.tile { border-left: 1px solid var(--border); padding-left: 16px; }
.tile .label { font-size: 12.5px; color: var(--text-secondary); font-weight: 600; }
.tile .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--text-muted); }
.tiles-5 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tiles-5 .tile:first-child { border-left: 0; padding-left: 0; }

/* ---------- gráficos ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--text-muted); font-size: 11px; font-family: var(--font-ui); }
.chart .val { fill: var(--text-secondary); font-size: 11.5px; font-weight: 600; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .link { fill: var(--link); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 8px; font-weight: 600; }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 6px; border-radius: 2px; }
.tooltip { position: absolute; pointer-events: none; background: var(--tooltip-bg); color: var(--tooltip-fg); padding: 8px 11px; border-radius: 8px; font-size: 12px; line-height: 1.45; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .1s; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.tooltip.show { opacity: 1; }

/* ---------- tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--grid); }
th { color: var(--text-muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; background: var(--surface-1); }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll { overflow-x: auto; max-height: 440px; overflow-y: auto; }
a { color: var(--link); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--link); cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }

/* ---------- estados ---------- */
.status { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.good { color: var(--good); }
.status.warning { color: var(--warning); }
.status.critical { color: var(--critical); }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--warning); color: #fff; margin-left: 8px; vertical-align: middle; }

.notice { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); margin-bottom: 16px; }
.notice.error { border-color: var(--critical); color: var(--critical); }
.loading { opacity: .5; pointer-events: none; transition: opacity .2s; }
details summary { cursor: pointer; color: var(--text-secondary); font-size: 12.5px; font-weight: 600; margin-top: 10px; }

button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ícone do seletor de tema: mostra a lua no claro e o sol no escuro */
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ---------- Bexper: login, administração e blocos novos ---------- */
.embed .topbar #admin-link { display: none; }
.topbar select { max-width: 220px; }
.btn.danger { color: var(--critical); border-color: var(--critical); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--brand-soft), transparent 60%), var(--surface-0); }
.login-box { width: 100%; max-width: 390px; padding: 32px 28px; }
.login-box .logo { height: 44px; width: auto; display: block; margin: 0 auto 18px; }
.login-box h1 { margin: 0 0 4px; text-align: center; font-size: 20px; font-weight: 800; }
.login-box .subtitle { text-align: center; margin: 0; color: var(--text-muted); font-size: 13px; }
.login-box form { display: grid; gap: 14px; margin: 22px 0 12px; }
.login-box .hint { text-align: center; color: var(--text-muted); font-size: 12.5px; margin: 0; }
label { display: grid; gap: 5px; font-size: 13px; color: var(--text-secondary); font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary); border-radius: 10px; padding: 9px 12px; font: inherit; font-weight: 500; width: 100%;
}
input[type="color"] { padding: 2px; height: 36px; width: 64px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); }
textarea { min-height: 70px; resize: vertical; }
.form-error { color: var(--critical); min-height: 1.2em; margin: 0; font-size: 13px; }
.form-ok { color: var(--good); font-size: 13px; margin: 0; font-weight: 600; }

.admin-layout { display: grid; grid-template-columns: 270px 1fr; gap: 16px; align-items: start; margin-top: 8px; }
@media (max-width: 900px) { .admin-layout { grid-template-columns: 1fr; } }
.company-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.company-list button { width: 100%; text-align: left; border: 1px solid transparent; background: none; color: var(--text-primary); padding: 8px 10px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.company-list button:hover { background: var(--surface-2); }
.company-list button[aria-current="true"] { border-color: var(--brand); background: var(--brand-soft); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.checks label { display: flex; gap: 8px; align-items: center; color: var(--text-primary); font-size: 13.5px; font-weight: 500; }
fieldset { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px 16px; margin: 0 0 14px; min-width: 0; }
legend { font-weight: 800; padding: 0 6px; font-size: 14px; }
fieldset .hint { margin: 0 0 10px; color: var(--text-muted); font-size: 12.5px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { border: 0; background: none; padding: 9px 12px; color: var(--text-secondary); cursor: pointer; font: inherit; font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--brand); }
.pill { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap; }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.warning { color: var(--warning); border-color: var(--warning); }
.pill.critical { color: var(--critical); border-color: var(--critical); }
code.copy { display: block; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); word-break: break-all; font-size: 12px; }
.logo-preview { height: 40px; max-width: 160px; object-fit: contain; border: 1px dashed var(--border); border-radius: 6px; padding: 2px; background: var(--surface-1); }
.logo-preview.dark { background: #111722; }

/* Análise da IA */
.ai-card { margin-top: 8px; border-left: 4px solid var(--accent); }
.ai-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-start; justify-content: space-between; }
.ai-text { white-space: pre-line; font-size: 14px; line-height: 1.6; color: var(--text-primary); }
.ai-text:empty { display: none; }
.ai-text b { font-weight: 800; }

/* Metas do mês */
.goals { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.goal .label { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.goal .value { font-size: 24px; font-weight: 800; margin: 2px 0 8px; font-variant-numeric: tabular-nums; }
.goal .bar { position: relative; height: 10px; border-radius: 999px; background: var(--grid); overflow: hidden; }
.goal .bar i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.goal .bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-muted); }
.goal .sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Marca: sem logo mostra o nome do cliente em texto */
.brand.no-logo .logo { display: none !important; }
.brand:not(.no-logo) .logo-fallback { display: none; }
