:root {
  --verde: #2D6A4F;
  --verde-md: #40916C;
  --verde-lt: #74C69D;
  --verde-xs: #D8F3DC;
  --terra: #8B5E3C;
  --terra-lt: #F5E6D8;
  --ouro: #D4A017;
  --ouro-lt: #FFF3CD;
  --azul: #1A6B9A;
  --azul-lt: #D6EAF8;
  --cinza-dk: #1C2B2A;
  --cinza: #3D5048;
  --cinza-md: #6B7E76;
  --cinza-lt: #C8D5CE;
  --cinza-xs: #F0F5F2;
  --branco: #FAFCFB;
  --perigo: #C0392B;
  --perigo-lt: #FDEDEC;
  --laranja: #E67E22;
  --laranja-lt: #FEF0E7;
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --transition: all .2s ease;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--cinza-xs);
  color: var(--cinza-dk);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── LOGIN ── */
#login-screen {
  position: fixed; inset:0; z-index:100;
  background: linear-gradient(135deg, #1a3a2a 0%, #2D6A4F 50%, #1a3a2a 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
}

.login-card {
  background: rgba(255,255,255,.96);
  border-radius: 18px;
  padding: 48px 44px;
  width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 72px; height: 72px;
  background: var(--verde);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 14px;
  box-shadow: 0 4px 16px rgba(45,106,79,.4);
}

.login-logo h1 {
  font-size: 32px; font-weight: 800; color: var(--verde);
  letter-spacing: -1px;
}

.login-logo p {
  font-size: 13px; color: var(--cinza-md);
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  margin-top: 2px;
}

.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--cinza);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 6px;
  font-family: 'Inter', sans-serif;
}

.login-card input, .login-card select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--cinza-lt);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  background: var(--branco);
  color: var(--cinza-dk);
  transition: var(--transition);
  margin-bottom: 16px;
  outline: none;
}

.login-card input:focus, .login-card select:focus {
  border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(45,106,79,.12);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--verde);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: 'Syne', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: .3px;
  margin-top: 4px;
}

.btn-primary:hover { background: var(--verde-md); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(45,106,79,.3); }

.login-roles {
  display: flex; gap: 8px;
  margin: 20px 0 24px;
}

.role-chip {
  flex: 1;
  padding: 8px 6px;
  border: 1.5px solid var(--cinza-lt);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  color: var(--cinza-md);
  background: var(--branco);
}

.role-chip:hover, .role-chip.active {
  border-color: var(--verde);
  color: var(--verde);
  background: var(--verde-xs);
}

.login-visitors {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--cinza-xs);
  display: flex; justify-content: space-between;
  align-items: center;
}

.visitor-stat {
  text-align: center;
}

.visitor-stat .num {
  font-size: 18px; font-weight: 700; color: var(--verde); font-family: 'Syne', sans-serif;
}

.visitor-stat .lbl {
  font-size: 10px; color: var(--cinza-md); text-transform: uppercase; letter-spacing: .5px;
}

.online-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: #2ecc71;
  border-radius: 50%;
  margin-right: 4px;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%,100%{opacity:1} 50%{opacity:.4}
}

/* ── LAYOUT PRINCIPAL ── */
#app { display: none; }
#app.visible { display: flex; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--cinza-dk);
  height: 100vh;
  position: fixed; left:0; top:0; z-index:50;
  display: flex; flex-direction: column;
  transition: var(--transition);
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
}

.sidebar-logo .icon {
  width: 36px; height: 36px;
  background: var(--verde);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.sidebar-logo h2 {
  font-family: 'Syne', sans-serif;
  font-size: 22px; font-weight: 800;
  color: #fff;
  letter-spacing: -1px;
}

.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.user-info {
  display: flex; align-items: center; gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--verde-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.user-details .name {
  font-size: 13px; font-weight: 600; color: #fff;
}

.user-details .role-badge {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.role-admin { background: #E74C3C; color: #fff; }
.role-operador { background: var(--ouro); color: #fff; }
.role-usuario { background: var(--verde-md); color: #fff; }

.status-dot {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; color: rgba(255,255,255,.5);
  margin-top: 4px;
}

.dot-green { width:6px;height:6px;border-radius:50%;background:#2ecc71;animation:pulse-dot 2s infinite; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 10px 20px 4px;
  font-family: 'Syne', sans-serif;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: var(--transition);
  border-radius: 0;
  position: relative;
  color: rgba(255,255,255,.65);
  font-size: 13.5px;
  font-weight: 500;
  user-select: none;
}

.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.nav-item.active {
  background: rgba(64,145,108,.25);
  color: var(--verde-lt);
  font-weight: 600;
}

.nav-item.active::before {
  content:'';
  position: absolute; left:0; top:0; bottom:0;
  width: 3px;
  background: var(--verde-lt);
  border-radius: 0 2px 2px 0;
}

.nav-item .icon { font-size: 18px; flex-shrink:0; }
.nav-item .badge {
  margin-left: auto;
  background: var(--perigo);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.online-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: rgba(255,255,255,.5);
  margin-bottom: 10px;
}

.btn-logout {
  width: 100%;
  padding: 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover { background: rgba(192,57,43,.2); color: #E74C3C; border-color: rgba(192,57,43,.3); }

/* ── MAIN ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--cinza-lt);
  display: flex; align-items: center;
  padding: 0 28px;
  position: sticky; top:0; z-index:40;
  gap: 16px;
}

.topbar-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px; font-weight: 700;
  color: var(--cinza-dk);
  flex: 1;
}

.topbar-title span {
  font-size: 13px;
  font-weight: 400;
  color: var(--cinza-md);
  font-family: 'Inter', sans-serif;
  margin-left: 8px;
}

.topbar-actions {
  display: flex; align-items: center; gap: 10px;
}

.topbar-btn {
  padding: 8px 12px;
  border: 1px solid var(--cinza-lt);
  border-radius: var(--radius-sm);
  background: var(--branco);
  color: var(--cinza);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; gap: 6px;
}

.topbar-btn:hover { background: var(--verde-xs); border-color: var(--verde-lt); color: var(--verde); }

.notif-badge {
  background: var(--perigo);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 20px;
}

/* ── PAGE CONTENT ── */
.page {
  display: none;
  padding: 28px;
  flex: 1;
  animation: fadeIn .25s ease;
}

.page.active { display: block; }

@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

/* ── CARDS ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--cinza-lt);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--cinza-xs);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 700;
  color: var(--cinza-dk);
}

.card-body { padding: 20px 22px; }

/* ── GRID STATS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--cinza-lt);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex; gap: 14px; align-items: flex-start;
  cursor: pointer;
  transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.ic-verde { background: var(--verde-xs); }
.ic-terra { background: var(--terra-lt); }
.ic-ouro  { background: var(--ouro-lt); }
.ic-azul  { background: var(--azul-lt); }
.ic-laranja { background: var(--laranja-lt); }
.ic-perigo  { background: var(--perigo-lt); }

.stat-info .num {
  font-family: 'Syne', sans-serif;
  font-size: 22px; font-weight: 700; color: var(--cinza-dk);
}

.stat-info .lbl {
  font-size: 12px; color: var(--cinza-md); margin-top: 2px;
}

.stat-info .delta {
  font-size: 11px; font-weight: 600; margin-top: 4px;
}

.delta-up { color: #27AE60; }
.delta-dn { color: var(--perigo); }

/* ── GRID LAYOUT ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-12 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--cinza-md);
  padding: 10px 14px;
  text-align: left;
  background: var(--cinza-xs);
  border-bottom: 1px solid var(--cinza-lt);
}
tbody td {
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--cinza-dk);
  border-bottom: 1px solid var(--cinza-xs);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fbf9; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}

.badge-success { background: #D5F5E3; color: #1E8449; }
.badge-warning { background: var(--ouro-lt); color: #9A7D0A; }
.badge-danger  { background: var(--perigo-lt); color: #922B21; }
.badge-info    { background: var(--azul-lt); color: #1A5276; }
.badge-neutral { background: var(--cinza-xs); color: var(--cinza-md); }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--cinza);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--cinza-lt);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  background: var(--branco);
  color: var(--cinza-dk);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(45,106,79,.1);
}

.form-row { display: grid; gap: 14px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: inline-flex; align-items: center; gap: 6px;
}

.btn-verde { background: var(--verde); color: #fff; }
.btn-verde:hover { background: var(--verde-md); }
.btn-outline { background: transparent; color: var(--cinza); border: 1.5px solid var(--cinza-lt); }
.btn-outline:hover { background: var(--cinza-xs); }
.btn-danger { background: var(--perigo); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── CHART BARS (CSS) ── */
.chart-bar-group {
  display: flex; align-items: flex-end; gap: 6px;
  height: 140px;
  padding: 0 4px;
}

.chart-bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.chart-bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  transition: height .4s ease;
  min-height: 4px;
}

.bar-verde { background: var(--verde); }
.bar-ouro  { background: var(--ouro); }
.bar-terra { background: var(--terra); }
.bar-azul  { background: var(--azul); }

.chart-label { font-size: 10px; color: var(--cinza-md); }

/* ── MÓDULO CARDS ── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.module-card {
  background: #fff;
  border: 1px solid var(--cinza-lt);
  border-radius: var(--radius);
  padding: 22px 20px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  box-shadow: var(--shadow);
}

.module-card:hover {
  border-color: var(--verde-lt);
  background: var(--verde-xs);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.module-card .mod-icon { font-size: 36px; margin-bottom: 10px; }
.module-card .mod-title { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: var(--cinza-dk); }
.module-card .mod-desc { font-size: 12px; color: var(--cinza-md); margin-top: 4px; }
.module-card .mod-count { font-size: 11px; font-weight: 600; color: var(--verde); margin-top: 8px; }

/* ── ALERTAS ── */
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.alert-danger  { background: var(--perigo-lt); border-left: 3px solid var(--perigo); }
.alert-warning { background: var(--ouro-lt);   border-left: 3px solid var(--ouro); }
.alert-success { background: #D5F5E3;           border-left: 3px solid #27AE60; }
.alert-info    { background: var(--azul-lt);    border-left: 3px solid var(--azul); }

.alert-item .alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-item strong { display: block; font-weight: 600; color: var(--cinza-dk); margin-bottom: 2px; }
.alert-item span   { color: var(--cinza-md); }

/* ── PROGRESSO ── */
.progress-bar {
  background: var(--cinza-lt);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 20px;
  transition: width .5s ease;
}

/* ── ABAS ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--cinza-lt);
  margin-bottom: 22px;
  gap: 0;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 13px; font-weight: 600;
  color: var(--cinza-md);
  cursor: pointer;
  border: none; background: transparent;
  font-family: 'Inter', sans-serif;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}

.tab-btn.active {
  color: var(--verde);
  border-bottom-color: var(--verde);
}

.tab-btn:hover { color: var(--verde-md); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── PAGE HEADER ── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px;
}

.page-header-text h2 {
  font-family: 'Syne', sans-serif;
  font-size: 22px; font-weight: 800;
  color: var(--cinza-dk);
}

.page-header-text p {
  font-size: 13px; color: var(--cinza-md); margin-top: 3px;
}

.page-header-actions { display: flex; gap: 8px; }

/* ── SEPARADOR ── */
.divider { height: 1px; background: var(--cinza-lt); margin: 20px 0; }

/* ── MINI STAT ROW ── */
.mini-stats { display: flex; gap: 20px; margin-bottom: 20px; }
.mini-stat { text-align: center; }
.mini-stat .val { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 700; color: var(--verde); }
.mini-stat .key { font-size: 11px; color: var(--cinza-md); }

/* ── TOOLTIP CHIP ── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--cinza-xs);
  border-radius: 20px;
  font-size: 12px; font-weight: 500;
  color: var(--cinza);
}

/* ── ADMIN ONLY INDICATOR ── */
.admin-only { border-left: 3px solid #E74C3C; }
.operador-plus { border-left: 3px solid var(--ouro); }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .module-grid { grid-template-columns: repeat(2,1fr); }
  .grid-12, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed; inset:0; z-index:200;
  background: rgba(0,0,0,.45);
  align-items: center; justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 580px; max-width: 95vw; max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .2s ease;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--cinza-lt);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-header h3 { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none; background: var(--cinza-xs);
  cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: var(--cinza-lt); }
.modal-body { padding: 22px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--cinza-lt); display: flex; justify-content: flex-end; gap: 10px; }

/* ── VISITANTES CONTADOR ── */
.visitor-counter {
  display: flex; align-items: center; gap: 16px;
  background: var(--cinza-xs);
  border: 1px solid var(--cinza-lt);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 12px;
}

.vc-item { display: flex; align-items: center; gap: 6px; }
.vc-num { font-family: 'Syne', sans-serif; font-weight: 700; color: var(--cinza-dk); font-size: 16px; }
.vc-lbl { color: var(--cinza-md); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cinza-lt); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cinza-md); }