@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0f1117;
  --surface: #181b22;
  --surface2: #1e222b;
  --border: #2a2f3a;
  --text: #e4e6eb;
  --text-dim: #8b8f9a;
  --accent: #3b82f6;
  --accent-dim: #1e3a5f;
  --green: #22c55e;
  --green-dim: #0a2e1a;
  --yellow: #eab308;
  --yellow-dim: #3d2e05;
  --red: #ef4444;
  --red-dim: #3b1111;
  --radius: 8px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ─── LAYOUT ─── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sidebar-logo h1 span { color: var(--accent); }
.sidebar-logo p { font-size: 11px; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: 1px; }

.sidebar-nav { padding: 12px 0; }

.nav-section { padding: 8px 20px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); margin-top: 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent); background: var(--accent-dim); border-left-color: var(--accent); }
.nav-item .badge { background: var(--red); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 10px; margin-left: auto; }

.main {
  margin-left: 240px;
  flex: 1;
  padding: 24px 32px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }

/* ─── STAT CARDS ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 6px; }
.stat-card .value { font-size: 28px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.stat-card .value.critical { color: var(--red); }
.stat-card .value.warning { color: var(--yellow); }
.stat-card .value.good { color: var(--green); }

/* ─── TABLES ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 { font-size: 14px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 16px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); background: var(--surface2); font-weight: 600; }
td { padding: 12px 16px; font-size: 13px; border-top: 1px solid var(--border); }
tr:hover td { background: rgba(59,130,246,0.03); }

/* ─── BADGES ─── */
.badge-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-status.critical { background: var(--red-dim); color: var(--red); }
.badge-status.warning { background: var(--yellow-dim); color: var(--yellow); }
.badge-status.good, .badge-status.valid, .badge-status.pass, .badge-status.active { background: var(--green-dim); color: var(--green); }
.badge-status.expired, .badge-status.fail, .badge-status.overdue { background: var(--red-dim); color: var(--red); }
.badge-status.expiring { background: var(--yellow-dim); color: var(--yellow); }
.badge-status.info { background: var(--accent-dim); color: var(--accent); }
.badge-status.missing { background: var(--red-dim); color: var(--red); }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  transition: all 0.15s;
}

.btn:hover { background: var(--border); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-danger { background: var(--red-dim); border-color: var(--red); color: var(--red); }

/* ─── ALERTS LIST ─── */
.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.alert-item:first-child { border-top: none; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.alert-dot.critical { background: var(--red); box-shadow: 0 0 6px var(--red); }
.alert-dot.warning { background: var(--yellow); }
.alert-dot.info { background: var(--accent); }
.alert-msg { flex: 1; font-size: 13px; }
.alert-type { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── HOS BAR ─── */
.hos-bar {
  display: flex;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface2);
}

.hos-bar .segment { height: 100%; position: relative; }
.hos-bar .driving { background: var(--accent); }
.hos-bar .on_duty { background: var(--yellow); }
.hos-bar .off_duty { background: var(--green-dim); }
.hos-bar .sleeper { background: #1e1e2e; }
.hos-bar .violation { background: var(--red); }

.hos-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
}

.hos-legend span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

.hos-legend .l-driving::before { background: var(--accent); }
.hos-legend .l-on_duty::before { background: var(--yellow); }
.hos-legend .l-off::before { background: var(--green-dim); }
.hos-legend .l-violation::before { background: var(--red); }

/* ─── DQ CHECKLIST ─── */
.dq-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 16px 20px;
}

.dq-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface2);
  font-size: 12px;
}

.dq-item .icon { font-size: 14px; }
.dq-item.valid .icon { color: var(--green); }
.dq-item.expiring .icon { color: var(--yellow); }
.dq-item.expired .icon, .dq-item.missing .icon { color: var(--red); }

/* ─── DETAIL PANEL ─── */
.panel-overlay {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 240px;
  background: rgba(0,0,0,0.5);
  z-index: 200;
}

.panel-overlay.open { display: block; }

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 520px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  z-index: 201;
  padding: 24px;
}

.detail-panel h3 { font-size: 18px; margin-bottom: 16px; }
.detail-panel .close-btn { position: absolute; top: 16px; right: 16px; cursor: pointer; color: var(--text-dim); font-size: 20px; background: none; border: none; }

/* ─── SECTION VIEWS ─── */
.section { display: none; }
.section.active { display: block; }

/* ─── MONO NUMBERS ─── */
.mono { font-family: 'JetBrains Mono', monospace; }

/* ─── RESPONSIVE ─── */
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .dq-grid { grid-template-columns: 1fr; }
}

/* LOGIN SCREEN */
.login-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%; max-width: 380px;
  text-align: center;
}
.login-box h1 { font-size: 28px; margin-bottom: 4px; color: var(--text); }
.login-box input:focus { outline: none; border-color: #00ff88; }
.login-box button:hover { opacity: 0.9; }
.user-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); margin-top: auto; font-size: 12px; color: var(--text-dim); }
.user-bar button { background: none; border: 1px solid var(--border); color: var(--text-dim); padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.user-bar button:hover { border-color: var(--red); color: var(--red); }
