/* =====================================================================
   Simple SCORM LMS - main stylesheet (no external fonts or CDNs)
   ===================================================================== */
:root {
  --ink: #1d2b33;
  --ink-soft: #52626b;
  --line: #d9e1e5;
  --bg: #f3f6f7;
  --card: #ffffff;
  --brand: #0f4c5c;
  --brand-ink: #ffffff;
  --brand-soft: #e3eff1;
  --brand-dark: #0a3a47;
  --link: #0f4c5c;
  --accent: #f3b33d;
  --ok: #1f7a4d;   --ok-bg: #e4f4ea;
  --warn: #8a5a00; --warn-bg: #fff3d6;
  --bad: #b3261e;  --bad-bg: #fbe6e4;
  --info: #1d5f8a; --info-bg: #e5f0f8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 40, 50, .06), 0 2px 8px rgba(16, 40, 50, .05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: var(--link); }
a:hover { color: var(--brand-dark); }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .6rem; }
h2:first-child, h1:first-child { margin-top: 0; }
h3 { font-size: 1rem; }
code { font-family: var(--mono); font-size: .9em; background: #eef2f4; padding: .05em .35em; border-radius: 4px; word-break: break-all; }
code.big { font-size: 1.2rem; padding: .2em .5em; background: #fff; border: 1px dashed var(--warn); }
pre.log, pre.debug { background: #10232b; color: #d7e7ec; padding: 1rem; border-radius: 8px; overflow-x: auto; font-size: .85rem; white-space: pre-wrap; }
textarea.code { width: 100%; font-family: var(--mono); font-size: .85rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--brand-ink); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.topbar { display: flex; align-items: center; gap: 1rem; background: var(--brand); color: var(--brand-ink); padding: .6rem 1.2rem; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: .6rem; margin-right: auto; }
.brand div { display: flex; flex-direction: column; line-height: 1.15; }
.brand span { font-size: .78rem; opacity: .8; }
.userbox { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.userbox a { color: var(--brand-ink); text-decoration: none; }
.userbox a:hover { text-decoration: underline; color: var(--brand-ink); }
.userbox .username { font-weight: 600; }
.nav-toggle { display: none; }
.layout { display: flex; min-height: calc(100vh - 110px); }
.sidenav { width: 220px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); padding: 1rem .6rem; }
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav a { display: block; padding: .5rem .8rem; border-radius: 8px; color: var(--ink); text-decoration: none; margin-bottom: 2px; }
.sidenav a:hover { background: var(--brand-soft); }
.sidenav a.active { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.sidenav .version { font-size: .75rem; color: var(--ink-soft); padding: 0 .8rem; margin-top: 1.5rem; }
.content { flex: 1; min-width: 0; padding: 1.4rem 1.6rem 2rem; }
.content-plain { max-width: 1000px; margin: 0 auto; padding: 2rem 1rem; }
.footer { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--ink-soft); padding: .8rem 1.6rem; border-top: 1px solid var(--line); background: #fff; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.page-head h1, .page-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.cols-even { grid-template-columns: 1fr 1fr; }
.col-side > .card + .card { margin-top: 1rem; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.3rem; margin-bottom: 1rem; }
.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.empty { color: var(--ink-soft); text-align: center; padding: 1.5rem .5rem; }
details > summary { cursor: pointer; font-weight: 600; margin: .4rem 0; }

/* ---------- Stats ---------- */
.section-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 1.4rem 0 .6rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.stat { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--brand); }
.stat .num { font-size: 1.8rem; font-weight: 700; color: var(--brand); line-height: 1.1; }
.stat small { color: var(--ink-soft); font-size: .75rem; }
.stat-pending { background: #fafbfc; border-style: dashed; }
.stat-pending .num { color: #9aa8ae; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .3rem; border-bottom: 2px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .55rem 1rem; text-decoration: none; color: var(--ink-soft); border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 600; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); background: #f8fafb; }
.table.compact th, .table.compact td { padding: .4rem .5rem; }
.table tbody tr:hover { background: #fafcfc; }
.row-muted td { color: var(--ink-soft); }
.row-actions { white-space: nowrap; }
.thumb-col { width: 76px; }
.thumb { width: 64px; height: 40px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; display: block; }
.thumb-empty { display: block; }
.thumb-large { max-width: 280px; max-height: 180px; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-muted { background: #eceff1; color: #5d6b72; }
.badge-role-admin { background: #ead9f5; color: #5b2a86; }
.badge-role-trainer { background: #dcecff; color: #1d4f91; }
.badge-role-manager { background: #ffe6d1; color: #8a3f00; }
.badge-role-learner { background: var(--ok-bg); color: var(--ok); }

/* ---------- Alerts ---------- */
.alert { border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert ul, .alert ol { margin: .4rem 0 0; padding-left: 1.2rem; }
.alert-success { background: var(--ok-bg); color: #13502f; border-color: #bfe3cc; }
.alert-error { background: var(--bad-bg); color: #7d1a14; border-color: #f2c4bf; }
.alert-warning { background: var(--warn-bg); color: #5e3d00; border-color: #f1dca8; }
.alert-info { background: var(--info-bg); color: #164a6b; border-color: #c4dcee; }

/* ---------- Forms ---------- */
.form label, .filters label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; margin-bottom: .8rem; }
input[type=text], input[type=search], input:not([type]), input[type=email], input[type=password], input[type=date], input[type=file], select, textarea {
  font: inherit; font-weight: 400; padding: .5rem .6rem; border: 1px solid #b9c6cc; border-radius: 7px; background: #fff; color: var(--ink); width: 100%; }
input[type=file] { padding: .35rem; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid var(--brand-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
label.check { display: flex; flex-direction: row; align-items: flex-start; gap: .5rem; font-weight: 400; margin-bottom: .4rem; }
label.check input { margin-top: .3rem; }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.checks-cols { columns: 2; }
.mode-list { display: grid; gap: .6rem; }
.mode-option { display: flex; gap: .7rem; align-items: flex-start; font-weight: 400 !important; border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem; flex-direction: row !important; cursor: pointer; }
.mode-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.mode-option input { margin-top: .3rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .2rem 1rem; align-items: flex-end; }
.filters label { flex: 1 1 170px; margin-bottom: .4rem; }
.filter-actions { margin-bottom: .4rem; display: flex; gap: .4rem; }
.filters-inline { margin-bottom: .8rem; }
form.inline { display: inline; }
.stack { margin-bottom: .5rem; }
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick-list li { padding: .35rem .6rem; border-bottom: 1px solid #edf1f3; }
.pick-list li:last-child { border-bottom: 0; }
.pick-list label.check { margin: 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font: inherit; font-weight: 600; font-size: .9rem; padding: .5rem 1rem; border-radius: 7px; border: 1px solid #b9c6cc; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-dark); color: var(--brand-ink); }
.btn-danger { color: var(--bad); border-color: #e2a9a4; }
.btn-danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; }
.topbar .btn-ghost { color: var(--brand-ink); border-color: currentColor; }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); color: var(--brand-ink); }
.btn-small { padding: .25rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.pagination { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination span { margin-right: auto; }

/* ---------- Details lists / history ---------- */
.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 0 0 1rem; }
.details dt { font-weight: 600; color: var(--ink-soft); }
.details dd { margin: 0; }
.details.compact { font-size: .9rem; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: .45rem 0; border-bottom: 1px solid #edf1f3; font-size: .9rem; }

/* ---------- Login / installer ---------- */
body.plain { background: linear-gradient(160deg, #e6f0f2 0%, #f3f6f7 50%); min-height: 100vh; }
.login-card { margin-top: 6vh; }
.login-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.login-brand h1 { font-size: 1.35rem; margin: 0; }
.login-brand p { margin: 0; }
.install-head { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.install-head h1 { margin: 0; font-size: 1.5rem; }
.install-head p { margin: 0; }

/* ---------- Phase 2 additions ---------- */
.input-narrow { width: 80px !important; }
.inline-form { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.inline-form input[type=date] { width: auto; padding: .25rem .4rem; }
.inline-form select { width: auto; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.course-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.course-thumb { height: 120px; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; }
.course-thumb img { max-width: 100%; max-height: 120px; object-fit: contain; }
.course-body { padding: .9rem 1rem 1rem; display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.course-body h3 { margin: 0; font-size: 1.05rem; }
.course-body p { margin: .1rem 0; }
.course-body .btn { margin-top: auto; }
.import-table td, .import-table th { font-size: .85rem; }
.row-error td { background: var(--bad-bg); }
.row-update td { background: #fffbea; }
.text-bad { color: var(--bad); }

/* ---------- Phase 3: course player ---------- */
.player-body { margin: 0; height: 100vh; display: flex; flex-direction: column; background: #10232b; overflow: hidden; }
.player-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .4rem 1rem; background: var(--brand); color: var(--brand-ink); flex-shrink: 0; }
.player-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.player-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-title span { font-size: .78rem; opacity: .85; }
.player-bar .btn-ghost { color: var(--brand-ink); border-color: currentColor; }
.player-bar .btn-ghost:hover { background: rgba(255,255,255,.12); color: var(--brand-ink); }
.player-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.player-banner { padding: .5rem 1rem; font-size: .9rem; }
.player-banner-error { background: var(--bad-bg); color: #7d1a14; }
.player-banner-warn { background: var(--warn-bg); color: #5e3d00; }
.player-done { position: fixed; inset: 0; background: rgba(16,35,43,.75); display: flex; align-items: center; justify-content: center; padding: 1rem; }
[hidden] { display: none !important; }
.version-notes { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .85rem; }
.btn-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; }
.btn-row .btn, .btn-row form { flex: 1; }
.btn-row form .btn { width: 100%; }
.linklike { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; font-size: .85rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .cols, .cols-even { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-flex; background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 7px; padding: .35rem .7rem; font: inherit; cursor: pointer; }
  .layout { flex-direction: column; }
  .sidenav { width: auto; display: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidenav.open { display: block; }
  .userbox .small { display: none; }
  .content { padding: 1rem; }
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .checks-cols { columns: 1; }
  .brand span { display: none; }
  .table thead { display: none; }
}
@media print {
  .topbar, .sidenav, .footer, .filters, .actions, .btn { display: none !important; }
  .card { box-shadow: none; border: 0; }
}

/* ---- Phase 4: progress bars, reports, attempt detail ---- */
progress.bar { width: 100%; height: .6rem; accent-color: #1d7a46; margin: .25rem 0 .5rem; }
.report-tabs { margin-bottom: 1rem; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.pre-wrap { white-space: pre-wrap; word-break: break-word; max-width: 40rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .9rem; }
.kv dt { font-weight: 600; color: #444; }
.kv dd { margin: 0; word-break: break-word; }
details.raw summary { cursor: pointer; font-weight: 600; }
.result-correct { color: #1d7a46; font-weight: 600; }
.result-incorrect { color: #b3261e; font-weight: 600; }

/* ---- Phase 5: certificates ---- */
.verify { max-width: 40rem; margin: 2rem auto; }
.form-inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.cert-link { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; }
.row-bad td { background: var(--bad-bg); }

/* ---- Client branding (0.7.0) ---- */
.brand-logo { height: 36px; width: auto; max-width: 170px; object-fit: contain; background: #fff; padding: 3px 6px; border-radius: 6px; }
.login-wrap { max-width: 440px; margin: 6vh auto 0; }
.login-wrap .login-card { margin-top: 0; }
.login-split { max-width: 1100px; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 1.5rem; align-items: stretch; margin-top: 3vh; }
.login-hero { position: relative; min-height: 420px; border-radius: var(--radius); overflow: hidden; background: var(--brand); box-shadow: var(--shadow); }
.login-slide { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1s ease; }
.login-slide.is-active { opacity: 1; }
.login-hero-text { position: absolute; left: 0; right: 0; bottom: 0; padding: 1.4rem 1.6rem; color: #fff; background: linear-gradient(to top, rgba(0,0,0,.65), rgba(0,0,0,0)); }
.login-hero-text h2 { margin: 0 0 .3rem; font-size: 1.5rem; color: #fff; }
.login-hero-text p { margin: 0; max-width: 40rem; }
.login-logo { height: 56px; width: auto; max-width: 200px; object-fit: contain; }
.login-welcome { background: var(--brand-soft); border-radius: 8px; padding: .7rem .9rem; margin-bottom: 1rem; }
.login-welcome p { margin: .2rem 0 0; }
.brand-preview { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-start; margin: .5rem 0; }
.brand-preview figure { margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: .4rem; background: #fff; text-align: center; }
.brand-preview img { display: block; max-height: 90px; max-width: 220px; object-fit: contain; }
.brand-preview figcaption { font-size: .8rem; margin-top: .3rem; }
input[type=color] { width: 4rem; height: 2.4rem; padding: 2px; }
@media (max-width: 820px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { min-height: 200px; }
}
.login-brand-stacked { flex-direction: column; align-items: flex-start; gap: .5rem; }
.login-brand-stacked .login-logo { height: 64px; }
.login-split .login-card { display: flex; flex-direction: column; justify-content: center; }
.picker-tools { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: .6rem; }
.picker-bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin: .4rem 0; }
.pick-list-scroll { max-height: 22rem; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: .3rem .5rem; background: #fff; }
.pick-list-scroll li[hidden] { display: none; }
@media (max-width: 700px) { .picker-tools { grid-template-columns: 1fr; } }

/* ---- Multi-tenancy (0.8.0) ---- */
.sidenav .nav-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); padding: .9rem .8rem .3rem; font-weight: 700; }
.sidenav .nav-head:first-child { padding-top: .1rem; }
.company-switch { display: flex; gap: .4rem; align-items: center; margin: 0; }
.company-switch select { max-width: 260px; padding: .3rem .5rem; border-radius: 8px; border: 1px solid rgba(255,255,255,.5); font-size: .88rem; }
.seat-meter { display: block; width: 100%; max-width: 420px; height: 10px; margin: .35rem 0 .8rem; appearance: none; border: 0; border-radius: 99px; background: var(--line); overflow: hidden; }
.seat-meter::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
.seat-meter::-webkit-progress-value { background: var(--brand); border-radius: 99px; }
.seat-meter::-moz-progress-bar { background: var(--brand); border-radius: 99px; }
.seat-meter.full::-webkit-progress-value { background: #b42318; }
.seat-meter.full::-moz-progress-bar { background: #b42318; }
details.card-inner { margin: 1rem 0; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 10px; }
.kv-inline { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin: .3rem 0; }
.cert-preview { width: 100%; max-width: 640px; aspect-ratio: 842 / 595; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.tag-private { background: #efe7fb; color: #4b2a83; }
.tag-shared { background: #e3f1ec; color: #1d5c46; }
@media (max-width: 640px) {
  .company-switch { order: 3; width: 100%; }
  .company-switch select { max-width: 100%; width: 100%; }
}
.setup-key code.big { letter-spacing: .08em; font-size: 1.15rem; word-break: break-all; }
