/* Legacy UI: Council palette aligned with DFMS.Next; shared components and vendor overrides. */

:root {
    /* Surfaces */
    --background:        #f6f8fb;
    --card:              #ffffff;
    --sidebar:           #0b2a5c;
    --muted:             #eaf0f9;
    --accent:            #e4edfa;
    --secondary:         #eaf0f9;
    --input-background:  #ffffff;

    /* Ink */
    --foreground:        #0f1722;
    --muted-foreground:  #5c6779;
    --primary:           #123a72;
    --primary-hover:     #1d5296;
    --primary-foreground:#ffffff;
    --destructive:       #d4183d;

    /* Lines */
    --border:            #dde4f0;
    --border-solid:      #dde4f0;
    --sidebar-border:    rgba(255,255,255,.12);
    --sidebar-accent:    rgba(255,255,255,.09);
    --ring:              #1d5296;

    /* Status tints — fg/bg pairs, all >= 6.3:1 */
    --ok-fg:      #166534;  --ok-bg:      #dcfce7;
    --warn-fg:    #9a3412;  --warn-bg:    #ffedd5;
    --info-fg:    #1e40af;  --info-bg:    #dbeafe;
    --danger-fg:  #991b1b;  --danger-bg:  #fee2e2;
    --neutral-fg: #030213;  --neutral-bg: #eceef2;

    /* Geometry — reference --radius is 0.625rem */
    --radius-sm:  0.375rem;
    --radius-md:  0.5rem;
    --radius-lg:  0.625rem;
    --radius-xl:  0.875rem;

    --weight-normal: 400;
    --weight-medium: 500;

    /* Shell */
    --sidebar-width:  240px;
    --header-height:  64px;
    --content-max:    1600px;

    /* Flat, border-first: elevation only for floating surfaces. */
    --shadow-pop: 0 4px 12px rgb(0 0 0 / .08), 0 1px 3px rgb(0 0 0 / .06);
    --ease: cubic-bezier(0.4, 0, 0.2, 1);


    /* Legacy spacing/geometry names still referenced by inline styles */
    --space-1: 0.25rem; --space-2: 0.5rem;  --space-3: 0.75rem;
    --space-4: 1rem;    --space-5: 1.5rem;  --space-6: 2rem;
    --radius-pill: 999px;
    --duration-fast: 150ms; --duration-normal: 200ms;
    --ease-in-out: var(--ease);
    --shadow-sm: none; --shadow-card: none; --shadow-hover: var(--shadow-pop);
    --shadow-md: var(--shadow-pop); --shadow-lg: var(--shadow-pop);
    --container-max-width: var(--content-max);
}

/* ─────────────────────────────────────────────────────────────────────────────
   0b. DARK THEME
   The reference app's .dark token set, oklch() resolved to sRGB. Applied by
   <html data-theme="dark">, set before first paint by the inline script in the
   layout so there is no flash of light theme.

   Note --primary inverts to near-white, exactly as the reference does: primary
   buttons and the active nav pill become light-on-dark. Contrast in dark:
     foreground #fafafa on #0a0a0a   18.97:1
     muted-fg   #a1a1a1 on #0a0a0a    7.66:1
     muted-fg   #a1a1a1 on sidebar    6.94:1
     nav active #171717 on #fafafa   17.18:1
     status tints                     8.55:1 – 10.33:1
   ───────────────────────────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
    --background:        #0a0a0a;
    --card:              #0a0a0a;
    --sidebar:           #171717;
    --muted:             #262626;
    --accent:            #262626;
    --secondary:         #262626;
    --input-background:  #262626;

    --foreground:        #fafafa;
    --muted-foreground:  #a1a1a1;
    --primary:           #fafafa;
    --primary-hover:     #e5e5e5;
    --primary-foreground:#171717;
    --destructive:       #fca5a5;

    --border:            rgba(255, 255, 255, 0.12);
    --border-solid:      #262626;
    --sidebar-border:    #262626;
    --sidebar-accent:    #262626;
    --ring:              #525252;

    --ok-fg:      #4ade80;  --ok-bg:      #052e16;
    --warn-fg:    #fdba74;  --warn-bg:    #2e1206;
    --info-fg:    #93c5fd;  --info-bg:    #0b1f3f;
    --danger-fg:  #fca5a5;  --danger-bg:  #300f0f;
    --neutral-fg: #fafafa;  --neutral-bg: #262626;

    --shadow-pop: 0 4px 14px rgb(0 0 0 / .6), 0 1px 3px rgb(0 0 0 / .4);

    color-scheme: dark;
}

/* The logo is a dark mark on a transparent field; lift it on a dark surface. */
:root[data-theme="dark"] .logo-src:before { filter: brightness(0) invert(1); }

/* Theme toggle button in the header */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem; height: 2.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--muted-foreground);
    padding: 0;
}
.theme-toggle:hover { background: var(--accent); color: var(--foreground); }
.theme-toggle .theme-toggle__dark { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-toggle__dark { display: inline; }
:root[data-theme="dark"] .theme-toggle .theme-toggle__light { display: none; }

/* ─────────────────────────────────────────────────────────────────────────────
   1. BASE
   ───────────────────────────────────────────────────────────────────────────── */
html { font-size: 16px; }

body {
    margin: 0;
    padding: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.875rem;
    font-weight: var(--weight-normal);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Reference typography: headings are medium (500), never bold. */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-weight: var(--weight-medium);
    line-height: 1.5;
    color: var(--foreground);
    letter-spacing: -0.01em;
}
h1, .h1 { font-size: 1.5rem; }
h2, .h2 { font-size: 1.25rem; }
h3, .h3 { font-size: 1.125rem; }
h4, h5, h6, .h4, .h5, .h6 { font-size: 1rem; }

p { line-height: 1.5; }
a { text-decoration: none; color: inherit; transition: color var(--duration-fast); }
a:hover { color: var(--primary); }
ul { list-style: none; padding: 0; margin: 0; }
button { cursor: pointer; font-family: inherit; }
small, .small { font-size: 0.875rem; }
hr { border-color: var(--border); opacity: 1; }
.text-muted { color: var(--muted-foreground) !important; }
::selection { background: var(--accent); color: var(--primary); }

*:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; box-shadow: none; }

/* ─────────────────────────────────────────────────────────────────────────────
   2. APP SHELL
   Sidebar retained: DFMS has a role-based nav tree the reference's flat top
   bar could not carry. Restyled onto the reference sidebar tokens.
   ───────────────────────────────────────────────────────────────────────────── */
.app-container { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    transition: transform var(--duration-normal) var(--ease);
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left var(--duration-normal) var(--ease);
}

.app-header {
    height: var(--header-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.app-content {
    padding: 1.5rem;
    max-width: var(--content-max);
    margin: 0 auto;
    width: 100%;
    background: var(--background);
}
.app-main__outer { background: var(--background); }

/* Logo */
.app-header__logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
}
.logo-src {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: var(--weight-medium);
    font-size: 1rem;
    color: var(--foreground);
    line-height: 1.2;
}
.logo-src:before {
    content: "";
    width: 32px; height: 32px;
    background: url("/images/mdcsl-logo.png") center / contain no-repeat;
    border-radius: var(--radius-sm);
    flex: 0 0 32px;
}
.logo-src:after { content: ""; display: none; }
.logo-src > * { display: none; }

/* Header pieces */
.header-left, .header-right { display: flex; align-items: center; gap: 0.75rem; }
.header-user-info .widget-heading { color: var(--foreground); font-size: 0.875rem; font-weight: var(--weight-medium); }
.header-user-info .widget-subheading { color: var(--muted-foreground); font-size: 0.8125rem; }
.search-wrapper input { background: var(--input-background); border: 1px solid transparent; border-radius: var(--radius-md); }
.search-wrapper input:focus { background: var(--card); border-color: var(--ring); box-shadow: none; }
.hamburger, .app-header__mobile-menu, .mobile-toggle-nav { display: none; }

/* ─────────────────────────────────────────────────────────────────────────────
   3. SIDEBAR NAV
   ───────────────────────────────────────────────────────────────────────────── */
.scrollbar-sidebar { flex: 1; overflow-y: auto; padding: 0.75rem; }

.vertical-nav-menu { display: flex; flex-direction: column; gap: 2px; }

.vertical-nav-menu .app-sidebar__heading {
    text-transform: uppercase;
    font-size: 0.6875rem;
    font-weight: var(--weight-medium);
    letter-spacing: 0.06em;
    color: var(--muted-foreground);
    padding: 1rem 0.75rem 0.375rem;
    margin: 0;
}

.vertical-nav-menu li a,
.vertical-nav-menu li .nav-submenu-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    text-align: left;
    color: var(--muted-foreground);
    font-size: 0.875rem;
    font-weight: var(--weight-normal);
    transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}
.vertical-nav-menu li a:hover,
.vertical-nav-menu li .nav-submenu-toggle:hover { background: var(--sidebar-accent); color: var(--foreground); }
.vertical-nav-menu li a.mm-active,
.vertical-nav-menu li.mm-active > a,
.vertical-nav-menu li.mm-active > .nav-submenu-toggle {
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: var(--weight-medium);
    box-shadow: none;
}

.vertical-nav-menu .metismenu-icon {
    width: 16px; flex: 0 0 16px;
    margin-right: 0.625rem;
    text-align: center;
    font-size: 0.875rem;
}
/* Submenu leaves carry a bare <i> as an indent; match on the absence of a
   Font Awesome class, since an <i> with only a ::before glyph is also :empty. */
.vertical-nav-menu .metismenu-icon:not([class*="fa-"]) { width: 6px; flex-basis: 6px; }

.vertical-nav-menu .metismenu-state-icon {
    margin-left: auto;
    font-size: 0.625rem;
    opacity: .5;
    transition: transform var(--duration-fast) ease;
}
.vertical-nav-menu .metismenu-state-icon.rotate-90 { transform: rotate(180deg); }

.vertical-nav-menu ul {
    display: none;
    margin-left: 0.75rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--sidebar-border);
    margin-top: 2px;
}
.vertical-nav-menu li.mm-active > ul { display: block; }
.vertical-nav-menu ul li a { font-size: 0.8125rem; padding: 0.4375rem 0.75rem; }

.header-context {
    color: var(--foreground);
    font-size: 0.875rem;
    font-weight: var(--weight-medium);
}

.text-body-primary { color: var(--foreground) !important; }
:root[data-theme="dark"] .bg-light,
:root[data-theme="dark"] .bg-white { background-color: var(--muted) !important; }
:root[data-theme="dark"] .text-dark { color: var(--foreground) !important; }

/* ─────────────────────────────────────────────────────────────────────────────
   4. PAGE HEADER
   ───────────────────────────────────────────────────────────────────────────── */
.app-page-title {
    margin: 0 0 1.5rem;
    padding: 0;
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-title-wrapper { display: flex; align-items: center; gap: 1rem; }
.page-title-heading { margin: 0; }
.page-title-heading div:first-child {
    font-size: 1.25rem;
    font-weight: var(--weight-medium);
    color: var(--foreground);
    letter-spacing: -0.01em;
    line-height: 1.5;
}
.page-title-subheading { color: var(--muted-foreground); font-size: 0.875rem; margin-top: 0.125rem; }
.page-title-icon { display: none; }

/* ─────────────────────────────────────────────────────────────────────────────
   5. CARDS / PANELS
   ───────────────────────────────────────────────────────────────────────────── */
.card, .panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: none;
    color: var(--foreground);
}
.card:hover { box-shadow: none; }

.card-header, .panel__head {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: var(--weight-medium);
    color: var(--foreground);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.card-title, .panel__title { font-size: 1rem; font-weight: var(--weight-medium); margin: 0; line-height: 1.5; }
.card-description, .panel__description { font-size: 0.875rem; color: var(--muted-foreground); margin: 0.25rem 0 0; font-weight: var(--weight-normal); }
.card-body, .panel__body { padding: 1.5rem; }
.card-footer, .panel__foot { background: transparent; border-top: 1px solid var(--border); padding: 1rem 1.5rem; }

/* ─────────────────────────────────────────────────────────────────────────────
   6. STAT CARDS — reference pattern: tinted icon tile left, label above figure
   ───────────────────────────────────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: none;
    color: inherit;
    text-decoration: none;
    transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}
a.stat-card:hover { background: var(--muted); border-color: rgba(0,0,0,.16); color: inherit; }
a.stat-card:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.stat-card__icon {
    flex: 0 0 auto;
    width: 2.5rem; height: 2.5rem;
    display: grid; place-items: center;
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--stat-bg, var(--neutral-bg));
    color: var(--stat-fg, var(--neutral-fg));
}
.stat-card__body { min-width: 0; display: block; }
.stat-card__label { display: block; font-size: 0.875rem; color: var(--muted-foreground); margin: 0; line-height: 1.4; }
.stat-card__value {
    display: block;
    font-size: 1.5rem;
    font-weight: var(--weight-medium);
    color: var(--foreground);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0.125rem 0 0;
}
.stat-card__meta { display: block; font-size: 0.8125rem; color: var(--muted-foreground); margin: 0.125rem 0 0; }

.stat-card--primary { --stat-bg: var(--neutral-bg); --stat-fg: var(--neutral-fg); }
.stat-card--success { --stat-bg: var(--ok-bg);      --stat-fg: var(--ok-fg); }
.stat-card--warning { --stat-bg: var(--warn-bg);    --stat-fg: var(--warn-fg); }
.stat-card--danger  { --stat-bg: var(--danger-bg);  --stat-fg: var(--danger-fg); }
.stat-card--info    { --stat-bg: var(--info-bg);    --stat-fg: var(--info-fg); }

/* ── Stat tile ────────────────────────────────────────────────────────────
   The card used on Roles & Permissions and User Management: white surface,
   coloured left rule, muted label above the figure, soft tinted icon disc.
   Defined once so those pages cannot drift apart again.
   ───────────────────────────────────────────────────────────────────────── */
.stat-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    height: 100%;
    padding: 1rem 1.25rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--tile-accent, var(--primary));
    border-radius: var(--radius-xl);
    color: inherit;
    text-decoration: none;
    transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}
a.stat-tile:hover { background: var(--muted); color: inherit; }
a.stat-tile:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.stat-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-tile__body { min-width: 0; }

.stat-tile__label {
    display: block;
    font-size: 0.875rem;
    font-weight: var(--weight-medium);
    color: var(--muted-foreground);
    margin: 0 0 0.125rem;
    line-height: 1.35;
}
.stat-tile__value {
    display: block;
    font-size: 1.75rem;
    font-weight: var(--weight-medium);
    color: var(--foreground);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0;
}
.stat-tile__icon {
    flex: 0 0 auto;
    width: 3rem; height: 3rem;
    display: grid; place-items: center;
    border-radius: var(--radius-pill);
    font-size: 1.25rem;
    background: var(--tile-bg, var(--neutral-bg));
    color: var(--tile-fg, var(--neutral-fg));
}

.stat-tile--primary { --tile-accent: var(--primary);     --tile-bg: var(--neutral-bg); --tile-fg: var(--neutral-fg); }
.stat-tile--success { --tile-accent: var(--ok-fg);       --tile-bg: var(--ok-bg);      --tile-fg: var(--ok-fg); }
.stat-tile--warning { --tile-accent: var(--warn-fg);     --tile-bg: var(--warn-bg);    --tile-fg: var(--warn-fg); }
.stat-tile--danger  { --tile-accent: var(--destructive); --tile-bg: var(--danger-bg);  --tile-fg: var(--danger-fg); }
.stat-tile--info    { --tile-accent: var(--info-fg);     --tile-bg: var(--info-bg);    --tile-fg: var(--info-fg); }
.stat-tile--muted   { --tile-accent: var(--muted-foreground); --tile-bg: var(--muted); --tile-fg: var(--muted-foreground); }

/* Retro-fit for any remaining legacy .widget-content markup */
.widget-content {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: none;
    padding: 1rem;
}
.widget-content .widget-heading { color: var(--muted-foreground); font-size: 0.875rem; font-weight: var(--weight-normal); text-transform: none; letter-spacing: 0; }
.widget-content .widget-numbers { color: var(--foreground); font-size: 1.5rem; font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.widget-content .widget-subheading { color: var(--muted-foreground); font-size: 0.8125rem; }
.widget-content .widget-icon-right {
    position: absolute; top: 1rem; right: 1rem;
    width: 2.5rem; height: 2.5rem;
    display: grid; place-items: center;
    border-radius: var(--radius-md);
    font-size: 1rem;
}
.bg-primary-soft { background: var(--neutral-bg); color: var(--neutral-fg); }
.bg-success-soft { background: var(--ok-bg);      color: var(--ok-fg); }
.bg-warning-soft { background: var(--warn-bg);    color: var(--warn-fg); }
.bg-info-soft    { background: var(--info-bg);    color: var(--info-fg); }
.bg-danger-soft  { background: var(--danger-bg);  color: var(--danger-fg); }

/* ─────────────────────────────────────────────────────────────────────────────
   7. BUTTONS
   ───────────────────────────────────────────────────────────────────────────── */
.btn {
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: var(--weight-medium);
    line-height: 1.5;
    padding: 0.5rem 0.875rem;
    border: 1px solid transparent;
    box-shadow: none;
    transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, color var(--duration-fast) ease;
}
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn:hover { transform: none; box-shadow: none; }
.btn-sm { padding: 0.375rem 0.625rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.625rem 1.125rem; font-size: 0.9375rem; }

.btn-primary, .btn-dark { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover, .btn-dark:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-foreground); }

.btn-secondary { background: var(--secondary); border-color: transparent; color: var(--primary); }
.btn-secondary:hover { background: var(--accent); border-color: transparent; color: var(--primary); }

.btn-outline-primary, .btn-outline-secondary, .btn-outline-dark, .btn-light {
    background: var(--card); border-color: var(--border); color: var(--foreground);
}
.btn-outline-primary:hover, .btn-outline-secondary:hover, .btn-outline-dark:hover, .btn-light:hover {
    background: var(--accent); border-color: var(--border); color: var(--foreground);
}

.btn-danger { background: var(--destructive); border-color: var(--destructive); color: #fff; }
.btn-outline-danger { background: var(--card); border-color: var(--border); color: var(--destructive); }
.btn-outline-danger:hover { background: var(--destructive); border-color: var(--destructive); color: #fff; }

.btn-success { background: var(--ok-fg); border-color: var(--ok-fg); color: #fff; }
.btn-outline-success { background: var(--card); border-color: var(--border); color: var(--ok-fg); }
.btn-outline-warning { background: var(--card); border-color: var(--border); color: var(--warn-fg); }
.btn-outline-info { background: var(--card); border-color: var(--border); color: var(--info-fg); }
.btn-link { color: var(--primary); font-weight: var(--weight-medium); }
.btn-link:hover { text-decoration: underline; }

/* ─────────────────────────────────────────────────────────────────────────────
   8. FORMS
   ───────────────────────────────────────────────────────────────────────────── */
.form-control, .form-select, .input-group-text, textarea.form-control {
    background: var(--input-background);
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-md);
    color: var(--foreground);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    box-shadow: none;
}
.form-control::placeholder, textarea.form-control::placeholder { color: var(--muted-foreground); }
.form-control:focus, .form-select:focus, textarea.form-control:focus {
    background: var(--card);
    border-color: var(--ring);
    box-shadow: none;
    outline: 2px solid var(--ring);
    outline-offset: -1px;
}
.form-label, label { font-size: 0.875rem; font-weight: var(--weight-medium); color: var(--foreground); margin-bottom: 0.375rem; }
.form-text { color: var(--muted-foreground); font-size: 0.8125rem; }
.invalid-feedback, .text-danger, .field-validation-error { color: var(--destructive) !important; font-size: 0.8125rem; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { border-color: var(--ring); box-shadow: none; }

/* ─────────────────────────────────────────────────────────────────────────────
   9. TABLES
   ───────────────────────────────────────────────────────────────────────────── */
.table { color: var(--foreground); margin-bottom: 0; font-size: 0.875rem; }
.table > thead > tr > th {
    background: transparent;
    color: var(--muted-foreground);
    font-size: 0.875rem;
    font-weight: var(--weight-medium);
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}
.table > tbody > tr > td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { background: var(--muted); }
.table .num, .table .amount { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { display: block; color: inherit; font-weight: var(--weight-medium); }
.row-link:hover { color: var(--primary); text-decoration: underline; }
.row-link:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-sm); }

/* ─────────────────────────────────────────────────────────────────────────────
   10. BADGES / PILLS — reference: rounded-md, xs, medium, sentence case
   ───────────────────────────────────────────────────────────────────────────── */
.badge, .pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: var(--weight-medium);
    line-height: 1.5;
    text-transform: none;
    letter-spacing: 0;
    border: 1px solid transparent;
    white-space: nowrap;
}
.pill::before { content: none; }

/* Bootstrap ships .bg-* as !important utilities, so these must match it or the
   tint reverts to Bootstrap's saturated defaults (e.g. #ffc107 for warning,
   which leaves brown-on-amber text well under AA). */
.badge.bg-success, .pill--success, .bg-success { background: var(--ok-bg)     !important; color: var(--ok-fg)     !important; }
.badge.bg-warning, .pill--warning, .bg-warning { background: var(--warn-bg)   !important; color: var(--warn-fg)   !important; }
.badge.bg-danger,  .pill--danger,  .bg-danger  { background: var(--danger-bg) !important; color: var(--danger-fg) !important; }
.badge.bg-info,    .pill--info,    .bg-info    { background: var(--info-bg)   !important; color: var(--info-fg)   !important; }
.badge.bg-primary, .badge.bg-secondary, .pill--neutral { background: var(--neutral-bg) !important; color: var(--neutral-fg) !important; }
.badge.rounded-pill { border-radius: var(--radius-pill); }

/* ─────────────────────────────────────────────────────────────────────────────
   11. TABS — reference segmented control
   ───────────────────────────────────────────────────────────────────────────── */
.nav-pills, .nav-pills-custom, .nav-tabs {
    background: var(--muted);
    padding: 0.1875rem;
    border-radius: var(--radius-lg);
    border: none;
    display: inline-flex;
    gap: 0.1875rem;
}
.nav-pills .nav-link, .nav-pills-custom .nav-link, .nav-tabs .nav-link {
    border: none;
    border-radius: var(--radius-md);
    color: var(--muted-foreground);
    font-size: 0.875rem;
    font-weight: var(--weight-medium);
    padding: 0.375rem 0.875rem;
    background: transparent;
}
.nav-pills .nav-link:hover, .nav-pills-custom .nav-link:hover, .nav-tabs .nav-link:hover { color: var(--foreground); }
.nav-pills .nav-link.active, .nav-pills-custom .nav-link.active, .nav-tabs .nav-link.active {
    background: var(--card);
    color: var(--foreground);
    box-shadow: 0 1px 2px rgb(0 0 0 / .06);
}

/* ─────────────────────────────────────────────────────────────────────────────
   12. ALERTS, DROPDOWNS, MODALS, LISTS
   ───────────────────────────────────────────────────────────────────────────── */
.alert { border-radius: var(--radius-lg); border: 1px solid var(--border); font-size: 0.875rem; padding: 1rem; }
.alert-success { background: var(--ok-bg);     color: var(--ok-fg); }
.alert-warning { background: var(--warn-bg);   color: var(--warn-fg); }
.alert-danger  { background: var(--danger-bg); color: var(--danger-fg); }
.alert-info    { background: var(--info-bg);   color: var(--info-fg); }
.alert-heading { font-size: 1rem; font-weight: var(--weight-medium); }

.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    padding: 0.25rem;
    font-size: 0.875rem;
    color: var(--foreground);
    min-width: 220px;
}
.dropdown-item { border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; color: var(--foreground); display: flex; align-items: center; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--accent); color: var(--foreground); }
.dropdown-header { color: var(--muted-foreground); font-size: 0.75rem; font-weight: var(--weight-medium); }
.dropdown-divider { border-color: var(--border); }
.dropdown-item-text { font-size: 0.875rem; }

/* Header bell. The dot renders only when there is something to act on, so it
   is a real signal rather than permanent decoration. */
.notify-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 8px; height: 8px;
    border-radius: var(--radius-pill);
    background: var(--info-fg);
    border: 2px solid var(--card);
    box-sizing: content-box;
}
.notify-dot--urgent { background: var(--destructive); }

.notify-icon {
    flex: 0 0 auto;
    width: 2rem; height: 2rem;
    display: grid; place-items: center;
    border-radius: var(--radius-md);
    background: var(--neutral-bg);
    color: var(--neutral-fg);
    font-size: 0.8125rem;
}
.notify-icon--urgent { background: var(--danger-bg); color: var(--danger-fg); }

/* Renewal prompt. Colour sits in the left rule and the icon tile only, so the
   copy keeps full contrast in both themes. */
.renewal-banner { border-left: 3px solid var(--warn-fg); }
.renewal-banner--urgent { border-left-color: var(--destructive); }

.modal-content { border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-pop); }
.modal-header, .modal-footer { border-color: var(--border); padding: 1.25rem 1.5rem; }
.modal-title { font-size: 1rem; font-weight: var(--weight-medium); }
.modal-body { padding: 1.5rem; }

.list-group-item { background: var(--card); border-color: var(--border); color: var(--foreground); font-size: 0.875rem; }
.breadcrumb { font-size: 0.875rem; }
.breadcrumb-item, .breadcrumb-item a { color: var(--muted-foreground); }
.breadcrumb-item.active { color: var(--foreground); }

/* ─────────────────────────────────────────────────────────────────────────────
   13. EMPTY / LOADING STATES
   ───────────────────────────────────────────────────────────────────────────── */
.empty-state { padding: 2.5rem 1.25rem; text-align: center; color: var(--muted-foreground); font-size: 0.875rem; }
.empty-state__icon { font-size: 1.5rem; color: var(--muted-foreground); margin-bottom: 0.5rem; }
.empty-state h5 { color: var(--foreground); }

.skeleton { background: var(--muted); border-radius: var(--radius-sm); animation: skeleton 1.6s ease-in-out infinite; }
@keyframes skeleton { 50% { opacity: .5 } }

/* ─────────────────────────────────────────────────────────────────────────────
   14. UTILITIES
   The text-* helpers below replace inline colour declarations that used to
   reference --theme-* tokens. Keeping colour in classes means it follows the
   theme (including dark) instead of being frozen into the markup.
   ───────────────────────────────────────────────────────────────────────────── */
.text-right { text-align: right; }

.text-brand  { color: var(--primary); }
.text-ok     { color: var(--ok-fg); }
.text-warn   { color: var(--warn-fg); }
.text-info-fg{ color: var(--info-fg); }
.text-bad    { color: var(--destructive); }
.text-strong { color: var(--foreground); }
.text-body   { color: var(--foreground); }
.text-dim    { color: var(--muted-foreground); }
.text-faint  { color: var(--border-solid); }

.surface-muted { background: var(--muted) !important; color: var(--foreground) !important; }

/* Circular icon tiles used in the admin/role views */
.avatar-tile {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-pill);
    flex-shrink: 0;
    background: var(--neutral-bg);
    color: var(--neutral-fg);
}
/* Solid fills: the icons inside these tiles carry .text-white, so a soft tint
   would render them invisible. */
.avatar-tile--brand   { background: var(--primary); color: var(--primary-foreground); }
.avatar-tile--warning { background: var(--warn-fg); color: #fff; }
.avatar-tile--danger  { background: var(--destructive); color: #fff; }
.avatar-tile--neutral { background: var(--neutral-bg); color: var(--neutral-fg); }

/* Left accent strips on summary cards */
.card-accent          { border-left: 3px solid var(--primary); }
.card-accent--success { border-left: 3px solid var(--ok-fg); }
.card-accent--info    { border-left: 3px solid var(--info-fg); }
.card-accent--warning { border-left: 3px solid var(--warn-fg); }

/* ─────────────────────────────────────────────────────────────────────────────
   15. SYNCFUSION EJ2
   The only !important in this file. EJ2's theme is served from a CDN with
   deeply specific selectors that ordinary specificity cannot reach.
   ───────────────────────────────────────────────────────────────────────────── */
.e-grid {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-xl) !important;
    overflow: hidden;
    font-family: inherit !important;
    color: var(--foreground) !important;
}
.e-grid .e-gridheader { border: none !important; border-bottom: 1px solid var(--border) !important; background: transparent !important; }
.e-grid .e-headercell, .e-grid .e-headercelldiv {
    background: transparent !important;
    color: var(--muted-foreground) !important;
    font-size: 0.875rem !important;
    font-weight: var(--weight-medium) !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    border: none !important;
}
.e-grid .e-headercell { padding: 0.75rem !important; vertical-align: middle; }
/* Vendor headers have a fixed line box even when text wrapping is enabled.
   Keep sort/filter controls intact while allowing complete words on multiple lines. */
.e-grid .e-headercelldiv {
    height: auto !important;
    min-height: 1.25rem;
    line-height: 1.4 !important;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
}
.e-grid .e-headertext {
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
}
.e-grid .e-headercell, .e-grid .e-headercelldiv { font-size: 0.8125rem !important; }
.e-grid .e-rowcell {
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    font-size: 0.875rem !important;
    color: var(--foreground) !important;
    padding: 0.625rem 0.75rem !important;
    vertical-align: middle !important;
    background: var(--card) !important;
}
.e-grid .e-altrow .e-rowcell { background: var(--card) !important; }
.e-grid .e-row:hover .e-rowcell { background: var(--muted) !important; }
.e-grid .e-gridcontent { border: none !important; }
.e-grid .e-toolbar { border: none !important; border-bottom: 1px solid var(--border) !important; background: transparent !important; }

.e-grid .e-pager {
    border: none !important;
    border-top: 1px solid var(--border) !important;
    background: var(--card) !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.875rem !important;
}
.e-pager .e-numericitem { color: var(--muted-foreground) !important; }
/* Listed after (and more specific than) .e-numericitem: both classes sit on the
   same element, so the current page would otherwise inherit muted grey on the
   near-black chip — about 2.3:1. */
.e-pager .e-currentitem,
.e-pager .e-numericitem.e-currentitem {
    background: var(--primary) !important;
    color: var(--primary-foreground) !important;
    border-radius: var(--radius-sm) !important;
}

.e-btn, .e-css.e-btn {
    border-radius: var(--radius-md) !important;
    font-family: inherit !important;
    font-size: 0.875rem !important;
    font-weight: var(--weight-medium) !important;
    text-transform: none !important;
}
.e-btn.e-primary { background: var(--primary) !important; border-color: var(--primary) !important; color: var(--primary-foreground) !important; }
.e-input-group, .e-input-group input { font-family: inherit !important; font-size: 0.875rem !important; }

/* ─────────────────────────────────────────────────────────────────────────────
   16. RESPONSIVE
   Previously a single 992px rule that slid the sidebar off-canvas with no
   backdrop and no narrow-screen handling for content.
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .app-content { padding: 1.25rem; }
}

@media (max-width: 992px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-pop); }
    .app-main { margin-left: 0; }

    /* modern-layout.js puts .sidebar-mobile-open on .app-sidebar itself. The
       old rule was a descendant selector (.sidebar-mobile-open .app-sidebar),
       which never matched — the mobile menu could not be opened at all. */
    .app-sidebar.sidebar-mobile-open { transform: translateX(0); }

    .hamburger, .app-header__mobile-menu, .mobile-toggle-nav {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Backdrop. modern-layout.js already toggles body.sidebar-open. */
    body.sidebar-open { overflow: hidden; }
    body.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgb(0 0 0 / .4);
        z-index: 999;
    }
}

@media (max-width: 768px) {
    .app-header { padding: 0 1rem; height: 56px; }
    .app-content { padding: 1rem; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; }

    .app-page-title { flex-direction: column; align-items: stretch; gap: 0.75rem; }
    .page-title-heading div:first-child { font-size: 1.125rem; }

    .card-body, .panel__body, .modal-body { padding: 1rem; }
    .card-header, .panel__head, .card-footer, .panel__foot { padding: 1rem; }

    /* Wide tables scroll inside their own container rather than forcing the
       page to scroll sideways. */
    .table-responsive, .e-gridcontent { -webkit-overflow-scrolling: touch; }
    .app-content .table:not(.e-table) {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table { font-size: 0.8125rem; }
    .table > thead > tr > th, .table > tbody > tr > td { padding: 0.625rem 0.75rem; }

    /* Full-width actions read better than a row of narrow buttons on a phone. */
    .page-title-actions .btn, .app-page-title > div > .btn { width: 100%; }
}

@media (max-width: 576px) {
    .stat-grid { grid-template-columns: 1fr; }
    .app-content { padding: 0.875rem; }
    .auth-card { padding: 1.5rem !important; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* The navy rail uses its own ink, independent of light/dark content surfaces. */
.app-sidebar { color: #c3d4ec; }
.app-sidebar .logo-src { color: #fff; gap: 0.75rem; }
.app-sidebar .logo-src:before { background-color: #fff; padding: 3px; background-size: 26px; filter: none; }
.app-sidebar .logo-src > span { display: block; }
.app-sidebar .logo-src small { display: block; color: #c3d4ec; font-size: 0.6875rem; font-weight: 400; margin-top: 3px; }
.vertical-nav-menu .app-sidebar__heading { color: #9eb8da; }
.vertical-nav-menu li a, .vertical-nav-menu li .nav-submenu-toggle { color: #c3d4ec; }
.vertical-nav-menu li a:hover, .vertical-nav-menu li .nav-submenu-toggle:hover { color: #fff; }
.vertical-nav-menu li a.mm-active, .vertical-nav-menu li.mm-active > a,
.vertical-nav-menu li.mm-active > .nav-submenu-toggle { background: #1d5296; color: #fff; }
.table { --bs-table-bg: var(--card); --bs-table-color: var(--foreground); }
.table > thead > tr > th { background: var(--muted); font-size: 0.8125rem; }
.e-grid .e-gridheader, .e-grid .e-toolbar { background: var(--muted) !important; }
.e-grid .e-rowcell.e-selectionbackground { background: var(--accent) !important; }
.table-responsive { border-radius: var(--radius-lg); }
.card-header { flex-wrap: wrap; }
.page-title-wrapper, .page-title-heading { min-width: 0; }
.page-title-heading { overflow-wrap: anywhere; }
@media (max-width: 768px) {
    /* Avoid automatic form zoom on mobile browsers. */
    .form-control, .form-select, textarea.form-control { font-size: 1rem; }
}
.e-grid .e-headercontent, .e-grid .e-headercontent .e-table { background: var(--muted) !important; }
