/* ══════════════════════════════════════════════════════════════
   Nexling Design System — v1.0
   ══════════════════════════════════════════════════════════════
   Design tokens, layout shell, component base styles.
   Loaded AFTER bootstrap.css, BEFORE site.css.
   ══════════════════════════════════════════════════════════════ */

/* ── COLOR PALETTE ─────────────────────────────────────────── */
:root {
    /* Primary — emerald green */
    --lf-50:  #ecfdf5;
    --lf-100: #d1fae5;
    --lf-200: #a7f3d0;
    --lf-300: #6ee7b7;
    --lf-400: #34d399;
    --lf-500: #10b981;
    --lf-600: #059669;
    --lf-700: #047857;
    --lf-800: #065f46;
    --lf-900: #064e3b;
    --lf-950: #022c22;

    /* Neutral — slate with green tint */
    --n-0:   #ffffff;
    --n-25:  #fcfcfd;
    --n-50:  #f8fafb;
    --n-100: #f1f5f9;
    --n-200: #e2e8f0;
    --n-300: #cbd5e1;
    --n-400: #94a3b8;
    --n-500: #64748b;
    --n-600: #475569;
    --n-700: #334155;
    --n-800: #1e293b;
    --n-900: #0f172a;
    --n-950: #020617;

    /* Semantic */
    --success:   #10b981;
    --warning:   #f59e0b;
    --error:     #ef4444;
    --info:      #3b82f6;

    /* Semantic — subtle backgrounds */
    --success-subtle: rgba(16, 185, 129, .08);
    --warning-subtle: rgba(245, 158, 11, .08);
    --error-subtle:   rgba(239, 68, 68, .08);
    --info-subtle:    rgba(59, 130, 246, .08);

    /* ── TYPOGRAPHY ────────────────────────────────────────── */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --text-xs:   0.75rem;   /* 12px */
    --text-sm:   0.8125rem; /* 13px */
    --text-base: 0.875rem;  /* 14px */
    --text-md:   0.9375rem; /* 15px */
    --text-lg:   1.125rem;  /* 18px */
    --text-xl:   1.25rem;   /* 20px */
    --text-2xl:  1.5rem;    /* 24px */
    --text-3xl:  1.875rem;  /* 30px */

    --weight-normal:   400;
    --weight-medium:   500;
    --weight-semibold: 600;
    --weight-bold:     700;
    --weight-extrabold:800;

    --leading-tight:  1.25;
    --leading-normal: 1.5;
    --leading-relaxed:1.625;

    --tracking-tight:  -0.025em;
    --tracking-normal:  0;
    --tracking-wide:    0.025em;
    --tracking-wider:   0.05em;

    /* ── SPACING ───────────────────────────────────────────── */
    --sp-0:   0;
    --sp-1:   0.25rem;   /* 4px */
    --sp-2:   0.5rem;    /* 8px */
    --sp-3:   0.75rem;   /* 12px */
    --sp-4:   1rem;      /* 16px */
    --sp-5:   1.25rem;   /* 20px */
    --sp-6:   1.5rem;    /* 24px */
    --sp-8:   2rem;      /* 32px */
    --sp-10:  2.5rem;    /* 40px */
    --sp-12:  3rem;      /* 48px */
    --sp-16:  4rem;      /* 64px */

    /* ── SHADOWS ───────────────────────────────────────────── */
    --shadow-xs:  0 1px 2px rgba(0, 0, 0, .05);
    --shadow-sm:  0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, .07), 0 2px 4px -2px rgba(0, 0, 0, .05);
    --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, .08), 0 4px 6px -4px rgba(0, 0, 0, .04);
    --shadow-xl:  0 20px 25px -5px rgba(0, 0, 0, .08), 0 8px 10px -6px rgba(0, 0, 0, .04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, .15);
    --shadow-ring:0 0 0 3px rgba(16, 185, 129, .15);
    --shadow-ring-error: 0 0 0 3px rgba(239, 68, 68, .12);

    /* ── BORDER RADIUS ─────────────────────────────────────── */
    --radius-sm:   6px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --radius-2xl:  20px;
    --radius-full: 9999px;

    /* ── TRANSITIONS ───────────────────────────────────────── */
    --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in:   cubic-bezier(0.55, 0, 1, 0.45);
    --ease-snap: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast:  120ms;
    --dur-base:  200ms;
    --dur-slow:  300ms;

    /* ── LAYOUT ────────────────────────────────────────────── */
    --sidebar-w:          240px;
    --sidebar-collapsed-w: 64px;
    --topbar-h:            56px;
    --content-max-w:       1240px;

    /* ── SURFACE COLORS (light mode) ───────────────────────── */
    --bg-app:        #f5f7fa;
    --bg-surface:    #ffffff;
    --bg-surface-2:  #f8fafb;
    --bg-elevated:   #ffffff;
    --border-default:rgba(0, 0, 0, .08);
    --border-subtle: rgba(0, 0, 0, .04);
    --text-primary:  var(--n-900);
    --text-secondary:var(--n-500);
    --text-tertiary: var(--n-400);
    --text-inverse:  #ffffff;

    /* Sidebar specific */
    --sb-bg:          linear-gradient(165deg, var(--lf-700) 0%, var(--lf-900) 100%);
    --sb-text:        rgba(255, 255, 255, .65);
    --sb-text-active: #ffffff;
    --sb-hover:       rgba(255, 255, 255, .08);
    --sb-active:      rgba(255, 255, 255, .14);
    --sb-section:     rgba(255, 255, 255, .28);
    --sb-accent:      var(--lf-300);
}

/* ── DARK MODE ─────────────────────────────────────────────── */
html[data-theme="dark"] {
    --bg-app:        #0c1210;
    --bg-surface:    #141c19;
    --bg-surface-2:  #1a2420;
    --bg-elevated:   #1e2a26;
    --border-default:rgba(255, 255, 255, .08);
    --border-subtle: rgba(255, 255, 255, .04);
    --text-primary:  #e2efe9;
    --text-secondary:#7a9a8e;
    --text-tertiary: #4a6a5e;
    --text-inverse:  #0c1210;

    --shadow-xs:  0 1px 2px rgba(0, 0, 0, .2);
    --shadow-sm:  0 1px 3px rgba(0, 0, 0, .3), 0 1px 2px rgba(0, 0, 0, .2);
    --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, .3), 0 2px 4px -2px rgba(0, 0, 0, .2);
    --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, .4), 0 4px 6px -4px rgba(0, 0, 0, .3);
    --shadow-xl:  0 20px 25px -5px rgba(0, 0, 0, .5), 0 8px 10px -6px rgba(0, 0, 0, .3);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, .6);
    --shadow-ring:0 0 0 3px rgba(16, 185, 129, .2);

    --success-subtle: rgba(16, 185, 129, .12);
    --warning-subtle: rgba(245, 158, 11, .12);
    --error-subtle:   rgba(239, 68, 68, .12);
    --info-subtle:    rgba(59, 130, 246, .12);

    --sb-bg:          linear-gradient(165deg, #0e1a16 0%, #081210 100%);

    color-scheme: dark;
}

/* ── FLASH PREVENTION ──────────────────────────────────────── */
/* The inline <script> in <head> sets data-theme before first paint.
   This class hides everything until the theme is applied. */
html:not([data-theme]) {
    visibility: hidden;
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT SHELL
   ══════════════════════════════════════════════════════════════ */

/* ── App container ─────────────────────────────────────────── */
.lf-app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.lf-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 200;
    transition: width var(--dur-slow) var(--ease-snap),
                transform var(--dur-slow) var(--ease-snap);
}

.lf-sidebar.collapsed {
    width: var(--sidebar-collapsed-w);
}

.lf-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding-bottom: var(--sp-6);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}
.lf-sidebar-inner::-webkit-scrollbar { display: none; }

/* ── Brand ─────────────────────────────────────────────────── */
.lf-sb-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-6) var(--sp-6) var(--sp-5);
    font-size: var(--text-xl);
    font-weight: var(--weight-extrabold);
    letter-spacing: var(--tracking-tight);
    color: #fff;
    text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
}
.lf-sb-brand i {
    font-size: 1.2rem;
    color: var(--sb-accent);
    flex-shrink: 0;
}
.lf-sb-brand span {
    opacity: 1;
    transition: opacity var(--dur-base) var(--ease-snap);
}
.lf-sb-brand:hover { color: #fff; text-decoration: none; }

.lf-sidebar.collapsed .lf-sb-brand span { opacity: 0; width: 0; }

/* ── Nav ───────────────────────────────────────────────────── */
.lf-sb-nav {
    flex: 1;
    padding: var(--sp-1) var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lf-sb-section {
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--sb-section);
    padding: var(--sp-5) var(--sp-2) var(--sp-2);
    white-space: nowrap;
    overflow: hidden;
}

.lf-sb-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--sb-text);
    text-decoration: none;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    transition: background var(--dur-fast) ease,
                color var(--dur-fast) ease;
}
.lf-sb-item i {
    width: 18px;
    text-align: center;
    font-size: 13px;
    flex-shrink: 0;
}
.lf-sb-item:hover {
    background: var(--sb-hover);
    color: var(--sb-text-active);
    text-decoration: none;
}
.lf-sb-item.active {
    background: var(--sb-active);
    color: var(--sb-text-active);
    font-weight: var(--weight-semibold);
}
.lf-sb-item span {
    opacity: 1;
    transition: opacity var(--dur-base) var(--ease-snap);
}
.lf-sidebar.collapsed .lf-sb-item span { opacity: 0; width: 0; }
.lf-sidebar.collapsed .lf-sb-section { opacity: 0; height: 0; padding: 0; margin: 0; }

.lf-sb-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--sb-accent);
    margin-left: auto;
    flex-shrink: 0;
}
.lf-sidebar.collapsed .lf-sb-dot { display: none; }

/* ── Collapse toggle button ────────────────────────────────── */
.lf-sb-collapse-btn {
    display: none; /* shown only on md+ screens */
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.5);
    cursor: pointer;
    position: absolute;
    right: -14px;
    top: 50px;
    z-index: 201;
    font-size: 11px;
    transition: background var(--dur-fast) ease,
                color var(--dur-fast) ease,
                transform var(--dur-base) var(--ease-snap);
}
.lf-sb-collapse-btn:hover {
    background: rgba(255,255,255,.14);
    color: #fff;
}
.lf-sidebar.collapsed .lf-sb-collapse-btn i {
    transform: rotate(180deg);
}
@media (min-width: 768px) {
    .lf-sb-collapse-btn { display: flex; }
}

/* ── User section ──────────────────────────────────────────── */
.lf-sb-user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-3);
    margin: var(--sp-2) var(--sp-3) 0;
    border-radius: var(--radius-lg);
    background: rgba(0, 0, 0, .18);
    flex-shrink: 0;
    overflow: hidden;
}
.lf-sb-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--lf-500);
    color: #fff;
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.lf-sb-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.lf-sb-user-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}
.lf-sb-user-role {
    font-size: 11px;
    color: rgba(255,255,255,.35);
    line-height: 1.35;
}
.lf-sb-logout {
    color: rgba(255,255,255,.35);
    font-size: 14px;
    text-decoration: none;
    transition: color var(--dur-fast) ease;
    flex-shrink: 0;
}
.lf-sb-logout:hover { color: rgba(255,255,255,.85); }

.lf-sidebar.collapsed .lf-sb-user-info,
.lf-sidebar.collapsed .lf-sb-logout { display: none; }
.lf-sidebar.collapsed .lf-sb-user {
    justify-content: center;
    padding: var(--sp-2);
    margin: var(--sp-2) var(--sp-1) 0;
}

/* ── Mobile overlay ────────────────────────────────────────── */
.lf-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 199;
    opacity: 0;
    transition: opacity var(--dur-base) ease;
}
.lf-sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ── Content area ──────────────────────────────────────────── */
.lf-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--bg-app);
}

/* ── Topbar ────────────────────────────────────────────────── */
.lf-topbar {
    display: flex;
    align-items: center;
    height: var(--topbar-h);
    padding: 0 var(--sp-8);
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
    gap: var(--sp-4);
    z-index: 100;
}

html[data-theme="dark"] .lf-topbar {
    background: rgba(20, 28, 25, .78);
}

/* Breadcrumb in topbar */
.lf-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    min-width: 0;
}
.lf-breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--dur-fast) ease;
}
.lf-breadcrumb a:hover {
    color: var(--lf-600);
}
.lf-breadcrumb-sep {
    color: var(--text-tertiary);
    font-size: 10px;
}
.lf-breadcrumb-current {
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lf-topbar-title {
    font-size: var(--text-md);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lf-hamburger {
    background: none;
    border: none;
    padding: var(--sp-2);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    border-radius: var(--radius-md);
    line-height: 1;
    transition: background var(--dur-fast) ease,
                color var(--dur-fast) ease;
}
.lf-hamburger:hover { background: var(--bg-surface-2); color: var(--text-primary); }

/* ── Theme toggle ──────────────────────────────────────────── */
.lf-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: background var(--dur-fast) ease,
                border-color var(--dur-fast) ease,
                color var(--dur-fast) ease;
}
.lf-theme-toggle:hover {
    background: var(--lf-50);
    border-color: var(--lf-200);
    color: var(--lf-600);
}
html[data-theme="dark"] .lf-theme-toggle:hover {
    background: rgba(16, 185, 129, .1);
    border-color: rgba(16, 185, 129, .3);
    color: var(--lf-400);
}

/* ── Main content ──────────────────────────────────────────── */
.lf-main {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-8);
    scrollbar-width: thin;
    scrollbar-color: var(--n-300) transparent;
}
.lf-main::-webkit-scrollbar { width: 5px; }
.lf-main::-webkit-scrollbar-track { background: transparent; }
.lf-main::-webkit-scrollbar-thumb {
    background: var(--n-300);
    border-radius: var(--radius-full);
}
html[data-theme="dark"] .lf-main { scrollbar-color: #2a3d34 transparent; }
html[data-theme="dark"] .lf-main::-webkit-scrollbar-thumb { background: #2a3d34; }

/* Content max-width wrapper */
.lf-content-wrap {
    max-width: var(--content-max-w);
    margin: 0 auto;
    width: 100%;
}

/* ── Footer ────────────────────────────────────────────────── */
.lf-app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-8);
    font-size: 11.5px;
    color: var(--text-tertiary);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-default);
    flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 767px) {
    .lf-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
        width: var(--sidebar-w); /* always expanded on mobile */
    }
    .lf-sidebar.open {
        transform: translateX(0);
        box-shadow: 6px 0 32px rgba(0, 0, 0, .2);
    }
    .lf-sidebar.collapsed { width: var(--sidebar-w); }
    .lf-main { padding: var(--sp-5) var(--sp-4); }
    .lf-topbar { padding: 0 var(--sp-4); }
    .lf-app-footer { padding: var(--sp-3) var(--sp-4); }
}

/* ══════════════════════════════════════════════════════════════
   BASE COMPONENT TOKENS
   ══════════════════════════════════════════════════════════════ */

/* ── Page headings ─────────────────────────────────────────── */
.lf-page-heading {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
}

.lf-page-eyebrow {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--text-tertiary);
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: box-shadow var(--dur-base) var(--ease-snap),
                transform var(--dur-base) var(--ease-snap);
}
.card:hover {
    box-shadow: var(--shadow-md) !important;
}

.card-header {
    background: var(--bg-surface-2) !important;
    border-bottom: 1px solid var(--border-default) !important;
    padding: var(--sp-4) var(--sp-6) !important;
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

html[data-theme="dark"] .card {
    background: var(--bg-surface) !important;
    border-color: var(--border-default) !important;
    box-shadow: var(--shadow-sm) !important;
}
html[data-theme="dark"] .card:hover {
    box-shadow: var(--shadow-md) !important;
}
html[data-theme="dark"] .card-header {
    background: var(--bg-surface-2) !important;
    border-bottom-color: var(--border-default) !important;
    color: var(--text-primary) !important;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    font-family: var(--font-sans);
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    letter-spacing: 0.01em;
    transition: background var(--dur-fast) ease,
                border-color var(--dur-fast) ease,
                color var(--dur-fast) ease,
                box-shadow var(--dur-fast) ease,
                transform 80ms ease;
}
.btn:active { transform: scale(.98); }
.btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-ring) !important;
}
.btn-sm {
    font-size: var(--text-xs);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
}

.btn-green,
.btn-success {
    background: var(--lf-600);
    border-color: var(--lf-600);
    color: #fff !important;
    font-weight: var(--weight-bold);
}
.btn-green:hover, .btn-green:focus,
.btn-success:hover, .btn-success:focus {
    background: var(--lf-700);
    border-color: var(--lf-700);
    box-shadow: 0 4px 14px rgba(5, 150, 105, .3);
    color: #fff !important;
}

.btn-outline-success {
    color: var(--lf-600) !important;
    border-color: var(--lf-300) !important;
    background: transparent;
}
.btn-outline-success:hover {
    background: var(--lf-600) !important;
    border-color: var(--lf-600) !important;
    color: #fff !important;
    box-shadow: 0 3px 12px rgba(5, 150, 105, .2);
}

/* ── Form controls ─────────────────────────────────────────── */
.form-control,
.form-select {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1.5px solid var(--n-200);
    border-radius: var(--radius-md) !important;
    padding: 9px 13px;
    transition: border-color var(--dur-fast) ease,
                box-shadow var(--dur-fast) ease,
                background var(--dur-fast) ease;
    box-shadow: none !important;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--lf-400) !important;
    box-shadow: var(--shadow-ring) !important;
    background: var(--bg-surface);
    outline: none;
}
.form-control::placeholder { color: var(--text-tertiary); }
.form-label { color: var(--text-secondary); font-weight: var(--weight-medium); font-size: var(--text-sm); }

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
    background: var(--bg-surface-2);
    border-color: var(--border-default);
    color: var(--text-primary);
}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus {
    background: var(--bg-elevated);
    border-color: var(--lf-500) !important;
    box-shadow: var(--shadow-ring) !important;
}
html[data-theme="dark"] .form-control::placeholder { color: var(--text-tertiary); }
html[data-theme="dark"] .form-label { color: var(--text-secondary); }

/* ── Tables ────────────────────────────────────────────────── */
.table {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
    --bs-table-bg: transparent;
    --bs-table-hover-bg: var(--success-subtle);
}
.table thead th {
    font-size: 11px;
    font-weight: var(--weight-bold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    border-bottom: 1px solid var(--border-default) !important;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-surface-2) !important;
}
.table tbody td {
    border-bottom: 1px solid var(--border-subtle) !important;
    padding: var(--sp-3) var(--sp-4);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none !important; }

html[data-theme="dark"] .table thead th {
    background: var(--bg-surface-2) !important;
    color: var(--text-secondary);
    border-bottom-color: var(--border-default) !important;
}
html[data-theme="dark"] .table tbody td {
    border-bottom-color: var(--border-subtle) !important;
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-content {
    border: none !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-2xl) !important;
    font-family: var(--font-sans);
    overflow: hidden;
    background: var(--bg-surface);
}
.modal-header {
    border-bottom: 1px solid var(--border-default) !important;
    padding: var(--sp-5) var(--sp-6) !important;
    background: var(--bg-surface);
}
.modal-title {
    font-size: var(--text-md) !important;
    font-weight: var(--weight-bold) !important;
    color: var(--text-primary);
}
.modal-body {
    padding: var(--sp-6) !important;
    color: var(--text-primary);
}
.modal-footer {
    border-top: 1px solid var(--border-default) !important;
    padding: var(--sp-4) var(--sp-6) !important;
    background: var(--bg-surface-2);
}

html[data-theme="dark"] .modal-content {
    background: var(--bg-surface) !important;
    box-shadow: 0 20px 80px rgba(0, 0, 0, .6) !important;
}
html[data-theme="dark"] .modal-header {
    background: var(--bg-surface) !important;
    border-bottom-color: var(--border-default) !important;
}
html[data-theme="dark"] .modal-title { color: var(--text-primary) !important; }
html[data-theme="dark"] .modal-body { color: var(--text-primary); }
html[data-theme="dark"] .modal-footer {
    background: var(--bg-surface-2) !important;
    border-top-color: var(--border-default) !important;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    font-weight: var(--weight-semibold);
    font-size: 11px;
    letter-spacing: 0.02em;
    border-radius: var(--radius-sm);
    padding: 3px 8px;
}

/* ── Dropdowns ─────────────────────────────────────────────── */
.dropdown-menu {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: var(--sp-1) !important;
    background: var(--bg-surface);
    font-size: var(--text-sm);
}
.dropdown-item {
    border-radius: var(--radius-sm);
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    color: var(--text-primary);
    transition: background var(--dur-fast) ease;
}
.dropdown-item:hover {
    background: var(--success-subtle);
    color: var(--lf-700);
}

html[data-theme="dark"] .dropdown-menu {
    background: var(--bg-elevated) !important;
    border-color: var(--border-default) !important;
    box-shadow: var(--shadow-xl) !important;
}
html[data-theme="dark"] .dropdown-item { color: var(--text-primary); }
html[data-theme="dark"] .dropdown-item:hover {
    background: var(--success-subtle);
    color: var(--lf-400);
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    border-radius: var(--radius-lg);
    border: none;
    font-size: var(--text-sm);
    padding: var(--sp-3) var(--sp-4);
}
.alert-success { background: var(--success-subtle); color: var(--lf-700); }
.alert-danger  { background: var(--error-subtle);   color: #b91c1c; }
.alert-warning { background: var(--warning-subtle); color: #92400e; }
.alert-info    { background: var(--info-subtle);    color: #1d4ed8; }

html[data-theme="dark"] .alert-success { background: var(--success-subtle); color: var(--lf-300); }
html[data-theme="dark"] .alert-danger  { background: var(--error-subtle);   color: #fca5a5; }
html[data-theme="dark"] .alert-warning { background: var(--warning-subtle); color: #fcd34d; }
html[data-theme="dark"] .alert-info    { background: var(--info-subtle);    color: #93c5fd; }

/* ── Toast overrides ───────────────────────────────────────── */
.lf-toast-success { border-left: 4px solid var(--success); }
.lf-toast-error   { border-left: 4px solid var(--error); }
.lf-toast-info    { border-left: 4px solid var(--info); }

/* ── Nav pills ─────────────────────────────────────────────── */
.nav-pills {
    gap: var(--sp-1);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--sp-2) var(--sp-3) !important;
    box-shadow: var(--shadow-sm) !important;
}
.nav-pills .nav-link {
    border-radius: var(--radius-md) !important;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary) !important;
    padding: var(--sp-2) var(--sp-3);
    transition: background var(--dur-fast) ease,
                color var(--dur-fast) ease;
}
.nav-pills .nav-link:hover {
    background: var(--success-subtle);
    color: var(--lf-700) !important;
}
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
    background: var(--lf-600) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(5, 150, 105, .25);
    font-weight: var(--weight-bold);
}

html[data-theme="dark"] .nav-pills {
    background: var(--bg-surface) !important;
    box-shadow: var(--shadow-sm) !important;
}
html[data-theme="dark"] .nav-pills .nav-link:not(.active) { color: var(--text-secondary) !important; }
html[data-theme="dark"] .nav-pills .nav-link:hover:not(.active) { background: var(--success-subtle); }

/* ── Progress bars ─────────────────────────────────────────── */
.progress {
    border-radius: var(--radius-full);
    background: var(--n-100);
    height: 6px;
}
.progress-bar {
    background: var(--lf-500);
    border-radius: var(--radius-full);
}
html[data-theme="dark"] .progress { background: rgba(255, 255, 255, .08); }

/* ── Smooth theme transition ───────────────────────────────── */
*,
*::before,
*::after {
    transition:
        background-color var(--dur-base) ease,
        border-color var(--dur-base) ease,
        color var(--dur-fast) ease,
        box-shadow var(--dur-base) ease;
}
/* Exclude layout/width/height transitions from the global rule */
.lf-proj-bar-fill,
.lf-lang-bar-fill,
.lf-toolbar-bar-fill { transition: width 0.4s ease; }
.lf-sidebar { transition: width var(--dur-slow) var(--ease-snap), transform var(--dur-slow) var(--ease-snap); }

/* ── btn-close dark mode ───────────────────────────────────── */
html[data-theme="dark"] .btn-close { filter: invert(.7) brightness(1.5); }

/* ── Text utilities with token colors ──────────────────────── */
html[data-theme="dark"] .text-muted { color: var(--text-secondary) !important; }
html[data-theme="dark"] .fw-semibold { color: var(--text-primary); }
