:root {
  --teal: #2563EB;
  --teal-dark: #1D4ED8;
  --teal-light: #DBEAFE;
  --navy: #1E2340;
  --navy-mid: #2D3561;
  --navy-light: #E8E9EF;
  --white: #FFFFFF;
  --gray-50: #F8F9FA;
  --gray-100: #F0F1F3;
  --gray-200: #E2E4E9;
  --gray-300: #C8CBD4;
  --gray-500: #7C8096;
  --text-primary: #1E2340;
  --text-secondary: #6B7094;
  --text-muted: #9DA3BC;
  --success: #10B981;
  --success-bg: #ECFDF5;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --border: #E8E9F0;
  --shadow-sm: 0 1px 3px rgba(30,35,64,.06), 0 1px 2px rgba(30,35,64,.04);
  --shadow: 0 4px 16px rgba(30,35,64,.08), 0 1px 4px rgba(30,35,64,.06);
  --shadow-lg: 0 8px 32px rgba(30,35,64,.12), 0 2px 8px rgba(30,35,64,.06);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --sidebar-w: 230px;
  --topbar-h: 58px;
  --font: 'Outfit', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.sidebar::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(0,191,179,.08);
  pointer-events: none;
}
.sidebar::after {
  content: '';
  position: absolute;
  bottom: 40px; left: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(0,191,179,.05);
  pointer-events: none;
}
.logo-wrap {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  position: relative; z-index: 1;
}
.logo-inner { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 36px; height: 36px;
  background: var(--teal);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon i { font-size: 20px; color: white; }
.logo-text { line-height: 1.15; }
.logo-name { font-size: 13px; font-weight: 700; color: white; letter-spacing: .03em; }
.logo-sub { font-size: 10px; color: rgba(255,255,255,.4); font-weight: 300; letter-spacing: .04em; }

.nav { padding: 10px; flex: 1; overflow-y: auto; position: relative; z-index: 1; }
.nav::-webkit-scrollbar { width: 3px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }
.nav-section {
  font-size: 9px; font-weight: 600;
  color: rgba(255,255,255,.3);
  letter-spacing: .1em; text-transform: uppercase;
  padding: 14px 8px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: rgba(255,255,255,.55);
  font-size: 13px; font-weight: 400;
  margin-bottom: 1px;
  transition: all .15s ease;
  position: relative;
}
.nav-item i { font-size: 16px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.nav-item.active { background: rgba(0,191,179,.18); color: var(--teal); font-weight: 500; }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--teal);
  border-radius: 0 2px 2px 0;
}
.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 30px; height: 30px;
  background: var(--teal);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: white;
  flex-shrink: 0;
}
.footer-name { font-size: 12px; font-weight: 500; color: rgba(255,255,255,.85); }
.footer-role { font-size: 10px; color: rgba(255,255,255,.35); }

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

/* TOPBAR */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 15px; font-weight: 600; color: var(--navy); }
.topbar-badge {
  font-size: 10px; font-weight: 600;
  background: var(--teal-light); color: var(--teal-dark);
  padding: 2px 8px; border-radius: 20px; letter-spacing: .03em;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px; font-family: var(--font); font-weight: 500;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--gray-100); border-color: var(--gray-300); }
.btn i { font-size: 15px; }
.btn-primary { background: var(--teal); color: white; border-color: var(--teal); box-shadow: 0 2px 8px rgba(0,191,179,.3); }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-navy { background: var(--navy); color: white; border-color: var(--navy); }
.btn-navy:hover { background: var(--navy-mid); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-sm i { font-size: 13px; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #FCA5A5; }

/* CONTENT */
.content { flex: 1; overflow-y: auto; padding: 22px 24px; }
.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

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

/* METRICS */
.metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.metric-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.metric-card:hover { box-shadow: var(--shadow); }
.metric-card::after {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--teal);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.metric-card.accent-navy::after { background: var(--navy); }
.metric-card.accent-warning::after { background: var(--warning); }
.metric-card.accent-success::after { background: var(--success); }
.metric-icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; font-size: 18px;
}
.metric-icon.teal { background: var(--teal-light); color: var(--teal-dark); }
.metric-icon.navy { background: var(--navy-light); color: var(--navy); }
.metric-icon.warn { background: var(--warning-bg); color: var(--warning); }
.metric-icon.success { background: var(--success-bg); color: var(--success); }
.metric-label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.metric-value { font-size: 22px; font-weight: 700; color: var(--navy); line-height: 1; margin-bottom: 4px; }
.metric-sub { font-size: 11px; color: var(--text-secondary); }
.metric-sub.pos { color: var(--success); }
.metric-sub.neg { color: var(--danger); }

/* CARDS */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--navy); }
.card-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* TABLES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAFBFF; }

/* BADGES */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 600;
  white-space: nowrap; letter-spacing: .02em;
}
.badge i { font-size: 10px; }
.badge-success { background: var(--success-bg); color: #059669; }
.badge-warning { background: var(--warning-bg); color: #D97706; }
.badge-danger { background: var(--danger-bg); color: #DC2626; }
.badge-info { background: var(--teal-light); color: var(--teal-dark); }
.badge-navy { background: var(--navy-light); color: var(--navy); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-aer { background: var(--teal-light); color: var(--teal-dark); }
.badge-ter { background: #EAF3DE; color: #3B6D11; }

/* MODALS */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(20,25,60,.5);
  backdrop-filter: blur(3px);
  z-index: 200;
  align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 660px; max-width: 100%;
  margin-bottom: 40px;
  animation: modalIn .2s ease;
}
.modal-sm { width: 480px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--gray-50);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title { font-size: 14px; font-weight: 600; color: var(--navy); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* FORMS */
.fg { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ff { grid-column: 1/-1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); letter-spacing: .02em; }
.form-input {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-primary);
  font-size: 13px; font-family: var(--font);
  transition: all .15s;
}
.form-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,191,179,.12); }
.form-input::placeholder { color: var(--text-muted); }
.fsec {
  font-size: 10px; font-weight: 700;
  color: var(--teal-dark);
  text-transform: uppercase; letter-spacing: .08em;
  margin: 16px 0 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--teal-light);
  display: flex; align-items: center; gap: 6px;
}
.fsec i { font-size: 13px; }

/* RESULT PREVIEW */
.result-preview { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.rp-box { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 11px; }
.rp-label { opacity: .7; margin-bottom: 3px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.rp-val { font-size: 15px; font-weight: 700; }
.rp-bruto { background: var(--gray-100); color: var(--navy); }
.rp-com { background: var(--warning-bg); color: #92400E; }
.rp-liq { background: var(--success-bg); color: #065F46; }

/* TIPO SELECTOR */
.tipo-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 7px; margin-bottom: 4px; }
.tipo-opt {
  padding: 9px 6px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  text-align: center; font-size: 11px; font-weight: 500;
  color: var(--text-secondary);
  transition: all .15s;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tipo-opt i { font-size: 18px; }
.tipo-opt:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-light); }
.tipo-opt.sel { border-color: var(--teal); background: var(--teal-light); color: var(--teal-dark); font-weight: 600; }

/* BARS */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { width: 100px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.bar-track { flex: 1; height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 6px; border-radius: 3px; transition: width .4s ease; }
.bar-val { width: 80px; text-align: right; font-weight: 600; font-size: 12px; }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 18px; font-weight: 700; color: var(--navy); }
.page-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* TWO COL */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* TOAST */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--navy); color: white;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .25s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

/* SELETOR DE MÊS */
.mes-selector-wrap {
  grid-column: 1 / -1;
  margin-bottom: 4px;
}
.mes-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
}
.mes-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  transition: all .15s ease;
  white-space: nowrap;
}
.mes-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-light);
}
.mes-btn.active {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
  box-shadow: 0 2px 8px rgba(0,191,179,.3);
}
.mes-btn i { font-size: 13px; }
.mes-count {
  background: rgba(255,255,255,.25);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}
.mes-btn:not(.active) .mes-count {
  background: var(--gray-100);
  color: var(--text-muted);
}

/* LOGIN */
.login-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy);
  background: radial-gradient(circle at 20% 20%, var(--navy-mid), var(--navy) 60%);
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-logo .logo-icon {
  width: 38px; height: 38px;
  background: var(--teal);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px;
}
.login-logo .logo-name { font-size: 14px; font-weight: 700; color: var(--navy); letter-spacing: .5px; }
.login-logo .logo-sub { font-size: 10px; color: var(--text-muted); letter-spacing: 1px; }
.login-title { font-size: 17px; font-weight: 600; color: var(--navy); margin-bottom: 18px; }
.login-card .form-group { margin-bottom: 14px; }
.login-btn { width: 100%; justify-content: center; margin-top: 6px; }
.login-error {
  background: #FEF2F2; color: #B91C1C;
  font-size: 12px; padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.footer-info { flex: 1; min-width: 0; }
.footer-name, .footer-role { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#logout-btn {
  background: transparent; border-color: rgba(255,255,255,.15);
  color: rgba(255,255,255,.7); flex-shrink: 0; padding: 6px 8px;
}
#logout-btn:hover { background: rgba(255,255,255,.08); color: white; }
