/* =====================================================================
   Sistema Web Melhoria — folha de estilo única da SPA.
   Sem framework e sem CDN: a fábrica pode estar sem internet.

   Identidade visual: verde abacate (ADR-018).
   Layout: menu lateral retrátil (largura cheia -> trilho de ícones) no
   desktop e gaveta sobreposta no celular. Mobile-first nos pontos que
   importam: alvo de toque de 44px, fonte de 16px nos campos (abaixo
   disso o iOS dá zoom sozinho ao focar) e área segura do iPhone.
   ===================================================================== */

:root {
  /* --- marca: cinza  ------------------------------------------ */
  --brand: #525c66;          /* ação, foco, links — 5,06:1 com texto branco (AA) */
  --brand-dark: #414952;     /* hover de ação */
  --brand-deep: #2f3439;     /* fundo do menu lateral */
  --brand-deeper: #24282c;   /* rodapé/cabeçalho do menu */
  --brand-light: #eef1f4;    /* tinta clara (tags, alertas) */
  --brand-border: #cbd3db;
  --brand-on-deep: #d5dae0;  /* texto sobre o verde escuro */
  --brand-accent: #9fb0c0;   /* detalhe claro sobre o verde escuro */

  /* --- neutros -------------------------------------------------------- */
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #fafbf9;
  --border: #dde3d9;
  --text: #1d2733;
  --text-muted: #5d6b7a;

  /* --- semânticas ----------------------------------------------------- */
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --success: #067647;
  --success-bg: #ecfdf3;
  --warning: #b54708;
  --warning-bg: #fffaeb;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);

  --sidebar-width: 258px;
  --sidebar-rail: 64px;
  --topbar-height: 60px;

  /* Área segura do iOS (notch / barra inferior). Vale 0 fora do iPhone. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;   /* iOS não reescala a fonte na rotação */
  -webkit-tap-highlight-color: rgba(77, 122, 52, .2);
}

/* Trava a rolagem do fundo enquanto a gaveta do menu está aberta. */
body.no-scroll { overflow: hidden; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; }

a { color: var(--brand); }

svg.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

svg.icon.small { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- splash */
.splash {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- login */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;              /* no celular desconta a barra do navegador */
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) calc(20px + var(--safe-right))
           calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 55%, #16240f 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  margin-bottom: 4px;
}

.login-card h1 { font-size: 18px; }

.login-card .subtitle {
  color: var(--text-muted);
  margin: 4px 0 24px;
  font-size: 13px;
  text-align: center;
}

.login-footer {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ----------------------------------------------------------------- marca */
/* Monograma oficial da Pack Bag. Os vazados da marca são transparentes: sobre
   o menu verde é o próprio verde que aparece dentro das letras, como manda o
   uso da marca em fundo escuro. */
.logo-mark { width: auto; height: 34px; flex: none; display: block; }
.logo-full { width: auto; height: 104px; display: block; margin: 0 auto 6px; }

/* ----------------------------------------------------------------- shell */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  transition: grid-template-columns .18s ease;
}

.shell.nav-collapsed { grid-template-columns: var(--sidebar-rail) 1fr; }

/* --------------------------------------------------------------- sidebar */
.sidebar {
  position: relative;
  background: var(--brand-deep);
  color: var(--brand-on-deep);
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-height);
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  overflow: hidden;
}

.brand-text { min-width: 0; }
.brand-text strong { color: #fff; font-size: 14px; display: block; line-height: 1.2; white-space: nowrap; }
.brand-text span { font-size: 11px; opacity: .75; white-space: nowrap; }

/* Botão redondo de recolher, encostado na borda do menu (como no 2.0.0). */
.sidebar-toggle {
  position: absolute;
  top: calc(var(--topbar-height) + var(--safe-top) + 14px);
  right: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--brand-deep);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 20;
  padding: 0;
}

.sidebar-toggle:hover { background: var(--brand-light); }
.sidebar-toggle svg { transition: transform .18s ease; }
.shell.nav-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.nav {
  padding: 10px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.nav-group { position: relative; margin-bottom: 2px; }

.nav-group-header,
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;              /* alvo de toque confortável */
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--brand-on-deep);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav-group-header { font-weight: 600; }

.nav-group-header:hover,
.nav-item:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-caret { flex: none; opacity: .7; transition: transform .18s ease; }
.nav-group.open > .nav-group-header .nav-caret { transform: rotate(90deg); }

.nav-children { display: none; padding: 2px 0 6px; }
.nav-group.open > .nav-children { display: block; }

.nav-children .nav-item { padding-left: 16px; font-size: 13px; }

.nav-item.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}

.nav-item.active:hover { background: var(--brand-dark); }

.nav-empty { padding: 16px 12px; font-size: 12px; opacity: .8; line-height: 1.5; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, .12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-version { font-size: 11px; opacity: .7; white-space: nowrap; }

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .25);
  background: transparent;
  color: var(--brand-on-deep);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-logout:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ------------------------------------------- sidebar recolhida (trilho) */
.shell.nav-collapsed .sidebar-header { justify-content: center; padding: 0; }
.shell.nav-collapsed .brand-text,
.shell.nav-collapsed .sidebar-version,
.shell.nav-collapsed .nav-caret,
.shell.nav-collapsed .btn-logout span { display: none; }

.shell.nav-collapsed .nav-label { display: none; }
/* Espaço no topo para o primeiro ícone ficar abaixo do botão de recolher. */
.shell.nav-collapsed .nav { padding-top: 36px; }
.shell.nav-collapsed .nav-group-header,
.shell.nav-collapsed .nav-item { justify-content: center; padding: 8px; gap: 0; }
.shell.nav-collapsed .sidebar-footer { justify-content: center; }
.shell.nav-collapsed .btn-logout { padding: 6px 8px; }

/* Submenu vira balão flutuante ao passar o mouse / tocar no ícone.
   Posição é `fixed` e calculada no JS: dentro do menu, que rola, um
   `absolute` seria cortado pelo overflow. */
.shell.nav-collapsed .nav-children { display: none; }

.shell.nav-collapsed .nav-group.flyout > .nav-children {
  display: block;
  position: fixed;
  min-width: 210px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 6px;
  border-radius: 0 10px 10px 0;
  background: var(--brand-deeper);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
}

.shell.nav-collapsed .nav-children .nav-label { display: block; }
.shell.nav-collapsed .nav-children .nav-item { justify-content: flex-start; gap: 10px; padding: 8px 12px; }

/* --------------------------------------------------------- área principal */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: var(--topbar-height);
  padding-top: var(--safe-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: calc(16px + var(--safe-right));
  padding-left: 16px;
  gap: 12px;
}

.topbar-title { min-width: 0; }
.topbar-title strong { display: block; font-size: 14px; }
.topbar-title .hint { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu-btn {
  display: none;                  /* só no celular */
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
  padding: 0;
}

/* ----------------------------------------------------- menu do usuário */
.user-menu { position: relative; flex: none; }

.user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  max-width: 260px;
}

.user-btn:hover { background: var(--surface-2); border-color: var(--border); }

.user-info { min-width: 0; text-align: left; }
.user-info .name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info .login { font-size: 11px; color: var(--text-muted); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-dark);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex: none;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 40;
}

.user-dropdown .who {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.user-dropdown .who strong { display: block; font-size: 13px; }
.user-dropdown .who span { font-size: 11px; color: var(--text-muted); }

.menu-action {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.menu-action:hover { background: var(--brand-light); color: var(--brand-dark); }
.menu-action.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* Fundo escuro da gaveta no celular. */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .5);
  z-index: 25;
}

.content {
  padding: 20px calc(20px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left));
  flex: 1;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-header h2 { font-size: 20px; }
.page-header p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-body { padding: 16px; }

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.field .hint { font-size: 11px; color: var(--text-muted); }

input[type=text], input[type=password], input[type=email], input[type=date],
input[type=number], input[type=search], select, textarea {
  font: inherit;
  color: inherit;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  min-width: 0;
  max-width: 100%;
}

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.sidebar button:focus-visible, .sidebar a:focus-visible { outline-color: var(--brand-accent); }

input[disabled], select[disabled] { background: #f1f3f0; color: var(--text-muted); }

.field-error { color: var(--danger); font-size: 12px; }
.field.invalid input, .field.invalid select { border-color: var(--danger); }

.checkbox { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; }
.checkbox input { margin-top: 2px; width: 18px; height: 18px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* --------------------------------------------------------------- buttons */
.btn {
  font: inherit;
  font-weight: 600;
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--brand); color: var(--brand-dark); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #92150e; }
.btn.link { background: none; border: none; color: var(--brand-dark); padding: 4px 6px; min-height: 36px; }
.btn.link:hover { background: var(--brand-light); }
.btn.small { padding: 6px 10px; font-size: 12px; min-height: 34px; }
.btn.block { width: 100%; padding: 12px 16px; min-height: 46px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; }

th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--surface-2);
  white-space: nowrap;
}

tbody tr:hover { background: var(--surface-2); }

td.actions { text-align: right; white-space: nowrap; }

.empty, .loading {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* ----------------------------------------------------------------- tags */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--brand-light);
  color: var(--brand-dark);
  margin: 1px 2px 1px 0;
}

.tag.ok { background: var(--success-bg); color: var(--success); }
.tag.off { background: #f1f3f0; color: var(--text-muted); }
.tag.warn { background: var(--warning-bg); color: var(--warning); }
.tag.err { background: var(--danger-bg); color: var(--danger); }

.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; }

/* --------------------------------------------------------------- alerts */
.alert {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert.error { background: var(--danger-bg); color: var(--danger); border-color: #fecdc9; }
.alert.warn { background: var(--warning-bg); color: var(--warning); border-color: #fedf89; }
.alert.info { background: var(--brand-light); color: var(--brand-dark); border-color: var(--brand-border); }

/* --------------------------------------------------------------- modais */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
}

.modal.narrow { max-width: 460px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-header h3 { font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 0 0 12px 12px;
  flex-wrap: wrap;
}

.close-x {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.close-x:hover { background: var(--surface-2); color: var(--text); }

/* --------------------------------------------------------------- toasts */
.toasts {
  position: fixed;
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  left: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.toast {
  min-width: 260px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  border-left: 4px solid var(--brand);
  font-size: 13px;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast strong { display: block; margin-bottom: 2px; }

/* ------------------------------------------------------- permission tree */
.perm-module { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; }

.perm-module > header {
  padding: 10px 14px;
  background: var(--surface-2);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.perm-sub { padding: 10px 14px; border-bottom: 1px solid #eef1ec; }
.perm-sub:last-child { border-bottom: none; }
.perm-sub h5 { margin: 0 0 8px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 16px; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }

.pill-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  background: #fff;
}

.pill-check input { margin: 0; width: 16px; height: 16px; }
.pill-check.checked { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }

.json-box {
  background: #1b2417;
  color: #dbe8d1;
  padding: 10px;
  border-radius: 8px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

/* =====================================================================
   TABLET — 1024px para baixo: o menu já entra recolhido por padrão
   (feito no JS); aqui só apertamos o espaçamento.
   ===================================================================== */
@media (max-width: 1024px) {
  .content { padding-left: calc(16px + var(--safe-left)); padding-right: calc(16px + var(--safe-right)); }
  .user-info { display: none; }
  .user-btn { max-width: none; }
}

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* =====================================================================
   TABELA EM CARTÕES — 900px para baixo (inclui iPad em pé). Em vez de
   rolagem horizontal, cada linha vira um cartão com rótulo à esquerda e
   valor à direita. O `data-label` e o invólucro `.cell-value` são
   carimbados pelo tableShell do ui.js.
   ===================================================================== */
@media (max-width: 900px) {
  table.stacked, table.stacked tbody, table.stacked tr, table.stacked td { display: block; width: 100%; }
  table.stacked thead { display: none; }

  table.stacked tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    background: var(--surface);
    padding: 4px 0;
  }

  table.stacked tr:hover { background: var(--surface); }

  table.stacked td {
    border: none;
    border-bottom: 1px solid #eef1ec;
    padding: 8px 12px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
  }

  table.stacked td > .cell-value {
    flex: 1;
    min-width: 0;
    text-align: right;
  }

  table.stacked td:last-child { border-bottom: none; }

  table.stacked td::before {
    content: attr(data-label);
    flex: none;
    max-width: 45%;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    text-align: left;
    padding-top: 2px;
  }

  table.stacked td[data-label=""]::before { display: none; }
  table.stacked td.actions > .cell-value {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 6px;
    justify-content: flex-end;
  }

  table.stacked td.spanned { display: block; text-align: center; }
  table.stacked td.spanned::before { display: none; }
}

/* =====================================================================
   CELULAR — 760px para baixo: o menu vira gaveta sobreposta, os campos
   sobem para 16px (senão o iOS dá zoom ao focar) e o modal vira folha
   colada no rodapé, ao alcance do polegar.
   ===================================================================== */
@media (max-width: 760px) {
  body { font-size: 15px; }

  .shell { grid-template-columns: 1fr; }
  .shell.nav-collapsed { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(84vw, 300px);
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 30;
    box-shadow: var(--shadow-lg);
  }

  /* Na gaveta o menu é sempre completo, nunca trilho. */
  .shell.nav-collapsed .sidebar .nav-label,
  .shell.nav-collapsed .sidebar .brand-text,
  .shell.nav-collapsed .sidebar .sidebar-version,
  .shell.nav-collapsed .sidebar .nav-caret,
  .shell.nav-collapsed .sidebar .btn-logout span { display: block; }

  .shell.nav-collapsed .sidebar-header { justify-content: flex-start; padding: 0 14px; }
  .shell.nav-collapsed .nav { padding-top: 10px; }
  .shell.nav-collapsed .nav-group-header,
  .shell.nav-collapsed .nav-item { justify-content: flex-start; padding: 8px 12px; gap: 12px; }
  .shell.nav-collapsed .nav-children .nav-item { padding-left: 16px; }
  .shell.nav-collapsed .sidebar-footer { justify-content: space-between; }
  .shell.nav-collapsed .nav-group.open > .nav-children,
  .shell.nav-collapsed .nav-group.flyout > .nav-children {
    display: block;
    position: static;
    min-width: 0;
    max-height: none;
    overflow: visible;
    padding: 2px 0 6px;
    background: none;
    border: none;
    box-shadow: none;
  }
  .shell.nav-collapsed .nav-group:not(.open) > .nav-children { display: none; }

  .shell.nav-open .sidebar { transform: translateX(0); }
  .shell.nav-open .scrim { display: block; }

  .sidebar-toggle { display: none; }
  .menu-btn { display: inline-flex; }

  .topbar { padding-left: 12px; padding-right: calc(12px + var(--safe-right)); gap: 8px; }
  .topbar-title strong { font-size: 13px; }
  .topbar-title .hint { display: none; }

  .content { padding: 16px calc(14px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(14px + var(--safe-left)); }

  .page-header { margin-bottom: 14px; }
  .page-header h2 { font-size: 18px; }
  .page-header > .actions,
  .page-header > .btn { width: 100%; }

  .filters { padding: 12px; }
  .filters > * { flex: 1 1 100%; }

  /* Campo com menos de 16px faz o iOS dar zoom ao focar. */
  input[type=text], input[type=password], input[type=email], input[type=date],
  input[type=number], input[type=search], select, textarea { font-size: 16px; padding: 11px 12px; }

  .modal-backdrop { padding: 0; place-items: end stretch; }

  .modal {
    max-width: none;
    max-height: 94dvh;
    border-radius: 14px 14px 0 0;
    padding-bottom: var(--safe-bottom);
  }

  .modal.narrow { max-width: none; }
  .modal-footer { border-radius: 0; }
  .modal-footer .btn { flex: 1; }

  .toasts { left: calc(12px + var(--safe-left)); right: calc(12px + var(--safe-right)); }
  .toast { min-width: 0; max-width: none; }

  .pager { justify-content: center; }
}

/* Quem prefere menos animação não recebe animação. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}

/* Impressão: sem menu, sem topo, conteúdo em largura total. */
@media print {
  .sidebar, .topbar, .scrim, .toasts { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .content { padding: 0; }
}
