/* desktop.css — layouts desktop (AdminShell, tabelas densas, vitrine, login,
   relatório A4). Traduzido das telas desktop dos protótipos fabricante.jsx /
   representante.jsx / relatorio.jsx. */

/* ── Login / register ────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--canvas); padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 32px;
  box-shadow: 0 30px 80px -30px rgba(20,20,20,0.18);
}
.brand { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.brand__mark {
  width: 26px; height: 26px; border-radius: 6px; background: var(--chrome); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 16px; font-style: italic;
}
.brand__name { font-size: 13px; font-weight: 500; letter-spacing: -0.2px; }
.brand__sub { font-family: var(--mono); font-size: 9px; color: var(--faint); letter-spacing: 0.5px; }
.auth-title { font-size: 22px; font-weight: 500; letter-spacing: -0.5px; margin: 0 0 4px; }
.auth-sub { font-size: 13px; color: var(--muted); margin: 0 0 22px; }
.auth-card .field { margin-bottom: 14px; }
.auth-error {
  background: var(--err-soft); color: var(--err); border-radius: 8px;
  padding: 10px 12px; font-size: 12px; margin-bottom: 14px;
}

/* ── AdminShell (sidebar + main) ─────────────────────────────── */
.shell { display: flex; min-height: 100vh; background: var(--surface); }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--chrome); color: var(--chrome-ink);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.sidebar__brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 22px; }
.sidebar .brand__mark { background: #fff; color: var(--chrome); }
.sidebar .brand__name { color: #fff; }
.sidebar .brand__sub { color: rgba(255,255,255,.45); }
.sidebar .eyebrow { color: rgba(255,255,255,.4); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; color: rgba(255,255,255,.72);
  font-size: 14px; cursor: pointer;
}
.nav__item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav__item.is-active {
  background: rgba(255,255,255,.14); color: #fff; font-weight: 500;
  box-shadow: none;
}
.sidebar__user {
  margin-top: auto; padding: 10px; border-radius: 10px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: 10px; color: #fff;
}
.avatar {
  width: 28px; height: 28px; border-radius: 99px; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.sidebar__user .btn--ghost { color: #fff; border-color: rgba(255,255,255,.22); }
.sidebar__user .btn--ghost:hover:not(:disabled) { background: rgba(255,255,255,.12); }

/* Topbar mobile + drawer: escondidos no desktop; ativados nos breakpoints abaixo. */
.mtopbar { display: none; }
.nav-overlay { display: none; }
.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  background: rgba(255,255,255,.12); color: #fff; border: 0;
}
.nav-toggle svg { width: 22px; height: 22px; }

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

/* Topbar CLARA — devolve o peso visual ao conteúdo (1 só superfície escura: a sidebar).
   Os átomos base (.eyebrow, .btn--ghost/primary, .tab) já são feitos p/ fundo claro,
   então aqui só definimos o container; os overrides "brancos" antigos foram removidos. */
.topbar {
  padding: 18px 28px;
  display: flex; align-items: flex-end; justify-content: space-between;
  background: var(--surface); color: var(--ink);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: var(--z-sticky);
}
.topbar__title { font-size: var(--fs-xl); font-weight: 500; letter-spacing: -0.5px; margin-top: 4px; color: var(--ink); }
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.live-pill {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  padding: 6px 10px; border: 1px solid var(--hairline); border-radius: 99px; background: var(--inset);
}
.main { background: var(--surface); }
.content { padding: 28px; display: flex; flex-direction: column; gap: 28px; }

/* ── KPIs ────────────────────────────────────────────────────── */
/* Cada .kpi é um cartão; a grade não tem borda/padding próprio.
   Estrutura no HTML: rótulo = .eyebrow, valor = .kpi__v (vide fabricante.html
   /representante.html/dashboard BI — todos injetam via renderKpis). */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
/* Valor. */
.kpi__v {
  font-size: clamp(20px, 2vw, 26px); font-weight: 600; letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere; margin: 0;
}
.kpi--warn .kpi__v { color: var(--warn); }
/* Rótulo: .eyebrow é o átomo compartilhado; ajuste só dentro do cartão. */
.kpi .eyebrow { font-size: 11px; letter-spacing: 0.6px; color: var(--faint); }
.kpi__d { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
/* Breakpoints do grid de KPIs (cartões): 4 → 2 → 1 coluna. */
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .kpi-grid { grid-template-columns: 1fr; } }

/* ── Dashboard executivo ─────────────────────────────────────── */
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dash-title { font-size: 30px; font-weight: 600; letter-spacing: -0.6px; margin-top: 2px; }
.dash-periodo { display: flex; gap: 6px; flex-shrink: 0; }
.dash-row { display: grid; grid-template-columns: 1.5fr 1fr; gap: 32px; align-items: start; }
.dash-row > * + * { border-left: 1px solid var(--hairline); padding-left: 32px; }
/* Coluna do par vazia: colapsa p/ uma só coluna (sem buraco). */
.dash-row--solo { grid-template-columns: 1fr; }
.dash-panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dash-panel__head strong { font-size: 17px; font-weight: 600; }

.delta { font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 3px; }
.delta--up { color: var(--ok); }
.delta--down { color: var(--err); }

/* Barras de reservas por dia. */
.barchart { display: flex; align-items: flex-end; gap: 3px; height: 260px; }
.bar { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.bar__fill { width: 100%; background: var(--inset); border-radius: 3px 3px 0 0; min-height: 2px; transition: height .25s ease; }
.bar__fill--now { background: var(--accent); }
.bar:hover .bar__fill { filter: brightness(0.94); }

/* Donut de situação (conic-gradient + furo central). */
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut { width: 176px; height: 176px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.donut__hole { width: 112px; height: 112px; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut__num { font-size: 40px; font-weight: 600; letter-spacing: -0.5px; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; flex: 1 1 160px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.donut-legend .rank__num { margin-left: auto; font-weight: 600; font-size: 16px; }

/* Rankings (lojistas / representantes). */
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank__item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--hairline); }
.rank__item:first-child { border-top: 0; }
/* Empty-state ocupando a largura do ranking (sem marcador/borda de item). */
.rank__empty { list-style: none; }
.rank__empty .empty-state { padding: 24px 16px; }
.rank__pos { font-family: var(--mono); font-size: 12px; color: var(--faint); width: 18px; flex-shrink: 0; }
.rank__avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.rank__info { flex: 1 1 auto; min-width: 0; }
.rank__name { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.rank__bar { height: 4px; background: var(--inset); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.rank__bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.rank__metric { text-align: right; flex-shrink: 0; }
.rank__count { font-size: 19px; font-weight: 600; }

/* Grid de modelos mais reservados (tiles achatados, sem borda). */
.model-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.model-card { background: var(--panel); border: 0; border-radius: 12px; padding: 16px; }
.model-card__name { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.model-card__count { margin-top: 8px; font-size: 14px; font-weight: 500; color: var(--accent); }

/* KPI com destaque de atenção (ex.: "A definir valor") — sem caixa, só cor. */
.kpi--warn { background: transparent; }

/* Painel "Sua atenção". */
.atencao { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.atencao__item { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--hairline); }
.atencao__item:first-child { border-top: 0; }
.atencao__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.atencao__t { font-size: 14px; font-weight: 500; }

/* ── Insights do Lojista (mobile-first, sem valores) ─────────── */
.insights { max-width: 620px; margin: 0 auto; width: 100%; }
.hero { background: var(--chrome); color: #fff; border-radius: 16px; padding: 22px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, rgba(31,111,74,.55), transparent 70%); }
.hero__num { font-family: var(--serif); font-size: clamp(32px, 8vw, 52px); line-height: 1; margin: 8px 0 12px; }
.hero__msg { font-size: 14px; color: rgba(255,255,255,.85); max-width: 280px; }
.hero__delta { display: inline-flex; margin-top: 14px; font-size: 12px; font-weight: 500; padding: 5px 10px; border-radius: 99px; background: rgba(255,255,255,.12); }
.hero__delta--up { color: var(--hero-delta-up); }
.hero__delta--down { color: var(--hero-delta-down); }

.ins-status { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ins-card { background: var(--surface); border: 1px solid var(--hairline); border-top: 3px solid var(--accent); border-radius: 10px; padding: 14px; }
.ins-card__num { font-size: 26px; font-weight: 600; letter-spacing: -0.5px; }

.ins-badge { display: flex; align-items: center; gap: 14px; background: var(--accent); color: #fff; border-radius: 14px; padding: 16px 18px; }
.ins-badge--soft { background: var(--accent-soft); color: var(--accent); }
.ins-badge__icon { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; background: rgba(255,255,255,.18); }
.ins-badge--soft .ins-badge__icon { background: #fff; }
.ins-badge__t { font-size: 15px; font-weight: 600; }

.ins-hist { display: flex; align-items: flex-end; gap: 10px; height: 150px; }
.ins-hist__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.ins-hist__val { font-size: 13px; font-weight: 600; }
.ins-hist__bar { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.ins-hist__fill { width: 100%; background: var(--inset); border-radius: 4px 4px 0 0; min-height: 3px; }
.ins-hist__fill--now { background: var(--accent); }

.rank--compact .rank__item { padding: 8px 0; }
.ins-tags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ins-tags li { display: flex; align-items: center; gap: 8px; }

.ins-cta { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--accent-soft); color: var(--accent); border-radius: 12px; padding: 16px 18px; font-weight: 500; }
.ins-cta:hover { filter: brightness(0.98); }

/* ── Tabelas densas ──────────────────────────────────────────── */
.panel { background: transparent; border: 0; border-radius: 0; overflow: visible; }
.panel__head {
  padding: 0 0 14px; border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between;
}
.panel__title { font-size: 15px; font-weight: 600; }

.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtable thead th {
  text-align: left; padding: 10px 16px; background: transparent;
  font-family: var(--mono); font-size: 10px; color: var(--faint);
  letter-spacing: 1px; text-transform: uppercase; font-weight: 500;
  border-bottom: 1px solid var(--hairline);
}
.dtable tbody td { padding: 13px 16px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
/* Bordas externas flush (alinham com o título do painel, que é flush-left);
   o respiro de 16px vai p/ o miolo, separando as colunas (antes coladas). */
.dtable thead th:first-child, .dtable tbody td:first-child { padding-left: 0; }
.dtable thead th:last-child,  .dtable tbody td:last-child  { padding-right: 0; }
.dtable tbody tr:last-child td { border-bottom: 0; }
.dtable tbody tr:hover td { background: var(--panel); }
.dtable .num { text-align: right; font-family: var(--mono); font-size: 12px; }
.dtable .sku { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 99px; border: 1px solid var(--hairline); display: inline-block; vertical-align: middle; margin-right: 8px; }
.thumb { width: 36px; height: 36px; border-radius: 6px; overflow: hidden; background: var(--inset); object-fit: cover; }

/* Densidade compacta (toggle persistido em body.dense). */
.dense .dtable thead th { padding-top: 6px; padding-bottom: 6px; }
.dense .dtable tbody td { padding-top: 7px; padding-bottom: 7px; }

/* Cabeçalho ordenável (texto). Indicador via ::after — ↕ neutro, ↑/↓ ativo. */
.dtable thead th.sortable { cursor: pointer; padding-right: 16px; position: relative; user-select: none; }
.dtable thead th.sortable::after { content: "↕"; position: absolute; right: 3px; opacity: .35; }
.dtable thead th.sortable:hover::after { opacity: .7; }
.dtable thead th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dtable thead th[aria-sort="ascending"]::after  { content: "↑"; opacity: 1; }
.dtable thead th[aria-sort="descending"]::after { content: "↓"; opacity: 1; }

/* ── Filtros / busca ─────────────────────────────────────────── */
.toolbar { display: flex; gap: 8px; align-items: center; }
.search {
  flex: 1; max-width: 340px; height: 36px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 6px; padding: 0 12px;
}
.search input { border: 0; outline: 0; background: transparent; flex: 1; font-size: 13px; font-family: var(--sans); }
/* Foco visível: o input some o outline próprio, então o anel vai no container
   (WCAG 2.4.7 — usuário de teclado precisa ver onde está). */
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Abas ────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 28px; padding: 0 28px; border-bottom: 1px solid var(--hairline); background: var(--surface); }
.tab {
  padding: 14px 0; font-size: 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.is-active { color: var(--ink); font-weight: 500; border-bottom-color: var(--ink); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── Grid de 2 colunas (carteira / dashboard) ────────────────── */
.split { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.split--wide { grid-template-columns: 1.4fr 1fr; }
/* Coluna lateral (lista de lojistas) com scroll independente. */
.split > .panel:last-child { position: sticky; top: 88px; max-height: calc(100dvh - 120px); overflow: auto; }
/* Lojista selecionado dentro da lista (panel branco, não a sidebar escura). */
#lojistas-list .nav__item.is-active {
  background: var(--accent-soft); color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Card escuro de convite */
.invite-card { background: var(--chrome); color: #fff; border-radius: var(--r-md); padding: 18px; }
.invite-card .eyebrow { color: rgba(255,255,255,0.45); }
.invite-link {
  margin-top: 12px; padding: 10px 12px; border-radius: 6px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12);
  font-family: var(--mono); font-size: 11px; color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.invite-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-link button { background: none; border: 0; color: rgba(255,255,255,0.7); cursor: pointer; font-size: 11px; }

/* ── Vitrine (Lojista) — grade de cards desktop ──────────────── */
.vitrine-grid {
  display: flex; flex-direction: column; gap: 10px;
}

/* Toolbar de busca + filtro por tipo. */
.vitrine-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
}
.vitrine-toolbar .input { max-width: 420px; flex: 1 1 260px; }
.vitrine-filtros { display: flex; flex-wrap: wrap; gap: 8px; }
.chip--filter {
  cursor: pointer; appearance: none; font-family: var(--sans);
  background: var(--surface); border: 1px solid var(--rule); color: var(--ink2);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chip--filter:hover { background: var(--inset); }
.chip--filter.is-active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ── Acordeão por modelo ─────────────────────────────────────── */
.model-acc { display: flex; flex-direction: column; gap: 12px; }
.model-group {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-1);
}
.model-group__head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; cursor: pointer; background: transparent;
  border: none; text-align: left; font: inherit; color: var(--ink);
}
.model-group__head:hover { background: var(--inset); }
.model-group__chevron { color: var(--muted); transition: transform .18s ease; }
.model-group.is-open .model-group__chevron { transform: rotate(90deg); }
.model-group__title { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.model-group__count { margin-left: auto; font-size: 13px; color: var(--muted); }
.model-group__body { padding: 0 14px 14px; }

/* Acordeão dentro de tabela (estoque do fabricante) */
.est-group { cursor: pointer; background: var(--inset); }
.est-group:hover { background: var(--hairline); }
.est-group__chevron { display: inline-block; color: var(--muted); margin-right: 8px; transition: transform .18s ease; }
.est-group.is-open .est-group__chevron { transform: rotate(90deg); }
.prod-card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; overflow: hidden; display: flex; flex-direction: row;
  align-items: center; gap: 12px; padding: 8px 12px 8px 8px;
  transition: opacity .35s ease, transform .35s ease, box-shadow .15s ease;
}
.prod-card:hover { box-shadow: var(--sh-2); }
.prod-card.is-leaving { opacity: 0; transform: scale(0.96); pointer-events: none; }
.prod-card__img {
  flex: 0 0 64px; width: 64px; aspect-ratio: 1/1;
  border-radius: 10px; overflow: hidden; background: var(--inset);
}
.prod-card__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prod-card__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.prod-card__title { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.prod-card__meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod-card__cta { flex: 0 0 auto; }

.empty {
  padding: 60px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--rule); border-radius: 12px; background: var(--surface);
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(14,14,12,0.4);
  display: flex; align-items: center; justify-content: center; z-index: var(--z-modal); padding: 24px;
}
.modal { background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 440px; padding: 24px; box-shadow: var(--sh-3); }
.modal__title { font-size: 18px; font-weight: 500; letter-spacing: -0.3px; margin: 0 0 4px; }
.modal__sub { font-size: 13px; color: var(--muted); margin: 0 0 18px; }
.modal__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Side-sheet (drawer de detalhe à direita, sem sair da página) ─ */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(14,14,12,0.4);
  z-index: var(--z-drawer); opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; top: 0; right: 0; height: 100dvh;
  width: 100%; max-width: 420px;
  background: var(--surface); border-left: 1px solid var(--hairline);
  box-shadow: var(--sh-3); z-index: var(--z-drawer);
  display: flex; flex-direction: column;
  transform: translateX(100%); pointer-events: none;
  transition: transform .24s ease;
}
.sheet.is-open { transform: none; pointer-events: auto; }
.sheet__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px; border-bottom: 1px solid var(--hairline); flex-shrink: 0;
}
.sheet__title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.3px; }
.sheet__sub { font-family: var(--mono); font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.sheet__close {
  background: transparent; border: 1px solid var(--rule); border-radius: var(--r-sm);
  width: 30px; height: 30px; flex-shrink: 0; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.sheet__close:hover { background: var(--inset); color: var(--ink); }
.sheet__body { padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.sheet__section { display: flex; flex-direction: column; gap: 9px; }
.sheet__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--fs-base); }
.sheet__row dt { color: var(--muted); margin: 0; }
.sheet__row dd { margin: 0; font-weight: 500; text-align: right; }

/* Linha de estoque clicável (abre o detalhe). */
.est-unit { cursor: pointer; }

/* Barra de ações em massa + checkboxes de seleção (reservas). */
.bulkbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 14px;
  background: var(--accent-soft); border-radius: var(--r-md);
  font-size: 13px; color: var(--accent);
}
.bulkbar__count b { font-weight: 600; }
.dtable .rsel, #rsel-all {
  width: 15px; height: 15px; cursor: pointer; margin: 0;
  accent-color: var(--accent); vertical-align: middle;
}

/* ── Responsivo ──────────────────────────────────────────────────
   ≥1024px  desktop (sidebar fixa)
   ≤1023px  tablet/celular: sidebar vira drawer off-canvas + topbar mobile
   ≤768px   celular: 1 coluna, tabelas em cartões, toque ampliado
   ──────────────────────────────────────────────────────────────── */

/* Drawer + topbar mobile (tablet e celular). */
@media (max-width: 1023px) {
  .mtopbar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; background: var(--chrome); color: #fff;
    position: sticky; top: 0; z-index: 60;
  }
  .mtopbar__logo { height: 26px; width: auto; background: #fff; padding: 4px 8px; border-radius: 8px; }

  .shell { flex-direction: column; }

  /* Sidebar off-canvas: desliza da esquerda; preserva seções/eyebrows
     e o rodapé de usuário (tema/logout) — diferente da antiga barra horizontal. */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; width: min(82vw, 300px);
    flex-direction: column; padding: 18px 14px; overflow-y: auto;
    transform: translateX(-100%); transition: transform .25s ease;
    z-index: 900; box-shadow: var(--shadow-modal);
  }
  .sidebar.is-open { transform: none; }
  .nav__item { padding: 12px 14px; min-height: 44px; }   /* alvo de toque */

  .nav-overlay:not([hidden]) {
    display: block; position: fixed; inset: 0;
    background: rgba(10,10,8,.5); z-index: 880;
  }

  /* A topbar da página deixa de ser sticky (a mtopbar já fixa o hambúrguer). */
  .topbar { position: static; }

  /* Grids encolhem já no tablet. */
  .dash-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .dash-row { grid-template-columns: 1fr; gap: 24px; }
  .dash-row > * + * { border-left: 0; padding-left: 0; padding-top: 24px; border-top: 1px solid var(--hairline); }
  .split, .split--wide { grid-template-columns: 1fr; }
  .split > .panel:last-child { position: static; max-height: none; overflow: visible; }
  .model-cards { grid-template-columns: repeat(2, 1fr); }
}

/* Celular: 1 coluna, tabelas em cartões, espaçamento e toque ampliados. */
@media (max-width: 768px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px 16px; }
  .topbar__title { font-size: clamp(20px, 6vw, 24px); }
  /* Ações da topbar viram uma faixa rolável de toque (mesmo padrão das .tabs):
     uma só linha limpa em vez de uma pilha de botões quebrando a cada largura.
     A ação primária vem primeiro p/ ficar visível sem precisar rolar. */
  .topbar__actions {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; gap: 8px;
    margin: 0 -16px; padding: 2px 16px;            /* sangra até a borda da topbar */
  }
  .topbar__actions::-webkit-scrollbar { display: none; }
  .topbar__actions > * { flex: 0 0 auto; }         /* não espreme os botões */
  .topbar__actions .btn--primary { order: -1; }    /* CTA principal à esquerda */
  /* Densidade só afeta a tabela densa do desktop; no celular a tabela vira
     cartões, então o botão não tem efeito — escondê-lo tira ruído do topo. */
  #btn-density { display: none; }
  .tabs { gap: 18px; padding: 0 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; }
  .content { padding: 16px; gap: 20px; min-width: 0; }

  /* Toque: alvos ≥44px nos controles densos (abas, chips de período). */
  .btn--sm { padding: 10px 14px; font-size: 13px; }
  .chip--filter { padding: 10px 14px; min-height: 44px; }

  /* Tabelas largas: fallback rola dentro do painel, com header fixo. */
  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; min-width: 0; }
  .dtable thead th, .dtable tbody td { padding-left: 10px; padding-right: 10px; }

  /* Reflow em cartões: tabelas com .dtable--cards (células com data-label). */
  .dtable--cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dtable--cards tbody tr {
    display: block; border: 1px solid var(--hairline); border-radius: 12px;
    padding: 6px 14px; margin-bottom: 10px; background: var(--surface);
  }
  .dtable--cards tbody tr:hover { background: var(--surface); }
  .dtable--cards tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 9px 0; border-bottom: 1px solid var(--hairline); text-align: right;
  }
  .dtable--cards tbody tr td:last-child { border-bottom: 0; }
  .dtable--cards tbody td::before {
    content: attr(data-label); text-align: left; flex-shrink: 0;
    font-family: var(--mono); font-size: 10px; letter-spacing: .8px; text-transform: uppercase;
    color: var(--faint);
  }

  /* Formulários em modal: pares de campos (.row) deixam de ficar lado a lado
     espremidos e empilham em coluna, cada campo na largura toda. */
  .modal .row { flex-direction: column; align-items: stretch; }

  /* Toolbar de filtros (selects + ações) quebra em linhas em vez de espremer. */
  .toolbar { flex-wrap: wrap; }

  /* Trava estouro horizontal e altura de modais. */
  html, body { overflow-x: hidden; }
  .modal { max-height: 90vh; overflow-y: auto; }
}

/* ── Empty state ────────────────────────────────────────── */
.empty-state { display:flex; flex-direction:column; align-items:center; text-align:center;
  gap:8px; padding:40px 24px; color:var(--muted); }
/* O atributo [hidden] precisa vencer o display:flex acima (senão o empty-state
   aparece mesmo escondido por JS quando a tabela tem dados). */
.empty-state[hidden] { display:none; }
.empty-state__icon { width:44px; height:44px; border-radius:12px; display:grid; place-items:center;
  background:var(--accent-soft); color:var(--accent); }
.empty-state__icon svg { width:24px; height:24px; }
.empty-state__t { font-size:15px; font-weight:600; color:var(--ink); margin:4px 0 0; }
.empty-state__d { font-size:13px; color:var(--muted); margin:0; max-width:42ch; }

/* ── Skeleton (pulse) ───────────────────────────────────── */
.skel { height:14px; border-radius:6px; margin:8px 0;
  background:linear-gradient(90deg, var(--hairline) 25%, var(--inset,#eef1f5) 37%, var(--hairline) 63%);
  background-size:400% 100%; animation:skel 1.3s ease infinite; }
@keyframes skel { 0%{background-position:100% 0} 100%{background-position:0 0} }
@media (prefers-reduced-motion: reduce){ .skel{ animation:none } }

.tbl-wrap { width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.tbl-wrap .dtable { min-width:560px; }
.tbl-wrap .cohort { min-width:760px; }

/* ── Configurações ──────────────────────────────────────── */
/* Cada seção (Dados da fábrica; Usuários & permissões) ganha cartão próprio
   (.panel é transparente/sem borda — o cartão é a superfície que falta). */
.cfg-card { background:var(--surface); border:1px solid var(--hairline); border-radius:12px; padding:20px 22px; }
/* Campos de texto não esticam até a largura toda (campo curto fica proporcional). */
.cfg-row .input, .cfg-row input[type=text] { max-width:420px; }
/* Toggle de estado: rótulo de texto + cor; foco visível acessível. */
.u-toggle { display:inline-flex; align-items:center; gap:6px; }
.u-toggle[aria-pressed="true"] { background:var(--accent-soft); color:var(--accent); border-color:var(--accent); }
.u-toggle:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }

/* Expedição — altura/scroll por coluna do kanban e ênfase em atraso. */
.kanban__col { max-height:calc(100dvh - 220px); display:flex; flex-direction:column; }
.kanban__body { overflow-y:auto; display:flex; flex-direction:column; gap:8px; padding-right:4px; }
.kcard__foot .badge { font-variant-numeric:tabular-nums; }
.kcard--late { border-color:color-mix(in srgb, var(--st-alert) 50%, var(--hairline)); }
.kcard--late .kcard__foot { color:var(--st-alert); font-weight:600; }
