
:root {
  /* ── Paleta Imagem Contabilidade ── */
  /* Primária: Azul Marinho */
  --wine: #C0394B;
  --wine-dark: #9B2A3A;
  --wine-light: #D4617A;
  --wine-xlight: #FDF0F2;
  --wine-glow: rgba(192,57,75,.18);

  /* Neutros */
  --charcoal: #0D1B4B;
  --charcoal-mid: #152060;
  --charcoal-light: #1A2E6B;
  --slate: #4A5568;
  --slate-light: #8492A6;
  --silver: #E2E8F0;
  --silver-light: #EDF2F7;
  --snow: #F4F6FA;
  --white: #ffffff;

  /* Semânticas */
  --green: #10b981;
  --green-dark: #059669;
  --green-light: #d1fae5;
  --red: #C0394B;
  --red-dark: #9B2A3A;
  --red-light: #fde8eb;
  --amber: #f59e0b;
  --amber-dark: #d97706;
  --amber-light: #fef3c7;
  --blue: #1A2E6B;
  --blue-dark: #0D1B4B;
  --blue-light: #dbeafe;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;

  /* Layout */
  --sidebar-w: 264px;
  --header-h: 60px;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.07);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 12px 32px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12), 0 24px 64px rgba(0,0,0,.1);
  --shadow-wine: 0 4px 20px rgba(192,57,75,.35);

  /* Sidebar — Azul Marinho escuro */
  --sb-bg: #0D1B4B;
  --sb-border: rgba(255,255,255,.07);
  --sb-text: rgba(255,255,255,.55);
  --sb-text-active: #ffffff;
  --sb-item-active-bg: rgba(192,57,75,.28);
  --sb-item-hover-bg: rgba(255,255,255,.07);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', 'Sora', sans-serif;
  background: var(--snow);
  color: var(--charcoal);
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════
   LOGIN SCREEN  — premium glass card
═══════════════════════════════════════ */
#login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  overflow: hidden;
  background: #060E2B;
}

/* animated mesh background */
#login-screen::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 15% 15%, rgba(26,46,107,.5) 0%, transparent 55%),
    radial-gradient(ellipse 50% 60% at 85% 85%, rgba(192,57,75,.12) 0%, transparent 55%),
    radial-gradient(ellipse 80% 80% at 50% 50%, #060E2B 0%, #0D1B4B 100%);
  animation: bgShift 12s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: .85; transform: scale(1.04); }
}

/* floating orbs */
#login-screen::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(192,57,75,.10) 0%, transparent 70%);
  top: -120px; right: -120px;
  animation: orb 8s ease-in-out infinite alternate;
}

@keyframes orb {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-40px, 60px) scale(1.1); }
}

#login-screen .login-card {
  position: relative;
  background: rgba(6,14,43,.82);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255,255,255,.10);
  border-top: 1px solid rgba(255,255,255,.16);
  border-radius: 24px;
  padding: 48px 52px;
  width: min(440px, 92vw);
  box-shadow: 0 32px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(26,46,107,.4) inset;
  animation: cardIn .5s cubic-bezier(.16,1,.3,1) forwards;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* thin top accent line */
#login-screen .login-card::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 60%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(192,57,75,.8), rgba(212,97,122,.6), transparent);
  border-radius: 1px;
}

#login-screen .login-logo {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin-bottom: 40px;
}

#login-screen .login-logo img {
  width: 80px; height: 80px; object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(192,57,75,.35));
}

#login-screen .login-logo .brand-name {
  font-size: 17px; font-weight: 700; color: rgba(255,255,255,.92);
  letter-spacing: .3px; margin-top: 2px;
  font-family: 'Sora', sans-serif;
}

#login-screen .login-logo .brand-sub {
  font-size: 10px; letter-spacing: 5px; color: rgba(255,255,255,.32);
  font-weight: 600; text-transform: uppercase;
}

#login-screen h2 {
  color: white; font-size: 21px; font-weight: 700; text-align: center;
  margin-bottom: 5px; font-family: 'Sora', sans-serif;
}

#login-screen p.subtitle {
  color: rgba(255,255,255,.38); font-size: 13px; text-align: center;
  margin-bottom: 36px; line-height: 1.5;
}

.login-field { margin-bottom: 14px; }

.login-field label {
  display: block; color: rgba(255,255,255,.5); font-size: 11px;
  font-weight: 600; letter-spacing: .8px; margin-bottom: 8px;
  text-transform: uppercase;
}

.login-field input {
  width: 100%; padding: 14px 18px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; color: white; font-family: 'DM Sans', sans-serif;
  font-size: 14px; outline: none; transition: all .25s;
}

.login-field input:focus {
  border-color: rgba(192,57,75,.7);
  background: rgba(255,255,255,.1);
  box-shadow: 0 0 0 3px rgba(192,57,75,.2), 0 2px 8px rgba(0,0,0,.2);
}

.login-field input::placeholder { color: rgba(255,255,255,.2); }


#login-btn {
  width: 100%; padding: 15px;
  background: linear-gradient(135deg, #D4617A 0%, #C0394B 50%, #9B2A3A 100%);
  border: none; border-radius: 12px; color: white;
  font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 700;
  cursor: pointer; margin-top: 6px; transition: all .25s;
  letter-spacing: .4px;
  box-shadow: 0 4px 16px rgba(192,57,75,.4);
  position: relative; overflow: hidden;
}

#login-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.12) 0%, transparent 100%);
}

#login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(192,57,75,.55);
}

#login-btn:active { transform: translateY(0); }

#login-error {
  color: #fca5a5; font-size: 13px; text-align: center;
  margin-top: 14px; display: none;
  background: rgba(239,68,68,.1); border-radius: 8px; padding: 8px 12px;
  border: 1px solid rgba(239,68,68,.2);
}

.login-hint {
  text-align: center; margin-top: 20px;
  font-size: 11px; color: rgba(255,255,255,.22); line-height: 1.6;
}

/* ═══════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════ */
#app { display: none; }
#app.visible { display: flex; flex-direction: row; height: 100vh; overflow: hidden; }
#app

/* ═══════════════════════════════════════
   SIDEBAR  — dark premium
═══════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sb-bg);
  height: 100vh; display: flex; flex-direction: column;
  position: relative; z-index: 100; flex-shrink: 0;
  overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid var(--sb-border);
  /* subtle noise texture feel via inset shadow */
  box-shadow: inset -1px 0 0 rgba(255,255,255,.03), 4px 0 24px rgba(0,0,0,.25);
}

#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 4px; }

.sidebar-header {
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--sb-border);
  display: flex; align-items: center; gap: 12px;
}

.sidebar-logo {
  flex-shrink: 0; display: flex; align-items: center;
}
.sidebar-logo img { width: 44px; height: 44px; object-fit: contain; }

.sidebar-brand h3 {
  color: white; font-size: 13.5px; font-weight: 700; line-height: 1.25;
  font-family: 'Sora', sans-serif;
}

.sidebar-brand span {
  color: rgba(255,255,255,.32); font-size: 9.5px; letter-spacing: 2.5px;
  text-transform: uppercase; font-weight: 500;
}

/* User block with profile badge */
.sidebar-user {
  padding: 14px 18px;
  border-bottom: 1px solid var(--sb-border);
  display: flex; align-items: center; gap: 10px;
  position: relative;
}

.user-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #C0394B 0%, #D4617A 100%);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 12px; flex-shrink: 0;
  font-family: 'Sora', sans-serif;
  box-shadow: 0 2px 8px rgba(192,57,75,.4);
  position: relative;
}

/* online dot */
.user-avatar::after {
  content: '';
  position: absolute; bottom: -2px; right: -2px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--sb-bg);
}

.user-info span { display: block; }
.user-info .user-name { color: rgba(255,255,255,.9); font-size: 12.5px; font-weight: 700; font-family: 'Sora', sans-serif; }
.user-info .user-role { color: rgba(255,255,255,.38); font-size: 10.5px; margin-top: 1px; }

/* Profile badge pill */
.profile-badge {
  margin-left: auto; flex-shrink: 0;
  font-size: 9px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  padding: 3px 7px; border-radius: 20px;
}
.profile-badge.admin  { background: rgba(192,57,75,.3); color: var(--wine-light); border: 1px solid rgba(192,57,75,.4); }
.profile-badge.cont   { background: rgba(59,130,246,.2); color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }
.profile-badge.client { background: rgba(16,185,129,.2); color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); }

.nav-section { padding: 18px 10px 6px; }

.nav-section-title {
  color: rgba(255,255,255,.22); font-size: 9.5px; font-weight: 700;
  letter-spacing: 2.5px; text-transform: uppercase; padding: 0 8px 8px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  transition: all .15s; color: var(--sb-text);
  font-size: 13px; font-weight: 500;
  user-select: none; margin-bottom: 1px;
  position: relative;
}

.nav-item:hover {
  background: var(--sb-item-hover-bg);
  color: rgba(255,255,255,.82);
}

.nav-item.active {
  background: var(--sb-item-active-bg);
  color: var(--sb-text-active);
  font-weight: 600;
}

/* active left accent bar */
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--wine-light);
  margin-left: -10px;
}

.nav-item.active .nav-icon { filter: none; }

.nav-icon {
  font-size: 15px; width: 20px; text-align: center; flex-shrink: 0;
  opacity: .7;
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.nav-item .nav-badge {
  margin-left: auto;
  background: linear-gradient(135deg, #C0394B 0%, #9B2A3A 100%);
  color: white; font-size: 9.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
  box-shadow: 0 2px 6px rgba(192,57,75,.4);
}

.nav-item-parent {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  transition: all .15s; color: var(--sb-text);
  font-size: 13px; font-weight: 600;
  user-select: none;
}

.nav-item-parent:hover { color: rgba(255,255,255,.82); background: var(--sb-item-hover-bg); }

.nav-arrow {
  margin-left: auto; font-size: 10px; transition: transform .2s;
  opacity: .4;
}

.nav-children {
  padding-left: 12px; overflow: hidden; max-height: 0;
  transition: max-height .3s ease;
}

.nav-children.open { max-height: 500px; }

.sidebar-footer {
  margin-top: auto; padding: 14px 10px;
  border-top: 1px solid var(--sb-border);
}

.logout-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  color: rgba(255,255,255,.35); font-size: 13px; font-weight: 500;
  transition: all .15s;
}

.logout-btn:hover { color: #fca5a5; background: rgba(239,68,68,.1); }

/* ═══════════════════════════════════════
   MAIN AREA
═══════════════════════════════════════ */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

#topbar {
  height: var(--header-h);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--silver);
  display: flex; align-items: center; padding: 0 26px;
  gap: 16px; flex-shrink: 0;
  position: relative; z-index: 50; flex-shrink: 0;
}

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--slate-light);
}

.topbar-breadcrumb strong {
  color: var(--charcoal); font-weight: 700;
  font-family: 'Sora', sans-serif;
}
.topbar-breadcrumb span.sep { color: var(--silver); font-size: 16px; }

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

.topbar-clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px; color: var(--slate);
  background: var(--snow); padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--silver);
  letter-spacing: .3px;
}

/* profile chip in topbar */
.topbar-profile-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 6px;
  background: var(--snow); border: 1px solid var(--silver);
  border-radius: 20px; cursor: pointer; transition: all .2s;
}

.topbar-profile-chip:hover { border-color: var(--wine-light); background: var(--wine-xlight); }

.topbar-profile-chip .chip-avatar {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #C0394B 0%, #D4617A 100%);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 10px; font-weight: 800;
  font-family: 'Sora', sans-serif; flex-shrink: 0;
}

.topbar-profile-chip .chip-name {
  font-size: 12.5px; font-weight: 600; color: var(--charcoal);
}

.notification-btn {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--snow); border: 1px solid var(--silver); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; transition: all .15s; position: relative;
}

.notification-btn:hover { background: var(--wine-xlight); border-color: var(--wine-light); }
.notification-dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; background: var(--wine);
  border-radius: 50%; border: 2px solid white;
  animation: pulse-dot 2s ease-in-out infinite;
}


/* ═══════════════════════════════════════
   FIX SCROLL MÓDULOS
═══════════════════════════════════════ */
#page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  min-height: 0;
  padding: 0;
  display: block;
}



/* ═══════════════════════════════════════
   SYNC BUTTON & INDICATOR
═══════════════════════════════════════ */
.sync-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px;
  background: var(--snow); border: 1px solid var(--silver);
  cursor: pointer; font-size: 12px; font-weight: 600;
  color: var(--slate); transition: all .2s; white-space: nowrap;
}
.sync-btn:hover { background: var(--wine-xlight); border-color: var(--wine-light); color: var(--wine); }
.sync-btn.syncing { opacity: .7; cursor: not-allowed; pointer-events: none; }
.sync-btn .sync-icon { font-size: 13px; transition: transform .6s; }
.sync-btn.syncing .sync-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-indicator {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--slate-light);
  background: var(--snow); border: 1px solid var(--silver);
  padding: 5px 10px; border-radius: 8px;
  white-space: nowrap; max-width: 210px;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sync-dot.ok    { background: var(--green); }
.sync-dot.erro  { background: var(--red); }
.sync-dot.nunca { background: var(--slate-light); }

/* ═══════════════════════════════════════
   FIX SCROLL MÓDULOS
═══════════════════════════════════════ */


@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: .7; }
}



#page-content::-webkit-scrollbar { width: 5px; }
#page-content::-webkit-scrollbar-track { background: transparent; }
#page-content::-webkit-scrollbar-thumb { background: var(--silver); border-radius: 4px; }

/* ═══════════════════════════════════════
   PAGES & TRANSITIONS
═══════════════════════════════════════ */
.page { display: none; }
.page.active { padding: 28px 32px; box-sizing: border-box; width: 100%; }
.page.active { display: block; padding: 28px 32px; box-sizing: border-box; width: 100%; }

/* ═══════════════════════════════════════
   CARDS
═══════════════════════════════════════ */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid rgba(13,27,75,.08);
}

.card-header {
  padding: 17px 20px; border-bottom: 1px solid rgba(13,27,75,.07);
  display: flex; align-items: center; justify-content: space-between;
}

.card-header h3 { font-size: 14.5px; font-weight: 700; font-family: 'Sora', sans-serif; }
.card-body { padding: 20px; }

/* ═══════════════════════════════════════
   KPI CARDS
═══════════════════════════════════════ */
.kpi-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.kpi-card {
  background: var(--white); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  border: 1px solid rgba(13,27,75,.07);
  border-left: 3px solid transparent; transition: all .22s;
  position: relative; overflow: hidden;
}

/* subtle inner gradient */
.kpi-card::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle at top right, rgba(0,0,0,.025) 0%, transparent 70%);
  pointer-events: none;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-clickable { cursor: pointer; }
.kpi-clickable::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(13,27,75,.04) 0%, transparent 70%);
  opacity: 0; transition: opacity .2s;
}
.kpi-clickable:hover::before { opacity: 1; }
.kpi-click-hint {
  font-size: 10px; opacity: 0; transition: opacity .2s;
  display: inline-block; margin-left: 4px;
}
.kpi-clickable:hover .kpi-click-hint { opacity: .6; }
.kpi-arrow-hint {
  position: absolute; bottom: 10px; right: 12px;
  font-size: 10px; color: var(--slate-light); opacity: 0; transition: all .2s;
  font-weight: 600; letter-spacing: .3px;
}
.kpi-clickable:hover .kpi-arrow-hint { opacity: 1; transform: translateX(2px); }

.kpi-card.wine   { border-left-color: var(--wine); }
.kpi-card.green  { border-left-color: var(--green); }
.kpi-card.amber  { border-left-color: var(--amber); }
.kpi-card.blue   { border-left-color: #1A2E6B; }
.kpi-card.red    { border-left-color: var(--red); }
.kpi-card.purple { border-left-color: var(--purple); }

.kpi-icon { font-size: 20px; margin-bottom: 10px; display: block; line-height: 1; }

.kpi-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .5px;
  color: var(--slate); text-transform: uppercase; margin-bottom: 5px;
  display: flex; align-items: center; gap: 4px;
}

.kpi-value {
  font-size: 27px; font-weight: 800; color: var(--charcoal);
  font-family: 'JetBrains Mono', monospace; line-height: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-value.sm  { font-size: 19px; }
.kpi-value.xs  { font-size: 15px; }

.kpi-row {
  display: flex; align-items: baseline; gap: 7px; margin-top: 2px;
}
.kpi-row-main {
  font-size: 27px; font-weight: 800; color: var(--charcoal);
  font-family: 'JetBrains Mono', monospace; line-height: 1;
}
.kpi-row-sub {
  font-size: 12px; font-weight: 600; color: var(--slate);
  font-family: 'JetBrains Mono', monospace;
}

.kpi-sub {
  font-size: 11px; color: var(--slate-light); margin-top: 6px;
  line-height: 1.4; min-height: 16px;
}
.kpi-trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 700; margin-top: 6px;
  padding: 2px 8px; border-radius: 20px;
}
.trend-up   { background: var(--green-light); color: var(--green-dark); }
.trend-down { background: var(--red-light);   color: var(--red-dark); }
.trend-neu  { background: var(--silver);      color: var(--slate); }

/* ═══════════════════════════════════════
   MODAL
═══════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,18,32,.65); backdrop-filter: blur(6px);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white); border-radius: 22px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
  transform: scale(.96) translateY(10px); transition: transform .22s cubic-bezier(.16,1,.3,1);
  min-width: 480px; max-width: 680px; width: 90vw;
  border: 1px solid var(--silver-light);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--silver-light);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: white; z-index: 1;
  border-radius: 22px 22px 0 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; font-family: 'Sora', sans-serif; }
.modal-close {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--snow); border: 1px solid var(--silver); cursor: pointer;
  font-size: 15px; display: flex; align-items: center; justify-content: center;
  transition: all .15s; color: var(--slate);
}
.modal-close:hover { background: var(--red-light); border-color: var(--red); color: var(--red); }
.modal-body { padding: 22px 24px; }
.modal-footer {
  padding: 14px 24px; border-top: 1px solid var(--silver-light);
  display: flex; gap: 10px; justify-content: flex-end;
  background: var(--snow); border-radius: 0 0 22px 22px;
}

/* ═══════════════════════════════════════
   TABLE
═══════════════════════════════════════ */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--snow); padding: 10px 14px;
  text-align: left; font-size: 10.5px; font-weight: 700;
  color: var(--slate); text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 2px solid var(--silver); white-space: nowrap;
  cursor: pointer; user-select: none;
}
th:hover { background: var(--silver-light); color: var(--charcoal); }
td { padding: 10px 14px; border-bottom: 1px solid var(--silver-light); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfe; }

/* ═══════════════════════════════════════
   BADGES
═══════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; white-space: nowrap;
  letter-spacing: .2px;
}
.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-red { background: var(--red-light); color: var(--red-dark); }
.badge-amber { background: var(--amber-light); color: var(--amber-dark); }
.badge-blue { background: var(--blue-light); color: var(--blue-dark); }
.badge-gray { background: var(--silver); color: var(--slate); }
.badge-wine { background: var(--wine-xlight); color: var(--wine-dark); }

/* ═══════════════════════════════════════
   BUTTONS
═══════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; font-family: 'DM Sans', 'Sora', sans-serif;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; transition: all .18s; white-space: nowrap;
  letter-spacing: .1px;
}
.btn-primary {
  background: linear-gradient(135deg, #D4617A 0%, #C0394B 50%, #9B2A3A 100%);
  color: white;
  box-shadow: 0 2px 10px rgba(192,57,75,.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #C0394B 0%, #9B2A3A 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-wine);
}
.btn-secondary {
  background: var(--white); color: var(--charcoal);
  border: 1px solid var(--silver);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--snow); border-color: #c9cdd8; }
.btn-danger { background: var(--red-light); color: var(--red-dark); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 6px 12px; font-size: 11.5px; }
.btn-icon { padding: 7px; border-radius: 8px; }

/* ═══════════════════════════════════════
   SEARCH / FILTER BAR
═══════════════════════════════════════ */
.filter-bar {
  display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap; margin-bottom: 16px;
}
.search-input {
  padding: 9px 14px 9px 36px; border: 1px solid var(--silver);
  border-radius: 9px; font-family: 'DM Sans', sans-serif; font-size: 13px;
  background: var(--white); outline: none; width: 280px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 11px center;
  transition: all .18s; box-shadow: var(--shadow-xs);
}
.search-input:focus { border-color: var(--wine-light); box-shadow: 0 0 0 3px rgba(192,57,75,.1); }
select.filter-select {
  padding: 9px 14px; border: 1px solid var(--silver);
  border-radius: 9px; font-family: 'DM Sans', sans-serif; font-size: 13px;
  background: var(--white); outline: none; cursor: pointer; transition: all .18s;
  box-shadow: var(--shadow-xs);
}
select.filter-select:focus { border-color: var(--wine-light); }

/* ═══════════════════════════════════════
   SECTION TITLE
═══════════════════════════════════════ */
.section-title {
  font-size: 21px; font-weight: 800; color: var(--charcoal); margin-bottom: 4px;
  font-family: 'Sora', sans-serif; letter-spacing: -.2px;
}
.section-subtitle { font-size: 13px; color: var(--slate-light); margin-bottom: 22px; }

/* ═══════════════════════════════════════
   MODULE CARDS
═══════════════════════════════════════ */
.module-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.module-card {
  background: var(--white); border-radius: 16px;
  padding: 26px 22px; box-shadow: var(--shadow);
  cursor: pointer; transition: all .22s;
  border: 1.5px solid var(--silver-light); position: relative; overflow: hidden;
}
.module-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(13,27,75,.05) 0%, transparent 60%);
  opacity: 0; transition: opacity .2s;
}
.module-card:hover {
  transform: translateY(-3px); box-shadow: var(--shadow-md);
  border-color: rgba(192,57,75,.2);
}
.module-card:hover::before { opacity: 1; }
.module-card-icon { font-size: 32px; margin-bottom: 12px; display: block; }
.module-card h4 { font-size: 14.5px; font-weight: 700; color: var(--charcoal); margin-bottom: 5px; font-family: 'Sora', sans-serif; }
.module-card p { font-size: 12px; color: var(--slate); line-height: 1.55; }

/* ═══════════════════════════════════════
   SECTION CARD
═══════════════════════════════════════ */
.section-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px;
  border: 1px solid rgba(229,232,239,.6);
}

/* ═══════════════════════════════════════
   TABS
═══════════════════════════════════════ */
.tabs {
  display: flex; gap: 2px; background: var(--silver-light);
  border-radius: 11px; padding: 4px; margin-bottom: 18px;
  border: 1px solid var(--silver); width: fit-content;
}
.tab {
  padding: 7px 16px; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--slate); transition: all .15s;
}
.tab:hover { color: var(--charcoal); background: rgba(255,255,255,.6); }
.tab.active {
  background: var(--white); color: var(--charcoal);
  box-shadow: var(--shadow-xs); font-weight: 700;
}

/* ═══════════════════════════════════════
   PAGINATION
═══════════════════════════════════════ */
.pagination { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.page-btn {
  min-width: 32px; height: 32px; border-radius: 8px;
  background: var(--white); border: 1px solid var(--silver);
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--slate);
  display: inline-flex; align-items: center; justify-content: center; transition: all .15s;
}
.page-btn:hover { background: var(--wine-xlight); border-color: var(--wine-light); color: var(--wine); }
.page-btn.active { background: var(--wine); border-color: var(--wine); color: white; box-shadow: 0 2px 8px rgba(192,57,75,.3); }

/* ═══════════════════════════════════════
   FORM
═══════════════════════════════════════ */
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-grid.col1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span2 { grid-column: span 2; }
.form-group label { font-size: 10.5px; font-weight: 700; color: var(--slate); text-transform: uppercase; letter-spacing: .6px; }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 13px; border: 1px solid var(--silver);
  border-radius: 9px; font-family: 'DM Sans', sans-serif; font-size: 13px;
  outline: none; transition: all .18s; background: var(--white); color: var(--charcoal);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--wine-light);
  box-shadow: 0 0 0 3px rgba(192,57,75,.1);
}

/* ═══════════════════════════════════════
   DATE FILTER
═══════════════════════════════════════ */
.date-filter {
  display: flex; gap: 10px; align-items: center;
  background: var(--white); padding: 12px 16px; border-radius: 11px;
  border: 1px solid var(--silver); flex-wrap: wrap;
  box-shadow: var(--shadow-xs);
}
.date-filter label { font-size: 12px; font-weight: 600; color: var(--slate); }
.date-filter input[type=month] {
  padding: 7px 10px; border: 1px solid var(--silver);
  border-radius: 7px; font-family: 'DM Sans', sans-serif; font-size: 13px; outline: none;
}
.date-filter input[type=month]:focus { border-color: var(--wine-light); }

/* ═══════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════ */
.empty-state { padding: 56px 20px; text-align: center; color: var(--slate-light); }
.empty-state .es-icon { font-size: 44px; margin-bottom: 12px; opacity: .6; }
.empty-state p { font-size: 14px; }

/* ═══════════════════════════════════════
   LOG
═══════════════════════════════════════ */
.log-item { overflow: hidden;
  display: flex; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--silver-light);
}
.log-item:last-child { border-bottom: none; }
.log-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.log-content { flex: 1; min-width: 0; }
.log-action { font-size: 13px; font-weight: 600; color: var(--charcoal); }
.log-detail { font-size: 11.5px; color: var(--slate); margin-top: 2px; }
.log-time { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--slate-light); white-space: nowrap; }

/* ═══════════════════════════════════════
   DROP ZONE
═══════════════════════════════════════ */
.drop-zone {
  border: 2px dashed var(--silver); border-radius: 14px;
  padding: 40px; text-align: center; cursor: pointer; transition: all .2s; background: var(--snow);
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--wine-light); background: var(--wine-xlight); }
.drop-zone p { color: var(--slate); font-size: 14px; margin-top: 12px; }
.drop-zone .dz-icon { font-size: 34px; }

/* ═══════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════ */
/* Botão hamburguer — oculto em desktop, visível só no mobile via @media */
#mobile-menu-btn { display: none; }
#mobile-drawer { display: none; }
@media (max-width: 900px) {
  :root { --sidebar-w: 56px; }
  .sidebar-brand, .nav-item span, .nav-section-title,
  .sidebar-user .user-info, .sidebar-user .profile-badge,
  .logout-btn span { display: none; }
  .nav-children { display: none !important; }
}

/* ═══════════════════════════════════════
   RESPONSIVO — CELULAR (≤600px)
═══════════════════════════════════════ */
@media (max-width: 600px) {
  :root { --sidebar-w: 0px; }

  /* Esconder sidebar completamente no celular */
  #sidebar { display: none !important; }

  /* Topbar adaptada */
  #topbar { padding: 0 12px; height: 52px; }
  .topbar-profile-chip .chip-name { display: none; }

  /* Botão de menu hamburguer */
  #mobile-menu-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
    background: var(--wine-xlight); border: none; font-size: 18px;
    color: var(--wine); margin-right: 8px; flex-shrink: 0;
  }

  /* Menu lateral móvel (drawer) */
  #mobile-drawer {
    display: none;
    position: fixed; inset: 0; z-index: 9999;
  }
  #mobile-drawer.open { display: block; }
  #mobile-drawer-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.5);
  }
  #mobile-drawer-panel {
    position: absolute; top: 0; left: 0; bottom: 0;
    width: 260px;
    background: linear-gradient(160deg, #0D1B4B 0%, #152060 60%, #0D1B4B 100%);
    overflow-y: auto; padding: 20px 0;
    animation: drawerIn .22s ease;
  }
  @keyframes drawerIn {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
  }

  /* KPI grid — 2 colunas no celular */
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .kpi-card { padding: 14px 12px; }
  .kpi-value { font-size: 20px !important; }
  .kpi-value.sm { font-size: 15px !important; }

  /* Cards: padding menor */
  .card-body  { padding: 14px; }
  .card-header { padding: 13px 14px; flex-wrap: wrap; gap: 8px; }

  /* Form grid — 1 coluna */
  .form-grid { grid-template-columns: 1fr !important; }
  .form-grid .span2 { grid-column: span 1 !important; }

  /* Tabelas — scroll horizontal */
  .table-wrap, .card-body > table { overflow-x: auto; display: block; }
  table { min-width: 520px; }

  /* Section titles menores */
  .section-title { font-size: 17px; }
  .section-subtitle { font-size: 12px; }

  /* Tabs — scroll horizontal */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; padding-bottom: 2px; }
  .tab  { white-space: nowrap; flex-shrink: 0; }

  /* Modais — tela cheia */
  .modal { min-width: unset !important; width: 96vw !important; max-width: 96vw !important;
           margin: 12px auto; max-height: 90vh; overflow-y: auto; }

  /* Grids de 2 colunas viram 1 coluna */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Topbar logo */
  .topbar-logo { font-size: 13px; }

  /* Botões no header do card — empilhar */
  .card-header { flex-wrap: wrap; }

  /* Greeting banner */
  .greeting-logo { width: 60px !important; }
  #greeting-banner { padding: 16px !important; }

  /* Touch targets — mínimo 44px */
  .notification-btn { width: 44px !important; height: 44px !important; border-radius: 10px; }
  .modal-close      { width: 44px !important; height: 44px !important; border-radius: 10px; }
  .page-btn         { min-width: 40px !important; height: 40px !important; }
  #mobile-menu-btn  { width: 44px !important; height: 44px !important; }

  /* Search e filtros — ocupar largura disponível */
  .search-input  { width: 100% !important; max-width: 100%; }
  .filter-select { flex: 1; min-width: 120px; }
  .filter-bar    { flex-wrap: wrap; gap: 8px; }

  /* Login — padding menor em telas pequenas */
  .login-card { padding: 32px 24px; }
}

@media print {
  #sidebar, #topbar, #mobile-menu-btn, #mobile-drawer { display: none !important; }
  
  .no-print { display: none !important; }
}

/* ═══════════════════════════════════════
   TRANSITIONS & ANIMATIONS
═══════════════════════════════════════ */
.fade-in { animation: fadeIn .3s cubic-bezier(.16,1,.3,1); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════════════════════════════
   QUADRANT BADGE
═══════════════════════════════════════ */
.q-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.q-star { background: #fef9c3; color: #854d0e; }
.q-up   { background: var(--blue-light); color: #1d4ed8; }
.q-warn { background: var(--amber-light); color: #92400e; }
.q-gear { background: var(--green-light); color: #065f46; }
.q-red  { background: var(--red-light); color: #991b1b; }

/* ═══════════════════════════════════════
   ONBOARDING
═══════════════════════════════════════ */
.onboard-step {
  display: flex; gap: 14px; padding: 15px;
  border: 1px solid var(--silver); border-radius: 11px;
  margin-bottom: 10px; cursor: pointer; transition: all .18s;
}
.onboard-step:hover { border-color: var(--wine-light); background: var(--wine-xlight); }
.onboard-step .step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--charcoal); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.onboard-step h5 { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; font-family: 'Sora', sans-serif; }
.onboard-step p  { font-size: 12px; color: var(--slate); }

/* ═══════════════════════════════════════
   GREETING BANNER — redesigned
═══════════════════════════════════════ */
.greeting-banner {
  background: linear-gradient(135deg, #0D1B4B 0%, #152060 60%, #1A2E6B 100%);
  border-radius: 18px; padding: 24px 28px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; position: relative; overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
}
.greeting-banner::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(circle at 80% 50%, rgba(192,57,75,.15) 0%, transparent 50%);
}
.greeting-text h2 {
  font-size: 23px; font-weight: 800; color: white; margin-bottom: 5px;
  font-family: 'Sora', sans-serif; position: relative;
}
.greeting-text p {
  font-size: 13px; color: rgba(255,255,255,.48); max-width: 480px;
  line-height: 1.6; position: relative;
}
.banner-profile-pill {
  position: relative; flex-shrink: 0;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; padding: 10px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 110px;
}
.banner-profile-pill .pill-role {
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: rgba(255,255,255,.38); font-weight: 700;
}
.banner-profile-pill .pill-name {
  font-size: 12px; font-weight: 700; color: white; font-family: 'Sora', sans-serif;
}
.banner-profile-pill .pill-status {
  font-size: 10px; color: var(--green);
  display: flex; align-items: center; gap: 4px;
}
.banner-profile-pill .pill-status::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); display: inline-block;
}
.greeting-logo {
  width: 90px; height: 90px; object-fit: contain;
  opacity: .35; position: absolute; right: 28px; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* ═══════════════════════════════════════
   CHART WRAP
═══════════════════════════════════════ */
.chart-wrap { position: relative; width: 100%; }

/* ═══════════════════════════════════════
   KPI DETAIL MODAL (wide)
═══════════════════════════════════════ */
#modal-kpi-detail .modal { max-width: 860px; width: 95vw; }
.modal-pills {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 12px 24px; border-bottom: 1px solid var(--silver-light);
  background: var(--snow);
}
.modal-pill {
  padding: 4px 11px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  display: flex; gap: 5px; align-items: center;
}
.pill-wine { background: var(--wine-xlight); color: var(--wine-dark); }
.pill-green { background: var(--green-light); color: #065f46; }
.pill-amber { background: var(--amber-light); color: #92400e; }
.pill-red { background: var(--red-light); color: #991b1b; }
.pill-blue { background: var(--blue-light); color: #1d4ed8; }
.pill-gray { background: var(--silver); color: var(--slate); }
.kpi-modal-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.kpi-modal-table th {
  background: var(--snow); padding: 9px 14px;
  text-align: left; font-size: 10px; font-weight: 700;
  color: var(--slate); text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--silver); white-space: nowrap; position: sticky; top: 0;
}
.kpi-modal-table td { padding: 9px 14px; border-bottom: 1px solid var(--silver-light); vertical-align: middle; }
.kpi-modal-table tr:hover td { background: var(--snow); }
.kpi-modal-table tr:last-child td { border-bottom: none; }
.modal-dtab-bar {
  display: flex; gap: 2px; padding: 10px 22px 0;
  border-bottom: 1px solid var(--silver);
}
.modal-dtab-btn {
  padding: 6px 15px; border-radius: 8px 8px 0 0;
  font-size: 12px; font-weight: 600; cursor: pointer; color: var(--slate);
  transition: all .15s; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.modal-dtab-btn:hover { color: var(--charcoal); }
.modal-dtab-btn.active { color: var(--wine); border-bottom-color: var(--wine); background: var(--wine-xlight); }

/* ═══════════════════════════════════════
   PROGRESS BAR
═══════════════════════════════════════ */
.progress-bar { height: 7px; background: var(--silver); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }


/* ── Reorganização KPIs — maio/2026 ─────────────────────────────── */
.kpi-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate);
  margin-bottom: 8px;
  margin-top: 4px;
  padding-left: 2px;
}
.kpi-grid-5 {
  grid-template-columns: repeat(5, 1fr) !important;
}
.kpi-grid-4 {
  grid-template-columns: repeat(4, 1fr) !important;
}
.kpi-grid-2 {
  grid-template-columns: repeat(2, 1fr) !important;
}
@media (max-width: 768px) {
  .kpi-grid-5,
  .kpi-grid-4,
  .kpi-grid-2 { grid-template-columns: 1fr 1fr !important; }
}
