:root {
  --bg: #090d16;
  --bg-subtle: #0d1322;
  --surface: #121826;
  --surface-hover: #182235;
  --surface-2: #1e293b;
  --surface-3: #283548;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(59, 130, 246, 0.5);
  --text: #f1f5f9;
  --text-muted: #8492a6;
  --text-dim: #627084;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --danger: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.12);
  --danger-border: rgba(244, 63, 94, 0.35);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.35);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 30px -4px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: #60a5fa; text-decoration: none; }

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 24, 38, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.3px;
}
.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 15px var(--primary-glow);
}
.navbar-nav {
  display: flex;
  gap: 6px;
  align-items: center;
  list-style: none;
}
.nav-link {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-link:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.nav-link.active {
  color: #fff;
  background: var(--surface-2);
}
.nav-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
}
.user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.btn-logout {
  color: var(--text-dim);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-logout:hover { color: var(--danger); background: var(--danger-bg); }

.container {
  max-width: 1380px;
  margin: 24px auto;
  padding: 0 20px;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.4px;
}
.page-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Cards & Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}
.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

/* Policy Card Top Accents */
.card-policy-fonte { border-top: 3px solid #10b981; }
.card-policy-controle { border-top: 3px solid #3b82f6; }
.card-policy-telecom { border-top: 3px solid #8b5cf6; }
.card-policy-usina { border-top: 3px solid #f59e0b; }

/* Stat badge & tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.35); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-spinner {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Forms & Inputs */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-row { display: flex; gap: 12px; align-items: flex-end; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s;
}
.btn:hover {
  background: var(--surface-3);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: 1px solid #3b82f6;
  color: #fff;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}
.btn-danger {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th, td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--bg-subtle);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.6px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.015); }

/* Switch toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--surface-3);
  transition: .2s;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.slider:before {
  position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px;
  background-color: #fff;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
input:checked + .slider { background-color: var(--success); border-color: var(--success); }
input:checked + .slider:before { transform: translateX(18px); }

/* Log Console */
.log-box {
  background: #050811;
  color: #34d399;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 18px;
  border-radius: var(--radius);
  max-height: 480px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
}
