:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #0f172a;
  color: #e2e8f0;
  padding: 24px 18px;
}

.sidebar a {
  display: block;
  color: #cbd5e1;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.sidebar a.active,
.sidebar a:hover {
  background: rgba(37, 99, 235, .2);
  color: white;
}

.main {
  padding: 28px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 22px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: white;
}

.btn:hover { background: var(--primary-dark); }

.btn.secondary {
  background: #e2e8f0;
  color: var(--text);
}

.btn.danger { background: var(--danger); }

input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
  background: white;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 8px;
}

.palette-btn {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: white;
  font-weight: 700;
  cursor: pointer;
}

.palette-btn.answered { background: #dcfce7; border-color: var(--success); }
.palette-btn.flagged { background: #fef3c7; border-color: #f59e0b; }
.palette-btn.active { outline: 3px solid var(--primary); }

.exam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.timer {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
}

#proctor-warning {
  position: fixed;
  inset: auto 16px 16px auto;
  background: var(--danger);
  color: white;
  padding: 14px 18px;
  border-radius: 12px;
  font-weight: 700;
  z-index: 999;
}

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.full-width {
    width: 100%;
    margin-top: 12px;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 600;
}

.alert.error {
    text-align: center;
    background: #fee2e2;
    color: #991b1b;
}

.muted {
    color: var(--muted);
}

.brand {
    margin-top: 0;
    margin-bottom: 24px;
    color: white;
}
.hidden { display: none !important; }

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

th {
    background: #f8fafc;
    font-size: 14px;
}

.badge {
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-draft { background: #e2e8f0; color: #334155; }
.badge-published { background: #dcfce7; color: #166534; }
.badge-closed { background: #fee2e2; color: #991b1b; }

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.inner-card {
    box-shadow: none;
    border: 1px solid #e2e8f0;
}

.checkbox-group {
    display: grid;
    gap: 10px;
    margin: 16px 0;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.builder-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.student-select-list {
    display: grid;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.student-select {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.exam-public-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.exam-preview-card {
    width: 100%;
    max-width: 640px;
}

.exam-meta {
    display: grid;
    gap: 8px;
    margin: 18px 0;
}

.instructions {
    background: #eff6ff;
    border-left: 4px solid var(--primary);
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.exam-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

.exam-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 18px;
}

.complete-card {
    max-width: 560px;
    margin: 60px auto;
}

@media (max-width: 800px) {
    .exam-layout {
        grid-template-columns: 1fr;
    }

    .builder-row {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .main { padding: 16px; }
}