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

:root {
  --bg: #0a0a0a;
  --bg2: #111111;
  --bg3: #1a1a1a;
  --border: #222222;
  --border2: #2e2e2e;
  --text: #e5e5e5;
  --muted: #666666;
  --muted2: #888888;
  --primary: #22c55e;
  --primary-dim: rgba(34,197,94,0.12);
  --danger: #ef4444;
  --danger-dim: rgba(239,68,68,0.12);
  --sidebar-w: 220px;
  --font: 'JetBrains Mono', 'Courier New', monospace;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 13px; line-height: 1.5; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Admin Layout ── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid var(--border);
  color: var(--primary); font-weight: 700; font-size: 14px; letter-spacing: 0.05em;
}
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section-label {
  font-size: 10px; letter-spacing: 0.12em; color: var(--muted);
  padding: 4px 8px 8px; text-transform: uppercase;
}
.nav-link {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 6px;
  color: var(--muted2); text-decoration: none; font-size: 12.5px;
  transition: background 0.15s, color 0.15s; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--primary-dim); color: var(--primary); }
.sidebar-bottom { padding: 12px 8px; border-top: 1px solid var(--border); }
.logout-btn { color: var(--muted); }
.logout-btn:hover { color: var(--danger); background: var(--danger-dim); }

.main-area { flex: 1; overflow-y: auto; }
.page-content { padding: 32px; max-width: 1100px; }

/* ── User Layout ── */
.user-layout { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px;
  border-bottom: 1px solid var(--border); background: var(--bg2);
  flex-shrink: 0;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; color: var(--primary); font-weight: 700; font-size: 14px; }
.user-main { flex: 1; overflow-y: auto; padding: 32px 24px; max-width: 1100px; width: 100%; margin: 0 auto; }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-wrap { width: 100%; max-width: 360px; }
.login-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 36px 32px;
}
.login-icon {
  width: 48px; height: 48px; background: var(--primary-dim);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: var(--primary); margin: 0 auto 16px;
}
.login-title { font-size: 22px; font-weight: 700; text-align: center; letter-spacing: 0.05em; }
.login-sub { color: var(--muted); text-align: center; margin-top: 6px; margin-bottom: 24px; font-size: 12px; }

/* ── Page Header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: 0.06em; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px;
}
.stat-label { font-size: 10px; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 10px; text-transform: uppercase; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }

/* ── Table ── */
.table-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table thead tr { border-bottom: 1px solid var(--border); }
.table th {
  padding: 12px 16px; text-align: left;
  font-size: 11px; letter-spacing: 0.08em; color: var(--muted);
  text-transform: uppercase; white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg3); }
.th-right, .td-right { text-align: right; }
.td-empty { text-align: center; color: var(--muted); padding: 40px !important; letter-spacing: 0.08em; }

/* ── Typography helpers ── */
.bold { font-weight: 700; }
.muted { color: var(--muted2); }
.small { font-size: 11px; }
.primary { color: var(--primary); }
.truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge-primary { background: var(--primary-dim); color: var(--primary); border: 1px solid rgba(34,197,94,0.25); }
.badge-secondary { background: var(--bg3); color: var(--muted2); border: 1px solid var(--border); }
.badge-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(239,68,68,0.25); }

/* ── Machine cell ── */
.machine-cell { display: flex; align-items: center; gap: 10px; }
.machine-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 16px; border-radius: 6px;
  font-family: var(--font); font-size: 12px; font-weight: 600; letter-spacing: 0.05em;
  cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #000; border-color: var(--primary); }
.btn-primary:hover { background: #16a34a; border-color: #16a34a; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted2); border-color: transparent; }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: transparent; border-color: var(--border2); color: var(--text); }
.btn-outline:hover { background: var(--bg3); }
.btn-danger-outline { border-color: rgba(239,68,68,0.4); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-dim); }
.btn-full { width: 100%; }
.btn-flex { flex: 1; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-icon {
  width: 30px; height: 30px; padding: 0; border-radius: 5px;
  background: transparent; border: 1px solid transparent;
  color: var(--muted2); cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s; font-family: var(--font);
}
.btn-icon:hover { background: var(--bg3); color: var(--text); border-color: var(--border); }
.btn-danger.btn-icon:hover, .btn-icon.btn-danger:hover { background: var(--danger-dim); color: var(--danger); border-color: rgba(239,68,68,0.3); }

/* ── Forms ── */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 10px; letter-spacing: 0.1em; color: var(--muted2); margin-bottom: 6px; text-transform: uppercase; }
.input {
  width: 100%; padding: 9px 12px; background: var(--bg);
  border: 1px solid var(--border2); border-radius: 6px;
  color: var(--text); font-family: var(--font); font-size: 13px;
  outline: none; transition: border-color 0.15s;
}
.input:focus { border-color: var(--primary); }
.input option { background: var(--bg2); }

/* ── Alerts ── */
.alert-error {
  background: var(--danger-dim); color: var(--danger);
  border-radius: 6px; padding: 10px 12px;
  font-size: 12px; margin-bottom: 16px;
}
.hidden { display: none !important; }

/* ── Modal ── */
.modal {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7); align-items: center; justify-content: center;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 10px; width: 100%; max-width: 440px;
  margin: 16px; animation: modal-in 0.15s ease;
}
@keyframes modal-in { from { opacity:0; transform:scale(0.96); } to { opacity:1; transform:scale(1); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 0;
}
.modal-header h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; }
.modal-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 4px 6px; border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-form { padding: 16px 20px 20px; }
.modal-body { padding: 16px 20px; color: var(--muted2); line-height: 1.7; }
.modal-body p + p { margin-top: 8px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px; padding: 12px 18px;
  font-size: 12px; letter-spacing: 0.04em;
  transform: translateY(16px); opacity: 0;
  transition: all 0.25s; pointer-events: none;
}
.toast-show { transform: translateY(0); opacity: 1; }
.toast-success { border-color: rgba(34,197,94,0.4); color: var(--primary); }
.toast-error { border-color: rgba(239,68,68,0.4); color: var(--danger); }

/* ── Assignment Cards ── */
.user-header { margin-bottom: 28px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.assignment-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px;
  transition: border-color 0.15s;
}
.assignment-card:hover { border-color: rgba(34,197,94,0.35); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 6px; }
.card-machine-name { font-size: 16px; }
.card-desc { margin-top: 4px; margin-bottom: 0; }
.timer-box {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 14px; margin: 16px 0;
}
.timer-box.timer-warn { background: rgba(234,179,8,0.05); border-color: rgba(234,179,8,0.25); }
.timer-label { font-size: 9px; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.timer-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-box.timer-warn .timer-value { color: #eab308; }
.card-actions { display: flex; gap: 8px; }

/* ── Empty State ── */
.empty-state {
  border: 1px dashed var(--border2); border-radius: 10px;
  padding: 60px 24px; text-align: center;
  background: rgba(255,255,255,0.015);
}
.empty-icon { font-size: 36px; color: var(--muted); margin-bottom: 14px; }
.empty-state h3 { font-size: 14px; letter-spacing: 0.08em; margin-bottom: 8px; }
.empty-state p { max-width: 380px; margin: 0 auto; }

/* ── Session Overlay ── */
.session-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg); display: flex; flex-direction: column;
  animation: fade-in 0.15s ease;
}
.session-overlay.hidden { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.session-bar {
  height: 52px; background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; flex-shrink: 0; gap: 12px;
}
.session-info { display: flex; flex-direction: column; }
.session-name { font-weight: 700; font-size: 13px; color: var(--primary); line-height: 1.2; }
.session-timer { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.session-actions { display: flex; gap: 6px; flex-shrink: 0; }
.session-frame-wrap { flex: 1; background: #000; position: relative; }
.session-frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }

/* ── Loading ── */
.loading-spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
