/* ============================================================
   GRAVIOR — Professional Application Stylesheet
   Theme: "Oxford Gravity" — premium, regulator-grade
   Color System:
     Sidebar:    #0E1B33 (oxford navy)
     Primary:    #1F3F8F (royal cobalt)
     Gold accent #C4A35A (antique gold — gravitas)
     Success:    #2DA37A (verdigris)
     Warning:    #D88C2B (burnt amber)
     Danger:     #B83245 (signal crimson)
     Info:       #2563B0 (cobalt-info)
     Page BG:    #F7F4ED (warm pearl)
     Text:       #1A2238 (graphite)
     Muted:      #5D6B85 (slate)
   ============================================================ */

/* ── Google Font ────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ──────────────────────────────────── */
:root {
    --sidebar-width: 224px;
    --sidebar-collapsed-width: 72px;
    --sidebar-bg: #0E1B33;
    --sidebar-hover: #16294D;
    --sidebar-active: #1F3F8F;
    --sidebar-text: #A8B4D0;
    --sidebar-text-bright: #F7F4ED;
    --sidebar-section: #6F7CA0;
    --primary: #1F3F8F;
    --primary-dark: #16306B;
    --primary-light: #E8EDF8;
    --accent: #C4A35A;
    --accent-dark: #A8853F;
    --accent-light: #F2EAD6;
    --gold: #C4A35A;
    --gold-soft: #E2CB94;
    --gold-deep: #8C6E33;
    --success: #2DA37A;
    --success-light: #DDF2EA;
    --warning: #D88C2B;
    --warning-light: #FBEFD9;
    --danger: #B83245;
    --danger-light: #F7DCDF;
    --info: #2563B0;
    --info-light: #DDE8F6;
    --bg-main: #F7F4ED;
    --bg-card: #ffffff;
    --text-main: #1A2238;
    --text-muted: #5D6B85;
    --border: #E2DDD0;
    --shadow-sm: 0 2px 8px rgba(14,27,51,.07);
    --shadow-md: 0 6px 24px rgba(14,27,51,.10);
    --shadow-lg: 0 14px 40px rgba(14,27,51,.14);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all .22s cubic-bezier(.4,0,.2,1);
    --navbar-height: 58px;
    --page-pad-x: 22px;
    --page-pad-y: 18px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --gradient-brand: linear-gradient(135deg, #1F3F8F 0%, #0E1B33 100%);
    --gradient-gold: linear-gradient(135deg, #E2CB94 0%, #C4A35A 100%);
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ── Layout Shell ───────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: var(--transition);
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
}

/* Sidebar brand area */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: var(--navbar-height);
    background: rgba(0,0,0,.15);
    border-bottom: 1px solid rgba(255,255,255,.05);
    flex-shrink: 0;
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(92,107,192,.5);
}

.sidebar-brand-text {
    font-size: .9rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    letter-spacing: .02em;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand-text span {
    display: block;
    font-size: .68rem;
    font-weight: 400;
    color: var(--sidebar-text);
    letter-spacing: .06em;
    text-transform: uppercase;
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 12px 4px;
    padding: 8px 10px;
    min-height: 38px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    background: rgba(255,255,255,.06);
    color: var(--sidebar-text);
}

.sidebar-search i {
    width: 18px;
    text-align: center;
    color: var(--sidebar-section);
    flex-shrink: 0;
}

.sidebar-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--sidebar-text-bright);
    font: 600 .78rem/1.2 var(--font);
}

.sidebar-search input::placeholder {
    color: color-mix(in srgb, var(--sidebar-text), transparent 12%);
}

/* Sidebar scroll area */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}

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

/* Section headers */
.sidebar-section-title {
    padding: 14px 14px 4px;
    font-size: .68rem;
    font-weight: 600;
    color: var(--sidebar-section);
    text-transform: uppercase;
    letter-spacing: .1em;
    white-space: nowrap;
    overflow: hidden;
}

/* Nav items */
.sidebar-nav-item {
    margin: 2px 8px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: .83rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-bright);
    text-decoration: none;
}

.sidebar-nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 2px 10px rgba(92,107,192,.4);
}

.sidebar-nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: #fff;
    border-radius: 0 4px 4px 0;
}

.sidebar-nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-nav-link .nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav-link .nav-badge {
    background: var(--danger);
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 100px;
    line-height: 1;
    flex-shrink: 0;
}
/* Phase D-3: amber pending-notice badge for the regulatory inbox link */
.sidebar-nav-link .nav-badge.nav-badge-warn { background: #C8881C; }

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-user:hover { background: var(--sidebar-hover); }

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
    flex: 1;
}

.sidebar-user-name {
    font-size: .8rem;
    font-weight: 600;
    color: var(--sidebar-text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.sidebar-user-role {
    font-size: .68rem;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Main Content Wrapper ───────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    min-width: 0;
}

/* ── Top Navbar ─────────────────────────────────────────────── */
.topnav {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--navbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--page-pad-x);
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.topnav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.topnav-toggle:hover { background: var(--bg-main); color: var(--primary); }

.topnav-breadcrumb {
    flex: 1;
    min-width: 0;
}

.breadcrumb {
    margin: 0;
    padding: 0;
    background: transparent;
    font-size: .8rem;
}

.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

.breadcrumb-item a { color: var(--text-muted); font-weight: 500; }
.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.active { color: var(--text-main); font-weight: 600; }

.topnav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Notification bell */
.topnav-bell {
    position: relative;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.topnav-bell:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.topnav-bell .bell-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-card);
    line-height: 1;
}

/* User dropdown */
.topnav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px 5px 8px;
    border: 1px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
}

.topnav-user:hover {
    background: var(--bg-main);
    border-color: var(--primary);
}

.topnav-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topnav-user-name {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-main);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
    min-width: 200px;
    animation: dropIn .18s ease;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.dropdown-item i { width: 16px; text-align: center; }

.dropdown-divider { border-color: var(--border); margin: 4px 0; }

.dropdown-header {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 6px 12px 2px;
}

/* ── Page Content ───────────────────────────────────────────── */
.page-content {
    flex: 1;
    padding: var(--page-pad-y) var(--page-pad-x);
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    margin: 0;
}

.page-subtitle {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 400;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: transparent;
    gap: 12px;
}

.card-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--primary); font-size: 1rem; }

.card-body { padding: 18px 20px; }

.card-footer {
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    background: transparent;
}

/* Accented cards (left border) */
.card-accent-primary { border-left: 4px solid var(--primary); }
.card-accent-success  { border-left: 4px solid var(--success); }
.card-accent-warning  { border-left: 4px solid var(--warning); }
.card-accent-danger   { border-left: 4px solid var(--danger); }
.card-accent-info     { border-left: 4px solid var(--info); }
.card-accent-accent   { border-left: 4px solid var(--accent); }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: .07;
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-card-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon-blue   { background: #e3f2fd; color: #1565c0; }
.stat-icon-green  { background: #e8f5e9; color: #2e7d32; }
.stat-icon-purple { background: #ede7f6; color: #4527a0; }
.stat-icon-orange { background: #fff3e0; color: #e65100; }
.stat-icon-teal   { background: #e0f7fa; color: #00695c; }
.stat-icon-red    { background: #ffebee; color: #b71c1c; }

.stat-card-body { flex: 1; min-width: 0; }

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-main);
    margin-bottom: 4px;
}

.stat-card-label {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-card-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    font-weight: 600;
    margin-top: 8px;
}

.trend-up   { color: var(--success); }
.trend-down { color: var(--danger); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    font-family: var(--font);
    font-weight: 500;
    font-size: .82rem;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
    cursor: pointer;
    white-space: nowrap;
}

.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-lg { padding: 11px 22px; font-size: .9rem; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(92,107,192,.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 16px rgba(92,107,192,.4);
    transform: translateY(-1px);
    color: #fff;
}

.btn-outline-primary {
    border: 1.5px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.btn-success  { background: var(--success);  border-color: var(--success);  color: #fff; }
.btn-success:hover  { background: #388e3c; border-color: #388e3c; color: #fff; transform: translateY(-1px); }

.btn-danger   { background: var(--danger);   border-color: var(--danger);   color: #fff; }
.btn-danger:hover   { background: #c62828; border-color: #c62828; color: #fff; transform: translateY(-1px); }

.btn-warning  { background: var(--warning);  border-color: var(--warning);  color: #fff; }
.btn-warning:hover  { background: #e65100; border-color: #e65100; color: #fff; transform: translateY(-1px); }

.btn-info     { background: var(--info);     border-color: var(--info);     color: #fff; }
.btn-info:hover     { background: #0277bd; border-color: #0277bd; color: #fff; transform: translateY(-1px); }

.btn-outline-secondary {
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    background: transparent;
}

.btn-outline-secondary:hover { background: var(--bg-main); color: var(--text-main); }

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: .9rem;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .83rem;
    margin: 0;
}

.table thead th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 11px 16px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.table tbody tr:last-child { border-bottom: none; }

.table tbody tr:hover { background: #f8fafc; }

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    color: var(--text-main);
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    font-family: var(--font);
    font-weight: 600;
    font-size: .7rem;
    padding: 4px 10px;
    border-radius: 100px;
    letter-spacing: .03em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    line-height: 1.4;
}

.badge-success  { background: var(--success-light);  color: #1b5e20; }
.badge-warning  { background: var(--warning-light);  color: #e65100; }
.badge-danger   { background: var(--danger-light);   color: #b71c1c; }
.badge-info     { background: var(--info-light);     color: #01579b; }
.badge-primary  { background: var(--primary-light);  color: var(--primary-dark); }
.badge-secondary{ background: #f1f5f9;               color: var(--text-muted); }
.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
    flex-shrink: 0;
}

/* Status-specific badges */
.status-active   { background: var(--success-light); color: #1b5e20; }
.status-inactive { background: #f1f5f9;              color: var(--text-muted); }
.status-pending  { background: var(--warning-light); color: #e65100; }
.status-approved { background: var(--success-light); color: #1b5e20; }
.status-rejected { background: var(--danger-light);  color: #b71c1c; }

/* Severity badges */
.severity-info     { background: var(--info-light);    color: #01579b; }
.severity-warning  { background: var(--warning-light); color: #e65100; }
.severity-error    { background: var(--danger-light);  color: #b71c1c; }
.severity-critical { background: #f3e5f5;              color: #4a148c; }
.severity-debug    { background: #f1f5f9;              color: var(--text-muted); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
    display: block;
}

.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control, .form-select {
    font-family: var(--font);
    font-size: .83rem;
    color: var(--text-main);
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    transition: var(--transition);
    width: 100%;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(92,107,192,.12);
    outline: none;
    background: var(--bg-card);
}

.form-control::placeholder { color: #b0bec5; }

.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--danger);
}

.form-control.is-invalid:focus, .form-select.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(229,57,53,.12);
}

.invalid-feedback {
    font-size: .75rem;
    color: var(--danger);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-group {
    position: relative;
}

.input-group-text {
    background: #f8fafc;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    font-size: .85rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

.input-group .form-control { border-radius: 0; }
.input-group > :first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group > :last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.form-check-input {
    width: 1em;
    height: 1em;
    border: 1.5px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    transition: var(--transition);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-label {
    font-size: .82rem;
    color: var(--text-main);
    cursor: pointer;
}

/* ── Validation summary ─────────────────────────────────────── */
.validation-summary-errors {
    background: var(--danger-light);
    border: 1px solid #ef9a9a;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 18px;
}

.validation-summary-errors li {
    font-size: .8rem;
    color: #b71c1c;
    padding: 2px 0;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: .83rem;
    border: none;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success  { background: var(--success-light);  color: #1b5e20; }
.alert-warning  { background: var(--warning-light);  color: #e65100; }
.alert-danger   { background: var(--danger-light);   color: #b71c1c; }
.alert-info     { background: var(--info-light);     color: #01579b; }

.alert i { margin-top: 1px; flex-shrink: 0; font-size: .95rem; }

/* ── Toast notifications ────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 14px 18px 14px 14px;
    min-width: 300px;
    max-width: 420px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideInRight .3s cubic-bezier(.4,0,.2,1);
    pointer-events: all;
    position: relative;
    overflow: hidden;
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.toast-success::before { background: var(--success); }
.toast-error::before   { background: var(--danger); }
.toast-warning::before { background: var(--warning); }
.toast-info::before    { background: var(--info); }

.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.toast-success .toast-icon { background: var(--success-light); color: var(--success); }
.toast-error   .toast-icon { background: var(--danger-light);  color: var(--danger); }
.toast-warning .toast-icon { background: var(--warning-light); color: var(--warning); }
.toast-info    .toast-icon { background: var(--info-light);    color: var(--info); }

.toast-body { flex: 1; min-width: 0; }

.toast-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.toast-msg {
    font-size: .78rem;
    color: var(--text-muted);
    line-height: 1.4;
    word-break: break-word;
}

.toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: .9rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: var(--transition);
    line-height: 1;
}

.toast-close:hover { color: var(--text-main); background: var(--bg-main); }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); max-height: 120px; }
    to   { opacity: 0; transform: translateX(24px); max-height: 0; padding: 0; margin: 0; }
}

.toast.hiding { animation: slideOutRight .25s ease forwards; }

/* ── Permission Matrix ──────────────────────────────────────── */
.permission-matrix {
    width: 100%;
    font-size: .82rem;
}

.permission-module-header {
    background: #f0f4ff;
    border-left: 3px solid var(--primary);
    padding: 10px 16px;
    font-weight: 700;
    color: var(--primary-dark);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.permission-screen-row {
    display: flex;
    align-items: center;
    padding: 8px 16px 8px 24px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.permission-screen-row:hover { background: #fafbff; }

.permission-screen-name {
    flex: 1;
    min-width: 120px;
    font-weight: 500;
    color: var(--text-main);
}

.permission-flags {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.perm-check {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.perm-check-label {
    font-size: .68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: .04em;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
    gap: 4px;
}

.page-link {
    border-radius: var(--radius-sm) !important;
    border: 1.5px solid var(--border);
    color: var(--text-main);
    font-size: .8rem;
    font-weight: 500;
    padding: 6px 12px;
    transition: var(--transition);
    font-family: var(--font);
}

.page-link:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(92,107,192,.3);
}

.page-item.disabled .page-link { opacity: .5; cursor: not-allowed; }

/* ── Filter Bar ─────────────────────────────────────────────── */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
    flex: 1;
}

.filter-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--border);
    margin-bottom: 16px;
    display: block;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.empty-state-text {
    font-size: .83rem;
    color: var(--text-muted);
    max-width: 360px;
    margin: 0 auto 20px;
}

/* ── Department tree ────────────────────────────────────────── */
.dept-tree-row td:first-child { position: relative; }

.dept-indent { display: inline-block; width: 0; }
.dept-level-1 .dept-indent { width: 0; }
.dept-level-2 .dept-indent { width: 20px; }
.dept-level-3 .dept-indent { width: 40px; }
.dept-level-4 .dept-indent { width: 60px; }

.dept-tree-connector {
    display: inline-flex;
    align-items: center;
    color: var(--border);
    font-size: .75rem;
    margin-right: 4px;
}

/* ── Stack trace ────────────────────────────────────────────── */
.stack-trace {
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: .75rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}

.stack-trace::-webkit-scrollbar { width: 6px; height: 6px; }
.stack-trace::-webkit-scrollbar-thumb { background: #45475a; border-radius: 4px; }

/* ── Login page ─────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    background: var(--sidebar-bg);
}

.login-brand-panel {
    flex: 1;
    background: linear-gradient(135deg, #1a2035 0%, #2d3561 50%, #1a2035 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
    overflow: hidden;
}

.login-brand-panel::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(92,107,192,.12);
    top: -100px;
    right: -100px;
}

.login-brand-panel::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(38,198,218,.08);
    bottom: -80px;
    left: -80px;
}

.login-shield {
    position: relative;
    z-index: 1;
    margin-bottom: 32px;
}

.login-app-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
    letter-spacing: .02em;
}

.login-tagline {
    font-size: .9rem;
    color: rgba(255,255,255,.6);
    text-align: center;
    max-width: 320px;
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

.login-features {
    margin-top: 40px;
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 320px;
}

.login-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.login-feature-item:last-child { border-bottom: none; }

.login-feature-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: rgba(92,107,192,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: .85rem;
    flex-shrink: 0;
}

.login-feature-text {
    font-size: .8rem;
    color: rgba(255,255,255,.7);
}

.login-form-panel {
    width: 480px;
    background: var(--bg-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
    overflow-y: auto;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-welcome {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: .83rem;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.login-divider {
    text-align: center;
    font-size: .75rem;
    color: var(--text-muted);
    margin: 12px 0;
    position: relative;
}

.login-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.login-divider span {
    background: var(--bg-card);
    padding: 0 12px;
    position: relative;
}

.login-footer-text {
    font-size: .75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 20px;
}

/* ── Dashboard charts placeholder ──────────────────────────── */
.chart-placeholder {
    height: 200px;
    background: linear-gradient(135deg, #f8fafc 0%, #e8eaf6 100%);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    border: 2px dashed var(--border);
}

.chart-placeholder i { font-size: 2rem; color: var(--primary); opacity: .4; }
.chart-placeholder span { font-size: .8rem; color: var(--text-muted); }

/* ── Sidebar overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1035;
    backdrop-filter: blur(2px);
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
    animation: fadeInUp .35s ease both;
}

.fade-in-up-1 { animation-delay: .05s; }
.fade-in-up-2 { animation-delay: .10s; }
.fade-in-up-3 { animation-delay: .15s; }
.fade-in-up-4 { animation-delay: .20s; }

/* ── Footer ─────────────────────────────────────────────────── */
.app-footer {
    padding: 10px var(--page-pad-x);
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    font-size: .75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s;
    }

    .sidebar.open ~ .sidebar-overlay,
    .sidebar-overlay.visible {
        opacity: 1;
        pointer-events: all;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .topnav-toggle {
        display: flex;
    }

    .login-brand-panel {
        display: none;
    }

    .login-form-panel {
        width: 100%;
    }
}

@media (min-width: 1600px) {
    :root {
        --page-pad-x: 28px;
        --page-pad-y: 22px;
    }
}

@media (max-width: 640px) {
    .page-content { padding: 14px; }
    .page-header { gap: 12px; margin-bottom: 14px; }
    .page-title { font-size: 1.1rem; }

    .stat-card-value { font-size: 1.6rem; }

    .filter-bar { gap: 10px; }
    .filter-group { min-width: 100%; }

    .login-card { padding: 28px 20px; }
    .login-form-panel { padding: 24px 16px; }

    .toast { min-width: unset; width: calc(100vw - 32px); }
    .toast-container { right: 16px; bottom: 16px; }
}

/* ── Utility classes ────────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-info    { color: var(--info)    !important; }
.text-muted   { color: var(--text-muted) !important; }

.bg-primary-subtle { background: var(--primary-light) !important; }
.bg-success-subtle { background: var(--success-light) !important; }
.bg-warning-subtle { background: var(--warning-light) !important; }
.bg-danger-subtle  { background: var(--danger-light)  !important; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.rounded-full { border-radius: 100px !important; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cursor-pointer { cursor: pointer; }

.separator {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* Fix Bootstrap overrides */
.btn:focus, .btn:focus-visible { box-shadow: 0 0 0 3px rgba(92,107,192,.25); }

.form-check { display: flex; align-items: center; gap: 8px; padding-left: 0; }
.form-check .form-check-input { margin-top: 0; flex-shrink: 0; }

.table > :not(caption) > * > * { padding: 12px 16px; }

/* ============================================================
   Mesmerizing Shell Upgrade
   Persistent themes + collapsible module clusters
   ============================================================ */

html[data-ui-theme="aurora"] {
    --sidebar-bg: #101729;
    --sidebar-hover: rgba(255,255,255,.09);
    --sidebar-active: #43d9b8;
    --sidebar-text: #aab8d7;
    --sidebar-text-bright: #f7fbff;
    --sidebar-section: #81f4d8;
    --primary: #5168f6;
    --primary-dark: #3547c7;
    --primary-light: #eef1ff;
    --accent: #19c7b8;
    --accent-dark: #009e97;
    --bg-main: #f5f7fc;
    --bg-card: #ffffff;
    --text-main: #20283a;
    --text-muted: #67748e;
    --border: #dde5f0;
    --shell-glow: rgba(67,217,184,.34);
    --shell-glow-2: rgba(81,104,246,.24);
}

html[data-ui-theme="prism"] {
    --sidebar-bg: #1a1330;
    --sidebar-hover: rgba(255,255,255,.10);
    --sidebar-active: #ffbf47;
    --sidebar-text: #d2c9f3;
    --sidebar-text-bright: #ffffff;
    --sidebar-section: #74f2ce;
    --primary: #7758ff;
    --primary-dark: #5437ce;
    --primary-light: #f0edff;
    --accent: #ff4fa3;
    --accent-dark: #d9267a;
    --success: #18b882;
    --warning: #ff9e2c;
    --info: #00a7ff;
    --bg-main: #fff7fb;
    --bg-card: #ffffff;
    --text-main: #251d35;
    --text-muted: #74677f;
    --border: #eadff2;
    --shell-glow: rgba(255,79,163,.30);
    --shell-glow-2: rgba(0,167,255,.22);
}

html[data-ui-theme="neon"] {
    --sidebar-bg: #050812;
    --sidebar-hover: rgba(0,229,255,.10);
    --sidebar-active: #00e5ff;
    --sidebar-text: #8da4c5;
    --sidebar-text-bright: #eaffff;
    --sidebar-section: #ff3df2;
    --primary: #00e5ff;
    --primary-dark: #00a3c4;
    --primary-light: #062331;
    --accent: #ff3df2;
    --accent-dark: #c600b7;
    --success: #28f19b;
    --warning: #ffe45c;
    --danger: #ff4d6d;
    --info: #64a9ff;
    --bg-main: #08101d;
    --bg-card: #0d1827;
    --text-main: #e8f7ff;
    --text-muted: #91a7bd;
    --border: rgba(117,238,255,.18);
    --shell-glow: rgba(0,229,255,.42);
    --shell-glow-2: rgba(255,61,242,.25);
    color-scheme: dark;
}

html[data-ui-theme="ivory"] {
    --sidebar-bg: #17211f;
    --sidebar-hover: rgba(255,255,255,.10);
    --sidebar-active: #d5a642;
    --sidebar-text: #bdc9c4;
    --sidebar-text-bright: #ffffff;
    --sidebar-section: #f0d38b;
    --primary: #2f7d6d;
    --primary-dark: #1f5d52;
    --primary-light: #eaf5f2;
    --accent: #d5a642;
    --accent-dark: #a77b24;
    --bg-main: #f8f6f0;
    --bg-card: #fffdf8;
    --text-main: #2b302d;
    --text-muted: #6f7871;
    --border: #e4ded1;
    --shell-glow: rgba(213,166,66,.28);
    --shell-glow-2: rgba(47,125,109,.22);
}

body {
    background:
        linear-gradient(135deg, rgba(255,255,255,.42), rgba(255,255,255,0) 36%),
        radial-gradient(900px 520px at 85% -20%, var(--shell-glow), transparent 62%),
        radial-gradient(700px 480px at 12% 105%, var(--shell-glow-2), transparent 58%),
        var(--bg-main);
}

html[data-ui-theme="neon"] body {
    background:
        linear-gradient(135deg, rgba(0,229,255,.08), rgba(255,61,242,.05) 40%, rgba(0,0,0,0) 70%),
        radial-gradient(850px 520px at 85% -20%, var(--shell-glow), transparent 62%),
        radial-gradient(720px 520px at 8% 105%, var(--shell-glow-2), transparent 60%),
        var(--bg-main);
}

.sidebar {
    width: 268px;
    background:
        linear-gradient(155deg, rgba(255,255,255,.10), rgba(255,255,255,0) 32%),
        linear-gradient(180deg, var(--sidebar-bg), color-mix(in srgb, var(--sidebar-bg), #000 18%));
    border-right: 1px solid rgba(255,255,255,.10);
    box-shadow: 10px 0 34px rgba(0,0,0,.22);
}

.main-wrapper {
    margin-left: 268px;
    width: calc(100% - 268px);
}

.sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(255,255,255,.10), transparent 18%),
        repeating-linear-gradient(135deg, rgba(255,255,255,.035) 0 1px, transparent 1px 12px);
    opacity: .42;
}

.sidebar-brand {
    min-height: 72px;
    height: 72px;
    padding: 0 18px;
    background: rgba(255,255,255,.06);
    border-bottom: 1px solid rgba(255,255,255,.10);
    position: relative;
    z-index: 1;
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 0 22px var(--shell-glow);
}

.sidebar-brand-text {
    font-size: .96rem;
    letter-spacing: 0;
}

.sidebar-brand-text span {
    color: color-mix(in srgb, var(--sidebar-text), #fff 12%);
}

.sidebar-nav {
    padding: 14px 10px 22px;
    position: relative;
    z-index: 1;
}

.sidebar-nav > .sidebar-nav-item {
    margin: 3px 2px;
}

.sidebar-nav-link {
    min-height: 42px;
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--sidebar-text);
    border: 1px solid transparent;
    isolation: isolate;
}

.sidebar-nav-link::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 7px;
    background: linear-gradient(135deg, rgba(255,255,255,.13), rgba(255,255,255,0));
    opacity: 0;
    z-index: -1;
    transition: var(--transition);
}

.sidebar-nav-link:hover {
    background: var(--sidebar-hover);
    border-color: rgba(255,255,255,.10);
    color: var(--sidebar-text-bright);
    transform: translateX(3px);
}

.sidebar-nav-link:hover::after {
    opacity: 1;
}

.sidebar-nav-link.active {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border-color: rgba(255,255,255,.22);
    box-shadow: 0 10px 28px color-mix(in srgb, var(--primary), transparent 62%);
}

.sidebar-nav-link.active::before {
    display: none;
}

.sidebar-nav-link i {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    color: inherit;
    background: rgba(255,255,255,.08);
}

.sidebar-nav-link.active i {
    background: rgba(255,255,255,.20);
}

.sidebar-menu-cluster {
    margin: 10px 0;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    background: rgba(255,255,255,.035);
    overflow: hidden;
}

.sidebar-section-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--sidebar-section);
    min-height: 40px;
    padding: 9px 10px;
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font);
    font-size: .69rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.sidebar-section-toggle .bi {
    margin-left: auto;
    transition: transform .2s ease;
}

.sidebar-menu-cluster.open .sidebar-section-toggle .bi {
    transform: rotate(180deg);
}

.section-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sidebar-section);
    box-shadow: 0 0 14px var(--sidebar-section);
    flex-shrink: 0;
}

.sidebar-section-body {
    max-height: 0;
    transition: max-height .24s ease;
}

.sidebar-menu-cluster.open .sidebar-section-body {
    max-height: 980px;
}

.sidebar-section-body {
    overflow: hidden;
}

.sidebar-section-body .sidebar-nav-item {
    margin: 2px 6px 6px;
}

.topnav {
    height: 64px;
    background: color-mix(in srgb, var(--bg-card), transparent 6%);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid color-mix(in srgb, var(--border), transparent 18%);
    box-shadow: 0 8px 26px rgba(31,41,55,.08);
}

.topnav-icon-btn,
.theme-switcher-btn {
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    transition: var(--transition);
}

.topnav-icon-btn:hover,
.theme-switcher-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary), transparent 86%);
}

.theme-switcher-btn {
    display: inline-flex;
    gap: 8px;
    padding: 0 12px;
    font-size: .8rem;
    font-weight: 700;
}

.theme-dot,
.theme-swatch {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 0 14px var(--shell-glow);
}

.theme-menu {
    min-width: 260px;
    padding: 8px;
    border-radius: 8px;
    border-color: var(--border);
    box-shadow: var(--shadow-lg);
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    border-radius: 8px;
}

.theme-option span:last-child {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.theme-option small {
    color: var(--text-muted);
    font-size: .72rem;
    margin-top: 2px;
}

.theme-option.active {
    background: var(--primary-light);
    color: var(--primary);
}

.industry-panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    margin-bottom: 1rem;
    overflow: hidden;
}

.industry-panel-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.industry-panel-head h2 {
    margin: .15rem 0 .25rem;
    font-size: 1.08rem;
    letter-spacing: 0;
}

.industry-panel-head p {
    margin: 0;
    max-width: 860px;
    color: var(--text-muted);
    font-size: .86rem;
}

.industry-kicker {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: var(--primary);
    font-weight: 800;
    font-size: .75rem;
    text-transform: uppercase;
}

.industry-regulator {
    min-width: 180px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .65rem .75rem;
    background: var(--bg-main);
}

.industry-regulator span {
    display: block;
    color: var(--text-muted);
    font-size: .68rem;
    text-transform: uppercase;
}

.industry-regulator strong {
    display: block;
    margin-top: .15rem;
    font-size: .9rem;
}

.industry-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr);
    gap: 1rem;
    padding: 1rem;
}

.industry-grid h3 {
    margin: 0 0 .65rem;
    font-size: .82rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: .03em;
}

.industry-pack-list,
.industry-module-list {
    display: grid;
    gap: .65rem;
}

.industry-pack,
.industry-module {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-main);
    padding: .75rem;
}

.industry-pack div {
    display: grid;
    gap: .1rem;
}

.industry-pack span {
    color: var(--primary);
    font-size: .7rem;
    font-weight: 800;
}

.industry-pack strong,
.industry-module strong {
    font-size: .9rem;
}

.industry-pack p,
.industry-module span {
    display: block;
    margin: .35rem 0 0;
    color: var(--text-muted);
    font-size: .8rem;
}

.industry-module {
    display: flex;
    gap: .7rem;
    align-items: flex-start;
}

.industry-module i {
    color: var(--primary);
    font-size: 1rem;
    margin-top: .1rem;
}

.swatch-aurora { background: linear-gradient(135deg, #5168f6, #19c7b8); }
.swatch-prism { background: linear-gradient(135deg, #7758ff, #ff4fa3 55%, #ffbf47); }
.swatch-neon { background: linear-gradient(135deg, #00e5ff, #ff3df2); }
.swatch-ivory { background: linear-gradient(135deg, #2f7d6d, #d5a642); }

html[data-sidebar="collapsed"] .sidebar {
    width: var(--sidebar-collapsed-width);
}

html[data-sidebar="collapsed"] .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

html[data-sidebar="collapsed"] .sidebar-brand {
    justify-content: center;
    padding: 0;
}

html[data-sidebar="collapsed"] .sidebar-brand-text,
html[data-sidebar="collapsed"] .sidebar-search input,
html[data-sidebar="collapsed"] .nav-label,
html[data-sidebar="collapsed"] .section-name,
html[data-sidebar="collapsed"] .sidebar-section-toggle .bi {
    display: none;
}

html[data-sidebar="collapsed"] .sidebar-search {
    justify-content: center;
    margin: 12px 8px 4px;
    padding: 8px;
}

html[data-sidebar="collapsed"] .sidebar-nav {
    padding: 14px 8px 22px;
}

html[data-sidebar="collapsed"] .sidebar-menu-cluster {
    border-color: transparent;
    background: transparent;
    margin: 8px 0;
}

html[data-sidebar="collapsed"] .sidebar-section-toggle {
    justify-content: center;
    padding: 8px 0;
    min-height: 28px;
}

html[data-sidebar="collapsed"] .sidebar-section-body {
    grid-template-rows: 1fr;
}

html[data-sidebar="collapsed"] .sidebar-nav-link {
    justify-content: center;
    padding: 10px 0;
}

html[data-sidebar="collapsed"] .sidebar-nav-link:hover {
    transform: none;
}

html[data-sidebar="collapsed"] .sidebar-nav-link i {
    margin: 0;
}

html[data-ui-theme="neon"] .card,
html[data-ui-theme="neon"] .topnav,
html[data-ui-theme="neon"] .dropdown-menu,
html[data-ui-theme="neon"] .filter-bar,
html[data-ui-theme="neon"] .toast {
    background: color-mix(in srgb, var(--bg-card), #000 4%);
    box-shadow: 0 0 0 1px rgba(0,229,255,.08), 0 12px 30px rgba(0,0,0,.24);
}

html[data-ui-theme="neon"] .btn-primary,
html[data-ui-theme="neon"] .sidebar-nav-link.active {
    box-shadow: 0 0 18px color-mix(in srgb, var(--primary), transparent 58%);
}

/* ============================================================
   Professional Light Theme
   A single restrained palette for every tenant module.
   ============================================================ */
html[data-ui-theme="professional"] {
    color-scheme: light;
    --sidebar-bg: #ffffff;
    --sidebar-hover: #f1f5f9;
    --sidebar-active: #eaf1ff;
    --sidebar-text: #475569;
    --sidebar-text-bright: #172033;
    --sidebar-section: #64748b;
    --primary: #2457a7;
    --primary-dark: #193f7d;
    --primary-light: #eaf1fb;
    --accent: #3b6fb6;
    --accent-dark: #2457a7;
    --accent-light: #edf3fb;
    --success: #287a5b;
    --success-light: #e7f4ee;
    --warning: #a96816;
    --warning-light: #fff4df;
    --danger: #b33a46;
    --danger-light: #fbeaec;
    --info: #2e659f;
    --info-light: #e9f2fb;
    --bg-main: #f4f6f9;
    --bg-card: #ffffff;
    --text-main: #172033;
    --text-muted: #667085;
    --border: #dfe5ec;
    --shell-glow: transparent;
    --shell-glow-2: transparent;
    --shadow-sm: 0 1px 3px rgba(15,23,42,.06);
    --shadow-md: 0 5px 16px rgba(15,23,42,.08);
    --shadow-lg: 0 12px 30px rgba(15,23,42,.10);
    --radius: 10px;
    --radius-sm: 7px;
}

html[data-ui-theme="professional"] body {
    background: var(--bg-main);
}

html[data-ui-theme="professional"] .sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    box-shadow: 3px 0 14px rgba(15,23,42,.05);
}

html[data-ui-theme="professional"] .sidebar::before {
    display: none;
}

html[data-ui-theme="professional"] .sidebar-brand {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
}

html[data-ui-theme="professional"] .sidebar-brand-icon {
    background: var(--primary);
    box-shadow: none;
}

html[data-ui-theme="professional"] .sidebar-brand-text,
html[data-ui-theme="professional"] .sidebar-user-name {
    color: var(--text-main);
}

html[data-ui-theme="professional"] .sidebar-brand-text span,
html[data-ui-theme="professional"] .sidebar-user-role {
    color: var(--text-muted);
}

html[data-ui-theme="professional"] .sidebar-search {
    background: #f8fafc;
    border-color: var(--border);
    color: var(--text-muted);
}

html[data-ui-theme="professional"] .sidebar-search i,
html[data-ui-theme="professional"] .sidebar-search input::placeholder {
    color: #8491a3;
}

html[data-ui-theme="professional"] .sidebar-search input {
    color: var(--text-main);
}

html[data-ui-theme="professional"] .sidebar-nav {
    scrollbar-color: #cbd5e1 transparent;
}

html[data-ui-theme="professional"] .sidebar-nav::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

html[data-ui-theme="professional"] .sidebar-nav-link {
    color: var(--sidebar-text);
}

html[data-ui-theme="professional"] .sidebar-nav-link::after {
    display: none;
}

html[data-ui-theme="professional"] .sidebar-nav-link:hover {
    background: var(--sidebar-hover);
    border-color: var(--border);
    color: var(--text-main);
    transform: none;
}

html[data-ui-theme="professional"] .sidebar-nav-link.active {
    background: var(--sidebar-active);
    border-color: #cbdaf1;
    color: var(--primary-dark);
    box-shadow: none;
}

html[data-ui-theme="professional"] .sidebar-nav-link i {
    background: #f1f5f9;
    color: #526274;
}

html[data-ui-theme="professional"] .sidebar-nav-link.active i {
    background: var(--primary);
    color: #ffffff;
}

html[data-ui-theme="professional"] .sidebar-menu-cluster {
    background: #ffffff;
    border-color: var(--border);
}

html[data-ui-theme="professional"] .sidebar-section-toggle {
    color: var(--sidebar-section);
}

html[data-ui-theme="professional"] .section-pulse {
    background: var(--primary);
    box-shadow: none;
}

html[data-ui-theme="professional"] .sidebar-footer {
    border-top-color: var(--border);
    background: #ffffff;
}

html[data-ui-theme="professional"] .sidebar-user:hover {
    background: var(--sidebar-hover);
}

html[data-ui-theme="professional"] .topnav {
    background: rgba(255,255,255,.98);
    border-bottom-color: var(--border);
    box-shadow: 0 1px 4px rgba(15,23,42,.05);
    backdrop-filter: none;
}

html[data-ui-theme="professional"] .card,
html[data-ui-theme="professional"] .stat-card,
html[data-ui-theme="professional"] .filter-bar,
html[data-ui-theme="professional"] .dropdown-menu {
    box-shadow: var(--shadow-sm);
}

html[data-ui-theme="professional"] .card:hover,
html[data-ui-theme="professional"] .stat-card:hover {
    box-shadow: var(--shadow-md);
}

html[data-ui-theme="professional"] .card-header,
html[data-ui-theme="professional"] .table thead th {
    background: #f8fafc;
}

html[data-ui-theme="professional"] .table tbody tr:hover {
    background: #f6f9fc;
}

html[data-ui-theme="professional"] .form-control,
html[data-ui-theme="professional"] .form-select {
    background-color: #ffffff;
    border-color: #cfd8e3;
}

html[data-ui-theme="professional"] .form-control:focus,
html[data-ui-theme="professional"] .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(36,87,167,.12);
}

html[data-ui-theme="professional"] .btn-primary {
    box-shadow: 0 1px 3px rgba(25,63,125,.18);
}

html[data-ui-theme="professional"] .btn-primary:hover {
    box-shadow: 0 3px 9px rgba(25,63,125,.20);
}

@media (max-width: 1024px) {
    .industry-panel-head,
    .industry-grid {
        grid-template-columns: 1fr;
    }

    .industry-regulator {
        min-width: 0;
    }

    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .main-wrapper,
    html[data-sidebar="collapsed"] .main-wrapper {
        width: 100%;
        margin-left: 0;
    }

    html[data-sidebar="collapsed"] .sidebar {
        width: var(--sidebar-width);
    }

    html[data-sidebar="collapsed"] .sidebar-brand-text,
    html[data-sidebar="collapsed"] .nav-label,
    html[data-sidebar="collapsed"] .section-name,
    html[data-sidebar="collapsed"] .sidebar-section-toggle .bi {
        display: initial;
    }

    html[data-sidebar="collapsed"] .sidebar-brand {
        justify-content: flex-start;
        padding: 0 18px;
    }

    html[data-sidebar="collapsed"] .sidebar-nav-link {
        justify-content: flex-start;
        padding: 10px 12px;
    }
}

@media (max-width: 640px) {
    .theme-switcher-btn {
        padding: 0;
        width: 38px;
    }
}

/* ── Seamless page changes ─────────────────────────────────────────────────
   Moving between pages is still a normal page load (so every page keeps its no-store,
   server-checked security), but it should not LOOK like one:
   - the browser keeps the current page on screen until the next one is ready, then swaps them
     with a short cross-fade (cross-document view transitions; ignored by older browsers);
   - the sidebar and top bar are named, so they are carried over as-is instead of fading;
   - nothing in the shell animates while a page starts, and card entrance animations only play
     on the first page of a visit. */
@view-transition { navigation: auto; }

.sidebar { view-transition-name: app-sidebar; }
.topnav { view-transition-name: app-topbar; }

::view-transition-group(app-sidebar),
::view-transition-group(app-topbar),
::view-transition-old(app-sidebar),
::view-transition-new(app-sidebar),
::view-transition-old(app-topbar),
::view-transition-new(app-topbar) { animation: none; }

::view-transition-old(root) { animation: 90ms ease-out both cm-page-out; }
::view-transition-new(root) { animation: 160ms ease-out both cm-page-in; }

@keyframes cm-page-out { to { opacity: 0; } }
@keyframes cm-page-in { from { opacity: 0; } }

html.shell-booting .sidebar-section-body,
html.shell-booting .sidebar-section-toggle .bi,
html.shell-booting .sidebar,
html.shell-booting .main-wrapper { transition: none !important; }

html.nav-internal .fade-in-up { animation: none; }

@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
}
