:root {
  --bg-space: #0f172a;         /* Slate 900 */
  --bg-panel: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
  --bg-panel-hover: rgba(30, 41, 59, 0.9);
  
  --text-main: #f8fafc;        /* Slate 50 */
  --text-muted: #94a3b8;       /* Slate 400 */
  
  --primary: #3b82f6;          /* Blue 500 */
  --primary-hover: #2563eb;    /* Blue 600 */
  --primary-glow: rgba(59, 130, 246, 0.4);
  
  --success: #10b981;          /* Emerald 500 */
  --warning: #f59e0b;          /* Amber 500 */
  --danger: #ef4444;           /* Red 500 */
  
  --border: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(255, 255, 255, 0.2);
  
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  --radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-space);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ────────────────────────────────────────────────────────────────
   GLASSMORPHISM & COMMON
   ──────────────────────────────────────────────────────────────── */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hidden { display: none !important; }
.text-center { text-align: center; }

/* ────────────────────────────────────────────────────────────────
   FORMS & BUTTONS
   ──────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}
.input-icon {
  position: relative;
}
.input-icon i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.input-icon input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 1rem;
  font-family: inherit;
  transition: var(--transition);
}
.input-icon input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

button {
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: var(--transition);
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: white;
  padding: 14px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  width: 100%;
  box-shadow: 0 4px 14px 0 var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 var(--primary-glow);
}
.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
}
.btn-secondary:hover { background: rgba(255,255,255,0.2); }
.btn-icon {
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 6px;
  font-size: 1rem;
}
.btn-icon:hover {
  color: var(--text-main);
  background: rgba(255,255,255,0.1);
}

/* ────────────────────────────────────────────────────────────────
   LOGIN VIEW
   ──────────────────────────────────────────────────────────────── */
.view-container {
  min-height: 100vh;
  width: 100%;
}
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-wrapper {
  width: 100%;
  max-width: 440px;
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.login-card {
  padding: 40px;
}
.login-header {
  text-align: center;
  margin-bottom: 32px;
}
.login-header h2 {
  font-size: 1.75rem;
  margin-bottom: 8px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}
.error-msg {
  color: var(--danger);
  font-size: 0.875rem;
  margin-bottom: 16px;
  min-height: 20px;
  text-align: center;
}

/* ────────────────────────────────────────────────────────────────
   DASHBOARD LAYOUT
   ──────────────────────────────────────────────────────────────── */
#dashboard-view {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}
.sidebar {
  border-radius: 0;
  border-right: 1px solid var(--border);
  border-top: none;
  border-bottom: none;
  border-left: none;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  border-bottom: 1px solid var(--border);
}
.brand-icon { color: var(--primary); }

.sidebar-nav {
  padding: 24px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: var(--transition);
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.05);
  color: var(--text-main);
}
.nav-item.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  border-right: 3px solid var(--primary);
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.user-details { display: flex; flex-direction: column; }
.user-name { font-size: 0.875rem; font-weight: 600; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

/* MAIN CONTENT */
.main-content {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.top-nav {
  margin: 24px 32px;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
h1#page-title {
  font-size: 1.25rem;
  font-weight: 600;
}
.status-badge {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.status-badge i { font-size: 8px; }

.content-wrapper {
  padding: 0 32px 32px;
  flex: 1;
}

/* ────────────────────────────────────────────────────────────────
   TABS & DASHBOARD COMPONENTS
   ──────────────────────────────────────────────────────────────── */
.welcome-banner { margin-bottom: 24px; }
.welcome-banner h2 { font-size: 1.5rem; margin-bottom: 8px; }
.welcome-banner p { color: var(--text-muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.stat-card {
  padding: 24px;
  transition: transform 0.2s, background 0.2s;
}
.stat-card:hover { transform: translateY(-4px); background: var(--bg-panel-hover); }
.stat-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px;}
.stat-header h3 { font-size: 0.875rem; color: var(--text-muted); font-weight: 500;}
.stat-icon { font-size: 1.5rem; }
.stat-icon.blue { color: var(--primary); }
.stat-icon.green { color: var(--success); }
.stat-icon.yellow { color: var(--warning); }
.stat-value { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.stat-trend { font-size: 0.75rem; display: flex; align-items: center; gap: 4px; }
.stat-trend.positive { color: var(--success); }
.stat-trend.neutral { color: var(--text-muted); }

.charts-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}
.chart-card { padding: 24px; }
.chart-card h3 { font-size: 1rem; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 12px;}

/* Custom Progress bars for Orgãos */
.orgao-item { margin-bottom: 16px; }
.orgao-info { display: flex; justify-content: space-between; font-size: 0.875rem; margin-bottom: 6px; }
.orgao-bar-bg { width: 100%; height: 8px; background: rgba(255,255,255,0.05); border-radius: 4px; overflow: hidden; }
.orgao-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 1s ease;}

/* ────────────────────────────────────────────────────────────────
   CREDENTIALS TAB
   ──────────────────────────────────────────────────────────────── */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.section-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.section-header .btn-primary { width: auto; padding: 10px 20px; }

.alert-box {
  padding: 24px; margin-bottom: 24px;
  display: flex; gap: 16px; align-items: flex-start;
  background: rgba(16, 185, 129, 0.05); /* very light success tint */
  border-color: rgba(16, 185, 129, 0.2);
}
.alert-icon { color: var(--success); font-size: 1.5rem; }
.alert-content h3 { color: var(--success); margin-bottom: 4px; font-size: 1rem;}
.alert-content p { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 16px; }
.copy-box {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,0.3); padding: 12px 16px; border-radius: 8px; border: 1px solid var(--border);
}
.copy-box code { font-family: monospace; color: var(--primary); font-size: 1rem; letter-spacing: 1px; }

.table-container { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; text-align: left;
}
.data-table th, .data-table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--text-muted); font-weight: 500; font-size: 0.875rem;}
.data-table td { font-size: 0.95rem; }
.data-table tr:last-child td { border-bottom: none; }
.badge-active { background: rgba(16, 185, 129, 0.1); color: var(--success); padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; }

pre { background: rgba(0,0,0,0.3); padding: 16px; border-radius: 8px; border: 1px solid var(--border); overflow-x: auto;}
pre code { color: #818cf8; font-family: monospace; font-size: 0.875rem; }

/* ────────────────────────────────────────────────────────────────
   ANIMATIONS & RESPONSIVE
   ──────────────────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  #dashboard-view { grid-template-columns: 1fr; grid-template-rows: auto 1fr;}
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; align-items: center; justify-content: space-between; padding: 0 16px;}
  .sidebar-nav { flex-direction: row; padding: 16px 0; overflow-x: auto; white-space: nowrap;}
  .sidebar-footer { padding: 16px 0; border: none; }
  .user-details { display: none; }
  .charts-section { grid-template-columns: 1fr; }
}
