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

:root {
  /* ── Azul Jandaia ── */
  --blue:       #005BAC;
  --blue-light: #3A8EDB;
  --blue-dark:  #003D7A;
  --blue-bg:    #EBF4FF;
  --blue-mid:   #1A7FD4;

  /* Aliases para componentes (mantém compatibilidade) */
  --red:        var(--blue);
  --red-light:  var(--blue-light);
  --red-dark:   var(--blue-dark);
  --red-bg:     var(--blue-bg);

  --gray-900:  #1A1A1A;
  --gray-700:  #3D3D3D;
  --gray-500:  #737373;
  --gray-300:  #C4C4C4;
  --gray-100:  #F5F5F5;
  --white:     #FFFFFF;
  --green:     #52C41A;
  --orange:    #FA8C16;
  --pos:       #389E0D;
  --neg:       #CF1322;

  --shadow-sm: 0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --radius:    10px;
  --radius-lg: 16px;
  --font:      'Inter', sans-serif;
  --font-head: 'Sora', sans-serif;
  --transition: .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--gray-100); color: var(--gray-900); min-height: 100vh; }

h1,h2,h3,h4 { font-family: var(--font-head); }
h1 { font-size: 1.8rem; font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--white);
}

.login-brand {
  background: linear-gradient(145deg, #002D5C 0%, #005BAC 55%, #1A7FD4 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  color: var(--white);
  position: relative;
  overflow: hidden;
}
.login-brand::before {
  content: '';
  position: absolute;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  top: -80px; right: -80px;
}
.login-brand::after {
  content: '';
  position: absolute;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  bottom: -40px; left: -40px;
}

.brand-logo {
  font-family: var(--font-head);
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: .5rem;
  position: relative;
  z-index: 1;
}
.brand-logo span {
  opacity: .65;
  font-size: 1.2rem;
  font-weight: 400;
  display: block;
  letter-spacing: 4px;
  text-transform: uppercase;
}
.brand-tagline {
  font-size: .95rem;
  opacity: .8;
  margin-top: 1.5rem;
  text-align: center;
  line-height: 1.7;
  position: relative;
  z-index: 1;
}
.brand-year {
  margin-top: 2.5rem;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 50px;
  padding: .4rem 1.2rem;
  font-size: .85rem;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.login-form-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
}
.login-form-inner { width: 100%; max-width: 360px; }
.login-form-inner h2 { margin-bottom: .4rem; color: var(--gray-900); }
.login-form-inner p { color: var(--gray-500); margin-bottom: 2rem; font-size: .95rem; }

.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: .4rem; font-size: .9rem; color: var(--gray-700); }
.form-group input, .form-group select {
  width: 100%;
  padding: .7rem 1rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .95rem;
  background: var(--white);
  transition: border-color var(--transition);
  outline: none;
  color: var(--gray-900);
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,91,172,.12);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1.4rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: var(--blue);
  color: var(--white);
  width: 100%;
  justify-content: center;
  padding: .85rem;
  font-size: 1rem;
}
.btn-primary:hover { background: var(--blue-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--white); color: var(--gray-700); border: 1.5px solid var(--gray-300); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger { background: #FFF1F0; color: var(--neg); border: 1.5px solid #FFCCC7; }
.btn-danger:hover { background: var(--neg); color: var(--white); }
.btn-sm { padding: .4rem .8rem; font-size: .82rem; }
.btn-icon { padding: .5rem; border-radius: 8px; }

.login-error {
  background: #FFF1F0;
  border: 1px solid #FFCCC7;
  color: var(--neg);
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .88rem;
  display: none;
}
.login-error.show { display: block; }

@media (max-width: 768px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { padding: 2rem; min-height: 200px; }
  .brand-logo { font-size: 2rem; }
}

/* ── App Shell ── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 1.5rem 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo .logo-text {
  font-family: var(--font-head);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -.5px;
}
.sidebar-logo .logo-sub {
  font-size: .7rem;
  color: var(--blue-light);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  font-weight: 500;
  margin-top: .1rem;
}

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-section {
  padding: .5rem 1.2rem .2rem;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.28);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.2rem;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  font-size: .87rem;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover { color: var(--white); background: rgba(255,255,255,.05); }
.nav-item.active {
  color: var(--white);
  background: rgba(0,91,172,.2);
  border-left-color: var(--blue-light);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .75; }

.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-info { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; color: var(--white); flex-shrink: 0;
}
.user-name { font-size: .85rem; font-weight: 600; color: var(--white); line-height: 1.2; }
.user-role { font-size: .7rem; color: rgba(255,255,255,.38); text-transform: uppercase; letter-spacing: .5px; }
.btn-logout {
  width: 100%;
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.45);
  border: 1px solid rgba(255,255,255,.1);
  justify-content: center;
  font-size: .82rem;
  padding: .5rem;
}
.btn-logout:hover { background: rgba(0,91,172,.25); color: var(--blue-light); border-color: var(--blue); }

/* ── Main ── */
.main { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid #E8E8E8;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}
.topbar-title { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; color: var(--gray-900); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

.period-badge {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid rgba(0,91,172,.2);
  border-radius: 50px;
  padding: .3rem .9rem;
  font-size: .78rem;
  font-weight: 600;
}

.content { padding: 1.5rem; flex: 1; }

/* ── Filter Bar ── */
.filter-bar {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
  border-top: 3px solid var(--blue);
}
.filter-item { display: flex; flex-direction: column; gap: .3rem; min-width: 130px; flex: 1; }
.filter-item label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .6px;
}
.filter-item select {
  padding: .5rem .8rem;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  font-family: var(--font);
  font-size: .85rem;
  background: var(--white);
  outline: none;
  cursor: pointer;
  color: var(--gray-900);
}
.filter-item select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,91,172,.1); }
.filter-actions { display: flex; gap: .5rem; align-items: flex-end; }

/* ── Mode Toggle ── */
.mode-toggle {
  display: flex;
  background: var(--gray-100);
  border-radius: 8px;
  padding: 3px;
}
.mode-btn {
  padding: .4rem 1rem;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--gray-500);
  transition: all var(--transition);
  font-family: var(--font);
}
.mode-btn.active { background: var(--white); color: var(--blue); box-shadow: var(--shadow-sm); }

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--gray-300);
  transition: box-shadow var(--transition);
}
.kpi-card:first-child { border-top-color: var(--blue); }
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: .4rem;
}
.kpi-value { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.kpi-vs { font-size: .78rem; color: var(--gray-500); margin-top: .3rem; }
.kpi-pct { font-weight: 700; }
.kpi-pct.pos { color: var(--pos); }
.kpi-pct.neg { color: var(--neg); }
.kpi-pct-big { font-size: 1.8rem !important; }

/* ── Chart Cards ── */
.charts-grid { display: grid; gap: 1.2rem; }
.charts-row { display: grid; gap: 1.2rem; }
.charts-row.cols-2 { grid-template-columns: 1fr 1fr; }
.charts-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.chart-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow-sm);
}
.chart-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; }
.chart-card-title { font-family: var(--font-head); font-size: .95rem; font-weight: 700; color: var(--gray-900); }
.chart-card-sub { font-size: .78rem; color: var(--gray-500); margin-top: .2rem; }

.chart-wrap { position: relative; display: block; width: 100%; }
.chart-wrap.h-260 { height: 260px; min-height: 260px; }
.chart-wrap.h-300 { height: 300px; min-height: 300px; }
.chart-wrap.h-350 { height: 350px; min-height: 350px; }
.chart-wrap.h-400 { height: 400px; min-height: 400px; }
.chart-wrap.h-500 { height: 500px; min-height: 500px; }
.chart-wrap.h-600 { height: 600px; min-height: 600px; }
.chart-wrap canvas { display: block; width: 100% !important; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th {
  background: var(--gray-100);
  padding: .6rem .9rem;
  text-align: left;
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-700);
  white-space: nowrap;
  position: sticky;
  top: 0;
  border-bottom: 2px solid var(--gray-300);
}
.data-table td { padding: .55rem .9rem; border-bottom: 1px solid #F0F0F0; }
.data-table tbody tr:hover { background: var(--blue-bg); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; font-size: .83rem; }
.data-table .pos { color: var(--pos); font-weight: 700; }
.data-table .neg { color: var(--neg); font-weight: 700; }
.data-table .total-row { background: var(--gray-100) !important; }
.data-table .total-row td { border-top: 2px solid var(--gray-300); }

/* ── Matrix ── */
.matrix-wrapper { overflow-x: auto; }
.matrix-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.matrix-table th, .matrix-table td { padding: .6rem .8rem; border: 1px solid #EBEBEB; text-align: center; }
.matrix-table .row-header { font-weight: 700; text-align: left; white-space: nowrap; background: var(--gray-100); }
.matrix-cell {
  position: relative;
  background: rgba(0,91,172,calc(var(--intensity) * 0.008));
  min-width: 110px;
}
.cell-val { display: block; font-weight: 600; font-size: .8rem; }
.cell-pct { display: block; font-size: .72rem; font-weight: 700; }
.cell-pct.pos { color: var(--pos); }
.cell-pct.neg { color: var(--neg); }
.cell-pct.neu { color: var(--gray-500); }
.row-total, .col-total, .grand-total { font-weight: 700; background: var(--gray-100); }

/* ── Admin ── */
.admin-section {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.2rem;
}
.admin-section h3 {
  margin-bottom: 1rem;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: .6rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--gray-100);
}

.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--gray-100);
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--blue); background: var(--blue-bg); }
.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.upload-zone p { color: var(--gray-500); font-size: .9rem; }
.upload-zone strong { color: var(--blue); }

.upload-progress { margin-top: 1rem; background: var(--gray-100); border-radius: 50px; height: 8px; overflow: hidden; display: none; }
.upload-progress.show { display: block; }
.upload-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-dark), var(--blue-light));
  border-radius: 50px;
  transition: width .3s ease;
  width: 0%;
}
.upload-status { margin-top: .75rem; font-size: .85rem; color: var(--gray-500); text-align: center; }

.user-form { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto; gap: .75rem; align-items: end; margin-bottom: 1rem; }
@media (max-width: 900px) { .user-form { grid-template-columns: 1fr 1fr; } }

.badge { display: inline-flex; align-items: center; padding: .2rem .65rem; border-radius: 50px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.badge-admin { background: rgba(0,91,172,.12); color: var(--blue); }
.badge-rep   { background: rgba(22,119,255,.1);  color: #1677FF; }

/* ── Sections ── */
.sections { display: none; }
.sections.active { display: block; }

/* ── States ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 4rem 2rem; color: var(--gray-500); text-align: center;
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { color: var(--gray-700); margin-bottom: .5rem; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-300);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast {
  position: fixed; top: 1.5rem; right: 1.5rem;
  background: var(--gray-900); color: var(--white);
  padding: .85rem 1.2rem; border-radius: var(--radius);
  font-size: .88rem; box-shadow: var(--shadow-lg); z-index: 9999;
  transform: translateY(-20px); opacity: 0;
  transition: all .25s ease; max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 4px solid var(--green); }
.toast.error   { border-left: 4px solid var(--neg); }
.toast.info    { border-left: 4px solid var(--blue); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 500;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal { background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem; width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 1.2rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ── Responsive ── */
@media (max-width: 1100px) { .charts-row.cols-2 { grid-template-columns: 1fr; } .charts-row.cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .charts-row.cols-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
