:root {
  --bg: #f8fafc; --surface: #ffffff; --border: #e2e8f0; --text: #0f172a;
  --muted: #64748b; --primary: #4f46e5; --primary-hover: #4338ca;
  --success: #10b981; --warning: #f59e0b; --danger: #ef4444; --radius: 8px;
}

/* Base Reset & Fonts */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === AUTH SCREENS (LOGIN / 2FA / LOCK) === */
.auth-wrap { 
  min-height: 100vh; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  background: linear-gradient(135deg, #f8fafc, #eef2ff); 
  padding: 20px; 
}
.auth-card { 
  width: 100%; 
  max-width: 400px; /* Prevents stretching */
  background: var(--surface); 
  padding: 40px 32px; 
  border-radius: 16px; 
  box-shadow: 0 4px 20px rgba(15,23,42,.08); 
  border: 1px solid var(--border); 
}
.auth-logo { font-size: 22px; font-weight: 800; margin-bottom: 8px; color: var(--primary); text-align: center; letter-spacing: -0.5px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; }
.field input { 
  width: 100%; 
  padding: 12px; 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  font-size: 14px; 
  font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.btn { 
  width: 100%; 
  padding: 12px; 
  background: var(--primary); 
  color: white; 
  border: none; 
  border-radius: var(--radius); 
  font-weight: 600; 
  font-size: 14px; 
  cursor: pointer; 
  transition: background 0.2s; 
}
.btn:hover { background: var(--primary-hover); }
.error-msg { background: #fee2e2; color: #991b1b; padding: 10px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; text-align: center; }

/* Lock Screen Specific */
.lock-screen-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(248, 250, 252, 0.95); backdrop-filter: blur(4px); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.pin-input { text-align: center; font-size: 24px; letter-spacing: 8px; font-weight: bold; }

/* === APP LAYOUT === */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 24px 0; display: flex; flex-direction: column; }
.sidebar-brand { padding: 0 24px 24px; font-weight: 800; font-size: 18px; color: var(--text); border-bottom: 1px solid var(--border); margin-bottom: 16px; letter-spacing: -0.5px; }
.sidebar-brand span { color: var(--primary); }
.nav-item { display: flex; align-items: center; padding: 12px 24px; color: var(--muted); font-weight: 500; border-left: 3px solid transparent; transition: all 0.2s; }
.nav-item:hover { background: #f8fafc; color: var(--text); text-decoration: none; }
.nav-item.active { background: #eef2ff; color: var(--primary); border-left-color: var(--primary); }
.nav-icon { margin-right: 12px; font-size: 16px; }

.main { display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 32px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-title { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-user { font-size: 13px; color: var(--muted); font-weight: 600; }
.content { padding: 32px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* === DASHBOARD WIDGETS === */
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); padding: 20px; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.02); }
.stat-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 16px; font-weight: 600; }
.stat-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.stat-row:last-child { margin-bottom: 0; }
.stat-label { display: flex; align-items: center; color: var(--muted); }
.stat-value { font-weight: 700; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }
.dot.g { background: var(--success); box-shadow: 0 0 8px rgba(16,185,129,.3); }
.dot.r { background: var(--danger); box-shadow: 0 0 8px rgba(239,68,68,.3); }
.dot.y { background: var(--warning); box-shadow: 0 0 8px rgba(245,158,11,.3); }

/* === PANELS & TABLES === */
.grid-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.02); }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; background: #fafafa; }
.panel-body { padding: 20px; }

.tbl { width: 100%; border-collapse: collapse; text-align: left; }
.tbl th { padding: 12px 20px; background: #f8fafc; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; border-bottom: 1px solid var(--border); }
.tbl td { padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl tbody tr:last-child td { border-bottom: none; }

/* Pills & Badges */
.pill { padding: 4px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; display: inline-block; }
.pill.up { background: #d1fae5; color: #065f46; }
.pill.down { background: #fee2e2; color: #991b1b; }
.pill.slow { background: #fef3c7; color: #92400e; }

/* Gauges */
.gauge { margin-bottom: 16px; }
.gauge-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.gauge-bar { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 99px; background: var(--primary); }
.gauge-fill.crit { background: var(--danger); }
.gauge-fill.warn { background: var(--warning); }

/* Alerts */
.alert-item { display: flex; align-items: flex-start; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.alert-item:last-child { border-bottom: none; }
.alert-icon { margin-right: 12px; font-size: 16px; }
.alert-text strong { display: block; font-size: 14px; margin-bottom: 2px; }
.alert-text small { color: var(--muted); font-size: 12px; }

@media (max-width: 1024px) {
  .grid-panels { grid-template-columns: 1fr; }
}