/* DIMS - Driving Institute Management System
   Palette taken from the road: asphalt, guide-sign green, lane-marking yellow. */

@font-face { font-family: "Barlow"; src: url("../vendor/fonts/barlow-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../vendor/fonts/barlow-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../vendor/fonts/barlow-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Semi Condensed"; src: url("../vendor/fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Semi Condensed"; src: url("../vendor/fonts/barlow-semi-condensed-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Noto Sans Ethiopic"; src: url("../vendor/fonts/noto-sans-ethiopic-ethiopic-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+1200-139F, U+2D80-2DDF, U+AB00-AB2F; }
@font-face { font-family: "Noto Sans Ethiopic"; src: url("../vendor/fonts/noto-sans-ethiopic-ethiopic-600-normal.woff2") format("woff2"); font-weight: 600 700; font-display: swap; unicode-range: U+1200-139F, U+2D80-2DDF, U+AB00-AB2F; }

:root {
  --asphalt: #22303a;
  --asphalt-2: #2d3d49;
  --asphalt-line: #3a4c59;
  --green: #0e6b4e;
  --green-ink: #0a5440;
  --green-soft: #e3f1ec;
  --lane: #f3b800;
  --paper: #f3f5f6;
  --surface: #ffffff;
  --ink: #1a2229;
  --muted: #5b6873;
  --line: #dde3e7;
  --red: #b3261e;

  --font-text: "Barlow", "Noto Sans Ethiopic", "Segoe UI", system-ui, sans-serif;
  --font-head: "Barlow Semi Condensed", "Noto Sans Ethiopic", "Segoe UI", system-ui, sans-serif;

  --bs-body-font-family: var(--font-text);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--paper);
  --bs-primary: var(--green);
  --bs-primary-rgb: 14, 107, 78;
  --bs-link-color: var(--green-ink);
  --bs-link-hover-color: var(--green);
  --bs-link-color-rgb: 10, 84, 64;
  --bs-border-color: var(--line);
  --bs-danger: var(--red);
  --bs-danger-rgb: 179, 38, 30;
}

/* Ethiopic glyphs need more room than Latin at the same size */
body { font-size: 0.95rem; line-height: 1.5; }
body.lang-am { --font-text: "Noto Sans Ethiopic", "Barlow", system-ui, sans-serif; --font-head: "Noto Sans Ethiopic", "Barlow Semi Condensed", system-ui, sans-serif; line-height: 1.65; }
h1, h2, h3, h4, h5, .h5, .h6 { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.005em; }

/* ---------- buttons ---------- */
.btn-primary { --bs-btn-bg: var(--green); --bs-btn-border-color: var(--green); --bs-btn-hover-bg: var(--green-ink); --bs-btn-hover-border-color: var(--green-ink); --bs-btn-active-bg: var(--green-ink); --bs-btn-disabled-bg: var(--green); --bs-btn-disabled-border-color: var(--green); }
.btn-outline-primary { --bs-btn-color: var(--green-ink); --bs-btn-border-color: var(--green); --bs-btn-hover-bg: var(--green); --bs-btn-hover-border-color: var(--green); --bs-btn-active-bg: var(--green-ink); }
.btn-icon { width: 2.4rem; height: 2.4rem; display: inline-grid; place-items: center; border-radius: 8px; color: var(--ink); font-size: 1.2rem; padding: 0; }
.btn-icon:hover { background: var(--paper); }
:focus-visible { outline: 3px solid var(--lane); outline-offset: 2px; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--green); box-shadow: 0 0 0 0.2rem rgba(14, 107, 78, 0.2); }
.form-check-input:checked { background-color: var(--green); border-color: var(--green); }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex: 0 0 248px; background: var(--asphalt); color: #d8e0e5; display: flex; flex-direction: column; }
@media (min-width: 992px) { .sidebar, .sidebar.offcanvas-lg { position: sticky; top: 0; height: 100vh; overflow-y: auto; background-color: var(--asphalt) !important; } }
@media (max-width: 991.98px) { .sidebar.offcanvas-lg { --bs-offcanvas-width: 270px; --bs-offcanvas-bg: var(--asphalt); } }

.sidebar-head { display: flex; align-items: center; gap: 0.7rem; padding: 1.1rem 1rem; border-bottom: 1px solid var(--asphalt-line); }
.brand-logo { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.brand-mark { width: 40px; height: 40px; border-radius: 8px; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 1.25rem; flex: none; }
.brand-name { font-family: var(--font-head); font-weight: 700; color: #fff; line-height: 1.2; font-size: 1rem; }

.sidebar-nav { padding: 0.75rem 0.6rem; flex: 1; }
.nav-group { color: #8fa0ab; font-size: 0.8rem; padding: 1rem 0.7rem 0.35rem; }
.nav-item { position: relative; display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.75rem 0.55rem 1rem; border-radius: 8px; color: #d8e0e5; text-decoration: none; }
.nav-item i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: 0.9; }
.nav-item:hover { background: var(--asphalt-2); color: #fff; }
/* The one signature: the active page is marked with a lane line */
.nav-item.active { background: var(--asphalt-2); color: #fff; font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: 3px; top: 6px; bottom: 6px; width: 4px; border-radius: 2px;
  background: repeating-linear-gradient(to bottom, var(--lane) 0 7px, transparent 7px 12px); }
.badge-count { margin-left: auto; background: var(--lane); color: var(--asphalt); font-weight: 700; font-size: 0.75rem; border-radius: 10px; padding: 0 0.45rem; min-width: 1.4rem; text-align: center; }
.sidebar-foot { color: #7f909b; font-size: 0.75rem; padding: 0.75rem 1rem; border-top: 1px solid var(--asphalt-line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020; }
.page-title { font-size: 1.35rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 0.35rem; }
.btn-lang { font-weight: 600; border: 1px solid var(--line); border-radius: 8px; padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.btn-user { display: flex; align-items: center; gap: 0.45rem; border: 0; }
.btn-user i { font-size: 1.35rem; }
.bell-dot { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }

.content { padding: 1.5rem; max-width: 1280px; width: 100%; }
@media (max-width: 575.98px) { .content { padding: 1rem 0.75rem; } .topbar { padding: 0.6rem 0.75rem; } .page-title { font-size: 1.15rem; } }

/* ---------- panels & tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.panel-head { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1.1rem; margin: 0; }
.panel-body { padding: 1.1rem; }
.panel + .panel { margin-top: 1.25rem; }

.table { --bs-table-bg: transparent; margin: 0; }
.table > thead th { color: var(--muted); font-weight: 600; font-size: 0.85rem; border-bottom-width: 1px; white-space: nowrap; background: #fafbfc; }
.table td, .table th { padding: 0.65rem 0.9rem; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f6f9f8; }
.row-muted td { color: var(--muted); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty i { font-size: 2rem; display: block; margin-bottom: 0.5rem; color: #a9b5bd; }

/* mobile: stack table rows as cards */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack tr { display: block; border-bottom: 1px solid var(--line); padding: 0.6rem 0.4rem; }
  .table-stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: 0.25rem 0.6rem; text-align: right; }
  .table-stack td::before { content: attr(data-label); color: var(--muted); font-size: 0.85rem; text-align: left; }
  .table-stack td.actions { justify-content: flex-end; }
  .table-stack td.actions::before { content: none; }
}

.chip { display: inline-block; font-size: 0.8rem; padding: 0.1rem 0.55rem; border-radius: 6px; background: var(--paper); border: 1px solid var(--line); margin: 0.1rem 0.15rem 0.1rem 0; }
.chip-green { background: var(--green-soft); border-color: #b9dccf; color: var(--green-ink); }
.chip-amber { background: #fff4d1; border-color: #f0d688; color: #6b5100; }

/* ---------- forms ---------- */
.form-label { font-weight: 500; font-size: 0.9rem; margin-bottom: 0.3rem; }
.form-section { font-size: 1rem; margin: 1.5rem 0 0.75rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--line); }
.form-section:first-child { margin-top: 0; }
.form-text { color: var(--muted); }
.req::after { content: " *"; color: var(--red); }
.eth-date { display: grid; grid-template-columns: 4.6rem 1fr 5.6rem; gap: 0.4rem; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 0.8rem 1.1rem; display: flex; gap: 0.5rem; justify-content: flex-end; border-radius: 0 0 10px 10px; }

.img-pick { display: flex; align-items: center; gap: 1rem; }
.img-pick img, .img-pick .img-empty { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; }
.img-pick .img-empty { display: grid; place-items: center; color: #a9b5bd; font-size: 1.8rem; }

/* ---------- dashboard ---------- */
.stat { padding: 1rem 1.1rem; }
.stat .num { font-family: var(--font-head); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.7rem 1.1rem; border-bottom: 1px solid var(--line); }
.alert-list li:last-child { border-bottom: 0; }
.alert-list .ic { width: 2rem; height: 2rem; flex: none; border-radius: 8px; display: grid; place-items: center; }
.ic-red { background: #fbe9e7; color: var(--red); }
.ic-amber { background: #fff4d1; color: #8a6900; }

/* ---------- notifications ---------- */
.ntf { display: flex; gap: 0.9rem; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--line); }
.ntf.unread { background: #f7fbf9; }
.ntf.high { box-shadow: inset 4px 0 0 var(--red); }
.ntf .ntf-ic { width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--green-soft); color: var(--green-ink); }
.ntf.high .ntf-ic { background: #fbe9e7; color: var(--red); }
.ntf-title { font-weight: 600; }
.ntf-meta { color: var(--muted); font-size: 0.85rem; }
.ntf-changes { font-size: 0.88rem; margin-top: 0.35rem; }
.ntf-changes .old { color: var(--red); text-decoration: line-through; }
.ntf-changes .new { color: var(--green-ink); font-weight: 600; }

/* ---------- login ---------- */
.content-bare { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--asphalt); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 12px; overflow: hidden; }
.login-top { background: var(--green); color: #fff; padding: 1.5rem; display: flex; gap: 0.9rem; align-items: center; }
.login-top img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.login-top .brand-mark { width: 56px; height: 56px; font-size: 1.6rem; background: rgba(255, 255, 255, 0.15); }
.login-top h1 { font-size: 1.3rem; margin: 0; }
.login-road { height: 6px; background: repeating-linear-gradient(to right, var(--lane) 0 22px, var(--asphalt) 22px 36px); }
.login-body { padding: 1.5rem; }
.install-card { max-width: 720px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .sidebar, .topbar, .btn, .sticky-actions { display: none !important; } .content { padding: 0; } }

/* ---------- context bars ---------- */
.acting-bar, .license-bar { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 1.5rem; font-size: 0.92rem; }
.acting-bar { background: var(--asphalt); color: #fff; }
.acting-bar i { color: var(--lane); }
.license-bar { background: #fff4d1; color: #5c4600; border-bottom: 1px solid #f0d688; }
.license-bar.license-grace { background: #fbe9e7; color: var(--red); border-bottom-color: #f1c2bd; }
@media (max-width: 575.98px) { .acting-bar, .license-bar { padding: 0.5rem 0.75rem; } }

/* ---------- login extras ---------- */
.student-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem 1rem; border: 2px solid var(--green); border-radius: 10px; color: var(--green-ink); text-decoration: none; font-weight: 700; font-size: 1.05rem; margin-top: 1.25rem; }
.student-link i { font-size: 1.6rem; }
.student-link:hover { background: var(--green-soft); color: var(--green-ink); }
.student-link small { display: block; font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.diff-old { color: var(--red); text-decoration: line-through; }
.diff-new { color: var(--green-ink); font-weight: 600; }

/* fields sit on white so they read as editable against the grey page */
.form-control, .form-select, .input-group-text { background-color: #fff; }
.form-control:disabled, .form-select:disabled { background-color: #eef1f3; }
.input-group-text { color: var(--muted); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--green); }
.pagination { --bs-pagination-active-bg: var(--green); --bs-pagination-active-border-color: var(--green); --bs-pagination-color: var(--green-ink); }

.form-control:focus, .form-select:focus { background-color: #fff; }

.stat-money { border-color: #b9dccf; background: var(--green-soft); }
.stat-money .num { color: var(--green-ink); }

.progress { --bs-progress-bar-bg: var(--green); }

/* ---------- student start screen & exam ---------- */
.exam-start { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 0; width: 100%; max-width: 1040px; background: var(--surface); border-radius: 14px; overflow: hidden; }
.exam-who { padding: 2.5rem 2rem; text-align: center; }
.exam-photo { width: 150px; height: 180px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); margin: 0 auto; background: var(--paper); }
.exam-facts { display: flex; justify-content: center; gap: 2rem; margin: 1.6rem 0; }
.exam-facts .num { font-family: var(--font-head); font-size: 2rem; font-weight: 700; line-height: 1; }
.exam-facts .lbl { color: var(--muted); font-size: 0.85rem; }
.btn-exam-start { background: #1f6fd1; color: #fff; font-size: 1.4rem; font-weight: 700; padding: 0.75rem 3.5rem; border-radius: 10px; border: 0; }
.btn-exam-start:hover, .btn-exam-start:focus { background: #175bb0; color: #fff; }
.exam-help { background: var(--paper); padding: 2rem; border-left: 1px solid var(--line); }
.exam-help ol { padding-left: 1.2rem; }
.exam-help li { margin-bottom: 0.4rem; }
.exam-keys { display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: 0.9rem; }
kbd { background: var(--asphalt); color: #fff; border-radius: 4px; padding: 0.1rem 0.4rem; font-size: 0.8rem; }
@media (max-width: 767.98px) { .exam-start { grid-template-columns: 1fr; } .exam-help { border-left: 0; border-top: 1px solid var(--line); } }

.exam-body { background: var(--paper); min-height: 100vh; }
#exam { display: flex; flex-direction: column; min-height: 100vh; }
.exam-bar { display: flex; align-items: center; gap: 0.9rem; padding: 0.6rem 1.2rem; background: var(--asphalt); color: #fff; position: sticky; top: 0; z-index: 5; }
.exam-mini { width: 40px; height: 48px; object-fit: cover; border-radius: 6px; }
.exam-progress { font-weight: 600; opacity: 0.9; }
.exam-timer { font-family: var(--font-head); font-size: 1.6rem; font-weight: 700; min-width: 5.5rem; text-align: right; color: var(--lane); }
.exam-timer.low { color: #ff8a80; }
.exam-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 1.2rem; padding: 1.2rem; max-width: 1200px; width: 100%; margin: 0 auto; }
.exam-q { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.6rem; }
.exam-qno { color: var(--muted); font-weight: 600; margin-bottom: 0.5rem; }
.exam-qtext { font-size: 1.35rem; font-weight: 600; line-height: 1.55; margin-bottom: 1rem; white-space: pre-line; }
.exam-qimg { max-width: 100%; max-height: 300px; border-radius: 8px; margin-bottom: 1rem; display: block; }
.exam-opts { display: grid; gap: 0.6rem; }
.exam-opt { display: flex; align-items: center; gap: 0.9rem; text-align: left; padding: 0.8rem 1rem; border: 2px solid var(--line); border-radius: 10px; background: #fff; font-size: 1.1rem; width: 100%; }
.exam-opt:hover { border-color: var(--green); background: #f6fbf9; }
.exam-opt.chosen { border-color: var(--green); background: var(--green-soft); font-weight: 600; }
.exam-letter { width: 2.2rem; height: 2.2rem; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--paper); font-weight: 700; }
.exam-opt.chosen .exam-letter { background: var(--green); color: #fff; }
.exam-otext { flex: 1; }
.exam-key { opacity: 0.6; }
.exam-side { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; align-self: start; position: sticky; top: 80px; }
.exam-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.35rem; }
.exam-cell { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 0.3rem 0; font-size: 0.85rem; }
.exam-cell.done { background: var(--green); color: #fff; border-color: var(--green); }
.exam-cell.skip { background: #fff4d1; border-color: #f0d688; }
.exam-cell.current { outline: 3px solid var(--lane); outline-offset: 1px; }
.legend { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 3px; vertical-align: -1px; margin-left: 0.4rem; }
.legend.done { background: var(--green); } .legend.skip { background: #fff4d1; border: 1px solid #f0d688; }
.exam-foot { display: flex; justify-content: center; gap: 0.75rem; padding: 0.9rem; background: var(--surface); border-top: 1px solid var(--line); position: sticky; bottom: 0; }
.exam-result { margin: 3rem auto; max-width: 520px; width: calc(100% - 2rem); text-align: center; padding: 2.5rem 1.5rem; border-radius: 16px; color: #fff; }
.exam-result.pass { background: #198754; }
.exam-result.fail { background: var(--red); }
.exam-verdict { font-family: var(--font-head); font-size: 3.6rem; font-weight: 800; letter-spacing: 0.06em; }
.exam-score { font-size: 1.6rem; font-weight: 700; margin-bottom: 0.4rem; }
.note-body { white-space: normal; line-height: 1.8; font-size: 1.05rem; }
@media (max-width: 767.98px) { .exam-main { grid-template-columns: 1fr; padding: 0.75rem; } .exam-side { position: static; } .exam-qtext { font-size: 1.15rem; } .exam-foot .btn { flex: 1; } }

.brand-link { display: flex; align-items: center; gap: 0.7rem; min-width: 0; color: inherit; text-decoration: none; border-radius: 8px; }
.brand-link:hover .brand-name { text-decoration: underline; text-decoration-color: var(--lane); text-underline-offset: 3px; }

/* ---------- reports ---------- */
.trend { display: flex; align-items: flex-end; gap: 0.5rem; height: 220px; overflow-x: auto; }
.trend-col { flex: 1 0 44px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.trend-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; border-bottom: 1px solid var(--line); }
.trend-bars span { width: 40%; min-height: 1px; border-radius: 3px 3px 0 0; }
.tb-in { background: var(--green); } .tb-ex { background: var(--red); opacity: 0.85; }
.trend-n { font-size: 0.75rem; font-weight: 600; margin-top: 2px; }
.trend-lbl { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }

/* ---------- exam sheet (trainee card left, question right) ---------- */
.ex-wrap { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1rem; padding: 1rem; max-width: 1400px; margin: 0 auto; min-height: 100vh; align-items: start; }
.ex-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1rem; text-align: center; position: sticky; top: 1rem; }
.ex-photo { width: 100%; max-width: 230px; aspect-ratio: 4 / 4.2; object-fit: cover; border-radius: 6px; display: block; margin: 0 auto 0.6rem; background: var(--paper); }
.ex-photo-empty { display: grid; place-items: center; font-size: 4rem; color: #a9b5bd; }
.ex-name-am { font-size: 1.15rem; font-weight: 600; line-height: 1.4; }
.ex-id { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; letter-spacing: 0.04em; margin-top: 0.2rem; }
.ex-name-en { font-weight: 700; font-size: 1.1rem; }
.ex-cat { margin-top: 0.2rem; }
.ex-count { margin-top: 0.3rem; }
.ex-answered { color: var(--red); min-height: 1.2em; }
.ex-timer { margin: 0.8rem 0 0.9rem; }
.ex-timer-tab { display: inline-block; background: #1f6fd1; color: #fff; font-weight: 700; padding: 0.3rem 1.1rem; border-radius: 6px 6px 0 0; }
.ex-timer-box { background: #1f6fd1; color: #fff; font-family: var(--font-head); font-size: 1.9rem; font-weight: 700; padding: 0.35rem 0; border-radius: 6px; letter-spacing: 0.05em; }
.ex-timer-box.low { background: var(--red); }
.ex-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.ex-grid .exam-cell { padding: 0.15rem 0; font-size: 0.72rem; }
.ex-main { min-width: 0; }
.ex-qcard { background: #fff; border: 1px solid #e3c9c9; border-radius: 10px; overflow: hidden; }
.ex-qhead { display: flex; gap: 1rem; padding: 1rem 1.2rem; min-height: 190px; border-bottom: 1px solid var(--line); background: #fbfcfc; }
.ex-qtext { flex: 1; font-size: 1.3rem; font-weight: 600; line-height: 1.6; white-space: pre-line; }
.ex-qimg { flex: 0 0 34%; max-width: 380px; border: 1px solid var(--line); border-radius: 6px; display: grid; place-items: center; background: #fff; padding: 0.4rem; }
.ex-qimg img { max-width: 100%; max-height: 260px; object-fit: contain; }
.ex-opts { display: grid; grid-template-columns: repeat(3, 1fr); }
.ex-opt { text-align: left; background: #fff; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 1rem 1.1rem; min-height: 170px; display: flex; flex-direction: column; gap: 0.4rem; }
.ex-opt:hover { background: #f6fbf9; }
.ex-opt-head { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 1.05rem; }
.ex-dot { width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid #b8c3ca; flex: none; }
.ex-opt-text { font-size: 1.15rem; color: var(--ink); }
.ex-opt.chosen { background: var(--green-soft); box-shadow: inset 0 0 0 3px var(--green); }
.ex-opt.chosen .ex-dot { border-color: var(--green); background: radial-gradient(circle, var(--green) 45%, transparent 50%); }
.ex-opt.chosen .ex-opt-head { color: var(--green-ink); font-weight: 700; }
.ex-nav { display: flex; justify-content: center; align-items: center; gap: 0.6rem; padding: 0.9rem; }
.ex-next { background: #1f6fd1; color: #fff; font-weight: 700; min-width: 220px; font-size: 1.15rem; }
.ex-next:hover, .ex-next:focus { background: #175bb0; color: #fff; }
.ex-msg { text-align: center; min-height: 1.6rem; padding-bottom: 0.6rem; font-weight: 600; }
.ex-msg.warn { color: var(--red); }
.ex-main .exam-result { margin: 2rem auto; }
.btn-outline-light { --bs-btn-color: #fff; --bs-btn-border-color: #fff; }
@media (max-width: 991.98px) {
  .ex-wrap { grid-template-columns: 1fr; padding: 0.6rem; }
  .ex-card { position: static; display: grid; grid-template-columns: 90px 1fr; gap: 0 0.8rem; text-align: left; }
  .ex-photo { grid-row: span 5; width: 90px; margin: 0; }
  .ex-timer, .ex-grid, .ex-card > .small, .ex-card > .btn { grid-column: 1 / -1; }
  .ex-opts { grid-template-columns: 1fr 1fr; }
  .ex-qhead { flex-direction: column; min-height: 0; }
  .ex-qimg { max-width: none; }
  .ex-opt { min-height: 110px; }
}
@media (max-width: 575.98px) { .ex-opts { grid-template-columns: 1fr; } .ex-opt { min-height: 0; } .ex-next { min-width: 0; flex: 1; } }
#exam.ex-wrap { display: grid; flex-direction: initial; }

/* =================== dark theme =================== */
[data-bs-theme="dark"] {
  --asphalt: #0f161b; --asphalt-2: #1b262e; --asphalt-line: #26343e;
  --paper: #121a20; --surface: #1a242c; --ink: #e4ebf0; --muted: #98a8b3; --line: #2b3944;
  --green: #17936b; --green-ink: #6fd3a8; --green-soft: #133328; --red: #ef6b62;
  --bs-body-color: var(--ink); --bs-body-bg: var(--paper); --bs-border-color: var(--line);
  --bs-link-color: var(--green-ink); --bs-link-color-rgb: 111, 211, 168; --bs-link-hover-color: #9be6c4;
  --bs-secondary-color: var(--muted); --bs-tertiary-bg: #202c35; color-scheme: dark;
}
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select, [data-bs-theme="dark"] .input-group-text,
[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus { background-color: #141d24; color: var(--ink); border-color: var(--line); }
[data-bs-theme="dark"] .form-control:disabled, [data-bs-theme="dark"] .form-select:disabled { background-color: #1e2a33; }
[data-bs-theme="dark"] .table > thead th { background: #1f2a33; }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { --bs-table-bg-state: #1f2c35; }
[data-bs-theme="dark"] .img-pick img, [data-bs-theme="dark"] .img-pick .img-empty { background: #141d24; }
[data-bs-theme="dark"] .chip { background: #202c35; }
[data-bs-theme="dark"] .chip-green { background: var(--green-soft); border-color: #24573f; color: var(--green-ink); }
[data-bs-theme="dark"] .chip-amber, [data-bs-theme="dark"] .ic-amber { background: #3a3014; border-color: #5c4a14; color: #f3cf62; }
[data-bs-theme="dark"] .ic-red { background: #3b1d1b; color: var(--red); }
[data-bs-theme="dark"] .ntf.unread { background: #17251f; }
[data-bs-theme="dark"] .bell-dot { border-color: var(--surface); }
[data-bs-theme="dark"] .btn-light { --bs-btn-bg: #24313b; --bs-btn-border-color: #2b3944; --bs-btn-color: var(--ink); --bs-btn-hover-bg: #2c3b46; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #33434f; }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: var(--green-ink); --bs-btn-border-color: #2f7a5c; }
[data-bs-theme="dark"] .btn-icon { color: var(--ink); }
[data-bs-theme="dark"] .btn-icon:hover { background: #24313b; }
[data-bs-theme="dark"] .license-bar { background: #3a3014; color: #f3cf62; border-color: #5c4a14; }
[data-bs-theme="dark"] .stat-money { border-color: #24573f; }
[data-bs-theme="dark"] .login-card { background: var(--surface); }
[data-bs-theme="dark"] .exam-help { background: #141d24; }
[data-bs-theme="dark"] .ex-card, [data-bs-theme="dark"] .ex-qcard, [data-bs-theme="dark"] .ex-opt, [data-bs-theme="dark"] .exam-cell,
[data-bs-theme="dark"] .ex-qimg { background: var(--surface); }
[data-bs-theme="dark"] .ex-qhead { background: #151f26; }
[data-bs-theme="dark"] .ex-qcard { border-color: var(--line); }
[data-bs-theme="dark"] .ex-opt:hover { background: #1f2d36; }
[data-bs-theme="dark"] .exam-cell.skip { background: #3a3014; border-color: #5c4a14; color: #f3cf62; }
[data-bs-theme="dark"] .list-group-item { background: var(--surface); }
[data-bs-theme="dark"] .modal-content { background: var(--surface); }
[data-bs-theme="dark"] .dropdown-menu { --bs-dropdown-bg: var(--surface); }
[data-bs-theme="dark"] .accordion { --bs-accordion-bg: var(--surface); }
.theme-float { position: fixed; top: 0.8rem; right: 0.8rem; color: #fff; z-index: 10; }
.theme-float:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* ---------- exam fits the screen: no page scrolling on desktop or phone ---------- */
.exam-body { height: 100vh; height: 100dvh; overflow: hidden; }
#exam.ex-wrap { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; align-items: stretch; grid-template-rows: minmax(0, 1fr); }
.ex-card { position: static; display: flex; flex-direction: column; align-items: center; min-height: 0; overflow: hidden; }
.ex-photo { max-height: 28vh; width: auto; max-width: 100%; flex: 0 1 auto; }
.ex-card > * { flex: none; }
.ex-grid { width: 100%; overflow: auto; flex: 0 1 auto; min-height: 0; }
.ex-grid-toggle { display: none; }
.ex-main { min-height: 0; display: flex; }
.ex-qcard { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ex-qhead { flex: 0 1 auto; min-height: 0; max-height: 40%; overflow: hidden; }
.ex-qtext { font-size: clamp(1rem, 2.4vh, 1.35rem); overflow: hidden; }
.ex-qimg img { max-height: 30vh; }
.ex-opts { flex: 1 1 auto; min-height: 0; grid-auto-rows: minmax(0, 1fr); }
.ex-opt { min-height: 0; overflow: hidden; padding: clamp(0.4rem, 1.4vh, 1rem) 1rem; }
.ex-opt-text { font-size: clamp(0.95rem, 2.1vh, 1.15rem); overflow: hidden; }
.ex-nav { flex: none; padding: clamp(0.4rem, 1.2vh, 0.9rem); }
.ex-msg { flex: none; min-height: 0; padding: 0 0.5rem 0.4rem; }
.ex-main .exam-result { margin: auto; }
@media (max-height: 700px) and (min-width: 992px) { .ex-photo { max-height: 20vh; } .ex-timer { margin: 0.4rem 0; } .ex-timer-box { font-size: 1.4rem; } }
@media (max-width: 991.98px) {
  #exam.ex-wrap { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 0.5rem; padding: 0.5rem; }
  .ex-card { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 0 0.6rem; padding: 0.5rem 0.6rem; text-align: left; align-items: center; position: relative; overflow: visible; }
  .ex-photo { grid-row: 1 / 3; width: 52px; height: 60px; max-height: none; margin: 0; }
  .ex-name-am { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ex-id { font-size: 0.85rem; margin: 0; }
  .ex-name-en, .ex-cat, .ex-count, .ex-answered, .ex-card > .small { display: none; }
  .ex-timer { grid-column: 3; grid-row: 1; margin: 0; }
  .ex-timer-tab { display: none; }
  .ex-timer-box { font-size: 1.15rem; padding: 0.2rem 0.6rem; }
  .ex-grid-toggle { display: inline-block; grid-column: 3; grid-row: 2; margin-top: 0.25rem; }
  .ex-card > .btn-danger { display: none; }
  .ex-grid { display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 0 0 10px 10px; padding: 0.6rem; grid-template-columns: repeat(8, 1fr); box-shadow: 0 8px 20px rgba(0,0,0,.15); }
  #exam.grid-open .ex-grid { display: grid; }
  .ex-qhead { padding: 0.6rem 0.8rem; flex-direction: column; gap: 0.4rem; max-height: 42%; }
  .ex-qimg { flex: 0 1 auto; min-height: 0; max-width: none; padding: 0.2rem; }
  .ex-qimg img { max-height: 18vh; }
  .ex-opts { grid-template-columns: 1fr 1fr; }
  .ex-opt { padding: 0.5rem 0.6rem; gap: 0.2rem; }
  .ex-opt-head { font-size: 0.85rem; }
  .ex-nav { gap: 0.4rem; padding: 0.45rem; }
  .ex-nav .btn { padding: 0.45rem 0.6rem; }
  .ex-next { min-width: 0; flex: 1; }
}
@media (max-width: 991.98px) { .ex-nav [data-submit-m] { display: inline-block; } }
.install-banner { display: flex; align-items: center; gap: 0.6rem; margin-top: 1rem; padding: 0.6rem 0.8rem; border-radius: 10px; background: var(--green-soft); color: var(--green-ink); font-size: 0.9rem; }
.install-banner[hidden] { display: none; }

/* text boxes get their own height so fitText() can measure them */
.ex-qtext { min-height: 0; }
.ex-opt-text { flex: 1 1 auto; min-height: 0; }
@media (min-width: 992px) { .ex-qhead { max-height: 42%; } .ex-qtext { max-height: 100%; } }
@media (max-width: 991.98px) {
  .ex-photo { grid-column: 1; grid-row: 1 / 3; }
  .ex-name-am { grid-column: 2; grid-row: 1; }
  .ex-id { grid-column: 2; grid-row: 2; }
  .ex-qhead { flex: 0 1 auto; max-height: 46%; display: flex; flex-direction: column; }
  .ex-qtext { flex: 1 1 auto; }
  .ex-qimg { flex: 0 1 auto; max-height: 16vh; }
  .ex-qimg img { max-height: 15vh; }
}
.ex-qimg { overflow: hidden; min-height: 0; }
.ex-qimg img { max-height: 100%; height: auto; }
@media (max-width: 991.98px) { .ex-qimg { height: 15vh; } }
@media (min-width: 992px) { .ex-qimg { max-height: 100%; } .ex-qimg img { max-height: 30vh; } }
@media (max-width: 991.98px) {
  .ex-qimg img { height: 100%; width: auto; max-width: 100%; object-fit: contain; }
  .ex-photo { height: 52px; width: 46px; border-radius: 6px; }
}
@media (min-width: 992px) { .ex-card > .ex-timer, .ex-card > .ex-grid, .ex-card > .btn { align-self: stretch; } }
.btn-back { margin-right: -0.25rem; }
.dev-credit { opacity: 0.85; font-size: 0.72rem; }
.dev-credit-bare { position: fixed; bottom: 0.4rem; left: 0; right: 0; text-align: center; font-size: 0.75rem; color: rgba(255,255,255,0.65); pointer-events: none; }
.exam-body .dev-credit-bare { display: none; }

/* ---------- developer credit: visible on every page ---------- */
.app-foot { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; justify-content: center; align-items: center; padding: 0.7rem 1rem; margin-top: auto; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.82rem; }
.app-foot b { color: var(--ink); }
.dev-top { align-items: center; gap: 0.45rem; text-decoration: none; color: var(--muted); font-size: 0.72rem; line-height: 1.2; padding: 0.2rem 0.5rem; border-radius: 8px; border: 1px solid var(--line); margin-right: 0.3rem; }
.dev-top img { height: 28px; width: auto; max-width: 70px; object-fit: contain; }
.dev-top b { color: var(--ink); }
.dev-credit-bare { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 0.5rem; padding: 0.35rem; font-size: 0.78rem; color: rgba(255,255,255,0.85); background: rgba(0,0,0,0.25); z-index: 5; }
.dev-credit-bare img { height: 20px; }
.print-only { display: none; }
.ex-dev { font-size: 0.68rem; color: var(--muted); text-align: center; margin-top: 0.4rem; }
@media print {
  .app-foot { display: none; }
  .print-only { display: block; }
  .content { padding-bottom: 0; }
}
.dk-key { font-family: ui-monospace, Consolas, monospace; font-size: clamp(1.3rem, 4vw, 2.1rem); font-weight: 700; letter-spacing: 0.06em; color: var(--green-ink); }

/* developer card inside the sign-in card */
.dev-card { display: flex; gap: 0.7rem; align-items: center; margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); }
.dev-card img { height: 34px; width: auto; max-width: 80px; object-fit: contain; flex: none; }
.dev-card-name b { color: var(--ink); }
.dev-card-links { display: flex; flex-wrap: wrap; gap: 0.15rem 0.8rem; margin-top: 0.15rem; }
.dev-card-links a { color: var(--green-ink); text-decoration: none; white-space: nowrap; }
.dev-card-links a:hover { text-decoration: underline; }
.dev-card-ver { font-size: 0.72rem; margin-top: 0.15rem; }
