/* ============================================================
   Training Management – 2026 Corporate Theme
   Modern, clean, sophisticated design language
   ============================================================ */

/* ── Design Tokens ────────────────────────────────────────── */
:root {
    /* Sidebar */
    --tm-sidebar-width: 272px;
    --tm-sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    --tm-sidebar-border: rgba(255, 255, 255, 0.06);

    /* Header */
    --tm-header-height: 64px;

    /* Brand Colors – Indigo/Violet spectrum.
       --tm-primary is indigo-600, not indigo-500: white text on indigo-500 (#6366f1)
       measures 4.47:1 and misses the WCAG AA 4.5:1 minimum for normal text by a hair.
       indigo-600 gives 6.29:1, so every solid primary button clears AA with margin.
       The rest of the ramp is shifted one step to match: hover is indigo-700 (7.90:1)
       and the glow is the new primary at 25% alpha. --tm-primary-light stays indigo-50;
       it is a tint surface, and primary text on it still reads at 5.62:1. */
    --tm-primary: #4f46e5;
    --tm-primary-hover: #4338ca;
    --tm-primary-light: #eef2ff;
    --tm-primary-glow: rgba(79, 70, 229, 0.25);

    /* Lighter end of the indigo ramp, for primary-coloured marks on the dark
       sidebar. --tm-primary (indigo-600) only measures 2.84:1 against #0f172a and
       2.33:1 against #1e293b, both under the WCAG 1.4.11 3:1 floor for non-text
       graphics; indigo-400 measures 5.98:1 and 4.90:1. Use this token — never
       --tm-primary — for anything drawn on --tm-sidebar-bg. */
    --tm-primary-on-dark: #818cf8;

    /* Accent */
    --tm-accent: #0ea5e9;
    --tm-accent-light: #e0f2fe;

    /* Success / Warning / Danger.
       --tm-success (emerald-500, #10b981) measured 2.54:1 for white text and
       --tm-danger (red-500, #ef4444) measured 3.76:1, both well short of the
       WCAG AA 4.5:1 minimum for normal text — worse than the primary ramp fixed
       in TM-1. Success moves to emerald-700 (5.48:1); emerald-600 (#059669)
       only reaches 3.77:1, so success needs the full two-step jump. Danger
       moves to red-600 (4.83:1). The ramp below moves with them, one step
       darker, same as TM-1: success hover is emerald-800 (7.68:1), danger
       hover is red-700 (6.47:1). --tm-warning is unchanged — nothing in the
       app puts white text on it, so it has no contrast failure to fix. */
    --tm-success: #047857;
    --tm-warning: #f59e0b;
    --tm-danger: #dc2626;

    /* Neutrals */
    --tm-bg: #f1f5f9;
    --tm-surface: #ffffff;
    --tm-text: #0f172a;
    --tm-text-secondary: #475569;
    --tm-text-muted: #94a3b8;
    --tm-border: #e2e8f0;
    --tm-border-light: #f1f5f9;

    /* Shadows – layered for depth */
    --tm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --tm-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --tm-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --tm-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Radii */
    --tm-radius-sm: 8px;
    --tm-radius-md: 12px;
    --tm-radius-lg: 16px;
    --tm-radius-xl: 24px;

    /* Transitions */
    --tm-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --tm-transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base Reset & Typography ──────────────────────────────── */
html, body {
    height: 100%;
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background-color: var(--tm-bg);
    color: var(--tm-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* Override Fomantic UI default font */
.ui,
.ui.menu,
.ui.header,
.ui.button,
.ui.form,
.ui.table,
.ui.segment,
.ui.message,
.ui.modal,
.ui.dropdown,
.ui.label,
.ui.input input,
.ui.statistic {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif !important;
}

/* Preserve Fomantic icon font */
i.icon {
    font-family: 'Icons' !important;
}

/* ── Application Shell ────────────────────────────────────── */
.tm-app {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background-color: var(--tm-bg);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.tm-sidebar {
    width: var(--tm-sidebar-width);
    min-width: var(--tm-sidebar-width);
    background: var(--tm-sidebar-bg);
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    z-index: 20;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

/* Subtle noise texture overlay on sidebar */
.tm-sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 20% 0%, rgba(79, 70, 229, 0.12) 0%, transparent 60%);
    pointer-events: none;
}

/* Custom scrollbar for sidebar */
.tm-sidebar::-webkit-scrollbar {
    width: 4px;
}

.tm-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.tm-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.tm-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ── Main Content Area ────────────────────────────────────── */
.tm-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Header ───────────────────────────────────────────────── */
.tm-header {
    height: var(--tm-header-height);
    min-height: var(--tm-header-height);
    background-color: var(--tm-surface);
    border-bottom: 1px solid var(--tm-border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    box-shadow: var(--tm-shadow-sm);
    z-index: 10;
    position: relative;
}

/* Mobile drawer toggle - hidden on desktop, shown by the responsive rules below */
.tm-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin-right: 0.5rem;
    flex: 0 0 auto;
    padding: 0;
    border: none;
    border-radius: var(--tm-radius-sm);
    background: transparent;
    color: var(--tm-text-secondary);
    cursor: pointer;
    transition: all var(--tm-transition);
}

.tm-nav-toggle:hover {
    background: var(--tm-border-light);
    color: var(--tm-text);
}

.tm-nav-toggle i.icon {
    margin: 0;
    font-size: 1.15rem;
}

.tm-header .ui.menu {
    margin: 0;
    border: none;
    box-shadow: none;
    width: 100%;
    background: transparent;
    min-height: auto;
}

.tm-header .ui.secondary.menu .item {
    padding: 0.5rem 0.75rem;
    border-radius: var(--tm-radius-sm);
    color: var(--tm-text-secondary);
    transition: all var(--tm-transition);
    margin: 0 0.125rem;
}

.tm-header .ui.secondary.menu .item:hover {
    background: var(--tm-border-light);
    color: var(--tm-text);
}

.tm-header .ui.secondary.menu .item i.icon {
    color: var(--tm-text-muted);
    transition: color var(--tm-transition);
}

.tm-header .ui.secondary.menu .item:hover i.icon {
    color: var(--tm-primary);
}

.tm-header-text {
    margin-left: 0.5em;
    font-weight: 500;
    font-size: 0.9rem;
}

/* User profile pill in header */
.tm-header .right.menu .item {
    font-weight: 500;
}

.tm-user-pill {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem;
}

.tm-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tm-primary), #7c3aed);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0;
    flex-shrink: 0;
}

/* ── Content Area ─────────────────────────────────────────── */
.tm-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    scroll-behavior: smooth;
}

/* Custom scrollbar for content */
.tm-content::-webkit-scrollbar {
    width: 6px;
}

.tm-content::-webkit-scrollbar-track {
    background: transparent;
}

.tm-content::-webkit-scrollbar-thumb {
    background: var(--tm-border);
    border-radius: 6px;
}

.tm-content::-webkit-scrollbar-thumb:hover {
    background: var(--tm-text-muted);
}

.tm-content > .ui.segment.basic {
    margin: 0;
    padding: 0;
}

/* ── Page Headers ─────────────────────────────────────────── */
.tm-page-header {
    margin-bottom: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tm-page-header h1,
.tm-page-header h2,
.tm-page-header .ui.header {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--tm-text);
}

.tm-page-header h1 {
    font-size: 1.75rem;
}

.tm-page-header h2 {
    font-size: 1.5rem;
}

/* ── Fomantic UI Overrides – Segments (Cards) ─────────────── */
.ui.segment {
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-md) !important;
    box-shadow: var(--tm-shadow-sm);
    transition: box-shadow var(--tm-transition), transform var(--tm-transition);
    background: var(--tm-surface);
}

/* Hover lift only for raised (card-like) segments, not all segments */

.ui.raised.segment {
    box-shadow: var(--tm-shadow-md) !important;
    border: 1px solid var(--tm-border);
}

.ui.raised.segment:hover {
    box-shadow: var(--tm-shadow-lg) !important;
    transform: translateY(-1px);
}

.ui.stacked.segment {
    border-radius: var(--tm-radius-md) !important;
}

/* Colored segments – subtle top border instead of full color */
.ui.red.segment {
    border-top: 3px solid var(--tm-danger) !important;
    border-color: var(--tm-border) !important;
    border-top-color: var(--tm-danger) !important;
}

.ui.yellow.segment {
    border-top: 3px solid var(--tm-warning) !important;
    border-color: var(--tm-border) !important;
    border-top-color: var(--tm-warning) !important;
}

.ui.blue.segment {
    border-top: 3px solid var(--tm-primary) !important;
    border-color: var(--tm-border) !important;
    border-top-color: var(--tm-primary) !important;
}

.ui.green.segment {
    border-top: 3px solid var(--tm-success) !important;
    border-color: var(--tm-border) !important;
    border-top-color: var(--tm-success) !important;
}

/* Attached segments – preserve visual continuity */
.ui.attached.segment,
.ui.top.attached.segment,
.ui.bottom.attached.segment {
    box-shadow: none;
    border-radius: 0 !important;
}

.ui.top.attached.segment {
    border-radius: var(--tm-radius-md) var(--tm-radius-md) 0 0 !important;
}

.ui.bottom.attached.segment {
    border-radius: 0 0 var(--tm-radius-md) var(--tm-radius-md) !important;
}

/* Disable hover shadow on attached segments */
.ui.attached.segment:hover,
.ui.top.attached.segment:hover,
.ui.bottom.attached.segment:hover {
    box-shadow: none;
    transform: none;
}

/* Tabular menu attached to segment */
.ui.top.attached.tabular.menu {
    border-radius: var(--tm-radius-md) var(--tm-radius-md) 0 0 !important;
}

.ui.tabular.menu .item {
    border-radius: var(--tm-radius-sm) var(--tm-radius-sm) 0 0 !important;
}

/* Stacked segment – proper layered effect */
.ui.stacked.segment::before,
.ui.stacked.segment::after {
    border-radius: var(--tm-radius-md) !important;
}

/* ── Fomantic UI Overrides – Buttons ──────────────────────── */
.ui.button {
    border-radius: var(--tm-radius-sm) !important;
    font-weight: 600;
    letter-spacing: 0;
    transition: all var(--tm-transition);
    text-transform: none;
}

.ui.button:hover {
    transform: translateY(-1px);
    box-shadow: var(--tm-shadow-md);
}

.ui.button:active {
    transform: translateY(0);
}

/* Colored buttons – solid fill.
   `:not(.basic)` is mandatory: Fomantic's basic variant keeps a transparent
   background and a *colored* text/border. Overriding the background without
   excluding `.basic` paints the button in the accent colour while the text
   stays in Fomantic's own colour → coloured text on a coloured fill
   (e.g. #DB2828 on #EF4444 ≈ 1.4:1, well below the WCAG AA 4.5:1 minimum). */
.ui.primary.button:not(.basic),
.ui.blue.button:not(.basic) {
    background: var(--tm-primary) !important;
    border: none;
}

.ui.primary.button:not(.basic):hover,
.ui.blue.button:not(.basic):hover {
    background: var(--tm-primary-hover) !important;
    box-shadow: 0 4px 12px var(--tm-primary-glow);
}

.ui.positive.button:not(.basic),
.ui.green.button:not(.basic) {
    background: var(--tm-success) !important;
}

.ui.positive.button:not(.basic):hover,
.ui.green.button:not(.basic):hover {
    background: #065f46 !important;
    box-shadow: 0 4px 12px rgba(4, 120, 87, 0.25);
}

.ui.negative.button:not(.basic),
.ui.red.button:not(.basic) {
    background: var(--tm-danger) !important;
}

.ui.negative.button:not(.basic):hover,
.ui.red.button:not(.basic):hover {
    background: #b91c1c !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

/* Basic (outline) danger button – transparent fill, so the text carries the
   whole contrast burden. Fomantic's own #DB2828 only reaches 4.4:1 against the
   app background (--tm-bg #f1f5f9), just short of WCAG AA. Use the same dark red
   already used for negative messages and red labels (7.6:1). */
.ui.basic.negative.button,
.ui.basic.red.button {
    color: #991b1b !important;
    box-shadow: 0 0 0 1px #991b1b inset !important;
}

.ui.basic.negative.button:hover,
.ui.basic.red.button:hover {
    background: #fef2f2 !important;
    color: #7f1d1d !important;
    box-shadow: 0 0 0 1px #7f1d1d inset !important;
}

/* ── Fomantic UI Overrides – Tables ───────────────────────── */
.ui.table {
    border-radius: var(--tm-radius-md) !important;
    border: 1px solid var(--tm-border);
    overflow: hidden;
}

.ui.table thead th {
    background: var(--tm-border-light) !important;
    color: var(--tm-text-secondary) !important;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--tm-border) !important;
    padding: 0.875rem 1rem !important;
}

.ui.table tbody td {
    padding: 0.875rem 1rem !important;
    color: var(--tm-text);
    border-top: 1px solid var(--tm-border-light) !important;
    transition: background var(--tm-transition);
}

.ui.table tbody tr:hover td {
    background: rgba(79, 70, 229, 0.03) !important;
}

.ui.table tfoot th {
    background: var(--tm-surface) !important;
    border-top: 1px solid var(--tm-border) !important;
}

/* ── Fomantic UI Overrides – Forms & Inputs ───────────────── */
.ui.form .field > label {
    color: var(--tm-text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.375rem;
}

.ui.input input,
.ui.form input[type="text"],
.ui.form input[type="email"],
.ui.form input[type="password"],
.ui.form input[type="number"],
.ui.form textarea,
.ui.form select,
.ui.selection.dropdown {
    border-radius: var(--tm-radius-sm) !important;
    border: 1.5px solid var(--tm-border) !important;
    transition: all var(--tm-transition);
    font-size: 0.95rem;
}

.ui.input input:focus,
.ui.form input:focus,
.ui.form textarea:focus,
.ui.selection.dropdown:focus,
.ui.selection.active.dropdown {
    border-color: var(--tm-primary) !important;
    box-shadow: 0 0 0 3px var(--tm-primary-glow) !important;
    outline: none;
}

/* ── Action Input (search field + button joined) ─────────── */
.ui.action.input > input {
    border-radius: var(--tm-radius-sm) 0 0 var(--tm-radius-sm) !important;
}

.ui.action.input > .button {
    border-radius: 0 var(--tm-radius-sm) var(--tm-radius-sm) 0 !important;
}

/* ── Fomantic UI Overrides – Dropdowns ────────────────────── */
.ui.dropdown .menu {
    border-radius: var(--tm-radius-sm) !important;
    border: 1px solid var(--tm-border) !important;
    box-shadow: var(--tm-shadow-lg) !important;
    margin-top: 4px !important;
}

.ui.dropdown .menu > .item {
    border-radius: 0 !important;
    transition: background var(--tm-transition);
    padding: 0.75rem 1rem !important;
}

.ui.dropdown .menu > .item:hover {
    background: var(--tm-primary-light) !important;
    color: var(--tm-primary) !important;
}

.ui.dropdown .menu > .active.item {
    background: var(--tm-primary-light) !important;
    color: var(--tm-primary) !important;
    font-weight: 600;
}

/* ── Fomantic UI Overrides – Messages (subtle left-accent style) ── */
.ui.message {
    border-radius: var(--tm-radius-sm) !important;
    box-shadow: none;
    border: 1px solid var(--tm-border);
    font-size: 0.9rem;
}

.ui.info.message {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    color: var(--tm-text-secondary) !important;
    border-left: 3px solid var(--tm-accent) !important;
}

.ui.negative.message,
.ui.error.message {
    background: #fef8f8 !important;
    border-color: #fde8e8 !important;
    color: #991b1b !important;
    border-left: 3px solid var(--tm-danger) !important;
}

.ui.positive.message,
.ui.success.message {
    background: #f8fdf9 !important;
    border-color: #e0f5e4 !important;
    color: #166534 !important;
    border-left: 3px solid var(--tm-success) !important;
}

.ui.warning.message {
    background: #fefcf5 !important;
    border-color: #fdf0d0 !important;
    color: #92400e !important;
    border-left: 3px solid var(--tm-warning) !important;
}

/* ── Fomantic UI Overrides – Labels ───────────────────────── */
.ui.label {
    border-radius: 6px !important;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
}

.ui.green.label {
    background: #dcfce7 !important;
    color: #166534 !important;
    border: none !important;
}

.ui.red.label {
    background: #fef2f2 !important;
    color: #991b1b !important;
    border: none !important;
}

.ui.blue.label {
    background: var(--tm-primary-light) !important;
    color: #3730a3 !important;
    border: none !important;
}

.ui.yellow.label {
    background: #fef9c3 !important;
    color: #854d0e !important;
    border: none !important;
}

/* Without this override .ui.orange.label falls back to Fomantic's own
   #F2711C with white text (2.94:1) — used by OverdueBadge and every
   "expiring" counter on the dashboard. Same tinted-background pattern as the
   other label colors above; #9a3412 on #ffedd5 measures 6.38:1. */
.ui.orange.label {
    background: #ffedd5 !important;
    color: #9a3412 !important;
    border: none !important;
}

/* ── Fomantic UI Overrides – Modals ───────────────────────── */
.ui.modal {
    border-radius: var(--tm-radius-lg) !important;
    box-shadow: var(--tm-shadow-xl) !important;
    border: 1px solid var(--tm-border);
}

.ui.modal > .header {
    border-radius: var(--tm-radius-lg) var(--tm-radius-lg) 0 0 !important;
    border-bottom: 1px solid var(--tm-border);
    font-weight: 700;
    letter-spacing: -0.01em;
    padding: 1.25rem 1.5rem !important;
}

.ui.modal > .content {
    padding: 1.5rem !important;
}

.ui.modal > .actions {
    border-top: 1px solid var(--tm-border);
    border-radius: 0 0 var(--tm-radius-lg) var(--tm-radius-lg) !important;
    padding: 1rem 1.5rem !important;
    background: var(--tm-border-light);
}

/* ── Fomantic UI Overrides – Statistics ───────────────────── */
.ui.statistic > .value {
    font-weight: 800 !important;
    letter-spacing: -0.03em;
    color: var(--tm-text);
}

.ui.statistic > .label {
    color: var(--tm-text-muted) !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem !important;
    letter-spacing: 0.06em;
    margin-top: 0.5rem;
}

.ui.red.statistic > .value {
    color: var(--tm-danger) !important;
}

.ui.yellow.statistic > .value {
    color: var(--tm-warning) !important;
}

.ui.blue.statistic > .value {
    color: var(--tm-primary) !important;
}

.ui.green.statistic > .value {
    color: var(--tm-success) !important;
}

/* ── Fomantic UI Overrides – Dividers ─────────────────────── */
.ui.divider {
    border-top-color: var(--tm-border) !important;
}

/* ── Fomantic UI Overrides – Menu (in content) ────────────── */
.ui.menu {
    border-radius: var(--tm-radius-sm) !important;
}

.ui.pagination.menu .item {
    border-radius: var(--tm-radius-sm) !important;
    transition: all var(--tm-transition);
}

.ui.pagination.menu .active.item {
    background: var(--tm-primary) !important;
    color: white !important;
    border-radius: var(--tm-radius-sm) !important;
}

/* ── Login Page ───────────────────────────────────────────── */
.tm-login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #312e81 70%, #4338ca 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

/* Decorative gradient orbs */
.tm-login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.2) 0%, transparent 70%);
    top: -200px;
    right: -100px;
    pointer-events: none;
}

.tm-login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.15) 0%, transparent 70%);
    bottom: -100px;
    left: -50px;
    pointer-events: none;
}

.tm-login-container {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}

.tm-login-grid {
    height: 100%;
}

.tm-login-column {
    max-width: 440px !important;
}

.tm-login-header {
    text-align: center;
    margin-bottom: 2.5rem;
    color: #fff;
}

.tm-login-header i.icon {
    font-size: 3.5rem !important;
    margin-bottom: 1rem;
    opacity: 0.9;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tm-login-header h1 {
    font-size: 2rem;
    font-weight: 300;
    margin: 0;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, #e0e7ff, #ffffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tm-login-page .ui.stacked.segment {
    padding: 2.25rem;
    border-radius: var(--tm-radius-lg) var(--tm-radius-lg) 0 0 !important;
    box-shadow: var(--tm-shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    margin-bottom: 0;
}

.tm-login-page .ui.form .field {
    margin-bottom: 1.25rem;
}

.tm-login-page .ui.form .ui.button {
    margin-top: 0.75rem;
    height: 48px;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--tm-primary) 0%, #7c3aed 100%) !important;
    border: none;
}

.tm-login-page .ui.form .ui.button:hover {
    background: linear-gradient(135deg, var(--tm-primary-hover) 0%, #6d28d9 100%) !important;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
    transform: translateY(-1px);
}

.tm-login-page .ui.attached.message {
    background: rgba(255, 255, 255, 0.92) !important;
    color: var(--tm-text-muted) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-top: 1px solid var(--tm-border) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
    text-align: center;
    border-radius: 0 0 var(--tm-radius-lg) var(--tm-radius-lg) !important;
    backdrop-filter: blur(20px);
    font-size: 0.9rem;
}

.tm-login-page .ui.attached.message i.icon {
    opacity: 0.7;
}

/* ── Error UI ─────────────────────────────────────────────── */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

#blazor-error-ui .ui.message {
    margin: 0;
    border-radius: 0;
}

#blazor-error-ui[style] {
    display: block;
}

/* Blazor error boundary */
.blazor-error-boundary {
    background: var(--tm-danger);
    padding: 1rem 1.5rem;
    color: white;
    margin: 1rem;
    border-radius: var(--tm-radius-md);
    font-weight: 500;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ── Focus Styles ─────────────────────────────────────────── */
h1:focus {
    outline: none;
}

/* ── Validation Styles ────────────────────────────────────── */
.field.error input,
.field.error textarea,
.field.error select {
    background: #fef2f2 !important;
    border-color: #fca5a5 !important;
    color: #991b1b !important;
}

.field.error input:focus,
.field.error textarea:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* Field validation error prompts */
.ui.form .field.error .ui.prompt.label,
.ui.form .field .validation-message {
    background: transparent !important;
    border: none !important;
    color: var(--tm-danger) !important;
    font-size: 0.825rem;
    font-weight: 500;
    padding: 0.35rem 0 0 0;
    box-shadow: none !important;
}

/* ── Error Boundary Component ─────────────────────────────── */
.tm-error-boundary {
    padding: 1rem;
}

.tm-error-boundary .ui.message {
    max-width: 800px;
    margin: 2rem auto;
}

.tm-error-details {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--tm-border-light);
    border-radius: var(--tm-radius-sm);
    border: 1px solid var(--tm-border);
}

.tm-error-details pre {
    margin: 0.5rem 0 0 0;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: var(--tm-radius-sm);
    font-size: 0.85em;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.tm-error-details details {
    margin-top: 0.5rem;
}

.tm-error-details summary {
    cursor: pointer;
    color: var(--tm-text-muted);
    font-weight: 500;
    transition: color var(--tm-transition);
}

.tm-error-details summary:hover {
    color: var(--tm-text-secondary);
}

.tm-error-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

/* ── Toast Notification Panel ─────────────────────────────── */
/* Anchored bottom-right, deliberately. Top-right put toasts directly on top of
   the page-header action buttons (Create…, Back, Edit), so for the toast's
   lifetime — up to 10 s for an error — those buttons could not be clicked.
   pointer-events keeps the container itself click-through; only the toast
   bodies take input, so its empty area never swallows a click either. */
.notification-panel,
.notifications {
    position: fixed !important;
    bottom: 1rem !important;
    right: 1rem !important;
    top: auto !important;
    left: auto !important;
    z-index: 1001;
    max-width: 400px;
    pointer-events: none;
}

.notification-panel > *,
.notifications > * {
    pointer-events: auto;
}

.notification-panel .ui.message,
.notifications .ui.message {
    border-radius: var(--tm-radius-sm) !important;
    box-shadow: var(--tm-shadow-lg) !important;
    animation: tm-slide-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes tm-slide-in {
    from {
        opacity: 0;
        transform: translateX(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* ── Loading States ───────────────────────────────────────── */
.tm-loading {
    position: relative;
    min-height: 100px;
}

.tm-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    border-radius: var(--tm-radius-md);
    backdrop-filter: blur(2px);
}

/* Loading spinner override */
.ui.loader::after {
    border-color: var(--tm-primary) transparent transparent !important;
}

/* ── Utility Classes ──────────────────────────────────────── */
.tm-mt-0 { margin-top: 0 !important; }
.tm-mb-0 { margin-bottom: 0 !important; }
.tm-mt-1 { margin-top: 1rem !important; }
.tm-mb-1 { margin-bottom: 1rem !important; }
.tm-mt-2 { margin-top: 2rem !important; }
.tm-mb-2 { margin-bottom: 2rem !important; }

/* ── Site Switcher (sidebar dark dropdown) ───────────────── */
.tm-sidebar .tm-site-switcher {
    width: 100%;
}

.tm-sidebar .tm-site-switcher .ui.selection.dropdown {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: rgba(255, 255, 255, 0.9) !important;
    min-height: 2.2rem;
    font-size: 0.85rem !important;
    border-radius: var(--tm-radius-sm) !important;
    width: 100% !important;
}

.tm-sidebar .tm-site-switcher .ui.selection.dropdown:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.tm-sidebar .tm-site-switcher .ui.selection.active.dropdown,
.tm-sidebar .tm-site-switcher .ui.selection.dropdown:focus,
.tm-sidebar .tm-site-switcher .ui.selection.dropdown.active,
.tm-sidebar .tm-site-switcher .ui.selection.dropdown.visible {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    box-shadow: none !important;
}

.tm-sidebar .tm-site-switcher .ui.selection.dropdown .default.text {
    color: rgba(255, 255, 255, 0.45) !important;
}

.tm-sidebar .tm-site-switcher .ui.selection.dropdown .text {
    color: rgba(255, 255, 255, 0.9) !important;
}

.tm-sidebar .tm-site-switcher .ui.selection.dropdown .menu {
    background: #1e293b !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.tm-sidebar .tm-site-switcher .ui.selection.dropdown .menu > .item {
    color: rgba(255, 255, 255, 0.75) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
}

.tm-sidebar .tm-site-switcher .ui.selection.dropdown .menu > .item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

.tm-sidebar .tm-site-switcher .ui.selection.dropdown .menu > .item.active {
    background: rgba(79, 70, 229, 0.2) !important;
    color: #ffffff !important;
}

.tm-sidebar .tm-site-switcher .ui.selection.dropdown i.dropdown.icon {
    color: rgba(255, 255, 255, 0.5) !important;
}

.tm-sidebar .tm-site-switcher .ui.selection.dropdown input.search {
    color: rgba(255, 255, 255, 0.9) !important;
    background: transparent !important;
}

.tm-sidebar .tm-site-switcher .ui.dropdown.selected,
.tm-sidebar .tm-site-switcher .ui.dropdown .menu .selected.item {
    background: rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

/* ── Group Filter (sidebar dark dropdown) ────────────────── */
.tm-sidebar .tm-group-filter {
    width: 100%;
}

.tm-sidebar .tm-group-filter .ui.selection.dropdown {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: rgba(255, 255, 255, 0.9) !important;
    min-height: 2.2rem;
    font-size: 0.85rem !important;
    border-radius: var(--tm-radius-sm) !important;
    width: 100% !important;
}

.tm-sidebar .tm-group-filter .ui.selection.dropdown:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.tm-sidebar .tm-group-filter .ui.selection.active.dropdown,
.tm-sidebar .tm-group-filter .ui.selection.dropdown:focus,
.tm-sidebar .tm-group-filter .ui.selection.dropdown.active,
.tm-sidebar .tm-group-filter .ui.selection.dropdown.visible {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    box-shadow: none !important;
}

.tm-sidebar .tm-group-filter .ui.selection.dropdown .default.text {
    color: rgba(255, 255, 255, 0.45) !important;
}

.tm-sidebar .tm-group-filter .ui.selection.dropdown .text {
    color: rgba(255, 255, 255, 0.9) !important;
}

.tm-sidebar .tm-group-filter .ui.selection.dropdown .menu {
    background: #1e293b !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.tm-sidebar .tm-group-filter .ui.selection.dropdown .menu > .item {
    color: rgba(255, 255, 255, 0.75) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
}

.tm-sidebar .tm-group-filter .ui.selection.dropdown .menu > .item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

.tm-sidebar .tm-group-filter .ui.selection.dropdown .menu > .item.active {
    background: rgba(79, 70, 229, 0.2) !important;
    color: #ffffff !important;
}

.tm-sidebar .tm-group-filter .ui.selection.dropdown i.dropdown.icon,
.tm-sidebar .tm-group-filter .ui.selection.dropdown i.delete.icon {
    color: rgba(255, 255, 255, 0.5) !important;
}

.tm-sidebar .tm-group-filter .ui.selection.dropdown input.search {
    color: rgba(255, 255, 255, 0.9) !important;
    background: transparent !important;
}

.tm-sidebar .tm-group-filter .ui.dropdown.selected,
.tm-sidebar .tm-group-filter .ui.dropdown .menu .selected.item {
    background: rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

/* ── Responsive ───────────────────────────────────────────── */
@media only screen and (max-width: 768px) {
    :root {
        --tm-sidebar-width: 220px;
    }

    .tm-content {
        padding: 1.25rem;
    }

    .tm-header {
        padding: 0 1rem;
    }

    /* Sidebar becomes an off-canvas drawer, toggled by .tm-nav-toggle */
    .tm-nav-toggle {
        display: inline-flex;
    }

    .tm-sidebar {
        position: fixed;
        left: calc(-1 * var(--tm-sidebar-width));
        z-index: 100;
        transition: left var(--tm-transition-slow);
        box-shadow: none;
    }

    .tm-sidebar.visible {
        left: 0;
        box-shadow: var(--tm-shadow-xl);
    }

    .tm-main {
        width: 100%;
    }
}

@media only screen and (max-width: 480px) {
    .tm-content {
        padding: 1rem;
    }
}

/* ── Session detail on narrow viewports ───────────────────── */

/* Fomantic keeps `four wide column` at 25% at every width, so on a phone the four
   overview values are squeezed until they run into each other ("AdministratorMichal
   Straka"). Two per row under 700px, one per row under 480px. The `!important` is
   not decoration — Fomantic's own column widths carry it and would otherwise win. */
@media only screen and (max-width: 700px) {
    .session-overview-grid.ui.grid > .four.wide.column {
        width: 50% !important;
    }
}

@media only screen and (max-width: 480px) {
    .session-overview-grid.ui.grid > .four.wide.column {
        width: 100% !important;
    }
}

/* Five tabs never fit into 375px. Let the strip scroll sideways and mark the edge
   that still has tabs behind it.

   The two cover layers sit on `background-attachment: local`, so they travel with
   the content and slide off exactly when that edge is reached; the two shadow
   layers stay put on `scroll`. The result is a shadow that appears only while
   there is something to scroll to — a plain static gradient would keep promising
   more tabs after the user had already reached the last one. The cover colour is
   --tm-bg because .ui.tabular.menu is transparent and sits directly on the page. */
@media only screen and (max-width: 700px) {
    .session-detail-tabs.ui.tabular.menu {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        background-image:
            linear-gradient(to right, var(--tm-bg) 40%, rgba(241, 245, 249, 0)),
            linear-gradient(to left, var(--tm-bg) 40%, rgba(241, 245, 249, 0)),
            linear-gradient(to right, rgba(15, 23, 42, 0.18), rgba(15, 23, 42, 0)),
            linear-gradient(to left, rgba(15, 23, 42, 0.18), rgba(15, 23, 42, 0));
        background-position: left center, right center, left center, right center;
        background-repeat: no-repeat;
        background-size: 26px 100%, 26px 100%, 12px 100%, 12px 100%;
        background-attachment: local, local, scroll, scroll;
    }

    /* The scrollbar itself is not the affordance here; the edge shadow is. */
    .session-detail-tabs.ui.tabular.menu::-webkit-scrollbar {
        display: none;
    }

    .session-detail-tabs.ui.tabular.menu > .item {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

/* ── Selection & Highlights ───────────────────────────────── */
::selection {
    background: var(--tm-primary-light);
    color: var(--tm-primary-hover);
}

/* ── Smooth page transitions ──────────────────────────────── */
.tm-content > * {
    animation: tm-fade-in 0.25s ease-out;
}

@keyframes tm-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Public Page (anonymous signature) ───────────────────── */
.tm-public-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #312e81 70%, #4338ca 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.tm-public-container {
    width: 100%;
    max-width: 550px;
    position: relative;
    z-index: 1;
}

.tm-public-header {
    text-align: center;
    margin-bottom: 2rem;
    color: #fff;
}

.tm-public-header i.icon {
    font-size: 2.5rem !important;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.tm-public-header h2 {
    font-size: 1.6rem;
    font-weight: 300;
    margin: 0;
    letter-spacing: 0.5px;
    opacity: 0.95;
}

.tm-public-page .ui.segment {
    background: rgba(255, 255, 255, 0.97);
    border: none;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 2rem;
}

.tm-signature-info {
    margin-bottom: 1.5rem;
}

.tm-signature-info .item {
    padding: 0.4rem 0 !important;
}

.tm-signature-info .header {
    color: #6b7280 !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
}

.tm-signature-info .description {
    font-size: 1rem !important;
    color: #1f2937 !important;
    font-weight: 600 !important;
}

.tm-signature-confirmation {
    text-align: center;
    padding: 2rem 0;
}

.tm-signature-confirmation i.icon {
    font-size: 4rem !important;
    color: #22c55e;
    margin-bottom: 1rem;
}

.tm-signature-confirmation h3 {
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.tm-signature-confirmation p {
    color: #6b7280;
}

/* ── Attendance result labels (TM-31) ─────────────────────── */
/* The result must be tellable from across a classroom, not only by reading the
   word. The glyph carries the same meaning as the text — it is decorative for
   assistive tech (aria-hidden) because the label text already names the state,
   so this is a usability improvement, not a WCAG 1.4.1 fix. */
.attendance-result-glyph {
    font-weight: 700;
    margin-right: 0.35em;
    font-size: 1.05em;
    line-height: 1;
}

/* Pending is the only state that still demands an action, so it is the most
   conspicuous of the scale. It used to be the quietest (grey). */
.ui.label[data-result="Pending"] {
    box-shadow: inset 0 0 0 1px #ca8a04 !important;
}

/* ── Selection chips in the add-participants / add-agenda dialogs (TM-22) ── */
/* The selection survives a new search, so it needs to stay visible even when the
   current result page no longer contains the selected rows. */
.tm-selected-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    max-height: 7rem;
    overflow-y: auto;
}

.tm-selected-chips .ui.label {
    display: inline-flex;
    align-items: center;
}

.tm-selected-chips .delete.icon {
    cursor: pointer;
    margin-left: 0.4em;
}

/* The clear button sits between the field and the magnifier, so it must not take
   the rounded end-cap that Fomantic gives the last button of an action input. */
.tm-search-input .tm-search-clear {
    border-radius: 0 !important;
}
