/* ============================================================
   AEGIS — Design System
   Dark industrial theme with indigo/violet accents
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ── */
:root {
    --bg-base: #0A0E1A;
    --bg-surface: #0F1526;
    --bg-elevated: #151C30;
    --bg-card: #1A2238;
    --bg-hover: #1F2940;
    --border: #1E2D4A;
    --border-subtle: #162038;
    --text-primary: #F0F4FF;
    --text-secondary: #94A3B8;
    --text-muted: #4A5568;
    --indigo: #6366F1;
    --indigo-light: #818CF8;
    --violet: #8B5CF6;
    --cyan: #06B6D4;
    --green: #10B981;
    --amber: #F59E0B;
    --red: #EF4444;
    --emerald: #059669;
    --sidebar-w: 240px;
    --sidebar-collapsed: 64px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.2);
    --shadow-glow: 0 0 20px rgba(99,102,241,0.15);
    --font-body: 'Space Grotesk', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--indigo-light);
    text-decoration: none;
}

    a:hover {
        color: var(--text-primary);
    }

code, pre {
    font-family: var(--font-mono);
}

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

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.25s ease;
    overflow: hidden;
}

.app-shell.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, var(--indigo-light), var(--violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.sidebar-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

    .sidebar-toggle:hover {
        background: var(--bg-elevated);
        color: var(--text-primary);
    }

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 8px 4px;
    white-space: nowrap;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
    margin-bottom: 2px;
}

    .nav-item:hover {
        background: var(--bg-elevated);
        color: var(--text-primary);
    }

    .nav-item.active {
        background: rgba(99, 102, 241, 0.15);
        color: var(--indigo-light);
    }

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border-subtle);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--indigo), var(--violet));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
    flex-shrink: 0;
}

    .logout-btn:hover {
        color: var(--red);
    }

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    transition: margin-left 0.25s ease;
    min-height: 100vh;
    background: var(--bg-base);
}

.app-shell.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

.page-container {
    padding: 28px 32px;
    max-width: 1400px;
}

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

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

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--indigo);
    color: white;
    border-color: var(--indigo);
}

    .btn-primary:hover {
        background: var(--indigo-light);
        border-color: var(--indigo-light);
        color: white;
    }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

    .btn-ghost:hover {
        background: var(--bg-elevated);
        color: var(--text-primary);
    }

.btn-success {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

.btn-warning {
    background: var(--amber);
    color: #1a1a1a;
    border-color: var(--amber);
}

.btn-danger {
    background: var(--red);
    color: white;
    border-color: var(--red);
}

.btn-danger-ghost {
    background: transparent;
    color: var(--red);
    border-color: transparent;
}

    .btn-danger-ghost:hover {
        background: rgba(239,68,68,0.1);
    }

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-card);
    transition: transform 0.15s, box-shadow 0.15s;
}

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

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-indigo .stat-icon {
    background: rgba(99,102,241,0.15);
    color: var(--indigo-light);
}

.stat-green .stat-icon {
    background: rgba(16,185,129,0.15);
    color: var(--green);
}

.stat-red .stat-icon {
    background: rgba(239,68,68,0.15);
    color: var(--red);
}

.stat-amber .stat-icon {
    background: rgba(245,158,11,0.15);
    color: var(--amber);
}

.stat-violet .stat-icon {
    background: rgba(139,92,246,0.15);
    color: var(--violet);
}

.stat-cyan .stat-icon {
    background: rgba(6,182,212,0.15);
    color: var(--cyan);
}

.stat-emerald .stat-icon {
    background: rgba(5,150,105,0.15);
    color: var(--emerald);
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-label {
    font-size: 11.5px;
    color: var(--text-secondary);
    margin-top: 3px;
    font-weight: 500;
}

/* ── Charts ── */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 14px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
}

.donut-chart {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-top: 16px;
}

.donut-legend {
    flex: 1;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 12.5px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    color: var(--text-secondary);
}

.legend-value {
    font-weight: 600;
    font-size: 13px;
}

.bar-chart {
    margin-top: 16px;
    height: 140px;
}

.bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 120px;
    padding: 0 4px;
}

.bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    height: 100%;
    justify-content: flex-end;
}

.bar-value {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.bar {
    width: 100%;
    min-height: 4px;
    border-radius: 4px 4px 0 0;
    overflow: hidden;
    transition: height 0.5s ease;
}

.bar-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, var(--indigo-light), var(--indigo));
    border-radius: 4px 4px 0 0;
}

.bar-label {
    font-size: 10.5px;
    color: var(--text-muted);
    text-align: center;
}

/* ── Audit List ── */
.audit-list {
    padding: 4px 0;
}

.audit-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.1s;
}

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

    .audit-item:hover {
        background: var(--bg-elevated);
    }

.audit-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.audit-green {
    background: rgba(16,185,129,0.15);
    color: var(--green);
}

.audit-red {
    background: rgba(239,68,68,0.15);
    color: var(--red);
}

.audit-amber {
    background: rgba(245,158,11,0.15);
    color: var(--amber);
}

.audit-blue {
    background: rgba(6,182,212,0.15);
    color: var(--cyan);
}

.audit-neutral {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

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

.audit-action {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.audit-details {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audit-time {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Filter Bar ── */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    color: var(--text-muted);
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13.5px;
    padding: 10px 0;
}

    .search-input::placeholder {
        color: var(--text-muted);
    }

.filter-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 9px 12px;
    cursor: pointer;
    outline: none;
}

    .filter-select:focus {
        border-color: var(--indigo);
    }

/* ── Data Table ── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

    .data-table th {
        padding: 12px 16px;
        text-align: left;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--text-muted);
        background: var(--bg-elevated);
        border-bottom: 1px solid var(--border);
    }

    .data-table td {
        padding: 12px 16px;
        font-size: 13px;
        color: var(--text-primary);
        border-bottom: 1px solid var(--border-subtle);
        vertical-align: middle;
    }

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

    .data-table tbody tr:hover {
        background: var(--bg-elevated);
    }

.data-table-sm th,
.data-table-sm td {
    padding: 8px 12px;
}

.empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-success {
    background: rgba(16,185,129,0.15);
    color: #34D399;
    border: 1px solid rgba(16,185,129,0.25);
}

.badge-danger {
    background: rgba(239,68,68,0.15);
    color: #F87171;
    border: 1px solid rgba(239,68,68,0.25);
}

.badge-warning {
    background: rgba(245,158,11,0.15);
    color: #FCD34D;
    border: 1px solid rgba(245,158,11,0.25);
}

.badge-neutral {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-perpetual {
    background: rgba(6,182,212,0.15);
    color: var(--cyan);
    border: 1px solid rgba(6,182,212,0.2);
}

.badge-type {
    background: rgba(139,92,246,0.15);
    color: #A78BFA;
    border: 1px solid rgba(139,92,246,0.25);
}

.badge-role {
}

.badge-role-admin {
    background: rgba(99,102,241,0.15);
    color: var(--indigo-light);
    border: 1px solid rgba(99,102,241,0.3);
}

.badge-role-manager {
    background: rgba(245,158,11,0.15);
    color: var(--amber);
    border: 1px solid rgba(245,158,11,0.3);
}

.badge-role-user {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* Audit badges */
.audit-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

    .audit-badge.audit-green {
        background: rgba(16,185,129,0.15);
        color: #34D399;
    }

    .audit-badge.audit-red {
        background: rgba(239,68,68,0.15);
        color: #F87171;
    }

    .audit-badge.audit-amber {
        background: rgba(245,158,11,0.15);
        color: #FCD34D;
    }

    .audit-badge.audit-blue {
        background: rgba(6,182,212,0.15);
        color: var(--cyan);
    }

    .audit-badge.audit-neutral {
        background: var(--bg-elevated);
        color: var(--text-secondary);
    }

/* ── Forms ── */
.form-page {
    max-width: 760px;
}

.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-card);
}

.form-section {
    margin-bottom: 24px;
}

.form-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.required {
    color: var(--red);
}

.form-input,
.form-select,
.form-textarea {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13.5px;
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

    .form-input:focus,
    .form-select:focus,
    .form-textarea:focus {
        border-color: var(--indigo);
        box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
    }

    .form-input::placeholder,
    .form-textarea::placeholder {
        color: var(--text-muted);
    }

    .form-select option {
        background: var(--bg-elevated);
    }

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-error {
    font-size: 12px;
    color: var(--red);
    display: block;
}

.form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 400;
}

.form-hint-inline {
    font-size: 11.5px;
    color: var(--indigo-light);
    margin-top: 2px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    margin-top: 8px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}

.input-wrapper .form-input {
    padding-left: 42px;
}

.key-toggle {
    margin-bottom: 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.toggle-input {
    width: 16px;
    height: 16px;
    accent-color: var(--indigo);
    cursor: pointer;
}

.mt-2 {
    margin-top: 8px;
}

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-bg {
    position: absolute;
    inset: 0;
    background: var(--bg-base);
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
}

.bg-orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--indigo), transparent 70%);
    top: -200px;
    right: -100px;
}

.bg-orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--violet), transparent 70%);
    bottom: -150px;
    left: -100px;
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(99,102,241,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(99,102,241,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
}

.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.login-brand h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, var(--indigo-light), var(--violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-brand p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-hint {
    margin-top: 20px;
    padding: 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

    .login-hint code {
        color: var(--indigo-light);
        font-size: 11.5px;
    }

/* ── Alerts ── */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.25);
    color: #F87171;
}

/* ── Spinner ── */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.6);
    animation: modalIn 0.2s ease;
}

.modal-lg {
    max-width: 640px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

    .modal-header h3 {
        font-size: 16px;
        font-weight: 600;
    }

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    display: flex;
    align-items: center;
}

    .modal-close:hover {
        color: var(--text-primary);
    }

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 16px;
}

/* ── Users Grid ── */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.user-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-card);
}

    .user-card:hover {
        transform: translateY(-1px);
        box-shadow: var(--shadow-glow);
    }

.user-inactive {
    opacity: 0.6;
}

.user-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.user-avatar-lg {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--indigo), var(--violet));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.user-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-email {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.user-card-actions {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
}

/* ── User cell in table ── */
.user-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mini-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--indigo), var(--violet));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 10px;
    color: white;
    flex-shrink: 0;
}

/* ── Products ── */
.products-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.product-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.1s;
}

    .product-row:last-child {
        border-bottom: none;
    }

    .product-row:hover {
        background: var(--bg-elevated);
    }

.product-inactive {
    opacity: 0.55;
}

.product-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--indigo-light);
    flex-shrink: 0;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.product-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
    font-size: 12px;
}

.version-badge {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 1px 7px;
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}

.product-stats {
    text-align: center;
    width: 80px;
}

.stat-mini-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-mini-label {
    font-size: 10.5px;
    color: var(--text-muted);
}

.product-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-secondary);
    width: 80px;
}

.product-actions {
    display: flex;
    gap: 6px;
}

/* ── License Key ── */
.license-key {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-elevated);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    color: var(--indigo-light);
    border: 1px solid var(--border);
}

.activations {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-secondary);
}

/* ── Detail View ── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.back-link {
    font-size: 13px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
}

    .back-link:hover {
        color: var(--indigo-light);
    }

.key-display {
    font-family: var(--font-mono);
    font-size: 15px;
    color: var(--indigo-light);
    display: block;
    margin-top: 4px;
    letter-spacing: 0.05em;
}

.detail-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
    gap: 16px;
}

    .detail-row:last-child {
        border-bottom: none;
    }

    .detail-row dt {
        font-size: 12px;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.06em;
        width: 140px;
        flex-shrink: 0;
        padding-top: 2px;
    }

    .detail-row dd {
        font-size: 13.5px;
        color: var(--text-primary);
        flex: 1;
    }

.activation-meter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.meter-track {
    flex: 1;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--indigo), var(--violet));
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ── Validate Page ── */
.validate-page {
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.validate-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-card);
}

.validate-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--indigo-light);
}

.validate-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.validate-subtitle {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.validate-form {
    text-align: left;
}

.key-input-wrapper {
    display: flex;
    gap: 10px;
}

.key-input {
    flex: 1;
}

.validate-result {
    margin-top: 24px;
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: left;
    animation: fadeIn 0.25s ease;
}

.result-valid {
    background: rgba(16,185,129,0.08);
    border: 1px solid rgba(16,185,129,0.25);
}

.result-invalid {
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.25);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.result-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-icon-valid {
    background: rgba(16,185,129,0.2);
    color: var(--green);
}

.result-icon-invalid {
    background: rgba(239,68,68,0.2);
    color: var(--red);
}

.result-title {
    font-size: 17px;
    font-weight: 700;
}

.result-message {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.result-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.result-detail-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.detail-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.detail-value {
    font-size: 13.5px;
    color: var(--text-primary);
}

/* API card */
.api-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

    .api-card h3 {
        font-size: 15px;
        font-weight: 600;
        margin-bottom: 8px;
    }

    .api-card p {
        font-size: 13px;
        color: var(--text-secondary);
        margin-bottom: 14px;
    }

.code-block {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--indigo-light);
    overflow-x: auto;
    white-space: pre;
}

/* ── Success Banner ── */
.success-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.25);
    border-radius: var(--radius);
    margin-bottom: 24px;
    color: var(--green);
}

.success-title {
    font-weight: 600;
    font-size: 13.5px;
    margin-bottom: 4px;
}

.success-key {
    font-family: var(--font-mono);
    font-size: 14px;
    color: #34D399;
    letter-spacing: 0.1em;
}

/* ── Dots ── */
.dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.dot-green {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.dot-red {
    background: var(--red);
}

/* ── Misc ── */
.text-muted {
    color: var(--text-muted);
}

.text-danger {
    color: var(--red);
}

.text-warning {
    color: var(--amber);
}

.text-nowrap {
    white-space: nowrap;
}

.action-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
}

.product-name {
    font-weight: 500;
    color: var(--text-primary);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 12px;
    font-size: 14px;
}

.empty-state-sm {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
}

.empty-chart {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 140px;
    color: var(--text-muted);
    font-size: 13px;
}

.loading-state {
    padding: 60px;
    text-align: center;
    color: var(--text-muted);
}

/* ── Skeleton Loading ── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    to {
        background-position: -200% 0;
    }
}

.skeleton-card {
    height: 88px;
    border-radius: var(--radius-lg);
}

.skeleton-row {
    height: 48px;
    margin-bottom: 2px;
}

.loading-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.skeleton-table {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--text-muted);
    }

/* ── Responsive ── */
@media (max-width: 900px) {
    .charts-row {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .result-details {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .page-container {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .users-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   AEGIS LIBRARY INTEGRATION — Additional Styles
   ============================================================ */

/* ── Aegis nav section accent ── */
.nav-label-accent {
    background: linear-gradient(90deg, var(--indigo), var(--violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.nav-item-aegis {
    border-left: 2px solid transparent;
}

    .nav-item-aegis.active,
    .nav-item-aegis:hover {
        border-left-color: var(--violet);
        background: rgba(139, 92, 246, 0.12);
        color: #C4B5FD;
    }

    .nav-item-aegis.active {
        color: #C4B5FD;
    }

/* ── Secrets status banner ── */
.secrets-status {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 22px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    border: 1px solid;
}

.status-ok {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
    color: #34D399;
}

.status-warn {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
    color: var(--amber);
}

.status-icon {
    margin-top: 2px;
    flex-shrink: 0;
}

.status-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.status-detail {
    font-size: 12.5px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

    .status-detail code {
        font-size: 11.5px;
        opacity: 0.9;
    }

.status-sep {
    opacity: 0.4;
}

/* ── Info banner ── */
.info-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 18px;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.25);
    border-radius: var(--radius);
    color: var(--cyan);
    font-size: 13px;
    margin-bottom: 20px;
}

    .info-banner a {
        color: var(--indigo-light);
        text-decoration: underline;
    }

.info-banner-warn {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
    color: var(--amber);
}

    .info-banner-warn a {
        color: var(--amber);
    }

/* ── Setup grid ── */
.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.setup-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.setup-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
}

.setup-card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.setup-icon-indigo {
    background: rgba(99,102,241,0.15);
    color: var(--indigo-light);
}

.setup-icon-violet {
    background: rgba(139,92,246,0.15);
    color: #C4B5FD;
}

.setup-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.setup-card-sub {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.setup-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ── Code guide ── */
.code-guide {
    padding: 8px 20px 20px;
}

.guide-section {
    margin-bottom: 22px;
}

    .guide-section:last-child {
        margin-bottom: 0;
    }

.guide-label {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* ── Aegis license model badges ── */
.badge-model {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 3px 9px;
    border-radius: 20px;
    border: 1px solid;
}

.badge-model-standard {
    background: rgba(99,102,241,0.12);
    color: #818CF8;
    border-color: rgba(99,102,241,0.3);
}

.badge-model-trial {
    background: rgba(6,182,212,0.12);
    color: var(--cyan);
    border-color: rgba(6,182,212,0.3);
}

.badge-model-nodelocked {
    background: rgba(245,158,11,0.12);
    color: #FCD34D;
    border-color: rgba(245,158,11,0.3);
}

.badge-model-subscription {
    background: rgba(16,185,129,0.12);
    color: #34D399;
    border-color: rgba(16,185,129,0.3);
}

.badge-model-floating {
    background: rgba(139,92,246,0.12);
    color: #C4B5FD;
    border-color: rgba(139,92,246,0.3);
}

.badge-model-concurrent {
    background: rgba(239,68,68,0.12);
    color: #FCA5A5;
    border-color: rgba(239,68,68,0.3);
}

/* model badge inline (next to form section title) */
.model-badge-inline {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-left: 8px;
    border: 1px solid;
    vertical-align: middle;
}

/* ── Feature rows ── */
.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.feature-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 10px;
}

.empty-features {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

/* ── Licensee cell ── */
.licensee-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
}

/* ── Features pill ── */
.features-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 20px;
    font-size: 11px;
    color: var(--indigo-light);
    cursor: default;
}

/* ── Revoke confirm ── */
.revoke-key-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ── Binary file status ── */
.bin-status {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border-radius: var(--radius);
    border: 1px solid;
    margin-top: 2px;
}

.bin-status-ok {
    background: rgba(16,185,129,0.08);
    border-color: rgba(16,185,129,0.2);
    color: #34D399;
}

.bin-status-missing {
    background: rgba(239,68,68,0.08);
    border-color: rgba(239,68,68,0.2);
    color: #F87171;
}

.bin-path {
    font-family: var(--font-mono);
    font-size: 11.5px;
    margin-bottom: 3px;
    word-break: break-all;
}

.bin-desc {
    font-size: 11.5px;
    opacity: 0.7;
}

/* ── Hw ID ── */
.hw-id {
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
    word-break: break-all;
}

/* ── Detail card font weight helpers ── */
.fw-500 {
    font-weight: 500;
}

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

/* ── mt helpers ── */
.mt-24 {
    margin-top: 24px;
}

/* ── Success content ── */
.success-content {
    flex: 1;
}

.success-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

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

/* ── Responsive fixes for setup grid ── */
@media (max-width: 800px) {
    .setup-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Validate tabs ── */
.validate-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 16px;
    width: fit-content;
}

.validate-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.15s;
}

    .validate-tab:hover {
        background: var(--bg-elevated);
        color: var(--text-primary);
    }

    .validate-tab.tab-active {
        background: var(--indigo);
        color: white;
        box-shadow: 0 2px 8px rgba(99,102,241,0.35);
    }

/* ── Features result ── */
.features-result {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.07);
}

.features-result-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.features-result-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.feature-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
}

.feature-chip-name {
    color: var(--indigo-light);
    font-weight: 600;
}

.feature-chip-value {
    color: var(--text-secondary);
}