/* ===============================================
   GM2 PLAY — PAINEL ADMINISTRATIVO
   Design: SaaS neutro profissional
   Paleta: Branco / Cinza / Preto + Azul único
   =============================================== */

:root {
  /* Superfícies */
  --bg:        #f4f4f5;
  --surface:   #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f4f4f5;

  /* Texto */
  --ink:    #09090b;
  --ink-2:  #3f3f46;
  --muted:  #71717a;
  --muted-2: #a1a1aa;

  /* Bordas */
  --line:       #e4e4e7;
  --line-strong: #d4d4d8;

  /* Cor primária — azul único */
  --brand:      #2563eb;
  --brand-hover: #1d4ed8;
  --brand-light: #dbeafe;
  --brand-text:  #1e40af;

  /* Perigo */
  --danger:       #ef4444;
  --danger-hover: #dc2626;
  --danger-light: #fee2e2;

  /* Layout */
  --sidebar-width: 256px;
  --topbar-height: 60px;
  --radius:    8px;
  --radius-lg: 12px;

  /* Sombras mínimas */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);

  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* === DARK MODE — [data-theme="dark"] === */
[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #111214;
  --surface:   #18191c;
  --surface-2: #202125;
  --surface-3: #25272b;
  --ink:    #f5f5f6;
  --ink-2:  #c8cbd1;
  --muted:  #8e939c;
  --muted-2: #676d77;
  --line:       #2a2d33;
  --line-strong: #363a42;
  --brand:      #6b8cff;
  --brand-hover: #5b7df5;
  --brand-light: rgba(107, 140, 255, 0.12);
  --brand-text:  #c8d4ff;
  --danger:       #e06b6b;
  --danger-hover: #d95757;
  --danger-light: rgba(224, 107, 107, 0.12);
}

[data-theme="dark"] .confirm-danger-note {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.3);
  color: #fca5a5;
}

[data-theme="dark"] .danger-group {
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.08);
}

[data-theme="dark"] .pill.ativo,
[data-theme="dark"] .pill.teste,
[data-theme="dark"] .pill.permanente,
[data-theme="dark"] .pill.fechado,
[data-theme="dark"] .pill.expirado,
[data-theme="dark"] .pill.inactive,
[data-theme="dark"] .pill.warn {
  color: var(--ink-2);
  background: var(--surface-3);
  border-color: var(--line-strong);
}

[data-theme="dark"] .plan.selected {
  background: rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .login-screen {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] tbody tr:hover { background: var(--surface-2); }

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

html {
  min-height: 100%;
  background: var(--bg);
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

body, button, input, textarea, select { font: inherit; }

button { cursor: pointer; }

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

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h2 {
  margin-bottom: 2px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

small {
  color: var(--muted);
  font-size: 12px;
}

/* === LOGIN === */
.locked .sidebar,
.locked .app,
.locked .fab {
  filter: blur(2px);
  pointer-events: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
}

body:not(.locked) .login-screen { display: none; }

.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 16px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.login-card img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

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

.login-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* === SIDEBAR === */
.sidebar {
  height: 100vh;
  padding: 18px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 5;
  overflow-y: auto;
  overflow-x: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  margin-bottom: 4px;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.brand strong,
.brand span { display: block; line-height: 1.3; }

.brand strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand span {
  font-size: 11px;
  color: var(--muted);
}

.sidebar-action { display: none; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}

/* Separadores e grupos do nav */
.nav-divider {
  height: 1px;
  background: var(--line);
  margin: 10px 4px 6px;
}

.nav-group-label {
  display: block;
  padding: 6px 10px 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  user-select: none;
}

/* Hambúrguer — invisível no desktop */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 8px 7px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.sidebar-toggle span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--ink-2);
  border-radius: 2px;
  transition: 150ms ease;
}

/* Overlay para mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 8;
}

/* === BOTÕES DE NAVEGAÇÃO === */
/* Remove indicadores coloridos da v1 */
.nav-item::before { display: none; }

.nav-item,
.filter,
.ghost,
.primary-action,
.danger-action {
  min-height: 36px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 10px;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  padding-left: 12px;
}

.nav-item:hover {
  color: var(--ink);
  background: var(--surface-3);
}

.nav-item.active {
  color: var(--ink);
  background: var(--surface-3);
  font-weight: 600;
}

/* Footer da sidebar */
.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
}

.sidebar-footer span {
  color: var(--muted);
  font-size: 11px;
}

.sidebar-footer strong {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}

/* Classes de cor muted herdadas */
.brand span,
.eyebrow,
.panel-head p,
.metric small,
.activity small,
.sidebar-footer span,
.client-card small,
.mini-meta { color: var(--muted); }

label { color: var(--ink-2); }

/* === MAIN APP === */
.app {
  min-width: 0;
  width: 100%;
  padding: 0 28px 40px;
}

/* === TOPBAR === */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  height: var(--topbar-height);
  margin: 0 -28px 22px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 4;
}

/* Wrapper esquerdo: hambúrguer + título */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.page-heading { min-width: 0; }

.eyebrow {
  margin: 0 0 1px;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* === BUSCA === */
.search { position: relative; }

.search::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--muted-2);
  border-radius: 999px;
  transform: translateY(-58%);
  pointer-events: none;
}

.search::after {
  content: "";
  position: absolute;
  left: 21px;
  top: calc(50% + 4px);
  width: 6px;
  height: 1.5px;
  background: var(--muted-2);
  transform: rotate(45deg);
  transform-origin: left center;
  pointer-events: none;
}

.search input { width: 240px; padding-left: 30px; }

/* === INPUTS === */
input,
textarea,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 12px;
  font-size: 14px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea { resize: vertical; }

input::placeholder,
textarea::placeholder { color: var(--muted-2); }

/* === BOTÕES === */
.primary-action {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  font-weight: 600;
  font-size: 14px;
}

.primary-action:hover:not(:disabled) {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.danger-action {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  font-weight: 600;
}

.danger-action:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.ghost,
.filter {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line-strong);
  font-weight: 500;
}

.ghost:hover:not(:disabled),
.filter:hover:not(:disabled) {
  background: var(--surface-3);
}

.filter.active {
  background: var(--surface-3);
  color: var(--ink);
  border-color: var(--line-strong);
  font-weight: 600;
}

.compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.section-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.user-dialog {
  width: min(760px, calc(100vw - 32px));
}

.permissions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.permissions-grid section {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.permissions-grid h4 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.permission-check {
  min-height: 28px;
}

.user-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.user-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.report-generator {
  margin-bottom: 14px;
}

.report-controls {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(160px, 0.7fr) minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
}

.report-generated-summary {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.report-generated-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.report-generated-summary strong {
  font-size: 22px;
}

.report-generated-summary small {
  color: var(--muted);
}

/* === VIEWS === */
.view { display: none; }
.view.active { display: block; }

/* === STATS GRID === */
.stats-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stats-grid.professional {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

/* === COMMAND BAR === */
.command-bar {
  display: none;
  grid-template-columns: minmax(200px, 0.7fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.command-bar h2 { margin-bottom: 2px; }

.command-bar p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.command-actions {
  display: grid;
  grid-template-columns: 1.15fr repeat(3, 1fr);
  gap: 8px;
}

.command-actions button { min-width: 0; }

#view-dashboard > .stats-grid.professional,
#view-dashboard > .command-bar,
#view-dashboard > .dashboard-summary,
#view-dashboard > .content-grid.dashboard-grid,
#view-dashboard > section.panel:not(.dashboard-hero):not(.dashboard-recent-panel):last-child {
  display: none;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
  border-left: 5px solid #22c55e;
}

.dashboard-hero.is-warn { border-left-color: #f59e0b; }
.dashboard-hero.is-danger { border-left-color: #ef4444; }
.dashboard-hero.is-good { border-left-color: #22c55e; }

.dashboard-health {
  display: grid;
  gap: 5px;
}

.dashboard-health span,
.ops-card span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboard-health strong {
  font-size: 28px;
  line-height: 1.05;
}

.dashboard-health small {
  color: var(--muted);
  font-size: 14px;
}

.dashboard-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.ops-card {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.ops-card strong {
  font-size: 34px;
  line-height: 1;
}

.ops-card small {
  color: var(--muted);
  font-size: 13px;
}

.ops-card.danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.13), var(--surface));
}

.ops-card.urgent {
  border-color: rgba(245, 158, 11, 0.48);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.14), var(--surface));
}

.ops-card.warn {
  border-color: rgba(14, 165, 233, 0.42);
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.12), var(--surface));
}

.ops-card.info {
  border-color: rgba(124, 58, 237, 0.38);
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.11), var(--surface));
}

.dashboard-focus-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 14px;
  margin-bottom: 14px;
}

.focus-panel {
  min-height: 310px;
}

.dashboard-list {
  max-height: 340px;
  overflow: auto;
  padding-right: 2px;
}

.dashboard-secondary {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  margin-bottom: 14px;
}

.dashboard-recent-panel {
  margin-bottom: 0;
}

/* === METRIC CARDS === */
.metric,
.panel,
.client-card,
.detail-summary article,
.system-grid article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.metric {
  padding: 15px 16px;
  position: relative;
  overflow: hidden;
}

.metric-link {
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.metric-link:hover,
.metric-link:focus-visible {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: var(--surface-2);
  outline: none;
}

/* Borda esquerda sutil em vez de barra colorida no topo */
.metric::before {
  display: none;
}

.metric span,
.metric strong,
.metric small { display: block; }

.metric span {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric strong {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
}

.metric small { margin-top: 6px; }

.metric.mini {
  padding: 13px 14px;
}

.metric.mini strong {
  font-size: 20px;
}

.dashboard-summary {
  margin-bottom: 16px;
}

.dashboard-charts {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  margin-bottom: 0;
}

.metric.report strong { color: var(--brand); }
.metric.urgent strong,
.metric.danger strong { color: var(--ink); }

/* === CONTENT GRIDS === */
.content-grid,
.form-grid,
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 14px;
  margin-bottom: 16px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
}

/* === PANELS === */
.panel {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
}

.panel-head { margin-bottom: 14px; }

.panel-head p {
  margin: 0;
  font-size: 13px;
}

.panel-head.split {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

/* === FILTROS === */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-bar {
  margin: 0 0 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.filter {
  min-height: 28px;
  white-space: nowrap;
  font-size: 12px;
  padding: 0 10px;
}

/* === LISTAS === */
.activity-list,
.due-list,
.attention-list,
.receipt-list {
  display: grid;
  gap: 8px;
}

.due-list.horizontal {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.activity,
.due-item,
.attention-item,
.receipt-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* Bordas esquerda coloridas — funcionais, discretas */
.attention-item {
  align-items: center;
}

.activity,
.due-item,
.receipt-item,
.attention-item {
  border-left: 1px solid var(--line);
}

.attention-item button,
.activity button,
.due-item button,
.receipt-item a { flex: 0 0 auto; }

/* === STATUS PILLS === */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pill.ativo,
.pill.teste,
.pill.fechado,
.pill.permanente,
.pill.expirado,
.pill.inactive,
.pill.warn {
  color: var(--ink-2);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
}

.pill.status-pill {
  min-height: 26px;
  padding: 0 10px;
  font-weight: 800;
}

.pill.status-pill.ativo {
  color: #065f46;
  background: #d1fae5;
  border-color: #6ee7b7;
}

.pill.status-pill.teste {
  color: #075985;
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.pill.status-pill.permanente {
  color: #14532d;
  background: #bbf7d0;
  border-color: #4ade80;
}

.pill.status-pill.warn {
  color: #7c2d12;
  background: #ffedd5;
  border-color: #fdba74;
}

.pill.status-pill.expirado,
.pill.status-pill.inactive {
  color: #7f1d1d;
  background: #fee2e2;
  border-color: #fca5a5;
}

[data-theme="dark"] .pill.status-pill.ativo {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(74, 222, 128, 0.45);
}

[data-theme="dark"] .pill.status-pill.teste {
  color: #bae6fd;
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(125, 211, 252, 0.45);
}

[data-theme="dark"] .pill.status-pill.permanente {
  color: #bbf7d0;
  background: rgba(22, 163, 74, 0.24);
  border-color: rgba(74, 222, 128, 0.5);
}

[data-theme="dark"] .pill.status-pill.warn {
  color: #fed7aa;
  background: rgba(249, 115, 22, 0.2);
  border-color: rgba(251, 146, 60, 0.52);
}

[data-theme="dark"] .pill.status-pill.expirado,
[data-theme="dark"] .pill.status-pill.inactive {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.5);
}

/* === TABELAS === */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--surface);
}

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

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
}

td {
  color: var(--ink);
  font-size: 14px;
}

tbody tr:last-child td { border-bottom: none; }

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

tr[data-client-id] { cursor: pointer; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.row-actions button {
  min-height: 30px;
  min-width: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 11px;
}

.row-actions button:hover { background: var(--surface-3); }

.action-icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.action-icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-icon-button[data-action="extend-test"] {
  color: #075985;
  border-color: #7dd3fc;
  background: #e0f2fe;
}

.action-icon-button[data-action="copy-access"] {
  color: #4c1d95;
  border-color: #c4b5fd;
  background: #ede9fe;
}

.action-icon-button[data-action="link"] {
  color: #064e3b;
  border-color: #6ee7b7;
  background: #d1fae5;
}

.action-icon-button[data-action="clear-device"] {
  color: #7c2d12;
  border-color: #fdba74;
  background: #ffedd5;
}

[data-theme="dark"] .action-icon-button[data-action="extend-test"] {
  color: #bae6fd;
  border-color: rgba(125, 211, 252, 0.45);
  background: rgba(14, 165, 233, 0.16);
}

[data-theme="dark"] .action-icon-button[data-action="copy-access"] {
  color: #ddd6fe;
  border-color: rgba(196, 181, 253, 0.42);
  background: rgba(124, 58, 237, 0.16);
}

[data-theme="dark"] .action-icon-button[data-action="link"] {
  color: #bbf7d0;
  border-color: rgba(110, 231, 183, 0.42);
  background: rgba(16, 185, 129, 0.16);
}

[data-theme="dark"] .action-icon-button[data-action="clear-device"] {
  color: #fed7aa;
  border-color: rgba(253, 186, 116, 0.45);
  background: rgba(249, 115, 22, 0.16);
}

.whatsapp-action {
  border-color: #22c55e !important;
  background: #22c55e !important;
  color: #052e16 !important;
  font-weight: 700 !important;
}

.whatsapp-action::before {
  content: "W";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 5px;
  border-radius: 999px;
  background: #052e16;
  color: #bbf7d0;
  font-size: 10px;
  font-weight: 800;
}

/* === AÇÕES DO DETALHE === */
.detail-actions {
  display: grid;
  grid-template-columns: minmax(160px, 0.65fr) minmax(240px, 1fr) minmax(200px, 0.75fr);
  gap: 10px;
}

.action-group {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.action-group > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.action-group > div {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 6px;
}

.action-group button { width: 100%; }

.danger-group {
  border-color: #fecaca;
  background: #fff5f5;
}

/* === CLIENT CARDS (mobile) === */
.client-cards {
  display: none;
  gap: 10px;
}

.client-card {
  padding: 16px;
  display: grid;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.client-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--brand);
}

.client-card header,
.client-card .card-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.client-card .row-actions {
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: flex-end;
}

.client-card .row-actions button {
  width: 34px;
  height: 34px;
  min-height: 34px;
}

.client-card h3 {
  margin: 0 0 3px;
  font-size: 15px;
}

.card-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.card-meta div {
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card-meta span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-meta strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

/* === FORMULÁRIOS === */
.fields,
.integration-grid,
.system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.customer-form {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  align-items: start;
}

.create-client-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--ink);
}

.create-client-dialog::backdrop {
  background: rgba(3, 7, 18, 0.64);
  backdrop-filter: blur(3px);
}

.create-dialog-shell {
  display: grid;
  gap: 16px;
  padding: 18px;
  overflow: auto;
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.create-client-dialog .customer-form {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
}

.create-client-dialog .customer-email-step {
  max-width: none;
}

.customer-email-step {
  max-width: 560px;
}

.customer-details-step[hidden] {
  display: none !important;
}

.access-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 16px);
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}

label textarea,
label input,
label select {
  font-weight: 400;
}

label input[readonly] {
  color: var(--muted);
  background: var(--surface-2);
  cursor: default;
}

label select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.access-select {
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

label:has(textarea),
.integration-grid label:nth-child(3),
.integration-grid label:nth-child(4),
.integration-grid label:nth-child(5) {
  grid-column: 1 / -1;
}

/* === PLAN PICKER === */
.plan-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.plan {
  position: relative;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 120ms ease;
}

.plan input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.plan strong,
.plan span { display: block; }

.plan span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.plan.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
  background: var(--brand-light);
}

/* === LISTAS MISC === */
.plan-grid,
.notification-list,
.agenda-list,
.log-list,
.user-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.notification-item,
.agenda-item,
.log-item,
.user-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  align-items: center;
}

.notification-item small,
.agenda-item small,
.log-item small,
.user-item small { color: var(--muted); }

.notification-item time,
.agenda-item .pill,
.log-item time {
  font-size: 12px;
  color: var(--muted);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.checkbox-line input {
  width: 16px;
  min-height: 16px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.access-panel .form-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
}

.access-panel .form-actions button { width: 100%; }

/* === RELATÓRIOS / INTEGRAÇÃO === */
.reports-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
}

.integration-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  max-width: 900px;
}

.integration-panel + .integration-panel { margin-top: 0; }

.system-grid article {
  padding: 14px;
  background: var(--surface-2);
  box-shadow: none;
}

.system-grid span,
.system-grid strong { display: block; }

.system-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.system-grid strong { margin-top: 6px; }

/* === LICENSE PANEL (novo painel de ações de licença) === */
.license-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.old-license-panel { display: none; }

.detail-action-panel {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.detail-license-card {
  padding: 14px;
}

.detail-license-card .panel-head {
  margin-bottom: 10px;
}

.license-control {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.license-control.single-action {
  grid-template-columns: 1fr;
}

.license-control.single-action button {
  justify-self: start;
}

.access-adjust-button {
  min-width: 220px;
  min-height: 42px;
  background: #16a34a;
  border-color: #15803d;
  color: #f0fdf4;
}

.access-adjust-button:hover {
  background: #15803d;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-actions button {
  min-height: 34px;
}

.danger-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.detail-more-actions {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--surface);
}

.detail-more-actions summary {
  padding: 12px 14px;
}

.detail-more-actions .time-presets {
  padding: 0 14px 14px;
}

.active-soft {
  background: var(--brand-light) !important;
  border-color: var(--brand) !important;
  color: var(--brand-text) !important;
}

.danger-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.license-section { display: grid; gap: 8px; }

.license-section-label {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.license-section-label.danger-label { color: var(--danger); }

.time-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.license-section--split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* === EDITAR DADOS — colapsável === */
.detail-edit-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.detail-edit-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  user-select: none;
  list-style: none;
}

.detail-edit-toggle::-webkit-details-marker { display: none; }

.detail-edit-toggle::after {
  content: "▾";
  font-size: 13px;
  color: var(--muted);
  transition: transform 180ms ease;
}

details[open] .detail-edit-toggle::after { transform: rotate(180deg); }

.detail-edit-section .detail-form { padding: 16px; }

/* === CONFIRM DIALOG === */
.confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-md);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

.confirm-shell {
  padding: 24px;
  display: grid;
  gap: 16px;
}

.confirm-header h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.confirm-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  min-height: 16px;
}

.confirm-body { display: grid; gap: 10px; }

.confirm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.time-preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.access-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.access-choice-section {
  display: grid;
  gap: 8px;
}

.access-choice-section > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.subscription-section {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.subscription-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.time-preset-btn {
  min-height: 30px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 100ms, border-color 100ms, color 100ms;
}

.time-preset-btn:hover { background: var(--surface-3); }

.time-preset-btn.selected {
  background: var(--brand-light);
  color: var(--brand-text);
  border-color: var(--brand);
  font-weight: 600;
}

.time-preset-btn.plan-choice {
  border-color: rgba(34, 197, 94, 0.45);
}

.custom-time-input {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.custom-time-label {
  display: block;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.custom-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-time-row input {
  width: 72px;
  flex-shrink: 0;
  text-align: center;
}

.custom-time-row span {
  font-size: 13px;
  color: var(--muted);
}

.confirm-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 400;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.5;
}

.confirm-check input[type="checkbox"] {
  width: 15px;
  min-height: 15px;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

.confirm-danger-note {
  padding: 12px 14px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  font-size: 13px;
  color: #b91c1c;
  line-height: 1.5;
  margin: 0;
}

.confirm-verify-label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}

.access-pre {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  font-family: inherit;
  margin: 0;
}

/* === DIALOG === */
.client-dialog {
  width: min(1020px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-md);
}

.client-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
}

.dialog-shell {
  padding: 20px;
  display: grid;
  gap: 16px;
  background: var(--surface);
}

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

.detail-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}

.detail-summary article {
  padding: 11px 12px;
  background: var(--surface-2);
  box-shadow: none;
}

.detail-summary span,
.detail-summary strong { display: block; }

.detail-summary span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-summary strong {
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.detail-contact-card {
  display: grid;
  gap: 8px;
}

.detail-contact-card .whatsapp-action {
  width: fit-content;
}

.detail-form,
.receipt-panel,
.activity-panel { padding-top: 0; }

.receipt-panel .panel-head,
.activity-panel .panel-head {
  padding: 14px 16px 0;
}

.receipt-panel .receipt-form,
.receipt-panel .receipt-list,
.activity-panel .activity-list {
  margin: 0 16px 16px;
}

.receipt-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.receipt-item { align-items: center; }

.receipt-item a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

/* === FAB === */
.fab {
  display: none !important;
  position: fixed;
  right: 18px;
  bottom: 24px;
  width: 50px;
  height: 50px;
  border-radius: 999px;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  z-index: 6;
  align-items: center;
  justify-content: center;
}

/* === TOAST === */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 16px;
  background: #18181b;
  color: #fafafa;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: 150ms ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* === EMPTY STATE === */
.empty {
  padding: 24px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  background: var(--surface-2);
}

/* ================================================
   RESPONSIVO — TABLET (≤1240px)
   ================================================ */
@media (max-width: 1240px) {
  :root { --sidebar-width: 220px; }

  .stats-grid.professional {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .ops-grid,
  .dashboard-secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .command-bar,
  .command-actions {
    grid-template-columns: 1fr 1fr;
  }

  .search input { width: 200px; }
}

/* ================================================
   RESPONSIVO — MOBILE (≤980px)
   Sidebar vira drawer deslizante com hambúrguer
   ================================================ */
@media (max-width: 980px) {
  body {
    display: block;
    overflow-x: hidden;
  }

  /* Sidebar: drawer oculto à esquerda */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    box-shadow: var(--shadow-md);
  }

  .sidebar.open { transform: translateX(0); }

  /* Overlay ativado quando sidebar está aberta */
  .sidebar-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* Hambúrguer aparece no mobile */
  .sidebar-toggle { display: flex; }

  /* Topbar ajustada para mobile */
  .topbar {
    margin: 0 -14px 16px;
    padding: 0 14px;
  }

  .app { padding: 0 14px 40px; }

  /* Primeiro filho do app (topbar) ajustado */
  .app > header.topbar {
    margin-top: 0;
  }

  .search input { width: 150px; }

  /* Grids viram coluna única */
  .stats-grid,
  .stats-grid.professional,
  .report-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .content-grid,
  .dashboard-grid,
  .dashboard-focus-grid,
  .report-controls,
  .form-grid,
  .customer-form,
  .fields,
  .integration-grid,
  .system-grid,
  .detail-summary,
  .license-control,
  .command-bar,
  .command-actions,
  .detail-actions {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
  }

  .dashboard-hero-actions {
    justify-content: flex-start;
  }

  .access-panel { position: static; }

  .panel-head.split {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Tabela some, cards aparecem */
  .client-table-wrap { display: none; }
  .client-cards { display: grid; }

  .fab {
    display: flex;
  }

  /* Dialog fullscreen no mobile */
  .client-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .dialog-shell {
    min-height: 100dvh;
    padding: 16px 16px 32px;
  }

  .dialog-header,
  .client-card header,
  .client-card .card-footer {
    align-items: stretch;
  }

  .attention-item,
  .activity,
  .due-item,
  .receipt-item {
    flex-direction: column;
  }

  .receipt-form { grid-template-columns: 1fr; }

  .detail-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ================================================
   RESPONSIVO — MOBILE PEQUENO (≤640px)
   ================================================ */
@media (max-width: 640px) {
  h1 { font-size: 17px; }

  .login-card { padding: 24px; }

  .plan-picker,
  .card-meta,
  .ops-grid,
  .dashboard-secondary,
  .access-choice-grid,
  .subscription-grid,
  .permissions-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-health strong {
    font-size: 23px;
  }

  .dashboard-hero-actions button {
    flex: 1 1 120px;
  }

  .metric strong { font-size: 22px; }

  .search input { width: 110px; }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .filter { flex: 0 0 auto; }

  .form-actions,
  .detail-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .access-panel .form-actions { grid-template-columns: 1fr; }

}
