:root {
  --brand: #1a56db;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f6fa;
  --card: #fff;
  --ok: #059669;
  --bad: #dc2626;
  --warn: #b45309;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 15px; color: var(--text); background: var(--bg); line-height: 1.45; }
a { color: var(--brand); }
h1 { font-size: 1.55rem; margin: 0 0 .2rem; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.up { color: var(--ok); } .down { color: var(--bad); } .neu { color: var(--muted); }

/* topo */
.topbar { display: flex; align-items: center; gap: 1rem; background: #fff; border-bottom: 1px solid var(--line); padding: .6rem 1.4rem; position: sticky; top: 0; z-index: 10; }
.topbar .logo { display: flex; align-items: center; text-decoration: none; font-weight: 700; color: var(--brand); font-size: 1.1rem; }
.topbar .logo img { height: 34px; }
.nav-links { display: flex; gap: .2rem; margin-left: auto; flex-wrap: wrap; }
.nav-links a { text-decoration: none; color: var(--text); padding: .45rem .75rem; border-radius: 7px; font-size: .93rem; }
.nav-links a:hover { background: #f1f4f9; }
.nav-links a.on { background: var(--brand); color: #fff; }
.nav-links a.logout { color: var(--muted); }
.menu-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 6px; font-size: 1.2rem; padding: .2rem .6rem; cursor: pointer; }

.container { max-width: 1280px; margin: 0 auto; padding: 1.4rem; }

/* botões e formulários */
.btn { display: inline-block; background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 8px; padding: .55rem 1rem; font-size: .93rem; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { filter: brightness(1.08); }
.btn-light { background: #fff; color: var(--text); border-color: var(--line); }
.btn-light:hover { background: #f8fafc; filter: none; }
.btn-danger { background: #fff; color: var(--bad); border-color: #fecaca; }
.btn-sm { padding: .32rem .65rem; font-size: .84rem; }
.btn-block { width: 100%; }
form.inline { display: inline; }
.form label { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .9rem; }
.form input:not([type=checkbox]), .form select, .form textarea, .filters select, .filters input {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; font-weight: 400; background: #fff;
}
.form textarea { resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem 1rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
.check-inline { display: block; font-weight: 400 !important; margin: .35rem 0 !important; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; margin-bottom: 1rem; max-width: 760px; }

/* alertas */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .93rem; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* login */
main.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 12%, #fff), #f4f6fa); }
.auth-card { background: #fff; width: 100%; max-width: 400px; padding: 2rem; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.auth-card.wide { max-width: 560px; }
.auth-logo { max-height: 56px; margin-bottom: 1rem; }
.auth-brand { font-weight: 800; color: var(--brand); font-size: 1.3rem; margin-bottom: 1rem; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: .25rem 0; }
.checklist .ok { color: var(--ok); } .checklist .fail { color: var(--bad); font-weight: 600; }

/* filtros */
.filters { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1.2rem; }
.f-row { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; }
.f-row label { font-size: .82rem; font-weight: 600; color: var(--muted); min-width: 140px; }
.f-row label.grow { flex: 1; min-width: 220px; }
.picker { margin-top: .9rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.picker summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.picker-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1rem; }
.picker h4 { margin: 0 0 .5rem; font-size: .95rem; }
.picker h4 .warn { color: var(--warn); font-weight: 400; margin-left: .4rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem .55rem; border-radius: 8px; cursor: pointer; }
.check:hover { background: #f8fafc; }
.check input { margin-top: .25rem; accent-color: var(--brand); width: 16px; height: 16px; }
.check small { display: block; color: var(--muted); font-weight: 400; }
.picker-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

/* cabeçalho do dashboard */
.dash-head, .page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dash-head p { margin: 0; }
.dash-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* blocos */
.blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.blocks .span2 { grid-column: span 2; }
.block { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; height: 100%; overflow: hidden; }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .9rem; gap: .5rem; }
.block-head h3 { margin: 0; font-size: 1.02rem; }
.block-head .src { font-size: .72rem; font-weight: 700; padding: .2rem .55rem; border-radius: 20px; background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); white-space: nowrap; }
.src-ga4 .block-head .src { background: #fef3c7; color: #92400e; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; }
.kpi { background: #f9fafb; border: 1px solid #eef0f3; border-radius: 9px; padding: .8rem .9rem; }
.kl { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.kv { font-size: 1.65rem; font-weight: 750; margin: .15rem 0; }
.kp { font-size: .8rem; }
.chg { font-weight: 700; }

.legend { font-size: .86rem; margin-bottom: .4rem; display: flex; gap: 1.2rem; flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }
.chart svg { width: 100%; height: auto; display: block; }

table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); padding: .45rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: .5rem; border-bottom: 1px solid #f2f4f7; }
table.data tr:hover td { background: #fafbfd; }
table.data .n { text-align: right; white-space: nowrap; }
table.data .t { word-break: break-word; }
.barcell { white-space: nowrap; width: 150px; }
.bar { display: inline-block; width: 90px; height: 8px; background: #eef2f7; border-radius: 4px; vertical-align: middle; overflow: hidden; }
.bar .fill { height: 100%; background: var(--brand); border-radius: 4px; }
.barcell span { font-size: .8rem; color: var(--muted); margin-left: .4rem; }

/* listas administrativas */
table.list { width: 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; overflow: hidden; }
table.list th { text-align: left; background: #f9fafb; font-size: .8rem; color: var(--muted); text-transform: uppercase; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
table.list td { padding: .7rem .9rem; border-bottom: 1px solid #f2f4f7; vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list .actions { text-align: right; white-space: nowrap; }
tr.inactive td { opacity: .6; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 20px; background: #eef2ff; color: #3730a3; }
.tag.ok { background: #ecfdf5; color: #065f46; }
.tag.bad { background: #fef2f2; color: #991b1b; }

.empty-state { background: #fff; border: 1px dashed #cbd5e1; border-radius: var(--radius); padding: 2.5rem; text-align: center; }

/* diálogos */
.dlg { border: none; border-radius: 14px; padding: 1.5rem; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(15,23,42,.45); }
.dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }

@media (max-width: 900px) {
  .blocks { grid-template-columns: 1fr; }
  .blocks .span2 { grid-column: auto; }
  .picker-cols { grid-template-columns: 1fr; }
  .menu-toggle { display: block; }
  .nav-links { display: none; width: 100%; flex-direction: column; }
  body.menu-open .nav-links { display: flex; }
  .topbar { flex-wrap: wrap; }
  .container { padding: 1rem; }
  table.list, table.data { display: block; overflow-x: auto; }
}
