/* Modern tabell-design */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}
.admin-table th, .admin-table td {
    padding: 12px 15px;
    text-align: left;
}
.admin-table th {
    background: #3c8dbc;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.admin-table tr:nth-child(even) {
    background: #f9f9f9;
}
.admin-table tr:hover {
    background: #f1f1f1;
}
.admin-table td {
    border-bottom: 1px solid #e9e9e9;
    color: #555;
    font-size: 14px;
}
.admin-table tr:last-child td {
    border-bottom: none;
}
.admin-table th:first-child, .admin-table td:first-child {
    border-top-left-radius: 4px;
}
.admin-table th:last-child, .admin-table td:last-child {
    border-top-right-radius: 4px;
}
@media (max-width: 700px) {
    .admin-table th, .admin-table td {
        padding: 8px 6px;
        font-size: 12px;
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ecf0f5;
    margin: 0;
    padding: 0;
    color: #333;
}

/* Dark theme variables */
:root {
    --c-bg: #0f171f;
    --c-bg-alt: #16222c;
    --c-bg-alt2: #1e2a36;
    --c-surface: #243443;
    --c-surface-alt: #2f4151;
    --c-border: #2d3e4c;
    --c-border-alt: #3a5468;
    --c-text: #e5eef5;
    --c-text-muted: #98a7b4;
    --c-primary: #3c8dbc; /* existing brand blue */
    --c-primary-hover: #357ca5;
    --c-accent: #4aa3df;
    --c-danger: #dd4b39;
    --c-warning: #f39c12;
    --c-success: #00a65a;
    --c-sidebar: #2c3e50; /* base sidebar */
}

body.theme-dark {
    background: var(--c-bg);
    color: var(--c-text);
}
body.theme-dark .sidebar { background: var(--c-sidebar); }
body.theme-dark .sidebar-title { background: #243342; border-bottom: 1px solid #1a252f; }
body.theme-dark .main-content { background: var(--c-bg); }
body.theme-dark .content { background: var(--c-bg); color: var(--c-text); }
body.theme-dark h1, body.theme-dark h2, body.theme-dark h3, body.theme-dark h4 { color: var(--c-text); border-color: var(--c-border); }
body.theme-dark .admin-table { background: var(--c-surface); box-shadow: 0 1px 3px rgba(0,0,0,0.6); }
body.theme-dark .admin-table th { background: var(--c-primary); color: #fff; }
body.theme-dark .admin-table tr:nth-child(even) { background: var(--c-bg-alt); }
body.theme-dark .admin-table tr:hover { background: var(--c-bg-alt2); }
body.theme-dark .admin-table td { border-bottom: 1px solid var(--c-border); color: var(--c-text-muted); }
body.theme-dark .topbar { background: var(--c-sidebar); box-shadow: 0 2px 6px rgba(0,0,0,0.6); }
body.theme-dark .topbar-left span, body.theme-dark .topbar-right { color: var(--c-text); }
body.theme-dark .logout-btn { background: var(--c-danger); }
body.theme-dark .logout-btn:hover { background: #c23321; }
/* Dark overrides for new booking components */
body.theme-dark .filter-card,
body.theme-dark .bookings-table,
body.theme-dark .bookings-table table,
body.theme-dark .bookings-footer { background: var(--c-surface); color: var(--c-text); }
body.theme-dark .filter-card { border:1px solid var(--c-border); box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
body.theme-dark .bookings-table { border:1px solid var(--c-border); box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
body.theme-dark .bookings-table thead { background: var(--c-sidebar); color:#fff; }
body.theme-dark .bookings-table tbody tr { border-bottom:1px solid var(--c-border); }
body.theme-dark .bookings-table tbody tr:hover { background: var(--c-surface-alt); }
body.theme-dark .status-tab { background: var(--c-surface-alt); color: var(--c-text-muted); }
body.theme-dark .status-tab.active { background: var(--c-primary); color:#fff; box-shadow: 0 2px 6px rgba(0,0,0,0.5); }
body.theme-dark .status-tab:not(.active):hover { background: var(--c-surface); color: var(--c-text); }
body.theme-dark .booking-type-badge { background: var(--c-surface-alt); border:2px solid var(--c-border); color: var(--c-text); }
body.theme-dark .status-badge { background: transparent; }
body.theme-dark .bookings-footer { border:1px solid var(--c-border); }
body.theme-dark .filter-grid input,
body.theme-dark .filter-grid select { background: var(--c-surface-alt); border:1px solid var(--c-border); color: var(--c-text); }
body.theme-dark .filter-grid button { background: var(--c-primary); box-shadow: 0 2px 8px rgba(0,0,0,0.5); }
body.theme-dark .filter-grid button:hover { background: var(--c-primary-hover); }
body.theme-dark input[type="text"],
body.theme-dark input[type="password"],
body.theme-dark input[type="email"],
body.theme-dark input[type="date"],
body.theme-dark input[type="time"],
body.theme-dark input[type="number"],
body.theme-dark select,
body.theme-dark textarea { background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text); }
body.theme-dark input:focus, body.theme-dark select:focus, body.theme-dark textarea:focus { border-color: var(--c-primary); box-shadow: 0 0 0 2px rgba(60,141,188,0.25); }
body.theme-dark button, body.theme-dark .btn { background: var(--c-primary); }
body.theme-dark button:hover, body.theme-dark .btn:hover { background: var(--c-primary-hover); }
/* Do not paint background for the account menu trigger, even though it's a button */
body.theme-dark .account-menu-btn { background: transparent !important; }
body.theme-dark .account-menu-btn:hover { background: transparent !important; }
body.theme-dark .info-box { background: var(--c-surface); box-shadow: 0 1px 3px rgba(0,0,0,0.5); }
body.theme-dark .info-box-text { color: var(--c-text-muted); }
body.theme-dark .info-box-number { color: var(--c-text); }
body.theme-dark .alert-success { background: rgba(0,166,90,0.15); color: var(--c-text); border-color: var(--c-success); }
body.theme-dark .alert-info { background: rgba(60,141,188,0.18); color: var(--c-text); border-color: var(--c-primary); }
body.theme-dark .alert-warning { background: rgba(243,156,18,0.18); color: var(--c-text); border-color: var(--c-warning); }
body.theme-dark .alert-danger { background: rgba(221,75,57,0.18); color: var(--c-text); border-color: var(--c-danger); }
body.theme-dark .error { background: rgba(221,75,57,0.2); color: #ffb7b0; border-color: var(--c-danger); }
body.theme-dark .nav-groups a { color: #c8d2db; }
body.theme-dark .nav-groups a:hover { background: #1e2e3d; color: #fff; }
body.theme-dark .nav-groups a.active { background: #1e2e3d; color: #fff; }
body.theme-dark .nav-group { background: var(--c-bg-alt2); border-color: var(--c-border); }
body.theme-dark .nav-group-toggle { color: var(--c-text); }
body.theme-dark .user-chip { background: #1f2c3d; color: #e2e8f0; }
body.theme-dark a { color: var(--c-accent); }
body.theme-dark a:hover { color: #6bb9ff; }
body.theme-dark .mailbox-link { background: #1f2c3d; }
/* Ensure page canvases stay dark */
body.theme-dark .main-content,
body.theme-dark .content { background: var(--c-bg) !important; color: var(--c-text); }
/* Extra specificity to kill residual light stripe behind booking header */
body.theme-dark .booking-view { background: var(--c-bg) !important; }
body.theme-dark .booking-view > div:not(.info-card):not(.status-card):not(.notes-section):not(.edit-card) { color: var(--c-text); }

/* --- Dark theme: Booking detail/edit overrides --- */
/* Card containers on booking pages */
body.theme-dark .info-card,
body.theme-dark .status-card,
body.theme-dark .notes-section,
body.theme-dark .edit-card { background: var(--c-surface) !important; color: var(--c-text) !important; border: 1px solid var(--c-border) !important; box-shadow: 0 2px 8px rgba(0,0,0,0.45) !important; }
body.theme-dark .note-item { background: var(--c-surface-alt) !important; border-left-color: var(--c-primary) !important; }
/* Notification card inside booking view */
body.theme-dark .notif-card { background: var(--c-surface-alt) !important; border:1px solid var(--c-border) !important; color: var(--c-text) !important; }
body.theme-dark .note-meta, body.theme-dark .detail-label { color: var(--c-text-muted) !important; }
body.theme-dark .detail-value, body.theme-dark .info-card h3 { color: var(--c-text) !important; }
body.theme-dark .note-form, body.theme-dark .note-form textarea { border-color: var(--c-border) !important; }
body.theme-dark .note-form textarea { background: var(--c-surface-alt) !important; color: var(--c-text) !important; }
/* Inputs/selects inside booking forms */
body.theme-dark .form-input,
body.theme-dark .edit-card input,
body.theme-dark .edit-card select,
body.theme-dark .edit-card textarea { background: var(--c-surface-alt) !important; border: 1px solid var(--c-border) !important; color: var(--c-text) !important; }
body.theme-dark .form-input:focus { border-color: var(--c-primary) !important; box-shadow: 0 0 0 2px rgba(60,141,188,0.25) !important; }
/* Status chips */
body.theme-dark .status-badge { border: 1px solid var(--c-border); }
body.theme-dark .status-pending { background: rgba(243,156,18,0.18) !important; color: var(--c-text) !important; border-color: var(--c-warning) !important; }
body.theme-dark .status-prepared { background: rgba(60,141,188,0.18) !important; color: var(--c-text) !important; border-color: var(--c-primary) !important; }
body.theme-dark .status-confirmed { background: rgba(0,166,90,0.15) !important; color: var(--c-text) !important; border-color: var(--c-success) !important; }
body.theme-dark .status-in_progress { background: rgba(60,141,188,0.18) !important; color: var(--c-text) !important; border-color: var(--c-primary) !important; }
body.theme-dark .status-completed { background: rgba(0,166,90,0.18) !important; color: var(--c-text) !important; border-color: var(--c-success) !important; }
body.theme-dark .status-invoiced { background: rgba(58,84,104,0.25) !important; color: var(--c-text) !important; border-color: var(--c-border-alt) !important; }
body.theme-dark .status-cancelled { background: rgba(221,75,57,0.18) !important; color: #ffb7b0 !important; border-color: var(--c-danger) !important; }
/* Buttons */
body.theme-dark .btn-primary { background: var(--c-primary) !important; color:#fff !important; }
body.theme-dark .btn-primary:hover { background: var(--c-primary-hover) !important; }
body.theme-dark .btn-secondary { background: var(--c-surface-alt) !important; color: var(--c-text) !important; border: 1px solid var(--c-border) !important; }
/* Custom select styling + arrow in dark mode */
body.theme-dark select {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-color: var(--c-surface-alt);
    color: var(--c-text);
    border: 1px solid var(--c-border);
    padding-right: 36px; /* room for arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 12px;
}
body.theme-dark select:focus { border-color: var(--c-primary); box-shadow: 0 0 0 2px rgba(60,141,188,0.25); }
body.theme-dark select option { background: var(--c-surface); color: var(--c-text); }

/* Inline-style light backgrounds -> dark equivalents */
/* Additional dark overrides for inline colored text & gradient headers */
body.theme-dark [style*="color:#333"],
body.theme-dark [style*="color:#444"],
body.theme-dark [style*="color:#555"],
body.theme-dark [style*="color:#666"],
body.theme-dark [style*="color:#777"],
body.theme-dark [style*="color:#888"],
body.theme-dark [style*="color:#999"],
body.theme-dark [style*="color:#1f2937"],
body.theme-dark [style*="color:#2d3748"],
body.theme-dark [style*="color:#374151"],
body.theme-dark [style*="color:#475569"] { color: var(--c-text) !important; }
body.theme-dark [style*="background:linear-gradient(135deg, #667eea"],
body.theme-dark .booking-header { background: var(--c-primary) !important; color:#fff !important; }
body.theme-dark [style*="background:rgba(255,255,255,0.95)"] { background: var(--c-surface-alt) !important; color: var(--c-text) !important; }
/* Dynamic purchase items & protocol details */
body.theme-dark .purchase-item { background: var(--c-surface-alt) !important; border-left:4px solid var(--c-primary) !important; }
body.theme-dark details[open] > div[style*="padding:16px"] { background: var(--c-surface) !important; }
body.theme-dark summary[style*="background:#fff3cd"],
body.theme-dark summary[style*="background: #fff3cd"],
body.theme-dark summary[style*="background:#e7f3ff"],
body.theme-dark summary[style*="background: #e7f3ff"] { background: var(--c-surface-alt) !important; color: var(--c-text) !important; }
body.theme-dark [style*="border-top:1px solid #e6ecf3"],
body.theme-dark [style*="border:1px solid #e6ecf3"],
body.theme-dark [style*="border:2px solid #e6ecf3"],
body.theme-dark [style*="border:1px solid #ddd"],
body.theme-dark [style*="border:2px solid #ddd"],
body.theme-dark [style*="border:1px solid #f0f0f0"],
body.theme-dark [style*="border:2px solid #f0f0f0"],
body.theme-dark [style*="border-left:4px solid #667eea"],
body.theme-dark [style*="border-left:4px solid #b3d9ff"],
body.theme-dark [style*="border:1px solid #bee5eb"],
body.theme-dark [style*="border:1px solid #c3e6cb"],
body.theme-dark [style*="border:1px solid #dee2e6"],
body.theme-dark [style*="border:1px solid #ffc107"] { border-color: var(--c-border) !important; }
/* Headings & labels inside cards */
body.theme-dark .info-card h3,
body.theme-dark .status-card h3,
body.theme-dark .notes-section h3,
body.theme-dark .edit-card h3 { color: var(--c-text) !important; border-color: var(--c-border) !important; }
body.theme-dark .detail-label,
body.theme-dark .detail-value,
body.theme-dark .note-text,
body.theme-dark .form-label { color: var(--c-text) !important; }
/* Convert old accent blue (#667eea) in dark to accent variable */
body.theme-dark [style*="color:#667eea"],
body.theme-dark a[style*="color:#667eea"] { color: var(--c-accent) !important; }
/* Headings & labels inside cards */
body.theme-dark .info-card h3,
body.theme-dark .status-card h3,
body.theme-dark .notes-section h3,
body.theme-dark .edit-card h3 { color: var(--c-text) !important; border-color: var(--c-border) !important; }
body.theme-dark .detail-label,
body.theme-dark .detail-value,
body.theme-dark .note-text,
body.theme-dark .form-label { color: var(--c-text) !important; }
/* Force dropdown/select readability */
body.theme-dark select,
body.theme-dark .status-update-form select,
body.theme-dark .form-grid select,
body.theme-dark .form-grid input,
body.theme-dark .form-grid textarea { background: var(--c-surface-alt) !important; color: var(--c-text) !important; border:1px solid var(--c-border) !important; }
body.theme-dark [style*="background:#ffffff"],
body.theme-dark [style*="background: #ffffff"],
body.theme-dark [style*="background:#fff"],
body.theme-dark [style*="background: #fff"],
body.theme-dark [style*="background:#f8f9fa"],
body.theme-dark [style*="background: #f8f9fa"],
body.theme-dark [style*="background:#f4f6f9"],
body.theme-dark [style*="background: #f4f6f9"],
body.theme-dark [style*="background:#eef2f7"],
body.theme-dark [style*="background: #eef2f7"] { background: var(--c-surface-alt) !important; color: var(--c-text) !important; }
body.theme-dark [style*="background:#fff3cd"],
body.theme-dark [style*="background: #fff3cd"] { background: rgba(243,156,18,0.18) !important; color: var(--c-text) !important; }
body.theme-dark [style*="border:1px solid #ffc107"],
body.theme-dark [style*="border: 1px solid #ffc107"] { border-color: var(--c-warning) !important; }
body.theme-dark [style*="background:#e7f3ff"],
body.theme-dark [style*="background: #e7f3ff"] { background: rgba(60,141,188,0.18) !important; color: var(--c-text) !important; }
body.theme-dark [style*="background:rgba(255,255,255"] { background: var(--c-surface) !important; color: var(--c-text) !important; }

/* Protokoll fritext svar - bättre kontrast i mörkt läge */
body.theme-dark .protocol-free-text { color: var(--c-text-muted) !important; }
/* Förbättra tabellhuvud för arbetsprotokoll i mörkt läge */
body.theme-dark table thead tr[style*="background:#e9ecef"] th { color:#fff !important; background:#2c3e50 !important; }

/* ------- review_order: radjustering och utan spinners ------- */
.invoice-edit-table td, .invoice-edit-table th { vertical-align: middle; }
.invoice-edit-table input[type="text"],
.invoice-edit-table input[type="number"],
.invoice-edit-table select {
    height: 32px !important;
    line-height: 32px !important;
    padding: 4px 2px !important;
}

/* review_order: Protokoll & Genomförd Inspektion (Generated documents) */
.ro-doc-card,
.ro-doc-meta { min-width: 0; }
.ro-doc-link { overflow-wrap: anywhere; word-break: break-word; }

@media (max-width: 640px) {
    .ro-doc-card { flex-direction: column !important; gap: 6px !important; }
    .ro-doc-actions { align-self: flex-end; }
    .ro-doc-delete { padding: 4px 8px !important; font-size: 11px !important; }
}

@media (max-width: 640px) {
    .ro-invoice-actions { flex-wrap: wrap !important; justify-content: flex-start !important; }
    .ro-invoice-actions-spacer { display: none !important; }
    .ro-invoice-actions .ro-invoice-primary-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
        max-width: 100% !important;
    }
}
/* Matcha stil: väljare som inputs (transparent + understreck) */
.invoice-edit-table select {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px dashed #5e7385 !important;
    color: #e8f0f7 !important;
    border-radius: 0 !important;
}
/* Ta bort spinners i number inputs */
.invoice-edit-table input[type=number]::-webkit-outer-spin-button,
.invoice-edit-table input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.invoice-edit-table input[type=number] { appearance: textfield; -moz-appearance: textfield; }

/* --- Dark theme: Safety Documents (chem) page overrides --- */
body.theme-dark .chem-table { border-spacing: 0 8px; }
body.theme-dark .chem-table th { background: var(--c-surface-alt) !important; color: var(--c-text) !important; }
body.theme-dark .chem-table td { background: var(--c-surface) !important; color: var(--c-text) !important; }
body.theme-dark .chem-row { box-shadow: 0 1px 3px rgba(0,0,0,0.6); }
body.theme-dark .upload-card { background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); }
body.theme-dark .info-card { background: var(--c-bg-alt); border: 1px solid var(--c-border); color: var(--c-text); }
body.theme-dark .legend-item { background: var(--c-surface); border: 1px solid var(--c-border); }
body.theme-dark .legend-item .txt { color: var(--c-text-muted) !important; }
body.theme-dark .btn-secondary { background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); }
body.theme-dark .title-link { color: var(--c-accent) !important; }
body.theme-dark .edit-link { color: var(--c-accent) !important; }
body.theme-dark .chem-header h2 { color: var(--c-text) !important; }
body.theme-dark .hazards label { background: var(--c-bg-alt); border-color: var(--c-border) !important; }
body.theme-dark .hazards span { color: var(--c-text-muted) !important; }

/* --- Dark theme: Global contrast fixes --- */
/* Force common cards/panels to dark surfaces */
body.theme-dark .dashboard-card { background: var(--c-surface) !important; color: var(--c-text) !important; border-top-color: var(--c-primary) !important; box-shadow: 0 1px 3px rgba(0,0,0,0.6) !important; }
body.theme-dark .stat-box, body.theme-dark .inspection-item { background: var(--c-surface-alt) !important; color: var(--c-text) !important; }
body.theme-dark .inspection-item.urgent { background: rgba(221,75,57,0.08) !important; }
body.theme-dark .inspection-item.ok { background: rgba(0,166,90,0.08) !important; }
body.theme-dark .inspection-item.soon { background: rgba(243,156,18,0.08) !important; }

/* Upgrade contrast for inline-styled muted texts across the app */
body.theme-dark [style*="color:#6b7a89"],
body.theme-dark [style*="color:#64748b"],
body.theme-dark [style*="color:#94a3b8"],
body.theme-dark [style*="color:#9ca3af"],
body.theme-dark [style*="color:#999"],
body.theme-dark [style*="color:#475569"],
body.theme-dark [style*="color:#31415a"],
body.theme-dark [style*="color:#1f2937"] { color: var(--c-text) !important; }

/* Normalize light backgrounds/borders inside cards to dark equivalents */
body.theme-dark [style*="background:#ffffff"],
body.theme-dark [style*="background:#fff"],
body.theme-dark [style*="background:#f8fafc"],
body.theme-dark [style*="background: #f8fafc"],
body.theme-dark [style*="background:#f4f6f9"],
body.theme-dark [style*="background: #f4f6f9"],
body.theme-dark [style*="background:#eef2f7"],
body.theme-dark [style*="background: #eef2f7"] { background: var(--c-surface-alt) !important; }

body.theme-dark [style*="border: 1px solid #e2e8f0"],
body.theme-dark [style*="border: 1px solid #d2d6de"],
body.theme-dark [style*="border:1px solid #e2e8f0"],
body.theme-dark [style*="border:1px solid #d2d6de"] { border-color: var(--c-border) !important; }

/* Small captions default to muted but readable */
body.theme-dark small, body.theme-dark .caption, body.theme-dark .stat-label { color: var(--c-text-muted) !important; }

/* Mjuk övergång till intro-animation bakgrund */
body.intro-active {
    background: #07090f;
    transition: background 0.8s ease-out;
}

.admin-wrapper {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh; /* modern viewport height to avoid mobile URL bar issues */
}

.sidebar {
    width: 240px;
    background: #2c3e50;
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 0;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    min-height: 100vh;
    min-height: 100dvh;
    position: sticky;
    top: 0;
    align-self: flex-start;
}
.sidebar-title {
    font-size: 1.4em;
    font-weight: 600;
    padding: 20px 0 15px 0;
    text-align: center;
    background: #243342;
    border-bottom: 1px solid #1a252f;
}
.sidebar nav ul {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}
.sidebar nav ul li {
    margin: 0;
}
.sidebar nav ul li a {
    display: block;
    color: #b8c7ce;
    text-decoration: none;
    padding: 14px 20px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
    font-size: 14px;
}
.sidebar nav ul li a:hover {
    background: #1e2e3d;
    color: #fff;
    border-left-color: #3c8dbc;
    padding-left: 24px;
}
.sidebar nav ul li a.active {
    background: #1e2e3d;
    color: #fff;
    border-left-color: #3c8dbc;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #ecf0f5;
    overflow-x: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #3c8dbc;
    padding: 12px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-height: 50px;
}
.topbar-left {
    font-size: 16px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 20px;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #ffffff;
}

/* External quick links in topbar (icons) */
.topbar-ext-links {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.topbar-ext-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #1f2c3d;
    color: #e2e8f0;
    text-decoration: none;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.topbar-ext-link:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.topbar-ext-link:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

.topbar-ext-link svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topbar-ext-link--autokatalogen::after {
    content: "A";
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3c8dbc;
    color: #fff;
    font-size: 10px;
    line-height: 14px;
    text-align: center;
    font-weight: 800;
}
.logout-btn {
    background: #dd4b39;
    color: #fff;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
}
.logout-btn:hover {
    background: #c23321;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.content {
    padding: 20px 20px 40px 20px;
    background: #ecf0f5;
}

/* Headings */
h1, h2, h3, h4 {
    color: #444;
    font-weight: 600;
}

h1 {
    font-size: 24px;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #d2d6de;
}

h2 {
    font-size: 20px;
    margin: 0 0 15px 0;
}

/* Info Box (för dashboard cards) */
.info-box {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    margin-bottom: 15px;
    display: flex;
    min-height: 90px;
}

.info-box-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90px;
    font-size: 40px;
    color: #fff;
    border-radius: 4px 0 0 4px;
}

.info-box-icon.bg-aqua {
    background: #00c0ef;
}

.info-box-icon.bg-green {
    background: #00a65a;
}

.info-box-icon.bg-yellow {
    background: #f39c12;
}

.info-box-icon.bg-red {
    background: #dd4b39;
}

.info-box-content {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.info-box-text {
    font-size: 12px;
    text-transform: uppercase;
    color: #666;
    font-weight: 600;
}

.info-box-number {
    font-size: 28px;
    font-weight: 700;
    color: #444;
}

/* Alert boxes */
.alert {
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    border-left: 4px solid;
}

.alert-success {
    background: #dff0d8;
    border-color: #00a65a;
    color: #3c763d;
}

.alert-info {
    background: #d9edf7;
    border-color: #3c8dbc;
    color: #31708f;
}

.alert-warning {
    background: #fcf8e3;
    border-color: #f39c12;
    color: #8a6d3b;
}

.alert-danger {
    background: #f2dede;
    border-color: #dd4b39;
    color: #a94442;
}

/* Login & Dashboard container (för inloggningssidan) */
.login-container, .dashboard-container {
    max-width: 400px;
    margin: 100px auto;
    background: #fff;
    padding: 30px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    text-align: center;
}
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="time"], input[type="number"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    margin: 6px 0;
    border: 1px solid #d2d6de;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, input[type="date"]:focus, input[type="time"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #3c8dbc;
    box-shadow: 0 0 0 2px rgba(60, 141, 188, 0.1);
}
button, .btn {
    padding: 10px 20px;
    background: #3c8dbc;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}
button:hover, .btn:hover {
    background: #357ca5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
button.btn-success {
    background: #00a65a;
}
button.btn-success:hover {
    background: #008d4c;
}
button.btn-danger {
    background: #dd4b39;
}
button.btn-danger:hover {
    background: #c23321;
}
button.btn-warning {
    background: #f39c12;
}
button.btn-warning:hover {
    background: #e08e0b;
}
.error {
    color: #dd4b39;
    margin-bottom: 10px;
    background: #f2dede;
    padding: 10px;
    border-radius: 4px;
    border-left: 4px solid #dd4b39;
}

@media (max-width: 900px) {
    .admin-wrapper {
        flex-direction: column;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: -240px;
        width: 240px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 8px rgba(0,0,0,0.3);
    }
    .sidebar.open {
        left: 0;
    }
    .sidebar-title {
        padding: 12px 0;
        font-size: 1.2em;
    }
    .sidebar nav ul {
        display: block;
    }
    .sidebar nav ul li a {
        padding: 14px 20px;
    }
    .main-content {
        margin-left: 0;
    }
}

/* Hamburger Menu Button */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    margin-right: 12px;
}

.hamburger-btn span {
    width: 28px;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.hamburger-btn.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

@media (max-width: 900px) {
    .hamburger-btn {
        display: flex;
    }
}

@media (max-width: 900px) {
    .topbar, .content {
        padding: 12px 8px;
    }
    .sidebar {
        font-size: 0.95em;
    }
    .sidebar-title {
        font-size: 1em;
    }
    .main-content {
        min-width: 0;
    }
    
    /* Hide some topbar items + simplify spacing on mobile (<=900px) */
    .topbar-left { gap: 10px; }
    .topbar-left .topbar-title, .topbar-left .logo-text { display: none; }
    .topbar-left .copyright-text { display: none; }
    .topbar-logo-mobile { display: none !important; }
    .topbar-right span { font-size: 12px; }
    .account-menu-btn .user-chip { display: none; }
    .account-menu-btn { padding: 0; }
    .account-avatar { width: 40px; height: 40px; }

    .topbar-ext-link {
        width: 38px;
        height: 38px;
    }
    
    /* Fix create_booking.php form grid to single column on mobile */
    .booking-form-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .booking-form-grid label {
        margin-bottom: 4px;
    }
    
    .booking-form-grid select,
    .booking-form-grid input,
    .booking-form-grid textarea {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix add_sitab_vehicle.php form grid to single column on mobile */
    .vehicle-form-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .vehicle-form-grid label {
        margin-bottom: 4px;
    }
    
    .vehicle-form-grid select,
    .vehicle-form-grid input,
    .vehicle-form-grid textarea {
        width: 100%;
        box-sizing: border-box;
    }
}

/* Hide mobile logo on desktop */
.topbar-logo-mobile {
    display: none;
}

/* Show title on desktop */
.topbar-title {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: .2px;
}

/* ==============================
     Execute Job view (execute_job.php)
     ============================== */
.job-exec-wrapper { max-width: 1400px; margin: 30px auto; padding: 20px; }
.job-exec-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.job-title { margin: 0; }
.job-header-actions { display: flex; gap: 10px; }

/* Buttons variants for anchors & buttons */
.btn { padding: 10px 20px; background: #3c8dbc; color: #fff; border: none; border-radius: 6px; text-decoration: none; font-weight: 600; display: inline-block; cursor: pointer; transition: background .2s ease, box-shadow .2s ease; }
.btn:hover { background: #357ca5; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.btn-success { background: var(--c-success); color: #fff !important; }
.btn-success:hover { background: #008d4c; }
.btn-danger { background: var(--c-danger); color: #fff !important; }
.btn-danger:hover { background: #c23321; }
.btn-secondary { background: #6c757d; color: #fff !important; }
.btn-secondary:hover { background: #5a636b; }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 4px; }
.btn.big { padding: 14px 28px; font-size: 16px; }
.btn.full { width: 100%; }
.btn.subtle { background: transparent; color: inherit; border: 1px solid rgba(0,0,0,0.1); }
.btn.subtle:hover { background: rgba(0,0,0,0.05); }
.btn.outline-btn { background: transparent; border: 1px solid var(--c-success); color: var(--c-success) !important; }
.btn.outline-btn:hover { background: rgba(0,166,90,0.1); }

/* Cards and grid */
.job-card { background: #fff; border: 1px solid #e6ecf3; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 20px; }
.section-title { margin: 0 0 16px 0; }
.section-title.icon { display: flex; align-items: center; gap: 8px; }
.section-title .shelf-inline { font-weight: 700; color: #c62828; margin-left: 12px; font-size: 14px; }
@media (max-width: 700px) {
    .section-title .shelf-inline { display: inline-block; margin-left: 8px; font-size: 13px; }
}
.overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.mini-card { background: #f8f9fa; border-radius: 8px; padding: 16px; border-left: 4px solid #3c8dbc; }
.mini-card.accent-blue { border-left-color: var(--c-primary); }
.mini-card.accent-green { border-left-color: var(--c-success); }
.mini-card.accent-amber { border-left-color: var(--c-warning); }
.mini-card-label { font-size: 12px; color: #6c757d; font-weight: 600; text-transform: uppercase; margin-bottom: 8px; }
.mini-card-label.small { font-size: 11px; margin-bottom: 4px; }
.mini-card-value { font-size: 18px; font-weight: 700; color: #2c3e50; margin-bottom: 4px; }
.mini-card-value.primary { color: #2c3e50; }
.mini-line { font-size: 13px; color: #666; margin-top: 4px; }
.mini-line.muted { color: #999; }
.mini-contact { margin-top: 12px; padding-top: 12px; border-top: 1px solid #dee2e6; }
.mini-contact-name { font-size: 13px; color: #2c3e50; font-weight: 600; }
.mini-contact-links { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.contact-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; background: #e7f3ff; color: #0b5fad; text-decoration: none; border-radius: 14px; font-size: 13px; border: 1px solid #b3d7ff; }

.status-chip { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; display: inline-block; }
.status-chip.prepared { background: #17a2b8; color: #fff; }
.status-chip.in-progress { background: #3c8dbc; color: #fff; }
.status-chip.completed { background: #00a65a; color: #fff; }

.order-notes { margin-top: 20px; padding: 16px; background: #fff3cd; border: 2px solid #ffc107; border-radius: 8px; }
.order-notes .notes-label { font-size: 12px; color: #856404; font-weight: 700; text-transform: uppercase; margin-bottom: 8px; }
.order-notes .notes-body { font-size: 14px; color: #856404; }

.start-job-form { margin-bottom: 20px; }
.job-split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* Protocol section */
.protocol-name-list { display: grid; gap: 8px; margin-bottom: 16px; }
.protocol-name-chip { padding: 12px; background: #e8f4fd; border-left: 4px solid var(--c-primary); border-radius: 6px; color: #0b5fad; font-weight: 700; }
.empty-protocol-warning { padding: 12px; background: #fff3cd; border-left: 4px solid #ffc107; border-radius: 6px; margin-bottom: 16px; color: #856404; }
.protocol-complete-box { padding: 12px; background: #d4edda; border: 1px solid #c3e6cb; color: #155724; border-radius: 6px; }

.protocol-group-header { background: var(--c-primary); color: #fff; padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-weight: 700; }
.protocol-section { margin-bottom: 24px; margin-left: 12px; }
.protocol-section-title { margin: 0 0 12px 0; padding-bottom: 8px; border-bottom: 2px solid #e6ecf3; color: var(--c-primary); }
.protocol-yesno-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 14px; }
.protocol-yesno-table thead tr { background: #f8f9fa; border-bottom: 2px solid #dee2e6; }
.protocol-yesno-table th, .protocol-yesno-table td { padding: 10px; text-align: left; }
.protocol-yesno-table th.center, .protocol-yesno-table td.center { text-align: center; }
.protocol-yesno-table tbody tr { border-bottom: 1px solid #e6ecf3; }
.protocol-yesno-table .label-col { font-weight: 600; }
.yn-radio { width: 20px; height: 20px; cursor: pointer; }
.comment-input { width: 100%; padding: 6px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; }
.req-star { color: #dc3545; font-weight: 700; margin-left: 4px; }

.field-card { margin-bottom: 16px; background: #f8f9fa; border: 2px solid #e6ecf3; border-radius: 8px; padding: 15px; }
.field-label { display: block; font-weight: 700; margin-bottom: 8px; color: #2c3e50; }
.badge-required { background: #e74c3c; color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 800; margin-left: 8px; }
.field-input { width: 100%; padding: 10px 14px; border: 2px solid #dee2e6; border-radius: 6px; font-size: 14px; background: #fff; }
.field-input.textarea { font-family: inherit; }
.checkbox-wrapper { display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border: 2px solid #dee2e6; border-radius: 6px; cursor: pointer; }

/* Items side */
.add-item-card { margin-bottom: 20px; padding: 20px; background: #f8f9fa; border-radius: 8px; }
.form-row { margin-bottom: 16px; }
.form-row.compact { margin-top: 12px; }
.form-label { display: block; font-weight: 700; margin-bottom: 8px; font-size: 14px; }
.form-grid-two { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 16px; }
.form-control { width: 100%; padding: 12px; border: 2px solid #ddd; border-radius: 6px; font-size: 14px; background: #fff; color: #333; box-sizing: border-box; }
.form-control.accent { border-color: var(--c-primary); }
.select-results { width: 100%; padding: 8px; border: 2px solid #ddd; border-radius: 6px; font-size: 14px; background: #fff; }
.select-results { z-index: 10; }
.select-results.hidden { display: none; }
.lib-panel.hidden { display: none; }
.hidden { display: none; }
.select-results option:hover { background: #e7f3ff; }

.empty-items { padding: 30px; text-align: center; color: #666; background: #f8f9fa; border-radius: 8px; }
.empty-items .icon { font-size: 18px; margin: 0 0 8px 0; }
.empty-items .hint { margin-top: 4px; font-size: 13px; color: #999; }

.items-table-wrap { overflow-x: auto; }
.items-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.items-table thead tr { background: #f8f9fa; border-bottom: 2px solid #dee2e6; }
.items-table th, .items-table td { padding: 12px; text-align: left; }
.items-table tbody tr { border-bottom: 1px solid #e6ecf3; }
.items-table .center { text-align: center; }
.item-name { font-weight: 700; margin-bottom: 2px; }
.item-desc { font-size: 13px; color: #666; margin-top: 4px; }
.item-type-badges { margin-top: 4px; }
.type-chip { padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 700; display: inline-block; color: #fff; }
.type-chip.product { background: #17a2b8; }
.type-chip.service { background: #28a745; }
.type-chip.labor { background: #ffc107; color: #333; }
.type-chip.custom { background: #6c757d; }
.unit { color: #666; margin-left: 4px; }
.notes-col em.muted { color: #999; }
.action-col { text-align: center; }
.totals-cell { padding: 14px; text-align: center; background: #f8f9fa; border-top: 2px solid #dee2e6; color: #666; }

.job-complete-box { background: #fff; border: 2px solid #28a745; border-radius: 12px; padding: 24px; text-align: center; }
.job-complete-box p { color: #666; margin-bottom: 20px; }

.muted { color: #666; }
.italic { font-style: italic; }

/* Responsive */
@media (max-width: 1200px) {
    .job-split-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .job-exec-wrapper { padding: 12px; }
}

/* Dark mode overrides for Execute Job */
body.theme-dark .job-card { background: var(--c-surface) !important; border-color: var(--c-border) !important; box-shadow: 0 2px 8px rgba(0,0,0,0.45) !important; }
body.theme-dark .mini-card { background: var(--c-surface-alt) !important; border-color: var(--c-border) !important; }
body.theme-dark .mini-card-label { color: var(--c-text-muted) !important; }
body.theme-dark .mini-card-value { color: var(--c-text) !important; }
body.theme-dark .mini-line { color: var(--c-text-muted) !important; }
body.theme-dark .contact-chip { background: var(--c-surface-alt) !important; color: var(--c-text) !important; border-color: var(--c-border) !important; }
body.theme-dark .order-notes { background: rgba(243,156,18,0.18) !important; border-color: var(--c-warning) !important; }
body.theme-dark .order-notes .notes-label, body.theme-dark .order-notes .notes-body { color: var(--c-text) !important; }
body.theme-dark .protocol-section-title { border-color: var(--c-border) !important; color: var(--c-accent) !important; }
body.theme-dark .protocol-yesno-table thead tr { background: var(--c-surface-alt) !important; border-bottom-color: var(--c-border) !important; }
body.theme-dark .protocol-yesno-table tbody tr { border-bottom-color: var(--c-border) !important; }
body.theme-dark .comment-input, body.theme-dark .field-input { background: var(--c-surface-alt) !important; border-color: var(--c-border) !important; color: var(--c-text) !important; }
/* Strengthen dark background for specific protocol inputs */
body.theme-dark input.field-input,
body.theme-dark .field-input { background-color: var(--c-surface-alt) !important; color: var(--c-text) !important; }
body.theme-dark .field-card { background: var(--c-surface-alt) !important; border-color: var(--c-border) !important; }
body.theme-dark .field-label { color: var(--c-text) !important; }
body.theme-dark .empty-items { background: var(--c-surface-alt) !important; color: var(--c-text) !important; }
body.theme-dark .items-table thead tr { background: var(--c-surface-alt) !important; border-bottom-color: var(--c-border) !important; }
body.theme-dark .items-table tbody tr { border-bottom-color: var(--c-border) !important; }
body.theme-dark .item-desc { color: var(--c-text-muted) !important; }
body.theme-dark .unit { color: var(--c-text-muted) !important; }
body.theme-dark .totals-cell { background: var(--c-surface-alt) !important; border-top-color: var(--c-border) !important; color: var(--c-text-muted) !important; }
body.theme-dark .job-complete-box { background: var(--c-surface) !important; border-color: var(--c-success) !important; }

/* Purchases table under "Produkter för arbetsorder" */
.table-responsive { overflow-x: auto; }
.table-light-theme { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
.table-light-theme thead tr { background: #f8f9fa; border-bottom: 2px solid #dee2e6; }
.table-light-theme th, .table-light-theme td { padding: 10px 12px; text-align: left; }
.table-light-theme tbody tr { border-bottom: 1px solid #e6ecf3; }
.table-light-theme .status-chip { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.table-light-theme .status-chip.prepared { background: #ffeeba; color: #856404; }
.table-light-theme .status-chip.in-progress { background: #cce5ff; color: #004085; }
.table-light-theme .status-chip.completed { background: #d4edda; color: #155724; }

/* Dark mode overrides for generic light tables */
body.theme-dark .table-light-theme thead tr { background: var(--c-surface-alt) !important; border-bottom-color: var(--c-border) !important; }
body.theme-dark .table-light-theme tbody tr { border-bottom-color: var(--c-border) !important; }
body.theme-dark .table-light-theme th { color: var(--c-text) !important; }
body.theme-dark .table-light-theme td { color: var(--c-text-muted) !important; }

/* Mobile tweaks: allow scroll and tighten spacing */
@media (max-width: 700px) {
    .table-light-theme { font-size: 13px; min-width: 600px; }
    .table-light-theme th, .table-light-theme td { padding: 8px 10px; }
}
body.theme-dark .job-complete-box p { color: var(--c-text-muted) !important; }
body.theme-dark .btn.subtle { border-color: var(--c-border) !important; }
body.theme-dark .select-results { background: var(--c-surface-alt) !important; color: var(--c-text) !important; border-color: var(--c-border) !important; }
body.theme-dark .select-results option { background: var(--c-surface) !important; color: var(--c-text) !important; }
/* Improve dropdown contrast in dark mode */
body.theme-dark .select-results { background: var(--c-surface) !important; box-shadow: 0 8px 18px rgba(0,0,0,0.45); }
body.theme-dark .select-results option:hover,
body.theme-dark .select-results option:focus { background: var(--c-bg-alt) !important; color: var(--c-text) !important; }
/* Ensure the main type select has contrast in dark mode */
body.theme-dark select.form-control {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-color: var(--c-surface) !important;
    color: var(--c-text) !important;
    border: 1px solid var(--c-border) !important;
    padding-right: 36px; /* room for arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 12px;
}
body.theme-dark select.form-control:focus { border-color: var(--c-primary) !important; box-shadow: 0 0 0 2px rgba(60,141,188,0.25) !important; }
/* Accent variant should keep primary border even on select */
body.theme-dark select.form-control.accent { border-color: var(--c-primary) !important; }
/* Avatar dropdown contrast boost */
body.theme-dark .avatar-dropdown { background: var(--c-surface) !important; border-color: var(--c-border) !important; box-shadow: 0 10px 24px rgba(0,0,0,0.5) !important; }
/* Placeholder readability (all inputs/textareas in dark mode) */
body.theme-dark .form-control::placeholder,
body.theme-dark .field-input::placeholder,
body.theme-dark .comment-input::placeholder,
body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder { color: var(--c-text-muted); opacity: 1; }
/* Vendor-prefixed placeholder selectors for broader support */
body.theme-dark .form-control::-webkit-input-placeholder,
body.theme-dark .field-input::-webkit-input-placeholder,
body.theme-dark .comment-input::-webkit-input-placeholder,
body.theme-dark input::-webkit-input-placeholder,
body.theme-dark textarea::-webkit-input-placeholder { color: var(--c-text-muted); opacity: 1; }
body.theme-dark .form-control::-moz-placeholder,
body.theme-dark .field-input::-moz-placeholder,
body.theme-dark .comment-input::-moz-placeholder,
body.theme-dark input::-moz-placeholder,
body.theme-dark textarea::-moz-placeholder { color: var(--c-text-muted); opacity: 1; }
body.theme-dark .form-control:-ms-input-placeholder,
body.theme-dark .field-input:-ms-input-placeholder,
body.theme-dark .comment-input:-ms-input-placeholder,
body.theme-dark input:-ms-input-placeholder,
body.theme-dark textarea:-ms-input-placeholder { color: var(--c-text-muted); opacity: 1; }
body.theme-dark .form-control::-ms-input-placeholder,
body.theme-dark .field-input::-ms-input-placeholder,
body.theme-dark .comment-input::-ms-input-placeholder,
body.theme-dark input::-ms-input-placeholder,
body.theme-dark textarea::-ms-input-placeholder { color: var(--c-text-muted); opacity: 1; }
/* Caret visibility in dark mode */
body.theme-dark input,
body.theme-dark textarea { caret-color: var(--c-text); }
/* Fix remaining light patches in dark theme on execute_job */
body.theme-dark .add-item-card { background: var(--c-surface-alt) !important; border: 1px solid var(--c-border) !important; }
body.theme-dark .form-label { color: var(--c-text) !important; }
body.theme-dark .form-control { background: var(--c-surface-alt) !important; border-color: var(--c-border) !important; color: var(--c-text) !important; }
body.theme-dark .form-control.accent { border-color: var(--c-primary) !important; }
/* Ensure service search and quantity inputs are themed */
body.theme-dark #serviceSearch.form-control { background: var(--c-surface-alt) !important; color: var(--c-text) !important; }
body.theme-dark input.form-control[type="number"],
body.theme-dark input[name="quantity"].form-control { background: var(--c-surface-alt) !important; color: var(--c-text) !important; }
/* Tame WebKit autofill in dark mode */
body.theme-dark input:-webkit-autofill,
body.theme-dark textarea:-webkit-autofill,
body.theme-dark select:-webkit-autofill {
    -webkit-text-fill-color: var(--c-text) !important;
    transition: background-color 9999s ease-in-out 0s;
    box-shadow: 0 0 0px 1000px var(--c-surface-alt) inset !important;
}
/* Ultra-specific fallbacks (in case of conflicting legacy CSS) */
body.theme-dark .job-exec-wrapper .field-input,
body.theme-dark .job-exec-wrapper input.field-input,
body.theme-dark .job-exec-wrapper #serviceSearch.form-control,
body.theme-dark .job-exec-wrapper input.form-control[name="quantity"],
body.theme-dark .job-exec-wrapper input.form-control[type="number"] {
    background-color: var(--c-surface-alt) !important;
    background: var(--c-surface-alt) !important;
    color: var(--c-text) !important;
    border-color: var(--c-border) !important;
}
body.theme-dark .protocol-name-chip { background: var(--c-surface-alt) !important; color: var(--c-text) !important; border-left-color: var(--c-primary) !important; }

/* Animated logo text (simple underline + background effect) */
.logo-text {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    color: var(--c-text);
    font-weight: 800;
    line-height: 1;
}
.logo-text .logo-line { display: inline-flex; align-items: baseline; gap: 8px; }
.logo-text .logo-word {
    display: inline-block;
    letter-spacing: .2px;
}
.logo-text .logo-word.els {
    color: var(--c-primary);
    text-shadow: 0 2px 0 rgba(0,0,0,0.15);
}
.logo-text .logo-word.service { font-weight: 800; }
.logo-text .logo-word.online { font-weight: 600; color: var(--c-text-muted); }

/* Underline that sweeps in */
.logo-text::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--c-primary), transparent 70%);
    bottom: -4px;
    transform-origin: left center;
    transform: scaleX(0);
    animation: underline-sweep 2200ms ease-out 300ms forwards;
}
@keyframes underline-sweep {
    to { transform: scaleX(1); }
}

/* Subtle animated background behind the logo */
.logo-text::before {
    content: "";
    position: absolute;
    inset: -6px -10px -10px -10px;
    background: radial-gradient(120px 30px at 10% 40%, rgba(76, 139, 188, 0.25), transparent 70%),
                radial-gradient(140px 32px at 60% 60%, rgba(58, 84, 104, 0.25), transparent 70%),
                radial-gradient(200px 36px at 90% 20%, rgba(0, 166, 90, 0.12), transparent 70%);
    filter: blur(10px) saturate(1.1);
    z-index: -1;
    opacity: .0;
    animation: logo-bg-pulse 4200ms ease-in-out 500ms forwards, logo-bg-drift 14s ease-in-out 3s infinite alternate;
}
@keyframes logo-bg-pulse {
    0% { opacity: 0; transform: translateY(4px); }
    40% { opacity: .6; transform: translateY(0); }
    100% { opacity: .35; }
}
@keyframes logo-bg-drift {
    0% { transform: translateX(0); }
    100% { transform: translateX(6px); }
}

/* Reduce motion: keep it subtle */
@media (prefers-reduced-motion: reduce) {
    .logo-text::after,
    .logo-text::before { animation: none !important; transform: none !important; opacity: .25; }
}

/* Avatar menu styles sync */
.topbar-left { position: relative; }
.topbar-right { position: relative; display: inline-flex; align-items: center; gap: 10px; }
.account-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0 6px 0 0;
    color: #e2e8f0;
}
.account-menu-btn:focus { outline: 2px solid #4a90e2; outline-offset: 2px; }
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #1f2c3d;
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 600;
}
.account-menu-btn .user-chip { margin-right: 0; }
.account-role {
    color: #b0bac5;
    font-size: 13px;
}
.account-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid #2f3d4c;
    background: #1f2c3d;
    transition: background .2s ease, transform .2s ease;
}
.account-menu-btn:hover .account-avatar {
    background: #27384c;
    transform: translateY(-1px);
}
.avatar-icon { width: 20px; height: 20px; display: block; }
.avatar-dropdown {
    position: absolute;
    right: 0; top: calc(100% + 8px);
    background: #1e2a36;
    border: 1px solid #2b3949;
    border-radius: 8px;
    min-width: 160px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    padding: 6px;
    display: none;
    z-index: 1000;
}
.avatar-dropdown.open { display: block; }
.avatar-dropdown a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; color: #dbe2ea; text-decoration: none; border-radius: 6px;
}
.avatar-dropdown a:hover { background: #2a3645; color: #fff; }

/* Removed old mascot rules */

/* Full-width cards on small screens */
@media (max-width: 900px) {
    .info-box, .dashboard-card, .admin-table, .alert, .chem-table, .upload-card, .info-card {
            width: 100% !important;
            box-sizing: border-box;
    }
    .content { padding-left: 12px; padding-right: 12px; }
}
