/* ==========================================================================
   KR CONNECT — UI 2.0 design system
   One stylesheet for every page that uses layouts.app (and the auth pages).
   Sections: tokens · base · shell · page · surfaces · controls · data · overlays · utilities
   Bootstrap 5.3 is still loaded underneath for grid / modal / tab behaviour;
   this file re-themes it so legacy markup inside new pages looks native.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --brand-50: #f1f0ff;
    --brand-100: #e4e1ff;
    --brand-200: #cbc5ff;
    --brand-300: #a99dff;
    --brand-400: #8a76ff;
    --brand-500: #6d4dff;
    --brand-600: #5b34f2;
    --brand-700: #4b26d1;
    --brand: var(--brand-500);
    --accent: #14c8e8;
    --pink: #f0509b;

    --ok: #12b886;
    --ok-soft: #e3f9f1;
    --warn: #f59f00;
    --warn-soft: #fff4dc;
    --bad: #f03e3e;
    --bad-soft: #ffe8e8;
    --info: #228be6;
    --info-soft: #e3f1ff;

    --bg: #f5f6fb;
    --bg-elev: #ffffff;
    --surface: #ffffff;
    --surface-2: #f8f9fd;
    --surface-3: #eef0f7;
    --ink: #0e1330;
    --ink-2: #3b4163;
    --muted: #747a99;
    --line: #e6e8f2;
    --line-strong: #d6d9e8;
    --glass: rgba(255, 255, 255, .72);
    --glass-line: rgba(255, 255, 255, .6);

    --grad: linear-gradient(135deg, #6d4dff 0%, #a64dff 48%, #14c8e8 100%);
    --grad-soft: linear-gradient(135deg, rgba(109, 77, 255, .12), rgba(20, 200, 232, .12));
    --grad-warm: linear-gradient(135deg, #ff7a59, #f0509b);
    --grad-ok: linear-gradient(135deg, #12b886, #38d9a9);
    --grad-sky: linear-gradient(135deg, #228be6, #14c8e8);
    --grad-sun: linear-gradient(135deg, #f59f00, #ffd43b);

    --r-xs: 8px;
    --r-sm: 12px;
    --r: 16px;
    --r-lg: 22px;
    --r-xl: 28px;
    --r-pill: 999px;

    --sh-xs: 0 1px 2px rgba(16, 21, 64, .06);
    --sh-sm: 0 1px 2px rgba(16, 21, 64, .05), 0 2px 8px -2px rgba(16, 21, 64, .08);
    --sh: 0 2px 4px rgba(16, 21, 64, .04), 0 10px 28px -10px rgba(16, 21, 64, .16);
    --sh-lg: 0 30px 60px -20px rgba(16, 21, 64, .32);
    --sh-brand: 0 10px 30px -10px rgba(109, 77, 255, .65);
    --ring: 0 0 0 4px rgba(109, 77, 255, .18);

    --ease: cubic-bezier(.2, .8, .2, 1);
    --spring: cubic-bezier(.34, 1.56, .64, 1);

    --sidebar-w: 276px;
    --sidebar-w-mini: 84px;
    --topbar-h: 68px;
    --bottomnav-h: 68px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);

    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0a0c1b;
    --bg-elev: #11142a;
    --surface: #131731;
    --surface-2: #181c3a;
    --surface-3: #1f2447;
    --ink: #eef0ff;
    --ink-2: #c3c7e6;
    --muted: #8a90b8;
    --line: #242a52;
    --line-strong: #2f3666;
    --glass: rgba(19, 23, 49, .72);
    --glass-line: rgba(255, 255, 255, .08);
    --ok-soft: rgba(18, 184, 134, .16);
    --warn-soft: rgba(245, 159, 0, .16);
    --bad-soft: rgba(240, 62, 62, .16);
    --info-soft: rgba(34, 139, 230, .16);
    --brand-50: rgba(109, 77, 255, .14);
    --brand-100: rgba(109, 77, 255, .22);
    --sh-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --sh: 0 10px 30px -12px rgba(0, 0, 0, .6);
    --sh-lg: 0 30px 60px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
}

/* Bootstrap bridge */
:root, [data-theme] {
    --bs-body-font-family: var(--font);
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
    --bs-primary: var(--brand);
    --bs-primary-rgb: 109, 77, 255;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 109, 77, 255;
    --bs-link-hover-color: var(--brand-600);
    --bs-secondary-color: var(--muted);
    --bs-tertiary-bg: var(--surface-2);
    --bs-border-radius: var(--r-sm);
    --bs-border-radius-lg: var(--r);
    --bs-emphasis-color: var(--ink);
    --bs-heading-color: var(--ink);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body.ui {
    margin: 0;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    min-height: 100vh;
    min-height: 100dvh;
}
.ui h1, .ui h2, .ui h3, .ui h4, .ui h5, .ui h6 { font-weight: 750; letter-spacing: -.02em; color: var(--ink); }
.ui a { color: var(--brand); text-decoration: none; }
.ui ::selection { background: rgba(109, 77, 255, .22); }
.ui :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.ui img { max-width: 100%; }
.ui .text-muted { color: var(--muted) !important; }
.mono { font-family: var(--mono); font-feature-settings: 'zero'; }
.tnum { font-variant-numeric: tabular-nums; }

.skip-link {
    position: fixed; left: 12px; top: -60px; z-index: 5000;
    padding: 10px 16px; border-radius: var(--r-sm);
    background: var(--ink); color: #fff !important; font-weight: 600;
    transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

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

/* Ambient background glow */
.ui-ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.ui-ambient::before, .ui-ambient::after {
    content: ''; position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55;
}
.ui-ambient::before { width: 560px; height: 560px; top: -240px; right: -120px; background: radial-gradient(circle, rgba(166, 77, 255, .28), transparent 70%); }
.ui-ambient::after { width: 520px; height: 520px; bottom: -260px; left: 10%; background: radial-gradient(circle, rgba(20, 200, 232, .2), transparent 70%); }

/* ---------- 3. Shell ---------- */
.shell { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }

/* Sidebar */
.side {
    position: fixed; z-index: 1040; top: 12px; bottom: 12px; left: 12px;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    transition: width .35s var(--ease), transform .35s var(--ease);
    overflow: hidden;
}
.side-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 18px 14px; min-height: 72px;
}
.side-brand img.full { height: 38px; width: auto; object-fit: contain; }
.side-brand img.mini { display: none; height: 38px; width: 38px; object-fit: contain; }
[data-theme="dark"] .side-brand img.full { filter: brightness(0) invert(1); opacity: .92; }

.side-search { padding: 0 14px 10px; }
.side-search button {
    width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--r-sm);
    border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
    font: 500 13px var(--font); cursor: pointer; transition: border-color .2s, background .2s;
}
.side-search button:hover { border-color: var(--brand-200); background: var(--surface); }
.side-search kbd {
    margin-left: auto; padding: 1px 6px; border-radius: 6px;
    border: 1px solid var(--line-strong); background: var(--surface);
    font: 600 11px var(--font); color: var(--muted); box-shadow: none;
}

.side-nav { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 16px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.side-label { margin: 14px 10px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.nav-item {
    position: relative; display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 10px 12px; margin: 2px 0;
    border: 0; border-radius: var(--r-sm); background: none;
    color: var(--ink-2) !important; font: 600 13.5px var(--font); text-align: left;
    cursor: pointer; transition: background .2s var(--ease), color .2s, transform .15s;
    white-space: nowrap;
}
.nav-item .ico {
    flex: 0 0 34px; height: 34px; display: grid; place-items: center;
    border-radius: 10px; background: var(--surface-2); color: var(--muted);
    font-size: 14px; transition: background .25s var(--ease), color .25s, box-shadow .25s;
}
.nav-item .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-item .chev { font-size: 11px; color: var(--muted); transition: transform .3s var(--ease); }
.nav-item:hover { background: var(--surface-2); color: var(--ink) !important; }
.nav-item:hover .ico { color: var(--brand); background: var(--brand-50); }
.nav-item:active { transform: scale(.98); }
.nav-item.is-active { background: var(--brand-50); color: var(--brand-700) !important; }
[data-theme="dark"] .nav-item.is-active { color: #fff !important; }
.nav-item.is-active .ico { background: var(--grad); color: #fff; box-shadow: var(--sh-brand); }
.nav-group.is-open > .nav-item .chev { transform: rotate(90deg); }
.nav-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s var(--ease); }
.nav-group.is-open > .nav-sub { grid-template-rows: 1fr; }
.nav-sub > div { overflow: hidden; padding-left: 22px; position: relative; }
.nav-sub > div::before { content: ''; position: absolute; left: 28px; top: 4px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--line); }
.nav-sub .nav-item { padding: 8px 12px 8px 24px; font-size: 13px; }
.nav-sub .nav-item .ico { flex-basis: 28px; height: 28px; font-size: 12px; background: transparent; }
.nav-sub .nav-item.is-active .ico { background: var(--grad); }

.side-foot { padding: 12px; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); }
.side-user .who { min-width: 0; flex: 1; }
.side-user .who b { display: block; font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who span { font-size: 11.5px; color: var(--muted); }

/* Collapsed (desktop) */
.shell.is-mini .side { width: var(--sidebar-w-mini); }
.shell.is-mini .side-brand { justify-content: center; padding-inline: 0; }
.shell.is-mini .side-brand img.full,
.shell.is-mini .side-search,
.shell.is-mini .side-label,
.shell.is-mini .nav-item .lbl,
.shell.is-mini .nav-item .chev,
.shell.is-mini .side-user .who,
.shell.is-mini .side-user form { display: none; }
.shell.is-mini .side-brand img.mini { display: block; }
.shell.is-mini .nav-item { justify-content: center; padding-inline: 0; }
.shell.is-mini .nav-sub > div { padding-left: 0; }
.shell.is-mini .nav-sub > div::before { display: none; }
.shell.is-mini .nav-sub .nav-item { padding-inline: 0; }
.shell.is-mini .side-user { justify-content: center; }

/* Main column */
.main {
    margin-left: calc(var(--sidebar-w) + 24px);
    padding: 0 24px 32px 0;
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column;
    transition: margin-left .35s var(--ease);
}
.shell.is-mini .main { margin-left: calc(var(--sidebar-w-mini) + 24px); }

/* Topbar */
.top {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 12px;
    height: calc(var(--topbar-h) + 12px); padding-top: 12px;
    background: linear-gradient(var(--bg) 70%, transparent);
}
.top-inner {
    flex: 1; display: flex; align-items: center; gap: 12px; height: var(--topbar-h);
    padding: 0 12px 0 16px; border-radius: var(--r-lg);
    background: var(--glass); border: 1px solid var(--line);
    backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.top-title { min-width: 0; flex: 1; }
/* 2026-11-19: let the bar shrink to the viewport (long headings / dept chip pushed it to ~500px on phones) */
.top-inner { min-width: 0; }
.top-title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { flex-shrink: 0; }
.top-title small { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.top-title h1 { margin: 0; font-size: 17px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
    position: relative; width: 42px; height: 42px; flex: 0 0 42px;
    display: grid; place-items: center; border-radius: 13px;
    border: 1px solid transparent; background: transparent; color: var(--ink-2);
    font-size: 16px; cursor: pointer; transition: background .2s, color .2s, transform .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.outlined { border-color: var(--line); background: var(--surface); }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 0 2px var(--surface); }

.avatar {
    position: relative; width: 40px; height: 40px; flex: 0 0 40px; border-radius: 13px;
    object-fit: cover; background: var(--grad); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 14px; overflow: hidden;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; flex-basis: 32px; border-radius: 10px; font-size: 12px; }
.avatar.lg { width: 64px; height: 64px; flex-basis: 64px; border-radius: 20px; font-size: 22px; }
.avatar.xl { width: 96px; height: 96px; flex-basis: 96px; border-radius: 28px; font-size: 32px; }
.avatar.ring { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand-300); }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border: 0; background: none; border-radius: 15px; cursor: pointer; transition: background .2s; }
.user-chip:hover { background: var(--surface-2); }
.user-chip .who { text-align: left; line-height: 1.2; }
.user-chip .who b { display: block; font-size: 13px; color: var(--ink); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { font-size: 11px; color: var(--muted); }

/* Department switch (HODs of two departments) */
.dept-chip {
    display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px; border-radius: 13px;
    border: 1px solid var(--brand-200, var(--line)); background: var(--brand-50, var(--surface-2)); color: var(--brand-700, var(--ink)) !important;
    font: 750 12.5px var(--font); letter-spacing: .02em; cursor: pointer; white-space: nowrap; transition: background .2s, border-color .2s;
}
.dept-chip:hover { border-color: var(--brand-300, var(--line-strong)); }
.dept-chip .caret { font-size: 10px; opacity: .7; }
[data-theme="dark"] .dept-chip { color: #fff !important; }
.pop.dept-pop { min-width: 290px; }
.dept-pop .pop-item { align-items: flex-start; }
.dept-pop .pop-item i { margin-top: 3px; }
.dept-pop .pop-item.is-current { background: var(--brand-50, var(--surface-2)); cursor: default; }
.dept-pop .pop-item.is-current i { color: var(--brand) !important; }
.dept-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.dept-name small { font-size: 11.5px; font-weight: 500; color: var(--muted); white-space: normal; }
@media (max-width: 575.98px) {
    .dept-chip { padding: 0 9px; gap: 5px; }
    .dept-chip > .fa-building-columns { display: none; }
    .pop.dept-pop { position: fixed; left: 12px; right: 12px; top: 76px; min-width: 0; transform-origin: top center; }
    /* room for the chip: theme stays in the account menu ("Switch theme") */
    .top-actions:has(.dept-chip) > .icon-btn[data-theme-toggle] { display: none; }
}

/* Dropdown */
.pop {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 1100; min-width: 230px;
    padding: 8px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line);
    box-shadow: var(--sh-lg); opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right;
    pointer-events: none; transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.pop.is-open { opacity: 1; transform: none; pointer-events: auto; }
.pop-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px;
    background: none; color: var(--ink-2) !important; font: 600 13px var(--font); text-align: left; cursor: pointer;
}
.pop-item:hover { background: var(--surface-2); color: var(--ink) !important; }
.pop-item i { width: 18px; text-align: center; color: var(--muted); }
.pop-item.danger, .pop-item.danger i { color: var(--bad) !important; }
.pop-sep { height: 1px; margin: 6px 4px; background: var(--line); }
.pop-head { padding: 10px 12px 8px; }
.pop-head b { display: block; font-size: 14px; }
.pop-head span { font-size: 12px; color: var(--muted); }

/* Content */
.content { position: relative; flex: 1; padding-top: 8px; animation: rise .5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.foot { margin-top: 32px; padding: 16px 4px 0; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

/* Bottom navigation (mobile) */
.bnav { display: none; }

/* Backdrop for drawers / sheets */
.scrim {
    position: fixed; inset: 0; z-index: 1045; background: rgba(8, 10, 30, .45);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none; transition: opacity .3s var(--ease);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

/* Bottom sheet */
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1050;
    max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column;
    background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, .35);
    transform: translateY(105%); transition: transform .42s var(--ease);
    padding-bottom: var(--safe-b);
}
.sheet.is-open { transform: none; }
.sheet-grip { display: block; width: 44px; height: 5px; margin: 10px auto 4px; border-radius: 5px; background: var(--line-strong); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 8px 20px 12px; }
.sheet-head h3 { margin: 0; font-size: 18px; flex: 1; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 20px; }
.sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sheet-tile {
    display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 4px;
    border-radius: var(--r); color: var(--ink-2) !important; font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.25;
    transition: background .2s;
}
.sheet-tile:active { background: var(--surface-2); }
.sheet-tile .ico { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 17px; font-size: 19px; color: #fff; background: var(--grad); box-shadow: var(--sh-brand); }
.sheet-tile.is-active { color: var(--brand) !important; }
.sheet-section { margin: 14px 4px 8px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* Tile colour rotation (keeps the grid lively but systematic) */
.tone-1 { --tone: linear-gradient(135deg, #6d4dff, #a64dff); --tone-solid: #6d4dff; --tone-soft: rgba(109, 77, 255, .12); }
.tone-2 { --tone: linear-gradient(135deg, #14c8e8, #228be6); --tone-solid: #1c9fe0; --tone-soft: rgba(28, 159, 224, .12); }
.tone-3 { --tone: linear-gradient(135deg, #12b886, #38d9a9); --tone-solid: #12b886; --tone-soft: rgba(18, 184, 134, .12); }
.tone-4 { --tone: linear-gradient(135deg, #ff7a59, #f0509b); --tone-solid: #f0507a; --tone-soft: rgba(240, 80, 122, .12); }
.tone-5 { --tone: linear-gradient(135deg, #f59f00, #ffc029); --tone-solid: #f08c00; --tone-soft: rgba(245, 159, 0, .14); }
.tone-6 { --tone: linear-gradient(135deg, #7950f2, #e64980); --tone-solid: #9c48d8; --tone-soft: rgba(156, 72, 216, .12); }
[class*="tone-"] .ico { background: var(--tone); }

/* Command palette */
.cmdk {
    position: fixed; z-index: 1060; left: 50%; top: 12vh; width: min(620px, calc(100vw - 24px));
    transform: translateX(-50%) translateY(-10px) scale(.98); opacity: 0; pointer-events: none;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
    transition: opacity .2s var(--ease), transform .2s var(--ease); overflow: hidden;
}
.cmdk.is-open { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.cmdk-input { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.cmdk-input i { color: var(--muted); }
.cmdk-input input { flex: 1; border: 0; outline: 0; background: none; color: var(--ink); font: 500 16px var(--font); }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 8px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--ink-2) !important; font-weight: 600; font-size: 14px; }
.cmdk-item .ico { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--brand); font-size: 13px; }
.cmdk-item small { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 12px; }
.cmdk-item.is-hl { background: var(--brand-50); color: var(--ink) !important; }
.cmdk-empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- 4. Page scaffolding ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 22px; }
.page-head h2 { margin: 0; font-size: clamp(22px, 2.4vw, 28px); font-weight: 800; letter-spacing: -.03em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- 5. Surfaces ---------- */
.card-x {
    position: relative; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
.card-x.pad { padding: 22px; }
.card-x.hover { transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s; }
.card-x.hover:hover { transform: translateY(-3px); box-shadow: var(--sh); border-color: var(--line-strong); }
.card-h { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font-size: 15.5px; font-weight: 750; flex: 1; }
.card-h p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.card-h .ico { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 12px; background: var(--tone-soft, var(--brand-50)); color: var(--tone-solid, var(--brand)); }
.card-b { padding: 20px 22px; }
.card-f { padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* Hero */
.hero {
    position: relative; overflow: hidden; isolation: isolate;
    padding: 28px; border-radius: var(--r-xl); color: #fff;
    background: radial-gradient(120% 140% at 0% 0%, #8a63ff 0%, #5b34f2 38%, #2a1a8f 100%);
    box-shadow: 0 30px 60px -30px rgba(91, 52, 242, .8);
}
.hero::before {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background:
        radial-gradient(40% 60% at 90% 10%, rgba(20, 200, 232, .55), transparent 70%),
        radial-gradient(35% 50% at 70% 110%, rgba(240, 80, 155, .55), transparent 70%);
    animation: drift 14s ease-in-out infinite alternate;
}
.hero::after {
    content: ''; position: absolute; inset: 0; z-index: -1; opacity: .18;
    background-image: radial-gradient(rgba(255, 255, 255, .9) 1px, transparent 1px);
    background-size: 18px 18px;
    mask-image: linear-gradient(120deg, transparent 30%, #000 100%);
    -webkit-mask-image: linear-gradient(120deg, transparent 30%, #000 100%);
}
@keyframes drift { to { transform: translate3d(-6%, 4%, 0) scale(1.08); } }
.hero h2 { color: #fff; margin: 0; font-size: clamp(22px, 3vw, 32px); font-weight: 800; letter-spacing: -.03em; }
.hero p { margin: 6px 0 0; color: rgba(255, 255, 255, .78); }
.hero .chip { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .22); backdrop-filter: blur(8px); }

/* KPI tile */
.kpi { position: relative; overflow: hidden; padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-sm); transition: transform .25s var(--ease), box-shadow .25s; }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--sh); }
.kpi .ico { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--tone, var(--grad)); color: #fff; font-size: 17px; box-shadow: 0 10px 20px -10px var(--tone-solid, var(--brand)); }
.kpi .lbl { margin-top: 14px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi .val { margin-top: 2px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); line-height: 1.25; word-break: break-word; }
.kpi .sub { margin-top: 4px; font-size: 12px; color: var(--muted); }
.kpi::after { content: ''; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: var(--tone-soft, var(--brand-50)); }
/* Wider screens: compact tile, icon beside label + value (about half the height). */
@media (min-width: 576px) {
    .kpi:has(> .ico) { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; align-content: center; padding: 16px 18px; }
    .kpi:has(> .ico) > .ico { grid-row: 1 / span 3; align-self: center; }
    .kpi:has(> .ico) > :not(.ico) { grid-column: 2; position: relative; z-index: 1; }
    .kpi:has(> .ico) .lbl { margin-top: 0; }
}
/* Safety net: a row of KPI tiles without a grid wrapper still sits side by side.
   Zero specificity, so any page's own layout for the wrapper wins. */
:where(.ui) :where(:has(> .kpi + .kpi)) { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }

/* Ring progress */
.ring { --p: 0; --size: 92px; --stroke: 10px; position: relative; width: var(--size); height: var(--size); flex: 0 0 var(--size); }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: calc(var(--stroke) / 3.2); } /* --stroke is in px of a 36-unit viewBox: scale so the ring stays inside its circle */
.ring .track { stroke: var(--surface-3); }
.ring .bar { stroke: url(#ringGrad); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p)); transition: stroke-dashoffset 1.2s var(--ease); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.ring .num small { font-size: 11px; color: var(--muted); font-weight: 700; }

/* Linear progress */
.meter { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--grad); transform-origin: left; animation: grow 1.1s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }

/* List rows */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 22px; border-top: 1px solid var(--line); color: var(--ink) !important; }
.list-row:first-child { border-top: 0; }
a.list-row:hover, button.list-row:hover { background: var(--surface-2); }
.list-row .ico { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 12px; background: var(--tone-soft, var(--brand-50)); color: var(--tone-solid, var(--brand)); }
.list-row .t { min-width: 0; flex: 1; }
.list-row .t b { display: block; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.list-row .t span { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* Definition list (label / value pairs) */
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 18px; }
.dl > div { padding: 10px 0; border-bottom: 1px dashed var(--line); min-width: 0; }
.dl dt { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dl dd { margin: 2px 0 0; font-weight: 650; color: var(--ink); word-break: break-word; }

/* Empty state */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ico { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 22px; margin-bottom: 14px; background: var(--grad-soft); color: var(--brand); font-size: 24px; }
.empty b { color: var(--ink); font-size: 15px; }
.empty p { margin: 4px 0 0; font-size: 13px; max-width: 340px; }

/* Skeleton */
.skel { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 8px; }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Chips / badges */
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
    border-radius: var(--r-pill); border: 1px solid var(--line);
    background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 650; white-space: nowrap;
}
.chip .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-soft); border-color: transparent; color: #0c8a64; }
.chip.warn { background: var(--warn-soft); border-color: transparent; color: #b66a00; }
.chip.bad { background: var(--bad-soft); border-color: transparent; color: #c92a2a; }
.chip.info { background: var(--info-soft); border-color: transparent; color: #1971c2; }
.chip.brand { background: var(--brand-50); border-color: transparent; color: var(--brand-600); }
[data-theme="dark"] .chip.ok { color: #63e6be; }
[data-theme="dark"] .chip.warn { color: #ffd43b; }
[data-theme="dark"] .chip.bad { color: #ff8787; }
[data-theme="dark"] .chip.info { color: #74c0fc; }
[data-theme="dark"] .chip.brand { color: var(--brand-300); }

/* Re-theme Bootstrap badges so legacy status pills match */
.ui .badge { border-radius: var(--r-pill); padding: .42em .8em; font-weight: 650; letter-spacing: .01em; }
.ui .badge.bg-success { background: var(--ok-soft) !important; color: #0c8a64 !important; }
.ui .badge.bg-warning { background: var(--warn-soft) !important; color: #b66a00 !important; }
.ui .badge.bg-danger { background: var(--bad-soft) !important; color: #c92a2a !important; }
.ui .badge.bg-info { background: var(--info-soft) !important; color: #1971c2 !important; }
.ui .badge.bg-primary { background: var(--brand-50) !important; color: var(--brand-600) !important; }
.ui .badge.bg-secondary { background: var(--surface-3) !important; color: var(--ink-2) !important; }

/* ---------- 6. Controls ---------- */
.btn-x, .ui .btn {
    --bh: 42px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--bh); padding: 0 18px; border-radius: 13px;
    border: 1px solid transparent; font: 650 13.5px var(--font); letter-spacing: .005em;
    cursor: pointer; white-space: nowrap; user-select: none;
    transition: transform .15s var(--ease), box-shadow .2s, background .2s, border-color .2s, color .2s, opacity .2s;
}
.btn-x:active, .ui .btn:active { transform: scale(.97); }
.btn-x:disabled, .ui .btn:disabled { opacity: .55; pointer-events: none; }
.btn-x.sm, .ui .btn-sm { --bh: 34px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; }
.btn-x.lg, .ui .btn-lg { --bh: 52px; padding: 0 24px; font-size: 15px; border-radius: 16px; }
.btn-x.block { width: 100%; }
.btn-x.icon { padding: 0; width: var(--bh); }

.btn-x.primary, .ui .btn-primary, .ui .btn-success {
    color: #fff; background: var(--grad); background-size: 160% 100%; background-position: 0 0;
    box-shadow: var(--sh-brand);
}
.btn-x.primary:hover, .ui .btn-primary:hover, .ui .btn-success:hover { background-position: 100% 0; color: #fff; box-shadow: 0 14px 34px -10px rgba(109, 77, 255, .75); }
.ui .btn-success { background: var(--grad-ok); box-shadow: 0 10px 28px -12px rgba(18, 184, 134, .8); }
.btn-x.soft, .ui .btn-outline-primary, .ui .btn-info, .ui .btn-light { color: var(--brand-600); background: var(--brand-50); border-color: transparent; }
.btn-x.soft:hover, .ui .btn-outline-primary:hover, .ui .btn-info:hover, .ui .btn-light:hover { background: var(--brand-100); color: var(--brand-700); }
[data-theme="dark"] .btn-x.soft, [data-theme="dark"] .ui .btn-outline-primary { color: var(--brand-300); }
.btn-x.ghost, .ui .btn-secondary, .ui .btn-outline-secondary { color: var(--ink-2); background: var(--surface); border-color: var(--line-strong); }
.btn-x.ghost:hover, .ui .btn-secondary:hover, .ui .btn-outline-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.btn-x.danger, .ui .btn-danger { color: #fff; background: linear-gradient(135deg, #f03e3e, #f0509b); box-shadow: 0 10px 26px -12px rgba(240, 62, 62, .8); }
.btn-x.danger-soft, .ui .btn-outline-danger { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.ui .btn-warning { color: #3d2600; background: var(--grad-sun); }
.btn-x.white { color: var(--brand-700); background: #fff; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .4); }
.btn-x .spin, .ui .btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Fields */
.field { position: relative; margin-bottom: 16px; }
.field > label, .ui .form-label {
    display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); letter-spacing: .01em;
}
.field .req, .ui .text-danger.req { color: var(--bad); }
.input, .ui .form-control, .ui .form-select {
    width: 100%; min-height: 46px; padding: 11px 14px; border-radius: 13px;
    border: 1.5px solid var(--line-strong); background-color: var(--surface); color: var(--ink);
    font: 500 14px var(--font); transition: border-color .2s, box-shadow .2s, background-color .2s;
    -webkit-appearance: none; appearance: none;
}
.ui textarea.form-control, textarea.input { min-height: 96px; resize: vertical; }
.input::placeholder, .ui .form-control::placeholder { color: var(--muted); opacity: .8; }
.input:hover, .ui .form-control:hover, .ui .form-select:hover { border-color: var(--brand-200); }
.input:focus, .ui .form-control:focus, .ui .form-select:focus { outline: 0; border-color: var(--brand); box-shadow: var(--ring); background-color: var(--surface); color: var(--ink); }
.ui .form-control:disabled, .ui .form-control[readonly], .ui .form-select:disabled, .input:disabled { background-color: var(--surface-2); color: var(--ink-2); border-style: dashed; }
.ui .form-select, select.input {
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23747a99' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; background-size: 16px;
}
.ui .is-invalid, .input.is-invalid { border-color: var(--bad) !important; }
.ui .invalid-feedback, .field .err { font-size: 12px; color: var(--bad); margin-top: 6px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.ui .form-check-input { width: 1.15em; height: 1.15em; border: 1.5px solid var(--line-strong); }
.ui .form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.ui .form-check-input:focus { box-shadow: var(--ring); border-color: var(--brand); }
.ui .input-group-text { border-radius: 13px; border: 1.5px solid var(--line-strong); background: var(--surface-2); color: var(--muted); }

/* Floating-label field with leading icon */
.ffield { position: relative; }
.ffield .input { height: 58px; padding: 22px 46px 6px 48px; font-size: 15px; border-radius: 16px; }
.ffield label {
    position: absolute; left: 48px; top: 50%; transform: translateY(-50%);
    margin: 0; font-size: 14.5px; font-weight: 550; color: var(--muted);
    pointer-events: none; transition: all .18s var(--ease);
}
.ffield .input:focus + label, .ffield .input:not(:placeholder-shown) + label { top: 18px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--brand); text-transform: uppercase; }
.ffield .lead { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; transition: color .2s; }
.ffield .input:focus ~ .lead { color: var(--brand); }
.ffield .trail { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border: 0; border-radius: 11px; background: none; color: var(--muted); cursor: pointer; }
.ffield .trail:hover { background: var(--surface-2); color: var(--ink); }

/* Segmented control */
.seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 5px; border-radius: 16px; background: var(--surface-3); }
.seg button { position: relative; z-index: 1; height: 44px; border: 0; background: none; border-radius: 12px; color: var(--muted); font: 700 13.5px var(--font); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: color .25s; }
.seg button[aria-selected="true"] { color: var(--ink); }
.seg .thumb { position: absolute; z-index: 0; top: 5px; bottom: 5px; left: 5px; border-radius: 12px; background: var(--surface); box-shadow: var(--sh-sm); transition: transform .4s var(--spring), width .4s var(--spring); }

/* Tabs (pill strip, scrolls sideways on phones). Bootstrap .nav-tabs inside .tabs-x get the same look. */
.tabs-x, .ui .custom-tabs > .nav-tabs, .ui .nav-tabs.tabs-x {
    display: flex; flex-wrap: nowrap; gap: 6px; padding: 6px; margin: 0 0 18px;
    overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
    border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--sh-xs);
}
.tabs-x::-webkit-scrollbar, .ui .custom-tabs > .nav-tabs::-webkit-scrollbar { display: none; }
/* .nav-item is also the sidebar menu row (full width, padded); inside any Bootstrap tab / pill list it must not be, or the
   tabs stack one per line (seen 2026-11-11 on Course Faculty, Class Advisor, HR PDF report). */
.tabs-x .nav-item, .nav-tabs > .nav-item, .nav-pills > .nav-item {
    margin: 0; padding: 0; display: block; width: auto; background: none; border-radius: 0; transform: none;
}
.tabs-x .nav-link, .ui .custom-tabs > .nav-tabs .nav-link, .tab-x {
    display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border: 0 !important;
    border-radius: 13px !important; background: none; color: var(--muted) !important;
    font: 650 13px var(--font); white-space: nowrap; scroll-snap-align: start; cursor: pointer;
    transition: background .2s, color .2s;
}
.tabs-x .nav-link:hover, .ui .custom-tabs > .nav-tabs .nav-link:hover { color: var(--ink) !important; background: var(--surface-2); }
.tabs-x .nav-link.active, .ui .custom-tabs > .nav-tabs .nav-link.active, .tab-x.is-active {
    color: #fff !important; background: var(--grad) !important; box-shadow: var(--sh-brand);
}
.tabs-x .nav-link i, .ui .custom-tabs > .nav-tabs .nav-link i { font-size: 13px; }
/* Tab colours: idle tabs sit on a soft brand tint, and every tab icon gets its own colour from an 8-colour cycle (--tc).
   The active tab keeps the gradient with a white icon. */
.tabs-x > :nth-child(8n+1), .ui .custom-tabs > .nav-tabs > :nth-child(8n+1), .tx-grid > .tx-tile:nth-child(8n+1) { --tc: #6d4dff; }
.tabs-x > :nth-child(8n+2), .ui .custom-tabs > .nav-tabs > :nth-child(8n+2), .tx-grid > .tx-tile:nth-child(8n+2) { --tc: #0ea5e9; }
.tabs-x > :nth-child(8n+3), .ui .custom-tabs > .nav-tabs > :nth-child(8n+3), .tx-grid > .tx-tile:nth-child(8n+3) { --tc: #10b981; }
.tabs-x > :nth-child(8n+4), .ui .custom-tabs > .nav-tabs > :nth-child(8n+4), .tx-grid > .tx-tile:nth-child(8n+4) { --tc: #f59e0b; }
.tabs-x > :nth-child(8n+5), .ui .custom-tabs > .nav-tabs > :nth-child(8n+5), .tx-grid > .tx-tile:nth-child(8n+5) { --tc: #ec4899; }
.tabs-x > :nth-child(8n+6), .ui .custom-tabs > .nav-tabs > :nth-child(8n+6), .tx-grid > .tx-tile:nth-child(8n+6) { --tc: #14b8a6; }
.tabs-x > :nth-child(8n+7), .ui .custom-tabs > .nav-tabs > :nth-child(8n+7), .tx-grid > .tx-tile:nth-child(8n+7) { --tc: #f97316; }
.tabs-x > :nth-child(8n+8), .ui .custom-tabs > .nav-tabs > :nth-child(8n+8), .tx-grid > .tx-tile:nth-child(8n+8) { --tc: #8b5cf6; }
[data-theme="dark"] :is(.tabs-x, .custom-tabs > .nav-tabs, .tx-grid) > * { --tc-mix: 72%; }
.tabs-x .nav-link, .ui .custom-tabs > .nav-tabs .nav-link, .tab-x {
    background: color-mix(in srgb, var(--brand) 6%, var(--surface));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 10%, transparent);
}
.tabs-x .nav-link:hover, .ui .custom-tabs > .nav-tabs .nav-link:hover, .tab-x:hover {
    background: color-mix(in srgb, var(--tc, var(--brand)) 13%, var(--surface));
}
.tabs-x .nav-link:not(.active) i, .ui .custom-tabs > .nav-tabs .nav-link:not(.active) i, .tab-x:not(.is-active) i {
    color: color-mix(in srgb, var(--tc, var(--brand)) var(--tc-mix, 100%), #fff) !important;
}
.tabs-x .nav-link.active i, .ui .custom-tabs > .nav-tabs .nav-link.active i, .tab-x.is-active i { color: #fff !important; }
.tx-tile:not(.is-on) .tx-ico {
    background: color-mix(in srgb, var(--tc, var(--brand)) 14%, var(--surface));
    color: color-mix(in srgb, var(--tc, var(--brand)) var(--tc-mix, 100%), #fff);
}
.tx-tile:not(.is-on) { background: color-mix(in srgb, var(--tc, var(--brand)) 4%, var(--surface)); }
/* Desktop: wrap onto more lines so no tab is cut off (beats page styles that force nowrap). */
@media (min-width: 768px) {
    .tabs-x, .ui .custom-tabs > .nav-tabs { flex-wrap: wrap !important; overflow-x: visible !important; }
}
/* ---------- Phone tabs (app-ui.js initTabStrips) ----------
   2-4 tabs: equal tiles, icon over label, nothing hidden. 5+ tabs: the strip is replaced by a "tab dock". */
.tx-dock[hidden] { display: none !important; }
@media (max-width: 767.98px) {
    .tabs-x.tx-docked, .ui .custom-tabs > .nav-tabs.tx-docked { display: none !important; }

    .tabs-x.tx-fit, .ui .custom-tabs > .nav-tabs.tx-fit {
        display: grid !important; grid-template-columns: repeat(var(--tx-n), minmax(0, 1fr)); gap: 4px; padding: 5px; overflow: visible;
    }
    .tabs-x.tx-fit .nav-item, .ui .custom-tabs > .nav-tabs.tx-fit .nav-item { min-width: 0; }
    .tabs-x.tx-fit .nav-link, .ui .custom-tabs > .nav-tabs.tx-fit .nav-link, .tabs-x.tx-fit .tab-x {
        width: 100%; height: auto; min-height: 56px; padding: 8px 4px; flex-direction: column; justify-content: center; gap: 5px;
        font-size: 11.5px; line-height: 1.2; text-align: center; white-space: normal;
        display: -webkit-box; display: flex; overflow: hidden; word-break: break-word;
    }
    .tabs-x.tx-fit .nav-link i, .ui .custom-tabs > .nav-tabs.tx-fit .nav-link i { font-size: 16px; margin: 0 !important; }

    /* The dock: [<]  [icon | 3 of 8 · Name | progress]  [>] */
    .tx-dock {
        position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: stretch; gap: 6px;
        margin: 0 0 16px; padding: 6px; border-radius: 22px;
        background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-sm);
        isolation: isolate;
    }
    .tx-dock::before {
        content: ''; position: absolute; inset: -1px; z-index: -1; border-radius: inherit; padding: 1px;
        background: linear-gradient(120deg, rgba(109, 77, 255, .55), rgba(20, 200, 232, .35), transparent 60%);
        -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
        pointer-events: none;
    }
    .tx-step {
        display: grid; place-items: center; border: 0; border-radius: 16px; background: var(--surface-2); color: var(--ink);
        font-size: 14px; transition: background .2s, transform .15s, opacity .2s;
    }
    .tx-step:active { transform: scale(.92); }
    .tx-step:disabled { opacity: .35; }
    .tx-main {
        display: flex; align-items: center; gap: 12px; min-width: 0; padding: 6px 10px 6px 6px; border: 0; border-radius: 16px;
        background: var(--surface-2); color: var(--ink); text-align: left; transition: transform .15s;
        touch-action: pan-y;
    }
    .tx-main:active { transform: scale(.985); }
    .tx-ico {
        flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px;
        background: var(--grad); color: #fff; font-size: 17px; box-shadow: var(--sh-brand);
    }
    .tx-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
    .tx-kicker { font-size: 10.5px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
    .tx-name { font-size: 14.5px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .tx-bar { display: flex; gap: 3px; margin-top: 2px; }
    .tx-bar i { flex: 1; height: 3px; border-radius: 3px; background: var(--line-strong); transition: background .3s, flex .35s var(--spring); }
    .tx-bar i.done { background: color-mix(in srgb, var(--brand) 45%, var(--line-strong)); }
    .tx-bar i.on { flex: 2.4; background: var(--grad); }
    .tx-more { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); font-size: 13px; }
    .tx-dock.swap .tx-ico, .tx-dock.swap .tx-name { animation: txSwap .38s var(--spring); }
    .tx-dock.nudge-r .tx-main { animation: txNudgeR .32s var(--ease); }
    .tx-dock.nudge-l .tx-main { animation: txNudgeL .32s var(--ease); }
    @keyframes txSwap { from { opacity: 0; transform: translateY(6px) scale(.96); } }
    @keyframes txNudgeR { 40% { transform: translateX(-5px); } }
    @keyframes txNudgeL { 40% { transform: translateX(5px); } }
}

/* Bottom sheet with every tab */
.tx-scrim { position: fixed; inset: 0; z-index: 2055; background: rgba(8, 10, 30, .5); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); }
.tx-scrim.is-open { opacity: 1; pointer-events: auto; }
.tx-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 2060; max-height: 82vh; max-height: 82dvh; display: flex; flex-direction: column;
    background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: 0 -24px 70px -20px rgba(0, 0, 0, .45);
    transform: translateY(105%); transition: transform .42s var(--ease); padding-bottom: calc(14px + var(--safe-b)); visibility: hidden;
}
.tx-sheet.is-open { transform: none; visibility: visible; }
.tx-sheet-head { position: relative; display: flex; align-items: center; gap: 10px; padding: 22px 18px 10px; }
.tx-sheet-head h3 { flex: 1; margin: 0; font-size: 17px; font-weight: 800; }
.tx-grip { position: absolute; top: 9px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: 5px; background: var(--line-strong); }
.tx-close { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--ink); }
.tx-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 4px 14px 6px; overflow-y: auto; overscroll-behavior: contain; }
.tx-tile {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 104px; padding: 14px 6px 12px;
    border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink-2);
    font-size: 12px; font-weight: 650; line-height: 1.25; text-align: center;
    animation: txTileIn .4s var(--spring) both; animation-delay: var(--d, 0ms); transition: transform .15s, border-color .2s;
}
.tx-tile:active { transform: scale(.95); }
.tx-tile .tx-ico { width: 46px; height: 46px; border-radius: 15px; background: var(--surface-2); color: var(--brand); box-shadow: none; }
.tx-tile.is-on { border-color: transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--grad) border-box; border: 1.5px solid transparent; color: var(--ink); }
.tx-tile.is-on .tx-ico { background: var(--grad); color: #fff; box-shadow: var(--sh-brand); }
.tx-lab { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.tx-num { position: absolute; top: 8px; left: 10px; font-size: 10px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.tx-badge { position: absolute; top: 7px; right: 8px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 20px; }
@keyframes txTileIn { from { opacity: 0; transform: translateY(14px) scale(.94); } }
html.tx-lock, html.tx-lock body { overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
    .tx-tile, .tx-dock.swap .tx-ico, .tx-dock.swap .tx-name, .tx-dock .tx-main { animation: none !important; }
    .tx-sheet, .tx-scrim { transition: none; }
}

/* Switch */
.switch { position: relative; display: inline-flex; width: 46px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 28px; background: var(--line-strong); cursor: pointer; transition: background .25s; }
.switch span::before { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--sh-sm); transition: transform .3s var(--spring); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---------- 7. Data: responsive tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }
.ui .table {
    --bs-table-bg: transparent; --bs-table-color: var(--ink); --bs-table-border-color: var(--line);
    --bs-table-striped-bg: var(--surface-2); --bs-table-hover-bg: var(--surface-2);
    width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; font-size: 13.5px;
}
.ui .table > thead > tr > th, .ui .table > thead > tr > td {
    padding: 12px 16px; background: var(--surface-2) !important; color: var(--muted) !important;
    font-size: 11.5px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase;
    border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle;
}
.ui .table > thead > tr > th:first-child { border-top-left-radius: 14px; }
.ui .table > thead > tr > th:last-child { border-top-right-radius: 14px; }
.ui .table > tbody > tr > td, .ui .table > tbody > tr > th { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink); background: transparent; }
.ui .table > tbody > tr:last-child > td { border-bottom: 0; }
.ui .table > tbody > tr { transition: background .15s; }
.ui .table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--surface-2); }
.ui .table thead.table-dark th, .ui .table .table-dark th { background: var(--surface-2) !important; color: var(--muted) !important; }
.ui .table-bordered > :not(caption) > * > * { border-width: 0 0 1px; }

/* Phones: every table row becomes a card. app-ui.js copies each <th> text into data-label. */
@media (max-width: 767.98px) {
    .ui table.rt, .ui .rt table { border: 0; }
    .ui table.rt > thead, .ui .rt table > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .ui table.rt > tbody, .ui .rt table > tbody { display: flex; flex-direction: column; gap: 12px; }
    .ui table.rt > tbody > tr, .ui .rt table > tbody > tr {
        display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; padding: 14px 16px;
        border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--sh-xs);
    }
    .ui table.rt > tbody > tr > td, .ui .rt table > tbody > tr > td {
        display: block; padding: 6px 0 !important; border: 0 !important; min-width: 0; text-align: left !important;
        word-break: break-word; font-weight: 600;
    }
    .ui table.rt > tbody > tr > td::before, .ui .rt table > tbody > tr > td::before {
        content: attr(data-label); display: block; margin-bottom: 1px;
        font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
    }
    .ui table.rt td[data-label=""]::before, .ui .rt td[data-label=""]::before { display: none; }
    /* First cell = card title, actions cell = card footer */
    .ui table.rt td.rt-title, .ui .rt td.rt-title, .ui table.rt td:first-child:not(.rt-keep), .ui .rt table td:first-child:not(.rt-keep) { grid-column: 1 / -1; font-size: 15px; font-weight: 750; }
    .ui table.rt td.rt-title::before, .ui .rt td.rt-title::before { display: none; }
    .ui table.rt td.rt-full, .ui .rt td.rt-full { grid-column: 1 / -1; }
    /* long chips (names + department) wrap inside phone cards instead of pushing the page sideways */
    .ui table.rt td .chip, .ui .rt table td .chip { white-space: normal; max-width: 100%; flex-wrap: wrap; text-align: left; line-height: 1.35; }
    .ui table.rt td.rt-actions, .ui .rt td.rt-actions, .ui table.rt td:last-child:has(.btn), .ui .rt table td:last-child:has(.btn) {
        grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; padding-top: 12px !important; border-top: 1px dashed var(--line) !important;
    }
    .ui table.rt td.rt-actions::before, .ui .rt td.rt-actions::before, .ui table.rt td:last-child:has(.btn)::before, .ui .rt table td:last-child:has(.btn)::before { display: none; }
    .ui table.rt td.rt-actions .btn, .ui .rt td.rt-actions .btn, .ui table.rt td:last-child .btn, .ui .rt table td:last-child .btn { flex: 1 1 auto; }
    .ui table.rt td.rt-empty, .ui .rt td.dataTables_empty { grid-column: 1 / -1; text-align: center !important; }
    .ui table.rt td.rt-empty::before, .ui .rt td.dataTables_empty::before { display: none; }
    .table-wrap, .ui .table-responsive { overflow: visible; }
}

/* DataTables chrome */
.ui .dataTables_wrapper .dataTables_length select, .ui .dataTables_wrapper .dataTables_filter input { border: 1.5px solid var(--line-strong); border-radius: 11px; padding: 6px 10px; background: var(--surface); color: var(--ink); }
.ui .dataTables_wrapper .dataTables_filter input:focus { outline: 0; border-color: var(--brand); box-shadow: var(--ring); }
.ui .dataTables_wrapper .dataTables_info, .ui .dataTables_wrapper .dataTables_length, .ui .dataTables_wrapper .dataTables_filter { color: var(--muted); font-size: 12.5px; }
.ui .page-link { border: 0; margin: 0 2px; border-radius: 10px !important; color: var(--ink-2); background: transparent; }
.ui .page-item.active .page-link { background: var(--grad); color: #fff; }

/* ---------- 8. Overlays: modals, toasts, SweetAlert ---------- */
.ui .modal-backdrop { background: #080a1e; }
.ui .modal-backdrop.show { opacity: .5; }
.ui .modal { z-index: 2050; }
.ui .modal-backdrop { z-index: 2040; }
.ui .modal-content { border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--sh-lg); overflow: hidden; }
.ui .modal-header { padding: 20px 24px 14px; border: 0; background: none; color: var(--ink); }
.ui .modal-header .modal-title { font-size: 18px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.ui .modal-header[class*="bg-"] { background: none !important; color: var(--ink) !important; }
.ui .modal-header[class*="bg-"] .modal-title, .ui .modal-header .text-white { color: var(--ink) !important; }
.ui .modal-header .btn-close { width: 36px; height: 36px; padding: 0; border-radius: 12px; background-color: var(--surface-2); background-size: 12px; opacity: 1; filter: none !important; }
[data-theme="dark"] .ui .modal-header .btn-close, [data-theme="dark"] .modal-header .btn-close { filter: invert(1) !important; }
.ui .modal-body { padding: 6px 24px 20px; }
.ui .modal-footer { padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); gap: 8px; }
.ui .modal-footer > * { margin: 0; }

@media (max-width: 767.98px) {
    /* Modals open as bottom sheets */
    .ui .modal-dialog, .ui .modal-dialog.modal-dialog-centered { margin: 0; max-width: none; min-height: 100%; display: flex; align-items: flex-end; }
    .ui .modal.fade .modal-dialog { transform: translateY(100%); transition: transform .4s var(--ease); }
    .ui .modal.show .modal-dialog { transform: none; }
    .ui .modal-content { border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0; max-height: 92vh; max-height: 92dvh; padding-bottom: var(--safe-b); }
    .ui .modal-content::before { content: ''; display: block; width: 44px; height: 5px; margin: 10px auto 0; border-radius: 5px; background: var(--line-strong); }
    .ui .modal-body { overflow-y: auto; }
    .ui .modal-dialog-scrollable .modal-content { max-height: 92dvh; }
    .ui .modal-footer { position: sticky; bottom: 0; }
    .ui .modal-footer > .btn { flex: 1; }
}

.toasts { position: fixed; z-index: 4000; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast-x {
    pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 14px 16px;
    border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-lg);
    animation: toastIn .45s var(--spring) both; position: relative; overflow: hidden;
}
.toast-x.is-out { animation: toastOut .3s var(--ease) forwards; }
.toast-x .ico { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 11px; color: #fff; font-size: 14px; }
.toast-x.ok .ico { background: var(--grad-ok); }
.toast-x.bad .ico { background: linear-gradient(135deg, #f03e3e, #f0509b); }
.toast-x.warn .ico { background: var(--grad-sun); }
.toast-x.info .ico { background: var(--grad); }
.toast-x .msg { flex: 1; padding-top: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.toast-x .x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; }
.toast-x::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: currentColor; opacity: .25; transform-origin: left; animation: toastBar var(--t, 4s) linear forwards; }
.toast-x.ok { color: var(--ok); } .toast-x.bad { color: var(--bad); } .toast-x.warn { color: var(--warn); } .toast-x.info { color: var(--brand); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
@keyframes toastBar { to { transform: scaleX(0); } }
@media (max-width: 767.98px) { .toasts { top: auto; bottom: calc(var(--bottomnav-h) + 18px + var(--safe-b)); left: 16px; right: 16px; width: auto; } }

/* SweetAlert2 theme */
.ui .swal2-container { z-index: 3000; }
.ui .swal2-popup { border-radius: var(--r-xl); background: var(--surface); color: var(--ink); font-family: var(--font); padding: 1.6em 1.4em 1.4em; box-shadow: var(--sh-lg); }
.ui .swal2-title { color: var(--ink); font-weight: 800; font-size: 1.35em; letter-spacing: -.02em; }
.ui .swal2-html-container { color: var(--ink-2); font-size: .98em; }
.ui .swal2-actions { gap: 8px; }
.ui .swal2-styled { margin: 0; min-height: 44px; padding: 0 22px; border-radius: 13px !important; font-weight: 700 !important; }
.ui .swal2-styled.swal2-confirm { background: var(--grad) !important; box-shadow: var(--sh-brand); }
.ui .swal2-styled.swal2-cancel { background: var(--surface-3) !important; color: var(--ink) !important; }
.ui .swal2-styled.swal2-deny { background: linear-gradient(135deg, #f03e3e, #f0509b) !important; }
.ui .swal2-styled:focus { box-shadow: var(--ring) !important; }
.ui .swal2-input, .ui .swal2-textarea, .ui .swal2-select { border-radius: 13px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); box-shadow: none; }
.ui .swal2-icon { transform: scale(.85); }

/* Loader bar */
.topline { position: fixed; z-index: 5000; top: 0; left: 0; height: 3px; width: 0; background: var(--grad); box-shadow: 0 0 12px rgba(109, 77, 255, .8); transition: width .4s var(--ease), opacity .4s; }

/* ---------- 9. Responsive shell ---------- */
@media (max-width: 1199.98px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
    :root { --topbar-h: 60px; }
    .side { top: 0; bottom: 0; left: 0; border-radius: 0 var(--r-xl) var(--r-xl) 0; transform: translateX(-105%); width: min(300px, 86vw); box-shadow: var(--sh-lg); }
    .shell.is-drawer .side { transform: none; }
    .shell.is-mini .side { width: min(300px, 86vw); }
    .main, .shell.is-mini .main { margin-left: 0; padding: 0 14px calc(var(--bottomnav-h) + 28px + var(--safe-b)); }
    .top { height: calc(var(--topbar-h) + var(--safe-t) + 8px); padding-top: calc(var(--safe-t) + 8px); margin: 0 -14px; padding-inline: 14px; }
    .top-inner { padding: 0 6px 0 8px; border-radius: 18px; }
    .top-title h1 { font-size: 16px; }
    .user-chip .who { display: none; }
    .hide-md { display: none !important; }
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .span-2, .span-3 { grid-column: auto; }
    .foot { display: none; }

    .bnav {
        position: fixed; z-index: 1035; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b));
        display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: var(--bottomnav-h); padding: 6px;
        border-radius: 24px; background: var(--glass); border: 1px solid var(--line);
        backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
        box-shadow: 0 18px 40px -16px rgba(16, 21, 64, .35);
    }
    .bnav a, .bnav button {
        position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
        border: 0; background: none; border-radius: 18px; color: var(--muted) !important;
        font: 650 10.5px var(--font); letter-spacing: .01em; cursor: pointer; transition: color .2s;
    }
    .bnav i { font-size: 18px; transition: transform .35s var(--spring); }
    .bnav .is-active { color: var(--brand) !important; }
    .bnav .is-active i { transform: translateY(-1px) scale(1.1); }
    .bnav .is-active::before { content: ''; position: absolute; inset: 2px 8px; z-index: -1; border-radius: 16px; background: var(--brand-50); animation: pop .35s var(--spring); }
    @keyframes pop { from { transform: scale(.6); opacity: 0; } }
    [data-theme="dark"] .bnav .is-active { color: #fff !important; }
}

@media (min-width: 992px) {
    .show-md { display: none !important; }
    .sheet, .bnav { display: none; }
}

@media (max-width: 575.98px) {
    body.ui { font-size: 14px; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .grid { gap: 14px; }
    .card-x.pad, .card-b { padding: 16px; }
    .card-h { padding: 16px; flex-wrap: wrap; }
    /* header buttons / controls drop under the title on phones instead of squeezing it */
    .card-h > .btn, .card-h > .btn-x, .card-h > .actions, .card-h > .d-flex:last-child:not(:first-child) { flex: 1 1 100%; justify-content: center; }
    .card-h > div[style*="flex:1"], .card-h > div[style*="flex: 1"] { min-width: 0; flex: 1 1 calc(100% - 50px) !important; }
    .list-row { padding: 12px 16px; }
    .hero { padding: 22px 20px; border-radius: var(--r-lg); }
    .page-head { margin-bottom: 16px; }
    .page-head .actions { width: 100%; }
    .page-head .actions > * { flex: 1; }
    .kpi { padding: 14px; }
    .kpi .ico { width: 38px; height: 38px; font-size: 15px; border-radius: 12px; }
    .kpi .lbl { margin-top: 10px; font-size: 10.5px; }
    .kpi .val { font-size: 16px; }
    .sheet-grid { grid-template-columns: repeat(4, 1fr); }
    .ui .modal-body { padding: 4px 18px 18px; }
    .dl { grid-template-columns: 1fr 1fr; }
}

/* ---------- 10. Utilities ---------- */
.muted { color: var(--muted) !important; }
.ink { color: var(--ink) !important; }
.brand-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.fw-800 { font-weight: 800 !important; }
.gap-6 { gap: 6px; } .gap-12 { gap: 12px; }
.mt-0 { margin-top: 0 !important; }
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }
/* Fail-safe: content never stays hidden if the scroll observer does not fire (old browser, script error, zoom). */
.reveal:not(.is-in) { animation: kr-reveal-safe .01s linear 1.2s forwards; }
@keyframes kr-reveal-safe { to { opacity: 1; transform: none; } }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.ui .card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-sm); color: var(--ink); }
.ui .card-header { background: none; border-bottom: 1px solid var(--line); padding: 16px 20px; font-weight: 750; }
.ui .card-body { padding: 20px; }
.ui .alert { border-radius: var(--r); border: 0; font-weight: 550; }
.ui .alert-info { background: var(--info-soft); color: #1864ab; }
.ui .alert-warning { background: var(--warn-soft); color: #8f5200; }
.ui .alert-danger { background: var(--bad-soft); color: #a61e1e; }
.ui .alert-success { background: var(--ok-soft); color: #087f5b; }
.ui hr { border-color: var(--line); opacity: 1; }

/* ---------- 11. Sidebar: dark graphite with colourful icons (both themes) ---------- */
.side {
    --sb-bg: #17181f;
    --sb-bg-2: #1f2029;
    --sb-line: rgba(255, 255, 255, .07);
    --sb-ink: #e7e8ef;
    --sb-muted: #8b8d9c;
    background: linear-gradient(180deg, #1b1c24 0%, var(--sb-bg) 100%);
    border-color: #23242e;
    box-shadow: 0 20px 50px -24px rgba(10, 10, 20, .6);
    color: var(--sb-ink);
}
.side-brand { margin: 10px 12px 6px; padding: 12px; min-height: 64px; border-radius: 16px; background: #fff; justify-content: center; }
.side-brand img.full { filter: none !important; opacity: 1 !important; height: 36px; }
.shell.is-mini .side-brand { margin-inline: 12px; padding: 10px 0; }
.side-search button { background: var(--sb-bg-2); border-color: var(--sb-line); color: var(--sb-muted); }
.side-search button:hover { background: #262733; border-color: rgba(255, 255, 255, .14); }
.side-search kbd { background: #2a2b37; border-color: rgba(255, 255, 255, .1); color: var(--sb-muted); }
.side-label { color: #6e7080; }
.side-nav { scrollbar-color: #33343f transparent; }

.side .nav-item { color: #c4c6d3 !important; }
.side .nav-item .ico { background: color-mix(in srgb, var(--tone-solid, #8a76ff) 16%, transparent); color: var(--tone-solid, #a99dff); }
.side .nav-item .chev { color: #6e7080; }
.side .nav-item:hover { background: rgba(255, 255, 255, .05); color: #fff !important; }
.side .nav-item:hover .ico { background: color-mix(in srgb, var(--tone-solid, #8a76ff) 26%, transparent); color: var(--tone-solid, #a99dff); transform: scale(1.06); }
.side .nav-item .ico { transition: background .25s, transform .3s var(--spring), box-shadow .25s; }
.side .nav-item.is-active { background: rgba(255, 255, 255, .07); color: #fff !important; }
.side .nav-item.is-active::before { content: ''; position: absolute; left: -12px; top: 22%; bottom: 22%; width: 4px; border-radius: 0 4px 4px 0; background: var(--tone-solid, #8a76ff); box-shadow: 0 0 12px var(--tone-solid, #8a76ff); }
.side .nav-item.is-active .ico { background: var(--tone, var(--grad)); color: #fff; box-shadow: 0 8px 20px -8px var(--tone-solid, #6d4dff); }
.side .nav-sub > div::before { background: rgba(255, 255, 255, .08); }
.side .nav-sub .nav-item .ico { background: transparent; }
.side .nav-sub .nav-item.is-active .ico { background: var(--tone, var(--grad)); }
.side .nav-sub .nav-item.is-active::before { display: none; }

.side-foot { border-top-color: var(--sb-line); }
.side-user { background: var(--sb-bg-2); }
.side-user .who b { color: #fff; }
.side-user .who span { color: var(--sb-muted); }
.side-user .icon-btn { color: var(--sb-muted); }
.side-user .icon-btn:hover { background: rgba(240, 62, 62, .15); color: #ff8787; }

/* Extra icon tones so a long menu stays varied */
.tone-7 { --tone: linear-gradient(135deg, #20c997, #12b886); --tone-solid: #20c997; --tone-soft: rgba(32, 201, 151, .12); }
.tone-8 { --tone: linear-gradient(135deg, #ff922b, #f76707); --tone-solid: #ff922b; --tone-soft: rgba(255, 146, 43, .14); }
.tone-9 { --tone: linear-gradient(135deg, #4dabf7, #4263eb); --tone-solid: #4dabf7; --tone-soft: rgba(77, 171, 247, .12); }
.tone-10 { --tone: linear-gradient(135deg, #f783ac, #d6336c); --tone-solid: #f783ac; --tone-soft: rgba(247, 131, 172, .12); }
.side .tone-1 { --tone-solid: #9b87ff; } .side .tone-2 { --tone-solid: #3bc9db; } .side .tone-3 { --tone-solid: #38d9a9; }
.side .tone-4 { --tone-solid: #ff8787; } .side .tone-5 { --tone-solid: #ffc94d; } .side .tone-6 { --tone-solid: #da77f2; }

/* ---------- 12. Full-height sidebar + drawer layering fix ---------- */
.side {
    top: 0; bottom: 0; left: 0; border-radius: 0; border: 0;
    border-right: 1px solid #24252f;
    box-shadow: 8px 0 30px -18px rgba(10, 10, 20, .55);
}
.main { margin-left: calc(var(--sidebar-w) + 24px); }
.shell.is-mini .main { margin-left: calc(var(--sidebar-w-mini) + 24px); }

/* Brand: round crest + wordmark on the dark rail */
.side-brand { margin: 0; padding: 20px 20px 16px; min-height: 76px; border-radius: 0; background: none; justify-content: flex-start; gap: 12px; }
/* mkce_s.png is a WHITE crest: it needs a coloured tile, never a white one */
.side-brand .crest { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 13px; padding: 4px; object-fit: contain;
    background: linear-gradient(135deg, #6d4dff 0%, #4c2fd6 55%, #1c7ed6 100%);
    box-shadow: 0 6px 18px -6px rgba(109, 77, 255, .7), inset 0 0 0 1px rgba(255, 255, 255, .18); }
.side-brand .word { min-width: 0; line-height: 1.15; }
.side-brand .word b { display: block; color: #fff; font-size: 15.5px; font-weight: 800; letter-spacing: .06em; }
.side-brand .word span { display: block; color: var(--sb-muted, #8b8d9c); font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell.is-mini .side-brand { justify-content: center; padding-inline: 0; margin: 0; }
.shell.is-mini .side-brand .word { display: none; }
.side-search { padding: 0 16px 10px; }
.side .nav-item.is-active::before { left: -12px; }

@media (max-width: 991.98px) {
    /* The drawer must sit ABOVE the blur scrim (scrim is 1045) */
    .side { z-index: 1055; width: min(300px, 86vw); border-radius: 0 24px 24px 0; padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
    .shell.is-mini .side { width: min(300px, 86vw); }
    .main, .shell.is-mini .main { margin-left: 0; }
}

/* Colourful table headers (all .ui tables): one gradient across the header row, white text. */
.ui .table > thead > tr:first-child { background: linear-gradient(90deg, #6d4dff 0%, #a64dff 45%, #e64980 75%, #ff922b 100%); }
.ui .table > thead > tr:not(:first-child) { background: linear-gradient(90deg, #5b3df0 0%, #8f3df0 45%, #d23a72 75%, #f0801c 100%); }
.ui .table > thead > tr > th, .ui .table > thead > tr > td,
.ui .table thead.table-dark th, .ui .table .table-dark th {
    background: transparent !important; color: #fff !important; border-bottom-color: rgba(255, 255, 255, .18);
    text-shadow: 0 1px 1px rgba(0, 0, 0, .12);
}
.ui .table > thead > tr > th a, .ui .table > thead > tr > th .muted { color: #fff !important; }
.ui .table > thead > tr > th:first-child, .ui .table > thead > tr > th:last-child { border-radius: 0; }
.ui table.dataTable > thead .sorting::before, .ui table.dataTable > thead .sorting::after,
.ui table.dataTable > thead .sorting_asc::before, .ui table.dataTable > thead .sorting_desc::after { color: #fff; }
.ui .table > thead > tr > th input[type="checkbox"] { accent-color: #fff; }

/* Colourful card headers on every page: tone wash + gradient icon + coloured top edge.
   A plain .card-h (no tone-N) uses the brand tone. */
.card-h:not([class*="tone-"]) { --tone: linear-gradient(135deg, #6d4dff, #a64dff); --tone-solid: #6d4dff; --tone-soft: rgba(109, 77, 255, .12); }
.card-h { background: linear-gradient(90deg, var(--tone-soft), transparent 85%); }
.card-h .ico { background: var(--tone) !important; color: #fff !important; box-shadow: 0 8px 18px -10px var(--tone-solid); }
.card-x:has(> .card-h) { position: relative; } /* no overflow:hidden: dropdowns inside cards must not be clipped */
/* the edge is a card-shaped layer masked to its top 4px, so it follows the rounded corners */
.card-x:has(> .card-h)::before { content: ''; position: absolute; inset: -1px; border-radius: inherit; background: var(--edge, linear-gradient(90deg, #6d4dff, #a64dff)); -webkit-mask: linear-gradient(#000 0 0) top / 100% 4px no-repeat; mask: linear-gradient(#000 0 0) top / 100% 4px no-repeat; z-index: 1; pointer-events: none; }
.card-h:first-child { border-radius: var(--r-lg) var(--r-lg) 0 0; }
.card-x:has(> .card-h.tone-2) { --edge: linear-gradient(90deg, #14c8e8, #228be6); }
.card-x:has(> .card-h.tone-3) { --edge: linear-gradient(90deg, #12b886, #38d9a9); }
.card-x:has(> .card-h.tone-4) { --edge: linear-gradient(90deg, #ff7a59, #f0509b); }
.card-x:has(> .card-h.tone-5) { --edge: linear-gradient(90deg, #f59f00, #ffc029); }
.card-x:has(> .card-h.tone-6) { --edge: linear-gradient(90deg, #7950f2, #e64980); }
.card-x:has(> .card-h.tone-7) { --edge: linear-gradient(90deg, #20c997, #12b886); }
.card-x:has(> .card-h.tone-8) { --edge: linear-gradient(90deg, #ff922b, #f76707); }
.card-x:has(> .card-h.tone-9) { --edge: linear-gradient(90deg, #4dabf7, #4263eb); }
.card-x:has(> .card-h.tone-10) { --edge: linear-gradient(90deg, #f783ac, #d6336c); }

/* ---------- Auto table pagination (app-ui.js pgScan; opt out with data-no-page) ---------- */
.ui table.table > tbody > tr.pg-hide { display: none !important; }
.ui table.pg-on { scroll-margin-top: 90px; }
.kr-pg { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding: 12px 18px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.kr-pg-info { font-variant-numeric: tabular-nums; }
.kr-pg-ctl { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.kr-pg-size { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; }
.kr-pg-size .form-select { width: auto; min-width: 74px; height: 32px; min-height: 32px; padding: 0 30px 0 10px; font-size: 13px; }
.kr-pg-btns { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.kr-pg[hidden], .kr-pg-btns[hidden] { display: none; }
.kr-pg-btns .btn { min-width: 34px; height: 32px; padding: 0 10px; font-variant-numeric: tabular-nums; font-weight: 600; }
.kr-pg-btns .btn.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.kr-pg-btns .btn:disabled { opacity: .45; }
.kr-pg-gap { padding: 0 4px; }
.kr-srv-pager[hidden] { display: none; }
@media (max-width: 575.98px) {
    .kr-pg { padding: 12px 4px; justify-content: center; text-align: center; }
    .kr-pg-ctl { justify-content: center; }
}
@media print {
    .ui table.table > tbody > tr.pg-hide { display: table-row !important; }
    .kr-pg { display: none !important; }
}
