/* Piccinin OS: painel de operação.
   Escuro sóbrio, verde Piccinin só em ações, seleção e estados. Uma família (Inter), escala fixa em rem. */

:root {
  color-scheme: dark;

  /* Neutros com leve tom do verde da marca */
  --bg: oklch(0.155 0.006 160);
  --surface: oklch(0.19 0.008 160);
  --surface-2: oklch(0.225 0.009 160);
  --surface-3: oklch(0.26 0.01 160);
  --line: oklch(0.29 0.01 160);
  --line-strong: oklch(0.36 0.012 160);
  --text: oklch(0.96 0.004 160);
  --text-2: oklch(0.82 0.008 160);
  --muted: oklch(0.69 0.01 160);

  /* Verde Piccinin, sem neon */
  --accent: oklch(0.8 0.17 158);
  --accent-hover: oklch(0.86 0.15 158);
  --accent-ink: oklch(0.2 0.04 158);
  --accent-soft: oklch(0.8 0.17 158 / 0.12);

  /* Estados */
  --warn: oklch(0.83 0.14 80);
  --warn-soft: oklch(0.83 0.14 80 / 0.12);
  --info: oklch(0.77 0.11 240);
  --info-soft: oklch(0.77 0.11 240 / 0.12);
  --danger: oklch(0.71 0.18 25);
  --danger-soft: oklch(0.71 0.18 25 / 0.12);
  --neutral-soft: oklch(0.69 0.01 160 / 0.14);

  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* Espaço (base 4px) */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;
  --s8: 4rem;

  /* Tipo (razão ~1.2) */
  --t-xs: 0.8125rem;
  --t-sm: 0.875rem;
  --t-base: 1rem;
  --t-md: 1.125rem;
  --t-lg: 1.375rem;
  --t-xl: 1.75rem;

  --radius: 8px;
  --radius-sm: 6px;
  --page-max: 1200px;
  --gutter: var(--s4);

  /* Camadas */
  --z-sticky: 10;
  --z-toast: 40;
  --z-tooltip: 50;

  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
}

@media (min-width: 720px) {
  :root { --gutter: var(--s6); }
}

/* ── Base ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: var(--t-base);
  line-height: 1.5;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
.num { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--s4); top: -100px; z-index: var(--z-toast);
  background: var(--accent); color: var(--accent-ink); padding: var(--s2) var(--s3); border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--s2); }

/* ── Barra superior ─────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: oklch(0.155 0.006 160 / 0.96);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter);
  display: flex; align-items: center; gap: var(--s5); min-height: 60px;
}
.brand { display: flex; align-items: center; gap: var(--s2); text-decoration: none; flex-shrink: 0; }
.brand img { height: 34px; width: auto; }
.nav { display: flex; gap: var(--s1); flex: 1; min-width: 0; }
.nav a {
  padding: var(--s2) var(--s3); border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-size: var(--t-sm); font-weight: 500; white-space: nowrap;
  transition: color 150ms var(--ease-out), background-color 150ms var(--ease-out);
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current='page'] { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: var(--s2); flex-shrink: 0; }
.user-email { color: var(--muted); font-size: var(--t-xs); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 719px) {
  .topbar-inner { flex-wrap: wrap; gap: 0 var(--s3); padding-top: var(--s2); }
  .brand img { height: 30px; }
  .topbar-actions { margin-left: auto; }
  .user-email { display: none; }
  .nav {
    order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none;
    margin: var(--s1) calc(var(--gutter) * -1) 0; padding: 0 var(--gutter) var(--s2);
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 1; text-align: center; }
}

/* ── Página ─────────────────────────────── */
main { flex: 1; }
.page { width: 100%; max-width: var(--page-max); margin: 0 auto; padding: var(--s5) var(--gutter) var(--s7); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s5); margin-bottom: var(--s5); }
.page-head h1 { font-size: var(--t-lg); letter-spacing: -0.01em; }
.page-head p { color: var(--muted); font-size: var(--t-sm); margin-top: var(--s1); max-width: 65ch; }
.page-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); }
.section { margin-top: var(--s6); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); }
.section-head h2 { font-size: var(--t-md); }
.section-head p { color: var(--muted); font-size: var(--t-sm); }

/* Status ao vivo */
.live { display: inline-flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--t-xs); white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.live[data-estado='ao-vivo'] .live-dot { background: var(--accent); }
.live[data-estado='reconectando'] .live-dot { background: var(--warn); }
.live[data-estado='erro'] .live-dot { background: var(--danger); }

/* Interruptor (histórico da V1) */
.switch { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); color: var(--text-2); cursor: pointer; user-select: none; }
.switch input { appearance: none; margin: 0; width: 34px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; cursor: pointer; flex-shrink: 0; transition: background-color 150ms var(--ease-out); }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform 150ms var(--ease-out); }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(14px); background: var(--accent-ink); }
.switch input:focus-visible { box-shadow: var(--focus); }

/* ── Botões e campos ────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 38px; padding: 0 var(--s4); border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  font-size: var(--t-sm); font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 150ms var(--ease-out), border-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; border-color: var(--line-strong); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { min-height: 32px; padding: 0 var(--s3); font-size: var(--t-xs); }
.btn-icon { width: 38px; padding: 0; }
.btn i { font-size: 1.1em; line-height: 1; }

.field { display: flex; flex-direction: column; gap: var(--s1); }
.field label { font-size: var(--t-sm); font-weight: 500; color: var(--text-2); }
.field .hint { font-size: var(--t-xs); color: var(--muted); }
.input, .select {
  min-height: 40px; width: 100%; padding: 0 var(--s3);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  color: var(--text); font-size: var(--t-sm);
  transition: border-color 150ms var(--ease-out);
}
.input::placeholder { color: var(--muted); }
.input:hover, .select:hover { border-color: oklch(0.45 0.012 160); }
.input:focus-visible, .select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); border-radius: var(--radius-sm); }
.input[aria-invalid='true'] { border-color: var(--danger); }
.select { appearance: none; padding-right: var(--s6); background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.search { position: relative; flex: 1; min-width: min(100%, 240px); }
.search i { position: absolute; left: var(--s3); top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 2.25rem; }
.form-error { color: var(--danger); font-size: var(--t-sm); }
.hint { color: var(--muted); font-size: var(--t-xs); }
.skeleton-cell { padding: 0 !important; }

/* Segmentado (filtro de status) */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  border: 0; background: transparent; color: var(--muted); padding: 6px var(--s3); border-radius: var(--radius-sm);
  font-size: var(--t-sm); font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--surface-3); color: var(--text); }
.seg .count { color: var(--muted); font-weight: 400; margin-left: 4px; }

/* ── Números (faixa de indicadores) ─────── */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.stat { padding: var(--s4) var(--s5); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; min-width: 0; }
.stat dt { font-size: var(--t-sm); color: var(--text-2); font-weight: 500; }
.stat dd { margin: var(--s1) 0 0; }
.stat .value { font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .value.is-empty { color: var(--muted); font-size: var(--t-lg); }
.stat .sub { display: block; color: var(--muted); font-size: var(--t-xs); margin-top: var(--s1); }
.stat .delta { font-variant-numeric: tabular-nums; font-weight: 500; }
/* Variação sem cor de julgamento: tempo maior não é "bom" como valor maior. */
.stat .delta { color: var(--text-2); }
.stat-link {
  display: inline-block; border: 0; background: none; padding: 0; color: var(--text); cursor: pointer; text-align: left;
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 6px; text-decoration-thickness: 2px;
  transition: text-decoration-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.stat-link:hover { text-decoration-color: var(--text-2); }
.stat:has(.stat-link) { position: relative; cursor: pointer; transition: background-color 150ms var(--ease-out); }
.stat:has(.stat-link):hover { background: var(--surface-2); }
.stat-link::after { content: ''; position: absolute; inset: 0; }
.stat-link:focus-visible { box-shadow: none; }
.stat:has(.stat-link:focus-visible) { box-shadow: inset 0 0 0 2px var(--accent); }
.stat-link.is-active { color: var(--accent); text-decoration-color: var(--accent); }
@media (max-width: 559px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: var(--s3) var(--s4); }
  .stat .value { font-size: var(--t-lg); }
  .stat .value.is-empty { font-size: var(--t-md); }
  .page { padding-top: var(--s4); }
  .page-head { margin-bottom: var(--s4); }
  .page-head p { font-size: var(--t-xs); }
}

/* Atenção */
.attention { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s5); }
.notice {
  display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: var(--s1) var(--s3); padding: var(--s3) var(--s4);
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); font-size: var(--t-sm);
}
.notice i { font-size: 1.15rem; line-height: 1.3; flex-shrink: 0; }
.notice strong { font-weight: 600; }
.notice p { color: var(--text-2); }
.notice .btn { align-self: center; }
.notice-danger { background: var(--danger-soft); border-color: oklch(0.71 0.18 25 / 0.35); }
.notice-danger i { color: var(--danger); }
.notice-warn { background: var(--warn-soft); border-color: oklch(0.83 0.14 80 / 0.3); }
.notice-warn i { color: var(--warn); }
.notice-ok i { color: var(--accent); }
.notice-info { background: var(--info-soft); border-color: oklch(0.77 0.11 240 / 0.3); }
.notice-info i { color: var(--info); }
@media (max-width: 559px) {
  .notice { grid-template-columns: auto 1fr; }
  .notice .btn { grid-column: 2; justify-self: start; margin-top: var(--s1); }
}

/* ── Barra de ferramentas da lista ──────── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.toolbar .select { width: auto; min-width: 180px; }
@media (max-width: 559px) {
  .toolbar .select { flex: 1; min-width: 0; }
}

/* ── Tabela de OS ───────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.os-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.os-table th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: var(--t-xs);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); background: var(--surface); white-space: nowrap;
}
.os-table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); vertical-align: top; }
.os-table tbody tr:last-child td { border-bottom: 0; }
.os-table .col-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.os-cell { display: inline-flex; align-items: center; gap: var(--s1); white-space: nowrap; }
.os-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px; }
.os-link i { color: var(--muted); font-size: 0.85em; }
.os-link:hover { text-decoration-color: var(--accent); }
.os-link:hover i { color: var(--accent); }
.copy-code { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer; }
.copy-code:hover { background: var(--surface-3); color: var(--text); }
@media (pointer: coarse) { .os-link, .copy-code { min-height: 40px; } .copy-code { width: 40px; } }
.os-table .os-code { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.os-table .primary { color: var(--text); font-weight: 500; }
.os-table .secondary { display: block; color: var(--muted); font-size: var(--t-xs); margin-top: 2px; }
.os-table .secondary.is-late { color: var(--warn); }
.fila-table td[data-col='quando'], .fila-table td[data-col='quando'] .secondary { white-space: nowrap; }
.os-row { cursor: pointer; transition: background-color 120ms var(--ease-out); }
.os-row:hover { background: var(--surface-2); }
.os-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0; }
.os-row .open-btn { border: 0; background: none; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.os-row .open-btn:focus-visible { box-shadow: var(--focus); }
.legacy-mark { color: var(--muted); font-size: var(--t-xs); font-weight: 400; margin-left: var(--s1); }

@media (max-width: 719px) {
  .os-table thead { display: none; }
  .os-table, .os-table tbody { display: block; }
  .os-table tr {
    display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s3);
    padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line);
  }
  .os-table tbody tr:last-child { border-bottom: 0; }
  .os-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .os-table td[data-col='os'] { grid-column: 1; }
  .os-table td[data-col='status'] { grid-column: 2; grid-row: 1; text-align: right; }
  .os-table td[data-col='cliente'] { grid-column: 1 / -1; }
  .os-table td[data-col='tecnico'] { grid-column: 1; color: var(--muted); font-size: var(--t-xs); }
  .os-table td[data-col='tecnico'] .primary { color: var(--text-2); font-weight: 400; }
  .os-table td[data-col='valor'] { grid-column: 2; grid-row: 3; text-align: right; color: var(--text-2); }
  .os-table td[data-col='quando'] { display: none; }
  .fila-table td[data-col='quando'] { display: block; grid-column: 1; color: var(--muted); font-size: var(--t-xs); }
  .fila-table td[data-col='quando'] .secondary { display: inline; margin-left: var(--s2); }
  .fila-table td[data-col='valor'] { grid-row: 4; }
}

.list-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--t-xs); }

/* Status */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px var(--s2); border-radius: 999px;
  font-size: var(--t-xs); font-weight: 500; white-space: nowrap; background: var(--neutral-soft); color: var(--text-2);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-aberta { background: var(--warn-soft); color: var(--warn); }
.badge-em_andamento { background: var(--info-soft); color: var(--info); }
.badge-concluida { background: var(--accent-soft); color: var(--accent); }
.badge-cancelada { background: var(--neutral-soft); color: var(--muted); }
.badge-erro { background: var(--danger-soft); color: var(--danger); }

/* ── Vazio, carregando, erro ────────────── */
.empty { padding: var(--s7) var(--s5); text-align: center; color: var(--text-2); }
.empty i { font-size: 1.75rem; color: var(--muted); display: block; margin-bottom: var(--s3); }
.empty h3 { font-size: var(--t-base); color: var(--text); }
.empty p { font-size: var(--t-sm); color: var(--muted); max-width: 52ch; margin: var(--s2) auto 0; }
.empty .btn { margin-top: var(--s4); }
.skeleton-row { height: 52px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton-row:last-child { border-bottom: 0; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ── Painéis e gráficos ─────────────────── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4) var(--s5); min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px var(--s3); margin-bottom: var(--s3); }
.panel-head h3 { font-size: var(--t-base); }
.panel-head span { color: var(--muted); font-size: var(--t-xs); }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--s4); }
.chart { min-height: 120px; }
.chart .empty { padding: var(--s7) var(--s4); }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.bars li { display: grid; grid-template-columns: minmax(0, 12rem) 1fr 3ch; align-items: center; gap: var(--s3); font-size: var(--t-sm); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.bar-fill.is-warn { background: var(--warn); }
.bar-value { text-align: right; color: var(--text); }
@media (max-width: 559px) { .bars li { grid-template-columns: minmax(0, 8rem) 1fr 3ch; } }

.split-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-3); margin-top: var(--s2); }
.split-bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-top: var(--s2); font-size: var(--t-xs); color: var(--text-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* ── Diálogos (detalhe da OS, ajuda) ────── */
dialog { color: var(--text); padding: 0; border: 1px solid var(--line-strong); background: var(--surface); }
dialog::backdrop { background: oklch(0.1 0.005 160 / 0.7); }
.drawer {
  margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(560px, 100vw); max-width: 100vw;
  border-width: 0 0 0 1px; border-radius: 0;
}
.drawer[open] { animation: drawer-in 220ms var(--ease-out); }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet { width: min(640px, calc(100vw - 2 * var(--s4))); max-height: calc(100dvh - 2 * var(--s6)); border-radius: var(--radius); }
.dialog-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s5); background: var(--surface); border-bottom: 1px solid var(--line);
}
.dialog-head h2 { font-size: var(--t-md); }
.dialog-head p { color: var(--muted); font-size: var(--t-xs); margin-top: 2px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.dialog-actions:empty { display: none; }
.stat-wide { grid-column: 1 / -1; }
.dialog-body { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s5); }
.dialog-body h3 { font-size: var(--t-sm); color: var(--text-2); font-weight: 600; margin-bottom: var(--s2); }

.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3) var(--s4); margin: 0; }
.kv div { min-width: 0; }
.kv dt { font-size: var(--t-xs); color: var(--muted); }
.kv dd { margin: 2px 0 0; font-size: var(--t-sm); overflow-wrap: anywhere; }
.report p { font-size: var(--t-sm); color: var(--text-2); overflow-wrap: anywhere; white-space: pre-line; }
.report p + p { margin-top: var(--s3); }
.report strong { color: var(--text); font-weight: 600; }
.items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.items li { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s3); font-size: var(--t-sm); }
.items li + li { border-top: 1px solid var(--line); }
.items small { display: block; color: var(--muted); font-size: var(--t-xs); }
.items .total { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s2); }
.photos > p, .photos > .btn { grid-column: 1 / -1; justify-self: start; }
.photos a { aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); }
.photos img { width: 100%; height: 100%; object-fit: cover; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; padding-top: var(--s4); border-top: 1px solid var(--line); }
.total-line span { color: var(--text-2); font-size: var(--t-sm); }
.total-line strong { font-size: var(--t-lg); font-variant-numeric: tabular-nums; }

/* Ajuda */
.help h3 { font-size: var(--t-base); color: var(--text); margin-bottom: var(--s2); }
.help p, .help li { font-size: var(--t-sm); color: var(--text-2); max-width: 65ch; }
.help ul { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: var(--s2); }
.help strong { color: var(--text); }

/* ── Abas (apelidos) ────────────────────── */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--line); margin-bottom: var(--s4); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role='tab'] {
  border: 0; background: none; color: var(--muted); padding: var(--s3) var(--s3); font-size: var(--t-sm); font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs [role='tab']:hover { color: var(--text); }
.tabs [role='tab'][aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { color: var(--muted); font-weight: 400; margin-left: 4px; }

.data-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.data-table th { text-align: left; font-weight: 500; color: var(--muted); font-size: var(--t-xs); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.data-table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table td.actions .btn + .btn { margin-left: var(--s2); }
.data-table code { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: var(--t-xs); color: var(--text-2); background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
.alias { font-weight: 600; }
@media (max-width: 719px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody { display: block; }
  .data-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td { padding: 0; border: 0; }
  .data-table td.actions { grid-column: 2; grid-row: 1 / span 3; align-self: center; display: flex; flex-direction: column; gap: var(--s2); }
  .data-table td.actions .btn + .btn { margin-left: 0; }
  .data-table td[data-col='criado'] { display: none; }
  .data-table td[data-col='nome'] { color: var(--text-2); }
}

.inline-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4) var(--s5); margin-bottom: var(--s4); }
.inline-form h3 { font-size: var(--t-base); margin-bottom: var(--s1); }
.inline-form > p { color: var(--muted); font-size: var(--t-sm); margin-bottom: var(--s4); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--s4); }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); margin-top: var(--s4); }

/* ── Login ──────────────────────────────── */
.auth { flex: 1; display: grid; place-items: center; padding: var(--s6) var(--s4); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s6) var(--s5); }
.auth-card img { height: 40px; width: auto; margin-bottom: var(--s5); }
.auth-card h1 { font-size: var(--t-lg); }
.auth-card > p { color: var(--muted); font-size: var(--t-sm); margin: var(--s1) 0 var(--s5); }
.auth-card form { display: flex; flex-direction: column; gap: var(--s4); }
.auth-card .btn-primary { min-height: 44px; }
.auth-foot { color: var(--muted); font-size: var(--t-xs); margin-top: var(--s5); }

/* Tela de bloqueio (sem acesso / erro de sessão) */
.gate { max-width: 480px; margin: var(--s8) auto; padding: 0 var(--gutter); text-align: center; }
.gate h1 { font-size: var(--t-lg); }
.gate p { color: var(--muted); font-size: var(--t-sm); margin: var(--s2) 0 var(--s5); }

/* ── Rodapé ─────────────────────────────── */
.footer { border-top: 1px solid var(--line); }
.footer-inner { max-width: var(--page-max); margin: 0 auto; padding: var(--s4) var(--gutter); display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2); color: var(--muted); font-size: var(--t-xs); }
.footer a { color: var(--text-2); text-decoration: none; }
.footer a:hover { color: var(--text); text-decoration: underline; }

/* ── Tooltip e aviso flutuante ──────────── */
.toast {
  position: fixed; left: 50%; bottom: var(--s5); transform: translateX(-50%); z-index: var(--z-toast);
  background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text); padding: var(--s3) var(--s4);
  border-radius: var(--radius); font-size: var(--t-sm); max-width: calc(100vw - 2 * var(--s4));
}

@media (pointer: coarse) {
  .btn, .input, .select { min-height: 44px; }
  .btn-sm { min-height: 40px; padding: 0 var(--s4); }
  .btn-icon { width: 44px; }
  .nav a { min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .seg button { min-height: 40px; }
  .switch { min-height: 44px; }
  .tabs [role='tab'] { min-height: 44px; }
  .stat-link { min-height: 44px; }
  .footer a { display: inline-block; padding: var(--s2) 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
