:root {
    /* Color Palette */
    --primary: #3498db;
    --primary-dark: #2980b9;
    --secondary: #95a5a6;
    --success: #2ecc71;
    --warning: #f1c40f;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --text-main: #2c3e50;
    --text-light: #7f8c8d;
    --bg-body: #eaeff2;
    --bg-panel: #ffffff;
    --border-radius: 6px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
    --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    margin: 0;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Login Screen --- */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #002e40 0%, #00425c 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-box {
    background: var(--bg-panel);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    width: 320px;
}

.login-box h2 {
    margin-top: 0;
    color: var(--text-main);
    margin-bottom: 20px;
}

.login-box input {
    display: block;
    width: 100%;
    padding: 12px;
    margin: 15px 0;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    box-sizing: border-box;
    font-size: 16px;
}

.login-box button {
    width: 100%;
    font-size: 16px;
    margin-top: 10px;
}

/* --- Toolbar --- */
#toolbar {
    background: linear-gradient(90deg, #002e40 0%, #00425c 100%);
    padding: 6px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

/* Quick Nav in Toolbar */
.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 15px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    padding-left: 15px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    padding: 4px 10px 4px 4px;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.active-nav {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.nav-item.active-nav .nav-label {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.nav-icon-small {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-icon-small svg {
    width: 16px;
    height: 16px;
    color: white;
}

.nav-icon-small.bg-wb {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.nav-icon-small.bg-tour {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.nav-icon-small.bg-palette {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

.nav-icon-small.bg-staff {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.nav-icon-small.bg-report {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.nav-icon-small.bg-settings {
    background: linear-gradient(135deg, #7f8c8d, #34495e);
}

.nav-icon-small.bg-diary {
    background: linear-gradient(135deg, #1abc9c, #16a085);
}

.nav-icon-small.bg-firstaid {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.nav-icon-small.bg-menu {
    background: rgba(255, 255, 255, 0.1);
}

.nav-label {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
}

.mobile-app-title {
    display: none;
}

/* Module Sub-Toolbar (Directly under Header) */
.sub-toolbar {
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 8px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 90;
    width: 100%;
    min-height: 64px;
    /* Einheitliche Höhe für alle Module */
}

/* Icon Backgrounds (Shared with Menu) */
.bg-wb {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.bg-tour {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.bg-palette {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

.bg-staff {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.bg-report {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.bg-settings {
    background: linear-gradient(135deg, #7f8c8d, #34495e);
}

.bg-menu {
    background: linear-gradient(135deg, #34495e, #2c3e50);
}

/* Buttons & Inputs Global */
button,
select,
input,
textarea {
    border-radius: 6px !important;
    /* Auf 6px reduziert */
    box-sizing: border-box;
    font-family: inherit;
}

button {
    height: 42px;
    padding: 8px 20px;
    cursor: pointer;
    border: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:active {
    transform: translateY(1px);
}

/* Inputs */
input:not([type="checkbox"]):not([type="radio"]) {
    height: 42px;
    padding: 8px 15px;
    border: 1px solid #ddd;
    font-size: 14px;
    background-color: #fff;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

textarea {
    min-height: 42px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    font-size: 14px;
    background-color: #fff;
    transition: all 0.2s ease;
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    vertical-align: middle;
}

select {
    height: 42px;
    padding: 8px 35px 8px 15px;
    border: 1px solid #ddd;
    font-size: 14px;
    background-color: #fff;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    /* Custom Arrow SVG */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23666' 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 10px center;
    background-size: 16px;
    cursor: pointer;
}

input[type="color"] {
    padding: 2px;
    cursor: pointer;
}

select:focus,
input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
    background-color: #fff;
}

/* Button Variants */
.btn-primary {
    background-color: #3498db !important;
    color: white !important;
}

.btn-primary:hover {
    background-color: #2980b9 !important;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.btn-secondary {
    background-color: #ecf0f1;
    color: var(--text-main);
    border: 1px solid #bdc3c7;
}

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

.btn-danger {
    background-color: #e74c3c !important;
    color: white !important;
}

.btn-danger:hover {
    background-color: #c0392b !important;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.2);
}

.btn-success {
    background-color: #2ecc71 !important;
    color: white !important;
}

.btn-success:hover {
    background-color: #27ae60 !important;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.2);
}

.btn-warning {
    background-color: #f1c40f !important;
    color: #333 !important;
}

.btn-warning:hover {
    filter: brightness(0.95);
}

/* Theme-kompatible Primärfarbe für Icons und neutrale Schaltflächen */
.btn-theme {
    background-color: var(--primary);
    color: white;
}

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

.btn-icon {
    padding: 8px;
    background: transparent;
    font-size: 18px;
    color: #555;
}

#user-display {
    color: #fff !important;
}

.btn-text-danger {
    background: transparent;
    color: #ff7675 !important;
    padding: 0 10px;
    font-weight: 600;
    font-size: 16px !important;
}

.btn-text-danger:hover {
    color: #ff4d4d !important;
    text-decoration: underline;
}

#edit-tools-bar {
    background: #fff8e1;
    color: #5d4037;
    padding: 10px 20px;
    text-align: center;
    display: none;
    border-bottom: 1px solid #ffe082;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* --- Plan Area --- */
#plan-area {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 40px;
    overflow: auto;
    position: relative;
    background-image: radial-gradient(#dfe6e9 1px, transparent 1px);
    background-size: 20px 20px;
}

#map-container {
    width: 297mm;
    height: 210mm;
    background-color: white;
    position: relative;
    box-shadow: var(--shadow-lg);
    /* Realistic Paper Shadow */
    border-radius: 2px;
    /* Print fidelity */
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    transition: transform 0.2s;
    z-index: 0;
}

/* Plan Name on Paper */
#plan-name-display {
    display: block;
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    pointer-events: none !important;
    z-index: 1;
    opacity: 0.8;
}

/* --- Map Elements --- */
.map-element {
    position: absolute;
    border: 3px solid #95a5a6;
    background-color: rgba(0, 0, 0, 0.03);
    pointer-events: none;
    z-index: 1;
    border-radius: 4px;
}

.spot {
    position: absolute;
    border: 2px dashed #bdc3c7;
    background-color: rgba(245, 247, 250, 0.8);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    text-align: center;
    font-size: 12px;
    z-index: 100;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-radius: 4px;
}

.spot:hover {
    border-color: var(--primary);
    background-color: #fff;
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.spot.occupied {
    border: 2px solid rgba(0, 0, 0, 0.2);
    /* Subtle border for occupied */
    z-index: 15;
    box-shadow: var(--shadow-md);
    padding: 0 !important;
    display: flex;
    overflow: hidden;
}

.spot-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px;
    text-align: center;
    line-height: 1.15;
    min-width: 0;
}

.spot-main>div {
    width: 100%;
}

.spot-wb-box {
    background: white !important;
    color: #333 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.1;
    font-weight: normal;
    flex-shrink: 0;
    padding: 0 5px;
}

/* Layout-Varianten */
.spot.horizontal {
    flex-direction: row !important;
}

.spot.horizontal .spot-wb-box {
    width: 22%;
    height: 100%;
    border-left: 1px solid rgba(0, 0, 0, 0.2);
}

.spot:not(.horizontal):not(.map-element) {
    flex-direction: column !important;
}

.spot:not(.horizontal):not(.map-element) .spot-wb-box {
    height: 18%;
    width: 100%;
    border-top: 1px solid rgba(0, 0, 0, 0.2);
}

.spot-number {
    font-weight: normal;
    font-size: 1.0em;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
}

.spot-details {
    font-size: 11px;
    line-height: 1.3;
    font-weight: 500;
    opacity: 0.9;
}

.spot-details strong {
    font-size: 14px;
}

.spot:not(.horizontal) .spot-main strong {
    font-size: 16px;
}

/* Optimierungen für sehr kleine Stellplätze */
.spot.small-spot .spot-main strong {
    font-size: 11px !important;
}

.spot.small-spot .spot-main {
    font-size: 9px !important;
    padding: 2px !important;
}

.spot.small-spot.horizontal .spot-wb-box {
    width: 35% !important;
}

.spot.small-spot:not(.horizontal) .spot-wb-box {
    height: 35% !important;
}

/* Optimierungen für schmale senkrechte Stellplätze */
.spot.narrow-spot .spot-main strong {
    font-size: 12px !important;
}

.spot.narrow-spot .spot-main {
    font-size: 10px !important;
    padding: 4px 2px !important;
}

.spot.drag-over {
    border-color: var(--warning);
    background-color: #f1c40f !important;
    color: #333 !important;
    transform: scale(1.02);
}

.dragging-touch {
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--primary) !important;
    background-color: white !important;
    color: black !important;
}

/* Edit Mode Visuals */
.edit-mode-active {
    cursor: crosshair;
    background-image: radial-gradient(#bdc3c7 2px, transparent 2px);
    background-size: 20px 20px;
}

.edit-mode-active .spot {
    cursor: grab;
    border-style: solid;
    overflow: visible !important;
}

.edit-mode-active .spot::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(52, 152, 219, 0.25);
    /* Blaue Überlagerung */
    z-index: 5;
    pointer-events: none;
}

.edit-mode-active .map-element {
    pointer-events: auto;
    cursor: grab;
}

.spot-size-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.85);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 900;
    z-index: 10;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
}

.coord-tooltip {
    position: fixed;
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    pointer-events: none;
    z-index: 10000;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Controls on Map Elements (Delete, Resize) */
.del-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: 2px solid white;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    display: none;
    z-index: 20;
    box-shadow: var(--shadow-sm);
}

.del-btn:hover {
    background-color: var(--danger-dark);
    transform: scale(1.1);
}

.resize-handle {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 12px;
    height: 12px;
    background: var(--warning);
    border: 1px solid #fff;
    border-radius: 50%;
    cursor: nwse-resize;
    display: none;
    z-index: 25;
    box-shadow: var(--shadow-sm);
}

.edit-mode-active .spot .del-btn,
.edit-mode-active .map-element .del-btn,
.edit-mode-active .spot .resize-handle,
.edit-mode-active .map-element .resize-handle {
    display: block;
}


/* --- Modals --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
    overflow-y: auto;
    /* Scrollen erlauben */
}

.modal-content {
    background-color: white;
    margin: 5vh auto;
    padding: 0;
    border-radius: 12px;
    width: 700px;
    max-width: 95%;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

/* Mobile Toggle & Overlay */
#menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
    border-radius: 8px;
}

#menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

#menu-toggle svg {
    width: 28px;
    height: 28px;
}

.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.3s;
}

.nav-overlay.active {
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #menu-toggle {
        display: block;
    }

    #toolbar {
        padding: 5px 15px !important;
        height: 60px;
        flex-direction: row !important;
        justify-content: flex-start !important;
        z-index: 1001 !important;
        /* Ensure toolbar (and its nav child) is above overlay */
    }

    .header-nav {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        background: linear-gradient(180deg, #002e40 0%, #00425c 100%);
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 70px 20px 20px 20px !important;
        margin: 0 !important;
        border: none !important;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
        gap: 5px !important;
    }

    .header-nav.active {
        transform: translateX(0);
    }

    .nav-item {
        width: 100%;
        padding: 12px 15px !important;
        border-radius: 12px;
    }

    .nav-label {
        font-size: 15px !important;
        opacity: 1 !important;
    }

    .nav-icon-small {
        width: 32px !important;
        height: 32px !important;
    }

    .nav-icon-small svg {
        width: 18px !important;
        height: 18px !important;
    }

    .toolbar-group:last-child {
        margin-left: auto;
    }

    .mobile-app-title {
        display: inline-block;
        font-size: 16px;
        font-weight: 800;
        color: white;
        margin-left: 10px;
    }

    .datenbasis-text,
    #user-display svg {
        display: none !important;
    }

    #user-name-text {
        display: none;
    }

    /* Still hide name to focus on mobile title and logout */

    .modal-content {
        margin: 2vh auto;
        width: 98%;
    }

    .settings-cols {
        flex-direction: column;
    }

    button,
    select,
    input {
        padding: 12px 16px;
        /* Larger touch targets */
    }

    /* Dashboard Grid stacking */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        padding: 15px 0.5% !important;
        /* Minimal padding for maximum width */
        gap: 15px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .dashboard-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        padding: 15px !important;
    }

    .dashboard-header>div {
        width: 100%;
        justify-content: space-between;
    }

    .widget {
        padding: 18px !important;
    }

    .list-grid {
        grid-template-columns: 1fr !important;
    }
}

.modal-content h2 {
    margin: 0;
    padding: 20px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 18px;
    color: var(--text-main);
}

.modal-content form {
    padding: 25px;
}

.modal-content label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
}

.modal-content input,
.modal-content select {
    display: block;
    width: 100%;
    margin-bottom: 15px;
    box-sizing: border-box;
}

.modal-content .settings-cols,
.modal-content>div {
    padding: 25px;
}

.close {
    float: right;
    font-size: 24px;
    cursor: pointer;
    color: #aaa;
    margin-right: 20px;
    margin-top: 15px;
}

.close:hover {
    color: var(--danger);
}

.modal-actions {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-save {
    background-color: var(--success);
    color: white;
    padding: 10px 20px;
}

.btn-save:hover {
    background-color: #27ae60;
}

/* Settings Lists */
.settings-cols {
    display: flex;
    gap: 20px;
}

.settings-cols>div {
    flex: 1;
}

.settings-cols h3 {
    margin-top: 0;
    font-size: 14px;
    text-transform: uppercase;
    color: var(--text-light);
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
}

.settings-cols ul {
    list-style: none;
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
}

.settings-cols li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #eee;
    margin-bottom: 6px;
    border-radius: 4px;
    font-size: 14px;
}

.add-row {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

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