/* =====================================================================
   Norte — Design System (identidade própria)
   Paleta: índigo profundo (marca) + verde-petróleo (ação) + ardósia neutra
   Modo claro padrão, modo escuro opcional. Sem gradientes decorativos.
   ===================================================================== */

:root {
  --brand-900: #1b2340;
  --brand-800: #232d52;
  --brand-700: #2f3b69;
  --brand-600: #3d4b80;
  --brand-500: #56659b;
  --brand-100: #e6e9f4;
  --brand-50:  #f2f4fa;

  --accent-700: #0b6f61;
  --accent-600: #0f8f7e;
  --accent-500: #17a893;
  --accent-100: #ddf2ee;

  --ink-900: #14181f;
  --ink-800: #1f2530;
  --ink-700: #333b49;
  --ink-600: #4b5565;
  --ink-500: #6b7686;
  --ink-400: #8f99a8;
  --ink-300: #c2c9d4;
  --ink-200: #dfe3ea;
  --ink-100: #eef1f5;
  --ink-50:  #f7f8fb;

  --success-600: #16794f;
  --success-100: #dff2e7;
  --warning-600: #a4650a;
  --warning-100: #fbf0d8;
  --risk-600:    #b1382f;
  --risk-100:    #fbe4e1;
  --info-600:    #23608f;
  --info-100:    #e0edf7;

  --surface: #ffffff;
  --surface-alt: var(--ink-50);
  --surface-sunken: #f2f4f8;
  --border: var(--ink-200);
  --border-strong: var(--ink-300);
  --text: var(--ink-900);
  --text-muted: var(--ink-500);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(20, 24, 31, .06), 0 1px 3px rgba(20, 24, 31, .04);
  --shadow-2: 0 4px 12px rgba(20, 24, 31, .08), 0 1px 3px rgba(20, 24, 31, .04);
  --shadow-3: 0 12px 32px rgba(20, 24, 31, .14);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --sidebar-w: 244px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 60px;
  --transition: 140ms cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
  --surface: #12151c;
  --surface-alt: #171b24;
  --surface-sunken: #0e1116;
  --border: #262c38;
  --border-strong: #333b49;
  --text: #eef1f5;
  --text-muted: #9aa4b2;
  --brand-100: #232d52;
  --brand-50: #1a1f33;
  --ink-100: #1d222c;
  --ink-50: #171b24;
  --ink-200: #262c38;
  --success-100: #10291e;
  --warning-100: #2a2110;
  --risk-100: #2d1615;
  --info-100: #10222f;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 12px rgba(0,0,0,.45);
  --shadow-3: 0 12px 32px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 640; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
[data-theme="dark"] a { color: var(--brand-500); }

/* Acessibilidade: foco sempre visível */
:focus-visible {
  outline: 2px solid var(--accent-600);
  outline-offset: 2px;
  border-radius: 4px;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--brand-700); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ------------------------------- Layout ------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--brand-900);
  color: #d8dced;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: width var(--transition), flex-basis var(--transition);
  z-index: 30;
}
.app-shell[data-collapsed="true"] .sidebar { width: var(--sidebar-w-collapsed); flex-basis: var(--sidebar-w-collapsed); }
.app-shell[data-collapsed="true"] .nav-label,
.app-shell[data-collapsed="true"] .brand-text,
.app-shell[data-collapsed="true"] .sidebar-section-title,
.app-shell[data-collapsed="true"] .sidebar-footer-text { display: none; }

.brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 16px; flex: 0 0 auto;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px;
  background: var(--accent-600); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.brand-text { font-weight: 660; color: #fff; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand-text small { display: block; font-weight: 400; font-size: 10.5px; color: #9aa6c9; letter-spacing: .04em; text-transform: uppercase; }

.nav { flex: 1 1 auto; overflow-y: auto; padding: 10px 8px; }
.sidebar-section-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: #7b88ae; padding: 12px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--radius-sm); color: #cbd2e6;
  font-size: 13.5px; margin-bottom: 2px; text-decoration: none; white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--brand-700); color: #fff; font-weight: 560; }
.nav-item i { width: 16px; text-align: center; font-size: 13px; flex: 0 0 16px; }
.nav-item .badge-soon { margin-left: auto; font-size: 9.5px; }

.sidebar-footer { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); flex: 0 0 auto; }
.sidebar-toggle {
  width: 100%; background: transparent; border: 1px solid rgba(255,255,255,.14);
  color: #cbd2e6; border-radius: var(--radius-sm); padding: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px;
  font-family: inherit;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }

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

.topbar {
  height: var(--topbar-h); flex: 0 0 auto;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-scroll { display: flex; align-items: center; gap: 10px; overflow-x: auto; flex: 1 1 auto; scrollbar-width: thin; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.content { padding: 20px; flex: 1 1 auto; max-width: 1600px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head-text { flex: 1 1 320px; min-width: 0; }
.page-head p { color: var(--text-muted); margin-top: 4px; font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------- Cards -------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.card-head h3 { flex: 1 1 auto; min-width: 0; }
.card-body { padding: 16px; }
.card-foot { padding: 11px 16px; border-top: 1px solid var(--border); background: var(--surface-alt); border-radius: 0 0 var(--radius) var(--radius); }
.card.highlighted { border-color: var(--accent-600); box-shadow: 0 0 0 1px var(--accent-600), var(--shadow-1); }

.grid { display: grid; gap: 14px; }
.grid-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ------------------------------ Buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 520; font-family: inherit; cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  white-space: nowrap; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--surface-alt); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-800); border-color: var(--brand-800); }
.btn-accent { background: var(--accent-600); border-color: var(--accent-600); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-700); border-color: var(--accent-700); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-alt); color: var(--text); }
.btn-danger { background: var(--surface); border-color: var(--risk-600); color: var(--risk-600); }
.btn-danger:hover:not(:disabled) { background: var(--risk-100); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn-icon { width: 34px; padding: 0; }
.btn-block { width: 100%; }

/* ------------------------------- Badges ------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 560;
  border: 1px solid transparent; white-space: nowrap;
}
.badge i { font-size: 9px; }
.badge-neutral { background: var(--ink-100); color: var(--ink-600); border-color: var(--border); }
.badge-success { background: var(--success-100); color: var(--success-600); border-color: color-mix(in srgb, var(--success-600) 30%, transparent); }
.badge-warning { background: var(--warning-100); color: var(--warning-600); border-color: color-mix(in srgb, var(--warning-600) 30%, transparent); }
.badge-risk    { background: var(--risk-100);    color: var(--risk-600);    border-color: color-mix(in srgb, var(--risk-600) 30%, transparent); }
.badge-info    { background: var(--info-100);    color: var(--info-600);    border-color: color-mix(in srgb, var(--info-600) 30%, transparent); }
.badge-brand   { background: var(--brand-100);   color: var(--brand-700);   border-color: color-mix(in srgb, var(--brand-700) 25%, transparent); }
.badge-soon    { background: var(--ink-100); color: var(--ink-500); border-color: var(--border); font-weight: 500; }
.badge-demo    { background: var(--warning-100); color: var(--warning-600); border-color: color-mix(in srgb, var(--warning-600) 35%, transparent); }

/* ------------------------------- Forms -------------------------------- */
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 180px; }
label.label { display: block; font-size: 12.5px; font-weight: 560; margin-bottom: 5px; color: var(--ink-700); }
[data-theme="dark"] label.label { color: var(--ink-300); }
.hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px; font-size: 13.5px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-600);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 18%, transparent);
}
.input[aria-invalid="true"] { border-color: var(--risk-600); }
.checkbox-row { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 9px; font-size: 13px; }
.checkbox-row input[type="checkbox"], .checkbox-row input[type="radio"] { margin-top: 2px; width: 15px; height: 15px; accent-color: var(--brand-700); flex: 0 0 auto; }
.form-error {
  background: var(--risk-100); color: var(--risk-600); border: 1px solid color-mix(in srgb, var(--risk-600) 30%, transparent);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
}
.color-input { height: 36px; width: 52px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }

/* Segmented control (períodos, abas curtas) */
.segmented { display: inline-flex; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--text-muted); font-family: inherit;
  font-size: 12.5px; padding: 5px 11px; border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 560; box-shadow: var(--shadow-1); }

/* ------------------------------- Tables ------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
  font-weight: 600; background: var(--surface-alt); position: sticky; top: 0; z-index: 1;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--surface-alt); }
table.data tbody tr[data-expandable] { cursor: pointer; }
table.data .row-child td:first-child { padding-left: 34px; }
table.data .row-grandchild td:first-child { padding-left: 56px; }

/* ------------------------------- KPI ---------------------------------- */
.kpi-label { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; font-weight: 520; }
.kpi-value { font-size: 26px; font-weight: 660; letter-spacing: -.02em; margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi-value.sm { font-size: 20px; }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 560; margin-top: 6px; }
.kpi-delta.up { color: var(--success-600); }
.kpi-delta.down { color: var(--risk-600); }
.kpi-delta.flat { color: var(--text-muted); }
.kpi-prev { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

.progress { height: 7px; background: var(--ink-100); border-radius: 999px; overflow: hidden; margin-top: 9px; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--accent-600); transition: width 300ms ease; }
.progress.warn > span { background: var(--warning-600); }
.progress.risk > span { background: var(--risk-600); }

/* Tooltip acessível */
.tip { position: relative; display: inline-flex; }
.tip > .tip-trigger {
  border: 0; background: transparent; padding: 0; cursor: help; color: var(--ink-400);
  font-size: 11px; line-height: 1; font-family: inherit;
}
.tip > .tip-body {
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: var(--ink-900); color: #fff; padding: 7px 10px; border-radius: var(--radius-sm);
  font-size: 11.5px; font-weight: 400; width: max-content; max-width: 260px; line-height: 1.45;
  opacity: 0; visibility: hidden; transition: opacity var(--transition); z-index: 60; box-shadow: var(--shadow-2);
  white-space: normal; text-align: left;
}
.tip:hover > .tip-body, .tip:focus-within > .tip-body { opacity: 1; visibility: visible; }

/* ------------------------------ Empty/alert --------------------------- */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state .icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--brand-50); color: var(--brand-700);
  display: grid; place-items: center; margin: 0 auto 12px; font-size: 18px;
}
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); max-width: 460px; margin: 0 auto 16px; font-size: 13px; }

.alert { display: flex; gap: 11px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-alt); font-size: 13px; }
.alert i { margin-top: 2px; flex: 0 0 auto; }
.alert-title { font-weight: 600; margin-bottom: 2px; }
.alert-body { color: var(--text-muted); }
.alert-info    { background: var(--info-100);    border-color: color-mix(in srgb, var(--info-600) 26%, transparent); }
.alert-info i, .alert-info .alert-title { color: var(--info-600); }
.alert-warning { background: var(--warning-100); border-color: color-mix(in srgb, var(--warning-600) 26%, transparent); }
.alert-warning i, .alert-warning .alert-title { color: var(--warning-600); }
.alert-risk    { background: var(--risk-100);    border-color: color-mix(in srgb, var(--risk-600) 26%, transparent); }
.alert-risk i, .alert-risk .alert-title { color: var(--risk-600); }
.alert-success { background: var(--success-100); border-color: color-mix(in srgb, var(--success-600) 26%, transparent); }
.alert-success i, .alert-success .alert-title { color: var(--success-600); }
.alert-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }

/* ------------------------------ Skeleton ------------------------------ */
.skeleton { background: linear-gradient(90deg, var(--ink-100) 25%, var(--ink-50) 50%, var(--ink-100) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 12px; margin-bottom: 8px; }
.skeleton-kpi { height: 74px; }
.skeleton-chart { height: 220px; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }

/* ------------------------------- Modal -------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,24,31,.5); z-index: 100;
  display: grid; place-items: center; padding: 18px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
  width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column;
}
.modal.wide { max-width: 940px; }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { flex: 1 1 auto; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1 1 auto; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-alt); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Drawer (filtros / biblioteca de widgets) */
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 340px; max-width: 92vw;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-3);
  z-index: 90; display: flex; flex-direction: column; transform: translateX(100%);
  transition: transform var(--transition);
}
.drawer[data-open="true"] { transform: translateX(0); }
.drawer-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer-body { padding: 14px 16px; overflow-y: auto; flex: 1 1 auto; }

/* Toast */
.toast-stack { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.toast {
  background: var(--ink-900); color: #fff; padding: 11px 14px; border-radius: var(--radius);
  box-shadow: var(--shadow-3); font-size: 13px; display: flex; gap: 9px; align-items: flex-start;
  animation: toast-in 180ms ease;
}
.toast.success { background: var(--success-600); }
.toast.error { background: var(--risk-600); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 5px); right: 0; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-2); padding: 5px; z-index: 70; display: none;
}
.dropdown[data-open="true"] .dropdown-menu { display: block; }
.dropdown-menu.left { right: auto; left: 0; }
.dropdown-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; background: transparent; border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--text); cursor: pointer; text-decoration: none;
}
.dropdown-item:hover { background: var(--surface-alt); text-decoration: none; }
.dropdown-item[aria-disabled="true"] { color: var(--ink-400); cursor: not-allowed; }
.dropdown-sep { height: 1px; background: var(--border); margin: 5px 0; }
.dropdown-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 7px 10px 3px; font-weight: 600; }

/* Avatar */
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-700); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: 0 0 auto; }
.avatar.sm { width: 24px; height: 24px; font-size: 10.5px; }
.avatar.lg { width: 40px; height: 40px; font-size: 15px; }

/* Status dot — nunca só cor: sempre acompanhado de texto */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.status-dot.fresh { background: var(--success-600); }
.status-dot.syncing { background: var(--info-600); animation: pulse 1.4s infinite; }
.status-dot.partial, .status-dot.stale { background: var(--warning-600); }
.status-dot.error, .status-dot.permission_expired { background: var(--risk-600); }
.status-dot.no_data { background: var(--ink-400); }
.status-dot.success { background: var(--success-600); }
.status-dot.info { background: var(--info-600); }
.status-dot.warning { background: var(--warning-600); }
.status-dot.risk { background: var(--risk-600); }
.status-dot.neutral { background: var(--ink-400); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* Widget grid do builder */
.widget-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; align-items: start; }
.widget { grid-column: span 3; position: relative; min-width: 0; }
.widget[data-w="2"] { grid-column: span 2; } .widget[data-w="3"] { grid-column: span 3; }
.widget[data-w="4"] { grid-column: span 4; } .widget[data-w="6"] { grid-column: span 6; }
.widget[data-w="8"] { grid-column: span 8; } .widget[data-w="9"] { grid-column: span 9; }
.widget[data-w="12"] { grid-column: span 12; }
.widget-toolbar {
  position: absolute; top: 7px; right: 7px; display: none; gap: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 2px; box-shadow: var(--shadow-1); z-index: 5;
}
.widget:hover .widget-toolbar, .widget:focus-within .widget-toolbar { display: flex; }
[data-edit-mode="true"] .widget { cursor: grab; }
[data-edit-mode="true"] .widget-toolbar { display: flex; }
.widget.dragging { opacity: .4; }
.widget.drop-target { outline: 2px dashed var(--accent-600); outline-offset: 3px; border-radius: var(--radius); }
.widget-hidden-client { border-style: dashed; }

.chart-box { position: relative; width: 100%; }
.chart-box canvas { max-width: 100%; }

.data-summary {
  margin-top: 10px; font-size: 12px; color: var(--text-muted);
  border-top: 1px dashed var(--border); padding-top: 9px;
}
.data-summary summary { cursor: pointer; font-weight: 560; color: var(--brand-700); }

/* Utilitários */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.muted { color: var(--text-muted); }
.up { color: var(--success-600); } .down { color: var(--risk-600); } .flat { color: var(--text-muted); }
.small { font-size: 12px; }
.xsmall { font-size: 11px; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.hide { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.pill-list { display: flex; gap: 6px; flex-wrap: wrap; }

/* Autenticação / onboarding */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside { background: var(--brand-900); color: #dfe4f2; padding: 44px; display: flex; flex-direction: column; }
.auth-aside h2 { color: #fff; font-size: 25px; margin: auto 0 14px; max-width: 420px; line-height: 1.3; }
.auth-aside ul { list-style: none; padding: 0; margin: 0 0 auto; max-width: 420px; }
.auth-aside li { display: flex; gap: 10px; margin-bottom: 11px; font-size: 13.5px; color: #b9c2dd; }
.auth-aside li i { color: var(--accent-500); margin-top: 3px; }
.auth-main { display: grid; place-items: center; padding: 34px 20px; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }

.steps { display: flex; gap: 6px; margin-bottom: 22px; flex-wrap: wrap; }
.step-dot { flex: 1 1 30px; height: 4px; border-radius: 999px; background: var(--ink-200); }
.step-dot[data-state="done"] { background: var(--accent-600); }
.step-dot[data-state="current"] { background: var(--brand-700); }

/* Página compartilhada (cliente) */
.share-page { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.share-header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.share-logo { height: 38px; max-width: 170px; object-fit: contain; }
.share-footer { margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 12px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ----------------------------- Responsivo ---------------------------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .widget[data-w="8"], .widget[data-w="9"], .widget[data-w="12"] { grid-column: span 6; }
  .widget[data-w="4"] { grid-column: span 3; }
}
@media (max-width: 860px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform var(--transition); width: var(--sidebar-w); flex-basis: var(--sidebar-w);
  }
  .app-shell[data-mobile-nav="true"] .sidebar { transform: translateX(0); }
  .app-shell[data-mobile-nav="true"]::after {
    content: ''; position: fixed; inset: 0; background: rgba(20,24,31,.45); z-index: 25;
  }
  .app-shell[data-collapsed="true"] .nav-label,
  .app-shell[data-collapsed="true"] .brand-text { display: block; }
  .content { padding: 14px; }
  .widget-grid { grid-template-columns: 1fr; }
  .widget, .widget[data-w] { grid-column: span 1 !important; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .mobile-only { display: initial; }
  .desktop-only { display: none !important; }
  .kpi-value { font-size: 22px; }
  .drawer { width: 100%; }
  /* Bottom sheet para filtros no mobile */
  .sheet {
    position: fixed; left: 0; right: 0; bottom: 0; max-height: 86vh;
    background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-3); z-index: 95; transform: translateY(100%);
    transition: transform var(--transition); display: flex; flex-direction: column;
  }
  .sheet[data-open="true"] { transform: translateY(0); }
}
@media (min-width: 761px) { .mobile-only { display: none !important; } }

/* ------------------------------ Impressão ---------------------------- */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; font-size: 10.5pt; }
  .sidebar, .topbar, .no-print, .toast-stack, .widget-toolbar, .drawer { display: none !important; }
  .content, .share-page { padding: 0; max-width: none; }
  .card { break-inside: avoid; page-break-inside: avoid; box-shadow: none; border-color: #ccc; }
  .widget-grid { display: block; }
  .widget { margin-bottom: 8mm; break-inside: avoid; }
  .report-page-break { break-before: page; page-break-before: always; }
  table.data th { background: #f3f3f3 !important; }
  a { color: #000; text-decoration: none; }
  .print-only { display: initial !important; }
}
.print-only { display: none; }

/* ---- Linhas de lista (autorizações, integrações) ---- */
.list-row {
  display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.list-row:first-child { padding-top: 0; }
.list-row-main { min-width: 0; flex: 1; }
.list-row-title { display: flex; align-items: center; gap: 8px; font-weight: 600; flex-wrap: wrap; }
.list-row-actions { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .list-row { flex-direction: column; }
  .list-row-actions { width: 100%; }
}

/* ---- Páginas legais públicas (privacidade, termos, exclusão de dados) ----
   Layout de leitura: coluna estreita, tipografia confortável e nada de
   distração. Um revisor da Meta abre isso para achar uma informação
   específica em segundos, às vezes em conexão ruim. Zero animação. */
.legal-body { background: var(--surface-alt); }
.legal-top {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.legal-brand { color: inherit; }
.legal-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.legal-nav a {
  padding: 7px 12px; border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--text-muted); text-decoration: none;
}
.legal-nav a:hover { background: var(--ink-100); color: var(--text); }
.legal-nav a.active { background: var(--brand-100); color: var(--brand-700); font-weight: 600; }
.legal-main {
  max-width: 820px; margin: 0 auto; padding: 40px 24px 72px;
  background: var(--surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  min-height: calc(100vh - 61px);
}
.legal-main h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.02em; }
.legal-lead { font-size: 17px; color: var(--text-muted); margin-top: 10px; line-height: 1.6; }
.legal-meta {
  font-size: 13px; color: var(--text-muted); margin-top: 16px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.legal-main section { margin-top: 34px; }
.legal-main h2 {
  font-size: 20px; letter-spacing: -0.01em; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.legal-main h3 { font-size: 16px; margin-top: 20px; }
.legal-main p { margin-top: 12px; line-height: 1.7; }
.legal-main ul, .legal-main ol { margin: 12px 0 0 22px; }
.legal-main li { margin-top: 8px; line-height: 1.65; }
.legal-main table.data { margin-top: 16px; }
.legal-main table.data td { vertical-align: top; line-height: 1.55; }
.legal-main code {
  background: var(--ink-100); padding: 2px 6px; border-radius: 5px;
  font-size: 0.88em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.legal-foot {
  margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border);
  font-size: 14px; color: var(--text-muted);
}
.legal-foot p { margin-top: 8px; }
@media (max-width: 720px) {
  .legal-main { padding: 28px 18px 56px; border: 0; }
  .legal-main h1 { font-size: 25px; }
}

/* ---- Assistente de criação de dashboard (3 passos) ------------------
   Listas potencialmente longas (uma conta com 80 campanhas, um catálogo
   com 46 métricas) dentro de um modal. Rolagem própria por bloco, para que
   o rodapé com "Continuar" nunca saia da tela — botão inalcançável é
   funcionalidade inexistente. */
.wiz-head { margin-bottom: 16px; }
.wiz-head .steps { margin-bottom: 8px; }

.wiz-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
.wiz-group + .wiz-group { margin-top: 10px; }
.wiz-group-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.wiz-group-head > i { color: var(--brand-700); }

.wiz-asset-list { display: flex; flex-direction: column; gap: 6px; }
.wiz-asset, .wiz-camp, .wiz-metric {
  display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
}
.wiz-asset:hover, .wiz-camp:hover, .wiz-metric:hover { border-color: var(--border-strong); background: var(--surface-alt); }
.wiz-asset:has(input:checked), .wiz-camp:has(input:checked), .wiz-metric:has(input:checked) {
  border-color: var(--brand-700); box-shadow: inset 0 0 0 1px var(--brand-700);
}
.wiz-asset.is-disabled { opacity: .55; cursor: not-allowed; background: var(--surface-alt); }
.wiz-asset.is-disabled:hover { border-color: var(--border); }
.wiz-asset input, .wiz-camp input, .wiz-metric input {
  margin-top: 3px; width: 15px; height: 15px; accent-color: var(--brand-700); flex: 0 0 auto;
}
.wiz-asset-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wiz-asset-title { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-weight: 560; font-size: 13.5px; }

.wiz-camp-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; padding-right: 2px; }
.wiz-metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; max-height: 330px; overflow-y: auto; padding-right: 2px; }

.wiz-summary { display: flex; flex-direction: column; gap: 6px; }
.wiz-summary-row { display: flex; gap: 12px; align-items: baseline; }
.wiz-summary-row > span:first-child { flex: 0 0 92px; text-transform: uppercase; letter-spacing: .04em; }
.wiz-summary-row > span:last-child { min-width: 0; word-break: break-word; }

@media (max-width: 640px) {
  .wiz-metric-grid { grid-template-columns: 1fr; }
}

/* ================= Relatório compartilhado (página pública) =============
   Layout próprio, sem barra lateral e sem nenhuma affordance de app: quem
   abre esta página é o cliente, não o operador. Largura de leitura maior que
   a do app porque não existe navegação roubando espaço.
   ===================================================================== */
.share-body { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.share-wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; width: 100%; }
.share-top { padding: 26px 0 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.share-title { font-size: 1.6rem; line-height: 1.25; margin: 0; }
.share-sub { color: var(--text-muted); margin: 6px 0 0; font-size: 14px; }
.share-main { padding: 22px 20px 48px; flex: 1; }
.share-foot { border-top: 1px solid var(--border); padding: 16px 0; background: var(--surface); }
.share-mark { width: 20px; height: 20px; font-size: 11px; border-radius: 5px; }
.share-blocked { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.share-blocked-icon {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  margin: 0 auto; font-size: 21px;
  background: var(--ink-100); color: var(--ink-500);
}
@media (max-width: 760px) {
  .share-title { font-size: 1.3rem; }
  .share-main { padding: 16px 14px 36px; }
  .share-wrap { padding: 0 14px; }
}
@media print {
  .share-top, .share-foot { border-color: #ccc; background: #fff; }
  .share-main, .share-wrap { padding: 0; max-width: none; }
  #share-print { display: none !important; }
}

/* Indicador sem dado.
 *
 * Ocupa a altura de uma linha de texto, não a de um número em corpo 26. A
 * hierarquia visual tem de refletir a hierarquia da informação: "não tenho
 * este número" é menos importante que qualquer número que eu tenha. */
.kpi-empty {
  margin-top: 7px; font-size: 12.5px; line-height: 1.45; color: var(--text-muted);
  display: flex; align-items: flex-start; gap: 6px;
}
.kpi-empty::before {
  content: "\f068"; font-family: "Font Awesome 6 Free"; font-weight: 900;
  font-size: 9px; opacity: .5; margin-top: 3px; flex: none;
}

/* Avisos secundários de qualidade: legíveis, não gritados. */
.quality-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.quality-notes li {
  font-size: 12.5px; line-height: 1.45; color: var(--text-secondary);
  display: flex; align-items: flex-start; gap: 7px; padding-left: 2px;
}
.quality-notes li .status-dot { margin-top: 5px; flex: none; }
