:root {
  --sidebar-bg: #003261;
  --sidebar-hover: #0d4375;
  --sidebar-active: #16528a;
  --primary: #00529d;
  --bg-page: #f4f6f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --green: #059669;
  --red: #dc2626;
  --purple: #7c3aed;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-title { font-weight: 800; font-size: 18px; letter-spacing: 0.5px; }
.dev-pill {
  background: #f59e0b;
  color: #000;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 99px;
}
.nav-section { padding: 14px 12px 4px; font-size: 11px; text-transform: uppercase; color: #93c5fd; font-weight: 600; }
.nav-item {
  margin: 2px 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: #e2e8f0;
  transition: background 0.15s;
}
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-count { font-size: 12px; opacity: 0.8; }

.user-box {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.15);
}
.user-role-badge {
  background: #1d4ed8;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
}
.role-switcher {
  width: 100%;
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.25);
  background: #002344;
  color: #fff;
  font-size: 12px;
}

/* Main Content */
.main { flex: 1; display: flex; flex-direction: column; overflow-x: hidden; }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tabs { display: flex; gap: 8px; }
.tab-btn {
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; }

.status-group { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); }
.sse-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  background: #ecfdf5;
  color: var(--green);
  font-weight: 600;
}
.sse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-danger { background: #fef2f2; color: var(--red); border-color: #fecaca; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.content { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }

/* Grid & Cards */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.card-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.card-value { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }

/* Progress Bar */
.progress-track { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin: 12px 0 6px; }
.progress-fill { height: 100%; background: var(--green); transition: width 0.3s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* Hourly Chart */
.chart-container {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 180px;
  padding-top: 20px;
  border-bottom: 1px solid var(--border);
}
.hour-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bars-wrap { display: flex; align-items: flex-end; gap: 2px; width: 100%; justify-content: center; height: 150px; }
.bar { width: 6px; border-radius: 3px 3px 0 0; min-height: 2px; transition: height 0.3s; }
.bar.ans { background: #10b981; }
.bar.mis { background: #8b5cf6; }
.bar.out { background: #1e3a8a; }
.hour-lbl { font-size: 10px; color: var(--text-muted); margin-top: 6px; }
.legend { display: flex; gap: 16px; justify-content: center; margin-top: 12px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 2px; }

/* Filters & Table */
.filters-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
select, input[type="text"] {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-weight: 600; }
td { padding: 11px 12px; border-bottom: 1px solid #f1f5f9; }
tr:hover td { background: #f8fafc; }
.badge { padding: 3px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; display: inline-block; }
.badge-in { background: #dbeafe; color: #1e40af; }
.badge-out { background: #fef3c7; color: #92400e; }

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45);
  display: none; justify-content: flex-end; z-index: 50;
}
.drawer-backdrop.open { display: flex; }
.drawer {
  width: 480px; max-width: 100%; background: #fff; height: 100%;
  padding: 24px; overflow-y: auto; box-shadow: -8px 0 24px rgba(0,0,0,0.15);
}
.step-item {
  border-left: 2px solid #cbd5e1;
  padding: 6px 0 12px 14px;
  margin-left: 6px;
  font-size: 13px;
}
.alert-box { padding: 10px 14px; border-radius: 8px; font-size: 13px; display: none; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
