@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;0,14..32,900&display=swap');

:root {
  /* DadosJá Premium Dark Palette */
  --bg:            hsl(220, 16%, 7%);
  --surface:       hsla(220, 14%, 12%, 0.80);
  --surface-solid: hsl(220, 13%, 11%);
  --surface-hover: hsl(220, 12%, 15%);
  --border:        hsla(220, 10%, 28%, 0.70);
  --border-focus:  hsl(213, 100%, 68%);
  --text:          hsl(213, 50%, 96%);
  --muted:         hsl(213, 12%, 56%);
  --primary:       hsl(142, 58%, 38%);
  --accent:        hsl(213, 100%, 68%);
  --danger:        hsl(4, 90%, 60%);
  --warning:       hsl(38, 95%, 54%);
  --success:       hsl(142, 52%, 52%);
  --foreground:    hsl(213, 50%, 96%);

  --glass:         blur(18px);
  --radius:        12px;
  --radius-lg:     20px;
  --transition:    all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow:        0 12px 40px rgba(0,0,0,0.38), 0 2px 8px rgba(0,0,0,0.18);
  --shadow-sm:     0 4px 16px rgba(0,0,0,0.22);
  --glow-accent:   0 0 24px hsla(213,100%,68%,0.18);
}

/* Light Mode Palette */
html.light-mode {
  --bg:            hsl(210, 20%, 98%);
  --surface:       hsla(210, 16%, 97%, 0.95);
  --surface-solid: hsl(210, 16%, 96%);
  --surface-hover: hsl(210, 14%, 92%);
  --border:        hsla(210, 14%, 85%, 0.80);
  --border-focus:  hsl(213, 88%, 52%);
  --text:          hsl(220, 26%, 14%);
  --muted:         hsl(215, 14%, 46%);
  --primary:       hsl(142, 58%, 36%);
  --accent:        hsl(213, 88%, 52%);
  --danger:        hsl(4, 78%, 50%);
  --warning:       hsl(38, 90%, 46%);
  --success:       hsl(142, 52%, 40%);
  --foreground:    hsl(220, 26%, 14%);

  --shadow:        0 8px 32px rgba(0,0,0,0.09), 0 2px 6px rgba(0,0,0,0.05);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.07);
  --glow-accent:   0 0 20px hsla(213,88%,52%,0.10);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 10% 0%,   hsla(213,100%,68%,0.055) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 100%,  hsla(142,52%,52%,0.04)  0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 55% 50%,   hsla(213,100%,68%,0.02) 0%, transparent 60%);
  color: var(--text);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* --- FORM COMPONENTS (FIXING "UGLY" INPUTS) --- */
input, select, textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
  background: var(--surface-hover);
}

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

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* Melhorar visibilidade do select e options */
select option {
  background: var(--surface-solid);
  color: var(--text);
}

select option:checked {
  background: var(--accent);
  color: white;
}

/* Chart type select specific styling */
select[id^="chart-type-"] {
  background-color: var(--surface-solid) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 8px center !important;
  padding-right: 28px !important;
  background-size: 14px !important;
  appearance: none !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 4px !important;
  padding: 6px 8px !important;
  font-size: 0.8rem !important;
  cursor: pointer !important;
}

select[id^="chart-type-"]:hover {
  border-color: var(--accent) !important;
  background-color: var(--surface-hover) !important;
}

select[id^="chart-type-"]:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2) !important;
}

/* --- VISÃO GERAL: seções por datasource --- */
.overview-section {
  animation: fadeIn 0.3s ease;
}

.overview-section .kpi-card-grid {
  min-height: 90px;
}

/* O grid-stack na overview fica desabilitado — usamos CSS grid manual */
.overview-mode #dashboard-grid {
  display: block !important;
  overflow: visible !important;
}

/* --- DRILLDOWN MODAL (tela grande) --- */
#drilldown-modal .dialog-card {
  width: 95vw;
  max-width: 95vw;
  height: 90vh;
  max-height: 90vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#drilldown-pagination .btn {
  padding: 3px 8px;
  font-size: 0.75rem;
  min-width: 32px;
}

/* --- DRILLDOWN TABLE STYLING --- */
#drilldown-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  border-right: 1px solid var(--border);
}

#drilldown-table th:last-child {
  border-right: none;
}

#drilldown-table th:hover {
  background: var(--surface-solid);
  color: white;
}

#drilldown-table td {
  padding: 10px 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

#drilldown-table td:last-child {
  border-right: none;
}

#drilldown-table tbody tr:hover {
  background: var(--surface-hover);
}

#drilldown-table tbody tr:nth-child(even) {
  background: rgba(22, 27, 34, 0.5);
}

.dialog-footer {
  background: var(--surface-solid);
}

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 22px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  user-select: none;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.10) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
}
.btn:hover::after { opacity: 1; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), hsl(142,58%,30%));
  color: white;
  box-shadow: 0 4px 14px hsla(142,58%,38%,0.32);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px hsla(142,58%,38%,0.44);
}

.btn-secondary {
  background: var(--surface-solid);
  color: var(--text);
  border-color: var(--border);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--muted);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
  border-color: var(--muted);
}

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

/* --- AUTH PAGES (Centering & Aesthetic) --- */
.auth-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}



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

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

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

/* --- KPI CARDS (OS STYLE) --- */
.kpi-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 24px;
}

.kpi-card {
  flex: 1;
  min-width: 220px;
  background: var(--surface);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 60%);
  pointer-events: none;
}

.kpi-card:hover {
  transform: translateY(-3px) scale(1.01);
  border-color: var(--accent);
  box-shadow: var(--shadow), var(--glow-accent);
}

.kpi-icon {
  width: 48px; height: 48px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid; place-items: center;
  color: var(--accent);
}

.kpi-info { flex: 1; }
.kpi-label { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.kpi-value { font-size: 1.4rem; font-weight: 800; color: var(--text); }

/* --- STATIC FILTER BAR (Not Fixed, Scrolls with Page) --- */
.static-filter-bar {
  padding: 12px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
}

/* COMPACT CENTERED FILTER --- */
.filter-bar-wrap {
  display: flex;
  justify-content: center;
  padding: 12px 0;
  background: rgba(13, 17, 23, 0.4);
  border-bottom: 1px solid var(--border);
}

html.light-mode .filter-bar-wrap {
  background: rgba(249, 250, 251, 0.4);
}

.filter-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-solid);
  padding: 6px 16px;
  border-radius: 50px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.filter-pill input[type="date"] {
  width: auto;
  padding: 4px 8px;
  background: transparent;
  border: none;
  font-size: 0.85rem;
  color: var(--text);
  color-scheme: dark; /* Force browser to pick dark variant */
}

/* Multi-datasource date filters */
#multi-date-filter {
  display: flex;
  align-items: center;
}

#multi-date-filters-container {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Filtro de data por base — Visão Geral */
.multi-base-date-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-solid);
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
}

.multi-base-date-filter input[type="date"] {
  width: 108px;
  padding: 3px 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.74rem;
  color: var(--text);
  color-scheme: dark;
}

.multi-base-date-filter select {
  width: auto;
  min-width: 90px;
  padding: 3px 6px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.74rem;
  color: var(--text);
}

/* Legado — mantido para compatibilidade */
.multi-date-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-solid);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
}

.multi-date-filter-item input[type="date"] {
  width: 110px;
  padding: 4px 6px;
  background: transparent;
  border: none;
  font-size: 0.75rem;
  color: var(--text);
  color-scheme: dark;
}

.multi-date-filter-item select {
  width: auto;
  min-width: 100px;
  padding: 4px 6px;
  background: transparent;
  border: none;
  font-size: 0.75rem;
  color: var(--text);
}

.multi-date-filter-item button {
  padding: 2px 8px;
  font-size: 0.7rem;
}

.multi-date-filter-item .datasource-label {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}


/* --- APP DIALOGS (MODALS) --- */
.app-dialog {
  border: none;
  background: transparent;
  padding: 0;
  width: 100%; height: 100%;
  max-width: 100vw; max-height: 100vh;
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.dialog-card {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 100%; max-width: 500px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
  color: var(--text);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.dialog-header h2 { font-size: 1.4rem; margin: 0; }

.field label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
}

.color-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 10px;
}

.filter-pill select {
  width: auto;
  min-width: 140px;
  padding: 4px 28px 4px 8px;
  background-color: transparent;
  border: none;
  font-size: 0.85rem;
}

/* --- CHAT SIDEBAR (SLIDE LAYOUT) --- */
.chat-sidebar {
  position: relative;
  flex: 0 0 auto;
  width: 0;
  min-width: 0;
  height: 100%;
  background: var(--surface);
  backdrop-filter: var(--glass);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2000;
  box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  overflow: hidden;
}

.chat-sidebar.active {
  width: 380px;
  min-width: 380px;
}

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

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.message-assistant { background: var(--surface-solid); align-self: flex-start; border: 1px solid var(--border); }
.message-user { background: var(--accent); color: white; align-self: flex-end; }

.chat-input-area {
  padding: 20px;
  background: rgba(0,0,0,0.2);
  border-top: 1px solid var(--border);
}

.chat-input-area textarea {
  height: 80px;
  resize: none;
  margin-bottom: 12px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 48px;
  background: var(--surface);
  backdrop-filter: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand-mark {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  font-size: 1.4rem;
  margin-bottom: 24px;
}

.auth-card h1 { margin-bottom: 12px; font-size: 1.8rem; }
.auth-card p { margin-bottom: 32px; color: var(--muted); font-size: 0.95rem; }

.auth-form { display: grid; gap: 20px; }
.auth-footer { margin-top: 32px; text-align: center; font-size: 0.9rem; color: var(--muted); }
.auth-footer a { color: var(--accent); font-weight: 600; text-decoration: none; margin-left: 6px; }


/* --- DASHBOARD PAGE LAYOUT --- */
.dashboard-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.dashboard-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  gap: 0;
}

.dashboard-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  min-width: 0;
  transition: flex 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- DASHBOARD TOPBAR --- */
.dashboard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 24px;
}

/* --- CHART CARDS --- */
.chart-container-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chart-header-simple {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.85rem;
}

.chart-body {
  flex: 1;
  padding: 12px;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chart-body canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --- WIDGET ACTION BUTTONS (info, ocultar, excluir) em todos os widgets --- */
.chart-header .btn-ghost.btn-sm,
.chart-header [class*="btn-ghost"],
.kpi-card-grid .btn-ghost.btn-sm,
.kpi-card-grid [class*="btn-ghost"],
.filter-card-grid .btn-ghost.btn-sm,
.filter-card-grid [class*="btn-ghost"],
.filter-header .btn-ghost.btn-sm,
.filter-header [class*="btn-ghost"] {
  padding: 6px 8px !important;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: var(--transition);
  flex-shrink: 0;
}

.chart-header .btn-ghost.btn-sm:hover,
.kpi-card-grid .btn-ghost.btn-sm:hover,
.filter-card-grid .btn-ghost.btn-sm:hover,
.filter-header .btn-ghost.btn-sm:hover {
  background: rgba(255,255,255,0.08) !important;
  transform: scale(1.10);
  opacity: 1 !important;
}

/* Ícones dentro de botões de widget */
.chart-header .btn-ghost i,
.kpi-card-grid .btn-ghost i,
.filter-card-grid .btn-ghost i,
.filter-header .btn-ghost i {
  width: 16px !important;
  height: 16px !important;
  display: block;
}

/* Selects dentro do chart-header */
.chart-header select {
  font-size: 0.82rem !important;
  padding: 5px 8px !important;
  min-height: 32px;
  border-radius: 8px !important;
}


/* --- TAB ROW --- */
.tab-row {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  padding: 0 4px;
}

.tab-item {
  padding: 11px 22px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.01em;
  position: relative;
}

.tab-item:hover { color: var(--text); background: rgba(255,255,255,0.03); border-radius: 8px 8px 0 0; }
.tab-item.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-shadow: 0 0 20px hsla(213,100%,68%,0.4);
}


.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 32px;
  padding: 40px;
  max-width: 1400px;
  margin: 0 auto;
}

.auth-card p { opacity: 0.85; }

/* --- UTILS --- */
.card-list { display: grid; gap: 14px; }
.entity-card {
  padding: 16px 20px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}
.entity-card:hover { border-color: var(--accent); background: var(--surface-hover); }

hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

.toast-region {
  position: fixed; top: 24px; right: 24px; z-index: 9999;
  display: grid; gap: 12px;
}
.toast {
  padding: 16px 24px;
  border-radius: var(--radius);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
  animation: toastIn 0.3s ease-out forwards;
}
@keyframes toastIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--accent); }

/* --- FILTER DROPDOWN (FLOATING) --- */
.filter-dropdown-menu {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
  animation: dropdownSlideIn 0.15s ease-out;
  padding: 4px 0;
}

@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filter-dropdown-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  color: var(--text);
  transition: all 0.15s ease;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--border);
}

.filter-dropdown-menu label:last-child {
  border-bottom: none;
}

.filter-dropdown-menu label:hover {
  background: var(--surface-hover);
  color: var(--accent);
  padding-left: 14px;
}

.filter-dropdown-menu label input[type="checkbox"]:checked {
  accent-color: var(--accent);
}

.filter-dropdown-menu label input[type="checkbox"] {
  accent-color: var(--accent);
}

/* --- FILE UPLOAD (CUSTOM STYLED) --- */
.file-upload-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-input {
  display: none !important;
}

.file-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(88, 166, 255, 0.2);
  flex-shrink: 0;
  border: none;
}

.file-upload-label i {
  color: white;
  stroke: white;
}

.file-upload-label span {
  color: white;
}

.file-upload-label:hover {
  background: linear-gradient(135deg, #4184f3 0%, #3573ea 100%);
  box-shadow: 0 6px 16px rgba(88, 166, 255, 0.35);
  transform: translateY(-2px);
}

.file-upload-label:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(88, 166, 255, 0.2);
}

.file-upload-name {
  flex: 1;
  padding: 12px 16px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 46px;
  display: flex;
  align-items: center;
}

.file-upload-name.has-file {
  color: var(--accent);
  font-weight: 500;
  background: var(--surface-solid);
  border-color: var(--accent);
}

/* --- MODAL: BASES VINCULADAS --- */
.ds-linked-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.ds-linked-row:last-child {
  border-bottom: none;
}
.ds-color-picker {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: none;
}
.ds-alias-input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 6px 10px;
  transition: border-color 0.15s;
}
.ds-alias-input:focus {
  outline: none;
  border-color: var(--accent);
}
.ds-save-btn {
  flex-shrink: 0;
}

/* --- SUNBURST BACK BUTTON --- */
.sunburst-back-btn {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
.sunburst-back-btn:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.35);
}

/* --- SUNBURST LOADING SPINNER --- */
.sunburst-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sunburst-spin 0.8s linear infinite;
}

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

/* --- HIDDEN WIDGETS SECTION --- */
.hidden-widgets-section {
  margin-top: 60px;
  padding: 32px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(13, 17, 23, 0.5) 0%, rgba(13, 17, 23, 0.3) 100%);
  backdrop-filter: blur(8px);
}

html.light-mode .hidden-widgets-section {
  background: linear-gradient(135deg, rgba(249, 250, 251, 0.5) 0%, rgba(249, 250, 251, 0.3) 100%);
}

.hidden-widgets-section h3 {
  margin: 0 0 24px 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hidden-widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* --- HIDDEN WIDGET CARDS --- */
.hidden-widget-card {
  padding: 16px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  opacity: 0.6;
  position: relative;
  overflow: hidden;
}

.hidden-widget-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(255, 255, 255, 0.05) 10px,
    rgba(255, 255, 255, 0.05) 20px
  );
  pointer-events: none;
}

.hidden-widget-card:hover {
  opacity: 0.85;
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

html.light-mode .hidden-widget-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.hidden-widget-card-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.hidden-widget-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hidden-widget-card-type {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 4px;
}

.hidden-widget-card-action {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  position: relative;
  z-index: 1;
}

/* --- HIDDEN TABS --- */
.tab-item.hidden-tab {
  opacity: 0.4;
  position: relative;
}

.tab-item.hidden-tab::after {
  content: '🔒';
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  font-size: 0.8rem;
}

.tab-item.hidden-tab:hover {
  opacity: 0.6;
}

/* --- TAB MENU BUTTON --- */
.tab-menu-btn {
  transition: opacity 0.2s;
}

.tab-menu-btn:hover {
  color: var(--accent) !important;
}

/* --- WIDGET REORGANIZATION ANIMATION --- */
@keyframes widgetReorganize {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  50% {
    opacity: 0.8;
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.widget-reorganizing .grid-stack-item-content {
  animation: widgetReorganize 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- ANIMATION: HIDDEN WIDGET CARD HIDING (REVEALING) --- */
@keyframes hiddenCardHide {
  0% {
    opacity: 0.4;
    transform: scale(1) translateX(0);
  }
  50% {
    opacity: 0.2;
  }
  100% {
    opacity: 0;
    transform: scale(0.95) translateX(-20px);
  }
}

.hidden-widget-card.hiding {
  animation: hiddenCardHide 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --- HIDDEN WIDGETS SECTION - OVERVIEW MODE (DISCRETE) --- */
.hidden-widgets-section {
  margin-top: 40px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(13, 17, 23, 0.3) 0%, rgba(13, 17, 23, 0.2) 100%);
}

html.light-mode .hidden-widgets-section {
  background: linear-gradient(135deg, rgba(249, 250, 251, 0.3) 0%, rgba(249, 250, 251, 0.2) 100%);
}

.hidden-widgets-section h3 {
  margin: 0 0 16px 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hidden-widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.hidden-widget-card {
  padding: 12px;
  background: rgba(22, 27, 34, 0.5);
  border: 1px solid rgba(48, 54, 61, 0.6);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  min-height: 180px;
}

html.light-mode .hidden-widget-card {
  background: rgba(243, 244, 246, 0.5);
  border: 1px solid rgba(229, 231, 235, 0.6);
}

.hidden-widget-card:hover {
  background: rgba(22, 27, 34, 0.7);
  border-color: rgba(88, 166, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

html.light-mode .hidden-widget-card:hover {
  background: rgba(243, 244, 246, 0.7);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Preview do widget oculto */
.hidden-widget-card-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(13, 17, 23, 0.7) 0%, rgba(13, 17, 23, 0.5) 100%);
  border: 1px solid rgba(48, 54, 61, 0.4);
  border-radius: 6px;
  padding: 16px 12px;
  overflow: hidden;
  min-height: 110px;
  position: relative;
}

html.light-mode .hidden-widget-card-preview {
  background: linear-gradient(135deg, rgba(249, 250, 251, 0.7) 0%, rgba(249, 250, 251, 0.5) 100%);
  border: 1px solid rgba(229, 231, 235, 0.4);
}

.hidden-widget-card-preview::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.01),
    rgba(255, 255, 255, 0.01) 10px,
    transparent 10px,
    transparent 20px
  );
  pointer-events: none;
  border-radius: 6px;
}

.hidden-widget-card-preview-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  white-space: normal;
  word-break: break-word;
  position: relative;
  z-index: 1;
}

.hidden-widget-card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hidden-widget-card-name {
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hidden-widget-card-type {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.hidden-widget-card-action {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.hidden-widget-card-action .btn {
  padding: 6px 12px;
  font-size: 0.75rem;
  width: 100%;
  text-align: center;
}

/* --- OVERVIEW MODE: EXTRA DISCRETE --- */
.hidden-widgets-section.overview-mode {
  background: rgba(255, 255, 255, 0.005);
  border: 1px dashed rgba(48, 54, 61, 0.4);
  padding: 16px;
  margin-top: 20px;
}

html.light-mode .hidden-widgets-section.overview-mode {
  background: rgba(13, 17, 23, 0.005);
  border: 1px dashed rgba(229, 231, 235, 0.4);
}

.hidden-widgets-section.overview-mode h3 {
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.5;
}

.hidden-widgets-section.overview-mode .hidden-widgets-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.hidden-widget-card.overview-mode {
  opacity: 0.35;
  background: rgba(22, 27, 34, 0.2);
  border: 1px solid rgba(48, 54, 61, 0.25);
  padding: 10px;
  min-height: 160px;
}

html.light-mode .hidden-widget-card.overview-mode {
  background: rgba(243, 244, 246, 0.2);
  border: 1px solid rgba(229, 231, 235, 0.25);
}

.hidden-widget-card.overview-mode:hover {
  opacity: 0.5;
  background: rgba(22, 27, 34, 0.35);
  border-color: rgba(48, 54, 61, 0.4);
}

html.light-mode .hidden-widget-card.overview-mode:hover {
  background: rgba(243, 244, 246, 0.35);
  border-color: rgba(229, 231, 235, 0.4);
}

/* ─────────────────────────────────────────────────────────
   MODALS (admin-companies, etc.)
   As divs com class="modal" precisam de overlay fixo
───────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  z-index: 1;
  width: 100%;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px 16px;
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-body {
  padding: 0 32px 8px;
  overflow-y: auto;
  flex: 1;
}

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

/* ─────────────────────────────────────────────────────────
   BRAND-MARK CLICÁVEL (logo → home)
───────────────────────────────────────────────────────── */
.brand-mark[onclick],
a .brand-mark {
  cursor: pointer;
}

.brand-mark:hover {
  transform: scale(1.07);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
}

/* ─────────────────────────────────────────────────────────
   STAT MINI CARDS (admin stats row)
───────────────────────────────────────────────────────── */
.stat-mini-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: var(--glass);
  transition: var(--transition);
}

.stat-mini-card:hover {
  border-color: var(--accent);
}

.stat-mini-card .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-mini-card .stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 4px;
}

/* --- SPINNER INLINE (FOR BUTTONS) --- */
.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   PROACTIVE EMPTY STATE — Botões "Quer que a IA comece pra você?"
   ═══════════════════════════════════════════════════════════════════════════ */

.ai-proactive-empty {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 20px;
  background: linear-gradient(135deg,
              hsla(220, 30%, 14%, 0.65),
              hsla(210, 40%, 18%, 0.55));
  border: 1px dashed hsla(210, 60%, 60%, 0.3);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}
.ai-proactive-empty::before {
  content: "";
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle,
              hsla(210, 80%, 60%, 0.08) 0%,
              transparent 60%);
  animation: aiEmptyShine 8s linear infinite;
  pointer-events: none;
}

[data-theme="light"] .ai-proactive-empty {
  background: linear-gradient(135deg, #f4f7fb, #e8eef7);
  border-color: hsla(210, 60%, 50%, 0.3);
}

.ai-proactive-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text, #e6edf3);
  text-align: center;
  position: relative;
  z-index: 1;
}

.ai-proactive-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 720px;
  position: relative;
  z-index: 1;
}

.ai-proactive-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 12px;
  background: hsla(210, 30%, 20%, 0.4);
  border: 1px solid hsla(210, 50%, 60%, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text, #e6edf3);
  font-family: inherit;
  text-align: center;
}
[data-theme="light"] .ai-proactive-btn {
  background: white;
  border-color: #dde4ee;
  color: #2c3e50;
}

.ai-proactive-btn:hover {
  transform: translateY(-3px);
  border-color: #58A6FF;
  box-shadow: 0 8px 24px hsla(210, 80%, 60%, 0.25);
  background: hsla(210, 50%, 30%, 0.5);
}
[data-theme="light"] .ai-proactive-btn:hover {
  background: #f0f6ff;
}

.ai-proactive-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.ai-proactive-label {
  font-size: 0.92rem;
  font-weight: 600;
}

.ai-proactive-desc {
  font-size: 0.72rem;
  opacity: 0.7;
  font-weight: 500;
}

@keyframes aiEmptyShine {
  0%   { transform: translate(0, 0); }
  50%  { transform: translate(15%, 15%); }
  100% { transform: translate(0, 0); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN PANEL — Shell unificado (sidebar lateral + 4 seções)
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--surface);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-bottom: 1px solid var(--border);
}

.admin-topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.admin-topbar-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.admin-topbar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.admin-topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 0;
  line-height: 1.2;
}
.admin-topbar-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 1px;
}

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

.admin-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.admin-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  backdrop-filter: var(--glass);
  border-right: 1px solid var(--border);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-sidebar-section {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 14px 6px;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: var(--transition);
  font-family: inherit;
}
.admin-nav-item i,
.admin-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.admin-nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.admin-nav-item.is-active {
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.25);
}
.admin-nav-item.is-locked {
  display: none;
}

/* ── Main content ───────────────────────────────────────── */
.admin-main {
  flex: 1;
  padding: 32px 36px 60px;
  overflow-y: auto;
  min-width: 0;
}

.admin-section {
  display: none;
  animation: adminSectionFadeIn 0.22s ease;
}
.admin-section.is-active {
  display: block;
}

@keyframes adminSectionFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.admin-section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-section-title i {
  width: 22px;
  height: 22px;
  color: var(--accent);
}
.admin-section-subtitle {
  margin: 4px 0 0 34px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Stat cards (Visão Geral) ───────────────────────────── */
.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.admin-stat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: var(--glass);
  transition: var(--transition);
  overflow: hidden;
}
.admin-stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0.85;
}
.admin-stat-card[data-tone="success"]::before { background: var(--success); }
.admin-stat-card[data-tone="warning"]::before { background: var(--warning); }
.admin-stat-card[data-tone="muted"]::before   { background: var(--muted); }

.admin-stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.admin-stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
}
.admin-stat-card[data-tone="success"] .admin-stat-card-icon { background: rgba(63,185,80,0.12); color: var(--success); }
.admin-stat-card[data-tone="warning"] .admin-stat-card-icon { background: rgba(240,136,62,0.12); color: var(--warning); }
.admin-stat-card[data-tone="muted"]   .admin-stat-card-icon { background: rgba(139,148,158,0.12); color: var(--muted); }

.admin-stat-card-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}
.admin-stat-card-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

/* ── Cards de conteúdo (lista de empresas, atividade) ───── */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: var(--glass);
}
.admin-card + .admin-card { margin-top: 20px; }

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.admin-card-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-card-title i { width: 16px; color: var(--accent); }

/* ── Filtros (linha de busca + selects) ────────────────── */
.admin-filters {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
.admin-filters .field { margin: 0; }
.admin-filters input,
.admin-filters select {
  padding: 10px 14px;
  font-size: 0.9rem;
}
@media (max-width: 720px) {
  .admin-filters { grid-template-columns: 1fr; }
}

/* ── Tabela admin ──────────────────────────────────────── */
.admin-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 14px 16px;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr {
  transition: background 0.15s;
}
.admin-table tbody tr:hover {
  background: var(--surface-hover);
}

.admin-id-cell {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Badge / pílula ───────────────────────────────────── */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(139,148,158,0.15);
  color: var(--muted);
  border: 1px solid transparent;
  white-space: nowrap;
}
.admin-badge[data-tone="accent"]  { background: rgba(88,166,255,0.15);  color: var(--accent); }
.admin-badge[data-tone="success"] { background: rgba(63,185,80,0.15);   color: var(--success); }
.admin-badge[data-tone="danger"]  { background: rgba(255,107,107,0.15); color: var(--danger); }
.admin-badge[data-tone="warning"] { background: rgba(240,136,62,0.15);  color: var(--warning); }
.admin-badge[data-tone="purple"]  { background: rgba(160,120,255,0.15); color: hsl(265, 80%, 70%); }

.admin-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Action menu (dropdown 3 pontos) ───────────────────── */
.admin-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.admin-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--muted);
  cursor: pointer;
  transition: var(--transition);
}
.admin-action-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface-hover);
}
.admin-action-btn.is-danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.admin-action-btn i { width: 14px; height: 14px; }

.admin-menu {
  position: absolute;
  top: 110%;
  right: 0;
  z-index: 30;
  min-width: 200px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
}
.admin-menu.is-open { display: block; }
.admin-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.86rem;
  text-align: left;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
}
.admin-menu button:hover { background: var(--surface-hover); }
.admin-menu button.is-danger { color: var(--danger); }
.admin-menu button i { width: 14px; height: 14px; }
.admin-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 2px;
}

/* ── Avatar (nome / empresa) ───────────────────────────── */
.admin-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(88,166,255,0.14);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  overflow: hidden;
}
.admin-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.admin-user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-user-cell .name { font-weight: 600; line-height: 1.2; }
.admin-user-cell .meta { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* ── Cards de empresa (seção Empresas) ─────────────────── */
.admin-company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.admin-company-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: var(--transition);
}
.admin-company-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.admin-company-card-head {
  display: flex;
  gap: 14px;
  align-items: center;
}
.admin-company-card-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.admin-company-card-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}
.admin-company-card-name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}
.admin-company-card-meta {
  font-size: 0.77rem;
  color: var(--muted);
  margin-top: 4px;
}
.admin-company-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}
.admin-company-card-actions .btn {
  padding: 7px 12px;
  font-size: 0.8rem;
}

/* ── Toggle switch (módulos) ───────────────────────────── */
.admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.admin-toggle-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.admin-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.admin-toggle.is-on .admin-toggle-track {
  background: var(--success);
}
.admin-toggle.is-on .admin-toggle-track::after {
  transform: translateX(18px);
}
.admin-toggle-label {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 70px;
}
.admin-toggle.is-on .admin-toggle-label { color: var(--text); }

/* ── Módulo row (lista em modais) ──────────────────────── */
.admin-module-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-solid);
}
.admin-module-row + .admin-module-row { margin-top: 10px; }
.admin-module-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-module-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.admin-module-name { font-weight: 600; font-size: 0.92rem; }
.admin-module-desc { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* ── Skeleton loader ────────────────────────────────────── */
.admin-skeleton {
  background: linear-gradient(90deg,
    var(--surface-solid) 0%,
    var(--surface-hover) 50%,
    var(--surface-solid) 100%);
  background-size: 200% 100%;
  animation: adminSkeletonShimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
  display: inline-block;
}
@keyframes adminSkeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.admin-skeleton-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.admin-skeleton-row:last-child { border-bottom: 0; }

/* ── Empty state ───────────────────────────────────────── */
.admin-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.admin-empty i {
  width: 44px;
  height: 44px;
  opacity: 0.5;
  margin-bottom: 12px;
}
.admin-empty-title { font-size: 1rem; font-weight: 600; color: var(--text); margin: 0 0 6px; }
.admin-empty-text { font-size: 0.88rem; margin: 0; }

/* ── Pagination ─────────────────────────────────────────── */
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 0 4px;
  font-size: 0.88rem;
  color: var(--muted);
}

/* ── Responsivo ─────────────────────────────────────────── */
@media (max-width: 880px) {
  .admin-sidebar {
    width: 64px;
    padding: 16px 8px;
  }
  .admin-sidebar-section { display: none; }
  .admin-nav-item {
    justify-content: center;
    padding: 11px 8px;
  }
  .admin-nav-item .label { display: none; }
  .admin-main { padding: 22px 18px 48px; }
}
@media (max-width: 560px) {
  .admin-topbar { padding: 10px 14px; }
  .admin-topbar-subtitle { display: none; }
}
