/* ==========================================================================
   Ads Intelligence - Design System
   Tokens -> Base -> Layout -> Componentes -> Paginas -> Responsivo
   ========================================================================== */

/* --------------------------------------------------------------- TOKENS */
:root {
  color-scheme: light;

  --bg: #f5f6f8;
  --bg-subtle: #eef0f4;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-hover: #f4f6f9;
  --border: #e3e6ec;
  --border-strong: #d3d8e0;

  --text: #101828;
  --text-secondary: #475467;
  --muted: #79839a;
  --inverse: #ffffff;

  --primary: #3b6cf6;
  --primary-hover: #2f5ae0;
  --primary-soft: #eef2ff;
  --primary-border: #c7d4fd;

  --positive: #0a8a5f;
  --positive-soft: #e7f6ef;
  --negative: #d64550;
  --negative-soft: #fdecee;
  --warning: #b7791f;
  --warning-soft: #fdf4e3;
  --neutral-soft: #f1f3f7;

  --chart-1: #3b6cf6;
  --chart-2: #0a8a5f;
  --chart-3: #b7791f;
  --chart-4: #7c5cff;
  --chart-5: #0e9dbd;
  --chart-6: #d64550;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px -4px rgba(16, 24, 40, .1), 0 2px 6px -2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .18);
  --elevation-1: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px -6px rgba(16, 24, 40, .1);
  --elevation-2: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 24px -12px rgba(16, 24, 40, .16);

  --sidebar-w: 248px;
  --topbar-h: 62px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --transition: 140ms cubic-bezier(.4, 0, .2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d1117;
  --bg-subtle: #11161f;
  --surface: #161b23;
  --surface-2: #1b212b;
  --surface-hover: #1f2630;
  --border: #262d38;
  --border-strong: #333c4a;

  --text: #e8eaee;
  --text-secondary: #aab2c0;
  --muted: #8892a3;
  --inverse: #0d1117;

  --primary: #5b86ff;
  --primary-hover: #7599ff;
  --primary-soft: #17203a;
  --primary-border: #2b3a63;

  --positive: #35c48b;
  --positive-soft: #12291f;
  --negative: #f2717c;
  --negative-soft: #2d1a1d;
  --warning: #e0a94a;
  --warning-soft: #2b2415;
  --neutral-soft: #1e242e;

  --chart-1: #5b86ff;
  --chart-2: #35c48b;
  --chart-3: #e0a94a;
  --chart-4: #a78bfa;
  --chart-5: #38bdf8;
  --chart-6: #f2717c;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 4px 16px -4px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .6);
  /* No escuro a sombra some: a elevacao vem de uma borda superior clara. */
  --elevation-1: 0 1px 2px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .035);
  --elevation-2: 0 8px 22px -12px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .05);
}

/* ----------------------------------------------------------------- BASE */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.011em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid var(--bg); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.bold { font-weight: 600; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 6px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

/* --------------------------------------------------------------- LAYOUT */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  z-index: 40;
}

.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar__logo {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--primary), #7c5cff);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
}
.sidebar__title { font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; }
.sidebar__subtitle { font-size: 10.5px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.nav-group { margin-top: 14px; }
.nav-group__label {
  padding: 6px 10px; font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: var(--transition); text-decoration: none;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav-item__badge {
  margin-left: auto; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 10px;
  background: var(--negative); color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center;
}

/* Fechar a gaveta: so existe quando a barra lateral vira gaveta (<=1024px).
   Seletor com dois niveis para vencer o `display: inline-flex` de `.btn`,
   que e declarado depois neste arquivo. */
.sidebar .sidebar__close { display: none; margin-left: auto; }

.sidebar__footer { padding: 12px 10px; border-top: 1px solid var(--border); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition); width: 100%; background: none; border: 0; text-align: left;
}
.user-chip:hover { background: var(--surface-hover); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 650; font-size: 12.5px;
}
.avatar--sm { width: 24px; height: 24px; font-size: 10.5px; }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--topbar-h); padding: 10px 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.topbar__crumb { font-size: 11.5px; color: var(--muted); }
.topbar__heading { min-width: 0; }
/* Acoes recolhidas no menu "mais" do celular: uma por linha, largura cheia.
   Paginas entregam grupos prontos (ex.: caixa de marcacao + botao); eles
   precisam poder quebrar, senao a ultima acao fica cortada na borda. */
.topbar__overflow { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.topbar__overflow > * { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
.topbar__overflow > .row > .btn,
.topbar__overflow > .row > label { flex: 1 1 100%; justify-content: flex-start; }
.topbar__overflow .segmented { width: 100%; }
.topbar__overflow .segmented__item { flex: 1; }

/* Barra inferior do celular (oculta no desktop, ver bloco responsivo). */
.tabbar { display: none; }

.content { padding: 22px 24px 56px; max-width: 1560px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head__desc { color: var(--muted); font-size: 13px; margin-top: 3px; max-width: 68ch; }

/* ----------------------------------------------------------- COMPONENTES */
/* Sombra em duas camadas: um contorno de 1px que define a borda e uma
   difusao curta que levanta o cartao — discreta o bastante para nao virar
   ruido quando a tela tem 10 cartoes. */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--elevation-1);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.card:hover { box-shadow: var(--elevation-2); }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card__title { font-size: 14px; font-weight: 620; }
.card__desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card__body { padding: 16px; }
.card__body--flush { padding: 0; }
.card__foot { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 14px; }
.grid--kpi { grid-template-columns: repeat(auto-fill, minmax(206px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* KPI */
.kpi {
  position: relative; padding: 14px 15px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--elevation-1);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  cursor: default;
}
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--elevation-2); transform: translateY(-1px); }
.kpi.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), var(--elevation-1); }
.kpi__label { font-size: 11.5px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 5px; }
.kpi__value { font-size: 23px; font-weight: 660; letter-spacing: -.02em; margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.kpi__prev { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi__hint { font-size: 11px; color: var(--muted); margin-top: 6px; font-style: italic; }
.kpi__spark { flex-shrink: 0; opacity: .8; margin-bottom: 2px; }

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 20px; font-size: 11.5px; font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.delta--positive { color: var(--positive); background: var(--positive-soft); }
.delta--negative { color: var(--negative); background: var(--negative-soft); }
.delta--neutral { color: var(--muted); background: var(--neutral-soft); }

/* Botoes */
.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: 550; cursor: pointer; transition: var(--transition);
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* `flex: none`: dentro de um botao flex o icone podia ser espremido a 2px
   quando o padding nao deixava espaco. Ele nunca deve encolher. */
.btn svg { width: 15px; height: 15px; flex: none; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-hover); }
.btn--danger { color: var(--negative); border-color: color-mix(in srgb, var(--negative) 35%, transparent); }
.btn--danger:hover { background: var(--negative-soft); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn--icon { width: 34px; padding: 0; }
.btn--icon.btn--sm { width: 28px; }
.btn--block { width: 100%; }

/* Campos */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label { font-size: 12px; font-weight: 550; color: var(--text-secondary); }
.field__hint { font-size: 11.5px; color: var(--muted); }
.field__error { font-size: 11.5px; color: var(--negative); }
.input, .select, .textarea {
  height: 34px; padding: 0 10px; width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13px;
  transition: var(--transition);
}
.textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 76px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.input::placeholder { color: var(--muted); }
.select { appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2379839a' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.input--search { padding-left: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2379839a' stroke-width='2.4'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.2-4.2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 10px center; }
/* Campo com acao interna (senha + botao de visualizacao) */
.input-wrap { position: relative; display: block; width: 100%; }
.input__reveal {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 30px; height: 28px;
  border: 0; background: none; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; transition: var(--transition);
}
.input__reveal:hover { color: var(--text); background: var(--surface-hover); }
.input__reveal.is-on { color: var(--primary); }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

.switch { position: relative; width: 38px; height: 21px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute; inset: 0; background: var(--border-strong);
  border-radius: 20px; cursor: pointer; transition: var(--transition);
}
.switch__track::before {
  content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: var(--transition);
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::before { transform: translateX(17px); }

/* Segmented */
.segmented { display: inline-flex; padding: 2px; background: var(--neutral-soft); border-radius: 8px; gap: 2px; }
.segmented__item {
  padding: 5px 11px; border-radius: 6px; border: 0; background: transparent;
  font-size: 12.5px; font-weight: 550; color: var(--text-secondary); cursor: pointer; transition: var(--transition);
}
.segmented__item:hover { color: var(--text); }
.segmented__item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
  background: var(--neutral-soft); color: var(--text-secondary); white-space: nowrap;
}
.badge--positive, .badge--EXCELENTE, .badge--completed, .badge--sent, .badge--connected, .badge--active, .badge--ENABLED { background: var(--positive-soft); color: var(--positive); }
.badge--negative, .badge--CRITICO, .badge--failed, .badge--error, .badge--REMOVED { background: var(--negative-soft); color: var(--negative); }
.badge--warning, .badge--ATENCAO, .badge--partial, .badge--retrying, .badge--PAUSED, .badge--pending { background: var(--warning-soft); color: var(--warning); }
.badge--info, .badge--BOM, .badge--running, .badge--processing, .badge--queued { background: var(--primary-soft); color: var(--primary); }
.badge--dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* Tabelas */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  position: sticky; top: 0; z-index: 1;
  padding: 9px 12px; text-align: left; font-size: 11.5px; font-weight: 600;
  color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--text); }
.table th.is-sorted { color: var(--primary); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.is-clickable { cursor: pointer; }
.table .num, .table .right { text-align: right; font-variant-numeric: tabular-nums; }
.table__entity { display: flex; flex-direction: column; gap: 2px; min-width: 180px; }
.table__entity-name { font-weight: 550; }
.table__entity-sub { font-size: 11.5px; color: var(--muted); }
.table__cmp { font-size: 10.5px; color: var(--muted); display: block; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagination__info { font-size: 12.5px; color: var(--muted); }

/* Estados */
.empty { padding: 44px 20px; text-align: center; }
.empty__icon {
  width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px;
  background: var(--neutral-soft); display: grid; place-items: center; color: var(--muted);
}
.empty__title { font-weight: 600; margin-bottom: 4px; }
.empty__desc { color: var(--muted); font-size: 13px; max-width: 46ch; margin: 0 auto 16px; }

.skeleton {
  background: linear-gradient(90deg, var(--neutral-soft) 25%, var(--surface-hover) 50%, var(--neutral-soft) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton--kpi { height: 96px; }
.skeleton--chart { height: 260px; }
.skeleton--row { height: 40px; margin-bottom: 6px; }

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--border-strong);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Filtros */
.filterbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: var(--topbar-h); z-index: 25;
}
.filterbar__group { display: flex; align-items: center; gap: 6px; }
.filterbar__divider { width: 1px; height: 22px; background: var(--border); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 20px; background: var(--surface);
  font-size: 12.5px; cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.chip:hover { background: var(--surface-hover); }
.chip.is-active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.chip__remove { display: grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: rgba(0,0,0,.08); font-size: 10px; }

/* Drawer / Modal */
.overlay {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45);
  backdrop-filter: blur(2px); z-index: 60; animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  position: fixed; z-index: 61; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.16, 1, .3, 1);
}
.modal--wide { width: min(940px, calc(100vw - 32px)); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal__body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); position: sticky; bottom: 0; }

.drawer {
  position: fixed; z-index: 61; top: 0; right: 0; height: 100vh;
  width: min(460px, 100vw); background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease;
}
@keyframes slide { from { transform: translateX(100%); } }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer__body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.drawer__foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; background: var(--surface-2); }

/* Toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
/* A severidade e sinalizada pelo mesmo chip colorido usado em .insight,
   mantendo um unico vocabulario visual de status em todo o produto. */
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } }
.toast__icon {
  width: 24px; height: 24px; border-radius: 7px; flex: none;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.toast--success .toast__icon { background: var(--positive-soft); color: var(--positive); }
.toast--error .toast__icon { background: var(--negative-soft); color: var(--negative); }
.toast--warning .toast__icon { background: var(--warning-soft); color: var(--warning); }
.toast__title { font-weight: 600; font-size: 13px; }
.toast__body { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }

/* Popover */
.popover {
  position: absolute; z-index: 62; min-width: 240px; max-height: 420px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s ease;
}
.popover__item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px;
  border: 0; background: none; border-radius: var(--radius-sm); font-size: 13px;
  cursor: pointer; text-align: left; color: var(--text); transition: var(--transition);
}
.popover__item:hover { background: var(--surface-hover); }
.popover__item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 550; }
.popover__label { padding: 8px 10px 4px; font-size: 10.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.popover__sep { height: 1px; background: var(--border); margin: 5px 0; }

/* Graficos */
.chart { width: 100%; display: block; overflow: visible; }
.chart__tooltip {
  position: fixed; z-index: 70; pointer-events: none; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  box-shadow: var(--shadow); font-size: 12px; min-width: 130px;
}
.chart__tooltip-title { font-weight: 620; margin-bottom: 4px; font-size: 11.5px; }
.chart__tooltip-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.chart-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.chart-legend__item { display: flex; align-items: center; gap: 6px; }
.chart-legend__swatch { width: 9px; height: 9px; border-radius: 3px; }

/* As barras preenchem 100% e sao escaladas no eixo X: anima na camada de
   composicao (sem recalculo de layout). O arredondamento vem do track, que
   recorta o preenchimento. */
.progress { height: 6px; background: var(--neutral-soft); border-radius: 4px; overflow: hidden; }
.progress__bar {
  height: 100%; width: 100%; background: var(--primary);
  transform-origin: left center; transform: scaleX(0);
  transition: transform .3s cubic-bezier(.16, 1, .3, 1);
}

.bar-row { display: grid; grid-template-columns: minmax(120px, 1.5fr) 3fr auto; align-items: center; gap: 10px; padding: 6px 0; }
.bar-track { height: 8px; background: var(--neutral-soft); border-radius: 5px; overflow: hidden; }
.bar-fill {
  height: 100%; width: 100%;
  transform-origin: left center; transform: scaleX(0);
  transition: transform .4s cubic-bezier(.16, 1, .3, 1);
}

/* Resumo executivo */
.insight {
  display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
}
.insight__icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; font-size: 13px; }
.insight--positive .insight__icon { background: var(--positive-soft); color: var(--positive); }
.insight--negative .insight__icon { background: var(--negative-soft); color: var(--negative); }
.insight--warning .insight__icon { background: var(--warning-soft); color: var(--warning); }
.insight--info .insight__icon { background: var(--primary-soft); color: var(--primary); }
.insight__text { font-size: 13px; line-height: 1.55; }

.narrative {
  font-size: 14.5px; line-height: 1.65; color: var(--text);
  padding: 16px 18px; background: var(--primary-soft); border-radius: var(--radius);
  border: 1px solid var(--primary-border);
}

/* ============================================================== LOGIN */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--bg);
}

/* Painel de apresentacao: azul profundo com um halo suave, no lugar do
   degrade saturado anterior. */
.auth__aside {
  position: relative; overflow: hidden;
  background: linear-gradient(155deg, #0a1633 0%, #132650 52%, #1b2f66 100%);
  color: #fff; display: flex; align-items: center;
}
/* Profundidade vem de duas fontes de luz suaves, nao de textura aplicada:
   um halo azul no alto (cor da marca) e um contraluz frio na base. */
.auth__aside::after {
  content: ""; position: absolute; pointer-events: none;
  width: 420px; height: 420px; border-radius: 50%;
  bottom: -200px; left: -120px;
  background: radial-gradient(circle, rgba(52, 168, 83, .18) 0%, rgba(52, 168, 83, 0) 70%);
}
.auth__glow {
  position: absolute; width: 460px; height: 460px; border-radius: 50%;
  top: -130px; right: -150px; pointer-events: none;
  background: radial-gradient(circle, rgba(66, 133, 244, .4) 0%, rgba(66, 133, 244, 0) 70%);
}
.auth__aside-inner {
  position: relative; z-index: 1;
  padding: 56px clamp(36px, 5vw, 72px);
  display: flex; flex-direction: column; gap: 40px; width: 100%;
}
.auth__brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.auth__brand-tag { font-size: 11.5px; color: #8fa6d8; }
.auth__hero {
  font-size: clamp(26px, 3vw, 36px); line-height: 1.2; font-weight: 660;
  letter-spacing: -.025em; max-width: 17ch; color: #ffffff;
}
.auth__hero-sub { margin-top: 14px; font-size: 14px; color: #9fb3dd; max-width: 40ch; line-height: 1.6; }
.auth__features { display: flex; flex-direction: column; gap: 18px; }
.auth__feature { display: flex; gap: 13px; align-items: flex-start; }
.auth__feature-icon {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center; color: #bcd0ff;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .09);
}
.auth__feature-title { font-size: 13.5px; font-weight: 600; }
.auth__feature-desc { font-size: 12.5px; color: #8ea4cf; line-height: 1.55; margin-top: 2px; max-width: 46ch; }
.auth__trust { font-size: 11.5px; color: #7186b0; letter-spacing: .01em; }

/* Coluna do formulario */
.auth__form {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 32px 24px;
}
.auth__box { width: min(392px, 100%); display: flex; flex-direction: column; gap: 15px; }
.auth__title { font-size: 25px; letter-spacing: -.022em; }
.auth__submit { height: 42px; font-size: 14px; font-weight: 600; }
.auth__error {
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12.5px;
  background: var(--negative-soft); color: var(--negative);
  border: 1px solid color-mix(in srgb, var(--negative) 25%, transparent);
}

/* Seletor de idioma: bandeira + sigla, fixo no topo da coluna. */
.auth__lang {
  position: absolute; top: 22px; right: 24px;
  display: flex; align-items: center; gap: 9px;
}
.auth__lang-label { font-size: 11.5px; color: var(--muted); }
.auth__lang-group {
  display: flex; gap: 2px; padding: 3px;
  background: var(--neutral-soft); border-radius: 9px;
}
.auth__lang-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 9px; border: 0; border-radius: 7px; background: transparent;
  font-size: 11.5px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; transition: var(--transition);
}
.auth__lang-btn:hover { color: var(--text); }
.auth__lang-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth__lang-flag { font-size: 14px; line-height: 1; }
.auth__lang-code { letter-spacing: .04em; }

/* Contas de demonstracao */
.auth__demo {
  padding: 13px 14px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
}
.auth__demo-title { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.auth__demo-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 8px; margin: 0 -8px; border: 0; background: none;
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  color: var(--text); transition: var(--transition);
}
.auth__demo-row:hover { background: var(--surface-hover); }
.auth__demo-row svg { margin-left: auto; color: var(--muted); }
.auth__demo-role { font-size: 12.5px; font-weight: 550; min-width: 92px; }
.auth__demo-mail { font-size: 11.5px; color: var(--muted); }

.auth__signup {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
}

.auth__plans-link {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 9px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 12.5px; font-weight: 550; font-family: inherit;
  border-radius: var(--radius-sm); transition: var(--transition);
}
.auth__plans-link:hover { color: var(--primary); background: var(--primary-soft); }

/* ------------------------------------------------------------- PLANOS */
.plans-page { min-height: 100dvh; background: var(--bg); }
.plans-page__head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.plans-page__brand {
  display: flex; align-items: center; gap: 10px; border: 0; background: none;
  cursor: pointer; font: inherit; font-weight: 650; color: var(--text); padding: 0;
}
.plans-page__body { max-width: 1180px; margin: 0 auto; padding: 40px 20px 64px; }
.plans-page__intro { text-align: center; max-width: 60ch; margin: 0 auto 32px; }
.plans-page__title { font-size: 32px; font-weight: 680; letter-spacing: -.03em; }
.plans-page__lead { margin-top: 10px; color: var(--text-secondary); font-size: 15px; line-height: 1.55; }

.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px; }

.plan-card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 22px 20px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--elevation-1);
}
/* O plano sugerido ganha contorno, nao um cartao maior: a comparacao entre
   colunas continua honesta e o olho ainda sabe onde parar. */
.plan-card.is-featured { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), var(--elevation-2); }
.plan-card.is-current { border-color: var(--positive); }
.plan-card__tag {
  position: absolute; top: -10px; left: 20px;
  padding: 3px 10px; border-radius: 20px; background: var(--primary); color: #fff;
  font-size: 10.5px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
}
.plan-card__name { font-size: 15px; font-weight: 660; }
.plan-card__pitch { font-size: 12.5px; color: var(--muted); line-height: 1.45; min-height: 34px; }
.plan-card__price { display: flex; align-items: baseline; gap: 5px; margin-top: 4px; }
.plan-card__amount { font-size: 28px; font-weight: 680; letter-spacing: -.03em; }
.plan-card__period { font-size: 12.5px; color: var(--muted); }
.plan-card__trial { font-size: 12px; font-weight: 600; color: var(--positive); }
.plan-card__trial--muted { color: var(--muted); font-weight: 550; }
.plan-card__features { list-style: none; display: flex; flex-direction: column; gap: 7px; margin: 6px 0 4px; padding: 0; }
.plan-card__features li { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; line-height: 1.45; }
.plan-card__features svg { color: var(--positive); flex: none; margin-top: 2px; }
.plan-card__features li:last-child { color: var(--muted); }
.plan-card__note { font-size: 11px; color: var(--muted); text-align: center; }

/* Seletor de moeda — mesmo idioma visual do seletor de idioma da tela de login. */
.currency-switcher { display: inline-flex; gap: 2px; padding: 3px; background: var(--neutral-soft); border-radius: 9px; }
.currency-switcher__btn {
  padding: 5px 11px; border: 0; border-radius: 7px; background: transparent;
  font-size: 12px; font-weight: 650; letter-spacing: .02em; color: var(--text-secondary);
  cursor: pointer; transition: var(--transition);
}
.currency-switcher__btn:hover { color: var(--text); }
.currency-switcher__btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.plan-card .btn { margin-top: auto; }

/* Medidores de uso do plano dentro do app */
.usage-meter { display: flex; flex-direction: column; gap: 6px; }
.usage-meter__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.usage-meter__value { font-variant-numeric: tabular-nums; color: var(--muted); }
.usage-meter__track { height: 6px; border-radius: 3px; background: var(--neutral-soft); overflow: hidden; }
.usage-meter__fill {
  height: 100%; border-radius: 3px; background: var(--primary);
  transform-origin: left; transition: transform .3s cubic-bezier(.16, 1, .3, 1);
}
.usage-meter__fill--full { background: var(--negative); }

/* Selecao de perfil no cadastro */
.auth__role-card {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 12px 13px; border-radius: var(--radius); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); transition: var(--transition);
}
.auth__role-card:hover { border-color: var(--border-strong); }
.auth__role-card.is-active { border-color: var(--primary); background: var(--primary-soft); }
.auth__role-title { font-size: 13px; font-weight: 650; }
.auth__role-desc { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

.auth__mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth__mobile-name { font-weight: 650; font-size: 15px; }

.steps { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.step__dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--neutral-soft); font-size: 11px; font-weight: 650; }
.step.is-active { color: var(--primary); font-weight: 600; }
.step.is-active .step__dot { background: var(--primary); color: #fff; }
.step.is-done .step__dot { background: var(--positive-soft); color: var(--positive); }

/* Status bar (offline / sync) */
.statusline { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.statusline__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); flex: none; }
.statusline__dot--offline { background: var(--warning); }
.statusline__dot--syncing { background: var(--primary); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.offline-banner {
  display: flex; align-items: center; gap: 10px; padding: 9px 24px;
  background: var(--warning-soft); color: var(--warning); font-size: 12.5px; font-weight: 550;
  border-bottom: 1px solid color-mix(in srgb, var(--warning) 25%, transparent);
}

/* Aviso de cobranca pendente, fixo logo abaixo do cabecalho. */
.due-banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 24px;
  background: var(--negative-soft); color: var(--negative);
  border-bottom: 1px solid color-mix(in srgb, var(--negative) 25%, transparent);
}
.due-banner__text { flex: 1; min-width: 0; font-size: 12.5px; }
.due-banner__text strong { font-weight: 650; }
.due-banner__extra { margin-left: 6px; opacity: .85; }
.due-banner__action {
  flex-shrink: 0; background: var(--negative); border-color: var(--negative); color: #fff;
}
.due-banner__action:hover { background: color-mix(in srgb, var(--negative) 85%, black); }

.demo-tag {
  flex-shrink: 0; padding: 1px 6px; border-radius: 4px;
  background: var(--warning-soft); color: var(--warning);
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}

/* Popup de instalacao do PWA (mobile) */
.install-banner {
  position: fixed; top: 12px; right: 12px; z-index: 60;
  display: flex; align-items: flex-start; gap: 10px;
  max-width: min(320px, calc(100vw - 24px));
  padding: 12px 12px 12px 14px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.install-banner__icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 30px; height: 30px; border-radius: var(--radius); color: var(--primary); background: var(--primary-soft);
}
.install-banner__body { flex: 1; min-width: 0; }
.install-banner__title { font-size: 12.5px; font-weight: 650; }
.install-banner__desc { font-size: 11.5px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.install-banner__close { flex-shrink: 0; margin: -4px -4px 0 0; }

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 34px 20px; text-align: center; transition: var(--transition); cursor: pointer;
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--primary); background: var(--primary-soft); }

.mapping-row { display: grid; grid-template-columns: 1fr 24px 1fr; align-items: center; gap: 10px; padding: 6px 0; }

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline__item { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline__item::before { content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 1px; background: var(--border); }
.timeline__item:last-child::before { display: none; }
.timeline__dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--neutral-soft); font-size: 10px; z-index: 1; }

/* --------------------------------------------------------------- RESPONSIVO */
@media (max-width: 1180px) {
  .content { padding: 18px 16px 48px; }
  .topbar, .filterbar { padding-left: 16px; padding-right: 16px; }
}

/* ---------------------------------------------- GAVETA (tablet e celular) */
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 45;
    width: min(304px, 86vw); height: 100dvh;
    padding-left: env(safe-area-inset-left);
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.16, 1, .3, 1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar .sidebar__close { display: inline-flex; }
  .sidebar__brand { padding-right: 10px; }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 44;
    background: rgba(16, 24, 40, .45);
    backdrop-filter: blur(2px);
  }
  /* Trava o fundo: sem isso a pagina desliza atras da gaveta aberta. */
  body.has-drawer-open { overflow: hidden; }

  .menu-toggle { display: inline-flex !important; }
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .auth__mobile-brand { display: flex; }
  .auth__lang { position: static; justify-content: flex-end; width: min(392px, 100%); margin-bottom: 18px; }
}

/* Alvos de toque maiores onde o dedo e o ponteiro (nao depende da largura). */
@media (pointer: coarse) {
  .nav-item { padding: 11px 10px; font-size: 14.5px; }
  .btn { height: 40px; padding: 0 15px; }
  .btn--sm { height: 34px; }
  /* Botoes de icone nao levam padding lateral: a largura fixa ja e o alvo. */
  .btn--icon { width: 40px; padding: 0; }
  .btn--icon.btn--sm { width: 36px; padding: 0; }
  .chip { height: 36px; padding: 0 13px; font-size: 13px; }
  .segmented__item { min-height: 32px; }
  .popover__item { padding: 11px 12px; }
  .user-chip { padding: 11px 8px; }
}

/* ------------------------------------------------------------- CELULAR */
@media (max-width: 720px) {
  /* Cabecalho em uma unica linha: era ate 145px empilhado, agora 56px fixos. */
  :root { --topbar-h: 56px; }
  .topbar {
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    min-height: 0; padding: env(safe-area-inset-top) 8px 0 4px;
    gap: 4px; flex-wrap: nowrap;
  }
  .topbar__title { font-size: 15.5px; }
  .topbar__actions { flex-shrink: 0; gap: 2px; }

  .filterbar {
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
    padding: 8px 14px; gap: 6px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .filterbar::-webkit-scrollbar { display: none; }
  .filterbar > * { flex-shrink: 0; }
  .filterbar .select { max-width: 46vw; }
  /* Some quando a barra chega ao fim (classe aplicada no scroll). */
  .filterbar:not(.is-scroll-end) {
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
  }

  .content { padding: 16px 14px 32px; }
  .grid { gap: 12px; }
  .grid--kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi__value { font-size: 20px; margin-top: 3px; }
  .kpi__label { font-size: 11px; }
  .kpi__hint { font-size: 10.5px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .modal { width: calc(100vw - 20px); max-height: calc(100dvh - 32px); }
  .drawer { width: 100vw; }
  .toasts { left: 12px; right: 12px; bottom: calc(12px + var(--tabbar-space, 0px)); max-width: none; }
  .install-banner { top: calc(var(--topbar-h) + env(safe-area-inset-top) + 8px); }

  /* ------------------------------------------ barra inferior de destinos */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar.hidden { display: none; }
  .tabbar__item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; min-height: 54px; padding: 7px 2px 6px;
    color: var(--muted); text-decoration: none; font-weight: 550;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--transition);
  }
  .tabbar__item:active { background: var(--surface-hover); }
  .tabbar__item.is-active { color: var(--primary); }
  .tabbar__icon { position: relative; display: grid; place-items: center; }
  .tabbar__label {
    font-size: 10.5px; letter-spacing: -.01em; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .tabbar__dot {
    position: absolute; top: -1px; right: -3px; width: 7px; height: 7px;
    border-radius: 50%; background: var(--negative);
    border: 1.5px solid var(--surface);
  }
  /* Reserva o espaco da barra para nada ficar escondido atras dela. */
  body.has-tabbar { --tabbar-space: calc(54px + env(safe-area-inset-bottom)); }
  body.has-tabbar .content { padding-bottom: calc(24px + var(--tabbar-space)); }

  /* Tabelas viram cartoes empilhados.
     `minmax(0, 1fr)` e obrigatorio: com `1fr` puro as colunas nao encolhem
     abaixo do conteudo e a tabela vaza, obrigando a rolar de lado dentro do
     cartao — os valores da direita ficavam cortados. */
  .table-wrap:has(.table--responsive) { overflow-x: visible; }
  .table--responsive { min-width: 0; width: 100%; }
  .table--responsive thead { display: none; }
  .table--responsive tbody tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
  }
  .table--responsive td {
    border: 0; padding: 2px 0; min-width: 0;
    display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  }
  .table--responsive td::before {
    content: attr(data-label); font-size: 11px; color: var(--muted); font-weight: 550;
    flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .table--responsive td > * { min-width: 0; }
  .table--responsive td:first-child {
    grid-column: 1 / -1; font-weight: 600; display: block;
  }
  .table--responsive td:first-child::before { display: none; }
}

/* Celular deitado: a tela e baixa e as barras fixas comiam 44% da altura.
   A barra inferior sai (o menu continua no cabecalho) e os filtros deixam de
   grudar, devolvendo o espaco a leitura dos dados. */
@media (max-width: 926px) and (max-height: 480px) {
  .tabbar { display: none !important; }
  body.has-tabbar { --tabbar-space: 0px; }
  body.has-tabbar .content { padding-bottom: 24px; }
  .filterbar { position: static; }
}

@media print {
  .sidebar, .topbar, .filterbar, .toasts, .btn { display: none !important; }
  .content { padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}
