:root {
    --bg-color: #f7f5f0;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --text-muted: #7f8c8d;
    --primary: #8fbc8f;
    --primary-hover: #6a994e;
    --danger: #f4a261;
    --success: #6a994e;
    --warning: #ffb74d;
    --border: #e8e8e8;
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.login-container {
    max-width: 400px;
    margin-top: 10vh;
}

/* App Layout (Sidebar + Main) */
.app-layout {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

.sidebar {
    width: 260px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0,0,0,0.03);
    padding-bottom: env(safe-area-inset-bottom);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    padding: 0 15px 20px 15px;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu a {
    color: var(--text-color);
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 12px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    font-weight: 500;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background-color: rgba(143, 188, 143, 0.15); /* Soft sage */
    color: var(--primary-hover);
    font-weight: 700;
}

.btn-logout {
    color: var(--danger) !important;
}

.main-wrapper {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
}

.top-header {
    padding: 15px 20px;
    padding-top: calc(15px + env(safe-area-inset-top));
    background-color: var(--bg-color);
    display: flex;
    align-items: center;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-color);
    line-height: 1;
    padding: 5px;
    touch-action: manipulation;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
        overflow-x: hidden;
    }
    .mobile-only {
        display: flex;
    }
    .dashboard-row {
        flex-direction: column !important;
    }
    .dashboard-col-1, .dashboard-col-2, .dashboard-col-flex {
        flex: none !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

/* Dashboard Responsive Cols */
.dashboard-row {
    display: flex; 
    flex-wrap: wrap; 
    gap: 20px;
}
.dashboard-col-1 {
    flex: 1;
    min-width: 250px;
}
.dashboard-col-2 {
    flex: 2;
    min-width: 280px;
}
.dashboard-col-flex {
    flex: 1;
    min-width: 200px;
}


/* Cards */
.card {
    background-color: var(--card-bg);
    border: none;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
input[type="date"],
select {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-color);
    font-size: 1rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    display: inline-block;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    touch-action: manipulation;
}

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

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

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-warning {
    background-color: rgba(255, 183, 77, 0.2);
    border: 1px solid var(--warning);
    color: var(--warning);
}

.offline-warning {
    background-color: var(--danger);
    color: #fff;
    text-align: center;
    padding: 10px;
    position: sticky;
    top: 0;
    z-index: 1000;
    font-weight: bold;
}


/* Checkboxes (44x44px minimum) */
.touch-checkbox {
    width: 44px;
    height: 44px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    position: relative;
    display: inline-block;
    vertical-align: middle;
    touch-action: manipulation;
}

.touch-checkbox:checked {
    background-color: var(--success);
    border-color: var(--success);
}

.touch-checkbox:checked::after {
    content: '✔';
    position: absolute;
    color: #ffffff;
    font-size: 24px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}





/* Tables & Lists */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
}

.item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
}

.item-row:last-child {
    border-bottom: none;
}



/* Responsive Table */
@media (max-width: 768px) {
    .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td {
        display: block;
        width: 100%;
    }
    .responsive-table thead {
        display: none;
    }
    .responsive-table tr {
        margin-bottom: 15px;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 10px;
        background-color: var(--card-bg);
    }
    .responsive-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 10px 5px;
        border-bottom: 1px solid #f0f0f0;
    }
    .responsive-table td:last-child {
        border-bottom: none;
    }
    .responsive-table td::before {
        content: attr(data-label);
        font-weight: bold;
        text-align: left;
        color: var(--text-muted);
        flex-basis: 45%;
    }
}

/* Sidebar Accordion (Details/Summary) */
.sidebar-group {
    margin-bottom: 2px;
}
.sidebar-group summary {
    list-style: none; /* Hide default arrow */
    padding: 12px 16px;
    font-weight: 700;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 12px;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-group summary::-webkit-details-marker {
    display: none;
}
.sidebar-group summary::after {
    content: '▼';
    font-size: 0.7em;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}
.sidebar-group[open] summary::after {
    transform: rotate(-180deg);
}
.sidebar-group summary:hover {
    background-color: rgba(0,0,0,0.03);
}
.sidebar-group-content {
    display: flex;
    flex-direction: column;
    padding-left: 15px;
    margin-top: 5px;
    gap: 4px;
    border-left: 2px solid rgba(0,0,0,0.05);
    margin-left: 10px;
}
.sidebar-group-content a {
    padding: 8px 12px;
    font-size: 0.9em;
}

/* Slide-In Modal (wird primär im Kalender/Terminen genutzt) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    z-index: 2000;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--card-bg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    max-height: 90dvh;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow-y: auto;
}

@media (min-width: 768px) {
    .modal-overlay {
        justify-content: center;
        align-items: center;
    }
    .modal-content {
        height: auto;
        max-height: 90vh;
        border-radius: 16px;
        transform: scale(0.95);
    }
    .modal-overlay.active .modal-content {
        transform: scale(1);
    }
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}
