/* =====================================================================
   TecRoot LMS: app-specific additions on top of tecroot-ui.css.
   Only classes the design-system component layer does not cover
   (LMS widgets, third-party pickers). Tokens and logical properties only,
   so light/dark and LTR/RTL work without per-theme rules.
   ===================================================================== */

/* ---------- Minds Academy brand (2026-10-15) ----------
   The logo's amber (#FCAA17) replaces the TecRoot blue. Amber is too light for white text, so text ON it
   uses a dark ink (--tc-on-primary) and text IN brand colour uses a deeper amber (--tc-link, 5:1 on white).
   Neutrals turn warm-charcoal to sit with the amber; status colours keep their meaning. */
:root, [data-bs-theme="light"] {
  --tc-primary: #FCAA17;
  --tc-primary-hover: #EE9C0A;
  --tc-primary-active: #D98A00;
  --tc-on-primary: #1F1400;
  --tc-primary-soft: #FFF4DC;
  --tc-primary-soft-2: #FFF8EA;
  --tc-primary-border: #FBD88F;
  --tc-primary-bright: #FFC04D;
  --tc-link: #A35F00;
  --tc-focus: #E8960A;
  --tc-accent: #F08A00;
  --tc-accent-strong: #8A4B00;
  --tc-accent-soft: #FFF0DC;
  --tc-brand-grad-start: #FFC44D;
  --tc-brand-grad-end: #F39200;
  --tc-logo-start: #FDBA3A;
  --tc-logo-end: #F29A0C;
  --tc-brand-ink: #D88A00;
  --tc-inverse-bg: #1C1A17;
  --tc-viz-1: #F2A012;
  --tc-viz-2: #3B82F6;
  --tc-viz-line: #F2A012;
  --shadow-primary: 0 3px 12px rgba(242, 150, 10, 0.32);
}
[data-bs-theme="dark"] {
  --tc-primary: #FFB53D;
  --tc-primary-hover: #FFC261;
  --tc-primary-active: #F2A012;
  --tc-on-primary: #1F1400;
  --tc-primary-soft: #3A2A0C;
  --tc-primary-soft-2: #2E220B;
  --tc-primary-border: #6B4A12;
  --tc-primary-bright: #FFC966;
  --tc-link: #FFC266;
  --tc-focus: #FFC266;
  --tc-accent: #FFA03D;
  --tc-accent-strong: #FFB866;
  --tc-accent-soft: #3A250C;
  --tc-brand-grad-start: #FFC44D;
  --tc-brand-grad-end: #F39200;
  --tc-logo-start: #FDBA3A;
  --tc-logo-end: #F29A0C;
  --tc-brand-ink: #FFC266;
  --tc-bg: #12110F;
  --tc-surface: #1A1816;
  --tc-surface-2: #211F1C;
  --tc-surface-3: #2A2724;
  --tc-border: #34302B;
  --tc-border-strong: #423D37;
  --tc-border-control: #6B645B;
  --tc-text: #F4F1EC;
  --tc-text-2: #E2DDD5;
  --tc-text-3: #C4BDB2;
  --tc-muted: #A59D92;
  --tc-subtle: #968E83;
  --tc-placeholder: #7A7268;
  --tc-sidebar-bg: #161412;
  --tc-sidebar-border: #2A2622;
  --tc-inverse-bg: #F4F1EC;
  --tc-on-inverse: #1A1816;
  --tc-viz-1: #FFB53D;
  --tc-viz-2: #60A5FA;
  --tc-viz-line: #FFB53D;
  --shadow-primary: 0 3px 12px rgba(255, 181, 61, 0.30);
}
/* Initials avatars sit on the amber gradient: dark ink reads, white does not. */
.avatar-initials { color: var(--tc-on-primary); }
code { color: var(--tc-link); }
/* The logo carries the name: the full logo stands alone (no extra text next to it). */
.brand-logo-full { width: auto; height: 40px; border-radius: 0; }
.sidebar-brand .brand-logo-full { width: auto; height: 46px; max-width: 190px; object-fit: contain; }
.auth-logo .brand-logo-full { width: auto; height: 120px; max-width: 100%; border-radius: 0; }
.auth-logo-sm .brand-logo-full { width: auto; height: 52px; }
/* Sign-in brand panel: charcoal with amber light instead of navy with teal/blue. */
.auth-brand { background: #1C1A17; }
.auth-brand::before { background:
  radial-gradient(520px 360px at 12% 8%, rgba(252, 170, 23, .30), transparent 70%),
  radial-gradient(560px 420px at 92% 96%, rgba(243, 146, 0, .26), transparent 70%); }
.auth-brand .eyebrow { color: #FFC266; }

/* ---------- Bootstrap colour utilities → design tokens ----------
   Bootstrap builds these from its own --bs-*-rgb values; point them at the
   TecRoot palette (and the runtime brand colour) instead. */
.text-primary { color: var(--tc-link) !important; }
.text-success { color: var(--tc-success-strong) !important; }
.text-danger { color: var(--tc-danger-strong) !important; }
.text-warning { color: var(--tc-warning-strong) !important; }
.text-info { color: var(--tc-info-strong) !important; }
.text-primary-emphasis { color: var(--tc-link) !important; }
.text-success-emphasis { color: var(--tc-success-strong) !important; }
.text-danger-emphasis { color: var(--tc-danger-strong) !important; }
.text-warning-emphasis { color: var(--tc-warning-strong) !important; }
.text-info-emphasis { color: var(--tc-info-strong) !important; }
.bg-primary { background-color: var(--tc-primary) !important; }
.bg-primary-subtle, .text-bg-primary-subtle { background-color: var(--tc-primary-soft) !important; }
.bg-success-subtle, .text-bg-success-subtle { background-color: var(--tc-success-soft) !important; }
.bg-danger-subtle, .text-bg-danger-subtle { background-color: var(--tc-danger-soft) !important; }
.bg-warning-subtle, .text-bg-warning-subtle { background-color: var(--tc-warning-soft) !important; }
.bg-info-subtle, .text-bg-info-subtle { background-color: var(--tc-info-soft) !important; }
.bg-secondary-subtle, .text-bg-secondary-subtle, .bg-light, .bg-body-tertiary, .bg-body-secondary { background-color: var(--tc-surface-2) !important; }
.text-bg-primary { background-color: var(--tc-primary) !important; color: var(--tc-on-primary) !important; }
.text-bg-success { background-color: var(--tc-success-strong) !important; color: #fff !important; }
.text-bg-danger { background-color: var(--tc-danger) !important; color: var(--tc-on-danger) !important; }
.text-bg-warning { background-color: var(--tc-warning-soft) !important; color: var(--tc-warning-strong) !important; }
.text-bg-secondary { background-color: var(--tc-surface-3) !important; color: var(--tc-text-3) !important; }
.text-bg-light { background-color: var(--tc-surface-3) !important; color: var(--tc-text-2) !important; }
.bg-body, .bg-white { background-color: var(--tc-surface) !important; }
.border-primary { border-color: var(--tc-primary) !important; }
.border-primary-subtle { border-color: var(--tc-primary-border) !important; }
.border-success-subtle { border-color: var(--tc-success-border) !important; }
.border-danger-subtle { border-color: var(--tc-danger-border) !important; }
.border-warning-subtle { border-color: var(--tc-warning-border) !important; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--tc-border) !important; }
.link-primary { color: var(--tc-link) !important; }
.text-body { color: var(--tc-text-2) !important; }
.text-body-emphasis { color: var(--tc-text) !important; }
.list-group-item { background-color: transparent; color: var(--tc-text-2); border-color: var(--tc-border); }

/* ---------- Component tweaks ---------- */
/* Headers that start with an icon/number followed by plain text: keep the title next to its icon. */
.card-header:has(> i:first-child, > .chapter-no:first-child) { justify-content: flex-start; gap: var(--space-2); }
.card-header > i:first-child { color: var(--tc-muted); }
.status-badge.status-inline { padding: 0; border: 0; border-radius: 0; background: none; font-size: 14px; font-weight: 500; color: var(--tc-text); }
.alert-dismissible { padding-inline-end: var(--space-4); }
.alert-dismissible .btn-close { position: static; padding: 0; flex-shrink: 0; margin-block: -5px; }
.alert > div { flex: 1; min-width: 0; }
.sidebar-brand .brand-text { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-header .breadcrumb { margin-bottom: 4px; }

/* ---------- Responsive fixes (phone → tablet → laptop → large screens) ---------- */
/* A long page title must shrink (ellipsis) instead of pushing the topbar actions off-screen. */
.app-topbar { min-width: 0; }
.topbar-title { flex: 1 1 auto; min-width: 0; display: block; }
.topbar-title .count { margin-inline-start: 6px; }
.topbar-actions { flex-shrink: 0; }
/* Segmented tabs / pills wrap on narrow screens. */
.nav-pills, .segmented:not(.w-100) { flex-wrap: wrap; max-width: 100%; }
/* FullCalendar hides the list-view header at left:-10000px; in RTL that widens the page. Use a clip instead. */
.fc .fc-list-table thead { left: 0 !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
/* Absolutely-positioned helpers inside tables (visually-hidden labels, btn-check radios) must be clipped by
   the horizontal scroller; without a positioned ancestor they escape it and widen the whole page. */
.table-responsive, .table-card, .card, .panel { position: relative; }
/* Long words / codes never force a card wider than the screen. */
.card, .table-card, .panel, .kpi-card { min-width: 0; }
.page-title, .card-header, .list-title, .person-name { overflow-wrap: anywhere; }

/* Large and very large screens (desktop monitors, TVs / wall displays up to 4K-75").
   The design system is sized in px, so on 2K/4K screens everything would look tiny: scale the whole UI
   up so the effective layout stays around 1600–2000 CSS px, and centre the content column. */
@media (min-width: 1800px) {
  .app-content { margin-inline: auto; }
}
@media (min-width: 2200px) { html { zoom: 1.25; } }
@media (min-width: 2800px) { html { zoom: 1.5; } }
@media (min-width: 3400px) { html { zoom: 1.75; } }
@media (min-width: 3800px) { html { zoom: 2; } }
/* Phones: tighter gutters, full-width actions, compact topbar */
@media (max-width: 575.98px) {
  .app-content { padding: var(--space-4); }
  .page-header { gap: var(--space-3); }
  .page-actions { width: 100%; }
  .page-actions > .btn, .page-actions > .dropdown, .page-actions > form { flex: 1 1 auto; }
  .page-actions > .dropdown > .btn { width: 100%; }
  .table-card > .table-toolbar { padding: var(--space-4); }
  .table-toolbar .search-field { max-width: none; flex-basis: 100%; }
  .table-toolbar .toolbar-end { margin-inline-start: 0; width: 100%; }
  .table-toolbar .toolbar-end > .btn, .table-toolbar .toolbar-end > .form-select { flex: 1 1 auto; }
  .panel-head, .panel-body, .card-body { padding: var(--space-4); }
  .form-section-body { padding: var(--space-4); }
  .form-actions { width: 100%; }
  form .btn-group:not(.att-group) { display: flex; width: 100%; }
  form .btn-group:not(.att-group) > .btn { flex: 1 1 0; min-width: 0; white-space: normal; }
  .form-actions > .btn { flex: 1 1 auto; }
  .kpi-value { font-size: 26px; line-height: 32px; }
  .topbar-actions { gap: 0; }
  .user-toggle .bi-chevron-down { display: none; }
}

/* ---------- Shell extras ---------- */
@media (max-width: 991.98px) {
  .app-sidebar.offcanvas-lg { --bs-offcanvas-width: 280px; --bs-offcanvas-bg: var(--tc-sidebar-bg); }
}
.app-content:focus { outline: none; }
.btn-icon { position: relative; }
.btn-icon:focus-visible { outline: 2px solid var(--tc-focus); outline-offset: 2px; }
.lang-toggle { font-size: 15px; font-weight: 600; }
.user-toggle .user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }

/* Auth: the registration form has two-column rows, so its card is wider */
.auth-main:has(form[action$="/register"]) .auth-card, .auth-main:has(form[action$="/register"]) .auth-toolbar { max-width: 560px; }
.auth-toolbar .auth-logo-sm { margin-inline-end: auto; }
.auth-logo-sm .brand-text { font-size: 18px; }
.error-page .debug-box summary { cursor: pointer; color: var(--tc-muted); font-size: 13px; }

/* Notifications dropdown */
.notif-menu { width: min(380px, calc(100vw - 2rem)); padding: 0; overflow: hidden; }
.notif-menu-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 12px var(--space-4); border-bottom: 1px solid var(--tc-border); }
.notif-menu-head strong { font-size: 15px; color: var(--tc-text); }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: block; padding: 12px var(--space-4); border-bottom: 1px solid var(--tc-border); color: inherit; text-decoration: none; }
.notif-item:hover { background: var(--tc-surface-2); text-decoration: none; }
.notif-item.unread { background: var(--tc-primary-soft-2); }
.notif-item .t { font-weight: 600; font-size: 14px; line-height: 20px; color: var(--tc-text); }
.notif-item .t i { color: var(--tc-link); }
.notif-item .b { font-size: 13px; line-height: 20px; color: var(--tc-text-3); }
.notif-item .d { font-size: 12px; color: var(--tc-muted); margin-top: 2px; }
.notif-menu-foot { display: block; padding: 10px; text-align: center; font-size: 13px; font-weight: 600; border-top: 1px solid var(--tc-border); }
.notif-unread { background: var(--tc-primary-soft-2); }

/* Branding preview chip (Settings → Branding): shows the picked colour on a button, pill and link */
.brand-chip { display: inline-flex; align-items: center; gap: var(--space-2); padding: 6px; border: 1px solid var(--tc-border); border-radius: var(--radius-lg); background: var(--tc-surface-2); }
.brand-chip-btn { padding: 4px 12px; border-radius: var(--radius-md); background: var(--chip); color: var(--chip-on, #fff); font-size: 13px; font-weight: 600; }
.brand-chip-pill { padding: 2px 10px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--chip) 12%, var(--tc-surface)); color: color-mix(in srgb, var(--chip) 80%, var(--tc-text)); border: 1px solid color-mix(in srgb, var(--chip) 30%, var(--tc-surface)); font-size: 12px; font-weight: 600; }
.brand-chip-link { padding-inline: 4px; color: color-mix(in srgb, var(--chip) 60%, var(--tc-text)); font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.logo-preview img { max-height: 64px; max-width: 100%; }

/* ---------- List pages (table-card recipe) ---------- */
/* Filter forms keep their old .toolbar-card class (automation hooks); inside a table-card they are the plain toolbar. */
.table-card > .table-toolbar.toolbar-card { margin: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.table-toolbar .search-field { flex: 1 1 260px; max-width: 420px; }
.table-toolbar .toolbar-end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-inline-start: auto; }
.table-toolbar .filters-panel { width: 100%; }
.table-toolbar .filters-panel .form-label { font-size: 12px; color: var(--tc-muted); margin-bottom: 4px; }
.table-card > .table-responsive { border-top: 1px solid var(--tc-border); }
.table-card > .table-toolbar + .table-responsive, .table-card > .card-header + .table-responsive { border-top: 0; }
.table-card .empty-state { padding-block: var(--space-12); }
.table-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-3); }
.table-footer:not(.table-card > .table-footer) { margin-top: var(--space-4); }
.table-card > .table-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 18px var(--space-6); border-bottom: 1px solid var(--tc-border); font-size: 16px; font-weight: 600; color: var(--tc-text); }
.table .person .avatar { flex-shrink: 0; }
.table td code, .cell-code { font-family: var(--font-mono); font-size: 12px; color: var(--tc-text-3); background: var(--tc-surface-3); padding: 2px 6px; border-radius: var(--radius-sm); }
.btn-kebab { display: inline-grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--tc-muted); }
.btn-kebab:hover, .btn-kebab[aria-expanded="true"] { background: var(--tc-surface-3); color: var(--tc-text); }
.row-action { width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: var(--radius-pill); }

/* ---------- Form pages (panel recipe) ---------- */
.form-section-body .row > * > .mb-3 { margin-bottom: 0 !important; }
.form-section-body > .mb-3:last-child { margin-bottom: 0 !important; }
.panel-head .page-head-main { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.panel-head .page-title { font-size: 20px; line-height: 28px; }
[dir="rtl"] .panel-head .page-title { font-size: 19px; }
.panel-head .breadcrumb { margin-bottom: 2px; }
.panel-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--tc-border); background: var(--tc-surface-2); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

/* Segmented radio group (btn-check + label) */
.segmented .seg-option { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 16px; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; color: var(--tc-muted); cursor: pointer; white-space: nowrap; }
.segmented .seg-option:hover { color: var(--tc-text); }
.segmented .btn-check:checked + .seg-option { background: var(--tc-surface); color: var(--tc-link); font-weight: 600; box-shadow: var(--shadow-xs); }
.segmented .btn-check:focus-visible + .seg-option { outline: 2px solid var(--tc-focus); outline-offset: 2px; }

/* ---------- Dashboards ---------- */
.batch-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); padding: 12px; border-radius: var(--radius-lg); background: var(--tc-surface-2); text-align: center; }
.batch-stats .v { display: block; font-size: 16px; line-height: 22px; font-weight: 600; color: var(--tc-text); font-variant-numeric: tabular-nums; }
.batch-stats .k { display: block; font-size: 12px; line-height: 16px; color: var(--tc-muted); }
.card > .flex-grow-1 > .list-row:last-child { border-bottom: 0; }
.list-row .list-sub .point-pill { padding: 0 8px; font-size: 12px; min-width: 0; }
.kpi-card .kpi-label { overflow-wrap: anywhere; }

/* ---------- Learning / assessment extras ---------- */
.exam-save { font-size: 13px; color: var(--tc-muted); }
@media (max-width: 575.98px) { .exam-bar { flex-wrap: wrap; } .exam-save { order: 3; width: 100%; } }
.att-group .btn { min-width: 64px; }
@media (max-width: 575.98px) { .att-group .btn { min-width: 0; padding-inline: 6px; font-size: 12px; } }
.component-box { padding: 10px 12px; border: 1px solid var(--tc-border); border-radius: var(--radius-lg); background: var(--tc-surface-2); }
.report-types .list-group-item { font-size: 14px; }

/* ---------- Performance extras ---------- */
.point-card .kpi-label { display: flex; align-items: center; gap: 8px; }
.point-card .kpi-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--pc, var(--tc-muted)); flex-shrink: 0; }
.point-card.red .kpi-value { color: var(--tc-danger-strong); }
.point-card.green .kpi-value { color: var(--tc-success-strong); }
.skill-row + .skill-row { margin-top: var(--space-3); }
.skill-progress.lvl-strong .progress-bar { background: var(--tc-success); }
.skill-progress.lvl-developing .progress-bar { background: var(--tc-warning); }
.skill-progress.lvl-weak .progress-bar { background: var(--tc-danger); }
.heat-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--tc-text-3); }
.heat-legend::before { content: ""; width: 14px; height: 14px; border-radius: var(--radius-xs); background: var(--tc-surface-3); border: 1px solid var(--tc-border); }
.heat-legend.lvl-strong::before { background: var(--tc-success-soft); border-color: var(--tc-success-border); }
.heat-legend.lvl-developing::before { background: var(--tc-warning-soft); border-color: var(--tc-warning-border); }
.heat-legend.lvl-weak::before { background: var(--tc-danger-soft); border-color: var(--tc-danger-border); }
.skill-head span { display: inline-block; max-width: 90px; white-space: normal; font-size: 11px; line-height: 1.25; }

/* ---------- Calendar extras (FullCalendar) ---------- */
.fc a { color: inherit; text-decoration: none; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: var(--tc-on-primary); }
.fc-event { padding: 1px 4px; cursor: default; }
.fc-event[href] { cursor: pointer; }
.fc-daygrid-dot-event .fc-daygrid-event-dot, .fc-list-event-dot { border-color: var(--ev-ink, var(--tc-primary)) !important; }
.fc-event.ev-lecture, .fc-event.ev-exam, .fc-event.ev-deadline, .fc-event.ev-custom, .fc-event.ev-event { --fc-event-text-color: var(--tc-text); }
.fc-event .fc-event-main, .fc-event .fc-event-title, .fc-event .fc-event-time { color: var(--tc-text); }
.fc-h-event.ev-exam, .fc-h-event.ev-deadline { box-shadow: inset 3px 0 0 var(--ev-ink); }
[dir="rtl"] .fc-h-event.ev-exam, [dir="rtl"] .fc-h-event.ev-deadline { box-shadow: inset -3px 0 0 var(--ev-ink); }
.legend-dot.ev-custom, .legend-dot.ev-event { box-shadow: none; }
.fc .fc-daygrid-more-link { color: var(--tc-link); font-weight: 500; }

/* ---------- Date pickers (flatpickr; see app.js) ---------- */
.tc-date { position: relative; display: block; }
.tc-date .tc-date-input { padding-inline-end: 2.4rem; cursor: pointer; text-overflow: ellipsis; }
.tc-date:has(.tc-date-clear) .tc-date-input { padding-inline-end: 3.9rem; }
.table .tc-date { min-width: 10.5rem; }
.table .tc-date.with-time { min-width: 14.5rem; }
.tc-date::after {
  content: ""; position: absolute; top: 50%; inset-inline-end: .8rem; width: 1rem; height: 1rem; transform: translateY(-50%);
  pointer-events: none; background-color: var(--tc-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5M1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5M1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tc-date-clear {
  position: absolute; top: 50%; inset-inline-end: 2.25rem; transform: translateY(-50%); display: none;
  border: 0; background: transparent; color: var(--tc-muted); padding: 3px 6px; line-height: 1; font-size: 12px; border-radius: var(--radius-sm);
}
.tc-date.has-value .tc-date-clear { display: block; }
.tc-date-clear:hover, .tc-date-clear:focus-visible { color: var(--tc-text); background: var(--tc-surface-3); }
.flatpickr-calendar { font-family: var(--font-sans); background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-popover); }
.flatpickr-calendar.arrowTop::before, .flatpickr-calendar.arrowBottom::before { border-bottom-color: var(--tc-border); }
.flatpickr-calendar.arrowTop::after { border-bottom-color: var(--tc-surface); }
.flatpickr-calendar.arrowBottom::after { border-top-color: var(--tc-surface); }
.flatpickr-months .flatpickr-month, .flatpickr-current-month input.cur-year, .flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month { color: var(--tc-text); fill: var(--tc-text); }
.flatpickr-current-month { font-family: var(--font-display); }
.flatpickr-current-month .flatpickr-monthDropdown-months { background: var(--tc-surface); font-weight: 700; }
.flatpickr-current-month .flatpickr-monthDropdown-months option { background: var(--tc-surface); }
span.flatpickr-weekday { color: var(--tc-subtle); font-weight: 600; }
.flatpickr-day { color: var(--tc-text-2); border-radius: var(--radius-md); }
.flatpickr-day:hover, .flatpickr-day:focus { background: var(--tc-surface-2); border-color: var(--tc-border); }
.flatpickr-day.today { border-color: var(--tc-primary); }
.flatpickr-day.today:hover { background: var(--tc-primary-soft); color: var(--tc-link); border-color: var(--tc-primary); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus { background: var(--tc-primary); border-color: var(--tc-primary); color: var(--tc-on-primary); }
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay, .flatpickr-day.flatpickr-disabled { color: var(--tc-placeholder); }
.flatpickr-time { border-top: 1px solid var(--tc-border) !important; }
.flatpickr-time input, .flatpickr-time .flatpickr-am-pm, .flatpickr-time .flatpickr-time-separator { color: var(--tc-text); }
.flatpickr-time input:hover, .flatpickr-time input:focus, .flatpickr-time .flatpickr-am-pm:hover, .flatpickr-time .flatpickr-am-pm:focus { background: var(--tc-surface-2); }
.numInputWrapper span.arrowUp::after { border-bottom-color: var(--tc-muted); }
.numInputWrapper span.arrowDown::after { border-top-color: var(--tc-muted); }
[dir="rtl"] .flatpickr-calendar { direction: rtl; }
/* RTL: "previous" sits on the right and points right, "next" on the left. */
[dir="rtl"] .flatpickr-months .flatpickr-prev-month.flatpickr-prev-month { left: auto; right: 0; }
[dir="rtl"] .flatpickr-months .flatpickr-next-month.flatpickr-next-month { right: auto; left: 0; }
[dir="rtl"] .flatpickr-months .flatpickr-prev-month svg, [dir="rtl"] .flatpickr-months .flatpickr-next-month svg { transform: scaleX(-1); }
[dir="rtl"] .flatpickr-time { direction: ltr; }

/* ---------- Toasts (flash messages + tcToast()) ---------- */
.toast-stack { position: fixed; top: var(--space-4); inset-inline-end: var(--space-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); width: min(380px, calc(100vw - 2 * var(--space-4))); pointer-events: none; }
.app-body .toast-stack { top: calc(var(--topbar-h) + var(--space-3)); }
.toast-stack:empty { display: none; }
.app-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--space-3); margin: 0; padding: 12px 14px; font-size: 14px; line-height: 1.45; border-radius: var(--radius-lg); box-shadow: var(--shadow-popover); animation: toast-in .22s ease-out; }
.app-toast .toast-icon { font-size: 18px; line-height: 1.2; flex-shrink: 0; }
.app-toast .toast-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.app-toast .btn-close { flex-shrink: 0; width: .65em; height: .65em; margin-top: 3px; padding: 0; opacity: .55; }
.app-toast.is-leaving { animation: toast-out .2s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .app-toast, .app-toast.is-leaving { animation-duration: .01s; } }
@media (max-width: 575.98px) { .toast-stack { inset-inline: var(--space-3); width: auto; } }

/* ---------- Global search (topbar) ---------- */
.topbar-search { position: relative; min-width: 0; }
.topbar-search .form-control { padding-inline-end: 64px; }
.topbar-search .form-control::-webkit-search-cancel-button { display: none; }
.search-kbd { position: absolute; inset-inline-end: 10px; padding: 2px 6px; font: 500 11px/1.4 var(--font-sans); color: var(--tc-muted); background: var(--tc-surface-2); border: 1px solid var(--tc-border); border-radius: var(--radius-sm); pointer-events: none; unicode-bidi: isolate; }
.topbar-search:focus-within .search-kbd { display: none; }
.search-close { position: absolute; inset-inline-end: 2px; }
.search-results { position: absolute; top: calc(100% + 6px); inset-inline: 0; min-width: 360px; max-height: min(70vh, 560px); overflow-y: auto; padding: 6px; background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-popover); z-index: var(--z-dropdown); }
.search-group + .search-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--tc-border); }
.search-group-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--tc-muted); }
.search-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-md); color: var(--tc-text); text-decoration: none; }
.search-item > i { flex-shrink: 0; width: 32px; height: 32px; display: grid; place-items: center; font-size: 15px; color: var(--tc-link); background: var(--tc-primary-soft, var(--tc-surface-2)); border-radius: var(--radius-md); }
.search-item .si-text { min-width: 0; display: flex; flex-direction: column; }
.search-item .si-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item .si-sub { font-size: 12px; color: var(--tc-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item .si-title, .search-item .si-sub { unicode-bidi: plaintext; text-align: left; }
[dir=rtl] .search-item .si-title, [dir=rtl] .search-item .si-sub { text-align: right; }
.search-item mark { padding: 0; background: transparent; color: var(--tc-link); }
.search-item:hover, .search-item.is-active { background: var(--tc-surface-2); color: var(--tc-text); }
.search-state { padding: 14px 10px; font-size: 13px; color: var(--tc-muted); text-align: center; }
.search-foot { padding: 6px 10px 2px; font-size: 11px; color: var(--tc-muted); border-top: 1px solid var(--tc-border); margin-top: 4px; }
@media (min-width: 992px) {
  .topbar-title { flex: 0 1 auto; }
  .app-topbar .topbar-actions { margin-inline-start: 0; }
}
@media (max-width: 991.98px) {
  .app-topbar.search-open .topbar-search { display: block; position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; justify-content: center; max-width: none; margin: 0; padding: 0 var(--space-4); background: var(--tc-surface); }
  .app-topbar.search-open .search-results { inset-inline: var(--space-3); top: calc(100% - 8px); min-width: 0; }
  .search-kbd { display: none; }
  .topbar-search .form-control { padding-inline-end: 44px; }
}
@media (min-width: 992px) and (max-width: 1279.98px) {
  .topbar-search { flex: 1 1 200px; min-width: 200px; }
  .search-kbd { display: none; }
  .topbar-search .form-control { padding-inline-end: 12px; }
  .app-topbar .user-meta { display: none !important; }
}
td code { white-space: nowrap; }

/* ---------- Certificates ---------- */
.cert-template-card.is-inactive .cert-thumb { opacity: .55; }
.cert-thumb { display: block; aspect-ratio: 297 / 210; background: var(--tc-surface-2); border-bottom: 1px solid var(--tc-border); border-radius: var(--radius-xl) var(--radius-xl) 0 0; overflow: hidden; }
.cert-thumb.is-portrait { aspect-ratio: 297 / 210; }
.cert-thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.cert-thumb-default { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 100%; color: var(--tc-link); font-size: 13px; font-weight: 600; background: linear-gradient(135deg, var(--tc-primary-soft), var(--tc-surface)); }
.cert-thumb-default i { font-size: 34px; }

.cert-editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--space-5); align-items: start; }
@media (max-width: 1199.98px) { .cert-editor { grid-template-columns: 1fr; } }
.cert-stage { position: relative; width: 100%; aspect-ratio: 297 / 210; background: #fff; border: 1px solid var(--tc-border-strong); border-radius: var(--radius-md); overflow: hidden; touch-action: none; user-select: none; direction: ltr; }
.cert-stage.is-portrait { aspect-ratio: 210 / 297; max-width: 520px; margin-inline: auto; }
.cert-stage-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.cert-field { position: absolute; line-height: 1.25; white-space: nowrap; overflow: visible; cursor: move; outline: 1px dashed rgba(252, 170, 23, .75); outline-offset: 1px; border-radius: 2px; }
.cert-field .cf-text { display: block; overflow: hidden; text-overflow: clip; }
.cert-field.is-qr { display: grid; place-items: center; background: rgba(12, 27, 46, .06); }
.cert-field.is-qr i { font-size: clamp(14px, 4vw, 48px); }
.cert-field.is-hidden { opacity: .3; outline-style: dotted; }
.cert-field.is-selected, .cert-field:focus-visible { outline: 2px solid var(--tc-primary); background-color: rgba(252, 170, 23, .10); z-index: 2; }
.cert-field .cf-tag { position: absolute; bottom: 100%; left: 0; margin-bottom: 2px; padding: 1px 6px; font: 600 10px/1.5 var(--font-sans); color: #fff; background: var(--tc-primary); border-radius: 4px; white-space: nowrap; opacity: 0; pointer-events: none; }
.cert-field.is-selected .cf-tag, .cert-field:hover .cf-tag { opacity: 1; }
.cert-field .cf-handle { position: absolute; top: 50%; right: -6px; width: 10px; height: 22px; margin-top: -11px; background: #fff; border: 2px solid var(--tc-primary); border-radius: 4px; cursor: ew-resize; opacity: 0; }
.cert-field.is-selected .cf-handle { opacity: 1; }
.cert-props { position: sticky; top: calc(var(--topbar-h) + var(--space-4)); padding: var(--space-4); background: var(--tc-surface-2); border: 1px solid var(--tc-border); border-radius: var(--radius-lg); }
/* rough on-screen stand-in for the built-in PDF design, so fields can be placed against it */
.cert-builtin { position: absolute; inset: 0; background: #FAFBFD; color: #1C1A17; font-family: Helvetica, Arial, sans-serif; pointer-events: none; }
.cert-builtin .b1 { position: absolute; inset: 4.3%; border: 3px solid var(--tc-primary); }
.cert-builtin .b2 { position: absolute; inset: 6.2%; border: 1px solid var(--tc-primary); }
.cert-builtin span[class^="t"] { position: absolute; left: 0; right: 0; text-align: center; }
.cert-builtin .t0 { top: 11.4%; font-size: 1.6cqw; font-weight: 700; color: var(--tc-link); }
.cert-builtin .t1 { top: 20%; font-size: 3.6cqw; font-weight: 700; }
.cert-builtin .t2 { top: 26.2%; font-size: 1.6cqw; color: var(--tc-link); }
.cert-builtin .t3 { top: 34.5%; font-size: 1.45cqw; color: #52514E; }
.cert-builtin .t4 { top: 53%; font-size: 1.45cqw; color: #52514E; }
.cert-builtin .sig { position: absolute; top: 86%; left: 38.2%; right: 38.2%; border-top: 1px solid #898781; }
.cert-stage { container-type: inline-size; }

.cert-card-icon { flex-shrink: 0; width: 44px; height: 44px; display: grid; place-items: center; font-size: 22px; color: var(--tc-warning-strong, #B7791F); background: var(--tc-warning-soft, #FEF3C7); border-radius: var(--radius-lg); }
.cert-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.cert-meta dt { font-weight: 500; color: var(--tc-muted); }
.cert-meta dd { margin: 0; overflow-wrap: anywhere; }

.verify-result { padding: var(--space-5); border: 1px solid var(--tc-border); border-radius: var(--radius-lg); background: var(--tc-surface-2); }
.verify-badge { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-4); font-size: 17px; }
.verify-badge i { font-size: 28px; }
.verify-result.is-valid { border-color: var(--tc-success); background: var(--tc-success-soft, #ECFDF5); }
.verify-result.is-valid .verify-badge { color: var(--tc-success-strong, #047857); }
.verify-result.is-revoked { border-color: var(--tc-danger); background: var(--tc-danger-soft, #FEF2F2); }
.verify-result.is-revoked .verify-badge { color: var(--tc-danger-strong, #B91C1C); }
.verify-result.is-unknown .verify-badge { color: var(--tc-muted); }
.verify-data { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 var(--space-3); font-size: 14px; }
.verify-data dt { font-weight: 500; color: var(--tc-muted); }
.verify-data dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Exam builder: bank draw table, manual question slots ---------- */
.draw-table td { vertical-align: middle; }
.manual-summary { margin: 0; padding-inline-start: 1.4rem; display: grid; gap: 8px; }
.manual-summary li::marker { color: var(--tc-muted); font-weight: 600; }
.manual-q { margin: 0 0 var(--space-4); padding: var(--space-4) var(--space-5); background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: var(--radius-lg); }
.manual-q.has-error { border-color: var(--tc-danger); }
.manual-q legend { float: none; display: flex; align-items: center; gap: 10px; width: auto; margin: 0 0 var(--space-3); padding: 0; font-size: 15px; font-weight: 600; }
.manual-q-no { display: inline-grid; place-items: center; width: 28px; height: 28px; font-size: 13px; color: var(--tc-link); background: var(--tc-primary-soft); border-radius: 50%; }

/* ---------- Course versions, batch grades & history, attendance ---------- */
.version-pill { background: var(--tc-primary-soft); color: var(--tc-link); }
.grades-scroll { max-height: 70vh; }
.grades-table th, .grades-table td { white-space: nowrap; }
.grades-table .sticky-col { position: sticky; inset-inline-start: 0; z-index: 1; min-width: 200px; background: var(--tc-surface); box-shadow: inset -1px 0 0 var(--tc-border); }
[dir=rtl] .grades-table .sticky-col { box-shadow: inset 1px 0 0 var(--tc-border); }
.grades-table thead th { position: sticky; top: 0; z-index: 2; background: var(--tc-surface-2); }
.grades-table thead th.sticky-col { z-index: 3; }
.grade-cell { display: inline-block; min-width: 38px; padding: 2px 6px; font-size: 12px; font-weight: 600; border-radius: 6px; }
.grade-cell.green { color: var(--tc-success-strong, #047857); background: var(--tc-success-soft, #ECFDF5); }
.grade-cell.red { color: var(--tc-danger-strong, #B91C1C); background: var(--tc-danger-soft, #FEF2F2); }
.history-list { list-style: none; margin: 0; padding: var(--space-2) 0; }
.history-day { padding: var(--space-3) var(--space-5) var(--space-1); font-size: 12px; font-weight: 600; color: var(--tc-muted); text-transform: uppercase; letter-spacing: .04em; }
.history-item { display: flex; gap: var(--space-3); padding: 10px var(--space-5); border-top: 1px solid var(--tc-border); }
.history-icon { flex-shrink: 0; width: 32px; height: 32px; display: grid; place-items: center; color: var(--tc-link); background: var(--tc-primary-soft); border-radius: 50%; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }
.att-badge { display: inline-flex; align-items: center; gap: 6px; }

/* Skill matrix picker preview */
.skill-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: var(--space-3); background: var(--tc-surface-2); border: 1px solid var(--tc-border); border-radius: var(--radius-md); max-height: 220px; overflow-y: auto; }
.skill-chip { padding: 3px 10px; font-size: 12px; font-weight: 500; color: var(--tc-link); background: var(--tc-primary-soft); border-radius: 999px; }

/* ---------- Maintenance mode ---------- */
.maintenance-banner { padding: 8px var(--space-6); font-size: 14px; font-weight: 500; color: #fff; background: var(--tc-danger, #DC2626); }
.maintenance-banner a { color: #fff; text-decoration: underline; }
.maintenance-page { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6); background: var(--tc-bg, var(--tc-surface-2)); }
.maintenance-card { width: min(560px, 100%); padding: var(--space-8) var(--space-6); text-align: center; background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-popover); }
.maintenance-brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: var(--space-5); font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--tc-link); }
.maintenance-icon { display: inline-grid; place-items: center; width: 72px; height: 72px; margin-bottom: var(--space-4); font-size: 34px; color: var(--tc-warning-strong, #B45309); background: var(--tc-warning-soft, #FEF3C7); border-radius: 50%; }
.maintenance-card h1 { font-size: 24px; margin-bottom: var(--space-3); }
.maintenance-message { color: var(--tc-text-2, var(--tc-muted)); margin-bottom: var(--space-3); }
.maintenance-until { font-size: 14px; color: var(--tc-muted); margin: 0; }
.maintenance-status.is-on { border-color: var(--tc-danger); background: var(--tc-danger-soft, #FEF2F2); }
.maintenance-status.is-off { border-color: var(--tc-success); background: var(--tc-success-soft, #ECFDF5); }
.maintenance-status-icon { flex-shrink: 0; width: 48px; height: 48px; display: grid; place-items: center; font-size: 24px; border-radius: 50%; background: var(--tc-surface); }
.maintenance-status.is-on .maintenance-status-icon { color: var(--tc-danger); }
.maintenance-status.is-off .maintenance-status-icon { color: var(--tc-success); }

/* ---------- Material library ---------- */
.material-card.is-superseded { opacity: .7; }
.material-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.material-meta dt { font-weight: 500; color: var(--tc-muted); }
.material-meta dd { margin: 0; overflow-wrap: anywhere; }
.material-files { list-style: none; margin: 8px 0 0; padding: 0 0 0 4px; display: grid; gap: 4px; font-size: 13px; }
.material-files i { color: var(--tc-muted); margin-inline-end: 6px; }
.material-preview { padding: var(--space-4); background: var(--tc-surface-2); border: 1px solid var(--tc-border); border-radius: var(--radius-lg); }
.material-preview .preview-info { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 var(--space-3); font-size: 14px; }
.material-preview .preview-info dt { font-weight: 500; color: var(--tc-muted); }
.material-preview .preview-info dd { margin: 0; font-weight: 500; }
.material-preview .skill-chips { background: var(--tc-surface); }
.usage-stat { padding: var(--space-3); background: var(--tc-surface-2); border-radius: var(--radius-md); }
.usage-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1.1; }
.usage-label { font-size: 12px; color: var(--tc-muted); }

/* certificate of a student: card on the performance page, cell in batch tables */
.certificate-strip { border-color: var(--tc-success-soft, var(--tc-border)); }
.certificate-strip .card-body { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.certificate-strip .cert-icon { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; border-radius: var(--radius-md); background: var(--tc-success-soft, var(--tc-surface-2)); color: var(--tc-success-strong); font-size: 22px; }
.certificate-strip.is-revoked .cert-icon { background: var(--tc-danger-soft, var(--tc-surface-2)); color: var(--tc-danger-strong); }
.certificate-strip .cert-info { flex: 1 1 200px; min-width: 0; }
.certificate-strip .cert-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.certificate-strip .cert-actions .btn i { margin-inline-end: 4px; }
.cert-cell { white-space: nowrap; }
@media (max-width: 575.98px) { .certificate-strip .cert-actions { width: 100%; } .certificate-strip .cert-actions .btn { flex: 1 1 auto; } }

/* online users: grid of round avatars or a list, grouped by role */
.online-group .card-header { display: flex; align-items: center; gap: var(--space-2); }
.online-list { list-style: none; margin: 0; padding: var(--space-4); }
.online-user { color: inherit; text-decoration: none; position: relative; }
a.online-user:hover .ou-name, a.online-user:focus-visible .ou-name { color: var(--tc-link); }
.ou-avatar { position: relative; display: inline-flex; flex: none; }
.ou-avatar .avatar { border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 3px var(--tc-surface), 0 0 0 5px var(--tc-success-soft); }
.ou-dot { position: absolute; inset-block-end: 2px; inset-inline-end: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--tc-success); border: 3px solid var(--tc-surface); }
.ou-text { display: flex; flex-direction: column; min-width: 0; }
.ou-name { font-weight: 600; line-height: 1.3; }
.ou-email, .ou-seen { font-size: 12px; color: var(--tc-muted); }
.ou-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--tc-success-strong); }
.ou-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tc-success); animation: ou-pulse 2s ease-in-out infinite; }
@keyframes ou-pulse { 50% { box-shadow: 0 0 0 4px var(--tc-success-soft); } }
@media (prefers-reduced-motion: reduce) { .ou-status-dot { animation: none; } }

.online-users.is-grid .online-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: var(--space-4); }
.online-users.is-grid .online-user { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: var(--space-3) var(--space-2); border-radius: var(--radius-md); }
.online-users.is-grid a.online-user:hover { background: var(--tc-surface-2); }
.online-users.is-grid .ou-text { align-items: center; gap: 4px; width: 100%; }
.online-users.is-grid .ou-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.online-users.is-grid .ou-email, .online-users.is-grid .ou-seen { display: none; }

.online-users.is-list .online-list { padding: 0; }
.online-users.is-list .online-list li + li { border-top: 1px solid var(--tc-border); }
.online-users.is-list .online-user { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.online-users.is-list a.online-user:hover { background: var(--tc-surface-2); }
.online-users.is-list .ou-avatar .avatar { width: 44px !important; height: 44px !important; font-size: 15px !important; }
.online-users.is-list .ou-dot { width: 13px; height: 13px; border-width: 2px; inset-block-end: 0; inset-inline-end: 0; }
.online-users.is-list .ou-text { flex: 1 1 auto; }
.online-users.is-list .ou-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-users.is-list .ou-status { margin-top: 2px; }
.online-users.is-list .ou-seen { white-space: nowrap; }
@media (max-width: 575.98px) { .online-users.is-list .ou-seen { display: none; } .online-users.is-grid .online-list { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--space-2); } }
.ou-timer { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--tc-muted); font-variant-numeric: tabular-nums; }
.ou-timer .bi { font-size: 11px; }
/* skills an exam / assignment measures (table cell) */
.skill-tags { display: flex; flex-wrap: wrap; gap: 4px; max-width: 280px; }
.skill-tags .skill-chip { padding: 2px 8px; font-size: 11.5px; white-space: nowrap; }
.skill-chip-more { color: var(--tc-muted); background: var(--tc-surface-2); border: 1px solid var(--tc-border); cursor: help; }

/* superseded / archived rows in list tables */
.table tr.row-muted > td { color: var(--tc-muted); }
.table tr.row-muted .cell-main { color: var(--tc-muted); }
/* Clickable rows (data-href): the whole row opens the details page */
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover > td { background: var(--tc-surface-2); --bs-table-bg-state: var(--tc-surface-2); }
.table tr[data-href]:hover .cell-main, .table tr[data-href]:hover .person-name { color: var(--tc-primary, var(--bs-primary)); }


/* track leadership: track checkboxes */
.leader-tracks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-2); }
.leader-track { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3); border: 1px solid var(--tc-border); border-radius: var(--radius-md); cursor: pointer; background: var(--tc-surface); }
.leader-track:has(input:checked) { border-color: var(--tc-primary); background: var(--tc-primary-soft); }
.leader-track.is-inactive { opacity: .7; }
.leader-track .form-check-input { margin-top: 3px; flex: none; }
.leader-track-text { display: flex; flex-direction: column; min-width: 0; }
.leader-track-note { font-size: 12px; color: var(--tc-muted); margin-top: 2px; }

/* reviews: approval panel, votes, round content */
.review-open { padding: var(--space-3); border: 1px solid var(--tc-border); border-radius: var(--radius-md); background: var(--tc-surface-2); }
.review-history { background: var(--tc-surface); }
.review-round + .review-round { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px dashed var(--tc-border); }
.review-votes { list-style: none; padding: 0; margin: var(--space-2) 0 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.vote-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.vote-approve { color: var(--tc-success-strong); background: var(--tc-success-soft); }
.vote-reject { color: var(--tc-danger-strong); background: var(--tc-danger-soft); }
.table tr.row-attention > td { background: var(--tc-primary-soft); }
.review-question.is-changed { border-color: var(--tc-warning, #f5a524); }
.review-options { margin: 0 0 var(--space-2); padding-inline-start: 1.4rem; }
.review-options li { margin-bottom: 2px; }
.review-options li.is-correct { font-weight: 600; color: var(--tc-success-strong); }
.review-model { padding: var(--space-2) var(--space-3); background: var(--tc-surface-2); border-radius: var(--radius-sm); }
.pill-warning { color: var(--tc-warning-strong); background: var(--tc-warning-soft, var(--tc-surface-2)); }

/* ---- Support tickets: conversation, status events, screenshots and videos ---- */
.ticket-thread { display: flex; flex-direction: column; gap: 12px; }
.ticket-msg.is-opening { border-inline-start: 3px solid var(--tc-primary); }
.ticket-msg.is-staff { background: var(--tc-primary-soft); border-color: var(--tc-primary-border, var(--tc-border)); }
.ticket-body { white-space: normal; overflow-wrap: anywhere; }
.ticket-event { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .85rem; color: var(--tc-text-2); padding: 2px 6px; }
.ticket-files { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.ticket-file.is-image { display: block; width: 132px; height: 96px; border-radius: var(--radius-md, 10px); overflow: hidden; border: 1px solid var(--tc-border); background: var(--tc-surface-2); }
.ticket-file.is-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .15s ease; }
.ticket-file.is-image:hover img { transform: scale(1.04); }
.ticket-file.is-video { margin: 0; width: min(360px, 100%); }
.ticket-file.is-video video { width: 100%; max-height: 240px; border-radius: var(--radius-md, 10px); background: #000; }
.ticket-file.is-video figcaption { font-size: .8rem; margin-top: 4px; overflow-wrap: anywhere; }
.ticket-file.is-video figcaption .bi { margin-inline-end: 4px; }

/* ---- Help assistant: robot button at the bottom end corner (right in LTR, left in RTL) + chat panel ---- */
.helpbot { position: fixed; inset-block-end: 20px; inset-inline-end: 20px; z-index: 1040; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; pointer-events: none; }
.helpbot > * { pointer-events: auto; }
.helpbot-fab {
  width: 60px; height: 60px; border: 0; border-radius: 50%; padding: 6px; cursor: pointer;
  background: linear-gradient(135deg, var(--tc-brand-grad-start), var(--tc-brand-grad-end)); color: var(--tc-on-primary);
  box-shadow: var(--shadow-primary, 0 8px 24px rgba(0, 0, 0, .18)); transition: transform .15s ease;
}
.helpbot-fab:hover { transform: translateY(-2px) scale(1.04); }
.helpbot-fab:focus-visible, .helpbot-min:focus-visible, .helpbot-choice:focus-visible { outline: 3px solid var(--tc-focus); outline-offset: 2px; }
.helpbot-fab .helpbot-robot { width: 100%; height: 100%; animation: helpbot-bob 3.2s ease-in-out infinite; }
.helpbot-robot .hb-head { fill: #fff; }
.helpbot-robot .hb-face { fill: var(--tc-brand-ink, #0b1b3f); }
.helpbot-robot .hb-eye { fill: #7ef0ff; }
.helpbot-robot .hb-mouth { stroke: #7ef0ff; }
.helpbot-robot .hb-ear, .helpbot-robot .hb-neck { fill: rgba(255, 255, 255, .75); }
.helpbot-robot .hb-antenna { fill: #ffd166; }
.helpbot-robot line { color: #fff; }
@keyframes helpbot-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .helpbot-fab .helpbot-robot { animation: none; } .helpbot-fab { transition: none; } }

.helpbot-panel {
  width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100vh - 120px)); display: flex; flex-direction: column;
  background: var(--tc-surface); color: var(--tc-text); border: 1px solid var(--tc-border); border-radius: var(--radius-xl, 18px);
  box-shadow: var(--shadow-modal, 0 18px 48px rgba(0, 0, 0, .2)); overflow: hidden;
}
.helpbot-panel[hidden] { display: none; }
.helpbot-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: linear-gradient(135deg, var(--tc-brand-grad-start), var(--tc-brand-grad-end)); color: var(--tc-on-primary);
}
.helpbot-avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, .16); padding: 3px; }
.helpbot-avatar .helpbot-robot { width: 100%; height: 100%; }
.helpbot-title { font-weight: 700; line-height: 1.2; }
.helpbot-status { font-size: .78rem; opacity: .9; display: flex; align-items: center; gap: 6px; }
.helpbot-dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }
.helpbot-min { width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: inherit; display: grid; place-items: center; }
.helpbot-min:hover { background: rgba(255, 255, 255, .28); }

.helpbot-log { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--tc-bg); }
.helpbot-msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: .9rem; line-height: 1.5; white-space: pre-line; }
.helpbot-msg.is-bot { align-self: flex-start; background: var(--tc-surface); border: 1px solid var(--tc-border); border-start-start-radius: 4px; }
.helpbot-msg.is-me { align-self: flex-end; background: var(--tc-primary); color: var(--tc-on-primary); border-start-end-radius: 4px; }
.helpbot-answer p { margin: 0 0 6px; }
.helpbot-steps-title { font-weight: 600; font-size: .82rem; color: var(--tc-text-2); margin-top: 4px; }
.helpbot-steps { margin: 4px 0 6px; padding-inline-start: 1.2rem; }
.helpbot-steps li { margin-bottom: 2px; }
.helpbot-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.helpbot-link {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--radius-pill, 999px);
  background: var(--tc-primary-soft); color: var(--tc-link); font-size: .82rem; font-weight: 600; text-decoration: none;
}
.helpbot-link:hover { background: var(--tc-primary-soft-2, var(--tc-primary-soft)); color: var(--tc-primary-hover); }
[dir="rtl"] .helpbot-link .bi-arrow-up-right { transform: scaleX(-1); }

.helpbot-choices { flex: none; max-height: 45%; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 12px; border-top: 1px solid var(--tc-border); background: var(--tc-surface); }
.helpbot-choice {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--tc-primary-border, var(--tc-border)); background: var(--tc-surface); color: var(--tc-link);
  font-size: .84rem; font-weight: 600; text-align: start; cursor: pointer;
}
.helpbot-choice:hover { background: var(--tc-primary-soft); }
.helpbot-choice.is-nav { color: var(--tc-text-2); border-color: var(--tc-border); }

@media (max-width: 575.98px) {
  .helpbot { inset-block-end: 12px; inset-inline-end: 12px; }
  .helpbot-fab { width: 52px; height: 52px; }
  .helpbot-panel { height: min(520px, calc(100vh - 96px)); }
}
@media print { .helpbot { display: none !important; } }

/* ---- Sidebar counter (e.g. support tickets still to handle) ---- */
.nav-count { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--radius-pill, 999px);
  background: var(--tc-danger); color: var(--tc-on-danger, #fff); font-size: 12px; font-weight: 700; line-height: 22px; text-align: center; }

/* ---- Exam integrity log (grading page) ---- */
.integrity-card.is-flagged { border-color: var(--tc-warning-border, var(--tc-border)); }
.integrity-log { padding-inline-start: 1.1rem; columns: 2; column-gap: 2rem; }
.integrity-log li { break-inside: avoid; margin-bottom: 2px; }
@media (max-width: 767.98px) { .integrity-log { columns: 1; } }

/* ---- Lecture feedback: star rating (radios 5→1 in the DOM, shown 1→5 in both directions) ---- */
.star-rating { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; border: 0; padding: 0; margin: 0; }
.star-rating input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-rating label { cursor: pointer; font-size: 1.35rem; line-height: 1; color: var(--tc-border-strong, #c7cdd8); padding: 2px; }
.star-rating label:hover, .star-rating label:hover ~ label, .star-rating input:checked ~ label { color: #f5b301; }
.star-rating input:focus-visible + label { outline: 2px solid var(--tc-focus); outline-offset: 1px; border-radius: 4px; }
.feedback-comments li + li { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--tc-border); }

/* ---- Lecture questions ---- */
.lq-item + .lq-item { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--tc-border); }
.lq-body { overflow-wrap: anywhere; }
.lq-reply { margin-top: 8px; padding: 8px 12px; border-radius: var(--radius-md, 10px); background: var(--tc-surface-2); border-inline-start: 3px solid var(--tc-border-strong, var(--tc-border)); }
.lq-reply.is-staff { background: var(--tc-primary-soft); border-inline-start-color: var(--tc-primary); }
.lq-state { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: var(--radius-pill, 999px); }
.lq-state.is-open { background: var(--tc-warning-soft); color: var(--tc-warning-strong, #8a5a00); }
.lq-state.is-answered { background: var(--tc-info-soft); color: var(--tc-info-strong, #0b5d7a); }
.lq-state.is-resolved { background: var(--tc-success-soft); color: var(--tc-success-strong); }

/* ---- Instructor pay: void a payment from a small disclosure ---- */
.void-box > summary { list-style: none; display: inline-block; }
.void-box > summary::-webkit-details-marker { display: none; }
.void-box[open] form { min-width: 240px; }

/* ---- Protected course material: viewer, watermark, focus shield, no printing ---- */
[data-protect] { position: relative; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
[data-protect] img, [data-protect] canvas, [data-protect] video { -webkit-user-drag: none; }
.protect-watermark { position: absolute; inset: 0; z-index: 5; pointer-events: none; background-repeat: repeat; border-radius: inherit; }
.protect-shield { position: absolute; inset: 0; z-index: 6; display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; border-radius: inherit; color: var(--tc-muted); font-weight: 600; text-align: center; }
.protect-shield span { position: sticky; top: 30vh; background: var(--tc-surface); border: 1px solid var(--tc-border); border-radius: var(--tc-radius); padding: .6rem 1rem; box-shadow: var(--shadow-card); }
body.protect-shielded [data-protect] > :not(.protect-shield):not(.protect-watermark) { filter: blur(24px); }
body.protect-shielded .protect-shield { display: flex; }
@media print {
  body.has-protected [data-protect] { display: none !important; }
  body.has-protected::before { content: attr(data-print-msg); display: block; padding: 2rem; font: 600 1.25rem/1.4 sans-serif; text-align: center; }
}
.viewer-card { overflow: hidden; }
.viewer-toolbar { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; border-bottom: 1px solid var(--tc-border); position: sticky; top: 0; z-index: 7; background: var(--tc-surface); }
.viewer-type { font-size: .8rem; font-weight: 700; color: var(--tc-muted); letter-spacing: .04em; }
.viewer-pages { font-size: .85rem; color: var(--tc-muted); }
.viewer-stage { background: var(--tc-bg); padding: 16px; min-height: 60vh; overflow-x: auto; }
.viewer-content { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.viewer-page { display: block; max-width: none; background: #fff; box-shadow: var(--shadow-card); border-radius: 4px; }
.viewer-loading { padding: 3rem 1rem; color: var(--tc-muted); }
.viewer-docx { width: 100%; }
.viewer-docx .docx-wrapper { background: transparent; padding: 0; }
.viewer-docx .docx-wrapper > section.docx { box-shadow: var(--shadow-card); margin-bottom: 16px; }
.video-protect { border-radius: var(--tc-radius); overflow: hidden; }
.video-protect:fullscreen { display: flex; align-items: center; justify-content: center; background: #000; border-radius: 0; }
.video-protect:fullscreen video { width: 100%; height: 100%; max-height: 100vh; }

/* ---- One filter button everywhere: a square funnel next to the search / filter fields ---- */
.filter-btn { flex: none; width: var(--control-md); height: var(--control-md); min-height: 0; padding: 0; display: inline-grid; place-items: center;
  border: 1px solid var(--tc-border-control); border-radius: var(--radius-md); background: var(--tc-surface); color: var(--tc-text-3); font-size: 16px; }
.filter-btn:hover, .filter-btn:focus-visible { background: var(--tc-primary-soft); border-color: var(--tc-primary-border); color: var(--tc-link); }
.filter-btn.btn-sm { width: var(--control-sm); height: var(--control-sm); font-size: 14px; }
.col-md-1 > .filter-btn { width: 100%; }

/* ---- Page header: the main button stays at the top end, beside the title, even with a long subtitle ---- */
@media (min-width: 768px) {
  .page-header { flex-wrap: nowrap; align-items: flex-start; }
  .page-header .page-head-main { flex: 1 1 auto; }
  .page-header .page-actions { flex: none; flex-wrap: nowrap; justify-content: flex-end; }
}
.page-title .title-count { font-size: .55em; font-weight: 500; color: var(--tc-muted); vertical-align: middle; }
.tooltip { pointer-events: none; }
