/* =====================================================================
   Robocodia Bebras Training — design system (UI Phase 1–4)
   Brand colours sampled from the official artwork (public/images/robocodia-logo.png):
     deep blue  #194778   turquoise #2BBFCD
   All colours below are semantic tokens; components use tokens only.
   Typography: Cairo, self-hosted (no external fonts/CDNs; CSP font-src 'self').
   Weights: body 400/500 · labels/navigation 500/600 · section headings 600 ·
   page headings 700 · metrics 600/700.
   ===================================================================== */

/* ------------------------------------------------------------------ Cairo (self-hosted)
   Cairo variable font (weight axis), SIL Open Font License 1.1 — see /fonts/cairo/OFL.txt.
   Served from this origin only (font-src 'self'): no CDN, no Google Fonts. One file per
   script; the browser downloads a file only when the page uses its unicode range. */
@font-face {
  font-family: "Cairo";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url("/fonts/cairo/cairo-arabic-wght.woff2") format("woff2-variations"), url("/fonts/cairo/cairo-arabic-wght.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Cairo";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url("/fonts/cairo/cairo-latin-ext-wght.woff2") format("woff2-variations"), url("/fonts/cairo/cairo-latin-ext-wght.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Cairo";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url("/fonts/cairo/cairo-latin-wght.woff2") format("woff2-variations"), url("/fonts/cairo/cairo-latin-wght.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Brand */
  --rb-primary: #194778;
  --rb-primary-hover: #12365c;
  --rb-primary-strong: #0e2a48;
  --rb-primary-soft: #e8eff7;
  --rb-accent: #2bbfcd;
  --rb-accent-strong: #0b6a74;
  --rb-accent-soft: #e3f7f9;

  /* Neutrals */
  --rb-bg: #f3f6fa;
  --rb-surface: #ffffff;
  --rb-surface-alt: #f7f9fc;
  --rb-border: #e1e7ef;
  --rb-border-strong: #c3cddb;
  --rb-text: #15233a;
  --rb-text-secondary: #46566e;
  --rb-text-muted: #5f6e84;

  /* Status (text colours meet AA on their soft backgrounds) */
  --rb-success: #1b6b3a;
  --rb-success-soft: #e5f4ea;
  --rb-warning: #8a5300;
  --rb-warning-soft: #fdf1dc;
  --rb-danger: #b42318;
  --rb-danger-soft: #fdebe9;
  --rb-info: #1d4f86;
  --rb-info-soft: #e8f0fa;

  /* Interaction */
  --rb-focus: #2bbfcd;
  --rb-focus-ring: 0 0 0 3px rgba(43, 191, 205, 0.55);

  /* Spacing scale */
  --rb-space-1: 4px;
  --rb-space-2: 8px;
  --rb-space-3: 12px;
  --rb-space-4: 16px;
  --rb-space-5: 24px;
  --rb-space-6: 32px;
  --rb-space-7: 48px;

  /* Radius / shadow */
  --rb-radius-sm: 8px;
  --rb-radius: 14px;
  --rb-radius-pill: 999px;
  --rb-shadow: 0 1px 2px rgba(21, 35, 58, 0.06), 0 1px 1px rgba(21, 35, 58, 0.04);
  --rb-shadow-lg: 0 10px 30px rgba(21, 35, 58, 0.1);

  /* Typography */
  --rb-font: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  --rb-font-mono: Consolas, "SFMono-Regular", Menlo, "Courier New", monospace;
  --rb-fs-xs: 0.78rem;
  --rb-fs-sm: 0.875rem;
  --rb-fs-base: 1rem;
  --rb-fs-lg: 1.125rem;
  --rb-fs-h2: 1.2rem;
  --rb-fs-h1: 1.55rem;
  /* Weights (Cairo variable) */
  --rb-fw-body: 400;
  --rb-fw-medium: 500;
  --rb-fw-label: 600;
  --rb-fw-section: 600;
  --rb-fw-heading: 700;
  --rb-fw-metric: 700;
  --rb-fs-display: 2rem;

  /* Layout */
  --rb-sidebar: 256px;
  --rb-content-max: 1180px;
  --rb-logo-ratio: 8.84; /* visible wordmark band of the official logo */

  /* Legacy aliases (older templates) */
  --bg: var(--rb-bg);
  --surface: var(--rb-surface);
  --text: var(--rb-text);
  --muted: var(--rb-text-muted);
  --accent: var(--rb-primary);
  --accent-soft: var(--rb-primary-soft);
  --radius: var(--rb-radius);

  font-family: var(--rb-font);
  color-scheme: light;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--rb-bg);
  color: var(--rb-text);
  font-size: var(--rb-fs-base);
  font-weight: var(--rb-fw-body);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.35; color: var(--rb-text); }
h1 { margin: 0 0 var(--rb-space-3); font-size: var(--rb-fs-h1); font-weight: var(--rb-fw-heading); letter-spacing: -0.005em; }
h2 { margin: 0 0 var(--rb-space-2); font-size: var(--rb-fs-h2); font-weight: var(--rb-fw-section); }
h3 { margin: var(--rb-space-4) 0 var(--rb-space-2); font-size: var(--rb-fs-lg); font-weight: var(--rb-fw-section); }
p { margin: 0 0 var(--rb-space-3); }
a { color: var(--rb-primary); text-underline-offset: 2px; }
a:hover { color: var(--rb-primary-hover); }
img { max-width: 100%; }
[dir="ltr"] { unicode-bidi: isolate; }
:focus-visible { outline: none; box-shadow: var(--rb-focus-ring); border-radius: 4px; }
::selection { background: var(--rb-accent-soft); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; inset-inline-start: var(--rb-space-3); top: -60px; z-index: 100; padding: var(--rb-space-2) var(--rb-space-4); background: var(--rb-primary); color: #fff; border-radius: var(--rb-radius-sm); text-decoration: none; }
.skip-link:focus { top: var(--rb-space-3); color: #fff; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Icons: inline SVG <use>; directional icons flip in RTL */
.ico { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }
.ico-lg { width: 2rem; height: 2rem; }
[dir="rtl"] .ico-dir { transform: scaleX(-1); }

/* The `hidden` attribute always hides: component rules (.alert, .btn, .actions, … set
   `display`) must never make a hidden element visible (D-066: the reader gate and the
   reader status lines rely on it). */
[hidden] { display: none !important; }

/* Official logo: the file is used as supplied; CSS shows its wordmark band
   (object-fit keeps the aspect ratio, nothing is stretched). */
.logo { display: inline-flex; align-items: center; text-decoration: none; }
.logo img, .auth-logo, .landing-logo, .display-logo {
  display: block;
  height: var(--logo-h, 24px);
  width: calc(var(--logo-h, 24px) * var(--rb-logo-ratio));
  max-width: 100%;
  object-fit: cover;
  object-position: 50% 50.7%;
}

/* ------------------------------------------------------------------ public layout */
.page {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--rb-space-4);
}
.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rb-space-3);
  padding: var(--rb-space-3) var(--rb-space-5);
  background: var(--rb-surface);
  border-bottom: 1px solid var(--rb-border);
  --logo-h: 26px;
}
.app-footer { padding: var(--rb-space-4) var(--rb-space-5); color: var(--rb-text-muted); font-size: var(--rb-fs-xs); text-align: center; }

.card {
  width: 100%;
  max-width: 560px;
  background: var(--rb-surface);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius);
  box-shadow: var(--rb-shadow-lg);
  padding: var(--rb-space-6) var(--rb-space-5);
  text-align: center;
}
.form-card { text-align: start; max-width: 440px; }
.auth-card { padding-top: var(--rb-space-6); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: var(--rb-space-2); margin-bottom: var(--rb-space-5); --logo-h: 40px; }
.auth-product { margin: 0; color: var(--rb-accent-strong); font-weight: 600; font-size: var(--rb-fs-sm); letter-spacing: 0.02em; }
.auth-foot { display: flex; justify-content: center; margin-top: var(--rb-space-4); padding-top: var(--rb-space-3); border-top: 1px solid var(--rb-border); }
.landing { max-width: 640px; --logo-h: 52px; }
.landing-logo { margin: 0 auto var(--rb-space-5); }
.landing h1 { font-size: var(--rb-fs-display); }
.landing-lead { color: var(--rb-text-secondary); font-size: var(--rb-fs-lg); }
.landing-note { margin: var(--rb-space-5) 0 0; color: var(--rb-text-muted); font-size: var(--rb-fs-xs); }
.code { margin: 0; font-size: 2.6rem; font-weight: var(--rb-fw-heading); color: var(--rb-border-strong); line-height: 1.1; }
.error-icon { display: inline-flex; width: 64px; height: 64px; align-items: center; justify-content: center; border-radius: 50%; margin-bottom: var(--rb-space-3); }
.error-info { background: var(--rb-info-soft); color: var(--rb-info); }
.error-warning { background: var(--rb-warning-soft); color: var(--rb-warning); }
.error-danger { background: var(--rb-danger-soft); color: var(--rb-danger); }
.badge { display: inline-block; margin: 0; padding: 4px 14px; border-radius: var(--rb-radius-pill); background: var(--rb-accent-soft); color: var(--rb-accent-strong); font-weight: 600; }

/* ------------------------------------------------------------------ application shell */
.app { min-height: 100vh; }
.app-main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.sidebar { display: none; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--rb-space-3);
  padding: var(--rb-space-2) var(--rb-space-4);
  min-height: 60px;
  background: var(--rb-surface);
  border-bottom: 1px solid var(--rb-border);
  --logo-h: 18px;
}
.user-area { display: flex; align-items: center; gap: var(--rb-space-2); margin-inline-start: auto; flex-wrap: wrap; justify-content: flex-end; }
.user-name { font-weight: 600; font-size: var(--rb-fs-sm); max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-chip { padding: 2px 10px; border-radius: var(--rb-radius-pill); background: var(--rb-accent-soft); color: var(--rb-accent-strong); font-size: var(--rb-fs-xs); font-weight: 600; white-space: nowrap; }
.page-wide { display: block; width: 100%; max-width: var(--rb-content-max); margin: 0 auto; padding: var(--rb-space-5) var(--rb-space-4); min-height: auto; flex: 1; }
.app .page:not(.page-wide) { flex: 1; min-height: auto; }
.app-main > .app-footer { margin-top: auto; }

/* Sidebar navigation (admins) */
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.nav-group { margin-bottom: var(--rb-space-4); }
.nav-group-title { margin: 0 0 var(--rb-space-1); padding: 0 var(--rb-space-3); font-size: var(--rb-fs-xs); font-weight: var(--rb-fw-label); letter-spacing: 0.04em; text-transform: uppercase; color: var(--rb-text-muted); }
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--rb-space-3);
  padding: 9px var(--rb-space-3);
  border-radius: var(--rb-radius-sm);
  color: var(--rb-text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}
.nav-link:hover { background: var(--rb-surface-alt); color: var(--rb-primary); }
.nav-link.active { background: var(--rb-primary-soft); color: var(--rb-primary); font-weight: var(--rb-fw-label); box-shadow: inset 3px 0 0 var(--rb-accent); }
[dir="rtl"] .nav-link.active { box-shadow: inset -3px 0 0 var(--rb-accent); }

/* Mobile admin navigation: a disclosure (no JavaScript) */
.mobile-nav { position: relative; }
.mobile-nav > summary { list-style: none; }
.mobile-nav > summary::-webkit-details-marker { display: none; }
.mobile-nav-panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  width: min(300px, calc(100vw - 32px));
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  padding: var(--rb-space-4) var(--rb-space-3);
  background: var(--rb-surface);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius);
  box-shadow: var(--rb-shadow-lg);
}

/* Student navigation: bottom bar on phones, compact tabs on wider screens */
.student-tabs {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--rb-surface);
  border-top: 1px solid var(--rb-border);
  box-shadow: 0 -4px 16px rgba(21, 35, 58, 0.06);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.student-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 10px;
  color: var(--rb-text-muted);
  text-decoration: none;
  font-size: var(--rb-fs-xs);
  font-weight: 600;
  min-height: 56px;
}
.student-tab .ico { width: 1.45em; height: 1.45em; }
.student-tab.active { color: var(--rb-primary); box-shadow: inset 0 3px 0 var(--rb-accent); }
.shell-student .app-main { padding-bottom: 72px; }

/* ------------------------------------------------------------------ panels & page headers */
.panel {
  background: var(--rb-surface);
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius);
  box-shadow: var(--rb-shadow);
  padding: var(--rb-space-5);
  margin-bottom: var(--rb-space-4);
}
.panel.narrow { max-width: 720px; }
.panel h1 { font-size: var(--rb-fs-h1); }
.panel h2 { font-size: var(--rb-fs-h2); margin: 0 0 var(--rb-space-3); }
.panel > h2:not(:first-child) { margin-top: var(--rb-space-5); }
.panel-head { display: flex; flex-wrap: wrap; gap: var(--rb-space-3); align-items: center; justify-content: space-between; margin-bottom: var(--rb-space-3); }
.panel-head h1, .panel-head h2 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--rb-space-2); }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--rb-space-2); align-items: center; }
.row-actions .btn { margin: 0; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--rb-space-1); margin: 0 0 var(--rb-space-3); font-size: var(--rb-fs-sm); color: var(--rb-text-muted); }
.breadcrumbs a { color: var(--rb-text-secondary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--rb-primary); text-decoration: underline; }
.breadcrumbs .ico { width: 0.95em; height: 0.95em; }
.section-title { display: flex; align-items: center; gap: var(--rb-space-2); }
.lede { color: var(--rb-text-secondary); }

/* Tabs (links between sections of one record) */
.tabs { display: flex; gap: var(--rb-space-1); overflow-x: auto; border-bottom: 1px solid var(--rb-border); margin: 0 0 var(--rb-space-4); }
.tabs a { padding: var(--rb-space-2) var(--rb-space-4); color: var(--rb-text-secondary); text-decoration: none; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs a:hover { color: var(--rb-primary); }
.tabs a.active, .tabs a[aria-current="page"] { color: var(--rb-primary); border-bottom-color: var(--rb-accent); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rb-space-2);
  margin: 0;
  padding: 10px 18px;
  min-height: 42px;
  border: 1px solid var(--rb-primary);
  border-radius: var(--rb-radius-sm);
  background: var(--rb-primary);
  color: #fff;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--rb-primary-hover); border-color: var(--rb-primary-hover); color: #fff; }
.btn:focus-visible { box-shadow: var(--rb-focus-ring); border-radius: var(--rb-radius-sm); }
.btn-secondary { background: var(--rb-surface); color: var(--rb-primary); border-color: var(--rb-border-strong); }
.btn-secondary:hover { background: var(--rb-primary-soft); color: var(--rb-primary-hover); border-color: var(--rb-primary); }
.btn-ghost { background: transparent; color: var(--rb-text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--rb-surface-alt); color: var(--rb-primary); border-color: var(--rb-border); }
.btn-danger { background: var(--rb-danger); border-color: var(--rb-danger); color: #fff; }
.btn-danger:hover { background: #8f1c13; border-color: #8f1c13; color: #fff; }
.btn-accent { background: var(--rb-accent-strong); border-color: var(--rb-accent-strong); }
.btn-accent:hover { background: #0f717b; border-color: #0f717b; }
.btn-link { min-height: 0; padding: 6px 8px; background: transparent; border-color: transparent; color: var(--rb-primary); font-weight: 600; }
.btn-link:hover { background: var(--rb-primary-soft); border-color: transparent; color: var(--rb-primary-hover); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: var(--rb-fs-sm); }
.btn-lg { min-height: 50px; padding: 12px 26px; font-size: var(--rb-fs-lg); }
.btn-block { width: 100%; }
.btn-icon { min-height: 40px; width: 40px; padding: 0; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--rb-border); border-color: var(--rb-border); color: var(--rb-text-muted); cursor: not-allowed; }
.btn-logout span, .btn-lang span { font-size: var(--rb-fs-sm); }
.inline-form { display: inline; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: var(--rb-space-2); justify-content: center; margin: var(--rb-space-4) 0 0; }
.panel .actions, .form-card .actions { justify-content: flex-start; }

/* ------------------------------------------------------------------ alerts */
.alert { display: flex; gap: var(--rb-space-2); align-items: flex-start; margin: var(--rb-space-3) 0; padding: var(--rb-space-3) var(--rb-space-4); border: 1px solid transparent; border-radius: var(--rb-radius-sm); text-align: start; }
.alert .ico { margin-top: 0.15em; }
ul.alert { display: block; padding-inline-start: 32px; }
.alert-error, .alert-danger { background: var(--rb-danger-soft); border-color: #f6cfca; color: var(--rb-danger); }
.alert-info { background: var(--rb-info-soft); border-color: #cfe0f3; color: var(--rb-info); }
.alert-success { background: var(--rb-success-soft); border-color: #c6e6d1; color: var(--rb-success); }
.alert-warning { background: var(--rb-warning-soft); border-color: #f2dcb3; color: var(--rb-warning); }
.notice { margin: var(--rb-space-3) 0; padding: var(--rb-space-3) var(--rb-space-4); border-inline-start: 3px solid var(--rb-accent); background: var(--rb-surface-alt); border-radius: var(--rb-radius-sm); color: var(--rb-text-secondary); font-size: var(--rb-fs-sm); }

/* ------------------------------------------------------------------ forms */
.form { display: flex; flex-direction: column; gap: var(--rb-space-1); }
.form label { font-weight: 600; margin-top: var(--rb-space-3); font-size: 0.95rem; }
.form > .btn, .form .form-actions { margin-top: var(--rb-space-4); }
.form input, .form select, .form textarea {
  font: inherit;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid var(--rb-border-strong);
  border-radius: var(--rb-radius-sm);
  background: var(--rb-surface);
  color: var(--rb-text);
  width: 100%;
}
.form textarea { min-height: 88px; }
.form input[type="file"] { padding: 8px; background: var(--rb-surface-alt); }
.form input:hover, .form select:hover, .form textarea:hover { border-color: var(--rb-text-muted); }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--rb-accent-strong); box-shadow: var(--rb-focus-ring); }
.form input[aria-invalid="true"], .form select[aria-invalid="true"] { border-color: var(--rb-danger); }
.form input[type="checkbox"], .form input[type="radio"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--rb-primary); }
.required { color: var(--rb-danger); }
.hint { margin: 2px 0 0; color: var(--rb-text-muted); font-size: var(--rb-fs-sm); }
.field-error { display: flex; gap: 6px; align-items: center; margin: 4px 0 0; color: var(--rb-danger); font-size: var(--rb-fs-sm); font-weight: 600; }
.field-error::before { content: "!"; display: inline-flex; width: 1.15em; height: 1.15em; align-items: center; justify-content: center; border-radius: 50%; background: var(--rb-danger); color: #fff; font-size: 0.75em; flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--rb-space-3); align-items: center; }
.form-actions .btn { margin: 0; }
.form-inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--rb-space-2); margin: var(--rb-space-3) 0; }
.form-inline input, .form-inline select { width: auto; flex: 1 1 180px; }
.form-inline .btn, .form-inline label { margin: 0; }
.filters { padding: var(--rb-space-3); background: var(--rb-surface-alt); border: 1px solid var(--rb-border); border-radius: var(--rb-radius-sm); }
.checks {
  border: 1px solid var(--rb-border);
  border-radius: var(--rb-radius-sm);
  margin: var(--rb-space-4) 0 0;
  padding: var(--rb-space-3) var(--rb-space-4) var(--rb-space-4);
  background: var(--rb-surface-alt);
}
.checks legend { padding: 0 var(--rb-space-2); font-weight: var(--rb-fw-section); color: var(--rb-primary); }
.checks label { display: flex; gap: var(--rb-space-2); align-items: center; font-weight: 400; margin: var(--rb-space-2) 0; }
.checks input { width: auto; margin: 0; }
.inline-check { display: inline-flex; gap: 6px; align-items: center; margin-inline-end: var(--rb-space-3); font-weight: 400; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--rb-space-3); }
.grid-3 label { display: block; }
.narrow-form { max-width: 560px; }
.static-value { margin: 0; padding: 10px 0; font-weight: 600; }
.secret strong { font-family: var(--rb-font-mono); font-size: 1.05rem; letter-spacing: 0.5px; word-break: break-all; }
.secret { padding: var(--rb-space-3); background: var(--rb-surface-alt); border: 1px dashed var(--rb-border-strong); border-radius: var(--rb-radius-sm); }

/* ------------------------------------------------------------------ data display */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--rb-space-2) var(--rb-space-5); margin: var(--rb-space-4) 0; text-align: start; }
.facts dt { color: var(--rb-text-muted); font-size: var(--rb-fs-sm); }
.facts dd { margin: 0; font-weight: 500; }
.muted { color: var(--rb-text-muted); font-size: var(--rb-fs-sm); }
.danger { color: var(--rb-danger); }
.empty { display: flex; gap: var(--rb-space-2); align-items: center; margin: var(--rb-space-2) 0; padding: var(--rb-space-5) var(--rb-space-4); justify-content: center; color: var(--rb-text-muted); background: var(--rb-surface-alt); border: 1px dashed var(--rb-border-strong); border-radius: var(--rb-radius-sm); text-align: center; }
.plain-list { list-style: none; padding: 0; margin: var(--rb-space-2) 0; }
.plain-list li { display: flex; flex-wrap: wrap; gap: var(--rb-space-2); align-items: center; padding: var(--rb-space-2) 0; border-bottom: 1px solid var(--rb-border); }
.plain-list li:last-child { border-bottom: 0; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--rb-border); border-radius: var(--rb-radius-sm); margin: var(--rb-space-2) 0; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--rb-border); vertical-align: middle; }
th { background: var(--rb-surface-alt); color: var(--rb-text-secondary); font-weight: var(--rb-fw-label); font-size: var(--rb-fs-xs); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcfe; }
tr.row-error td { background: var(--rb-danger-soft); }
td .inline-form + .inline-form, td a + .inline-form { margin-inline-start: var(--rb-space-2); }

/* Status badges: text + shape, never colour alone */
.status { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: var(--rb-radius-pill); font-size: var(--rb-fs-xs); font-weight: 700; background: var(--rb-surface-alt); color: var(--rb-text-secondary); border: 1px solid var(--rb-border); white-space: nowrap; vertical-align: middle; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.status-active, .status-current, .status-success { background: var(--rb-success-soft); color: var(--rb-success); border-color: #c6e6d1; }
.status-suspended, .status-inactive, .status-danger { background: var(--rb-danger-soft); color: var(--rb-danger); border-color: #f6cfca; }
.status-inactive::before, .status-suspended::before, .status-danger::before { border-radius: 1px; }
.status-future, .status-info { background: var(--rb-info-soft); color: var(--rb-info); border-color: #cfe0f3; }
.status-future::before, .status-info::before { background: transparent; border: 2px solid currentColor; width: 6px; height: 6px; }
.status-warning { background: var(--rb-warning-soft); color: var(--rb-warning); border-color: #f2dcb3; }
.status-warning::before { border-radius: 0; transform: rotate(45deg); }
.status-past, .status-neutral { background: var(--rb-surface-alt); color: var(--rb-text-muted); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--rb-space-3); margin: var(--rb-space-3) 0; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: var(--rb-space-4); border-radius: var(--rb-radius-sm); background: var(--rb-surface-alt); border: 1px solid var(--rb-border); color: var(--rb-text); text-decoration: none; }
a.stat:hover { border-color: var(--rb-primary); color: var(--rb-text); }
.stat strong { font-size: 1.75rem; line-height: 1.2; color: var(--rb-primary); }
.stat span { color: var(--rb-text-secondary); font-size: var(--rb-fs-sm); }
.stat.ok strong { color: var(--rb-success); }
.stat.bad strong { color: var(--rb-danger); }
.stat.attention { background: var(--rb-warning-soft); border-color: #f2dcb3; }
.stat.attention strong { color: var(--rb-warning); }

/* Danger zone */
.danger-zone { border: 1px solid #f6cfca; border-radius: var(--rb-radius); background: #fffafa; padding: var(--rb-space-4) var(--rb-space-5); margin-bottom: var(--rb-space-4); }
.danger-zone h2 { color: var(--rb-danger); }

img.evidence { display: block; max-width: 100%; height: auto; border: 1px solid var(--rb-border); border-radius: var(--rb-radius-sm); background: var(--rb-surface-alt); }

/* ------------------------------------------------------------------ public event display (dark board) */
.display-body { background: radial-gradient(circle at top, #1d3d66 0%, #0e1f36 55%, #0a1729 100%); color: #f4f7fb; min-height: 100vh; }
.display { max-width: 1280px; margin: 0 auto; padding: var(--rb-space-5) var(--rb-space-5) var(--rb-space-6); }
.display-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--rb-space-4); margin-bottom: var(--rb-space-5); }
.display-head h1 { margin: 0 0 4px; font-size: 2.3rem; color: #fff; }
.display-brand { display: inline-flex; padding: 10px 16px; background: #fff; border-radius: var(--rb-radius); --logo-h: 30px; }
.display-sub { margin: 0; font-size: 1.2rem; color: #c9d6ea; display: flex; flex-wrap: wrap; gap: var(--rb-space-2); align-items: center; }
.display-grade { padding: 2px 12px; border-radius: var(--rb-radius-pill); background: rgba(43, 191, 205, 0.18); color: #8ee6ef; font-weight: 700; }
.display-table { font-size: 1.35rem; border: 0; }
.display-table th { background: transparent; color: #9fb3d1; font-size: 0.95rem; }
.display-table td, .display-table th { border-bottom-color: #24406a; padding: 14px 16px; }
.display-table tbody tr:hover td { background: transparent; }
.display-table tr.muted td { color: #8a9cb8; }
.display-table tr.top-1 td { color: #fff; font-weight: 700; background: rgba(43, 191, 205, 0.14); }
.display-table tr.top-2 td, .display-table tr.top-3 td { color: #fff; font-weight: 600; background: rgba(255, 255, 255, 0.05); }
.display-table td:first-child { width: 4.5em; font-weight: var(--rb-fw-metric); color: #8ee6ef; }
.display-foot { color: #93a6c4; font-size: 0.95rem; margin: var(--rb-space-3) 0 0; }
.display-live { display: inline-flex; align-items: center; gap: 6px; }
.display-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--rb-accent); }
.display-body .status { border-color: transparent; }
.display-body .empty { background: rgba(255, 255, 255, 0.05); border-color: #24406a; color: #c9d6ea; }

/* ------------------------------------------------------------------ page structure (admin) */
.page-head { display: flex; flex-wrap: wrap; gap: var(--rb-space-3); align-items: flex-start; justify-content: space-between; margin: 0 0 var(--rb-space-4); }
.page-head h1 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--rb-space-2); }
.page-head .lede { margin: var(--rb-space-1) 0 0; }
.meta-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--rb-radius-pill); background: var(--rb-primary-soft); color: var(--rb-primary); font-size: var(--rb-fs-xs); font-weight: 700; }
.section-nav { display: flex; flex-wrap: wrap; gap: var(--rb-space-1) var(--rb-space-2); margin: 0 0 var(--rb-space-4); padding: 0; list-style: none; }
.section-nav a { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 12px; border: 1px solid var(--rb-border); border-radius: var(--rb-radius-pill); background: var(--rb-surface); color: var(--rb-text-secondary); font-size: var(--rb-fs-sm); font-weight: 600; text-decoration: none; }
.section-nav a:hover { border-color: var(--rb-primary); color: var(--rb-primary); }
.panel[id], .form-section[id] { scroll-margin-top: 80px; }
.subtle-head { font-size: var(--rb-fs-sm); text-transform: uppercase; letter-spacing: 0.04em; color: var(--rb-text-muted); margin: var(--rb-space-5) 0 var(--rb-space-2); }

/* Attention-first dashboards */
.attention { display: grid; gap: var(--rb-space-2); margin: 0 0 var(--rb-space-4); padding: 0; list-style: none; }
.attention-item { display: flex; gap: var(--rb-space-3); align-items: center; height: 100%; padding: var(--rb-space-3) var(--rb-space-4); border: 1px solid var(--rb-border); border-inline-start: 4px solid var(--rb-warning); border-radius: var(--rb-radius-sm); background: var(--rb-surface); color: var(--rb-text); text-decoration: none; }
a.attention-item:hover { border-color: var(--rb-primary); color: var(--rb-text); }
.attention-item > .ico { flex: none; width: 1.4em; height: 1.4em; color: var(--rb-warning); }
.attention-item.is-info { border-inline-start-color: var(--rb-info); }
.attention-item.is-info > .ico { color: var(--rb-info); }
.attention-item.is-ok { border-inline-start-color: var(--rb-success); }
.attention-item.is-ok > .ico { color: var(--rb-success); }
.attention-body { flex: 1; min-width: 0; }
.attention-body strong { display: block; }
.attention-body span { color: var(--rb-text-secondary); font-size: var(--rb-fs-sm); }
.attention-item > .ico-dir { flex: none; width: 1em; height: 1em; color: var(--rb-text-muted); }

/* Form sections */
.form-section { border: 1px solid var(--rb-border); border-radius: var(--rb-radius); margin: var(--rb-space-4) 0 0; padding: var(--rb-space-4) var(--rb-space-5) var(--rb-space-5); background: var(--rb-surface); }
.form-section-title { display: flex; align-items: center; gap: var(--rb-space-2); margin: 0 0 var(--rb-space-1); font-size: 1.05rem; color: var(--rb-primary); }
.panel .form-section-title { font-size: 1.05rem; margin: 0 0 var(--rb-space-1); }
.form-section-title .num { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--rb-primary-soft); color: var(--rb-primary); font-size: var(--rb-fs-xs); }
.form-section .checks { border: 0; background: transparent; padding: 0; margin: var(--rb-space-3) 0 0; }
.form-section .checks legend { padding: 0; font-size: 0.95rem; color: var(--rb-text); }
.form-section > label:first-of-type { margin-top: var(--rb-space-2); }
.form-section label { display: block; }
.form-section .checks label { display: flex; }
.form-section .inline-check, .form-section .checks .inline-check { display: inline-flex; margin-block: var(--rb-space-1); }
.form-sticky-actions { position: sticky; bottom: 0; z-index: 2; margin-top: var(--rb-space-5); padding: var(--rb-space-3) 0; background: linear-gradient(to top, var(--rb-surface) 75%, transparent); }
.panel.form-panel { max-width: 860px; }

/* Process steps (import, promotions, attempts) */
.steps { display: flex; flex-wrap: wrap; gap: var(--rb-space-2); margin: 0 0 var(--rb-space-4); padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: var(--rb-space-2); padding-block: 6px; padding-inline: 8px 14px; border-radius: var(--rb-radius-pill); background: var(--rb-surface-alt); border: 1px solid var(--rb-border); color: var(--rb-text-muted); font-size: var(--rb-fs-sm); font-weight: 600; }
.steps li::before { content: counter(step); display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--rb-surface); border: 1px solid var(--rb-border-strong); font-size: var(--rb-fs-xs); }
.steps li.is-done { color: var(--rb-success); border-color: #c6e6d1; background: var(--rb-success-soft); }
.steps li.is-done::before { content: "\2713"; background: var(--rb-success); border-color: var(--rb-success); color: #fff; }
.steps li.is-current { color: var(--rb-primary); border-color: var(--rb-primary); background: var(--rb-primary-soft); }
.steps li.is-current::before { background: var(--rb-primary); border-color: var(--rb-primary); color: #fff; }

/* Two-column layouts */
.split { display: grid; gap: var(--rb-space-4); margin-bottom: var(--rb-space-4); }
.split > * { min-width: 0; }
.split > .panel { margin-bottom: 0; }

/* Status card (settings) */
.status-card { display: flex; gap: var(--rb-space-4); align-items: flex-start; padding: var(--rb-space-4); border: 1px solid var(--rb-border); border-radius: var(--rb-radius); background: var(--rb-surface-alt); margin: 0 0 var(--rb-space-4); }
.status-card > .ico { flex: none; width: 2.25rem; height: 2.25rem; padding: 7px; border-radius: 50%; background: var(--rb-primary-soft); color: var(--rb-primary); }
.status-card.is-ok > .ico { background: var(--rb-success-soft); color: var(--rb-success); }
.status-card.is-warn > .ico { background: var(--rb-warning-soft); color: var(--rb-warning); }
.status-card.is-bad > .ico { background: var(--rb-danger-soft); color: var(--rb-danger); }
.status-card h2 { margin: 0 0 var(--rb-space-1); font-size: 1.05rem; }
.status-card .facts { margin: var(--rb-space-2) 0 0; }

/* Per-action counts */
.count-pills { display: flex; flex-wrap: wrap; gap: var(--rb-space-2); margin: var(--rb-space-2) 0 var(--rb-space-3); padding: 0; list-style: none; }
.count-pills li { display: inline-flex; gap: 6px; align-items: center; padding: 4px 12px; border-radius: var(--rb-radius-pill); background: var(--rb-surface-alt); border: 1px solid var(--rb-border); font-size: var(--rb-fs-sm); }
.count-pills strong { color: var(--rb-primary); }

/* Responsive tables: stacked cards on phones (labels come from data-label) */
@media (max-width: 599px) {
  .table-cards { border: 0; overflow: visible; }
  .table-cards table, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-cards tr { margin: 0 0 var(--rb-space-3); padding: var(--rb-space-2) var(--rb-space-3); border: 1px solid var(--rb-border); border-radius: var(--rb-radius-sm); background: var(--rb-surface); }
  .table-cards tbody tr:hover td { background: transparent; }
  .table-cards td { display: flex; flex-wrap: wrap; gap: var(--rb-space-1) var(--rb-space-3); justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--rb-border); text-align: end; }
  .table-cards tbody tr:last-child td { border-bottom: 1px solid var(--rb-border); }
  .table-cards tbody tr td:last-child { border-bottom: 0; }
  .table-cards td[data-label]::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--rb-text-muted); font-size: var(--rb-fs-xs); font-weight: 700; text-align: start; }
  .table-cards td:first-child { font-weight: var(--rb-fw-label); font-size: 1rem; }
  .table-cards td:empty { display: none; }
  .table-cards tr.row-error { border-color: #f6cfca; background: var(--rb-danger-soft); }
  .table-cards tr.row-error td { background: transparent; }
  .form-section { padding: var(--rb-space-3) var(--rb-space-4) var(--rb-space-4); }
  .status-card { flex-direction: column; }
}

@media (min-width: 1024px) {
  .split { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); align-items: start; }
  .split-sticky { position: sticky; top: 84px; }
  .attention { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
}

/* Fieldset sections: the legend sits inside the card like a heading */
fieldset.form-section { min-width: 0; }
fieldset.form-section > legend { float: left; width: 100%; padding: 0; margin: 0 0 var(--rb-space-1); }
[dir="rtl"] fieldset.form-section > legend { float: right; }
fieldset.form-section > legend ~ * { clear: both; }

/* Disclosures (secondary details, extra filters) */
.disclosure { margin: var(--rb-space-3) 0; }
.disclosure > summary, .filter-more > summary { cursor: pointer; display: inline-flex; align-items: center; gap: var(--rb-space-1); min-height: 36px; color: var(--rb-primary); font-weight: 600; font-size: var(--rb-fs-sm); }
.disclosure > summary:focus-visible, .filter-more > summary:focus-visible { outline: none; box-shadow: var(--rb-focus-ring); border-radius: var(--rb-radius-sm); }
.disclosure[open] > summary { margin-bottom: var(--rb-space-2); }
.filter-more { flex: 1 1 100%; order: 10; }
.filter-more-body { display: flex; flex-wrap: wrap; gap: var(--rb-space-2); margin-top: var(--rb-space-2); }
.filter-more-body select { flex: 1 1 180px; width: auto; }
.filters .btn { order: 5; }

/* Small destructive text button */
.btn.danger, .btn-ghost.danger { color: var(--rb-danger); }
.btn-ghost.danger:hover { background: var(--rb-danger-soft); }
.danger-zone h3 { margin: var(--rb-space-4) 0 var(--rb-space-1); font-size: 1rem; }
.danger-zone .form { max-width: 560px; }
.date-range { white-space: normal; }
.date-range-sep { color: var(--rb-text-muted); }
.count-pills li.status-warning { background: var(--rb-warning-soft); border-color: #f2dcb3; color: var(--rb-warning); }
.count-pills li.status-warning strong { color: var(--rb-warning); }

/* ------------------------------------------------------------------ student experience */
.hero-panel h1 { margin-bottom: var(--rb-space-2); }
.meta-line { display: flex; flex-wrap: wrap; gap: var(--rb-space-2) var(--rb-space-4); margin: 0 0 var(--rb-space-3); padding: 0; list-style: none; color: var(--rb-text-secondary); font-size: var(--rb-fs-sm); }
.meta-line li { display: inline-flex; align-items: center; gap: 6px; }
.cta-box { margin: var(--rb-space-3) 0; padding: var(--rb-space-4) var(--rb-space-5); border: 1px solid var(--rb-border); border-inline-start: 4px solid var(--rb-accent); border-radius: var(--rb-radius); background: var(--rb-surface-alt); }
.cta-box h2 { font-size: 1.1rem; margin: 0 0 var(--rb-space-1); }
.cta-box .actions { justify-content: flex-start; margin-top: var(--rb-space-2); }
.cta-box h2 + .hint { margin-bottom: var(--rb-space-2); }
.start-form { margin: var(--rb-space-2) 0; }
.lang-choice { display: flex; flex-wrap: wrap; gap: var(--rb-space-1) var(--rb-space-2); border: 0; margin: 0; padding: 0; min-width: 0; }
.lang-choice .inline-check { min-height: 44px; padding: 0 var(--rb-space-3); border: 1px solid var(--rb-border-strong); border-radius: var(--rb-radius-sm); background: var(--rb-surface); margin: 0; }
.lang-choice .inline-check:has(input:checked) { border-color: var(--rb-primary); background: var(--rb-primary-soft); color: var(--rb-primary); font-weight: 600; }
.panel-secondary { background: var(--rb-surface-alt); box-shadow: none; }
.panel-secondary h2 { font-size: 1.05rem; }

/* Rank cards: two per row on phones */
.rank-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rank-cards .stat strong { font-size: 1.6rem; }

/* Cards (assignments, events, progress) */
.card-grid { display: grid; grid-template-columns: 1fr; gap: var(--rb-space-3); margin: 0; padding: 0; list-style: none; }
.training-card, .progress-card { position: relative; display: flex; flex-direction: column; gap: var(--rb-space-2); padding: var(--rb-space-4); border: 1px solid var(--rb-border); border-radius: var(--rb-radius); background: var(--rb-surface); box-shadow: var(--rb-shadow); }
.training-card:hover { border-color: var(--rb-primary); }
.training-card:focus-within { box-shadow: var(--rb-focus-ring); }
.training-card-top { display: flex; justify-content: space-between; align-items: center; gap: var(--rb-space-2); }
.training-kind { display: inline-flex; align-items: center; gap: 6px; color: var(--rb-accent-strong); font-size: var(--rb-fs-xs); font-weight: var(--rb-fw-label); text-transform: uppercase; letter-spacing: 0.03em; }
.training-card-event .training-kind { color: var(--rb-primary); }
.training-card h3, .progress-card h3 { margin: 0; font-size: 1.08rem; line-height: 1.4; }
.training-card h3 a { color: var(--rb-text); text-decoration: none; }
.training-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--rb-radius); }
.training-card h3 a:focus-visible { outline: none; }
.training-card .muted { margin: 0; }
.training-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; color: var(--rb-text-secondary); font-size: var(--rb-fs-sm); }
.training-cta { margin: auto 0 0; }

/* Attempts list */
.attempt-list { display: grid; gap: var(--rb-space-2); margin: 0; padding: 0; list-style: none; }
.attempt-item { display: flex; align-items: center; gap: var(--rb-space-3); padding: var(--rb-space-3); border: 1px solid var(--rb-border); border-radius: var(--rb-radius-sm); background: var(--rb-surface); color: var(--rb-text); text-decoration: none; }
.attempt-item:hover { border-color: var(--rb-primary); color: var(--rb-text); }
.attempt-no { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--rb-primary-soft); color: var(--rb-primary); font-weight: 700; }
.attempt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.attempt-side { display: flex; flex-wrap: wrap; gap: var(--rb-space-1); align-items: center; justify-content: flex-end; }
.attempt-score { font-weight: var(--rb-fw-metric); font-size: 1.1rem; color: var(--rb-primary); }
/* D-051: a captured (not yet approved) score — deliberately unlike the approved .attempt-score. */
.attempt-captured { font-size: var(--rb-fs-sm); color: var(--rb-text-muted); border: 1px dashed var(--rb-border); border-radius: var(--rb-radius-sm); padding: 1px 8px; white-space: nowrap; }
.captured-result { margin: var(--rb-space-2) 0; }
/* D-066: Browser Reader first-use gate on the attempt page. */
.reader-gate { margin: var(--rb-space-3) 0; }
.gate-box { border: 1px solid var(--rb-border); border-radius: var(--rb-radius-sm); padding: var(--rb-space-3) var(--rb-space-4); margin: var(--rb-space-2) 0; background: var(--rb-surface, #fff); }
.gate-box p { margin: var(--rb-space-1) 0; }
.gate-title { display: flex; align-items: center; gap: var(--rb-space-2); }
.verified-by { display: inline-block; margin-inline-start: var(--rb-space-1, .25rem); }
.attempt-item > .ico-dir { flex: none; color: var(--rb-text-muted); }

/* Attempt page */
.step-block { margin: var(--rb-space-5) 0 0; }
.step-block h2 { display: flex; align-items: center; gap: var(--rb-space-2); font-size: 1.1rem; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--rb-primary); color: #fff; font-size: var(--rb-fs-sm); }
.step-block .actions { justify-content: flex-start; }
.upload-zone { display: flex; flex-direction: column; align-items: center; gap: var(--rb-space-2); padding: var(--rb-space-5) var(--rb-space-4); border: 2px dashed var(--rb-accent); border-radius: var(--rb-radius); background: var(--rb-accent-soft); text-align: center; }
.upload-zone > .ico { width: 2.2rem; height: 2.2rem; color: var(--rb-accent-strong); }
.upload-zone label { margin: 0; font-size: 1.05rem; }
.upload-zone input[type="file"] { max-width: 420px; background: var(--rb-surface); }
.upload-zone.has-error { border-color: var(--rb-danger); background: var(--rb-danger-soft); }
.result-box { display: flex; gap: var(--rb-space-3); align-items: flex-start; margin: var(--rb-space-3) 0; padding: var(--rb-space-4); border-radius: var(--rb-radius); border: 1px solid var(--rb-border); }
.result-box > .ico { flex: none; width: 2rem; height: 2rem; }
.result-box p { margin: 0; }
.result-label { font-weight: 700; font-size: 1.1rem; }
.result-score strong { font-size: 1.6rem; }
.result-box.is-ok { background: var(--rb-success-soft); border-color: #c6e6d1; color: var(--rb-success); }
.result-box.is-bad { background: var(--rb-danger-soft); border-color: #f6cfca; color: var(--rb-danger); }
.result-box.is-wait { background: var(--rb-warning-soft); border-color: #f2dcb3; color: var(--rb-warning); }
.result-box .hint { color: var(--rb-text-secondary); }
[dir="rtl"] .ico-dir.ico-back { transform: none; }
.ico-back { transform: scaleX(-1); }

/* Progress */
.score-steps { display: flex; flex-wrap: wrap; gap: var(--rb-space-2); margin: 0; padding: 0; list-style: none; }
.score-steps li { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: var(--rb-radius-sm); background: var(--rb-surface-alt); border: 1px solid var(--rb-border); }
.delta { font-weight: 700; font-size: var(--rb-fs-sm); }
.delta-up { color: var(--rb-success); }
.delta-down { color: var(--rb-danger); }
.delta-flat { color: var(--rb-text-muted); }

/* Public display additions */
.display-logo-bg { display: block; height: 30px; width: calc(30px * var(--rb-logo-ratio)); max-width: 60vw; background: url("/images/robocodia-logo.png") 50% 50.7% / cover no-repeat; }
.display-status { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--rb-space-3); margin-top: var(--rb-space-4); color: #93a6c4; font-size: 0.95rem; }
.display-table tr.top-1 td:first-child { color: #ffd76a; }
.display-table tr.top-2 td:first-child { color: #e3e9f2; }
.display-table tr.top-3 td:first-child { color: #f0b98a; }

@media (min-width: 600px) {
  .rank-cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 599px) {
  .cta-box { padding: var(--rb-space-3) var(--rb-space-4); }
  .start-form .btn { width: 100%; }
  .attempt-item { flex-wrap: wrap; }
  .attempt-side { width: 100%; justify-content: flex-start; padding-inline-start: 44px; }
  .attempt-item > .ico-dir { display: none; }
  .display-logo-bg { height: 22px; width: calc(22px * var(--rb-logo-ratio)); }
}

/* Training videos (secondary list) */
.video-list { display: grid; gap: var(--rb-space-2); margin: 0 0 var(--rb-space-2); padding: 0; list-style: none; }
.video-item { display: flex; align-items: center; gap: var(--rb-space-3); padding: var(--rb-space-2) var(--rb-space-3); border: 1px solid var(--rb-border); border-radius: var(--rb-radius-sm); background: var(--rb-surface); color: var(--rb-text); text-decoration: none; }
.video-item:hover { border-color: var(--rb-primary); color: var(--rb-text); }
.video-item > .ico { flex: none; color: var(--rb-primary); }
.video-item > .ico:last-of-type { color: var(--rb-text-muted); }
.video-item > span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.video-item strong { font-weight: 600; }
/* Disclosure marker */
.disclosure > summary { list-style: none; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "+"; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid currentColor; font-size: 0.9rem; line-height: 1; }
.disclosure[open] > summary::before { content: "\2212"; }

.video-item { position: relative; }
.video-item:focus-within { box-shadow: var(--rb-focus-ring); }
.video-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.video-body a { color: var(--rb-text); font-weight: 600; text-decoration: none; }
.video-body a::after { content: ""; position: absolute; inset: 0; border-radius: var(--rb-radius-sm); }
.video-body a:focus-visible { outline: none; }

/* ------------------------------------------------------------------ Phase 4 polish */
.training-note { flex-basis: 100%; }
[dir="auto"] { unicode-bidi: plaintext; }
h1[dir="auto"], h3 [dir="auto"], .training-card h3 a { text-align: start; }
.panel-head h1[dir="auto"] { display: block; }
@media (max-width: 599px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--rb-space-2); }
  .stat { padding: var(--rb-space-3); }
  .stat strong { font-size: 1.45rem; }
  .page-head { margin-bottom: var(--rb-space-3); }
  .section-nav a { min-height: 40px; }
}
@media (max-width: 380px) {
  .app-header { gap: var(--rb-space-1); }
  .steps li { font-size: var(--rb-fs-xs); }
}

/* Public display: the leaderboard scrolls inside its own box, never the page */
.display-table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.display-head > div { min-width: 0; }
.display-head h1 { overflow-wrap: anywhere; }
@media (max-width: 599px) {
  .display { padding: var(--rb-space-4) var(--rb-space-3) var(--rb-space-5); }
  .display-head { gap: var(--rb-space-3); margin-bottom: var(--rb-space-4); }
  .display-sub { font-size: 1rem; }
  .display-table { font-size: 0.98rem; }
  .display-table td, .display-table th { padding: 10px 8px; }
  .display-table td:first-child { width: 2.6em; }
  .display-table td:nth-child(2) { min-width: 8.5em; }
  .display-table th { white-space: normal; }
  .display-brand { padding: 8px 12px; }
}

/* ------------------------------------------------------------------ imports (D-041) */
.callout { display: flex; flex-wrap: wrap; gap: var(--rb-space-3) var(--rb-space-5); align-items: center; justify-content: space-between; margin: 0 0 var(--rb-space-4); padding: var(--rb-space-4) var(--rb-space-5); border: 1px solid var(--rb-border); border-inline-start: 4px solid var(--rb-accent); border-radius: var(--rb-radius); background: var(--rb-surface-alt); }
.callout h2 { margin: 0 0 2px; font-size: 1.05rem; }
.callout .hint { margin: 0; max-width: 60ch; }
.column-list { display: grid; gap: 6px; margin: 0 0 var(--rb-space-3); padding: 0; list-style: none; }
.column-list li { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.column-list code { padding: 1px 8px; border-radius: var(--rb-radius-sm); background: var(--rb-primary-soft); color: var(--rb-primary); font-family: var(--rb-font-mono); font-size: var(--rb-fs-sm); }
.required-tag { padding: 0 8px; border-radius: var(--rb-radius-pill); background: var(--rb-warning-soft); color: var(--rb-warning); font-size: var(--rb-fs-xs); font-weight: 600; }
.status-line { margin: 0 0 var(--rb-space-2); }

/* ------------------------------------------------------------------ form system polish (pre-launch)
   One rhythm for every form (RTL + LTR): label 16px above its control, hint 4px below,
   44px controls, one select style, explicit disabled / invalid / focus states. */
.form label { margin-top: var(--rb-space-4); margin-bottom: 2px; font-weight: var(--rb-fw-label); color: var(--rb-text); }
.form .hint { margin-top: 4px; line-height: 1.55; }
.form select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("/images/select-chevron.svg");
  background-repeat: no-repeat;
  background-size: 16px 16px;
  background-position: right 12px center;
  padding-inline-end: 40px;
  cursor: pointer;
  text-overflow: ellipsis;
}
[dir="rtl"] .form select { background-position: left 12px center; }
.form select[multiple] { background-image: none; padding-inline-end: 12px; }
/* Native option lists always show dark text on a light background (no grey/blank rows). */
.form select option { color: var(--rb-text); background-color: var(--rb-surface); }
.form select option[value=""] { color: var(--rb-text-secondary); }
.form input::placeholder, .form textarea::placeholder { color: var(--rb-text-muted); opacity: 1; }
.form input:disabled, .form select:disabled, .form textarea:disabled {
  background-color: var(--rb-surface-alt);
  color: var(--rb-text-muted);
  border-style: dashed;
  cursor: not-allowed;
  opacity: 1;
}
.form input[aria-invalid="true"], .form select[aria-invalid="true"], .form textarea[aria-invalid="true"] { border-color: var(--rb-danger); background-color: #fffafa; }
.form input[aria-invalid="true"]:focus, .form select[aria-invalid="true"]:focus, .form textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.22); }
.required { margin-inline-start: 2px; color: var(--rb-danger); font-weight: var(--rb-fw-label); }
.form-section .grid-3 > div > label:first-child { margin-top: var(--rb-space-3); }
.static-value { padding: 8px 0 0; }

/* Quieter weights for chips and pills (Cairo reads heavier than system fonts). */
.status, .meta-chip { font-weight: var(--rb-fw-label); }
.result-label { font-weight: var(--rb-fw-section); }
.display-table tr.top-1 td { font-weight: var(--rb-fw-metric); }

/* Navigation density */
.nav-link { padding-block: 8px; }
.side-nav .nav-group + .nav-group { margin-top: var(--rb-space-3); }

/* ------------------------------------------------------------------ SaaS density pass (pre-launch)
   Cards: white surface, hairline border, soft shadow. Metrics: compact tiles that fit
   five per row on desktop. Tables: calmer headers, consistent row actions. */
.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--rb-space-3); }
.stat {
  gap: 4px;
  padding: 14px 16px;
  background: var(--rb-surface);
  box-shadow: var(--rb-shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
a.stat:hover { border-color: var(--rb-accent); box-shadow: 0 4px 14px rgba(21, 35, 58, 0.08); }
.stat strong { order: 2; font-size: 1.6rem; line-height: 1.15; font-weight: var(--rb-fw-metric); }
.stat span { order: 1; font-size: var(--rb-fs-sm); font-weight: var(--rb-fw-medium); line-height: 1.4; }
.stat.attention { box-shadow: none; }
.subtle-head { margin-top: var(--rb-space-4); }

/* Panels / cards */
.panel { box-shadow: 0 1px 2px rgba(21, 35, 58, 0.05); }
.panel + .panel, .split + .panel { margin-top: 0; }
.panel h2 { font-size: 1.12rem; }
.panel-head { margin-bottom: var(--rb-space-4); }
.training-card, .progress-card, .attention-item { transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.training-card:hover, a.attention-item:hover { box-shadow: 0 4px 14px rgba(21, 35, 58, 0.08); }

/* Tables */
th { text-transform: none; letter-spacing: 0; font-size: var(--rb-fs-sm); padding-block: 9px; }
td { padding-block: 11px; }
tbody tr:hover td { background: var(--rb-surface-alt); }
td.row-actions { gap: var(--rb-space-1); white-space: nowrap; }
td.row-actions a, td .btn-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: var(--rb-radius-sm);
  color: var(--rb-primary);
  font-weight: var(--rb-fw-label);
  font-size: var(--rb-fs-sm);
  text-decoration: none;
}
td.row-actions a:hover, td .btn-link:hover { background: var(--rb-primary-soft); }

/* Lists */
.plain-list li { padding: 10px 0; }

/* Result upload: paste / drop preview (public/js/evidence-upload.js) */
.upload-zone.is-dragover { border-style: solid; border-color: var(--rb-primary); background: var(--rb-primary-soft); }
.upload-status { margin: 0; min-height: 1.4em; font-size: var(--rb-fs-sm); color: var(--rb-success); }
.upload-status.field-error { color: var(--rb-danger); }
.upload-preview { display: flex; flex-direction: column; align-items: center; gap: var(--rb-space-2); margin-top: var(--rb-space-2); }
.upload-preview[hidden] { display: none; }
.upload-preview img { display: block; max-width: min(100%, 360px); max-height: 240px; border: 1px solid var(--rb-border); border-radius: var(--rb-radius-sm); background: var(--rb-surface); }
.upload-name { font-size: var(--rb-fs-sm); color: var(--rb-text-secondary); word-break: break-all; }

/* ------------------------------------------------------------------ breakpoints */
@media (max-width: 599px) {
  .panel { padding: var(--rb-space-4); border-radius: var(--rb-radius-sm); }
  .page-wide { padding: var(--rb-space-3) var(--rb-space-3); }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: var(--rb-space-2); }
  .user-name, .role-chip { display: none; }
  .btn-logout span, .btn-lang span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .card { padding: var(--rb-space-5) var(--rb-space-4); }
  h1, .panel h1 { font-size: 1.3rem; }
  .landing h1 { font-size: 1.55rem; }
  .form-inline input, .form-inline select { flex-basis: 100%; }
  .display-head h1 { font-size: 1.6rem; }
  .display-table { font-size: 1.05rem; }
}

@media (min-width: 768px) {
  .student-tabs { position: static; display: flex; gap: var(--rb-space-1); border: 0; box-shadow: none; padding: 0; background: transparent; margin-inline-start: var(--rb-space-4); }
  .student-tab { flex-direction: row; gap: var(--rb-space-2); min-height: 40px; padding: 8px 14px; border-radius: var(--rb-radius-sm); font-size: 0.92rem; }
  .student-tab .ico { width: 1.15em; height: 1.15em; }
  .student-tab:hover { background: var(--rb-surface-alt); color: var(--rb-primary); }
  .student-tab.active { background: var(--rb-primary-soft); box-shadow: none; }
  .shell-student .app-main { padding-bottom: 0; }
  .app-header { --logo-h: 22px; padding: var(--rb-space-2) var(--rb-space-5); }
  .page-wide { padding: var(--rb-space-5); }
}

@media (min-width: 1024px) {
  .shell-admin .app { display: grid; grid-template-columns: var(--rb-sidebar) minmax(0, 1fr); }
  .sidebar {
    display: block;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: var(--rb-space-5) var(--rb-space-3);
    background: var(--rb-surface);
    border-inline-end: 1px solid var(--rb-border);
    --logo-h: 24px;
  }
  .sidebar .logo { padding: 0 var(--rb-space-3); }
  .product-name { margin: var(--rb-space-2) 0 var(--rb-space-5); padding: 0 var(--rb-space-3); font-size: var(--rb-fs-xs); font-weight: 600; color: var(--rb-accent-strong); }
  .shell-admin .mobile-nav, .shell-admin .logo-header { display: none; }
  .page-wide { padding: var(--rb-space-6) var(--rb-space-6); }
}

@media (min-width: 1280px) {
  :root { --rb-sidebar: 272px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .sidebar, .app-header, .student-tabs, .app-footer, .skip-link { display: none !important; }
  .panel { box-shadow: none; border: 0; }
}

/* Published ranking board (D-045): table on wide screens, cards on phones */
.rank-board .cell-name { font-weight: 700; }
@media (max-width: 599px) {
  .display .rank-board.table-cards tr { display: flex; flex-direction: column; background: rgba(255, 255, 255, 0.05); border-color: #24406a; color: #f4f7fb; }
  .display .rank-board.table-cards td { border-bottom-color: #24406a; font-size: 1rem; }
  .display .rank-board.table-cards td[data-label]::before { color: #9fb3d1; }
  .display .rank-board .cell-name { order: -2; font-size: 1.15rem; }
  .display .rank-board .cell-pos { order: -3; }
  .display .rank-board .cell-score { font-size: 1.1rem; font-weight: 700; }
  .display .rank-board .display-table { font-size: 1rem; }
}

/* Student "My Position" (D-045) */
.my-position .position-head p { margin: 0 0 2px; }
.my-position .position-name { font-size: 1.15rem; }
.my-position .position-score { margin-top: var(--rb-space-2); font-size: 1.05rem; }
.my-position .position-score strong { font-size: 1.6rem; color: var(--rb-primary); }
.my-position .rank-cards { margin-top: var(--rb-space-3); }

/* Bulk student actions and lifecycle impact tables (D-046) */
.bulk-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--rb-space-2) var(--rb-space-3); padding: var(--rb-space-3); margin: var(--rb-space-3) 0; border: 1px solid var(--rb-border); border-radius: var(--rb-radius-sm); background: var(--rb-surface-alt); }
.bulk-toolbar label { margin: 0; font-weight: 600; }
.bulk-toolbar select { width: auto; min-width: 12rem; }
.inline-fieldset { display: flex; flex-wrap: wrap; gap: var(--rb-space-2); border: 0; padding: 0; margin: 0; }
.col-check { width: 2.5rem; text-align: center; }
.col-check input { width: 18px; height: 18px; }
.facts-table { width: auto; min-width: 18rem; margin: var(--rb-space-2) 0 var(--rb-space-4); }
.facts-table th { font-weight: 600; text-align: start; padding-inline-end: var(--rb-space-5); }
.facts-table td { font-weight: 700; }
@media (max-width: 599px) {
  .bulk-toolbar select { min-width: 0; width: 100%; }
  .table-cards td.col-check { justify-content: flex-start; }
}
/* ===== Teachers (D-047) ===== */
.pager { display: flex; align-items: center; gap: var(--rb-space-3); margin-top: var(--rb-space-4); }
.class-list .muted { font-size: .9em; }
/* ===== School branding (D-049): secondary to the Robocodia logo ===== */
.school-brand { display: inline-flex; align-items: center; gap: var(--rb-space-2); padding-inline-start: var(--rb-space-3); margin-inline-start: var(--rb-space-2); border-inline-start: 1px solid var(--rb-border); min-width: 0; }
.school-brand-logo { max-height: 36px; max-width: 140px; width: auto; height: auto; object-fit: contain; flex: none; }
.school-brand-name { font-size: .9rem; color: var(--rb-muted, #5f6b7a); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 599px) { .school-brand-name { display: none; } .school-brand-logo { max-height: 28px; max-width: 96px; } }
.school-logo-preview { display: block; max-height: 96px; max-width: 280px; width: auto; height: auto; object-fit: contain; background: repeating-conic-gradient(#eef1f4 0% 25%, #fff 0% 50%) 50% / 16px 16px; border: 1px solid var(--rb-border); border-radius: var(--rb-radius-sm); padding: 6px; }
.logo-manage { display: grid; gap: var(--rb-space-4); grid-template-columns: 1fr; }
@media (min-width: 720px) { .logo-manage { grid-template-columns: 1fr 1fr; } }
.display-school-logo { max-height: 48px; max-width: 180px; width: auto; height: auto; object-fit: contain; }
@media (max-width: 599px) { .display-school-logo { max-height: 32px; max-width: 120px; } }
.display-brand:has(.display-school-logo) { align-items: center; gap: 14px; }
