* { box-sizing: border-box; }

:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --border: #d0d7de;
    --text: #1f2328;
    --muted: #656d76;
    --accent: #2f7d31;
    --accent-light: #a5d6a7;
    --other: #f39c12;
    --other-light: #ffe0b2;
    --today: #ffe08a;
    --weekend: #f0f2f4;
    --disabled: #eaecef;
    --danger: #b42318;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
}

header {
    background: var(--accent);
    color: #fff;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

header h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0.5px;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: #d0d7de;
}

.header-info button {
    background: transparent;
    border: 1px solid #d0d7de;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.header-info button:hover { background: rgba(255,255,255,0.1); }

main {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

#persons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.person-row {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.row-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.row-head input[type="text"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 15px;
    min-width: 180px;
}

.row-head input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
}
.row-head input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.row-head input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }
.row-head input[type="color"]::-moz-color-swatch { border: none; border-radius: 3px; }

.row-head .spacer { flex: 1; }

.btn {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 14px;
}

.btn:hover { background: #f4f6f8; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #256a27; }
.btn-danger { color: var(--danger); border-color: #f2b8b0; }
.btn-danger:hover { background: #fef0ee; }
.btn-toggle { min-width: 180px; text-align: center; }
.btn-save {
    background: #f39c12;
    border-color: #e08600;
    color: #fff;
    font-weight: 600;
}
.btn-save:hover { background: #e08600; }
.btn-add {
    padding: 10px 16px;
    border: 1px solid #e08600;
    background: #f39c12;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    color: #fff;
    font-weight: 600;
    width: 100%;
}
.btn-add:hover { background: #e08600; }

.calendar-wrapper {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.calendar-wrapper.global {
    margin: 0 0 16px 0;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.calendar-info {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

.legend-hint { margin-left: auto; font-style: italic; }

.calendar-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---- Bestaetigungsdialog ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 22px 24px;
    min-width: 320px;
    max-width: 90vw;
}

.modal-msg {
    font-size: 16px;
    margin-bottom: 20px;
    color: var(--text);
}

.modal-btns {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-btns .btn { min-width: 90px; }

.months {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.month {
    background: #fbfcfd;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    user-select: none;
}

.month-title {
    font-weight: 600;
    text-align: center;
    margin-bottom: 6px;
}

.weekdays, .days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.weekdays > div {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    padding: 4px 0;
}

.day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e6eaee;
    border-radius: 4px;
    font-size: 13px;
    cursor: default;
    transition: background 0.05s;
}

.day.empty { visibility: hidden; }
.day.disabled { background: var(--disabled); color: #b0b6bd; cursor: not-allowed; border-color: var(--disabled); }
.day.weekend:not(.has-reservation) { background: var(--weekend); }
.day.today { border-color: var(--today); border-width: 2px; font-weight: bold; }
.day.has-reservation {
    color: #fff;
    text-shadow: 0 0 2px rgba(0,0,0,0.55), 0 1px 1px rgba(0,0,0,0.4);
    border-color: rgba(0,0,0,0.15);
}
.day.editable { cursor: pointer; }
.day.editable:not(.disabled):hover { outline: 2px solid #1f2328; outline-offset: -2px; }
.day.editable.selected-by-active:not(.disabled):hover { outline-color: #fff; }

footer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding: 12px;
}

#status {
    display: inline-block;
    min-height: 16px;
    transition: opacity 0.3s;
}
#status.saving { color: var(--muted); }
#status.saved { color: var(--accent); }
#status.error { color: var(--danger); }

@media (max-width: 700px) {
    .row-head input[type="text"] { flex: 1; }
}
