/**
 * Stylesheet für Auftragsbearbeitungs-WebApp
 * Responsive Design, Schweizer Style
 */

/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3a7bc8;
    --primary-hover: #2e6ab3;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --secondary-color: #6c757d;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #212529;
    --text-muted: #6c757d;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #fff;
}

/* === LOGIN PAGE === */
.login-page {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
    padding-top: 10vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://www.stapes.ch/new_world/img/hero-bg-4.svg');
    background-position: center top;
    background-size: cover;
    background-repeat: no-repeat;
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 8px;
}

.login-form .form-control {
    border-radius: 10px;
    height: 48px;
    padding: 12px 16px;
    font-size: 14px;
}

.login-form .btn {
    border-radius: 10px;
    height: 48px;
    font-size: 15px;
}

.login-box .alert {
    border-radius: 10px;
}

.login-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
}

/* === NAVIGATION === */
.navbar {
    background-color: #f8f9fa;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.navbar-brand a {
    color: #1a3a5c;
    text-decoration: none;
    font-size: 24px;
    font-weight: bold;
    padding: 15px 0;
    display: flex;
    align-items: center;
}

.navbar-logo {
    max-height: 40px;
    height: auto;
    max-width: 200px;
    object-fit: contain;
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px;
    z-index: 1010;
    position: relative;
    min-width: 48px;
    min-height: 48px;
    -webkit-tap-highlight-color: rgba(255,255,255,0.2);
    touch-action: manipulation;
}

.navbar-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: #555;
    margin: 5px 0;
    transition: 0.3s;
}

.navbar-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 6px);
}

.navbar-toggle.active span:nth-child(2) {
    opacity: 0;
}

.navbar-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -6px);
}

.navbar-menu {
    display: flex;
    align-items: center;
    list-style: none;
    gap: 5px;
}

.navbar-menu > li {
    position: relative;
}

.navbar-menu > li > a {
    color: #444;
    text-decoration: none;
    padding: 15px 15px;
    display: block;
    transition: background 0.3s, color 0.3s;
    font-weight: 500;
}

.navbar-menu > li > a:hover {
    background-color: #e9ecef;
    color: #1a3a5c;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 200px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    border-radius: 4px;
    list-style: none;
    padding: 8px 0;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu li a {
    color: var(--text-color);
    text-decoration: none;
    padding: 10px 20px;
    display: block;
    transition: background 0.2s;
}

.dropdown-menu li a:hover {
    background-color: var(--light-bg);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 0 0 0 15px;
}

.navbar-user span {
    color: #444;
}

/* === CONTAINER & LAYOUT === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.page-header h1 {
    font-size: 32px;
    color: var(--text-color);
}

.page-header p {
    color: var(--text-muted);
    margin-top: 5px;
}

.date-short {
    display: none;
}

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

.section {
    background: white;
    padding: 25px;
    margin-bottom: 25px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.section h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-color);
}

/* Tables in sections: stretch to card edges */
.section .table-responsive {
    margin-left: -25px;
    margin-right: -25px;
}

.section .table-responsive .table {
    margin-bottom: 0;
}

.section .table-responsive .table thead th:first-child,
.section .table-responsive .table tbody td:first-child {
    padding-left: 25px;
}

.section .table-responsive .table thead th:last-child,
.section .table-responsive .table tbody td:last-child {
    padding-right: 25px;
}

/* === FORMS === */
.form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child,
.form-section:last-of-type {
    border-bottom: none;
}

.form-section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--primary-color);
}

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

.form-group {
    flex: 1;
    min-width: 0;
}

.form-group.flex-grow {
    flex-grow: 2;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
    transition: border-color 0.2s;
    box-sizing: border-box;
    height: 40px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

.form-control:disabled {
    background-color: var(--light-bg);
    cursor: not-allowed;
}

select.form-control {
    padding-right: 40px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: 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='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 14px center / 14px;
    background-color: #fff;
}

input[list].form-control {
    padding-right: 40px;
}

body.dark-mode select.form-control {
    background: 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='%23aaa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 14px center / 14px;
    background-color: #1a1a2e;
}

body.dark-mode input[list].form-control {
    background-color: #1a1a2e;
    border-color: #2a3a5c;
    color: #e0e0e0;
}

body.dark-mode input[list].form-control::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}

textarea.form-control {
    resize: vertical;
    height: auto;
    min-height: 60px;
}

/* Custom file input styling */
input[type="file"].form-control {
    padding: 0;
    height: auto;
    min-height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

input[type="file"].form-control::file-selector-button {
    padding: 8px 16px;
    margin-right: 12px;
    border: none;
    border-right: 1px solid var(--border-color);
    background-color: var(--primary-color);
    color: white;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background-color 0.2s;
    height: 100%;
    border-radius: 3px 0 0 3px;
}

input[type="file"].form-control::file-selector-button:hover {
    background-color: var(--primary-hover);
}

.form-text {
    display: block;
    margin-top: 5px;
    font-size: 13px;
    color: var(--text-muted);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding-top: 28px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    box-sizing: border-box;
    height: 40px;
}

.btn-icon-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    font-size: 13px;
    color: #555;
    text-decoration: none;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
}

.btn-icon-link:hover {
    color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.05);
}

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

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

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

.btn-success:hover {
    background-color: #218838;
}

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

.btn-danger:hover {
    background-color: #c82333;
}

.btn-warning {
    background-color: var(--warning-color);
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid #999;
    color: #555;
}

.btn-outline:hover {
    background-color: #555;
    color: white;
}

.btn-block {
    display: block;
    width: 100%;
}

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

/* Links als Buttons: Textfarbe vom Button übernehmen */
a.btn {
    color: inherit;
    text-decoration: none;
}
a.btn-danger,
a.btn-success,
a.btn-primary,
a.btn-secondary,
a.btn-info {
    color: white;
}
a.btn-warning {
    color: #212529;
}
a.btn:hover {
    text-decoration: none;
}

/* Icon-only action buttons (no background) */
.btn-icon {
    background: none;
    border: none;
    padding: 4px 6px;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s ease, transform 0.15s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: inherit;
}

.btn-icon:hover {
    opacity: 1;
    transform: scale(1.15);
    background: rgba(0, 0, 0, 0.05);
    text-decoration: none;
    color: inherit;
}

.btn-icon[title] {
    position: relative;
}

.btn-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #f8f9fa;
    padding: 15px 18px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stat-card.stat-success {
    border-left-color: var(--success-color);
}

.stat-card.stat-warning {
    border-left-color: var(--warning-color);
}

.stat-card.stat-info {
    border-left-color: var(--info-color);
}

.stat-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 22px;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 3px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.stat-link {
    color: var(--primary-color);
    font-size: 13px;
    text-decoration: none;
    font-weight: 500;
}

.stat-link:hover {
    text-decoration: underline;
}

/* === TABLES === */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 13px;
}

/* Base styles for plain tables using mobile-cards */
table.mobile-cards {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 13px;
}

table.mobile-cards th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    font-size: 13px;
}

table.mobile-cards td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

table.mobile-cards tbody tr:hover {
    background-color: #f8f9fa;
}

.table thead {
    background-color: var(--light-bg);
}

.table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    font-size: 13px;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

.table tbody tr.row-inactive {
    opacity: 0.5;
}

.table-info {
    padding: 10px;
    text-align: right;
    color: var(--text-muted);
    font-size: 14px;
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
}

.badge-success {
    background-color: #d4edda;
    color: #155724;
}

.badge-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.badge-warning {
    background-color: #fff3cd;
    color: #856404;
}

.badge-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.badge-secondary {
    background-color: #6c757d;
    color: #ffffff;
}

.badge-pink {
    background-color: #f8d0e8;
    color: #8b1a5c;
}

/* === ALERTS === */
.alert {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    position: relative;
}

.alert ul {
    margin: 0;
    padding-left: 20px;
}

.alert-success {
    background-color: #d4edda;
    border-left: 4px solid #28a745;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    border-left: 4px solid #dc3545;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border-left: 4px solid #17a2b8;
    color: #0c5460;
}

.btn-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: inherit;
}

/* === FILTER BAR === */
.filter-bar {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.filter-form .form-row {
    margin-bottom: 0;
}

/* === INFO BOX === */
.info-box {
    background-color: #e7f3ff;
    border-left: 4px solid var(--info-color);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.info-box h3 {
    margin-bottom: 10px;
    color: var(--info-color);
}

/* === QUICK ACTIONS === */
.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* === UTILITIES === */
.text-muted {
    color: var(--text-muted) !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-3 {
    margin-top: 1rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

/* Column widths */
.row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}
.col-md-3 { flex: 0 1 25%; max-width: 25%; }
.col-md-4 { flex: 0 1 33.333%; max-width: 33.333%; }
.col-md-6 { flex: 0 1 50%; max-width: 50%; }
.col-md-8 { flex: 0 1 66.666%; max-width: 66.666%; }
.col-md-9 { flex: 0 1 75%; max-width: 75%; }
.col-md-12 { flex: 0 0 100%; max-width: 100%; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .navbar-toggle {
        display: block;
    }
    
    .navbar-menu {
        display: flex;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: #f8f9fa;
        border-top: 1px solid #e0e0e0;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        flex-direction: column;
        padding: 0;
        z-index: 1005;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.35s ease;
    }
    
    .navbar-menu.active {
        max-height: 80vh;
        overflow-y: auto;
        opacity: 1;
        padding: 10px 0;
    }
    
    .dropdown-menu {
        position: static;
        box-shadow: none;
        background-color: #eef0f2;
        display: none;
    }
    
    .dropdown.open .dropdown-menu {
        display: block;
    }
    
    .dropdown-menu li a {
        color: #444;
        padding-left: 40px;
    }
    
    .navbar-user {
        flex-direction: row;
        padding: 10px 15px;
        border-top: 1px solid #e0e0e0;
        margin-top: 5px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .dashboard-welcome {
        font-size: 0.85rem;
    }
    .dashboard-welcome .date-long {
        display: none;
    }
    .dashboard-welcome .date-short {
        display: inline;
    }
    
    .page-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
        justify-content: flex-end;
    }
    
    .page-actions .btn,
    .page-actions .btn-icon-link {
        padding: 8px 14px;
        font-size: 12px;
        white-space: nowrap;
    }
    
    .form-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-9, .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    /* btn-group: stay horizontal on mobile (except in page-actions) */
    .btn-group {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
}

/* === RESPONSIVE (mobile-only) === */
@media screen and (max-width: 768px) {

    /* === TABLE → CARD LAYOUT (mobile only) === */
    .table,
    table.mobile-cards {
        display: block !important;
        border-collapse: initial;
    }

    .table tbody,
    table.mobile-cards tbody {
        display: block !important;
    }

    .table thead,
    table.mobile-cards thead {
        display: none !important;
    }

    .table tbody tr,
    table.mobile-cards tbody tr {
        display: block !important;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 0;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
        overflow: hidden;
    }

    .table tbody tr:hover,
    table.mobile-cards tbody tr:hover {
        background: #fafbfc;
    }

    .table td,
    table.mobile-cards td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 6px 15px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 13px;
        text-align: right;
    }

    .table td:first-child,
    table.mobile-cards td:first-child {
        background: #f0f4f8;
        padding: 10px 15px;
        font-size: 14px;
        border-bottom: 2px solid var(--border-color);
    }

    .table td:last-child,
    table.mobile-cards td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        padding: 10px 15px;
    }

    .table td::before,
    table.mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
        margin-right: 10px;
        font-size: 12px;
    }

    .table td[data-label=""]::before,
    table.mobile-cards td[data-label=""]::before,
    .table td:not([data-label])::before,
    table.mobile-cards td:not([data-label])::before {
        display: none;
    }

    /* Reset desktop section padding for mobile cards */
    .section .table-responsive .table thead th:first-child,
    .section .table-responsive .table tbody td:first-child {
        padding-left: 15px !important;
    }

    .section .table-responsive .table thead th:last-child,
    .section .table-responsive .table tbody td:last-child {
        padding-right: 15px !important;
    }

    /* Action cells (empty label) always right-aligned */
    .section .table-responsive .table tbody td[data-label=""],
    .table td[data-label=""],
    table.mobile-cards td[data-label=""] {
        justify-content: flex-end !important;
        text-align: right !important;
        border-bottom: none !important;
        padding: 10px 15px !important;
    }

    .table td .btn-group,
    table.mobile-cards td .btn-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Tfoot: show as summary card */
    .table tfoot tr,
    table.mobile-cards tfoot tr {
        display: block;
        background: #f8f9fa;
        border-radius: 8px;
        padding: 10px 15px;
        margin-top: 5px;
    }

    .table tfoot td,
    table.mobile-cards tfoot td {
        display: inline;
        border-bottom: none;
        padding: 0;
    }

    .table tfoot td[colspan],
    table.mobile-cards tfoot td[colspan] {
        display: none;
    }

    .table tfoot td:not([colspan]),
    table.mobile-cards tfoot td:not([colspan]) {
        display: inline;
    }

    /* Dark mode card overrides (mobile) */
    body.dark-mode .table tbody tr,
    body.dark-mode table.mobile-cards tbody tr {
        background: #16213e;
        border-color: #2a3a5c;
        box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    }

    body.dark-mode .table td,
    body.dark-mode table.mobile-cards td {
        border-bottom-color: #1e2a45;
    }

    body.dark-mode .table td:first-child,
    body.dark-mode table.mobile-cards td:first-child {
        background: #1a2744;
        border-bottom-color: #2a3a5c;
    }

    body.dark-mode .table td::before,
    body.dark-mode table.mobile-cards td::before {
        color: #888;
    }

    body.dark-mode .table tfoot tr,
    body.dark-mode table.mobile-cards tfoot tr {
        background: #1a2744;
    }

    /* Card/card-body: transparent wrapper on mobile */
    .card {
        border: none;
        box-shadow: none;
        background: transparent;
    }

    .card-body {
        padding: 5px 0;
        overflow: visible;
    }

    /* Table-responsive: no horizontal scroll in card mode */
    .table-responsive {
        overflow-x: visible;
    }

    /* Filter tabs compact on mobile */
    .filter-tabs {
        gap: 5px;
    }

    .filter-tab {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Container tighter on mobile */
    .container {
        padding: 15px 10px;
    }

    /* Page title smaller on mobile */
    .page-header h1 {
        font-size: 22px;
    }

    /* Search groups stack on mobile */
    .search-group {
        flex-wrap: wrap;
    }

    /* Filter bar form responsive */
    .filter-bar .form-row,
    .filter-form .form-row {
        gap: 8px;
    }

    /* Reset desktop stretch on mobile */
    .section .table-responsive {
        margin-left: 0;
        margin-right: 0;
    }

    /* Dashboard sections: less padding on mobile */
    .section {
        padding: 15px 10px;
    }
}

/* === FILTER TABS === */
.filter-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.filter-tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: -2px;
}

.filter-tab:hover {
    color: var(--primary-color);
    background-color: var(--light-bg);
}

.filter-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.filter-tab small {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: normal;
    margin-top: 2px;
}

/* === SEARCHABLE SELECT (Kunden-Suche) === */
.searchable-select-wrapper {
    position: relative;
    width: 100%;
}

.searchable-select-input {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    cursor: text;
    box-sizing: border-box;
}

.searchable-select-input:focus {
    border-color: #4a90d9;
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.15);
}

.searchable-select-input.has-value {
    font-weight: 500;
}

.searchable-select-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #999;
    padding: 2px 4px;
    line-height: 1;
    display: none;
}

.searchable-select-clear:hover {
    color: #333;
}

.searchable-select-wrapper.has-value .searchable-select-clear {
    display: block;
}

.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ced4da;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
}

.searchable-select-dropdown.open {
    display: block;
}

.searchable-select-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.1s ease;
}

.searchable-select-option:last-child {
    border-bottom: none;
}

.searchable-select-option:hover,
.searchable-select-option.highlighted {
    background: #e7f3ff;
}

.searchable-select-option.selected {
    background: #d4e9ff;
    font-weight: 500;
}

.searchable-select-option .kunde-nr {
    color: #888;
    font-size: 12px;
    margin-right: 6px;
}

.searchable-select-option .kunde-name {
    color: #333;
}

.searchable-select-no-results {
    padding: 12px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

@media print {
    .navbar,
    .page-actions,
    .filter-bar,
    .btn,
    .form-actions {
        display: none !important;
    }
}

/* === DARK MODE TOGGLE === */
.dark-mode-toggle,
.nav-icon-link {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 8px 10px;
    line-height: 1;
    border-radius: 6px;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit;
}

.dark-mode-toggle:hover,
.nav-icon-link:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

body.dark-mode .nav-icon-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* === FOOTER === */
.site-footer {
    text-align: center;
    padding: 20px 15px;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
}

@media (max-width: 768px) {
    .site-footer {
        font-size: 11px;
        padding: 15px 10px;
    }
}

.site-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* === DARK MODE === */
body.dark-mode {
    background-color: #1a1a2e;
    color: #e0e0e0;
}

body.dark-mode .navbar {
    background-color: #16213e;
    border-bottom-color: #1a1a2e;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

body.dark-mode .navbar-brand a {
    color: #e0e0e0;
}

body.dark-mode .navbar-menu > li > a {
    color: #ccc;
}

body.dark-mode .navbar-menu > li > a:hover {
    background-color: rgba(255,255,255,0.08);
    color: #fff;
}

body.dark-mode .navbar-toggle span {
    background: #ccc;
}

body.dark-mode .dropdown-menu {
    background: #1e2a45;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

body.dark-mode .dropdown-menu li a {
    color: #ccc;
}

body.dark-mode .dropdown-menu li a:hover {
    background-color: rgba(255,255,255,0.08);
    color: #fff;
}

body.dark-mode .dark-mode-toggle:hover {
    background-color: rgba(255,255,255,0.1);
}

body.dark-mode .btn-outline {
    border-color: #ccc;
    color: #ccc;
}

body.dark-mode .btn-outline:hover {
    background-color: #ccc;
    color: #1a1a2e;
}

body.dark-mode .btn-primary,
body.dark-mode .btn-success,
body.dark-mode .btn-danger,
body.dark-mode .btn-secondary,
body.dark-mode .btn-warning,
body.dark-mode .btn-info {
    color: #fff;
}

body.dark-mode .btn-primary {
    background-color: #2979cc;
}

body.dark-mode .btn-success {
    background-color: #22a347;
}

body.dark-mode .btn-danger {
    background-color: #d04050;
}

body.dark-mode .btn-secondary {
    background-color: #5a6672;
}

body.dark-mode .btn-warning {
    background-color: #d4850a;
    color: #fff;
}

body.dark-mode .btn-info {
    background-color: #148a9e;
}

/* Content areas */
body.dark-mode .container {
    color: #e0e0e0;
}

body.dark-mode .card,
body.dark-mode .section,
body.dark-mode .form,
body.dark-mode .filter-bar {
    background: #1a1a2e;
    color: #e0e0e0;
    box-shadow: none;
}

body.dark-mode .page-header {
    border-bottom-color: #2a3a5c;
}

body.dark-mode .page-header h1,
body.dark-mode .section h2 {
    color: #e0e0e0;
}

body.dark-mode .page-header p,
body.dark-mode .text-muted {
    color: #999 !important;
}

body.dark-mode .site-footer {
    border-top-color: #2a3a5c;
    color: #999;
}

body.dark-mode .site-footer a {
    color: #6ea8fe;
}

/* Forms */
body.dark-mode .form-control,
body.dark-mode select,
body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode input[type="number"],
body.dark-mode input[type="date"],
body.dark-mode input[type="search"],
body.dark-mode textarea {
    background-color: #1a1a2e;
    border-color: #2a3a5c;
    color: #e0e0e0;
}

body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}

body.dark-mode input[type="file"].form-control {
    background-color: #1a1a2e;
    border-color: #2a3a5c;
    color: #ccc;
}

body.dark-mode input[type="file"].form-control::file-selector-button {
    background-color: #2979cc;
    color: #fff;
    border-right-color: #2a3a5c;
}

body.dark-mode input[type="file"].form-control::file-selector-button:hover {
    background-color: #3a8ae0;
}

body.dark-mode .form-control:focus {
    border-color: #4a90d9;
    box-shadow: 0 0 0 3px rgba(74,144,217,0.2);
}

body.dark-mode .form-control:disabled {
    background-color: #12121f;
    color: #888;
}

body.dark-mode .form-group label {
    color: #ccc;
}

body.dark-mode .form-section {
    border-bottom-color: #2a3a5c;
}

body.dark-mode .form-section h2 {
    color: #4a90d9;
}

body.dark-mode .form-actions {
    border-top-color: #2a3a5c;
}

body.dark-mode .form-text {
    color: #888;
}

/* Tables */
body.dark-mode .table,
body.dark-mode table.mobile-cards {
    background: #16213e;
    color: #e0e0e0;
}

body.dark-mode .table thead,
body.dark-mode table.mobile-cards thead {
    background-color: #1e2a45;
}

body.dark-mode .table th,
body.dark-mode table.mobile-cards th {
    color: #ccc;
    border-bottom-color: #2a3a5c;
}

body.dark-mode .table td,
body.dark-mode table.mobile-cards td {
    border-bottom-color: #1e2a45;
    color: #ddd;
}

body.dark-mode .table tbody tr:hover,
body.dark-mode table.mobile-cards tbody tr:hover {
    background-color: rgba(255,255,255,0.04);
}

/* Stat cards */
body.dark-mode .stat-card {
    background: #16213e;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

body.dark-mode .stat-value {
    color: #e0e0e0;
}

body.dark-mode .stat-label {
    color: #999;
}

/* Badges */
body.dark-mode .badge-success {
    background-color: #1a3a2a;
    color: #6fdc8c;
}

body.dark-mode .badge-danger {
    background-color: #3a1a1e;
    color: #ff8a8a;
}

body.dark-mode .badge-warning {
    background-color: #3a3218;
    color: #ffd866;
}

body.dark-mode .badge-info {
    background-color: #1a2e3a;
    color: #6cc4dc;
}

body.dark-mode .badge-secondary {
    background-color: #4a4d55;
    color: #e0e0e0;
}

body.dark-mode .badge-pink {
    background-color: #3a1a30;
    color: #f48fb1;
}

/* Alerts */
body.dark-mode .alert-success {
    background-color: #1a3a2a;
    color: #6fdc8c;
    border-left-color: #28a745;
}

body.dark-mode .alert-danger {
    background-color: #3a1a1e;
    color: #ff8a8a;
    border-left-color: #dc3545;
}

body.dark-mode .alert-warning {
    background-color: #3a3218;
    color: #ffd866;
    border-left-color: #ffc107;
}

body.dark-mode .alert-info {
    background-color: #1a2e3a;
    color: #6cc4dc;
    border-left-color: #17a2b8;
}

/* Info box */
body.dark-mode .info-box {
    background-color: #1a2e3a;
    border-left-color: #17a2b8;
    color: #ccc;
}

body.dark-mode .info-box h3 {
    color: #6cc4dc;
}

/* Filter tabs */
body.dark-mode .filter-tabs {
    border-bottom-color: #2a3a5c;
}

body.dark-mode .filter-tab {
    color: #999;
}

body.dark-mode .filter-tab:hover {
    color: #4a90d9;
    background-color: rgba(255,255,255,0.05);
}

body.dark-mode .filter-tab.active {
    color: #4a90d9;
    border-bottom-color: #4a90d9;
}

/* Searchable select */
body.dark-mode .searchable-select-input {
    background: #1a1a2e;
    border-color: #2a3a5c;
    color: #e0e0e0;
}

body.dark-mode .searchable-select-dropdown {
    background: #1e2a45;
    border-color: #2a3a5c;
}

body.dark-mode .searchable-select-option:hover,
body.dark-mode .searchable-select-option.highlighted {
    background: #2a3a5c;
}

body.dark-mode .searchable-select-option.selected {
    background: #1a3a5c;
}

body.dark-mode .searchable-select-option .kunde-name {
    color: #ddd;
}

/* btn-icon-link */
body.dark-mode .btn-icon-link {
    color: #aaa;
}

body.dark-mode .btn-icon-link:hover {
    color: #4a90d9;
    background-color: rgba(255,255,255,0.08);
}

/* Links */
body.dark-mode a {
    color: #4a90d9;
}

body.dark-mode .stat-link {
    color: #4a90d9;
}

/* Table info */
body.dark-mode .table-info {
    color: #888;
}

/* Mobile dark mode */
@media (max-width: 768px) {
    body.dark-mode .navbar-menu {
        background-color: #16213e;
        border-top-color: #1a1a2e;
    }

    body.dark-mode .dropdown-menu {
        background-color: #12192d;
    }

    body.dark-mode .dropdown-menu li a {
        color: #bbb;
    }

    body.dark-mode .navbar-user {
        border-top-color: #2a3a5c;
    }
}

/* === CUSTOM MODAL DIALOG === */
.stapes-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: stapesModalFadeIn 0.15s ease;
}

.stapes-modal-overlay.stapes-modal-visible {
    display: flex;
}

.stapes-modal {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: stapesModalSlideIn 0.2s ease;
}

.stapes-modal-icon {
    font-size: 40px;
    margin-bottom: 12px;
    line-height: 1;
}

.stapes-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #212529;
    margin-bottom: 10px;
}

.stapes-modal-message {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 24px;
}

.stapes-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.stapes-modal-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 100px;
}

.stapes-modal-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.stapes-modal-btn-cancel {
    background: #f0f0f0;
    color: #333;
}

.stapes-modal-btn-cancel:hover {
    background: #e0e0e0;
}

.stapes-modal-btn-confirm {
    color: #fff;
}

.stapes-modal-btn-warning {
    background: var(--primary-color);
}

.stapes-modal-btn-warning:hover {
    background: var(--primary-hover);
}

.stapes-modal-btn-danger {
    background: var(--danger-color);
}

.stapes-modal-btn-danger:hover {
    background: #c82333;
}

.stapes-modal-btn-info {
    background: var(--info-color);
}

.stapes-modal-btn-info:hover {
    background: #138496;
}

.stapes-modal-btn-success {
    background: var(--success-color);
}

.stapes-modal-btn-success:hover {
    background: #218838;
}

@keyframes stapesModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes stapesModalSlideIn {
    from { transform: scale(0.9) translateY(-10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

@media (max-width: 480px) {
    .stapes-modal {
        padding: 20px;
        margin: 10px;
    }

    .stapes-modal-buttons {
        flex-direction: column-reverse;
    }

    .stapes-modal-btn {
        width: 100%;
    }
}

/* Dark Mode Modal */
body.dark-mode .stapes-modal {
    background: #2a2d35;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

body.dark-mode .stapes-modal-title {
    color: #e0e0e0;
}

body.dark-mode .stapes-modal-message {
    color: #b0b0b0;
}

body.dark-mode .stapes-modal-btn-cancel {
    background: #3a3d45;
    color: #e0e0e0;
}

body.dark-mode .stapes-modal-btn-cancel:hover {
    background: #4a4d55;
}

/* ========================================
   SESSION TIMEOUT OVERLAY
   ======================================== */
#session-timeout-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(3px);
}
#session-timeout-overlay.visible {
    opacity: 1;
}
.session-timeout-box {
    background: #fff;
    border-radius: 16px;
    padding: 35px 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: sessionPulse 0.4s ease;
}
@keyframes sessionPulse {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.session-timeout-icon {
    font-size: 48px;
    margin-bottom: 10px;
}
.session-timeout-box h3 {
    margin: 0 0 10px;
    font-size: 22px;
    color: #333;
}
.session-timeout-box p {
    margin: 0 0 25px;
    color: #666;
    font-size: 15px;
    line-height: 1.5;
}
.session-timeout-box #session-countdown {
    font-size: 20px;
    color: #e74c3c;
}
.session-timeout-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Dark Mode */
body.dark-mode .session-timeout-box {
    background: #1e2a3a;
}
body.dark-mode .session-timeout-box h3 {
    color: #e0e0e0;
}
body.dark-mode .session-timeout-box p {
    color: #aaa;
}
