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

:root {
  --bg-base: #0d1117;
  --bg-surface: #161b22;
  --bg-card: #1c2128;
  --border: #30363d;
  --border-light: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --accent-blue: #58a6ff;
  --accent-red: #ff7b72;
  --accent-green: #3fb950;
  --accent-orange: #f0883e;
  --accent-purple: #bc8cff;
  --sidebar-width: 220px;
  --bottom-nav-height: 60px;
}

/* ── LIGHT MODE ──────────────────────────── */
body.light {
  --bg-base: #f6f8fa;
  --bg-surface: #ffffff;
  --bg-card: #f0f2f5;
  --border: #d0d7de;
  --border-light: #e1e4e8;
  --text-primary: #1f2328;
  --text-secondary: #57606a;
  --text-muted: #8c959f;
  --accent-blue: #0969da;
  --accent-red: #cf222e;
  --accent-green: #1a7f37;
  --accent-orange: #bc4c00;
  --accent-purple: #8250df;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Courier New', Courier, monospace;
  min-height: 100vh;
  display: flex;
  transition: background 0.3s, color 0.3s;
}

/* ── FADE IN ANIMATION ───────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
  opacity: 0;
  animation: fadeInUp 0.5s ease forwards;
}

.fade-in-1 { animation-delay: 0.05s; }
.fade-in-2 { animation-delay: 0.10s; }
.fade-in-3 { animation-delay: 0.15s; }
.fade-in-4 { animation-delay: 0.20s; }
.fade-in-5 { animation-delay: 0.25s; }
.fade-in-6 { animation-delay: 0.30s; }

/* ── SIDEBAR ─────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: background 0.3s;
}

.sidebar-logo { padding: 20px 18px 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo .logo-name { font-size: 16px; font-weight: 700; color: var(--accent-blue); letter-spacing: 2px; }
.sidebar-logo .logo-sub  { font-size: 10px; color: var(--text-secondary); letter-spacing: 1px; margin-top: 3px; }

.sidebar-status { padding: 10px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-green); flex-shrink: 0;
  animation: pulse 2s infinite;
}
.status-dot.offline { background: var(--accent-red); animation: none; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.status-text { font-size: 11px; color: var(--text-secondary); line-height: 1.4; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { font-size: 10px; color: var(--text-muted); letter-spacing: 2px; padding: 10px 18px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; font-size: 13px;
  color: var(--text-secondary); text-decoration: none;
  border-left: 2px solid transparent; transition: all 0.15s;
  position: relative;
}
.nav-item:hover  { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { color: var(--accent-blue); border-left-color: var(--accent-blue); background: rgba(88,166,255,0.06); }
.nav-icon { font-size: 14px; width: 18px; text-align: center; }

/* Badge contador alertas */
.nav-badge {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  background: var(--accent-red); color: white;
  font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 8px;
  min-width: 16px; text-align: center;
  display: none;
}
.nav-badge.visible { display: block; }

.theme-toggle {
  padding: 10px 18px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.theme-toggle-label { font-size: 11px; color: var(--text-muted); letter-spacing: 1px; }
.toggle-btn {
  width: 38px; height: 20px; border-radius: 10px;
  background: var(--border); border: none; cursor: pointer;
  position: relative; transition: background 0.3s;
}
.toggle-btn.on { background: var(--accent-blue); }
.toggle-btn::after {
  content: ''; position: absolute;
  width: 14px; height: 14px; border-radius: 50%;
  background: white; top: 3px; left: 3px;
  transition: transform 0.3s;
}
.toggle-btn.on::after { transform: translateX(18px); }

.sidebar-footer { padding: 14px 18px; border-top: 1px solid var(--border); font-size: 10px; color: var(--text-muted); line-height: 1.6; }

/* ── BOTTOM NAV ──────────────────────────── */
.bottom-nav {
  display: none; position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  z-index: 100; justify-content: space-around; align-items: center;
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: var(--text-secondary);
  flex: 1; padding: 6px 0; transition: color 0.15s;
  position: relative;
}
.bottom-nav-item.active { color: var(--accent-blue); }
.bottom-nav-item:hover  { color: var(--text-primary); }
.bottom-nav-icon  { font-size: 16px; }
.bottom-nav-label { font-size: 9px; letter-spacing: 0.5px; }
.bottom-badge {
  position: absolute; top: 2px; right: calc(50% - 18px);
  background: var(--accent-red); color: white;
  font-size: 8px; font-weight: 700;
  padding: 1px 4px; border-radius: 8px;
  display: none;
}
.bottom-badge.visible { display: block; }

/* ── MAIN ────────────────────────────────── */
.main { margin-left: var(--sidebar-width); flex: 1; padding: 24px; min-height: 100vh; }
.page-header   { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.page-title    { font-size: 18px; font-weight: 600; color: var(--text-primary); letter-spacing: 1px; }
.page-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ── CARDS ───────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; transition: background 0.3s, border-color 0.3s; }
.card-label { font-size: 10px; color: var(--text-secondary); letter-spacing: 2px; margin-bottom: 8px; }
.card-value { font-size: 32px; font-weight: 600; font-family: 'Courier New', monospace; line-height: 1; transition: all 0.4s ease; }
.card-unit  { font-size: 14px; color: var(--text-secondary); margin-left: 2px; }
.card-trend { font-size: 11px; color: var(--text-secondary); margin-top: 6px; }
.card-trend.up   { color: var(--accent-red); }
.card-trend.down { color: var(--accent-blue); }
.card-trend.ok   { color: var(--accent-green); }

/* ── GAUGE ───────────────────────────────── */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gauge-svg  { width: 100%; max-width: 140px; }
.gauge-val  { font-size: 20px; font-weight: 600; font-family: 'Courier New', monospace; text-anchor: middle; transition: all 0.5s ease; }
.gauge-unit { font-size: 10px; fill: var(--text-secondary); text-anchor: middle; }

/* ── CHART BOX ───────────────────────────── */
.chart-box { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 20px; transition: background 0.3s; }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.chart-title  { font-size: 11px; color: var(--text-secondary); letter-spacing: 2px; }
.chart-area   { position: relative; height: 200px; }
.chart-paused { position: absolute; inset: 0; background: rgba(13,17,23,0.85); border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
body.light .chart-paused { background: rgba(246,248,250,0.9); }
.chart-paused-icon  { font-size: 28px; color: var(--text-muted); }
.chart-paused-title { font-size: 13px; color: var(--text-secondary); letter-spacing: 1px; }
.chart-paused-sub   { font-size: 11px; color: var(--text-muted); }

/* ── HEATMAP ─────────────────────────────── */
.heatmap-cell { height: 18px; border-radius: 2px; cursor: pointer; transition: opacity 0.2s; }
.heatmap-cell:hover { opacity: 0.7; }

/* ── ALERT ───────────────────────────────── */
.alert { border-radius: 6px; padding: 10px 14px; font-size: 12px; margin-bottom: 14px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid; }
.alert-warn   { background: rgba(240,136,62,0.08);  border-color: var(--accent-orange); color: var(--accent-orange); }
.alert-danger { background: rgba(255,123,114,0.08); border-color: var(--accent-red);    color: var(--accent-red);    }
.alert-ok     { background: rgba(63,185,80,0.08);   border-color: var(--accent-green);  color: var(--accent-green);  }

/* ── NOTIFICATION TOAST ──────────────────── */
#notifToast {
  position: fixed; bottom: 80px; right: 20px;
  background: var(--bg-surface); border: 1px solid var(--accent-red);
  border-radius: 8px; padding: 12px 16px;
  font-size: 12px; color: var(--accent-red);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 999; max-width: 280px;
  transform: translateX(120%);
  transition: transform 0.3s ease;
}
#notifToast.show { transform: translateX(0); }

/* ── TABLE ───────────────────────────────── */
.table-box { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 20px; overflow-x: auto; transition: background 0.3s; }
.table-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text-secondary); letter-spacing: 2px; }
table { width: 100%; border-collapse: collapse; min-width: 400px; }
th { padding: 8px 16px; font-size: 10px; color: var(--text-muted); letter-spacing: 1px; text-align: left; border-bottom: 1px solid var(--border); font-weight: 400; }
td { padding: 9px 16px; font-size: 13px; border-bottom: 1px solid var(--border-light); color: var(--text-primary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card); }

/* ── BADGES ──────────────────────────────── */
.badge        { font-size: 10px; padding: 3px 8px; border-radius: 4px; font-weight: 500; letter-spacing: 0.5px; }
.badge-ok     { background: rgba(63,185,80,0.15);   color: var(--accent-green);  }
.badge-warn   { background: rgba(240,136,62,0.15);  color: var(--accent-orange); }
.badge-danger { background: rgba(255,123,114,0.15); color: var(--accent-red);    }

.section-label { font-size: 10px; color: var(--text-muted); letter-spacing: 2px; text-transform: uppercase; margin-bottom: 10px; }

/* ── RANGE BAR ───────────────────────────── */
.range-bar { position:relative; height:10px; background:linear-gradient(to right,#58a6ff 0%,#3fb950 30%,#3fb950 70%,#ff7b72 100%); border-radius:5px; margin-top:6px; }
.range-marker { position:absolute; top:-4px; width:4px; height:18px; background:white; border-radius:2px; transform:translateX(-50%); transition:left 0.5s ease; box-shadow:0 0 6px rgba(255,255,255,0.5); }

/* ── NUMBER ANIMATION ────────────────────── */
@keyframes numPop { 0%{transform:scale(1)} 50%{transform:scale(1.12)} 100%{transform:scale(1)} }
.num-pop { animation: numPop 0.35s ease; }

/* ── QR CODE BOX ─────────────────────────── */
.qr-box {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 20px;
  background: var(--bg-card); border-radius: 8px;
  border: 1px solid var(--border);
}
.qr-box img { width: 140px; height: 140px; border-radius: 6px; }
.qr-label   { font-size: 11px; color: var(--text-secondary); letter-spacing: 1px; }
.qr-url     { font-size: 12px; color: var(--accent-blue); }

/* ── RESPONSIVE ──────────────────────────── */
@media (max-width: 768px) {
  .sidebar    { display: none; }
  .bottom-nav { display: flex; }
  .main { margin-left: 0; padding: 16px 12px; padding-bottom: calc(var(--bottom-nav-height) + 16px); }
  .cards-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card { padding: 12px; }
  .card-value { font-size: 22px; }
  .card-unit  { font-size: 12px; }
  .chart-area { height: 160px; }
  .page-title    { font-size: 15px; }
  .page-subtitle { font-size: 11px; }
  #notifToast { bottom: 70px; right: 10px; left: 10px; max-width: none; }
}

/* ── SWIPE TRANSITION ────────────────────── */
.main { overflow-x: hidden; }
