/* ==========================================================================
   ระบบตรวจข้อสอบ OMR — Stylesheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@500;600;700&family=Sarabun:wght@400;500;600;700&display=swap');

:root {
  --ink: #1c2333;
  --ink-soft: #4b5468;
  --ink-faint: #8891a3;
  --line: #e2e5ec;
  --line-soft: #eef0f5;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-raised: #ffffff;

  --brand: #2b4c8c;
  --brand-dark: #1e3766;
  --brand-light: #eaf0fd;
  --accent: #0f9d8f;
  --accent-light: #e3f7f4;

  --good: #16824f;
  --good-bg: #e6f6ee;
  --bad: #c0293c;
  --bad-bg: #fdecee;
  --warn: #b6791b;
  --warn-bg: #fdf3e2;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(28, 35, 51, 0.06);
  --shadow: 0 6px 20px rgba(28, 35, 51, 0.08);
  --shadow-lg: 0 16px 40px rgba(28, 35, 51, 0.14);

  --font-body: 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif;
  --font-head: 'Kanit', 'Noto Sans Thai', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-head);
  color: var(--ink);
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: 0.01em;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }

p { margin: 0 0 8px; color: var(--ink-soft); }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

small { color: var(--ink-faint); font-size: 0.82rem; }

.hint-text { color: var(--ink-faint); font-size: 0.88rem; }

code {
  background: var(--line-soft);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.85em;
}

/* ---------- layout shell ---------- */

.topbar {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.topbar strong {
  font-family: var(--font-head);
  font-size: 1.08rem;
  display: block;
}

.topbar > div span {
  display: block;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 1px;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.topbar nav a {
  color: rgba(255, 255, 255, 0.88);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.topbar nav a:hover {
  background: rgba(255, 255, 255, 0.16);
  text-decoration: none;
  color: #fff;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* ---------- hero (index) ---------- */

.hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 130%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 22px;
}

.hero h1 {
  color: #fff;
  font-size: 1.9rem;
  max-width: 620px;
  margin-bottom: 10px;
}

.hero p {
  color: rgba(255, 255, 255, 0.9);
  max-width: 560px;
  margin-bottom: 18px;
}

.hero .actions { margin: 0; }

.grid.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.grid.stats .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.grid.stats .card b {
  display: block;
  font-family: var(--font-head);
  font-size: 1.7rem;
  color: var(--brand-dark);
}

.grid.stats .card span {
  color: var(--ink-faint);
  font-size: 0.86rem;
}

/* ---------- panels / cards ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  box-shadow: var(--shadow-sm);
}

.panel.narrow {
  max-width: 420px;
  margin: 40px auto;
}

.panel.scanner { padding-bottom: 34px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head h1 { margin-bottom: 2px; }
.page-head p { margin: 0; color: var(--ink-faint); font-size: 0.92rem; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  text-decoration: none;
  border-color: var(--brand);
  color: var(--brand-dark);
  box-shadow: var(--shadow-sm);
}

.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn.primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.btn.danger {
  background: var(--bad-bg);
  border-color: rgba(192,41,60,0.3);
  color: var(--bad);
}

.btn.danger:hover:not(:disabled) {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn[id="autoScan"].on {
  background: var(--good-bg);
  border-color: var(--good);
  color: var(--good);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--surface) 70%, rgba(255,255,255,0));
  padding: 16px 0 4px;
  margin-top: 10px;
}

/* ---------- forms ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 6px;
}

.form label,
.grid-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 20px;
  margin-top: 6px;
}

.grid-form .wide { grid-column: 1 / -1; }

.grid-form .check {
  flex-direction: row;
  align-items: center;
  font-weight: 600;
}

label.check {
  flex-direction: row !important;
  align-items: center;
  font-weight: 600;
  gap: 6px !important;
  display: inline-flex !important;
}
label.check input[type="checkbox"],
label.check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

input, select, textarea, button {
  font-family: var(--font-body);
}

input[type="text"], input[type="password"], input[type="number"],
input[type="file"], input:not([type]), select, textarea {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.94rem;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

input[readonly] {
  background: var(--line-soft);
  color: var(--ink-faint);
}

.form button.btn { align-self: flex-start; }

/* ---------- alerts ---------- */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert.danger { background: var(--bad-bg); color: var(--bad); border-color: rgba(192,41,60,0.2); }
.alert.success { background: var(--good-bg); color: var(--good); border-color: rgba(22,130,79,0.2); }

/* ---------- tables ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 640px;
}

thead th {
  text-align: left;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  text-transform: uppercase;
  background: var(--line-soft);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--ink);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--brand-light); }

.row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  white-space: nowrap;
}

.row-actions a {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--line-soft);
  color: var(--brand-dark);
}

.row-actions a:hover {
  background: var(--brand);
  color: #fff;
  text-decoration: none;
}

.row-actions-icons { gap: 6px; }
@media (min-width: 900px) {
  .row-actions-icons { flex-wrap: nowrap; }
}
.row-actions-icons a.icon-btn {
  padding: 0;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-dark);
}
.row-actions-icons a.icon-btn:hover {
  background: var(--brand);
  color: #fff;
}

.filter { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.filter select { max-width: 260px; flex: 1 1 180px; }
.filter input[type="text"] { max-width: 320px; flex: 1 1 220px; }

.search-filter {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-filter input[type="text"] {
  max-width: 420px;
  flex: 1 1 260px;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 12px 16px;
  border-bottom: none;
}

.bulk-bar label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.bulk-bar input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
  cursor: pointer;
}

.selected-count {
  font-size: 0.85rem;
  color: var(--ink-faint);
  flex: 1;
}

.bulk-bar + .table-wrap {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.col-check { width: 40px; }
.col-check input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
  cursor: pointer;
}

.row-check:disabled { opacity: 0.25; }

.empty-row {
  text-align: center;
  color: var(--ink-faint);
  padding: 32px 16px !important;
}

/* ---------- answer key grid ---------- */

.key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.key-item b {
  width: 26px;
  text-align: right;
  color: var(--ink-faint);
  font-weight: 600;
  font-size: 0.85rem;
}

.key-item select { padding: 6px 8px; }

/* ---------- scanner ---------- */

/* ---------- scan stage: idle / camera / review ---------- */

#scanStage .camera-wrap,
#scanStage .canvas-wrap,
#scanStage #scanSummary,
#scanStage #saveForm { display: none; }

#scanStage[data-state="idle"] .scan-controls-bar { display: flex; }

#scanStage[data-state="camera"] .scan-controls-bar { display: none; }
#scanStage[data-state="camera"] .camera-wrap { display: block; }

#scanStage[data-state="review"] .scan-controls-bar { display: none; }
#scanStage[data-state="review"] .canvas-wrap { display: block; }
#scanStage[data-state="review"] #scanSummary { display: block; }
#scanStage[data-state="review"] #saveForm { display: block; }

.scan-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.scan-controls-bar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.scan-controls-bar select, .scan-controls-bar input[type="file"] { min-width: 220px; }

.scan-controls-bar label.check-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.scan-controls-bar label.check-inline input { width: 16px; height: 16px; accent-color: var(--brand); }

.idle-note {
  font-size: 0.82rem;
  color: var(--ink-faint);
  max-width: 640px;
  margin: -4px 0 16px;
}

.camera-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 3 / 4;
  margin: 0 auto 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.camera-video.hidden { display: none; }
.camera-video.hidden ~ .live-overlay,
.camera-video.hidden ~ .frame-guide,
.camera-video.hidden ~ .cam-toolbar { display: none; }

.live-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.frame-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frame-guide::before {
  content: "";
  /* สัดส่วนเดียวกับกระดาษ A5 แนวตั้ง (148 x 210 มม.) ให้วางกระดาษในกรอบนี้พอดี */
  aspect-ratio: 148 / 210;
  height: 86%;
  max-width: 78%;
  border: 2.5px dashed rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.32);
}

.cam-toolbar {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  z-index: 5;
}

.cam-toolbar-top {
  top: 0;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}

.cam-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cam-toolbar-bottom {
  bottom: 0;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}

.cam-btn {
  border: none;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 8px 16px;
}

.cam-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.cam-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  padding: 8px 14px;
}
.cam-count b { font-size: 0.9rem; }

.status-pill { font-size: 0.78rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; white-space: nowrap; display: inline-block; }
.status-pass { background: var(--good-bg); color: var(--good); }
.status-fail { background: var(--bad-bg); color: var(--bad); }
.status-pending { background: var(--warn-bg); color: var(--warn); }
.status-new { background: var(--line-soft); color: var(--ink-faint); }

.status-toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}
.status-toggle-switch input { opacity: 0; width: 0; height: 0; }
.status-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bad);
  border-radius: 999px;
  transition: background 0.15s ease;
}
.status-toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.status-toggle-switch input:checked + .status-toggle-slider { background: var(--good); }
.status-toggle-switch input:checked + .status-toggle-slider::before { transform: translateX(20px); }
.status-toggle-switch input:disabled + .status-toggle-slider { opacity: 0.4; cursor: not-allowed; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-dark);
  border: none;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}
.icon-btn:hover { background: var(--brand); color: #fff; text-decoration: none; }
.icon-btn:active { transform: translateY(1px); }
.icon-btn svg { width: 16px; height: 16px; }

.icon-row { display: flex; align-items: center; gap: 6px; }

.icon-btn-disabled {
  background: var(--line-soft);
  color: var(--ink-faint);
  opacity: 0.6;
  cursor: not-allowed;
}
.icon-btn-disabled:hover { background: var(--line-soft); color: var(--ink-faint); }
.cam-btn-round {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
}

.cam-btn-shutter {
  width: 62px;
  height: 62px;
  padding: 0;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}
.cam-btn-shutter:active { background: #e2e5ec; }

.cam-btn-light {
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

.recent-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  z-index: 8;
  background: rgba(15, 18, 26, 0.92);
  display: flex;
  flex-direction: column;
}
.recent-panel.hidden { display: none; }

.recent-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.recent-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
}

.recent-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 6px;
  color: #fff;
}

.recent-item .recent-info {
  font-size: 0.82rem;
  line-height: 1.4;
  color: #fff;
  text-decoration: none;
  display: block;
  flex: 1;
  min-width: 0;
}
.recent-item .recent-info:hover { text-decoration: underline; }
.recent-item .recent-info b { font-size: 0.9rem; }
.recent-item .recent-info small { color: rgba(255, 255, 255, 0.6); }
.recent-item.dup .recent-info small { color: #ffce7a; }

.recent-item .recent-undo {
  background: rgba(192, 41, 60, 0.85);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 auto;
}
.recent-item .recent-undo:disabled { opacity: 0.5; cursor: not-allowed; }

.recent-empty {
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  padding: 24px 10px;
  font-size: 0.85rem;
}

.canvas-wrap {
  position: relative;
  text-align: center;
  margin-bottom: 16px;
}

.canvas-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  z-index: 5;
}

.auto-status {
  text-align: center;
  font-weight: 600;
  font-size: 0.82rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 999px;
  padding: 8px 16px;
  max-width: 88%;
}

.canvas-wrap canvas {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  cursor: crosshair;
  background: #eee;
}

.scan-summary {
  max-width: 560px;
  margin: 0 auto 16px;
}

.scan-summary .summary-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.scan-summary .summary-card h3 { margin-bottom: 10px; }

.scan-summary .summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.scan-summary .summary-grid div {
  background: var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
}

.scan-summary .summary-grid b {
  display: block;
  font-family: var(--font-head);
  font-size: 1.2rem;
  color: var(--brand-dark);
}

.scan-summary .summary-grid span {
  font-size: 0.74rem;
  color: var(--ink-faint);
}

.saveForm.hidden, .hidden { display: none !important; }

/* ---------- misc ---------- */

@media (max-width: 900px) {
  .grid-form { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .container { padding: 18px 14px 48px; }
  .grid-form { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
  .page-head { flex-direction: column; }
}

/* ---------- Admin sidebar / topbar ---------- */
.oe-admin-body { min-height: 100vh; overflow-x: hidden; }
.oe-admin-shell { min-height: 100vh; background: #f4f7fb; }
.oe-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 100; width: 270px; display: flex; flex-direction: column; color: #e8efff; background: linear-gradient(180deg,#17366f 0%,#102750 62%,#0c1d3c 100%); box-shadow: 8px 0 32px rgba(12,29,60,.15); }
.oe-sidebar-brand { min-height: 82px; padding: 17px 20px; display: flex; align-items: center; gap: 12px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); }
.oe-sidebar-brand:hover { color: #fff; text-decoration: none; }
.oe-sidebar-brand strong { display: block; font-family: var(--font-head); letter-spacing: .045em; font-size: 1.08rem; }
.oe-sidebar-brand small { display: block; color: rgba(255,255,255,.66); font-size: .75rem; }
.oe-brand-mark { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(135deg,#32b5ac,#138a91); box-shadow: 0 8px 20px rgba(15,157,143,.28); flex: 0 0 auto; }
.oe-brand-mark svg { width: 24px; height: 24px; }
.oe-sidebar svg,.oe-admin-topbar svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.oe-sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 13px; }
.oe-nav-heading { display: block; padding: 15px 13px 7px; color: rgba(255,255,255,.42); font-size: .69rem; font-weight: 700; letter-spacing: .08em; }
.oe-sidebar-nav a { position: relative; display: flex; align-items: center; gap: 12px; min-height: 46px; margin: 4px 0; padding: 10px 13px; border-radius: 11px; color: rgba(255,255,255,.78); font-weight: 600; transition: .18s ease; }
.oe-sidebar-nav a svg { width: 20px; height: 20px; flex: 0 0 auto; }
.oe-sidebar-nav a:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,.09); transform: translateX(2px); }
.oe-sidebar-nav a.active { color: #fff; background: linear-gradient(135deg,rgba(38,180,168,.95),rgba(18,137,146,.95)); box-shadow: 0 8px 20px rgba(8,117,126,.22); }
.oe-sidebar-nav a.active::before { content: ''; position: absolute; left: -13px; top: 10px; bottom: 10px; width: 4px; background: #7cf4e7; }
.oe-sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.1); }
.oe-user-card { display: flex; align-items: center; min-width: 0; gap: 10px; padding: 7px 5px 12px; }
.oe-user-card > span:last-child,.oe-topbar-user > span:last-child { min-width: 0; }
.oe-user-card strong,.oe-topbar-user strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.oe-user-card small { display: block; color: rgba(255,255,255,.55); }
.oe-avatar { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 12px; background: #e8f8f6; color: #137b78; font-family: var(--font-head); font-weight: 700; flex: 0 0 auto; }
.oe-avatar.small { width: 36px; height: 36px; border-radius: 50%; }
.oe-logout-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px; padding: 10px 12px; border: 1px solid rgba(255,255,255,.13); border-radius: 10px; color: rgba(255,255,255,.82); background: rgba(255,255,255,.06); font: inherit; font-weight: 600; cursor: pointer; }
.oe-logout-button:hover { color: #fff; background: rgba(218,58,79,.22); }
.oe-logout-button svg { width: 19px; height: 19px; }
.oe-admin-main { min-height: 100vh; margin-left: 270px; }
.oe-admin-topbar { position: sticky; top: 0; z-index: 60; min-height: 72px; padding: 12px 26px; display: flex; align-items: center; gap: 14px; background: rgba(255,255,255,.95); border-bottom: 1px solid #e5eaf2; box-shadow: 0 3px 14px rgba(38,55,82,.05); backdrop-filter: blur(10px); }
.oe-menu-toggle { display: none; width: 42px; height: 42px; place-items: center; border: 1px solid #dce3ee; border-radius: 11px; color: #29466f; background: #fff; cursor: pointer; }
.oe-menu-toggle svg { width: 23px; height: 23px; }
.oe-topbar-title strong { display: block; color: #1c3152; font-family: var(--font-head); font-size: 1.04rem; }
.oe-topbar-title span { display: block; color: #8190a8; font-size: .78rem; }
.oe-topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; max-width: 260px; }
.oe-topbar-user small { display: block; color: #8996a9; font-size: .74rem; }
.oe-admin-content { max-width: 1540px; margin: 0 auto; padding: 25px; }
.oe-content-card { min-height: calc(100vh - 123px); padding: 26px 28px; background: #fff; border: 1px solid #e5eaf2; border-radius: 17px; box-shadow: 0 6px 24px rgba(35,54,82,.06); }
.oe-error-list { margin: 0; padding-left: 20px; }
.oe-sidebar-overlay { display: none; }
@media (max-width:900px) {
  .oe-sidebar { transform: translateX(-105%); transition: transform .22s ease; }
  .oe-admin-main { margin-left: 0; }
  .oe-menu-toggle { display: grid; }
  .oe-admin-shell.sidebar-open .oe-sidebar { transform: translateX(0); }
  .oe-sidebar-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(9,20,40,.48); backdrop-filter: blur(2px); }
  .oe-admin-shell.sidebar-open .oe-sidebar-overlay { display: block; }
  body.oe-menu-open { overflow: hidden; }
}
@media (max-width:640px) {
  .oe-sidebar { width: min(290px,86vw); }
  .oe-admin-topbar { min-height: 64px; padding: 10px 13px; }
  .oe-topbar-title span,.oe-topbar-user > span:last-child { display: none; }
  .oe-admin-content { padding: 13px; }
  .oe-content-card { min-height: calc(100vh - 90px); padding: 19px 15px; border-radius: 13px; }
}

/* ---------- Login / authentication ---------- */
.oe-auth-body { min-height: 100vh; background: #eef3fb; }
.staff-login-wrap,.student-login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(390px,520px) minmax(420px,1fr); background: #fff; }
.staff-login-card,.student-login-card { align-self: center; width: 100%; max-width: 470px; margin: 0 auto; padding: 45px 52px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 45px; }
.auth-brand strong { display: block; color: #17366f; font: 700 1.12rem var(--font-head); letter-spacing: .055em; }
.auth-brand small { display: block; color: #8491a5; font-size: .78rem; }
.auth-logo { position: relative; width: 48px; height: 48px; display: grid; place-items: center; overflow: hidden; border-radius: 14px; color: #fff; background: linear-gradient(135deg,#2456a5,#15356b); box-shadow: 0 9px 22px rgba(26,65,128,.2); }
.auth-logo.student { background: linear-gradient(135deg,#13aa9c,#087c82); }
.auth-logo img { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; padding: 4px; object-fit: contain; background: #fff; }
.auth-logo svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.auth-heading { margin-bottom: 24px; }
.auth-heading h1 { margin: 11px 0 5px; color: #182c4c; font-size: 2rem; }
.auth-heading p { color: #718098; line-height: 1.55; }
.auth-role-badge { display: inline-flex; padding: 5px 11px; border-radius: 999px; color: #285ca8; background: #eaf1ff; font-size: .75rem; font-weight: 700; }
.auth-role-badge.student { color: #087b76; background: #e4f8f5; }
.auth-field { display: block; margin: 16px 0; color: #34435a; font-weight: 600; }
.auth-field > span:first-child { display: block; margin-bottom: 7px; font-size: .9rem; }
.auth-input-wrap { position: relative; display: block; }
.auth-input-wrap svg { position: absolute; top: 50%; left: 14px; width: 20px; height: 20px; transform: translateY(-50%); fill: none; stroke: #8593a8; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.auth-input-wrap input { width: 100%; height: 50px; padding: 10px 14px 10px 45px; border: 1px solid #d7deea; border-radius: 12px; outline: 0; color: #1e2d43; background: #fbfcff; font: 500 .96rem var(--font-body); transition: .18s ease; }
.auth-input-wrap input::placeholder { color: #a5afbd; }
.auth-input-wrap input:focus { border-color: #3d6fba; background: #fff; box-shadow: 0 0 0 4px rgba(61,111,186,.11); }
.auth-submit { width: 100%; min-height: 50px; margin-top: 9px; display: flex; align-items: center; justify-content: center; gap: 12px; border: 0; border-radius: 12px; color: #fff; background: linear-gradient(135deg,#295da9,#173b76); box-shadow: 0 10px 24px rgba(29,71,138,.2); font: 700 1rem var(--font-body); cursor: pointer; transition: .18s ease; }
.auth-submit.student { background: linear-gradient(135deg,#13a99c,#087d83); box-shadow: 0 10px 24px rgba(8,125,131,.2); }
.auth-submit:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 13px 28px rgba(29,71,138,.24); }
.auth-switch { margin-top: 23px; text-align: center; color: #8290a5; font-size: .86rem; }
.auth-switch a { font-weight: 700; }
.auth-alert { margin: 0 0 16px; padding: 11px 13px; border-radius: 10px; font-size: .87rem; }
.auth-alert.success { color: #17623e; background: #e6f6ee; border: 1px solid #c8ead8; }
.auth-alert.danger { color: #a3293a; background: #fdecee; border: 1px solid #f6ccd2; }
.payment-qr-box { margin: 12px auto; padding: 10px; max-width: 210px; border-radius: 12px; background: #fff; border: 1px solid #e0e6ef; text-align: center; }
.payment-qr-box img { max-width: 100%; display: block; }
.auth-visual { position: relative; min-height: 100vh; display: grid; place-items: center; overflow: hidden; padding: 60px; color: #fff; background: radial-gradient(circle at 80% 15%,rgba(80,215,205,.28),transparent 29%),linear-gradient(145deg,#17366f,#0c2147 72%); }
.auth-visual.student { background: radial-gradient(circle at 80% 15%,rgba(163,250,234,.3),transparent 29%),linear-gradient(145deg,#087e82,#07535f 72%); }
.auth-visual::before,.auth-visual::after { content: ''; position: absolute; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; }
.auth-visual::before { width: 520px; height: 520px; right: -180px; bottom: -240px; }
.auth-visual::after { width: 300px; height: 300px; left: -130px; top: -120px; }
.auth-visual-content { position: relative; z-index: 1; max-width: 530px; }
.auth-visual-content h2 { margin: 23px 0 15px; color: #fff; font-size: clamp(2rem,4vw,3.4rem); line-height: 1.2; }
.auth-visual-content p { max-width: 490px; color: rgba(255,255,255,.76); font-size: 1.02rem; }
.visual-icon { width: 72px; height: 72px; display: grid; place-items: center; border-radius: 20px; color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.17); backdrop-filter: blur(8px); }
.visual-icon svg { width: 37px; height: 37px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.visual-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 25px; }
.visual-pills span { padding: 7px 13px; border-radius: 999px; color: rgba(255,255,255,.88); background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.12); font-size: .8rem; }
@media (max-width:900px) {
  .staff-login-wrap,.student-login-wrap { grid-template-columns: 1fr; min-height: 100vh; }
  .auth-visual { display: none; }
  .staff-login-card,.student-login-card { padding: 38px 28px; }
}
@media (max-width:480px) {
  .staff-login-card,.student-login-card { align-self: start; padding: 28px 20px 35px; }
  .auth-brand { margin-bottom: 35px; }
  .auth-heading h1 { font-size: 1.72rem; }
}
