/* ==========================================================================
   GSOS Exam Management Portal - core stylesheet
   ========================================================================== */
:root {
  --primary: #0b3b75;
  --primary-600: #0a3264;
  --primary-50: #e8eff8;
  --accent: #f2a900;
  --success: #15803d;
  --success-50: #e7f6ec;
  --danger: #b91c1c;
  --danger-50: #fdecec;
  --warning: #a15c07;
  --warning-50: #fdf3e1;
  --info: #1d4ed8;
  --info-50: #e8efff;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #1c2533;
  --muted: #566074;
  --border: #d9e0ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --sidebar-w: 264px;
  --focus: 0 0 0 3px rgba(242, 169, 0, .55);
  font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: .9375rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
img { max-width: 100%; height: auto; }
a { color: var(--primary); }
a:hover { color: var(--primary-600); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; color: #0f1b2d; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
code { background: #eef1f6; padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #111; padding: .5rem 1rem; z-index: 1000; border-radius: 6px; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 1rem; }

/* ---------------- App shell ---------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: #0a2a52; color: #d7e2f1;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1rem 1rem .9rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand img { border-radius: 50%; background: #fff; }
.sidebar-brand strong { display: block; color: #fff; font-size: 1.1rem; letter-spacing: .06em; }
.sidebar-brand span { display: block; font-size: .75rem; color: #b9c8dd; }
.sidebar-nav { padding: .5rem 0 2rem; }
.nav-link {
  display: flex; align-items: center; gap: .65rem; width: 100%; padding: .55rem 1rem .55rem 2.6rem; color: #d7e2f1;
  text-decoration: none; font-size: .9rem; border: 0; background: none; cursor: pointer; font-family: inherit; text-align: left;
  border-left: 3px solid transparent;
}
.nav-link.nav-top { padding-left: 1rem; }
.nav-link i { width: 1.1rem; text-align: center; color: #9fb4d1; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(242,169,0,.14); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.nav-group-toggle {
  display: flex; align-items: center; gap: .65rem; width: 100%; padding: .6rem 1rem; background: none; border: 0; color: #eef3fa;
  font: inherit; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; text-align: left;
}
.nav-group-toggle i:first-child { width: 1.1rem; text-align: center; color: #9fb4d1; }
.nav-group-toggle .chev { margin-left: auto; font-size: .7rem; transition: transform .15s; }
.nav-group.open .chev { transform: rotate(180deg); }
.nav-group-items { display: none; padding-bottom: .35rem; }
.nav-group.open .nav-group-items { display: block; }
.nav-logout { margin: .75rem 0 0; border-top: 1px solid rgba(255,255,255,.08); padding-top: .5rem; }
.sidebar-backdrop { display: none; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .75rem; height: 60px; padding: 0 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-weight: 600; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid transparent; background: none; color: var(--text); cursor: pointer; text-decoration: none; font-size: 1.05rem;
}
.icon-btn:hover { background: var(--primary-50); color: var(--primary); }
.sidebar-toggle { display: none; }
.dot-count { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .68rem; line-height: 18px; text-align: center; font-weight: 700; }
.user-chip { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--text); padding: .25rem .5rem; border-radius: 8px; }
.user-chip:hover { background: var(--primary-50); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.user-meta strong { display: block; font-size: .85rem; line-height: 1.2; }
.user-meta small { color: var(--muted); font-size: .75rem; }
.content { padding: 1.25rem; flex: 1; outline: none; max-width: 1400px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.crumbs { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
.crumbs a { color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.app-footer { padding: 1rem 1.25rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border); background: var(--surface); }

/* ---------------- Public pages ---------------- */
.public-body { min-height: 100vh; display: flex; flex-direction: column; background: linear-gradient(180deg, #e9eff7 0, var(--bg) 320px); }
.public-header { background: var(--primary); color: #fff; padding: .75rem 1.25rem; border-bottom: 4px solid var(--accent); }
.public-brand { display: inline-flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.public-brand:hover { color: #fff; }
.public-brand img { border-radius: 50%; background: #fff; }
.public-brand strong { display: block; font-size: 1.15rem; }
.public-brand small { display: block; color: #cfdbec; }
.public-main { flex: 1; padding: 2rem 1rem; outline: none; }
.public-footer { text-align: center; padding: 1rem; font-size: .8rem; color: var(--muted); }
.narrow { max-width: 520px; margin: 0 auto; }
.center-card { text-align: center; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); }
.big-icon { font-size: 2.5rem; color: var(--primary); margin-bottom: .5rem; }
.landing { max-width: 1040px; margin: 0 auto; }
.landing-hero { text-align: center; margin: 0 auto 1.75rem; max-width: 720px; }
.landing-hero h1 { font-size: 1.9rem; color: var(--primary); }
.login-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.login-card h2 { display: flex; align-items: center; gap: .5rem; }
.install-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 1.25rem; max-width: 1080px; margin: 0 auto; }
.install-steps ol { list-style: none; padding: 0; margin: 0; }
.install-steps li { display: flex; gap: .6rem; align-items: center; padding: .45rem 0; color: var(--muted); }
.install-steps li span { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; }
.install-steps li.current { color: var(--primary); font-weight: 600; }
.install-steps li.current span { border-color: var(--primary); background: var(--primary); color: #fff; }
.install-steps li.done span { border-color: var(--success); background: var(--success); color: #fff; }

/* ---------------- Cards & grids ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }
.card-body { padding: 1rem; }
.card-body > :last-child { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; display: flex; gap: .75rem; align-items: center; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
a.stat-card:hover { border-color: var(--primary); }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-50); color: var(--primary); font-size: 1.1rem; flex: 0 0 42px; }
.stat-icon.green { background: var(--success-50); color: var(--success); }
.stat-icon.red { background: var(--danger-50); color: var(--danger); }
.stat-icon.amber { background: var(--warning-50); color: var(--warning); }
.stat-icon.blue { background: var(--info-50); color: var(--info); }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--muted); }
.kv-list { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv-list dt { color: var(--muted); font-size: .85rem; }
.kv-list dd { margin: 0; font-weight: 600; word-break: break-word; }
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2rem; margin-bottom: .5rem; color: #9aa7ba; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .45rem .95rem;
  border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem; text-decoration: none;
  cursor: pointer; white-space: nowrap; background: #e8ecf2; color: var(--text); transition: background .12s, border-color .12s;
}
.btn:hover { background: #dce2ea; color: var(--text); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #116a32; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991717; color: #fff; }
.btn-warning { background: #f2a900; color: #1b1300; }
.btn-warning:hover { background: #d99800; color: #1b1300; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--primary); }
.btn-outline:hover { background: var(--primary-50); border-color: var(--primary); color: var(--primary); }
.btn-link { background: none; color: var(--primary); padding-left: .25rem; padding-right: .25rem; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-sm { min-height: 32px; padding: .25rem .6rem; font-size: .8rem; border-radius: 6px; }
.btn-lg { min-height: 50px; padding: .6rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form { display: inline; margin: 0; }

/* ---------------- Badges & alerts ---------------- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; border: 1px solid transparent; }
.badge-success { background: var(--success-50); color: var(--success); border-color: #b9e3c7; }
.badge-danger { background: var(--danger-50); color: var(--danger); border-color: #f3c0c0; }
.badge-warning { background: var(--warning-50); color: var(--warning); border-color: #f1d39c; }
.badge-info { background: var(--info-50); color: var(--info); border-color: #c1d2fb; }
.badge-neutral { background: #eef1f5; color: #475467; border-color: #d9dfe7; }
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; border-left-width: 4px; }
.alert-success { background: var(--success-50); border-color: #b9e3c7; border-left-color: var(--success); color: #0f5c2c; }
.alert-error { background: var(--danger-50); border-color: #f3c0c0; border-left-color: var(--danger); color: #7f1414; }
.alert-warning { background: var(--warning-50); border-color: #f1d39c; border-left-color: var(--warning); color: #6d3f05; }
.alert-info { background: var(--info-50); border-color: #c1d2fb; border-left-color: var(--info); color: #173c9c; }
.alert ul { margin: .25rem 0 0; padding-left: 1.2rem; }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field > label, .field-label { font-weight: 600; font-size: .85rem; color: #243044; }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=search], input[type=tel], input[type=file], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: .45rem .65rem; border: 1px solid #c4cdd9; border-radius: 8px; font: inherit; font-size: .9rem;
  color: var(--text); background: #fff;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11,59,117,.18); }
input[readonly], input:disabled, select:disabled { background: #f1f4f8; color: #4b5565; }
.field-hint { color: var(--muted); font-size: .78rem; }
.field-error { color: var(--danger); font-size: .8rem; font-weight: 600; }
.is-invalid { border-color: var(--danger) !important; }
.check { display: inline-flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem 1rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin: 0; }
legend { font-weight: 700; padding: 0 .35rem; color: var(--primary); }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.filters .field { flex: 1 1 160px; max-width: 240px; }
.filters .field.grow { max-width: 340px; flex-basis: 220px; }
.filters .field > label { font-size: .75rem; }

/* ---------------- Tables & pagination ---------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid #e6ebf1; vertical-align: top; }
.table thead th { background: #f5f7fb; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: #3f4a5c; white-space: nowrap; }
.table tbody tr:hover { background: #fafbfd; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions .btn, .table .actions form { margin-left: .2rem; }
.table-compact th, .table-compact td { padding: .4rem .55rem; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link i { color: #9aa7ba; font-size: .7rem; }
.cell-sub { display: block; color: var(--muted); font-size: .78rem; }
.truncate { max-width: 420px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .9rem; }
.pagination ul { display: flex; flex-wrap: wrap; gap: .25rem; list-style: none; padding: 0; margin: 0; }
.pagination-info { color: var(--muted); font-size: .82rem; }
.page-link { display: inline-flex; min-width: 36px; height: 36px; align-items: center; justify-content: center; padding: 0 .6rem; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; background: #fff; font-size: .85rem; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.disabled { color: #a3adbb; background: #f6f7f9; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }

/* ---------------- Charts ---------------- */
.bar-chart { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 48px; gap: .6rem; align-items: center; font-size: .85rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #edf1f6; border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 6px; min-width: 2px; }
.bar-fill.alt { background: #2f7bbf; }
.bar-value { text-align: right; font-weight: 700; }
.donut-wrap { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; border-radius: 50%; position: relative; flex: 0 0 140px; }
.donut::after { content: ""; position: absolute; inset: 26px; background: var(--surface); border-radius: 50%; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1; font-weight: 700; }
.donut-center small { font-weight: 500; color: var(--muted); }
.legend { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.legend li { display: flex; align-items: center; gap: .45rem; margin: .25rem 0; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.progress { background: #edf1f6; border-radius: 6px; height: 8px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--success); }
.progress.warn > span { background: var(--danger); }

/* ---------------- Activity feed ---------------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid #eef1f5; font-size: .87rem; }
.feed li:last-child { border-bottom: 0; }
.feed-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-50); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 30px; font-size: .8rem; }
.feed time { display: block; color: var(--muted); font-size: .75rem; }

/* ---------------- Student exam cards ---------------- */
.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.exam-card { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--primary); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: .6rem; box-shadow: var(--shadow); }
.exam-card h3 { margin: 0; font-size: 1.05rem; }
.exam-card .meta { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .75rem; font-size: .83rem; margin: 0; }
.exam-card .meta dt { color: var(--muted); }
.exam-card .meta dd { margin: 0 0 .15rem; font-weight: 600; }
.exam-card .card-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; }
.instructions-list li { margin-bottom: .4rem; }
.info-strip { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; padding: .75rem 1rem; background: var(--primary-50); border-radius: 8px; margin-bottom: 1rem; }
.info-strip div span { display: block; font-size: .75rem; color: var(--muted); }
.info-strip div strong { font-size: .95rem; }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; font-size: .88rem; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------------- Toasts & modals ---------------- */
.toast-root { position: fixed; right: 1rem; bottom: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: #1c2533; color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: .88rem; border-left: 4px solid var(--accent); }
.toast.success { border-left-color: #4ade80; }
.toast.error { border-left-color: #f87171; }
dialog.modal { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 2rem)); box-shadow: 0 20px 50px rgba(0,0,0,.25); color: var(--text); }
dialog.modal.wide { width: min(860px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(10, 20, 35, .55); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 1rem; max-height: 70vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1rem; border-top: 1px solid var(--border); background: #f8fafc; border-radius: 0 0 12px 12px; }

/* ---------------- Question preview ---------------- */
.q-preview { font-size: .95rem; }
.q-preview .q-text { white-space: pre-wrap; margin-bottom: .6rem; }
.q-preview ol { list-style: none; padding: 0; margin: 0; }
.q-preview li { padding: .35rem .6rem; border: 1px solid var(--border); border-radius: 6px; margin-bottom: .35rem; }
.q-preview li.correct { border-color: var(--success); background: var(--success-50); font-weight: 600; }
.q-image { max-height: 240px; border: 1px solid var(--border); border-radius: 6px; margin: .4rem 0; }

/* ---------------- Exam builder ---------------- */
.builder { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.builder .card { margin-bottom: 0; }
.builder-list { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow-y: auto; }
.builder-item { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: start; padding: .6rem .5rem; border-bottom: 1px solid #eef1f5; font-size: .87rem; }
.builder-item .q-no { font-weight: 700; color: var(--primary); min-width: 1.6rem; }
.builder-item .q-meta { color: var(--muted); font-size: .75rem; margin-top: .15rem; }
.builder-item .q-tools { display: flex; flex-wrap: wrap; gap: .25rem; justify-content: flex-end; align-items: center; }
.builder-item input.marks { width: 70px; min-height: 32px; padding: .2rem .4rem; }
.builder-item.selected { background: var(--success-50); }
.builder-summary { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .88rem; }
.sticky-top { position: sticky; top: 72px; }

/* ---------------- Result sheet ---------------- */
.result-sheet { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; max-width: 900px; margin: 0 auto 1rem; }
.result-sheet-head { display: flex; gap: 1rem; align-items: center; border-bottom: 3px double var(--primary); padding-bottom: .9rem; margin-bottom: 1rem; text-align: left; }
.result-sheet-head h2 { margin: 0; color: var(--primary); font-size: 1.35rem; }
.result-sheet-head p { margin: 0; }
.sheet-title { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #7a5200; margin-top: .25rem !important; }
.sheet-section { margin-bottom: 1rem; }
.sheet-section h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.kv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem 1rem; }
.kv span { display: block; font-size: .75rem; color: var(--muted); }
.kv strong { font-size: .92rem; word-break: break-word; }
.score-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.score-grid div { padding: .6rem .75rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.score-grid span { display: block; font-size: .75rem; color: var(--muted); }
.score-grid strong { font-size: 1.15rem; }
.result-verdict { margin-top: .9rem; padding: .75rem; text-align: center; border-radius: 8px; font-size: 1.25rem; font-weight: 800; letter-spacing: .06em; }
.result-verdict small { font-size: .8rem; font-weight: 500; letter-spacing: 0; }
.result-verdict.pass { background: var(--success-50); color: var(--success); border: 1px solid #b9e3c7; }
.result-verdict.fail { background: var(--danger-50); color: var(--danger); border: 1px solid #f3c0c0; }
.sheet-signatures { display: flex; justify-content: space-between; gap: 2rem; margin-top: 3rem; font-size: .85rem; font-weight: 600; }
.sheet-signatures div { flex: 1; max-width: 240px; text-align: center; }
.sig-line { display: block; border-top: 1px solid #333; margin-bottom: .35rem; }
.sheet-note { font-size: .75rem; color: var(--muted); text-align: center; margin: 1rem 0 0; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .builder { grid-template-columns: 1fr; }
  .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.3); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,20,35,.45); z-index: 35; }
  .sidebar-toggle { display: inline-flex; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .install-wrap { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky-top { position: static; }
}
@media (max-width: 640px) {
  .content { padding: 1rem; }
  .topbar { padding: 0 .75rem; }
  .user-meta { display: none; }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .filters .field, .filters .field.grow { max-width: none; flex-basis: 100%; }
  .bar-row { grid-template-columns: 90px 1fr 40px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv-list { grid-template-columns: 1fr; }
  .kv-list dd { margin-bottom: .4rem; }
  .result-sheet { padding: 1rem; }
  .kv-grid { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  h1 { font-size: 1.3rem; }
}

/* ---------------- Print ---------------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .app-footer, .page-head, .no-print, .toast-root, .public-header, .public-footer, .alert { display: none !important; }
  .content, .public-main { padding: 0; max-width: none; }
  .result-sheet { border: 0; padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  a { color: inherit; text-decoration: none; }
  .result-verdict, .score-grid, .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
