/* ============================================
   Planner.bodyshopmanager.dk - Stylesheet
   Kapacitetsplanlægning for autolakerere
   ============================================ */

html {
    overflow-x: clip;
}

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

:root {
    --primary:       #1a56db;
    --primary-dark:  #1244b0;
    --primary-light: #e8effc;
    --accent:        #f59e0b;
    --accent-dark:   #d97706;
    --success:       #10b981;
    --danger:        #ef4444;
    --warning:       #f59e0b;
    --info:          #3b82f6;
    --dark:          #1e293b;
    --gray-50:       #f8fafc;
    --gray-100:      #f1f5f9;
    --gray-200:      #e2e8f0;
    --gray-300:      #cbd5e1;
    --gray-400:      #94a3b8;
    --gray-500:      #64748b;
    --gray-600:      #475569;
    --gray-700:      #334155;
    --gray-800:      #1e293b;
    --gray-900:      #0f172a;
    --white:         #ffffff;
    --radius:        8px;
    --radius-lg:     12px;
    --shadow:        0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md:     0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg:     0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl:     0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --transition:    all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: clip;
}

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

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

/* ============================================
   LOGO
   ============================================ */

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -1px;
    box-shadow: 0 2px 8px rgba(26, 86, 219, 0.3);
}

.logo-icon svg {
    width: 26px;
    height: 26px;
    fill: var(--white);
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.logo-text .brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.5px;
}

.logo-text .sub {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #1a56db 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 800px;
    height: 800px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(26, 86, 219, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 80px;
    position: relative;
    z-index: 1;
}

.login-left .logo {
    position: absolute;
    top: 40px;
    left: 80px;
}

.login-left .logo .logo-icon {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-left .logo .brand {
    color: var(--white);
}

.login-left .logo .sub {
    color: rgba(255, 255, 255, 0.5);
}

.login-hero {
    max-width: 480px;
}

.login-hero h1 {
    font-size: 42px;
    font-weight: 800;
    color: var(--white);
    line-height: 1.15;
    margin-bottom: 20px;
    letter-spacing: -1px;
}

.login-hero h1 span {
    background: linear-gradient(135deg, var(--accent), #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-hero p {
    font-size: 17px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.7;
    max-width: 400px;
}

.login-features {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 40px;
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

.login-feature-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.login-feature-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.login-right {
    width: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    z-index: 1;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-xl), 0 0 60px rgba(0, 0, 0, 0.15);
}

.login-card h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.login-card .subtitle {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 32px;
}

/* ============================================
   FORMS
   ============================================ */

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

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-group {
    margin-bottom: 0;
}

.card-body > .form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control,
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="tel"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-800);
    transition: var(--transition);
    font-family: inherit;
    box-sizing: border-box;
}

.form-control:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.form-control::placeholder,
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--gray-400);
}

.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper .form-control {
    padding-left: 42px;
    background: #fff;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--gray-400);
    pointer-events: none;
    z-index: 1;
}

.input-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    box-shadow: 0 2px 8px rgba(26, 86, 219, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: var(--white);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: var(--white);
}

.btn-danger:hover {
    transform: translateY(-1px);
}

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

.btn-outline:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ============================================
   LAYOUT - SIDEBAR + MAIN
   ============================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 300px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.25s ease, transform 0.25s ease;
    overflow: hidden;
}

/* Mobil-menu (hamburger + drawer-overlay) — skjult på desktop, vises kun i @media ≤768px */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #1e293b;
    color: #fff;
    border: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.mobile-menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 1000;
}

/* Toggle-knap */
.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--gray-400);
    border-radius: 6px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.sidebar .expand-icon { display: none; }
.sidebar .collapse-icon { display: block; }

/* Collapsed state */
.sidebar.collapsed {
    width: 68px;
}
.sidebar.collapsed .collapse-icon { display: none; }
.sidebar.collapsed .expand-icon { display: block; }

.sidebar.collapsed .logo-text { display: none; }
.sidebar.collapsed .sidebar-header { padding: 12px 8px 8px; }
.sidebar.collapsed .sidebar-header-top { justify-content: center; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.sidebar.collapsed .sidebar-header .logo { justify-content: center; }
.sidebar.collapsed .sidebar-header-bar { justify-content: center; gap: 2px; }
.sidebar.collapsed #onlineUsersBtn .sidebar-online-label { display: none; }
.sidebar.collapsed #onlineCount { display: none; }
.sidebar.collapsed #notifBarInline { margin: 0; }
.sidebar.collapsed #notifDropdown { left: 72px !important; width: 300px !important; position: fixed !important; }
.sidebar.collapsed #onlineDropdown { left: 72px !important; position: fixed !important; }
.sidebar.collapsed .sidebar-section-title { display: none; }
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px;
    font-size: 0;
    gap: 0;
    overflow: hidden;
    white-space: nowrap;
}
.sidebar.collapsed .nav-item svg {
    font-size: 14px;
    flex-shrink: 0;
}
.sidebar.collapsed .nav-dropdown-toggle { font-size: 0; gap: 0; }
.sidebar.collapsed .nav-dropdown-arrow { display: none; }
.sidebar.collapsed .nav-dropdown-menu { display: none !important; }
.sidebar.collapsed .nav-sub-item { display: none; }
.sidebar.collapsed .sidebar-user-info { display: none; }
.sidebar.collapsed .sidebar-user a[href="/logout.php"] { display: none; }
.sidebar.collapsed .sidebar-footer { padding: 12px; }
.sidebar.collapsed .tenant-switch { display: none; }
.sidebar.collapsed .sidebar-user { justify-content: center; }
.sidebar.collapsed .sidebar-user > a { gap: 0; justify-content: center; }
.sidebar.collapsed .sidebar-nav { padding: 8px 6px; }
.sidebar.collapsed .sidebar-toggle-btn { margin: 0; }

/* Tooltip ved hover i collapsed */
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    background: var(--gray-900);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 200;
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

.sidebar-header {
    padding: 16px 20px 10px;
    border-bottom: 1px solid var(--gray-200);
}
.sidebar-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.sidebar-header-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}
.sidebar-bar-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s;
}
.sidebar-bar-btn:hover { background: #f1f5f9; }

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

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

.sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gray-400);
    padding: 0 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}
.sidebar-section-title:hover { color: var(--gray-300); }
.sidebar-section-title .section-arrow {
    transition: transform 0.2s;
    opacity: 0.6;
    flex-shrink: 0;
}
.sidebar-section.section-collapsed .section-arrow { transform: rotate(-90deg); }
.sidebar-section.section-collapsed .sidebar-section-body { display: none; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--gray-600);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--gray-50);
    color: var(--gray-800);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* Sidebar dropdown */
.nav-dropdown-toggle {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    justify-content: flex-start;
    position: relative;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.nav-dropdown-arrow {
    margin-left: auto;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    opacity: 0.5;
}

.nav-dropdown.open > .nav-dropdown-toggle .nav-dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    display: none;
    flex-direction: column;
    padding-left: 18px;
    margin-top: 2px;
}

.nav-dropdown.open > .nav-dropdown-menu {
    display: flex;
}

.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px 7px 22px;
    border-radius: var(--radius);
    color: var(--gray-500);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    margin-bottom: 1px;
    position: relative;
}

.nav-sub-item::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--gray-300);
    transform: translateY(-50%);
}

.nav-sub-item:hover {
    background: var(--gray-50);
    color: var(--gray-700);
}

.nav-sub-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-sub-item.active::before {
    background: var(--primary);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
}

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

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

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

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

.sidebar-user-role {
    font-size: 11px;
    color: var(--gray-400);
    text-transform: capitalize;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    flex: 1;
    margin-left: 300px;
    min-height: 100vh;
    min-width: 0;
    overflow-x: clip;
    transition: margin-left 0.25s ease;
}
.sidebar.collapsed ~ .main-content {
    margin-left: 68px;
}

.topbar {
    height: 64px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

.topbar-title p {
    font-size: 13px;
    color: var(--gray-400);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-content {
    padding: 32px;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: 24px;
}

/* ============================================
   STAT CARDS (Dashboard)
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

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

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.stat-icon.blue {
    background: #dbeafe;
    color: var(--primary);
}

.stat-icon.green {
    background: #d1fae5;
    color: var(--success);
}

.stat-icon.amber {
    background: #fef3c7;
    color: var(--accent-dark);
}

.stat-icon.red {
    background: #fee2e2;
    color: var(--danger);
}

.stat-info h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-info .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
}

.stat-info .stat-change {
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
}

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

/* ============================================
   TABLE
   ============================================ */

.table-wrapper,
.table-responsive {
    overflow-x: auto;
}

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

th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

tr:hover td {
    background: var(--gray-50);
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-superadmin {
    background: #fce7f3;
    color: #9d174d;
}

.badge-admin {
    background: #fef3c7;
    color: #92400e;
}

.badge-planner {
    background: #dbeafe;
    color: #1e40af;
}

.badge-mekaniker {
    background: #d1fae5;
    color: #065f46;
}

.badge-active {
    background: #d1fae5;
    color: #065f46;
}

.badge-inactive {
    background: #fee2e2;
    color: #991b1b;
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--gray-100);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-200);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================
   WIDE MODAL & PERMISSIONS
   ============================================ */

.modal-wide {
    max-width: 620px;
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 8px;
}

.permissions-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-bottom: 12px;
}

/* Afdelings-checkboxes */
.dept-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
}

.dept-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
}

.dept-checkbox-item:hover {
    background: #eff6ff;
    border-color: var(--primary-light);
}

.dept-checkbox-item:has(input:checked) {
    background: #eff6ff;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.dept-checkbox-item input[type="checkbox"] {
    flex-shrink: 0;
}

.dept-checkbox-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.dept-checkbox-label {
    font-weight: 600;
    color: var(--gray-700);
}

.dept-checkbox-city {
    font-size: 11px;
    color: var(--gray-400);
    margin-left: auto;
}

.permissions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.permission-category {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.permission-category-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-500);
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--gray-200);
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 13px;
    color: var(--gray-700);
    transition: var(--transition);
}

.permission-item:hover {
    color: var(--gray-900);
}

.permission-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.permission-label {
    line-height: 1.3;
}

/* ============================================
   PERMISSION MANAGER (roller — rediger/opret)
   ============================================ */
.perm-modal { max-width: 920px; }

.perm-manager { display: flex; flex-direction: column; gap: 14px; }

.perm-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--white, #fff);
    padding: 4px 0 10px;
    border-bottom: 1px solid var(--gray-200);
}
.perm-search-wrap { position: relative; flex: 1; min-width: 200px; }
.perm-search-wrap svg {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; color: var(--gray-400); pointer-events: none;
}
.perm-search {
    width: 100%; padding: 9px 12px 9px 34px;
    border: 1.5px solid var(--gray-200); border-radius: 9px;
    font-size: 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.perm-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.perm-count { font-size: 13px; color: var(--gray-500); white-space: nowrap; }
.perm-count b { color: var(--primary); font-weight: 700; }
.perm-toolbar-actions { display: flex; gap: 8px; }

.perm-cats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    align-items: start;
}

.perm-cat {
    border: 1px solid var(--gray-200);
    border-radius: 11px;
    background: var(--white, #fff);
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}
.perm-cat.has-checked { border-color: var(--primary-light, #93c5fd); box-shadow: 0 1px 4px rgba(37,99,235,.08); }

.perm-cat-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 12px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}
.perm-cat-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.perm-cat-toggle input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.perm-cat-name {
    font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
    color: var(--gray-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.perm-cat-count {
    font-size: 11px; font-weight: 700; color: var(--gray-400);
    background: var(--white, #fff); border: 1px solid var(--gray-200);
    border-radius: 999px; padding: 1px 8px; white-space: nowrap; flex-shrink: 0;
}
.perm-cat.has-checked .perm-cat-count { color: var(--primary); border-color: var(--primary-light, #93c5fd); }

.perm-cat-body { padding: 6px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.perm-cat-body .permission-item {
    padding: 6px 8px; border-radius: 7px; gap: 9px; align-items: flex-start;
}
.perm-cat-body .permission-item:hover { background: var(--gray-50); }
.perm-cat-body .permission-item:has(input:checked) { background: #eff6ff; }

.perm-empty { text-align: center; padding: 28px; color: var(--gray-400); font-size: 13px; }

@media (max-width: 640px) {
    .perm-cats { grid-template-columns: 1fr; }
    .perm-toolbar { flex-direction: column; align-items: stretch; }
    .perm-toolbar-actions { justify-content: flex-end; }
}

/* ============================================
   ROLE CARDS
   ============================================ */

.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
}

.role-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.role-card-header {
    padding: 20px 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-100);
}

.role-card-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.role-card-desc {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 6px;
}

.role-card-meta {
    flex-shrink: 0;
}

.role-user-count {
    font-size: 12px;
    color: var(--gray-400);
    background: var(--gray-100);
    padding: 4px 10px;
    border-radius: 50px;
    font-weight: 500;
}

.role-card-permissions {
    padding: 16px 24px;
}

.role-perm-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-400);
    margin-bottom: 12px;
}

.role-perm-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.role-perm-category {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.role-perm-cat-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    width: 100%;
    margin-bottom: 2px;
}

.role-perm-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.role-perm-tag.active {
    background: #d1fae5;
    color: #065f46;
}

.role-perm-tag.inactive {
    background: var(--gray-100);
    color: var(--gray-400);
    text-decoration: line-through;
}

.role-card-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 8px;
}

/* ============================================
   403 PAGE
   ============================================ */

.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.error-page h1 {
    font-size: 80px;
    font-weight: 800;
    color: var(--gray-200);
}

.error-page h2 {
    font-size: 24px;
    color: var(--gray-800);
    margin-bottom: 12px;
}

.error-page p {
    color: var(--gray-500);
    margin-bottom: 24px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .login-left {
        padding: 40px;
    }

    .login-left .logo {
        left: 40px;
    }

    .login-hero h1 {
        font-size: 32px;
    }
}

@media (max-width: 768px) {
    .login-wrapper {
        flex-direction: column;
    }

    .login-left {
        padding: 100px 30px 40px;
    }

    .login-left .logo {
        left: 30px;
        top: 30px;
    }

    .login-hero h1 {
        font-size: 28px;
    }

    .login-right {
        width: 100%;
        padding: 20px;
    }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        z-index: 1002;
        box-shadow: 0 0 50px rgba(0,0,0,0.35);
    }

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

    /* Vis hamburger-knap og overlay på mobil */
    .mobile-menu-btn { display: flex; }
    .mobile-menu-backdrop.show { display: block; }
    /* Plads til hamburger-knappen øverst */
    .main-content { padding-top: 60px; }

    /* Formularer: to-kolonne-layouts stakkes til én kolonne på mobil */
    .form-row { grid-template-columns: 1fr; }
    .permissions-grid { grid-template-columns: 1fr; }
    .form-actions { flex-wrap: wrap; }
    .form-actions .btn { flex: 1 1 auto; }
}

/* ============================================
   TOPMENU — Systemindstillinger → Menu-placering
   Står indstillingen på "top", får <html> klassen nav-top i header.php, og
   sidemenuens egen markup lægges vandret: hver sektion bliver en dropdown.
   Rettighedstjekkene i header.php er dermed stadig det eneste sted, der afgør
   hvilke menupunkter en bruger ser.
   Bjælken er sticky og følger med ved scroll. .topbar, filterkortet i orders.php
   og andre elementer der i forvejen er sticky med top:0 mod selve siden, ville
   lægge sig under den — footer.php rykker dem ned med bjælkens højde.
   På mobil (≤768px) gælder intet af det her — der er det hamburger-draweren.
   ============================================ */
@media (min-width: 769px) {
    html.nav-top { scroll-padding-top: 64px; }   /* ankerlinks (#kort) må ikke lande under bjælken */
    html.nav-top .app-layout { flex-direction: column; }

    html.nav-top .sidebar {
        position: sticky;
        top: 0;
        left: auto;
        bottom: auto;
        width: 100% !important;
        height: 52px;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        padding: 0 14px 0 16px;
        border-right: 0;
        border-bottom: 1px solid var(--gray-200);
        overflow: visible;
        transition: none;
        z-index: 900;
    }
    html.nav-top .sidebar.nav-stuck { box-shadow: 0 4px 14px rgba(15,23,42,.08); }   /* sat af footer.php, når der er rullet */
    /* "Du ser systemet som …"-bjælken har z-index 999 i header.php og lagde sig over menuens
       dropdowns. Menuen kan ikke løftes over 999 uden at ramme modalerne på 1000, så bjælken
       sænkes i stedet — stadig over sidernes egne sticky-elementer (topbar 50, filterkort 200). */
    html.nav-top #impersonation-banner { z-index: 800 !important; }
    html.nav-top .main-content { margin-left: 0 !important; }

    /* Logo til venstre, menuen i midten, klokke/chat og bruger til højre */
    html.nav-top .sidebar-header { display: contents; }
    html.nav-top .sidebar-header-top { order: 0; margin: 0 12px 0 0; flex: none; }
    html.nav-top .sidebar-toggle-btn { display: none; }
    html.nav-top .logo { gap: 9px; }
    html.nav-top .logo-icon { width: 32px; height: 32px; }
    html.nav-top .logo-icon svg { width: 18px; height: 18px; }
    html.nav-top .logo-text .brand { font-size: 16px; }
    html.nav-top .logo-text .sub { display: none; }
    html.nav-top .sidebar-header-bar { order: 2; margin-left: auto; padding: 0 0 0 8px; flex: none; }
    html.nav-top .sidebar-footer { order: 3; padding: 0 0 0 8px; border-top: 0; flex: none; display: flex; align-items: center; gap: 6px; }
    /* "Installér app" som lille ikon i bjælken — JS'en i header.php afgør stadig om den vises (display:flex/none) */
    html.nav-top #pwaInstallBtn { width: 32px !important; height: 32px; margin: 0 !important; padding: 0 !important; border-radius: 8px !important; }
    html.nav-top #pwaInstallBtn .pwa-lbl { display: none; }
    html.nav-top .sidebar-user { gap: 4px; }
    html.nav-top .sidebar-user-info { display: none; }
    html.nav-top .sidebar-user-avatar { width: 32px; height: 32px; font-size: 12px; }
    /* Koncernvælgeren i bjælken: ingen overskrift (den står i title), samme højde som ikonerne */
    html.nav-top .tenant-switch { margin: 0 !important; }
    html.nav-top .tenant-switch label { display: none !important; }
    html.nav-top .tenant-switch select { height: 32px; padding: 0 6px !important; font-size: 12.5px !important; max-width: 150px; width: auto !important; }

    html.nav-top .sidebar-nav {
        order: 1;
        flex: 1 1 auto;
        min-width: 0;
        height: 100%;
        display: flex;
        align-items: stretch;
        gap: 1px;
        padding: 0;
        overflow: visible;
    }
    html.nav-top .sidebar-section {
        position: relative;
        flex: none;
        display: flex;
        align-items: center;
        margin: 0;
    }
    /* Indtil footer.php har pakket punkterne ind i en dropdown, må de ikke stå i bjælken */
    html.nav-top .sidebar-nav > .sidebar-section > :not(.sidebar-section-title):not(.sidebar-section-body) { display: none; }

    html.nav-top .sidebar-section-title {
        height: 34px;
        margin: 0;
        padding: 0 10px;
        gap: 4px;
        justify-content: flex-start;
        border-radius: 7px;
        font-size: 13.5px;
        font-weight: 500;
        letter-spacing: 0;
        text-transform: none;
        color: var(--gray-700);
        white-space: nowrap;
    }
    html.nav-top .sidebar-section-title:hover { background: var(--gray-100); color: var(--gray-900); }
    html.nav-top .sidebar-section-title .section-arrow { transform: none; opacity: .5; }
    html.nav-top .sidebar-section.nav-open > .sidebar-section-title { background: var(--primary-light); color: var(--primary); }
    html.nav-top .sidebar-section.nav-open > .sidebar-section-title .section-arrow { transform: rotate(180deg); opacity: 1; }
    /* Sektionen med den side man står på, får en streg under sig */
    html.nav-top .sidebar-nav > .sidebar-section:has(.active) > .sidebar-section-title { color: var(--primary); font-weight: 600; }
    html.nav-top .sidebar-nav > .sidebar-section:has(.active)::after {
        content: "";
        position: absolute;
        left: 10px;
        right: 10px;
        bottom: 0;
        height: 2px;
        border-radius: 2px 2px 0 0;
        background: var(--primary);
    }

    /* Dropdown-panelet */
    html.nav-top .sidebar-section-body,
    html.nav-top .sidebar-section.section-collapsed .sidebar-section-body {
        display: none;
        position: absolute;
        top: calc(100% - 4px);
        left: 0;
        min-width: 240px;
        max-height: calc(100vh - 64px);
        overflow-y: auto;
        padding: 6px;
        background: var(--white);
        border: 1px solid var(--gray-200);
        border-radius: 10px;
        box-shadow: 0 16px 36px rgba(15,23,42,.16);
        z-index: 950;
    }
    html.nav-top .sidebar-section.nav-open > .sidebar-section-body { display: block; }
    /* Lange sektioner (Administration) deles i to kolonner i stedet for én lang liste */
    html.nav-top .sidebar-section-body:has(> :nth-child(9)) { columns: 2; column-gap: 8px; width: 520px; }

    html.nav-top .sidebar-section-body .nav-item {
        margin: 0;
        padding: 8px 10px;
        font-size: 13.5px;
        white-space: nowrap;
    }
    html.nav-top .sidebar-section-body .nav-item::after { content: none; }
    html.nav-top .sidebar-section-body .nav-dropdown { break-inside: avoid; }
    /* Undermenuer (Brugere, Kunder, Logs, workflow-afdelinger) står foldet ud under en overskrift */
    html.nav-top .sidebar-section-body .nav-dropdown-toggle,
    html.nav-top .sidebar-section-body .nav-dropdown-toggle:hover {
        cursor: default;
        padding: 10px 10px 4px;
        background: none;
        color: var(--gray-400);
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: .08em;
        text-transform: uppercase;
    }
    html.nav-top .sidebar-section-body .nav-dropdown-toggle svg { display: none; }
    html.nav-top .sidebar-section-body .nav-dropdown-menu { display: flex; padding-left: 0; margin: 0; }
    html.nav-top .sidebar-section-body .nav-sub-item { white-space: nowrap; }

    /* »Mere« — sektioner der ikke kan være i bjælken, flyttes herind af footer.php */
    html.nav-top .nav-more { display: none; }
    html.nav-top .nav-more.has-items { display: flex; }
    html.nav-top .nav-more > .sidebar-section-body { left: auto; right: 0; min-width: 260px; }
    html.nav-top .nav-more .sidebar-section { display: block; }
    html.nav-top .nav-more .sidebar-section + .sidebar-section { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--gray-100); }
    html.nav-top .nav-more .sidebar-section .sidebar-section-title {
        height: auto;
        padding: 8px 10px 4px;
        pointer-events: none;
        background: none;
        color: var(--gray-400);
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: .08em;
        text-transform: uppercase;
    }
    html.nav-top .nav-more .sidebar-section .section-arrow { display: none; }
    html.nav-top .nav-more .sidebar-section .sidebar-section-body {
        display: block;
        position: static;
        width: auto;
        min-width: 0;
        max-height: none;
        overflow: visible;
        columns: auto;
        padding: 0;
        border: 0;
        box-shadow: none;
    }
}

