/* ═══════════════════════════════════════════════════════════════════════════
   Próvision — App Shell Design System  v2 (Phase 5 Visual Polish)
   Sidebar · Top Bar · Layout · Forms · Modals · Components
   ═══════════════════════════════════════════════════════════════════════════ */

/* :root tokens vivem em css/design-tokens.css. Aliases legacy (--bg-primary,
   --accent-purple, --shadow-purple, --font-heading, etc.) também ficam lá. */

/* ── Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App Layout Grid ───────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "header header"
    "sidebar content";
  min-height: 100vh;
  transition: grid-template-columns 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-layout.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.app-sidebar {
  grid-area: sidebar;
  background: var(--bg-sidebar);
  box-shadow: 1px 0 0 var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 100;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed); }

/* Área rolável: menu + “Voltar ao Site”; botão Recolher fica fixo no rodapé */
.sidebar-body-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Sidebar scrollbar (só na área rolável) */
.sidebar-body-scroll::-webkit-scrollbar { width: 3px; }
.sidebar-body-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-body-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidebar-body-scroll::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 56px;
  box-sizing: border-box;
  transition: var(--transition-fast);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-sidebar);
}

.global-header-brand .sidebar-logo {
  position: relative;
  top: auto;
  height: var(--topbar-height);
  width: 100%;
  border-bottom: none;
}
.sidebar-logo:hover .sidebar-logo-icon {
  box-shadow: var(--shadow-purple);
  transform: scale(1.05);
}

.sidebar-logo-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #C49A3C, #E8B84B);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  transition: var(--transition-base);
  box-shadow: 0 2px 8px rgba(196,154,60,.35);
}

.sidebar-logo-text {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s, width 0.25s;
  letter-spacing: -.01em;
}
.sidebar-collapsed .sidebar-logo-text { opacity: 0; width: 0; }

/* Section dividers */
.sidebar-section { padding: 20px 0 6px; }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
  padding: 0 18px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}
.sidebar-collapsed .sidebar-section-label { opacity: 0; height: 0; margin: 0; padding: 0; }

/* Nav items — pastilhas levemente inset (continuidade tipo “floating pill”, sem encostar à borda da coluna) */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.68);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.1s ease;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  border: none;
  background: none;
  box-sizing: border-box;
  width: calc(100% - 12px);
  margin: 2px 6px;
  text-align: left;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
}

.sidebar-item:active { transform: scale(0.98); }

.sidebar-item:focus-visible {
  outline: 2px solid #C49A3C;
  outline-offset: 1px;
}

.sidebar-item.active {
  background: rgba(196,154,60,0.14);
  color: #C49A3C;
  border-left: none;
  padding-left: 10px;
  font-weight: 600;
  border-radius: var(--radius-lg);
}
.sidebar-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 4px;
  border-radius: 0 3px 3px 0;
  background: #C49A3C;
  box-shadow: 0 0 12px rgba(196, 154, 60, 0.35);
}
.sidebar-collapsed .sidebar-item.active::before {
  display: none;
}
.sidebar-collapsed .sidebar-item.active {
  background: rgba(196,154,60,0.18);
}

.sidebar-item-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-item-icon svg { width: 17px; height: 17px; stroke-width: 1.7; }

.sidebar-item-label { transition: opacity 0.2s; overflow: hidden; }
.sidebar-collapsed .sidebar-item-label { opacity: 0; width: 0; }
.sidebar-collapsed .sidebar-item {
  justify-content: center;
  padding: 10px;
  width: 100%;
  margin: 2px 0;
}
.sidebar-collapsed .sidebar-item.active { padding-left: 10px; }

/* Tooltip on collapsed sidebar */
.sidebar-collapsed .sidebar-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--navy, #1B2540);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 200;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  animation: tooltipIn 0.1s ease;
}

@keyframes tooltipIn {
  from { opacity: 0; transform: translateY(-50%) translateX(-4px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}

/* Sidebar collapse toggle */
.sidebar-toggle {
  flex-shrink: 0;
  margin: 0 8px 12px;
  padding: 9px;
  border-radius: var(--radius-md);
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  transition: var(--transition-base);
}
.sidebar-toggle:hover {
  border-color: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.06);
}
.sidebar-toggle:active { transform: scale(0.97); }
.sidebar-collapsed .sidebar-toggle-label { display: none; }

/* ── Header global (logo + contexto) — faixa contínua, estilo HubSpot ──── */
.app-global-header {
  grid-area: header;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  height: var(--topbar-height);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 110;
  transition: box-shadow 0.22s ease;
  box-sizing: border-box;
}

.global-header-brand {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapsed .global-header-brand {
  width: var(--sidebar-collapsed);
}

.global-header-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.topbar-breadcrumb {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 15px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-purple-bg);
  border: 1.5px solid var(--accent-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-purple-light);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(124,58,237,.1);
}

.topbar-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-body);
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-btn:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background: var(--accent-red-bg);
}
.topbar-btn:active { transform: scale(0.97); }

/* ── Content Area ──────────────────────────────────────────────────────── */
.app-content {
  grid-area: content;
  padding: 24px 32px;
  /* Sem margin-top: o grid já coloca a área "content" na 2.ª linha (abaixo da topbar).
     margin-top duplicava ~52px de “faixa” transparente (fundo do layout) entre topbar e conteúdo. */
  margin-top: 0;
  min-height: calc(100vh - var(--topbar-height));
  min-width: 0;        /* permite que grid 1fr limite o tamanho (evita overflow) */
  overflow-x: hidden;  /* clips filhos; ativa scroll interno do .pipeline-container */
}

/* ═══════════════════════════════════════════════════════════════════════
   REUSABLE COMPONENTS
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent-purple);
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  line-height: 1.4;
}
.btn-primary:hover {
  background: var(--accent-purple-hover);
  box-shadow: var(--shadow-purple);
}
.btn-primary:active  { transform: scale(0.97); background: var(--accent-purple-hover); }
.btn-primary:focus-visible { outline: 2px solid var(--accent-purple-light); outline-offset: 2px; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 9px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  line-height: 1.4;
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--bg-surface-hover); }
.btn-ghost:active  { transform: scale(0.97); }
.btn-ghost:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 2px; }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-sm { padding: 5px 13px; font-size: 12px; gap: 5px; }
.btn-xs { padding: 3px 9px;  font-size: 11px; gap: 4px; border-radius: var(--radius-sm); }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }

.card-glass {
  background: rgba(255,255,255,.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.25s ease;
}
.card-glass:hover { border-color: rgba(255,255,255,.12); box-shadow: var(--shadow-sm); }

/* ── KPI Cards ─────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(124,58,237,.05) 0%, transparent 60%);
  pointer-events: none;
}
.kpi-card:hover {
  border-color: rgba(124,58,237,.3);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg { width: 20px; height: 20px; stroke-width: 1.6; }

.kpi-label {
  font-size: 11px;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -.02em;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
}
.badge-ativo     { background: rgba(16,185,129,.15);  color: #34d399; border: 1px solid rgba(16,185,129,.25); }
.badge-pausado   { background: rgba(245,158,11,.15);  color: #fbbf24; border: 1px solid rgba(245,158,11,.25); }
.badge-concluido { background: rgba(124,58,237,.15);  color: #a78bfa; border: 1px solid rgba(124,58,237,.25); }
.badge-erro      { background: rgba(239,68,68,.15);   color: #f87171; border: 1px solid rgba(239,68,68,.25); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-base {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.table-base thead { background: rgba(13,17,23,.5); }
.table-base th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-label);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}
.table-base td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid rgba(33,38,45,.5);
  color: var(--text-secondary);
  vertical-align: middle;
}
.table-base tbody tr { transition: background 0.12s; }
.table-base tbody tr:hover td { background: var(--bg-surface-hover); }
.table-base tr:last-child td { border-bottom: none; }

/* ── Section Headers ───────────────────────────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
  line-height: 1.2;
}
.section-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 400;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 11px;
  color: var(--text-label);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 13px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.form-input:hover  { border-color: var(--border-hover); }
.form-input:focus  {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:disabled { opacity: 0.5; cursor: not-allowed; }

textarea.form-input { resize: vertical; min-height: 72px; line-height: 1.5; }

select.form-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Legacy aliases */
.input-base  { @extend .form-input; }
.input-label { @extend .form-label; }

/* ── Modals ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 20, 0.75);
  z-index: 300;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: overlayIn 0.2s ease;
}
.modal-overlay.open { display: flex; }
/* triggered via JS style.display = "flex" */

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  width: min(520px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s cubic-bezier(0.34, 1.3, 0.64, 1);
  overflow: hidden;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

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

.modal-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  transition: var(--transition-fast);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--bg-surface-hover); border-color: var(--border); color: var(--text-primary); }
.modal-close:active { transform: scale(0.93); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Legacy compat */
.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: min(480px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s cubic-bezier(0.34, 1.3, 0.64, 1);
}

/* ── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-label);
  font-size: 14px;
  line-height: 1.6;
}
.empty-state svg { opacity: 0.3; margin-bottom: 4px; }
.empty-state a { color: var(--accent-purple); text-decoration: underline; }

/* ── Quick Actions ──────────────────────────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
}
.quick-action::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(124,58,237,.06) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.2s;
}
.quick-action:hover {
  border-color: var(--accent-purple);
  background: var(--bg-surface-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.quick-action:hover::after { opacity: 1; }
.quick-action:active { transform: scale(0.99); }

.quick-action-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Alert Cards ────────────────────────────────────────────────────────── */
.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 8px;
  transition: var(--transition-fast);
}
.alert-card:hover { filter: brightness(1.05); }
.alert-card-warn {
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.2);
  color: #fbbf24;
}
.alert-card-info {
  background: rgba(59,130,246,.08);
  border: 1px solid rgba(59,130,246,.2);
  color: #93c5fd;
}
.alert-card-success {
  background: rgba(16,185,129,.08);
  border: 1px solid rgba(16,185,129,.2);
  color: #6ee7b7;
}
.alert-card-danger {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  color: #f87171;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.app-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-green);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transition: opacity 0.25s, transform 0.25s cubic-bezier(0.34, 1.3, 0.64, 1);
  z-index: 999;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}
.app-toast.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.app-toast.error { border-left-color: var(--accent-red); }

/* ── Loading Overlay (with spinner) ────────────────────────────────────── */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(244,246,249,0.95);
  z-index: 500;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  font-size: 13px;
  color: #1B2540;
  letter-spacing: .01em;
}
.loading-overlay.show { display: flex; }

.loading-overlay::before {
  content: '';
  width: 36px; height: 36px;
  border: 2.5px solid var(--border);
  border-top-color: #C49A3C;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Skeleton Screen (shimmer) ──────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface)       0%,
    var(--bg-surface-hover) 40%,
    var(--bg-surface)       80%
  );
  background-size: 300% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-text   { height: 13px; border-radius: var(--radius-xs); }
.skeleton-title  { height: 20px; width: 40%; border-radius: var(--radius-xs); }
.skeleton-avatar { width: 36px; height: 36px; border-radius: 50%; }
.skeleton-card   { height: 120px; border-radius: var(--radius-lg); }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInFast {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in      { animation: fadeIn     0.3s ease forwards; }
.fade-in-fast { animation: fadeInFast 0.15s ease forwards; }
.slide-up     { animation: slideUp    0.35s ease forwards; }

/* Staggered children */
.stagger-children > * {
  animation: fadeIn 0.3s ease both;
}
.stagger-children > *:nth-child(1)  { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2)  { animation-delay: 0.1s;  }
.stagger-children > *:nth-child(3)  { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4)  { animation-delay: 0.2s;  }
.stagger-children > *:nth-child(5)  { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6)  { animation-delay: 0.3s;  }

/* ── Mobile Hamburger ───────────────────────────────────────────────────── */
.mobile-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}
.mobile-hamburger:hover { color: var(--text-primary); background: var(--bg-surface-hover); }

.sidebar-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas:
      "header"
      "content";
  }

  .global-header-brand {
    width: auto;
    min-width: 52px;
    flex-shrink: 0;
  }

  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    z-index: 200;
    width: var(--sidebar-width);
    top: var(--topbar-height);
  }
  .app-sidebar.mobile-open { transform: translateX(0); }

  .sidebar-mobile-overlay.active { display: block; }
  .mobile-hamburger               { display: flex; }

  .app-content   { margin-left: 0 !important; padding: 16px; }

  .section-title { font-size: 17px; }
  .kpi-grid      { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .modal         { width: 96vw; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .app-content { padding: 12px; }
}

/* ── Divider ────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── Progress Bar ───────────────────────────────────────────────────────── */
.progress-track {
  height: 6px;
  background: var(--bg-surface-hover);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-purple);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Scrollbar (global custom) ──────────────────────────────────────────── */
::-webkit-scrollbar         { width: 6px; height: 6px; }
::-webkit-scrollbar-track   { background: transparent; }
::-webkit-scrollbar-thumb   { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ── Focus visible (accessibility) ─────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ── Btn Voltar (saída de container/módulo/bloco) ───────────────────────── */
/* Uso: <button class="btn-voltar" onclick="fecharPainel()">← Voltar</button>  */
/* ou: <a href="/dashboard" class="btn-voltar">← Voltar</a>                   */
.btn-voltar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}
.btn-voltar:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}
.btn-voltar:active { transform: scale(0.97); }
.btn-voltar svg { width: 14px; height: 14px; flex-shrink: 0; }
a:focus-visible, button:focus-visible { outline-offset: 3px; }
