/* TJC Safety Portal — design tokens: TJC navy, sun-logo red, white. */
:root {
  --navy-950: #0A3D91;
  --navy-900: #1877F2;
  --navy-800: #166FE5;
  --navy-700: #0D5BC6;
  --navy-200: #C6DCFC;
  --navy-100: #E7F0FE;
  --navy-50: #F2F7FF;
  --red-600: #D7141E;
  --red-700: #B10F18;
  --red-100: #FBD9DB;
  --red-50: #FDF0F0;
  --bg: #F0F2F5;
  --surface: #FFFFFF;
  --text: #0F172A;
  --muted: #475569;
  --subtle: #64748B;
  --border: #DADDE1;
  --border-strong: #BCC0C4;
  --ok: #15803D;   --ok-bg: #E7F5EC;
  --warn: #A45006; --warn-bg: #FEF3E2;
  --bad: #B91C1C;  --bad-bg: #FDECEC;
  --info: #1D4ED8; --info-bg: #E8EEFD;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(10, 61, 145, .06);
  --shadow: 0 1px 3px rgba(10, 61, 145, .08), 0 6px 16px -6px rgba(10, 61, 145, .12);
  --shadow-lg: 0 12px 32px -12px rgba(10, 61, 145, .28);
  --focus: 0 0 0 3px #fff, 0 0 0 6px var(--navy-700);
  --font: 'Noto Sans Thai', 'Noto Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 96px; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.65; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
a { color: var(--navy-700); text-underline-offset: 3px; }
a:hover { color: var(--red-600); }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .5em; color: var(--navy-950); font-weight: 700; }
h1 { font-size: clamp(1.6rem, 3.2vw, 2.25rem); }
h2 { font-size: clamp(1.3rem, 2.4vw, 1.6rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--navy-900); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); }
.skip:focus { top: 12px; color: #fff; }
.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .container { padding: 0 24px; } }
.narrow { max-width: 820px; }

/* ---------- Buttons ---------- */
.btn {
  --b: var(--navy-800); --c: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: 10px; border: 1.5px solid var(--b); background: var(--b); color: var(--c); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; line-height: 1.2; transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease), box-shadow .18s var(--ease);
}
.btn:hover { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-red { --b: var(--red-600); }
.btn-red:hover { background: var(--red-700); border-color: var(--red-700); }
.btn-outline { background: #fff; color: var(--navy-950); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--navy-50); color: var(--navy-950); border-color: var(--navy-700); }
.btn-ghost { background: transparent; color: var(--navy-950); border-color: transparent; }
.btn-ghost:hover { background: var(--navy-50); color: var(--navy-950); border-color: transparent; }
.btn-danger { background: #fff; color: var(--bad); border-color: #F2B8B8; }
.btn-danger:hover { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.btn-white { background: #fff; color: var(--navy-950); border-color: #fff; }
.btn-white:hover { background: var(--navy-50); color: var(--navy-950); border-color: var(--navy-50); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 8px; }
.btn-lg { min-height: 52px; padding: 14px 24px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ---------- Header ---------- */
.topbar { background: var(--navy-950); color: #E4EEFD; font-size: .85rem; }
.topbar .container { display: flex; align-items: center; gap: 16px; min-height: 38px; }
.topbar a { color: #fff; text-decoration: none; }
.topbar .emerg { display: inline-flex; gap: 6px; align-items: center; }
.topbar .emerg strong { color: #fff; }
@media (max-width: 640px) { .topbar .emerg .lbl { display: none; } .topbar .emerg { font-size: .8rem; } }
.lang-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; min-height: 30px; }
.lang-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.site-header { position: sticky; top: 0; z-index: 40; background: rgba(255,255,255,.97); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; gap: 16px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--navy-950); min-width: 0; }
.brand img { height: 44px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main-nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.main-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 10px; color: var(--navy-950); text-decoration: none; font-weight: 500; font-size: .95rem; border-radius: 8px; white-space: nowrap; }
.main-nav a:hover { background: var(--navy-50); color: var(--navy-950); }
.main-nav a[aria-current="page"] { color: var(--red-600); box-shadow: inset 0 -3px 0 var(--red-600); border-radius: 0; }
.main-nav .btn { margin-left: 8px; color: #fff; }
.nav-toggle { display: none; margin-left: auto; }
@media (max-width: 1140px) {
  .nav-toggle { display: inline-flex; }
  .main-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; background: #fff; border-bottom: 1px solid var(--border); padding: 8px 16px 16px; box-shadow: var(--shadow-lg); }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px; }
  .main-nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--red-600); background: var(--red-50); }
  .main-nav .btn { margin: 8px 0 0; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff;
  background:
    radial-gradient(1200px 500px at 85% 120%, rgba(215, 20, 30, .35), transparent 60%),
    linear-gradient(135deg, var(--navy-950) 0%, var(--navy-700) 55%, var(--navy-900) 100%);
}
.hero::before { /* sun rays from the TJC logo */
  content: ""; position: absolute; right: -180px; bottom: -260px; width: 720px; height: 720px; border-radius: 50%; opacity: .16;
  background: repeating-conic-gradient(from 0deg, #fff 0deg 4deg, transparent 4deg 15deg);
  -webkit-mask: radial-gradient(circle, transparent 34%, #000 35%, #000 70%, transparent 71%);
          mask: radial-gradient(circle, transparent 34%, #000 35%, #000 70%, transparent 71%);
}
.hero::after { content: ""; position: absolute; right: 70px; bottom: -110px; width: 220px; height: 220px; border-radius: 50%; background: var(--red-600); opacity: .55; }
.hero .container { position: relative; z-index: 1; display: grid; gap: 32px; padding-top: 56px; padding-bottom: 64px; }
@media (min-width: 960px) { .hero .container { grid-template-columns: 1.5fr 1fr; align-items: center; padding-top: 72px; padding-bottom: 88px; } }
.hero h1 { color: #fff; font-size: clamp(1.9rem, 4.4vw, 3rem); margin-bottom: 16px; }
.hero p.lead { font-size: 1.1rem; color: #DCE8FD; max-width: 40em; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600; letter-spacing: .02em; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.1); color: #fff; margin-bottom: 16px; }
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: #4ADE80; box-shadow: 0 0 0 4px rgba(74, 222, 128, .25); }
.hero .row { margin-top: 24px; }

.safe-card { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius-lg); padding: 24px; backdrop-filter: blur(6px); }
.safe-card .label { color: #DCE8FD; font-size: .95rem; display: flex; gap: 8px; align-items: center; }
.safe-num { font-size: clamp(3rem, 8vw, 4.5rem); font-weight: 700; line-height: 1; margin: 12px 0 6px; font-variant-numeric: tabular-nums; }
.safe-num small { font-size: 1.1rem; font-weight: 500; color: #DCE8FD; margin-left: 6px; }
.safe-track { height: 8px; background: rgba(255,255,255,.15); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.safe-track span { display: block; height: 100%; background: linear-gradient(90deg, #4ADE80, #22C55E); border-radius: 99px; }

/* ---------- Sections ---------- */
.section { padding: 56px 0; }
.section-sm { padding: 32px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.bg-white { background: #fff; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.page-head { background: linear-gradient(135deg, var(--navy-950), var(--navy-700) 60%, var(--navy-900)); color: #fff; padding: 36px 0 40px; position: relative; overflow: hidden; }
.page-head::after { content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%; opacity: .12; background: repeating-conic-gradient(#fff 0deg 4deg, transparent 4deg 15deg); }
.page-head h1 { color: #fff; margin: 0; }
.page-head p { color: #DCE8FD; margin: 8px 0 0; max-width: 46em; }
.crumbs { font-size: .875rem; margin-bottom: 10px; color: #C6DCFC; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.crumbs a { color: #fff; }

/* ---------- Cards & tiles ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.card-lg { padding: 28px; }
.card h3 { margin-bottom: 6px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
@media (min-width: 900px) { .split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; } }

.tile { display: flex; gap: 16px; align-items: flex-start; padding: 20px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease); min-height: 100%; }
.tile:hover { border-color: var(--navy-200); box-shadow: var(--shadow); transform: translateY(-2px); color: var(--text); }
.tile h3 { font-size: 1.05rem; margin: 0 0 4px; }
.tile p { margin: 0; color: var(--muted); font-size: .92rem; }
.tile .go { margin-left: auto; color: var(--subtle); align-self: center; }
.tile:hover .go { color: var(--red-600); }
.ico { width: 48px; height: 48px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--navy-50); color: var(--navy-700); }
.ico .icon { width: 24px; height: 24px; }
.ico.red { background: var(--red-50); color: var(--red-600); }
.ico.green { background: var(--ok-bg); color: var(--ok); }
.ico.amber { background: var(--warn-bg); color: var(--warn); }
.tile .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: .8rem; color: var(--subtle); }

.role-card { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 24px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); text-decoration: none; color: var(--text); box-shadow: var(--shadow-sm); transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s var(--ease); overflow: hidden; }
.role-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--navy-700); }
.role-card.contractor::before { background: #E08A00; }
.role-card.visitor::before { background: var(--red-600); }
.role-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--navy-200); color: var(--text); }
.role-card h3 { font-size: 1.25rem; margin: 0; }
.role-card p { margin: 0; color: var(--muted); }
.role-card .btn { margin-top: auto; align-self: flex-start; }

/* ---------- Badges, alerts, progress ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--navy-50); color: var(--navy-700); white-space: nowrap; line-height: 1.6; }
.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.info { background: var(--info-bg); color: var(--info); }
.badge.muted { background: #EEF0F3; color: var(--muted); }
.badge.red { background: var(--red-600); color: #fff; }
.risk { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 6px; font-weight: 700; font-size: .82rem; white-space: nowrap; }
.risk.low { background: #DCFCE7; color: #14532D; }
.risk.medium { background: #FEF08A; color: #713F12; }
.risk.high { background: #FDBA74; color: #7C2D12; }
.risk.vhigh { background: #DC2626; color: #fff; }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid; margin-bottom: 16px; }
.alert .icon { margin-top: 3px; }
.alert.ok { background: var(--ok-bg); border-color: #A7DDB8; color: #14532D; }
.alert.warn { background: var(--warn-bg); border-color: #F5CF94; color: #78350F; }
.alert.bad { background: var(--bad-bg); border-color: #F2B8B8; color: #7F1D1D; }
.alert.info { background: var(--info-bg); border-color: #BFD0FA; color: #1E3A8A; }
.alert p:last-child { margin: 0; }

.progress { height: 8px; background: #E4E6EB; border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--navy-700); border-radius: 99px; transition: width .4s var(--ease); }
.progress.ok > span { background: var(--ok); }
.progress-label { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }

/* ---------- Prose (articles) ---------- */
.prose { font-size: 1.04rem; line-height: 1.8; }
.prose h2 { font-size: 1.35rem; margin: 1.8em 0 .6em; padding-bottom: .3em; border-bottom: 2px solid var(--navy-100); }
.prose h3 { font-size: 1.12rem; margin: 1.5em 0 .5em; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.prose li { margin: .3em 0; }
.prose li::marker { color: var(--red-600); }
.prose strong { color: var(--navy-950); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose blockquote { margin: 1.4em 0; padding: 14px 18px; border-left: 4px solid var(--navy-700); background: var(--navy-50); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prose blockquote p:last-child { margin: 0; }
.prose blockquote.warn { border-color: var(--red-600); background: var(--red-50); }
.prose blockquote.warn strong:first-child { color: var(--red-700); }
.prose blockquote.note { border-color: var(--info); background: var(--info-bg); }
.prose img { border-radius: var(--radius-sm); height: auto; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--border); border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
.prose table, .table { width: 100%; border-collapse: collapse; font-size: .95rem; background: #fff; }
.prose th, .table th { background: var(--navy-900); color: #fff; font-weight: 600; text-align: left; padding: 10px 12px; vertical-align: bottom; }
.prose td, .table td { padding: 10px 12px; border-top: 1px solid var(--border); vertical-align: top; }
.prose tr:nth-child(even) td { background: #F7F9FC; }
.table th { background: var(--navy-50); color: var(--navy-950); font-size: .85rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:hover td { background: #F5F9FF; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { white-space: nowrap; text-align: right; }

.doc-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 14px 16px; background: var(--navy-50); border: 1px solid var(--navy-100); border-radius: var(--radius-sm); font-size: .88rem; color: var(--muted); margin-bottom: 24px; }
.doc-meta b { color: var(--navy-950); font-weight: 600; }
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; background: #000; }
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.side-nav { position: sticky; top: 96px; }
.side-nav a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); font-size: .92rem; }
.side-nav a:hover { background: var(--navy-50); color: var(--navy-950); }
.side-nav a.done { color: var(--ok); }
.side-nav a.current { background: var(--navy-900); color: #fff; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field > label, .label { font-weight: 600; color: var(--navy-950); font-size: .95rem; }
.field .req { color: var(--red-600); margin-left: 2px; }
.help { font-size: .85rem; color: var(--muted); }
.err { font-size: .85rem; color: var(--bad); font-weight: 500; display: flex; gap: 6px; align-items: center; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=url], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; font: inherit; font-size: 1rem; color: var(--text); background: #fff;
  border: 1.5px solid var(--border-strong); border-radius: 10px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(24, 119, 242, .18); }
.invalid input, .invalid select, .invalid textarea, input.invalid { border-color: var(--bad); }
input[type=file] { font: inherit; font-size: .95rem; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--navy-900); flex: none; }
.form-grid { display: grid; gap: 18px; }
@media (min-width: 720px) { .form-grid.two { grid-template-columns: 1fr 1fr; } .form-grid.three { grid-template-columns: repeat(3, 1fr); } .span-2 { grid-column: span 2; } }

.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.segmented label { position: relative; display: flex; gap: 10px; align-items: center; padding: 14px; border: 1.5px solid var(--border-strong); border-radius: 12px; cursor: pointer; font-weight: 600; background: #fff; transition: border-color .15s, background .15s; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:hover { border-color: var(--navy-700); }
.segmented input:checked + span { color: var(--navy-950); }
.segmented label:has(input:checked) { border-color: var(--navy-900); background: var(--navy-50); box-shadow: inset 0 0 0 1px var(--navy-900); }
.segmented label:has(input:focus-visible) { box-shadow: var(--focus); }

/* ---------- Learning ---------- */
.steps { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 24px; }
.step { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 12px; background: #fff; border: 1px solid var(--border); }
.step .n { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-100); color: var(--navy-950); font-weight: 700; flex: none; }
.step.done .n { background: var(--ok); color: #fff; }
.step.active { border-color: var(--navy-900); box-shadow: inset 0 0 0 1px var(--navy-900); }
.step.active .n { background: var(--navy-900); color: #fff; }
@media (max-width: 640px) {
  .steps { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .step { flex-direction: column; text-align: center; gap: 6px; padding: 10px 6px; font-size: .78rem; line-height: 1.35; }
}
.lesson { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); min-height: 64px; }
.lesson:last-child { border-bottom: 0; }
.lesson:hover { background: var(--navy-50); color: var(--text); }
.lesson .state { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; color: #fff; }
.lesson.done .state { background: var(--ok); border-color: var(--ok); }
.lesson .t { font-weight: 600; }
.lesson .d { font-size: .85rem; color: var(--muted); }
.learn-bar { position: sticky; bottom: 0; z-index: 20; background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -6px 20px -12px rgba(11,31,75,.3); padding: 12px 0; margin-top: 32px; }

.quiz-bar { position: sticky; top: 72px; z-index: 30; background: var(--navy-950); color: #fff; padding: 12px 0; box-shadow: var(--shadow); }
.quiz-bar .container { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.timer { display: inline-flex; gap: 8px; align-items: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.15rem; padding: 4px 12px; border-radius: 8px; background: rgba(255,255,255,.12); }
.timer.low { background: var(--red-600); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .75; } }
.quiz-bar .progress { flex: 1; min-width: 120px; background: rgba(255,255,255,.2); }
.quiz-bar .progress > span { background: #4ADE80; }
.q-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; scroll-margin-top: 150px; }
.q-card + .q-card { margin-top: 16px; }
.q-num { font-size: .85rem; font-weight: 700; color: var(--red-600); letter-spacing: .02em; }
.q-text { font-size: 1.1rem; font-weight: 600; color: var(--navy-950); margin: 4px 0 16px; }
.choices { display: grid; gap: 10px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1.5px solid var(--border-strong); border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; min-height: 52px; }
.choice:hover { border-color: var(--navy-700); background: var(--navy-50); }
.choice input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--navy-900); flex: none; }
.choice:has(input:checked) { border-color: var(--navy-900); background: var(--navy-50); box-shadow: inset 0 0 0 1px var(--navy-900); }
.choice:has(input:focus-visible) { box-shadow: var(--focus); }
.choice.correct { border-color: var(--ok); background: var(--ok-bg); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice .tag { margin-left: auto; }
.explain { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--navy-50); font-size: .95rem; }

.score-ring { --p: 0; --c: var(--ok); width: 160px; height: 160px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 16px;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), #E4E6EB 0); }
.score-ring > div { width: 128px; height: 128px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.score-ring strong { font-size: 2.1rem; color: var(--navy-950); display: block; }
.score-ring.fail { --c: var(--red-600); }

/* ---------- Org chart ---------- */
.org-tree { overflow-x: auto; padding: 8px 0 16px; -webkit-overflow-scrolling: touch; }
.org-tree ul { list-style: none; margin: 0; padding: 24px 0 0; display: flex; justify-content: center; position: relative; }
.org-tree > ul { padding-top: 0; }
.org-tree li { position: relative; padding: 24px 8px 0; display: flex; flex-direction: column; align-items: center; }
.org-tree > ul > li { padding-top: 0; }
.org-tree li::before, .org-tree li::after { content: ""; position: absolute; top: 0; width: 50%; height: 24px; border-top: 2px solid var(--navy-200); }
.org-tree li::before { right: 50%; }
.org-tree li::after { left: 50%; border-left: 2px solid var(--navy-200); }
.org-tree li:first-child::before, .org-tree li:last-child::after { border-top: 0; }
.org-tree li:last-child::before { border-right: 2px solid var(--navy-200); border-radius: 0 8px 0 0; }
.org-tree li:first-child::after { border-radius: 8px 0 0 0; }
.org-tree li:only-child::before, .org-tree li:only-child::after { display: none; }
.org-tree li:only-child { padding-top: 24px; }
.org-tree li:only-child > .node::before { content: ""; position: absolute; top: -24px; left: 50%; height: 24px; border-left: 2px solid var(--navy-200); }
.org-tree > ul > li:only-child { padding-top: 0; }
.org-tree > ul > li:only-child > .node::before { display: none; }
.org-tree ul ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 24px; border-left: 2px solid var(--navy-200); }
.node { position: relative; width: 190px; padding: 14px 12px; background: #fff; border: 1px solid var(--border); border-top: 4px solid var(--navy-700); border-radius: 12px; text-align: center; box-shadow: var(--shadow-sm); }
.node.root { border-top-color: var(--red-600); background: var(--navy-950); color: #fff; }
.node.root .pos { color: #fff; }
.node.root .nm { color: #C6DCFC; }
.node.se { border-top-color: var(--ok); }
.node .avatar { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 8px; object-fit: cover; background: var(--navy-50); display: grid; place-items: center; color: var(--navy-700); }
.node .pos { font-weight: 700; color: var(--navy-950); font-size: .92rem; line-height: 1.35; }
.node .nm { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.people { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.person { display: flex; gap: 12px; align-items: center; padding: 14px; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.person .avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; background: var(--navy-50); display: grid; place-items: center; color: var(--navy-700); }
.person .pos { font-weight: 600; color: var(--navy-950); font-size: .92rem; }
.person .nm { font-size: .85rem; color: var(--muted); }

/* ---------- Registers (responsive cards on mobile) ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .search { position: relative; flex: 1; min-width: 220px; }
.toolbar .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.toolbar .search input { padding-left: 40px; }
@media (max-width: 760px) {
  .table.stackable thead { display: none; }
  .table.stackable, .table.stackable tbody, .table.stackable tr, .table.stackable td { display: block; width: 100%; }
  .table.stackable tr { border-bottom: 8px solid var(--bg); padding: 8px 0; }
  .table.stackable td { border: 0; padding: 6px 14px; }
  .table.stackable td::before { content: attr(data-label); display: block; font-size: .78rem; font-weight: 600; color: var(--subtle); }
}

/* ---------- News & contacts ---------- */
.news-item { display: block; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.news-item:last-child { border-bottom: 0; }
.news-item h3 { font-size: 1.05rem; margin: 4px 0 6px; }
.news-item .prose { font-size: .95rem; color: var(--muted); }
.news-item .prose p:last-child { margin: 0; }
.contact { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.contact:last-child { border-bottom: 0; }
.contact .num { margin-left: auto; font-weight: 700; font-size: 1.1rem; color: var(--red-600); text-decoration: none; white-space: nowrap; }
.emergency-strip { background: var(--red-600); color: #fff; }
.emergency-strip .container { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.emergency-strip a { color: #fff; font-weight: 700; }

/* ---------- Footer ---------- */
.site-footer { background: var(--navy-950); color: #BFD5F7; padding: 48px 0 24px; margin-top: 64px; font-size: .92rem; }
.site-footer a { color: #fff; }
.site-footer .grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 32px; }
.site-footer h4 { color: #fff; font-size: 1rem; margin-bottom: 12px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.site-footer .foot-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.site-footer .foot-brand img { height: 40px; background: #fff; border-radius: 8px; padding: 4px; }
.site-footer .bottom { border-top: 1px solid rgba(255,255,255,.1); margin-top: 32px; padding-top: 20px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

/* ---------- Empty/error ---------- */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .ico { margin: 0 auto 12px; }
.err-page { text-align: center; padding: 80px 16px; }
.err-page .code { font-size: 4rem; font-weight: 700; color: var(--navy-100); line-height: 1; }

/* ---------- Certificate ---------- */
.cert-wrap { padding: 24px 0 48px; }
.cert {
  position: relative; max-width: 1000px; margin: 0 auto; aspect-ratio: 1.414 / 1; background: #fff; color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); padding: clamp(20px, 4vw, 48px); overflow: hidden;
  display: flex; flex-direction: column; container-type: inline-size;
}
.cert::before { content: ""; position: absolute; inset: 14px; border: 2px solid var(--navy-900); outline: 1px solid var(--navy-900); outline-offset: 5px; pointer-events: none; }
.cert::after { content: ""; position: absolute; left: -120px; bottom: -160px; width: 420px; height: 420px; border-radius: 50%; opacity: .07; background: repeating-conic-gradient(var(--red-600) 0deg 4deg, transparent 4deg 15deg); }
.cert-top { display: flex; gap: 16px; align-items: center; justify-content: center; position: relative; z-index: 1; }
.cert-top img { height: clamp(40px, 8cqw, 76px); }
.cert-top .co { text-align: left; }
.cert-top .co strong { display: block; font-size: clamp(.9rem, 2.2cqw, 1.3rem); color: var(--navy-950); }
.cert-top .co span { font-size: clamp(.7rem, 1.5cqw, .9rem); color: var(--muted); }
.cert-body { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; position: relative; z-index: 1; gap: .4em; }
.cert-title { font-size: clamp(1.2rem, 4.2cqw, 2.4rem); font-weight: 700; color: var(--navy-950); letter-spacing: .02em; }
.cert-title small { display: block; font-size: .45em; color: var(--red-600); letter-spacing: .2em; text-transform: uppercase; font-weight: 600; }
.cert-name { font-size: clamp(1.3rem, 4.6cqw, 2.6rem); font-weight: 700; color: var(--red-600); border-bottom: 2px solid var(--navy-100); padding: 0 1em .1em; }
.cert-course { font-size: clamp(.95rem, 2.4cqw, 1.35rem); font-weight: 600; color: var(--navy-950); }
.cert-body p { margin: 0; font-size: clamp(.8rem, 1.8cqw, 1rem); color: var(--muted); }
.cert-foot { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: end; position: relative; z-index: 1; font-size: clamp(.68rem, 1.5cqw, .88rem); }
.cert-foot .sig { text-align: center; }
.cert-foot .sig .line { border-top: 1px solid var(--text); margin: 0 auto 4px; width: 80%; padding-top: 4px; }
.cert-foot .qr { width: clamp(64px, 12cqw, 110px); text-align: center; color: var(--muted); }
.cert-foot .qr svg { width: 100%; height: auto; display: block; }
.cert-foot .info { text-align: right; color: var(--muted); }
.cert-foot .info b { color: var(--navy-950); }

/* ---------- Admin ---------- */
.admin-body { background: #F0F2F5; }
.admin-shell { display: grid; min-height: 100vh; }
@media (min-width: 1000px) { .admin-shell { grid-template-columns: 260px minmax(0, 1fr); } }
.admin-side { background: var(--navy-950); color: #C6DCFC; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
@media (min-width: 1000px) { .admin-side { position: sticky; top: 0; height: 100vh; overflow-y: auto; } }
@media (max-width: 999px) { .admin-side { display: none; } .admin-side.open { display: flex; position: fixed; inset: 0 20% 0 0; z-index: 60; overflow-y: auto; box-shadow: var(--shadow-lg); } }
.admin-side .brand { color: #fff; padding: 6px 8px 16px; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 8px; }
.admin-side .brand img { height: 36px; background: #fff; border-radius: 8px; padding: 3px; }
.admin-side .brand-text span { color: #A9C8F5; }
.admin-side .grp { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8DB4EE; padding: 14px 10px 4px; font-weight: 600; }
.admin-side a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; color: #E4EEFD; text-decoration: none; font-size: .93rem; min-height: 40px; }
.admin-side a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-side a.active { background: var(--red-600); color: #fff; }
.admin-side a .badge { margin-left: auto; background: var(--red-600); color: #fff; }
.admin-side a.active .badge { background: #fff; color: var(--red-600); }
.admin-main { min-width: 0; }
.admin-top { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--border); }
.admin-top .inner { display: flex; gap: 12px; align-items: center; min-height: 60px; padding: 0 20px; }
.admin-top .who { display: flex; gap: 8px; align-items: center; font-size: .9rem; color: var(--muted); }
.admin-content { padding: 24px 20px 48px; max-width: 1280px; }
.admin-content > h1 { font-size: 1.5rem; }
.admin-menu-btn { display: none; }
@media (max-width: 999px) { .admin-menu-btn { display: inline-flex; } }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; gap: 14px; align-items: center; }
.stat .v { font-size: 1.8rem; font-weight: 700; color: var(--navy-950); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .k { font-size: .85rem; color: var(--muted); }
.stat.flash { animation: flash 1.2s var(--ease); }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(215, 20, 30, .5); } 100% { box-shadow: 0 0 0 14px rgba(215, 20, 30, 0); } }
.live-dot { display: inline-flex; gap: 6px; align-items: center; font-size: .8rem; font-weight: 600; color: var(--ok); }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
.live-dot.off { color: var(--subtle); }
.feed { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.feed li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.feed li.new { animation: slidein .5s var(--ease); }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); background: var(--navy-50); } }
.feed .time { margin-left: auto; color: var(--subtle); font-size: .8rem; white-space: nowrap; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 12px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .b .col { width: 100%; max-width: 32px; background: var(--navy-100); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.bars .b .col .p { background: var(--navy-700); width: 100%; }
.bars .b .x { font-size: .68rem; color: var(--subtle); white-space: nowrap; }
.bars .b .n { font-size: .72rem; font-weight: 600; color: var(--navy-950); }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.md-editor { display: grid; gap: 12px; }
@media (min-width: 1200px) { .md-editor.split-view { grid-template-columns: 1fr 1fr; } }
.md-toolbar { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px; background: var(--navy-50); border: 1.5px solid var(--border-strong); border-bottom: 0; border-radius: 10px 10px 0 0; }
.md-toolbar button { min-width: 36px; min-height: 36px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 700; color: var(--navy-950); padding: 0 8px; }
.md-toolbar button:hover { background: #fff; }
.md-toolbar + textarea { border-radius: 0 0 10px 10px; min-height: 360px; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .92rem; }
.md-preview { border: 1px dashed var(--border-strong); border-radius: 10px; padding: 16px; background: #fff; max-height: 520px; overflow-y: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a, .tabs button { padding: 10px 14px; text-decoration: none; color: var(--muted); border: 0; background: none; font: inherit; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover, .tabs button:hover { color: var(--navy-950); }
.tabs .active, .tabs [aria-selected="true"] { color: var(--navy-950); border-bottom-color: var(--red-600); }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(135deg, var(--navy-950), var(--navy-700)); }
.auth-card { width: 100%; max-width: 440px; background: #fff; border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-lg); }
.auth-card .brand { justify-content: center; margin-bottom: 20px; }
.inline-form { display: inline; }
details.box { border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
details.box > summary { padding: 12px 16px; cursor: pointer; font-weight: 600; color: var(--navy-950); }
details.box > div { padding: 0 16px 16px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.temp-pass { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; background: #fff; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); user-select: all; }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  @page { size: A4 landscape; margin: 0; }
  body { background: #fff; }
  .topbar, .site-header, .site-footer, .no-print, .emergency-strip { display: none !important; }
  .cert-wrap { padding: 0; }
  .cert-wrap .container { max-width: none; padding: 0; }
  .cert { box-shadow: none; border: 0; max-width: none; width: 297mm; height: 210mm; aspect-ratio: auto; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
