/* ========================================================================
   Scan Manager – Design System (dark)
   Token names are kept from the previous light theme so inline
   var(--…) references in views pick up the new values automatically.
   ======================================================================== */

:root {
    --sidebar-width: 248px;
    --sidebar-collapsed: 0px;
    --topbar-height: 56px;

    /* Brand */
    --brand: #060c18;
    --brand-light: #0b1424;
    --brand-accent: #38bdf8;
    --brand-accent-hover: #7dd3fc;
    --brand-accent-strong: #0ea5e9;
    --brand-accent-subtle: rgba(56, 189, 248, .12);
    --on-accent: #04111f;

    /* Surfaces (base → raised → elevated → overlay) */
    --surface-base: #060c18;
    --surface: #0b1424;
    --surface-alt: #060c18;
    --surface-elevated: #111d33;
    --surface-hover: #13213a;
    --surface-overlay: #16243e;

    /* Lines */
    --border: rgba(148, 163, 184, .12);
    --border-strong: rgba(148, 163, 184, .22);

    /* Text */
    --text: #eef4ff;
    --text-secondary: #b6c6da;
    --text-muted: #9fb3cc;
    --text-light: #6b84a3;

    /* Status */
    --success: #22c55e;
    --success-text: #4ade80;
    --success-subtle: rgba(34, 197, 94, .14);
    --warning: #f59e0b;
    --warning-text: #fbbf24;
    --warning-subtle: rgba(245, 158, 11, .14);
    --danger: #ef4444;
    --danger-text: #f87171;
    --danger-subtle: rgba(239, 68, 68, .14);
    --info: #38bdf8;
    --info-text: #7dd3fc;
    --info-subtle: rgba(56, 189, 248, .14);
    --neutral-subtle: rgba(148, 163, 184, .14);

    /* Shape */
    --radius-sm: .5rem;
    --radius: .5rem;
    --radius-lg: .75rem;
    --radius-xl: 1rem;
    --shadow-sm: inset 0 1px 0 rgba(255,255,255,.03);
    --shadow: 0 1px 2px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.03);
    --shadow-md: 0 8px 24px -8px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.04);
    --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.7);
    --focus-ring: 0 0 0 3px rgba(56, 189, 248, .35);
    --transition: 150ms cubic-bezier(.2, 0, 0, 1);

    /* Aliases referenced by inline styles in older views (previously undefined) */
    --primary: var(--brand-accent);
    --accent: var(--brand-accent);
    --border-color: var(--border);
    --bg-alt: var(--surface-elevated);
    --warning-bg: var(--warning-subtle);
    --danger-bg: var(--danger-subtle);
    --success-bg: var(--success-subtle);
    --info-bg: var(--info-subtle);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── Bootstrap 5.3 dark theme mapped to our tokens ── */
[data-bs-theme=dark] {
    color-scheme: dark;
    --bs-body-bg: var(--surface-base);
    --bs-body-bg-rgb: 6, 12, 24;
    --bs-body-color: var(--text);
    --bs-body-color-rgb: 238, 244, 255;
    --bs-body-font-family: var(--font-sans);
    --bs-emphasis-color: #ffffff;
    --bs-secondary-color: var(--text-muted);
    --bs-secondary-bg: var(--surface-elevated);
    --bs-tertiary-color: var(--text-light);
    --bs-tertiary-bg: var(--surface);
    --bs-border-color: var(--border);
    --bs-border-color-translucent: var(--border);
    --bs-heading-color: var(--text);
    --bs-link-color: var(--brand-accent);
    --bs-link-color-rgb: 56, 189, 248;
    --bs-link-hover-color: var(--brand-accent-hover);
    --bs-link-hover-color-rgb: 125, 211, 252;
    --bs-primary: var(--brand-accent);
    --bs-primary-rgb: 56, 189, 248;
    --bs-success-rgb: 34, 197, 94;
    --bs-warning-rgb: 245, 158, 11;
    --bs-danger-rgb: 239, 68, 68;
    --bs-info-rgb: 56, 189, 248;
    --bs-primary-text-emphasis: var(--info-text);
    --bs-success-text-emphasis: var(--success-text);
    --bs-warning-text-emphasis: var(--warning-text);
    --bs-danger-text-emphasis: var(--danger-text);
    --bs-info-text-emphasis: var(--info-text);
    --bs-primary-bg-subtle: var(--info-subtle);
    --bs-success-bg-subtle: var(--success-subtle);
    --bs-warning-bg-subtle: var(--warning-subtle);
    --bs-danger-bg-subtle: var(--danger-subtle);
    --bs-info-bg-subtle: var(--info-subtle);
    --bs-secondary-bg-subtle: var(--neutral-subtle);
    --bs-light-bg-subtle: var(--surface-elevated);
    --bs-dark-bg-subtle: var(--surface-base);
    --bs-primary-border-subtle: rgba(56, 189, 248, .3);
    --bs-success-border-subtle: rgba(34, 197, 94, .3);
    --bs-warning-border-subtle: rgba(245, 158, 11, .3);
    --bs-danger-border-subtle: rgba(239, 68, 68, .3);
    --bs-info-border-subtle: rgba(56, 189, 248, .3);
    --bs-border-radius: var(--radius);
    --bs-border-radius-lg: var(--radius-lg);
    --bs-focus-ring-color: rgba(56, 189, 248, .35);
    --bs-form-valid-color: var(--success-text);
    --bs-form-valid-border-color: var(--success);
    --bs-form-invalid-color: var(--danger-text);
    --bs-form-invalid-border-color: var(--danger);
}

/* Bootstrap utilities that hard-code light colours */
[data-bs-theme=dark] .bg-white,
[data-bs-theme=dark] .bg-light { background-color: var(--surface) !important; color: var(--text); }
[data-bs-theme=dark] .text-dark { color: var(--text) !important; }
[data-bs-theme=dark] .text-muted,
[data-bs-theme=dark] .text-secondary { color: var(--text-muted) !important; }
[data-bs-theme=dark] .text-success { color: var(--success-text) !important; }
[data-bs-theme=dark] .text-warning { color: var(--warning-text) !important; }
[data-bs-theme=dark] .text-danger { color: var(--danger-text) !important; }
[data-bs-theme=dark] .text-info,
[data-bs-theme=dark] .text-primary { color: var(--info-text) !important; }
[data-bs-theme=dark] .border,
[data-bs-theme=dark] .border-top,
[data-bs-theme=dark] .border-bottom,
[data-bs-theme=dark] .border-start,
[data-bs-theme=dark] .border-end { border-color: var(--border) !important; }
[data-bs-theme=dark] .shadow,
[data-bs-theme=dark] .shadow-sm { box-shadow: var(--shadow) !important; }
[data-bs-theme=dark] .card {
    --bs-card-bg: var(--surface);
    --bs-card-cap-bg: transparent;
    --bs-card-border-color: var(--border);
    --bs-card-border-radius: var(--radius-lg);
}
[data-bs-theme=dark] .modal {
    --bs-modal-bg: var(--surface-elevated);
    --bs-modal-border-color: var(--border-strong);
    --bs-modal-header-border-color: var(--border);
    --bs-modal-footer-border-color: var(--border);
    --bs-modal-border-radius: var(--radius-xl);
}
[data-bs-theme=dark] .modal-backdrop { --bs-backdrop-bg: #000; --bs-backdrop-opacity: .65; }
[data-bs-theme=dark] .dropdown-menu {
    --bs-dropdown-bg: var(--surface-overlay);
    --bs-dropdown-border-color: var(--border-strong);
    --bs-dropdown-link-color: var(--text);
    --bs-dropdown-link-hover-bg: var(--surface-hover);
    --bs-dropdown-link-active-bg: var(--brand-accent-subtle);
    --bs-dropdown-link-active-color: var(--brand-accent);
    --bs-dropdown-border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: .375rem;
}
[data-bs-theme=dark] .dropdown-item { border-radius: var(--radius-sm); font-size: .85rem; }
[data-bs-theme=dark] .list-group {
    --bs-list-group-bg: var(--surface);
    --bs-list-group-border-color: var(--border);
    --bs-list-group-action-hover-bg: var(--surface-hover);
    --bs-list-group-active-bg: var(--brand-accent-subtle);
    --bs-list-group-active-color: var(--brand-accent);
    --bs-list-group-active-border-color: var(--border-strong);
}
[data-bs-theme=dark] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: rgba(148,163,184,.04);
    --bs-table-hover-bg: var(--surface-hover);
}
[data-bs-theme=dark] .nav-tabs {
    --bs-nav-tabs-border-color: var(--border);
    --bs-nav-tabs-link-hover-border-color: transparent;
    --bs-nav-tabs-link-active-bg: transparent;
    --bs-nav-tabs-link-active-color: var(--text);
    --bs-nav-tabs-link-active-border-color: transparent;
}
[data-bs-theme=dark] .nav-tabs .nav-link { color: var(--text-muted); border: none; border-bottom: 2px solid transparent; font-weight: 500; }
[data-bs-theme=dark] .nav-tabs .nav-link:hover { color: var(--text); }
[data-bs-theme=dark] .nav-tabs .nav-link.active { color: var(--text); border-bottom-color: var(--brand-accent); }
[data-bs-theme=dark] .nav-pills {
    --bs-nav-pills-link-active-bg: var(--brand-accent-subtle);
    --bs-nav-pills-link-active-color: var(--brand-accent);
}
[data-bs-theme=dark] .progress {
    --bs-progress-bg: rgba(148,163,184,.12);
    --bs-progress-bar-bg: var(--brand-accent);
    --bs-progress-border-radius: 999px;
}
[data-bs-theme=dark] .badge.bg-secondary { background: var(--neutral-subtle) !important; color: var(--text-secondary); }
[data-bs-theme=dark] .badge.bg-success { background: var(--success-subtle) !important; color: var(--success-text); }
[data-bs-theme=dark] .badge.bg-warning { background: var(--warning-subtle) !important; color: var(--warning-text) !important; }
[data-bs-theme=dark] .badge.bg-danger { background: var(--danger-subtle) !important; color: var(--danger-text); }
[data-bs-theme=dark] .badge.bg-info,
[data-bs-theme=dark] .badge.bg-primary { background: var(--info-subtle) !important; color: var(--info-text) !important; }
[data-bs-theme=dark] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
[data-bs-theme=dark] hr { border-color: var(--border); opacity: 1; }
[data-bs-theme=dark] code { color: var(--info-text); }
[data-bs-theme=dark] pre {
    background: var(--surface-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .875rem 1rem;
    color: var(--text-secondary);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: var(--font-sans);
    font-feature-settings: 'cv11', 'ss01';
    background: var(--surface-base);
    color: var(--text);
    margin: 0;
    font-size: .9rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}
::selection { background: rgba(56, 189, 248, .3); color: #fff; }
h1, h2, h3, h4, h5, h6 { color: var(--text); letter-spacing: -.015em; font-weight: 650; }
a { color: var(--brand-accent); }
a:hover { color: var(--brand-accent-hover); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.tabular, .stat-value, .tg-table td { font-variant-numeric: tabular-nums; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(148,163,184,.25) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(148,163,184,.2); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: rgba(148,163,184,.35); }

/* ── Sidebar ── */
.tg-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--brand);
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 220ms cubic-bezier(.2, 0, 0, 1);
    overflow-y: auto;
    overflow-x: hidden;
}
.tg-sidebar-brand {
    padding: 1.125rem 1.125rem 1rem;
    display: flex;
    align-items: center;
    gap: .7rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -.02em;
}
.tg-sidebar-brand:hover { color: #fff; }
.tg-sidebar-brand .brand-icon {
    width: 32px;
    height: 32px;
    background: #38bdf8;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px -4px rgba(56,189,248,.6), inset 0 1px 0 rgba(255,255,255,.25);
}
.tg-sidebar-section {
    padding: .875rem .75rem .375rem;
    font-size: .66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--text-light);
}
.tg-sidebar-nav {
    list-style: none;
    padding: .25rem .625rem 1rem;
    margin: 0;
    flex: 1;
}
.tg-sidebar-nav li { margin-bottom: 2px; }
.tg-sidebar-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem .75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: .845rem;
    font-weight: 500;
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
}
.tg-sidebar-nav a:hover {
    color: var(--text);
    background: rgba(148,163,184,.07);
}
.tg-sidebar-nav a.active {
    color: #fff;
    background: var(--brand-accent-subtle);
}
.tg-sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: -.625rem;
    top: .45rem;
    bottom: .45rem;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand-accent);
    box-shadow: 0 0 12px rgba(56,189,248,.6);
}
.tg-sidebar-nav a .nav-icon {
    width: 18px;
    font-size: 1rem;
    opacity: .75;
    flex-shrink: 0;
    text-align: center;
}
.tg-sidebar-nav a.active .nav-icon { opacity: 1; color: var(--brand-accent); }
.tg-sidebar-nav a:hover .nav-icon { opacity: 1; }
.tg-sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: .625rem .75rem;
}
.tg-sidebar-footer {
    padding: .875rem 1rem 1rem;
    border-top: 1px solid var(--border);
    font-size: .8rem;
}
.tg-sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: .625rem;
    margin-bottom: .75rem;
}
.tg-sidebar-footer .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a5f, #0c4a6e);
    border: 1px solid rgba(56,189,248,.35);
    color: var(--brand-accent-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.tg-sidebar-footer .user-name {
    color: var(--text);
    font-weight: 600;
    font-size: .82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tg-sidebar-footer .user-role {
    color: var(--text-light);
    font-size: .72rem;
}

/* ── Topbar (mobile) ── */
.tg-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: rgba(6, 12, 24, .82);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    z-index: 1041;
    padding: 0 1rem;
    align-items: center;
    gap: .75rem;
}
.tg-topbar .brand-text {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -.02em;
}
.tg-menu-toggle {
    background: none;
    border: none;
    color: var(--text);
    padding: .25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: var(--radius-sm);
}

/* ── Main content ── */
.tg-main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100vw - var(--sidebar-width));
    min-height: 100vh;
    padding: 2rem 2.5rem 3rem;
    transition: margin-left var(--transition);
    overflow-x: hidden;
    background:
        radial-gradient(1200px 400px at 70% -200px, rgba(56,189,248,.06), transparent 70%),
        var(--surface-base);
}

/* ── Impersonation banner ── */
.tg-impersonation-bar {
    background: linear-gradient(90deg, rgba(245,158,11,.22), rgba(245,158,11,.12));
    color: var(--warning-text);
    padding: .65rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: .85rem;
    border: 1px solid rgba(245,158,11,.35);
    border-radius: var(--radius-lg);
    margin-bottom: 1.25rem;
}
.tg-impersonation-bar strong { color: #fde68a; }
.tg-impersonation-bar button {
    background: var(--warning);
    color: #1c1003;
    border: none;
    border-radius: var(--radius-sm);
    padding: .3rem .8rem;
    font-weight: 600;
    cursor: pointer;
    font-size: .8rem;
    white-space: nowrap;
}
.tg-impersonation-bar button:hover { background: var(--warning-text); }

/* ── Overlay ── */
.tg-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 1039;
}

/* ── Mobile ── */
@media (max-width: 991.98px) {
    .tg-sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .tg-sidebar.open {
        transform: translateX(0);
    }
    .tg-overlay.open {
        display: block;
    }
    .tg-topbar {
        display: flex;
    }
    .tg-main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        padding: calc(var(--topbar-height) + 1.25rem) 1rem 2rem;
    }
}

/* ── Page header ── */
.page-header {
    margin-bottom: 1.75rem;
}
.page-header h1 {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -.025em;
    line-height: 1.2;
}
.page-header .page-subtitle {
    color: var(--text-muted);
    font-size: .875rem;
    margin-top: .35rem;
}
.page-header .page-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
}
.page-header-row > div {
    min-width: 0;
    flex: 1 1 320px;
}
.page-header-row .page-actions {
    flex: 0 1 auto;
}

/* ── Breadcrumbs ── */
.tg-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .4rem;
    font-size: .8rem;
    color: var(--text-light);
    margin-bottom: .875rem;
}
.tg-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}
.tg-breadcrumb a:hover { color: var(--brand-accent); }
.tg-breadcrumb .sep { color: var(--text-light); opacity: .6; }

/* ── Cards ── */
.tg-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.tg-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: .875rem 1.25rem;
    font-weight: 600;
    font-size: .875rem;
    color: var(--text);
    letter-spacing: -.005em;
}
.tg-card .card-body {
    padding: 1.25rem;
}
.tg-card .card-footer {
    background: transparent;
    border-top: 1px solid var(--border);
    padding: .75rem 1.25rem;
}

/* ── Stat cards ── */
.stat-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.125rem 1.25rem;
    text-align: left;
    overflow: hidden;
    transition: border-color var(--transition), background var(--transition);
    box-shadow: var(--shadow-sm);
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-card .stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -.03em;
    color: var(--text);
}
.stat-card .stat-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-top: .35rem;
}
.stat-card::after {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 2px;
    background: transparent;
}
.stat-card.stat-success .stat-value { color: var(--success-text); }
.stat-card.stat-warning .stat-value { color: var(--warning-text); }
.stat-card.stat-info .stat-value { color: var(--info-text); }
.stat-card.stat-danger .stat-value { color: var(--danger-text); }
.stat-card.stat-primary::after { background: linear-gradient(90deg, var(--brand-accent), transparent); }
.stat-card.stat-success::after { background: linear-gradient(90deg, var(--success), transparent); }
.stat-card.stat-warning::after { background: linear-gradient(90deg, var(--warning), transparent); }
.stat-card.stat-danger::after { background: linear-gradient(90deg, var(--danger), transparent); }
.stat-card.stat-info::after { background: linear-gradient(90deg, var(--info), transparent); }

/* Progress track (usable inside stat cards or anywhere) */
.tg-progress {
    height: 6px;
    background: rgba(148,163,184,.12);
    border-radius: 999px;
    overflow: hidden;
}
.tg-progress > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand-accent-strong), var(--brand-accent));
}

/* ── Tables ── */
.tg-table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    max-width: 100%;
}
.tg-table-wrapper .table-responsive {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}
.tg-table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
    color: var(--text);
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
}
.tg-table thead th {
    background: rgba(6, 12, 24, .55);
    border-bottom: 1px solid var(--border);
    padding: .625rem 1rem;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-light);
    white-space: nowrap;
}
.tg-table tbody td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: .855rem;
    vertical-align: middle;
    color: var(--text);
    background: transparent;
}
.tg-table tbody tr:last-child td { border-bottom: none; }
.tg-table tbody tr { transition: background var(--transition); }
.tg-table tbody tr:hover { background: rgba(148,163,184,.05); }
.tg-table tbody tr:hover td { background: transparent; }
.tg-table .actions-cell {
    white-space: nowrap;
    text-align: right;
}

/* ── Buttons ── */
.btn {
    border-radius: var(--radius);
    font-weight: 550;
    font-size: .85rem;
    transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
    letter-spacing: -.005em;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--focus-ring); }
.btn-xs { padding: .25rem .5rem; font-size: .75rem; }

.btn-primary {
    --bs-btn-color: var(--on-accent);
    --bs-btn-bg: var(--brand-accent);
    --bs-btn-border-color: var(--brand-accent);
    --bs-btn-hover-color: var(--on-accent);
    --bs-btn-hover-bg: var(--brand-accent-hover);
    --bs-btn-hover-border-color: var(--brand-accent-hover);
    --bs-btn-active-color: var(--on-accent);
    --bs-btn-active-bg: var(--brand-accent-strong);
    --bs-btn-active-border-color: var(--brand-accent-strong);
    --bs-btn-disabled-color: var(--on-accent);
    --bs-btn-disabled-bg: var(--brand-accent);
    --bs-btn-disabled-border-color: var(--brand-accent);
    box-shadow: 0 6px 18px -8px rgba(56,189,248,.7), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-success {
    --bs-btn-color: #03140a;
    --bs-btn-bg: var(--success);
    --bs-btn-border-color: var(--success);
    --bs-btn-hover-color: #03140a;
    --bs-btn-hover-bg: var(--success-text);
    --bs-btn-hover-border-color: var(--success-text);
    --bs-btn-active-color: #03140a;
    --bs-btn-active-bg: #16a34a;
}
.btn-danger {
    --bs-btn-bg: #dc2626;
    --bs-btn-border-color: #dc2626;
    --bs-btn-hover-bg: var(--danger);
    --bs-btn-hover-border-color: var(--danger);
}
.btn-warning {
    --bs-btn-color: #1c1003;
    --bs-btn-hover-color: #1c1003;
    --bs-btn-active-color: #1c1003;
}
.btn-secondary,
.btn-light {
    --bs-btn-color: var(--text);
    --bs-btn-bg: var(--surface-elevated);
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-color: var(--text);
    --bs-btn-hover-bg: var(--surface-overlay);
    --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-active-color: var(--text);
    --bs-btn-active-bg: var(--surface-overlay);
    --bs-btn-active-border-color: var(--border-strong);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-accent);
    --bs-btn-border-color: rgba(56,189,248,.45);
    --bs-btn-hover-color: var(--on-accent);
    --bs-btn-hover-bg: var(--brand-accent);
    --bs-btn-hover-border-color: var(--brand-accent);
    --bs-btn-active-color: var(--on-accent);
    --bs-btn-active-bg: var(--brand-accent-strong);
}
.btn-outline-secondary,
.btn-outline-dark,
.btn-outline-light {
    --bs-btn-color: var(--text-secondary);
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-color: var(--text);
    --bs-btn-hover-bg: var(--surface-hover);
    --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-active-color: var(--text);
    --bs-btn-active-bg: var(--surface-overlay);
}
.btn-outline-danger {
    --bs-btn-color: var(--danger-text);
    --bs-btn-border-color: rgba(239,68,68,.4);
    --bs-btn-hover-bg: var(--danger-subtle);
    --bs-btn-hover-color: var(--danger-text);
    --bs-btn-hover-border-color: rgba(239,68,68,.6);
}
.btn-outline-success {
    --bs-btn-color: var(--success-text);
    --bs-btn-border-color: rgba(34,197,94,.4);
    --bs-btn-hover-bg: var(--success-subtle);
    --bs-btn-hover-color: var(--success-text);
    --bs-btn-hover-border-color: rgba(34,197,94,.6);
}
.btn-outline-warning {
    --bs-btn-color: var(--warning-text);
    --bs-btn-border-color: rgba(245,158,11,.4);
    --bs-btn-hover-bg: var(--warning-subtle);
    --bs-btn-hover-color: var(--warning-text);
    --bs-btn-hover-border-color: rgba(245,158,11,.6);
}
.btn-link { --bs-btn-color: var(--brand-accent); --bs-btn-hover-color: var(--brand-accent-hover); }

.btn-ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .65rem;
    font-size: .8rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text-secondary);
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    cursor: pointer;
    font-weight: 500;
}
.btn-action:hover { background: var(--surface-overlay); color: var(--text); border-color: var(--border-strong); }
.btn-action.action-danger { color: var(--danger-text); }
.btn-action.action-danger:hover { background: var(--danger-subtle); border-color: rgba(239,68,68,.4); color: var(--danger-text); }
.btn-action.action-primary { color: var(--info-text); }
.btn-action.action-primary:hover { background: var(--info-subtle); border-color: rgba(56,189,248,.4); color: var(--info-text); }
.btn-action.action-success { color: var(--success-text); }
.btn-action.action-success:hover { background: var(--success-subtle); border-color: rgba(34,197,94,.4); color: var(--success-text); }

/* ── Badges / Pills ── */
.tg-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .6rem;
    font-size: .7rem;
    font-weight: 600;
    border-radius: 999px;
    letter-spacing: .02em;
    border: 1px solid transparent;
    line-height: 1.4;
    white-space: nowrap;
}
.tg-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.tg-badge:has(> .bi)::before { display: none; }
.tg-badge-success { background: var(--success-subtle); color: var(--success-text); border-color: rgba(34,197,94,.22); }
.tg-badge-warning { background: var(--warning-subtle); color: var(--warning-text); border-color: rgba(245,158,11,.22); }
.tg-badge-danger { background: var(--danger-subtle); color: var(--danger-text); border-color: rgba(239,68,68,.22); }
.tg-badge-info { background: var(--info-subtle); color: var(--info-text); border-color: rgba(56,189,248,.22); }
.tg-badge-neutral { background: var(--neutral-subtle); color: var(--text-secondary); border-color: rgba(148,163,184,.18); }
.tg-badge-secondary { background: var(--neutral-subtle); color: var(--text-secondary); border-color: rgba(148,163,184,.18); }

/* ── Forms ── */
.tg-form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 560px;
    box-shadow: var(--shadow-sm);
}
.form-label {
    font-weight: 600;
    font-size: .8rem;
    color: var(--text-secondary);
    margin-bottom: .4rem;
}
.form-control, .form-select {
    background-color: var(--surface-base);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: .875rem;
    padding: .55rem .8rem;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}
.form-control::placeholder { color: var(--text-light); opacity: 1; }
.form-control:hover, .form-select:hover { border-color: rgba(148,163,184,.32); }
.form-control:focus, .form-select:focus {
    background-color: var(--surface-base);
    color: var(--text);
    border-color: var(--brand-accent);
    box-shadow: var(--focus-ring);
}
.form-control:disabled, .form-control[readonly], .form-select:disabled {
    background-color: var(--surface);
    color: var(--text-muted);
}
.form-control-color { padding: .3rem; min-height: 2.5rem; }
.form-check-input {
    background-color: var(--surface-base);
    border-color: rgba(148,163,184,.4);
}
.form-check-input:checked {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
}
.form-check-input:focus { box-shadow: var(--focus-ring); border-color: var(--brand-accent); }
.form-text { font-size: .78rem; color: var(--text-light); }
.input-group-text {
    background: var(--surface-elevated);
    border-color: var(--border-strong);
    color: var(--text-muted);
    font-size: .85rem;
}
.invalid-feedback { color: var(--danger-text); }

/* ── Alerts ── */
.alert {
    border-radius: var(--radius-lg);
    font-size: .855rem;
    border: 1px solid transparent;
    padding: .8rem 1rem;
}
.alert-success { background: var(--success-subtle); color: var(--success-text); border-color: rgba(34,197,94,.25); }
.alert-danger { background: var(--danger-subtle); color: var(--danger-text); border-color: rgba(239,68,68,.25); }
.alert-warning { background: var(--warning-subtle); color: var(--warning-text); border-color: rgba(245,158,11,.25); }
.alert-info,
.alert-primary { background: var(--info-subtle); color: var(--info-text); border-color: rgba(56,189,248,.25); }
.alert-secondary,
.alert-light { background: var(--neutral-subtle); color: var(--text-secondary); border-color: var(--border); }
.alert a { color: inherit; font-weight: 600; }
.alert strong { color: inherit; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--brand-accent);
    background: var(--brand-accent-subtle);
    border: 1px solid rgba(56,189,248,.2);
}
.empty-state .empty-text { font-size: .9rem; margin-bottom: 1.25rem; color: var(--text-muted); }

/* ── Pagination ── */
.pagination { gap: .25rem; flex-wrap: wrap; }
.pagination .page-link {
    border-radius: var(--radius) !important;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: .8rem;
    padding: .35rem .7rem;
    font-variant-numeric: tabular-nums;
}
.pagination .page-link:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.pagination .page-item.active .page-link {
    background: var(--brand-accent-subtle);
    border-color: rgba(56,189,248,.45);
    color: var(--brand-accent);
}
.pagination .page-item.disabled .page-link { background: transparent; color: var(--text-light); }

/* ── Step indicator ── */
.step-indicator {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1.5rem;
}
.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 1.5px solid var(--border-strong);
    color: var(--text-muted);
    background: var(--surface);
}
.step-dot.active {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
    color: var(--on-accent);
    box-shadow: 0 0 0 4px var(--brand-accent-subtle);
}
.step-dot.done {
    background: var(--success);
    border-color: var(--success);
    color: #03140a;
}
.step-line {
    flex: 1;
    height: 2px;
    background: var(--border-strong);
    max-width: 60px;
    border-radius: 2px;
}
.step-line.done { background: var(--success); }
.step-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
}
.step-label.active { color: var(--text); }

/* ── Section label ── */
.section-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-light);
}

/* ── Utility ── */
.text-mono { font-family: var(--font-mono); font-size: .82em; }
.tg-break {
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
}
.gap-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.text-strong { color: var(--text) !important; }
.text-soft { color: var(--text-muted) !important; }
.text-faint { color: var(--text-light) !important; }
.bg-surface { background: var(--surface) !important; }
.bg-surface-elevated { background: var(--surface-elevated) !important; }
.tg-surface-inset {
    background: var(--surface-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ── Print: always light, paper-friendly ── */
@media print {
    :root, [data-bs-theme=dark] {
        --surface-base: #fff;
        --surface: #fff;
        --surface-alt: #fff;
        --surface-elevated: #fff;
        --border: #d4d4d8;
        --border-strong: #a1a1aa;
        --text: #111;
        --text-secondary: #333;
        --text-muted: #555;
        --text-light: #777;
        --bs-body-bg: #fff;
        --bs-body-color: #111;
        color-scheme: light;
    }
    body, .tg-main { background: #fff !important; color: #111 !important; }
    .tg-sidebar, .tg-topbar, .tg-overlay, .tg-impersonation-bar { display: none !important; }
    .tg-main { margin: 0 !important; padding: 0 !important; width: 100% !important; max-width: 100% !important; }
    .tg-card, .stat-card, .tg-table-wrapper { box-shadow: none !important; }
}

/* Neutral stat card (muted figure) */
.stat-card.stat-neutral .stat-value { color: var(--text-muted); }
.stat-card.stat-neutral::after { background: linear-gradient(90deg, rgba(148,163,184,.5), transparent); }

/* Coloured icons used as card/section leads get a soft tile */
.tg-card h6.fw-bold { letter-spacing: -.01em; }

/* ========================================================================
   v2 — Inset shell redesign
   Sidebar sits on a near-black backdrop; each page lives on a raised,
   rounded canvas. Stats rows become one connected KPI panel, page headers
   are compact, and colour is reserved for state.
   ======================================================================== */
:root {
    --shell: #03070e;
    --canvas: #070e1b;
    --surface: #0b1424;
    --surface-alt: #070e1b;
}
body { background: var(--shell); }

/* Sidebar */
.tg-sidebar {
    background: var(--shell);
    border-right: none;
    padding: .25rem 0;
}
.tg-sidebar-brand {
    margin: .5rem .625rem .75rem;
    padding: .55rem .6rem;
    border-radius: var(--radius-lg);
    gap: .65rem;
    transition: background var(--transition);
}
.tg-sidebar-brand:hover { background: rgba(148,163,184,.06); }
.tg-sidebar-brand .brand-text-wrap { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.tg-sidebar-brand .brand-name { font-size: .9rem; font-weight: 700; color: var(--text); letter-spacing: -.015em; }
.tg-sidebar-brand .brand-context {
    font-size: .72rem; font-weight: 500; color: var(--text-light);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tg-sidebar-section {
    padding: 1rem .75rem .35rem;
    font-size: .68rem;
    letter-spacing: .02em;
    text-transform: none;
    font-weight: 600;
    color: var(--text-light);
}
.tg-sidebar-divider { display: none; }
.tg-sidebar-nav a {
    padding: .42rem .7rem;
    font-size: .845rem;
    color: #8ea3bd;
    gap: .65rem;
}
.tg-sidebar-nav a:hover { background: rgba(148,163,184,.06); color: var(--text); }
.tg-sidebar-nav a.active {
    background: rgba(148,163,184,.09);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(148,163,184,.08);
}
.tg-sidebar-nav a.active::before { display: none; }
.tg-sidebar-nav a .nav-icon { font-size: .95rem; opacity: .85; }
.tg-sidebar-nav a.active .nav-icon { color: var(--brand-accent); }
.tg-sidebar-footer { border-top: none; padding: .75rem .625rem 1rem; }
.tg-sidebar-footer .user-info {
    margin: 0;
    padding: .55rem .6rem;
    border-radius: var(--radius-lg);
    background: rgba(148,163,184,.05);
    border: 1px solid var(--border);
}
.tg-sidebar-footer .user-meta { min-width: 0; flex: 1; }
.tg-sidebar-footer .user-signout { margin: 0; }
.tg-sidebar-footer .user-signout button {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    border: none; background: transparent;
    color: var(--text-light);
    transition: background var(--transition), color var(--transition);
}
.tg-sidebar-footer .user-signout button:hover { background: rgba(148,163,184,.1); color: var(--text); }

/* Main + canvas */
.tg-main {
    background: var(--shell);
    padding: .5rem .5rem .5rem 0;
}
.tg-canvas {
    position: relative;
    min-height: calc(100vh - 1rem);
    background:
        radial-gradient(900px 320px at 85% -120px, rgba(56,189,248,.07), transparent 70%),
        var(--canvas);
    border: 1px solid rgba(148,163,184,.1);
    border-radius: 16px;
    padding: 1.75rem 2.25rem 3rem;
    box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 20px 50px -20px rgba(0,0,0,.6);
}
.tg-canvas-inner > .alert:first-child,
.tg-canvas-inner > .tg-impersonation-bar:first-child { margin-top: 0; }
@media (max-width: 991.98px) {
    .tg-main { padding: calc(var(--topbar-height) + .25rem) .375rem .375rem; }
    .tg-canvas { padding: 1.25rem 1rem 2rem; border-radius: 14px; min-height: calc(100vh - var(--topbar-height) - .75rem); }
    .tg-topbar { background: rgba(3,7,14,.85); border-bottom-color: transparent; }
}

/* Page header: compact title, divider, no decorative leading icon */
.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.page-header h1 {
    font-size: 1.45rem;
    font-weight: 650;
    letter-spacing: -.025em;
}
.page-header h1 > i.bi:first-child { display: none; }
.page-header .page-subtitle { font-size: .85rem; margin-top: .3rem; margin-bottom: 0; }
.tg-breadcrumb { margin-bottom: .6rem; font-size: .78rem; }
.tg-breadcrumb + .page-header,
.page-header-row { align-items: flex-end; }

/* Actions: one primary, the rest neutral */
.page-actions .btn-success,
.page-actions .btn-outline-primary,
.page-actions .btn-outline-secondary,
.page-actions .btn-info,
.page-header .btn-success,
.page-header .btn-outline-primary,
.page-header .btn-info {
    --bs-btn-color: var(--text);
    --bs-btn-bg: var(--surface-elevated);
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--surface-overlay);
    --bs-btn-hover-border-color: rgba(148,163,184,.32);
    --bs-btn-active-bg: var(--surface-overlay);
    --bs-btn-active-color: #fff;
    box-shadow: none;
}
.btn { --bs-btn-padding-y: .42rem; --bs-btn-padding-x: .85rem; }
.btn-sm { --bs-btn-padding-y: .3rem; --bs-btn-padding-x: .65rem; font-size: .8rem; }
.btn-primary { box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 4px 14px -6px rgba(56,189,248,.65); }
.btn .bi { opacity: .9; }

/* KPI panel: any row of stat cards becomes one connected strip */
.row:has(> [class*="col"] > .stat-card) {
    --bs-gutter-x: 0;
    --bs-gutter-y: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-left: 0;
    margin-right: 0;
    box-shadow: var(--shadow-sm);
}
.row:has(> [class*="col"] > .stat-card) > [class*="col"] {
    box-shadow: 1px 0 0 var(--border), 0 1px 0 var(--border);
}
.row:has(> [class*="col"] > .stat-card) .stat-card {
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    height: 100%;
    padding: 1.1rem 1.25rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.row:has(> [class*="col"] > .stat-card) .stat-card:hover { background: rgba(148,163,184,.03); }
.stat-card .stat-label {
    order: -1;
    margin-top: 0;
    text-transform: none;
    letter-spacing: 0;
    font-size: .78rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: .45rem;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 650; letter-spacing: -.035em; }
.stat-card::after { display: none; }
.stat-card .stat-label::before {
    content: '';
    width: 7px; height: 7px; border-radius: 2px;
    background: rgba(148,163,184,.45);
    flex-shrink: 0;
}
.stat-card.stat-primary .stat-label::before,
.stat-card.stat-info .stat-label::before { background: var(--brand-accent); }
.stat-card.stat-success .stat-label::before { background: var(--success); }
.stat-card.stat-warning .stat-label::before { background: var(--warning); }
.stat-card.stat-danger .stat-label::before { background: var(--danger); }
.stat-card.stat-primary .stat-value { color: var(--text); }

/* Cards */
.tg-card { background: var(--surface); }
.tg-card .card-header {
    padding: .9rem 1.25rem;
    font-size: .875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 3.25rem;
}
.tg-card .card-header .bi,
.tg-card h6 .bi,
.tg-card .card-body > div > .d-flex > i.bi:first-child { color: var(--text-light) !important; }
.tg-card .card-header .btn { margin-left: auto; }

/* Quick-action cards: icon tile */
.tg-card .card-body > div > .d-flex.align-items-center.gap-2 > i.bi:first-child {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    font-size: 1.05rem !important;
    color: var(--brand-accent) !important;
}

/* Tables: list-like */
.tg-table thead th {
    background: transparent;
    font-size: .72rem;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    color: var(--text-light);
    padding: .7rem 1rem;
}
.tg-table tbody td { padding: .85rem 1rem; }
.tg-table tbody td:first-child,
.tg-table thead th:first-child { padding-left: 1.25rem; }
.tg-table tbody td:last-child,
.tg-table thead th:last-child { padding-right: 1.25rem; }
.tg-table tbody td .bi { color: var(--text-light); }
.tg-table .btn-action {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
    width: 32px; height: 32px;
    justify-content: center;
    padding: 0;
}
.tg-table .btn-action:hover { background: rgba(148,163,184,.1); border-color: transparent; color: var(--text); }
.tg-table tbody tr:hover .btn-action { color: var(--text-secondary); }

/* Filter bars */
form .form-control, form .form-select { min-height: 36px; }

/* Forms inside canvas */
.tg-form-card { background: var(--surface); }

/* Section label */
.section-label { text-transform: none; letter-spacing: 0; font-size: .78rem; font-weight: 600; color: var(--text-muted); }

/* Figures stay neutral; colour lives in the marker only */
.stat-card .stat-value,
.stat-card.stat-success .stat-value,
.stat-card.stat-warning .stat-value,
.stat-card.stat-info .stat-value,
.stat-card.stat-danger .stat-value,
.stat-card.stat-neutral .stat-value { color: var(--text); }

/* Tables nested in cards: no double frame */
.tg-card .tg-table-wrapper,
.tg-card > .table-responsive,
.tg-card .card-body.p-0 .tg-table-wrapper {
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

/* ── v2 components ── */
.tg-eyebrow {
    font-size: .75rem;
    font-weight: 600;
    color: var(--brand-accent);
    margin-bottom: .35rem;
    letter-spacing: .01em;
}
.tg-card-meta { font-size: .78rem; font-weight: 500; color: var(--text-light); }
.tg-link-sm {
    font-size: .78rem; font-weight: 600; color: var(--text-muted); text-decoration: none;
    display: inline-flex; align-items: center; gap: .3rem;
}
.tg-link-sm:hover { color: var(--brand-accent); }
.tg-link-sm .bi { color: inherit !important; font-size: .8rem; }

/* Shortcut tiles */
.tg-shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: .75rem;
}
.tg-shortcut {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: .875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text);
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.tg-shortcut:hover { border-color: rgba(56,189,248,.35); background: #0d182b; color: var(--text); }
.tg-shortcut:hover .tg-shortcut-arrow { transform: translateX(3px); color: var(--brand-accent); }
.tg-shortcut-icon {
    width: 40px; height: 40px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 11px;
    background: linear-gradient(160deg, rgba(56,189,248,.18), rgba(56,189,248,.04));
    border: 1px solid rgba(56,189,248,.22);
    color: var(--brand-accent);
    font-size: 1.1rem;
}
.tg-shortcut-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tg-shortcut-title { font-weight: 600; font-size: .875rem; }
.tg-shortcut-sub { font-size: .78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-shortcut-arrow { color: var(--text-light); transition: transform var(--transition), color var(--transition); }

/* List rows */
.tg-list { display: flex; flex-direction: column; }
.tg-list-row {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .8rem 1.25rem;
    text-decoration: none;
    color: var(--text);
    border-top: 1px solid var(--border);
    transition: background var(--transition);
}
.tg-list > .tg-list-row:first-child { border-top: none; }
.tg-list-row:hover { background: rgba(148,163,184,.04); color: var(--text); }
.tg-list-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tg-list-title { font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-list-sub { font-size: .78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-list-progress { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; width: 96px; flex-shrink: 0; }
.tg-list-progress .tg-progress { width: 100%; height: 4px; }
.tg-list-progress-figures { font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tg-list-count { font-size: .8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tg-list-count .bi { color: var(--text-light); margin-right: .2rem; }
.tg-list-chevron { color: var(--text-light); font-size: .8rem; }
@media (max-width: 575.98px) { .tg-list-progress { display: none; } }

/* Date block */
.tg-date-block {
    width: 44px; height: 46px; flex-shrink: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 10px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    line-height: 1;
}
.tg-date-month { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.tg-date-day { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-top: .2rem; font-variant-numeric: tabular-nums; }
.tg-date-block-accent { background: var(--brand-accent-subtle); border-color: rgba(56,189,248,.28); }
.tg-date-block-accent .tg-date-month { color: var(--brand-accent); }

/* Progress variants */
.tg-progress > span.is-success { background: linear-gradient(90deg, #16a34a, var(--success)); }
.tg-progress > span.is-warning { background: linear-gradient(90deg, #d97706, var(--warning)); }
.tg-progress-lg { height: 8px; }

/* Live card */
.tg-card-live {
    background:
        radial-gradient(400px 160px at 100% 0%, rgba(34,197,94,.10), transparent 70%),
        var(--surface);
    border-color: rgba(34,197,94,.22);
}
.tg-live-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(34,197,94,.6);
    animation: tg-pulse 2s infinite;
}
@keyframes tg-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55); }
    70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
@media (prefers-reduced-motion: reduce) { .tg-live-dot { animation: none; } }
.tg-today-figure { display: flex; align-items: baseline; gap: .5rem; }
.tg-today-value { font-size: 2.5rem; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1; }
.tg-today-label { color: var(--text-muted); font-size: .85rem; }
.tg-mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.tg-mini-stats > div {
    display: flex; flex-direction: column;
    font-size: .72rem; color: var(--text-muted);
    padding: .6rem .7rem; border-radius: var(--radius);
    background: rgba(6,12,24,.5); border: 1px solid var(--border);
}
.tg-mini-stats > div > span { font-size: 1rem; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }

/* Header buttons stay compact */
.page-actions .btn { white-space: nowrap; }

/* Progress inside connected stat cards */
.stat-card .tg-progress { height: 4px; }

/* ── Event hero ── */
.tg-event-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(148,163,184,.14);
    overflow: hidden;
    background:
        radial-gradient(700px 260px at 0% 0%, color-mix(in srgb, var(--poster-b) 55%, transparent), transparent 70%),
        linear-gradient(120deg, color-mix(in srgb, var(--poster-a) 70%, var(--surface)) 0%, var(--surface) 65%);
}
.tg-event-hero::after {
    content: '';
    position: absolute; inset: 0;
    background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px);
    background-size: 18px 18px;
    mask-image: linear-gradient(90deg, rgba(0,0,0,.8), transparent 60%);
    pointer-events: none;
}
.tg-event-hero > * { position: relative; z-index: 1; }
.tg-event-hero-main { display: flex; align-items: center; gap: 1.25rem; min-width: 0; }
.tg-event-poster {
    width: 96px; height: 112px; flex-shrink: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 16px;
    background: linear-gradient(160deg, var(--poster-b), var(--poster-a));
    border: 1px solid rgba(255,255,255,.14);
    box-shadow: 0 18px 40px -16px color-mix(in srgb, var(--poster-b) 80%, transparent), inset 0 1px 0 rgba(255,255,255,.2);
    color: #fff;
    line-height: 1;
}
.tg-event-poster-month { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .8; }
.tg-event-poster-day { font-size: 2.4rem; font-weight: 800; letter-spacing: -.04em; margin: .2rem 0 .3rem; }
.tg-event-poster-time { font-size: .72rem; font-weight: 600; opacity: .75; font-variant-numeric: tabular-nums; }
.tg-event-hero-text { min-width: 0; }
.tg-event-hero-promoter { font-size: .78rem; font-weight: 600; color: var(--text-muted); }
.tg-event-hero-title {
    font-size: 2rem;
    font-weight: 750;
    letter-spacing: -.035em;
    line-height: 1.1;
    margin: .1rem 0 .55rem;
    color: #fff;
    overflow-wrap: anywhere;
}
.tg-event-hero-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: .85rem; color: var(--text-secondary); }
.tg-event-hero-meta .bi { margin-right: .4rem; color: var(--text-light); }

.tg-event-ring { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.tg-event-ring svg { transform: rotate(-90deg); }
.tg-ring-track { fill: none; stroke: rgba(148,163,184,.14); stroke-width: 9; }
.tg-ring-fill {
    fill: none; stroke: var(--success); stroke-width: 9; stroke-linecap: round;
    filter: drop-shadow(0 0 6px rgba(34,197,94,.45));
    transition: stroke-dashoffset 600ms cubic-bezier(.2,0,0,1);
}
.tg-event-ring-label {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    line-height: 1.1;
}
.tg-event-ring-value { font-size: 1.6rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tg-event-ring-sub { font-size: .72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-top: .15rem; }

@media (max-width: 767.98px) {
    .tg-event-hero { flex-direction: column; align-items: flex-start; }
    .tg-event-hero-main { align-items: flex-start; }
    .tg-event-poster { width: 72px; height: 84px; border-radius: 12px; }
    .tg-event-poster-day { font-size: 1.8rem; }
    .tg-event-hero-title { font-size: 1.5rem; }
    .tg-event-ring { align-self: center; }
}

/* Toolbar */
.tg-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}
.tg-toolbar-spacer { flex: 1; }

/* Live grid */
.tg-live-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 767.98px) { .tg-live-grid { grid-template-columns: repeat(2, 1fr); } }
.tg-live-value { font-size: 2rem; font-weight: 700; letter-spacing: -.035em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tg-live-label { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }
.tg-live-pace {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem;
    margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--border);
    font-size: .85rem;
}

/* Bootstrap table-sm inside cards (performance lists) */
.tg-card .table { --bs-table-bg: transparent; margin-bottom: 0; }
.tg-card .table td { border-color: var(--border); padding: .6rem 0; font-size: .855rem; }
.tg-card .table tr:last-child td { border-bottom: none; }
.tg-card h6.fw-bold { font-size: .875rem; font-weight: 600 !important; }
.tg-card h6.fw-bold > .bi:first-child { display: none; }

/* Progress tracks set inline to the canvas colour need to stay visible */
.progress { background: rgba(148,163,184,.12) !important; border-radius: 999px !important; }
.progress-bar { border-radius: 999px; }

.btn-action { white-space: nowrap; }
.btn-action.btn-action-primary { color: var(--info-text); }
.btn-action.btn-action-primary:hover { background: var(--info-subtle); border-color: rgba(56,189,248,.4); color: var(--info-text); }
/* Filter bars: controls and buttons share one height */
form.d-flex .btn, form .row .btn, .tg-filter .btn { min-height: 36px; display: inline-flex; align-items: center; }

/* Text buttons inside tables (empty states etc.) keep normal sizing */
.tg-table .empty-state .btn-action,
.tg-table td[colspan] .btn-action {
    width: auto; height: auto;
    padding: .45rem .9rem;
    background: var(--brand-accent-subtle);
    border: 1px solid rgba(56,189,248,.3);
    color: var(--info-text);
}
.tg-table td[colspan] .btn-action:hover { background: rgba(56,189,248,.2); color: #fff; }
.tg-table td[colspan] { white-space: normal; }

/* Empty state variant: <i> + <h5> + <p> + button */
.empty-state > i.bi:first-child {
    width: 56px; height: 56px;
    margin: 0 auto 1rem;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    color: var(--brand-accent) !important;
    background: var(--brand-accent-subtle);
    border: 1px solid rgba(56,189,248,.2);
}
.empty-state h5 { font-size: 1rem; font-weight: 650; margin-bottom: .35rem; }
.empty-state p { font-size: .85rem; color: var(--text-muted); margin-bottom: 1.1rem; }

/* Plain Bootstrap tables used in a few views */
.table > thead th {
    font-size: .72rem; font-weight: 500; color: var(--text-light);
    border-bottom-color: var(--border); background: transparent;
}
.table > :not(caption) > * > * { border-bottom-color: var(--border); }

/* ── Auth (split layout) ── */
.tg-auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    background: var(--shell);
}
.tg-auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    padding: 2.5rem 3.5rem;
    margin: .5rem;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(148,163,184,.1);
    background:
        radial-gradient(600px 380px at 15% 10%, rgba(56,189,248,.20), transparent 65%),
        radial-gradient(500px 400px at 90% 100%, rgba(56,189,248,.08), transparent 65%),
        #07101f;
}
.tg-auth-brand::after {
    content: '';
    position: absolute; inset: 0;
    background-image: linear-gradient(rgba(148,163,184,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(148,163,184,.06) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse at 30% 30%, #000 0%, transparent 70%);
    pointer-events: none;
}
.tg-auth-brand > * { position: relative; z-index: 1; }
.tg-auth-logo {
    display: inline-flex; align-items: center; gap: .65rem;
    font-weight: 700; font-size: 1rem; color: var(--text); text-decoration: none; letter-spacing: -.015em;
}
.tg-auth-logo:hover { color: #fff; }
.tg-auth-logo .brand-icon {
    width: 34px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: #38bdf8;
    box-shadow: 0 6px 18px -6px rgba(56,189,248,.7), inset 0 1px 0 rgba(255,255,255,.25);
}
.tg-auth-pitch { margin-top: auto; }
.tg-auth-pitch h2 { font-size: 2.6rem; font-weight: 750; letter-spacing: -.04em; line-height: 1.05; color: #fff; margin-bottom: 1rem; }
.tg-auth-pitch p { font-size: 1rem; color: var(--text-secondary); max-width: 26rem; margin: 0; }
.tg-auth-preview {
    max-width: 420px;
    padding: 1.1rem 1.2rem;
    border-radius: 16px;
    background: rgba(11,20,36,.75);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(148,163,184,.16);
    box-shadow: 0 30px 60px -30px rgba(0,0,0,.8);
}
.tg-auth-preview-head { display: flex; align-items: center; gap: .5rem; font-size: .78rem; font-weight: 600; color: var(--text-muted); margin-bottom: .6rem; }
.tg-auth-preview-figure { display: flex; align-items: baseline; gap: .4rem; margin-bottom: .7rem; }
.tg-auth-preview-figure span { font-size: 2rem; font-weight: 750; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.tg-auth-preview-figure small { color: var(--text-muted); font-size: .85rem; }
.tg-auth-preview-rows { display: flex; flex-direction: column; margin-top: .9rem; }
.tg-auth-preview-rows > div {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem;
    padding: .5rem 0; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-secondary);
}
.tg-auth-foot { font-size: .78rem; color: var(--text-light); margin: 0; }

.tg-auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.tg-auth-form { width: 100%; max-width: 380px; }
.tg-auth-form h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; margin-bottom: .35rem; }
.tg-auth-sub { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.75rem; }
.tg-auth-form .form-control-lg, .tg-auth-form .input-group-lg > .form-control { font-size: .95rem; padding: .7rem .9rem; border-radius: 10px; }
.tg-password-group > .form-control { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.tg-password-group > .btn {
    background: var(--surface-base); border: 1px solid var(--border-strong); border-left: 0;
    color: var(--text-muted); font-size: .82rem; border-radius: 0 10px 10px 0; padding: 0 1rem;
}
.tg-password-group > .btn:hover { color: var(--text); }
.tg-auth-submit { padding: .75rem 1rem; font-size: .95rem; font-weight: 650; border-radius: 10px; }
.tg-auth-switch { margin-top: 1.5rem; text-align: center; font-size: .875rem; color: var(--text-muted); }
.tg-auth-switch a { font-weight: 600; text-decoration: none; }
.tg-auth-logo-mobile { display: none; margin-bottom: 2rem; }
@media (max-width: 991.98px) {
    .tg-auth { grid-template-columns: 1fr; }
    .tg-auth-brand { display: none; }
    .tg-auth-logo-mobile { display: inline-flex; }
}
