:root {
  --bg: #070b14;
  --bg2: #0b1220;
  --panel: #121a2b;
  --panel2: #1a2438;
  --line: rgba(148, 163, 184, 0.16);
  --gold: #c9a227;
  --gold2: #e8c547;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --primary: #c9a227;
  --primary-light: #e8c547;
  --accent: #c9a227;
  --card: #121a2b;
  --border: rgba(148, 163, 184, 0.16);
  --sidebar-w: 260px;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
a { color: var(--gold2); }

/* LOGIN */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 20%, #1a2438 0%, #070b14 55%);
  padding: 20px;
}
.login-card {
  background: rgba(18, 26, 43, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(12px);
}
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, #c9a227, #8a7020);
  color: #111;
  font-weight: 900;
  font-size: 18px;
  display: grid; place-items: center;
  box-shadow: 0 8px 28px rgba(201,162,39,.35);
}
.login-card h1 {
  color: var(--gold2);
  font-size: 26px;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.login-sub { color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.login-card label {
  display: block;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 16px;
  background: var(--bg2);
  color: var(--text);
}
.login-card input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.2);
}
.login-hint { margin-top: 14px; font-size: 12px; color: var(--muted); }

/* APP */
.app { display: flex; min-height: 100vh; background: var(--bg); }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #121a2b 0%, #0b1220 100%);
  border-right: 1px solid var(--line);
  color: var(--text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar-brand {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 16px;
  color: var(--gold2);
}
.brand-icon { font-size: 22px; }
.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-section {
  padding: 14px 18px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  margin: 2px 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover, .nav-item.active {
  background: rgba(201, 162, 39, 0.12);
  color: var(--gold2);
}
.nav-icon { font-size: 15px; width: 22px; text-align: center; }
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(7, 11, 20, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.topbar h2 { font-size: 17px; font-weight: 700; color: var(--text); flex: 1; }
.menu-toggle {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 18px;
  cursor: pointer;
}
.content { padding: 16px 18px 88px; flex: 1; }

/* Cards / panels */
.card, .panel, .stat-card, .kpi, .box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
}
.panel { padding: 16px; margin-bottom: 16px; }
.panel-header, .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.stats, .kpi-row, .grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card, .kpi {
  padding: 14px 16px;
}
.stat-card h3, .kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-card .value, .kpi .value {
  font-size: 22px;
  font-weight: 800;
  color: var(--gold2);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.2);
}
tr:hover td { background: rgba(201, 162, 39, 0.04); }

/* Forms */
input, select, textarea {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}
label { color: var(--muted); font-size: 12px; font-weight: 600; }

/* Buttons */
.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary, .btn.btn-primary {
  background: linear-gradient(135deg, #c9a227, #a8841c);
  border-color: transparent;
  color: #111;
  font-weight: 700;
}
.btn-block { width: 100%; }
.btn-danger { background: rgba(248, 113, 113, 0.15); color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }
.btn-ghost { background: transparent; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px 18px 12px 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  padding: 18px;
  color: var(--text);
}
@media (min-width: 768px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 18px; }
}

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel2);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 300;
  font-size: 13px;
  box-shadow: var(--shadow);
}

/* Bottom nav mobile — padrão suíte EC$ 360° */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 200;
  background: rgba(7, 11, 20, 0.97);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(8px + var(--safe-b));
  justify-content: space-around;
  gap: 2px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.bottom-nav .bn-item,
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  margin: 0;
  padding: 6px 2px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.bottom-nav .bn-item.active,
.bottom-nav a.active {
  color: var(--gold2);
  background: rgba(201, 162, 39, 0.14);
}
.bottom-nav .bn-ico { font-size: 18px; line-height: 1; pointer-events: none; }
.bottom-nav .bn-item span:last-child { pointer-events: none; }
.bottom-nav a.active, .bottom-nav a:hover { color: var(--gold2); }
.bottom-nav .bn-ico { display: block; font-size: 18px; margin-bottom: 2px; }

.page { display: none; }
.page.active { display: block; }

@media print {
  .sidebar, .topbar, .toolbar, .btn, .modal-overlay, .toast, .bottom-nav, .menu-toggle {
    display: none !important;
  }
  .main { margin-left: 0; }
  body { background: #fff; color: #000; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 40px rgba(0,0,0,.5); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding-bottom: calc(72px + var(--safe-b)); }
  .bottom-nav { display: flex; }
  .stats, .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1000px) {
  .sidebar-brand .brand-text { font-size: 14px; }
}

/* Charts canvas area */
canvas { max-width: 100%; }

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(201, 162, 39, 0.15);
  color: var(--gold2);
}
.badge-ok { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.badge-danger { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
