/* ============================================================
   Dashboard de Compras — Folha de Estilos Principal
   Design System: Linear / Stripe / Vercel Dark Mode Refinado
   ============================================================ */

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

/* ---- Reset & Tokens ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  hyphens: none !important;
  -webkit-hyphens: none !important;
  word-break: normal;
}

:root {
  /* Palette — Linear/Stripe Deep Dark */
  --bg-base:       #090d16;
  --bg-surface:    #0e1526;
  --bg-card:       rgba(15, 23, 42, 0.72);
  --bg-card-hover: rgba(22, 34, 60, 0.85);
  --border:        rgba(255, 255, 255, 0.08);
  --border-light:  rgba(255, 255, 255, 0.14);
  --border-glow:   rgba(99, 102, 241, 0.35);

  /* Brand Accents */
  --accent-1:  #6366f1;
  --accent-2:  #8b5cf6;
  --accent-3:  #06b6d4;
  --accent-4:  #10b981;
  --accent-5:  #f59e0b;
  --accent-6:  #ef4444;

  /* Typography */
  --text-primary:   #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted:     #64748b;

  /* Sidebar */
  --sidebar-w: 260px;
  --sidebar-bg: #0b0f19;

  /* Misc */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow:          0 4px 20px -2px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --shadow-elevated: 0 16px 40px -8px rgba(0, 0, 0, 0.75), 0 0 1px 1px rgba(255, 255, 255, 0.1);
  --ease-spring:     cubic-bezier(0.16, 1, 0.3, 1);
  --transition:      280ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Compatibility Aliases */
  --bg:            var(--bg-surface);
  --text:          var(--text-primary);
  --primary:       var(--accent-1);
  --primary-dark:  #4f46e5;
  --primary-hover: #4f46e5;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-base);
  background-image:
    radial-gradient(circle at 10% 12%, rgba(99, 102, 241, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 90% 40%, rgba(6, 182, 212, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 50% 92%, rgba(139, 92, 246, 0.06) 0%, transparent 45%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 48px 48px, 48px 48px;
  background-position: 0 0, 0 0, 0 0, -1px -1px, -1px -1px;
  background-attachment: fixed;
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  padding: 20px 0;
}

.sidebar-header {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 12px;
  padding: 18px 14px 16px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   PAGE HEADER LIVE CLOCK BADGE (Horizontal Modern Status)
   ============================================================ */
.page-clock-widget,
.sidebar-clock-widget {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  background: rgba(15, 23, 42, 0.75) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 8px !important;
  padding: 5px 12px !important;
  margin: 0 !important;
  width: auto !important;
  max-width: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
  cursor: default;
  vertical-align: middle;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.page-clock-widget:hover,
.sidebar-clock-widget:hover {
  border-color: rgba(56, 189, 248, 0.4) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), 0 0 10px rgba(56, 189, 248, 0.15) !important;
}

.page-clock-widget .clock-dot,
.sidebar-clock-widget .clock-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.9);
  display: inline-block;
  animation: clockPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  flex-shrink: 0;
}

@keyframes clockPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.page-clock-widget .clock-digits,
.sidebar-clock-widget .clock-digits,
.sidebar-clock-widget .sidebar-clock-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.5px;
}

.page-clock-widget .clock-tz,
.sidebar-clock-widget .clock-tz {
  font-size: 9.5px;
  font-weight: 700;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: 0.4px;
}

.page-clock-widget .clock-sep {
  color: rgba(255, 255, 255, 0.2);
  font-size: 11px;
}

.page-clock-widget .clock-date,
.sidebar-clock-widget .sidebar-clock-date,
.sidebar-clock-widget .clock-date {
  font-size: 12px;
  font-weight: 500;
  color: #cbd5e1;
}


.logo-text {
  display: flex;
  flex-direction: column;
}
.logo-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-item svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition);
}
.nav-item:hover {
  background: rgba(99,102,241,0.1);
  color: var(--text-primary);
}
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.15));
  color: var(--accent-1);
  border: 1px solid rgba(99,102,241,0.3);
}
.nav-item.active svg { opacity: 1; color: var(--accent-1); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.etl-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse-dot 2s infinite;
}
.status-dot.ok   { background: var(--accent-4); }
.status-dot.error{ background: var(--accent-6); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
}

/* ============================================================
   HEADER (STICKY WITH FROSTED GLASS EFFECT)
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 20px 32px;
  margin: -28px -32px 16px -32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.page-title {
  font-size: clamp(1.4rem, 2vw, 2.1rem);
  font-weight: 800;
  background: linear-gradient(135deg, #f8fafc 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.header-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-select, .filter-date {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  cursor: pointer;
  transition: all var(--transition);
  min-width: 140px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.filter-select:focus,
.filter-select:hover,
.filter-date:focus,
.filter-date:hover {
  border-color: var(--accent-1);
  color: var(--text-primary);
  background: rgba(22, 34, 60, 0.9);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
}
select, input, textarea {
  color-scheme: dark;
}

select {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

select option,
.filter-select option,
.form-group select option {
  background-color: #0e1526 !important;
  color: #f8fafc !important;
  padding: 8px 12px;
}

select option:hover,
select option:focus,
select option:checked {
  background-color: #1e293b !important;
  color: #ffffff !important;
}

select optgroup {
  background-color: #090d16 !important;
  color: var(--text-muted) !important;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: transform 0.28s var(--ease-spring), box-shadow 0.28s var(--ease-spring);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.btn-refresh:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.6);
}
.btn-refresh:active { transform: translateY(0); }

/* ============================================================
   KPI CARDS (LAYERED FLOATING CARDS & STAGGER ENTRANCE)
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  width: 100%;
}

@media (max-width: 1280px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.28s var(--ease-spring),
              border-color 0.28s var(--ease-spring),
              box-shadow 0.28s var(--ease-spring),
              background-color 0.28s var(--ease-spring);
  cursor: default;
  position: relative;
  overflow: visible !important;
  box-shadow: var(--shadow);
  animation: fadeInUpStagger 0.5s var(--ease-spring) both;
}
.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 70%);
  pointer-events: none;
}
.kpi-card:hover {
  border-color: rgba(99, 102, 241, 0.42);
  background: rgba(22, 34, 60, 0.88);
  transform: translateY(-4px);
  box-shadow: var(--shadow-elevated), 0 0 24px rgba(99, 102, 241, 0.15);
  z-index: 50;
}

/* Stagger entrance delays */
.kpi-card:nth-child(1) { animation-delay: 0.04s; }
.kpi-card:nth-child(2) { animation-delay: 0.09s; }
.kpi-card:nth-child(3) { animation-delay: 0.14s; }
.kpi-card:nth-child(4) { animation-delay: 0.19s; }
.kpi-card:nth-child(5) { animation-delay: 0.24s; }

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.15);
}
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-icon.spend     { background: rgba(99, 102, 241, 0.18);  color: var(--accent-1); }
.kpi-icon.orders    { background: rgba(6, 182, 212, 0.18);   color: var(--accent-3); }
.kpi-icon.ticket    { background: rgba(245, 158, 11, 0.18);  color: var(--accent-5); }
.kpi-icon.suppliers { background: rgba(16, 185, 129, 0.18);  color: var(--accent-4); }

.kpi-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
}
.kpi-value {
  font-size: clamp(1.35rem, 1.8vw, 2.1rem);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================================
   CHARTS (LAYERED CARDS WITH REFINED ELEVATION)
   ============================================================ */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  width: 100%;
  animation: fadeInUpStagger 0.55s var(--ease-spring) both;
}
.charts-row:nth-of-type(1) { animation-delay: 0.26s; }
.charts-row:nth-of-type(2) { animation-delay: 0.33s; }
.charts-row:nth-of-type(3) { animation-delay: 0.40s; }

.charts-row + .charts-row {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 1100px) {
  .charts-row, .charts-row + .charts-row {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  overflow: visible;
  box-shadow: var(--shadow);
  transition: transform 0.28s var(--ease-spring),
              border-color 0.28s var(--ease-spring),
              box-shadow 0.28s var(--ease-spring),
              background-color 0.28s var(--ease-spring);
}
.chart-card:hover {
  transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.42);
  background: rgba(22, 34, 60, 0.88);
  box-shadow: var(--shadow-elevated), 0 0 24px rgba(99, 102, 241, 0.15);
  z-index: 40;
}
.chart-card.wide { grid-column: span 1; }

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.chart-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-wrapper.tall { height: 340px; }
.chart-wrapper canvas {
  display: block;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,13,20,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms;
}
.loading-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 44px; height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--primary);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 1s linear infinite;
}

/* =========================================================================
   Modal de Configurações
   ========================================================================= */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  color: var(--text-main);
}

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

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 24px 20px;
}

.form-group {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-body);
  transition: .3s;
  border-radius: 24px;
  border: 1px solid var(--border);
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 2px; bottom: 2px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary);
}
input:checked + .slider:before {
  transform: translateX(20px);
}

/* Modal Buttons */
.btn-save, .btn-sync {
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  border: none;
}
.btn-save {
  background: var(--primary);
  color: white;
}
.btn-save:hover {
  background: var(--primary-hover);
}
.btn-sync {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-sync:hover {
  background: rgba(239, 68, 68, 0.25);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-1); }

/* Custom Checkbox Dropdown */
.custom-select {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  min-width: 210px;
  user-select: none;
}
.custom-select:hover {
  border-color: var(--accent-1);
}
.select-selected {
  padding: 8px 24px 8px 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.select-selected:after {
  content: '▼';
  font-size: 10px;
  position: absolute;
  right: 12px;
  top: 10px;
}
.select-items {
  position: absolute;
  background-color: var(--bg-card);
  border: 1px solid var(--accent-1);
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 99;
  border-radius: var(--radius-sm);
  max-height: 250px;
  overflow-y: auto;
  box-shadow: var(--shadow);
  display: none;
}
.custom-select.active .select-items {
  display: block;
}
.select-items label {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  gap: 8px;
  color: var(--text-primary);
}
.select-items label:hover {
  background: rgba(99,102,241,0.1);
}
.select-items input[type="checkbox"] {
  accent-color: var(--accent-1);
  cursor: pointer;
}

/* ============================================================
   SEARCHABLE AUTOCOMPLETE COMBOBOX (CÓDIGO E DESCRIÇÃO)
   ============================================================ */
.searchable-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 220px;
}

.searchable-select-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.8) !important;
  border: 1px solid var(--border-light) !important;
  color: var(--text-primary) !important;
  padding: 8px 32px 8px 12px !important;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  cursor: text;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.searchable-select-input:focus,
.searchable-select-input:hover {
  border-color: var(--accent-1) !important;
  background: rgba(22, 34, 60, 0.95) !important;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
}

.searchable-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  display: none;
  line-height: 1;
  transition: all 0.2s ease;
  z-index: 5;
}

.searchable-clear-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
  transform: translateY(-50%) scale(1.1);
}

.searchable-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 380px;
  max-width: 90vw;
  max-height: 320px;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
  z-index: 1000;
  display: none;
}

.searchable-dropdown.open {
  display: block;
}

.searchable-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: #cbd5e1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.15s ease;
}

.searchable-item:hover,
.searchable-item.highlighted {
  background: rgba(99, 102, 241, 0.2);
  color: #ffffff;
}

.searchable-item-all {
  border-bottom: 1px solid rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.08);
}

.searchable-code-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.searchable-desc-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.searchable-empty {
  padding: 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
}

/* TOOLTIPS INFORMATIVAS */
.tooltip-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  cursor: help;
  vertical-align: middle;
}

.tooltip-container svg {
  width: 15px;
  height: 15px;
  stroke: var(--text-muted);
  transition: all 0.2s ease;
}

.tooltip-container:hover svg {
  stroke: var(--accent-1);
  transform: scale(1.15);
}

.tooltip-text {
  visibility: hidden;
  width: 320px;
  max-width: min(320px, 85vw);
  background-color: rgba(22, 28, 45, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #f1f5f9;
  text-align: left;
  border-radius: 10px;
  padding: 12px 14px;
  position: absolute;
  z-index: 99999;
  top: 135%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s ease, top 0.2s ease;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.75), 0 0 1px rgba(255, 255, 255, 0.2);
  font-size: 0.82rem;
  font-weight: 400;
  pointer-events: none;
  line-height: 1.45;
}

.tooltip-text::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent rgba(22, 28, 45, 0.98) transparent;
}

.tooltip-container:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
  top: 120%;
}

/* Tooltips de KPI: ancorados no card e abrindo logo ABAIXO dele.
   Abrir para cima fazia o balão cair sob o header sticky (z-index 1000) e ficar cortado;
   abaixo do card ele não cobre número/subtítulo nem colide com o header. */
.kpi-card,
.kpi-ruptura-card,
.kpi-roi-card {
  overflow: visible !important;
}

.kpi-card .tooltip-container,
.kpi-ruptura-card .tooltip-container,
.kpi-roi-card .tooltip-container {
  position: static;
}

.kpi-card .tooltip-text,
.kpi-ruptura-card .tooltip-text,
.kpi-roi-card .tooltip-text {
  top: calc(100% + 10px) !important;
  bottom: auto !important;
  transition: opacity 0.2s ease, top 0.2s ease;
}

.kpi-card .tooltip-container:hover .tooltip-text,
.kpi-ruptura-card .tooltip-container:hover .tooltip-text,
.kpi-roi-card .tooltip-container:hover .tooltip-text {
  top: calc(100% + 6px) !important;
  bottom: auto !important;
}

/* Seta oculta: o balão está ancorado no card e não no ícone "i" */
.kpi-card .tooltip-text::after,
.kpi-ruptura-card .tooltip-text::after,
.kpi-roi-card .tooltip-text::after {
  display: none !important;
}

/* Alinhamento inteligente para cards laterais evitando cortes de tela */
.kpi-card:last-child .tooltip-text,
.kpi-roi-card:last-child .tooltip-text,
.kpi-ruptura-card:last-child .tooltip-text,
.panel:last-child .tooltip-text,
.chart-card:last-child .tooltip-text,
.tooltip-align-right .tooltip-text,
th:last-child .tooltip-text,
td:last-child .tooltip-text {
  left: auto !important;
  right: 0 !important;
  transform: none !important;
}
.kpi-card:last-child .tooltip-text::after,
.kpi-roi-card:last-child .tooltip-text::after,
.kpi-ruptura-card:last-child .tooltip-text::after,
.panel:last-child .tooltip-text::after,
.chart-card:last-child .tooltip-text::after,
.tooltip-align-right .tooltip-text::after,
th:last-child .tooltip-text::after,
td:last-child .tooltip-text::after {
  left: auto !important;
  right: 12px !important;
  margin-left: 0 !important;
}

.kpi-card:first-child .tooltip-text,
.kpi-roi-card:first-child .tooltip-text,
.kpi-ruptura-card:first-child .tooltip-text,
.panel:first-child .tooltip-text,
.tooltip-align-left .tooltip-text,
th:first-child .tooltip-text,
td:first-child .tooltip-text,
.table-container th:first-child .tooltip-text,
.table-responsive th:first-child .tooltip-text,
.users-table th:first-child .tooltip-text {
  left: 0 !important;
  right: auto !important;
  transform: none !important;
}
.kpi-card:first-child .tooltip-text::after,
.kpi-roi-card:first-child .tooltip-text::after,
.kpi-ruptura-card:first-child .tooltip-text::after,
.panel:first-child .tooltip-text::after,
.tooltip-align-left .tooltip-text::after,
th:first-child .tooltip-text::after,
td:first-child .tooltip-text::after,
.table-container th:first-child .tooltip-text::after,
.table-responsive th:first-child .tooltip-text::after,
.users-table th:first-child .tooltip-text::after {
  left: 14px !important;
  right: auto !important;
  margin-left: 0 !important;
}

.tooltip-text strong {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--accent-3);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.tooltip-text span.example {
  display: block;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 2px solid var(--accent-1);
  border-radius: 4px;
  color: #94a3b8;
  font-size: 0.78rem;
  line-height: 1.35;
}

/* ============================================================
   CURRENCY TICKER BAR (BACEN PTAX)
   ============================================================ */
.currency-bar {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.currency-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.currency-flag {
  font-size: 16px;
  line-height: 1;
}

.currency-name {
  color: var(--text-secondary);
  font-weight: 500;
}

.currency-rate {
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Inter', monospace;
}

.currency-var {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.currency-var.positive {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.currency-var.negative {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.currency-var.neutral {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

.currency-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
}

.currency-date {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 4px;
}

/* ============================================================
   TABLES & DENSE DATA CONTAINERS (STICKY HEADERS)
   ============================================================ */
.table-section {
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  animation: fadeInUpStagger 0.55s var(--ease-spring) both;
  animation-delay: 0.3s;
  transition: transform 0.28s var(--ease-spring),
              border-color 0.28s var(--ease-spring),
              box-shadow 0.28s var(--ease-spring);
}
.table-section:hover {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: var(--shadow-elevated), 0 0 20px rgba(99, 102, 241, 0.1);
}

.table-container {
  max-height: calc(100vh - 270px);
  overflow-y: auto;
  overflow-x: auto;
  border-radius: var(--radius-md);
  position: relative;
}

.users-table thead th,
.table-container thead th,
.table-section table thead th,
table.dataTable thead th {
  position: sticky;
  top: 0;
  z-index: 25;
  background: #0d1424;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 14px 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ============================================================
   KEYFRAMES & STAGGER ENTRANCE (LINEAR/STRIPE FLUIDITY)
   ============================================================ */
@keyframes fadeInUpStagger {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   ACCESSIBILITY: PREFERS-REDUCED-MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .kpi-card, .chart-card, .table-section, .charts-row {
    animation: none !important;
    transform: none !important;
  }
  .kpi-card:hover, .chart-card:hover, .btn-refresh:hover, .table-section:hover {
    transform: none !important;
  }
}


/* ============================================================
   MENU HORIZONTAL (TOPBAR) — substitui a sidebar lateral
   ============================================================ */
:root { --topbar-h: 58px; }
body { display: block; padding-top: var(--topbar-h); }

.sidebar {
  width: 100%;
  min-height: 0;
  height: var(--topbar-h);
  flex-direction: row;
  align-items: center;
  top: 0; left: 0; right: 0; bottom: auto;
  padding: 0 16px;
  gap: 14px;
  border-right: none;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 13, 22, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
  z-index: 1100;
}
.sidebar-header {
  flex-direction: row !important;
  gap: 10px;
  padding: 0 !important;
  border: none !important;
  flex-shrink: 0;
}
.sidebar-header img { max-width: none !important; height: 36px !important; width: auto; padding: 4px 8px !important; }

.sidebar-nav {
  flex: 1;
  flex-direction: row;
  align-items: center;
  padding: 0;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  min-width: 0;
}
.sidebar-nav::-webkit-scrollbar { height: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
.nav-label {
  margin: 0 !important;
  padding: 0 4px 0 12px;
  font-size: 0;
  align-self: stretch;
  display: flex; align-items: center;
}
.nav-label::before {
  content: '';
  width: 1px; height: 22px;
  background: rgba(255,255,255,0.1);
}
.sidebar-nav > .nav-label:first-child { display: none; }
.nav-item {
  white-space: nowrap;
  padding: 7px 10px;
  font-size: 12.5px;
  gap: 6px;
  margin-top: 0 !important;
  border: 1px solid transparent;
  flex-shrink: 0;
}
.nav-item svg { width: 15px; height: 15px; }
.sidebar-footer { display: none; }

.main-content { margin-left: 0; }
.page-header { top: var(--topbar-h); }

/* Estilos de Item Selecionado no Autocomplete Multi-Select */
.searchable-item.selected {
  background: rgba(16, 185, 129, 0.15) !important;
  border-left: 3px solid #10b981;
}
.searchable-check-badge {
  color: #10b981;
  font-weight: 700;
  font-size: 13px;
  margin-left: auto;
}
