:root {
    --ukba-primary: #1e3a5f;
    --ukba-primary-dark: #15294a;
    --ukba-primary-light: #2a4d7a;
    --ukba-accent: #c5a572;
    --ukba-accent-dark: #a88a5a;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 20px 50px rgba(0,0,0,0.15);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --transition: all 0.2s ease;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
}

/* ==================== LOGIN ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--ukba-primary) 0%, var(--ukba-primary-light) 100%);
    padding: 1rem;
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}

.logo-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ukba-primary), var(--ukba-primary-light));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 1px;
    box-shadow: 0 8px 24px rgba(30, 58, 95, 0.35);
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--ukba-primary) 0%, var(--ukba-primary-dark) 100%);
    color: rgba(255,255,255,0.92);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-badge {
    background: var(--ukba-accent);
    color: var(--ukba-primary-dark);
    font-weight: 700;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.sidebar-title-main {
    font-weight: 700;
    font-size: 1.05rem;
    color: white;
    line-height: 1.15;
    letter-spacing: 0.3px;
}

.sidebar-title-sub {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.75);
    margin-top: 3px;
    letter-spacing: 0.2px;
}

.sidebar-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}
.sidebar-close:hover { background: rgba(255,255,255,0.1); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 0.85rem;
}

.sidebar-nav .nav-section-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ukba-accent);
    padding: 1rem 0.85rem 0.5rem;
    font-weight: 700;
    opacity: 0.95;
}
.sidebar-nav .nav-section-label:first-child {
    padding-top: 0.25rem;
}

.sidebar-nav a.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.78rem 0.95rem;
    color: rgba(255,255,255,0.92);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 0.98rem;
    font-weight: 500;
    letter-spacing: 0.2px;
    margin-bottom: 3px;
    position: relative;
}

.sidebar-nav a.nav-item:hover {
    background: rgba(255,255,255,0.12);
    color: #ffffff;
    transform: translateX(2px);
}

.sidebar-nav a.nav-item.active {
    background: linear-gradient(90deg, rgba(197, 165, 114, 0.32), rgba(197, 165, 114, 0.08));
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.sidebar-nav a.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 18%;
    bottom: 18%;
    width: 4px;
    background: var(--ukba-accent);
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 8px rgba(197, 165, 114, 0.6);
}

.sidebar-nav a.nav-item i {
    font-size: 1.25rem;
    width: 26px;
    display: inline-flex;
    justify-content: center;
    opacity: 1;
    color: rgba(255,255,255,0.85);
}
.sidebar-nav a.nav-item:hover i {
    color: #ffffff;
}
.sidebar-nav a.nav-item.active i {
    color: var(--ukba-accent);
    opacity: 1;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    position: relative;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.user-card:hover { background: rgba(255,255,255,0.08); }

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ukba-accent), var(--ukba-accent-dark));
    color: var(--ukba-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

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

.user-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.2px;
}

.user-role {
    font-size: 0.74rem;
    color: var(--ukba-accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-top: 2px;
}

.user-menu-icon {
    color: rgba(255,255,255,0.5);
    font-size: 1rem;
}

.user-menu {
    position: absolute;
    bottom: calc(100% - 0.5rem);
    left: 0.75rem;
    right: 0.75rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    z-index: 10;
    animation: menuFadeIn 0.15s ease;
}

@keyframes menuFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-menu a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    transition: var(--transition);
}
.user-menu a:hover { background: var(--bg); }
.user-menu a.text-danger:hover { background: #fef2f2; color: #dc2626; }
.user-menu hr { margin: 0.35rem 0; border-color: var(--border); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
}
.sidebar-overlay.show { display: block; }

/* ==================== MAIN / TOPBAR ==================== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
}

.topbar-toggle, .topbar-btn {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.25rem;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.topbar-toggle:hover, .topbar-btn:hover { background: var(--bg); }

.topbar-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

main {
    flex: 1;
    padding: 1.75rem;
}

/* ==================== CARDS ==================== */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    height: 100%;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--ukba-primary);
}
.stat-card.accent::before { background: var(--ukba-accent); }
.stat-card.success::before { background: #10b981; }
.stat-card.warning::before { background: #f59e0b; }
.stat-card.danger::before { background: #ef4444; }

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin: 0;
    font-weight: 500;
}

.member-detail-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

/* ==================== BUTTONS ==================== */
.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-primary {
    background: var(--ukba-primary);
    border-color: var(--ukba-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--ukba-primary-dark);
    border-color: var(--ukba-primary-dark);
}

/* ==================== FORMS ==================== */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--ukba-primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

/* ==================== TABLES ==================== */
.table-hover tbody tr { cursor: pointer; }
.table {
    color: var(--text);
    margin-bottom: 0;
}
.table thead.table-light {
    background: var(--bg);
}

/* ==================== BADGES ==================== */
.status-badge {
    font-size: 0.72rem;
    padding: 0.35em 0.7em;
    font-weight: 600;
    border-radius: 20px;
}
.status-aktiv { background: #d1fae5; color: #065f46; }
.status-afmeldt { background: #fee2e2; color: #991b1b; }
.status-under_oprettelse { background: #fef3c7; color: #92400e; }
.status-afdoed { background: #e5e7eb; color: #1f2937; border: 1px solid #6b7280; }

/* ==================== PAGE HEADER ==================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h2 {
    margin: 0;
    color: var(--text);
    font-weight: 600;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.page-header h2 i {
    color: var(--ukba-primary);
}

/* ==================== FILTER BAR ==================== */
.filter-bar {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

/* ==================== MISC ==================== */
.cpr-display {
    font-family: 'SF Mono', Monaco, monospace;
    background: var(--bg);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.log-entry {
    border-left: 3px solid var(--border);
    padding: 0.6rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg);
    font-size: 0.88rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.log-entry .log-time { color: var(--text-muted); font-size: 0.78rem; }
.log-entry .log-user { font-weight: 600; color: var(--ukba-primary); }

.activity-item {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.activity-item:last-child { border-bottom: none; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; opacity: 0.4; }

.sub-member-row { background: var(--bg) !important; }
.sub-member-row td:first-child::before { content: "↳ "; color: var(--text-muted); }

#twofa-qr img {
    max-width: 220px;
    margin: 1rem auto;
    border-radius: var(--radius);
}

/* ==================== MODALS ==================== */
.modal-content {
    border-radius: var(--radius);
    border: none;
    box-shadow: var(--shadow-lg);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    main { padding: 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* Dark mode adjustments */
[data-theme="dark"] .user-menu a.text-danger:hover { background: rgba(220,38,38,0.15); }
[data-theme="dark"] .table { color: var(--text); }
[data-theme="dark"] .table thead.table-light {
    background: #0f172a !important;
    color: var(--text);
}
[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: transparent;
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .btn-close {
    filter: invert(1);
}
[data-theme="dark"] .form-control, [data-theme="dark"] .form-select {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .modal-content {
    background: var(--surface);
    color: var(--text);
}
