:root {
  --bg: #0e1016;
  --panel: #171a23;
  --panel2: #1e222d;
  --border: #2a2f3c;
  --text: #e6e8ee;
  --muted: #8b90a0;
  --accent: #5b8cff;
  --accent2: #7c5bff;
  --green: #35c28b;
  --red: #ff5d6c;
  --amber: #f3b64b;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 18px; margin-top: 8px; font-size: 13px; }
.dot { color: var(--accent); }
a { color: var(--accent); }

/* buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  transition: .15s;
}
.btn:hover { border-color: #3a4152; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #46303a; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

/* inputs */
label { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); }
input, textarea, select {
  width: 100%;
  margin-top: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  font: inherit;
}
textarea { resize: vertical; min-height: 120px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
input[type=checkbox] { width: auto; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

/* login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 25%, rgba(108, 92, 231, 0.09) 0%, transparent 60%), var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.login-header {
  text-align: center;
  margin-bottom: 24px;
}
.login-icon-box {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: rgba(108, 92, 231, 0.12);
  border: 1px solid rgba(108, 92, 231, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.login-icon {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.login-header h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.login-header p {
  margin: 0;
  font-size: 13px;
}
.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrap input {
  padding-right: 40px;
}
.pw-toggle {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  padding: 6px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.pw-toggle:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
}
.btn-block {
  width: 100%;
  margin-top: 14px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.spin {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* card */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 22px; height: 60px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
.tabs { display: flex; gap: 4px; margin-left: 10px; }
.tab { background: transparent; border: none; color: var(--muted); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel2); color: var(--text); }
.user { margin-left: auto; display: flex; align-items: center; gap: 12px; }

main { padding: 26px; max-width: 1100px; margin: 0 auto; }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* section header */
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sec-head h2 { margin: 0; font-size: 18px; }

/* list / table */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.item .t { font-weight: 600; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--panel2); }
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }

code.key { font-family: ui-monospace, Consolas, monospace; background: var(--bg); padding: 3px 7px; border-radius: 6px; border: 1px solid var(--border); font-size: 12.5px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
  line-height: 1.3;
  vertical-align: middle;
}
.badge.green { color: var(--green); border-color: #2a4d41; background: rgba(53, 194, 139, 0.08); }
.badge.red { color: var(--red); border-color: #4d2a32; background: rgba(255, 93, 108, 0.08); }
.badge.amber { color: var(--amber); border-color: #4d3f2a; background: rgba(243, 182, 75, 0.08); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.spacer { height: 14px; }

/* modal */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { width: 640px; max-width: 100%; max-height: 88vh; overflow: auto; }
.modal h2 { margin-top: 0; }

/* toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--border); padding: 11px 18px; border-radius: 10px; z-index: 100; }
.toast.ok { border-color: #2a4d41; }
.toast.bad { border-color: #4d2a32; }

.empty { text-align: center; color: var(--muted); padding: 40px; }
pre.code { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 14px; overflow: auto; max-height: 340px; font-size: 12px; }

/* ---- buttons: fixed height, never shift on hover ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; line-height: 1; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn.sm { height: 28px; }
.btn:active { transform: none; }
.actions { align-items: center; }
.actions .btn { min-width: 34px; }

/* ---- toggle switch ---- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin: 10px 0; color: var(--text); }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--border); position: relative; transition: background .15s, border-color .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .18s, background .18s; }
.switch input:checked + .track { background: rgba(91,140,255,.25); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--accent); }

/* ---- number stepper ---- */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--bg); width: 100%; margin-top: 5px; }
.stepper .st-btn { width: 38px; border: none; background: var(--panel2); color: var(--text); font-size: 18px; cursor: pointer; transition: background .15s; flex: none; }
.stepper .st-btn:hover { background: #2a3140; }
.stepper .st-in { border: none; text-align: center; margin: 0; border-radius: 0; background: transparent; -moz-appearance: textfield; }
.stepper .st-in::-webkit-outer-spin-button, .stepper .st-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---- custom date picker ---- */
.dp { position: relative; margin-top: 5px; }
.dp-input { width: 100%; text-align: left; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 9px 11px; cursor: pointer; font: inherit; height: 38px; }
.dp-input.empty { color: var(--muted); }
.dp-pop {
  position: absolute;
  z-index: 100;
  top: 44px;
  left: 0;
  width: 290px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.6);
  user-select: none;
}
.dp-presets {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.dp-preset-btn {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: .12s;
}
.dp-preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dp-title { font-weight: 600; font-size: 13.5px; }
.dp-nav { width: 28px; height: 28px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); border-radius: 7px; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.dp-nav:hover { border-color: var(--accent); }
.dp-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 6px; }
.dp-dow span { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; padding: 2px 0; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.dp-cell {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0;
  margin: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: background .12s, color .12s, border-color .12s;
}
.dp-cell:hover:not(.empty) { background: var(--panel2); border-color: var(--border); }
.dp-cell.empty { cursor: default; }
.dp-cell.today { outline: 1px solid var(--accent); color: var(--accent); font-weight: 600; }
.dp-cell.sel { background: var(--accent); color: #fff; font-weight: 700; border-color: var(--accent); }
.dp-foot { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.dp-foot button { background: transparent; border: none; color: var(--accent); cursor: pointer; font-size: 12.5px; padding: 3px 6px; border-radius: 6px; font-weight: 500; }
.dp-foot button:hover { background: var(--panel2); }

/* ---- security ---- */
.sev-critical { color: var(--red); }
.sev-warn { color: var(--amber); }
.sev-info { color: var(--muted); }
.lock-chip { font-size: 11px; color: var(--muted); }
.qr-wrap { background: #fff; padding: 12px; border-radius: 10px; display: inline-block; }
.mono-box { font-family: ui-monospace, Consolas, monospace; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; word-break: break-all; font-size: 12px; }

/* field hints under inputs */
.hint { display: block; margin-top: 5px; color: var(--muted); font-size: 11.5px; line-height: 1.45; font-weight: 400; }
.hint code.key { font-size: 11px; padding: 1px 5px; }
label > input, label > textarea, label > select { margin-top: 6px; }

/* ---- SVG icons ---- */
.icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -2px;
  flex: none;
  transition: stroke .15s, transform .15s;
}
.icon.sm { width: 12px; height: 12px; }
.icon.md { width: 16px; height: 16px; }
.icon.lg { width: 20px; height: 20px; }
.icon-btn { min-width: 28px !important; width: 28px; height: 28px; padding: 0 !important; }
.btn .icon { margin-right: 4px; }
.icon-btn .icon { margin-right: 0; }

/* ---- hourly activity chart ---- */
.chart-card { margin-bottom: 24px; position: relative; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.chart-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.peak-badge { display: inline-flex; align-items: center; gap: 6px; background: rgba(91, 140, 255, 0.1); border: 1px solid rgba(91, 140, 255, 0.3); color: var(--accent); padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.peak-badge.hot { background: rgba(243, 182, 75, 0.12); border-color: var(--amber); color: var(--amber); }
.chart-bars-wrap { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 24px; border-bottom: 1px solid var(--border); }
.chart-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; cursor: pointer; }
.chart-bar-bg { width: 100%; max-width: 24px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 4px 4px 0 0; background: rgba(255,255,255,0.02); }
.chart-bar { width: 100%; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--accent), var(--accent2)); min-height: 2px; transition: transform 0.15s, opacity 0.15s; }
.chart-bar.denied { background: linear-gradient(180deg, var(--red), #8b2331); }
.chart-bar.mixed { background: linear-gradient(180deg, var(--amber), var(--accent)); }
.chart-col:hover .chart-bar { opacity: 0.85; transform: scaleY(1.04); }
.chart-col:hover .chart-tooltip { opacity: 1; visibility: visible; }
.chart-tooltip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 11px; white-space: nowrap; pointer-events: none; opacity: 0; visibility: hidden; z-index: 20; box-shadow: 0 4px 14px rgba(0,0,0,0.5); }
.chart-labels { display: flex; gap: 4px; margin-top: 6px; }
.chart-label { flex: 1; text-align: center; font-size: 10px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }

/* ---- student CRM styles ---- */
.student-avatar { width: 34px; height: 34px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--border); color: var(--accent); font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; flex: none; letter-spacing: 0.05em; font-family: ui-monospace, Consolas, monospace; }
.student-id-pill { font-family: ui-monospace, Consolas, monospace; background: rgba(91, 140, 255, 0.12); border: 1px solid rgba(91, 140, 255, 0.3); color: var(--accent); padding: 2px 7px; border-radius: 6px; font-weight: 600; font-size: 12px; }
.student-cell { display: flex; align-items: center; gap: 10px; }
.student-meta { display: flex; flex-direction: column; }
.student-meta .name { font-weight: 600; color: var(--text); }
.student-meta .sub { font-size: 11.5px; color: var(--muted); }
.timeline-item { padding: 8px 12px; border-left: 2px solid var(--border); margin-left: 10px; margin-bottom: 8px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: -6px; top: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--panel2); border: 2px solid var(--accent); }
.timeline-item.served::before { border-color: var(--green); }
.timeline-item.denied::before { border-color: var(--red); }
