:root {
    --bg-1: #eef8f6;
    --bg-2: #d8ecff;
    --surface: rgba(255, 255, 255, 0.93);
    --text: #18262c;
    --muted: #4d5f68;
    --border: #9ebed0;
    --neutral: #c9dae8;
    --own: #72d89f;
    --other: #f0a07e;
    --past: #a9b8c7;
}

:root[data-theme="dark"] {
    --bg-1: #141822;
    --bg-2: #1a212c;
    --surface: rgba(26, 33, 44, 0.9);
    --text: #f4f8fb;
    --muted: #c0ccd8;
    --border: #85c6e3;
    --neutral: #2a3442;
    --own: #2f7a52;
    --other: #8a3a3a;
    --past: #3a4654;
}

:root[data-theme="soft-beach"] {
    --bg-1: #f7fde7;
    --bg-2: #c9f8f1;
    --surface: rgba(255, 255, 255, 0.95);
    --text: #352e3a;
    --muted: #6c6072;
    --border: #51e2f5;
    --neutral: #e1fbf7;
    --own: #9df9ef;
    --other: #ffa8b6;
    --past: #c7bcc3;
}

:root[data-theme="bright-power"] {
    --bg-1: #fff9d6;
    --bg-2: #d9f9ff;
    --surface: rgba(255, 255, 255, 0.95);
    --text: #102f76;
    --muted: #4c5f92;
    --border: #00ddff;
    --neutral: #e8f4ff;
    --own: #63c2e2;
    --other: #ff1d58;
    --past: #bdc8df;
}

:root[data-theme="deep-blue-tan"] {
    --bg-1: #e1b382;
    --bg-2: #c89666;
    --surface: rgba(255, 248, 238, 0.93);
    --text: #12343b;
    --muted: #2d545e;
    --border: #2d545e;
    --neutral: #ecdcc8;
    --own: #9fc6b6;
    --other: #d58e73;
    --past: #bead97;
}

:root[data-theme="apricot-avalanche"] {
    --bg-1: #f5e6cf;
    --bg-2: #f7c331;
    --surface: rgba(255, 251, 243, 0.95);
    --text: #354052;
    --muted: #6b7a8f;
    --border: #f7882f;
    --neutral: #f0e2cd;
    --own: #9fc4b1;
    --other: #d67f5a;
    --past: #c2b39f;
}

:root[data-theme="trust-blue-green"] {
    --bg-1: #f3f8fb;
    --bg-2: #dce8ee;
    --surface: rgba(255, 255, 255, 0.95);
    --text: #233947;
    --muted: #4d6676;
    --border: #368cbf;
    --neutral: #dbe8f0;
    --own: #7ebc59;
    --other: #e0474c;
    --past: #aebbc4;
}

:root[data-theme="charcoal-gold"] {
    --bg-1: #151515;
    --bg-2: #080808;
    --surface: rgba(30, 30, 30, 0.92);
    --text: #f4e4bf;
    --muted: #c8b894;
    --border: #d8ab4e;
    --neutral: #2f2f2f;
    --own: #5e7d4d;
    --other: #9a5d47;
    --past: #434343;
}

:root[data-bs-theme="dark"] .navbar-brand,
:root[data-bs-theme="dark"] .form-label,
:root[data-bs-theme="dark"] .table,
:root[data-bs-theme="dark"] .table th,
:root[data-bs-theme="dark"] .table td,
:root[data-bs-theme="dark"] .app-card,
:root[data-bs-theme="dark"] .week-table-wrap {
    color: var(--text);
}

:root[data-bs-theme="dark"] .form-control,
:root[data-bs-theme="dark"] .form-select {
    color: var(--text);
    background-color: rgba(20, 24, 34, 0.92);
    border-color: var(--border);
}

:root[data-bs-theme="dark"] .form-control::placeholder {
    color: var(--muted);
}

:root[data-bs-theme="dark"] .form-control:focus,
:root[data-bs-theme="dark"] .form-select:focus {
    color: var(--text);
    background-color: rgba(20, 24, 34, 0.92);
    border-color: #85c6e3;
    box-shadow: 0 0 0 0.2rem rgba(133, 198, 227, 0.25);
}

:root[data-bs-theme="dark"] .btn-light {
    color: var(--text);
    background-color: rgba(26, 33, 44, 0.95);
    border-color: var(--border);
}

:root[data-bs-theme="dark"] .btn-primary {
    color: #141822;
    background-color: #85c6e3;
    border-color: #85c6e3;
}

:root[data-bs-theme="dark"] .btn-primary:hover,
:root[data-bs-theme="dark"] .btn-primary:focus {
    color: #141822;
    background-color: #9ad0e8;
    border-color: #9ad0e8;
}

:root[data-bs-theme="dark"] .btn-outline-secondary {
    color: #85c6e3;
    border-color: #85c6e3;
}

:root[data-bs-theme="dark"] .btn-outline-secondary:hover,
:root[data-bs-theme="dark"] .btn-outline-secondary:focus {
    color: #141822;
    background-color: #85c6e3;
    border-color: #85c6e3;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    color: var(--text);
    background: radial-gradient(circle at top right, var(--bg-2), var(--bg-1));
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

main.container:has(.week-table-wrap) {
    max-width: none;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.background-glow {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 10% 8%, rgba(72, 180, 170, 0.2), rgba(72, 180, 170, 0) 35%),
        radial-gradient(circle at 88% 6%, rgba(64, 138, 230, 0.18), rgba(64, 138, 230, 0) 32%),
        linear-gradient(120deg, transparent, rgba(91, 170, 210, 0.1), transparent);
    pointer-events: none;
    z-index: -1;
}

:root[data-theme="dark"] .background-glow {
    background:
        linear-gradient(140deg, rgba(133, 198, 227, 0.16), rgba(133, 198, 227, 0) 50%),
        radial-gradient(circle at 80% 15%, rgba(244, 113, 205, 0.14), rgba(244, 113, 205, 0) 45%);
}

:root[data-theme="charcoal-gold"] .background-glow {
    background:
        radial-gradient(circle at 15% 10%, rgba(216, 171, 78, 0.16), rgba(216, 171, 78, 0) 42%),
        linear-gradient(145deg, rgba(180, 140, 54, 0.1), rgba(180, 140, 54, 0) 55%);
}

.app-nav {
    background: var(--surface);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}

.nav-tenant-name {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    pointer-events: none;
    font-size: 0.95rem;
    opacity: 0.85;
}

.booking-type-tabs {
    align-items: center;
}

.theme-select {
    width: auto;
    min-width: 13.5rem;
}

.app-card {
    border: 1px solid var(--border);
    background: var(--surface);
}

.text-muted {
    color: var(--muted) !important;
}

.week-table-wrap {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--surface);
}

.week-table {
    margin-bottom: 0;
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

.week-table th,
.week-table td {
    border: 1px solid var(--border) !important;
    text-align: center;
    vertical-align: middle;
}

.week-table thead th.weekend-header {
    background: rgba(205, 73, 73, 0.12);
}

:root[data-theme="dark"] .week-table thead th.weekend-header {
    background: rgba(205, 73, 73, 0.22);
}

.week-badge {
    display: inline-flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--text);
    line-height: 1.2;
    font-size: 0.88rem;
}

.week-badge span {
    color: var(--muted);
    font-size: 0.8rem;
}

.slot-cell {
    min-height: 88px;
    height: auto;
    padding: 0.35rem;
    transition: transform 0.18s ease, filter 0.18s ease;
}

.slot-cell-combined {
    min-height: 108px;
}

.slot-cell:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.slot-cell.neutral {
    background: var(--neutral);
}

.slot-cell.own {
    background: var(--own);
}

.slot-cell.other {
    background: var(--other);
}

.slot-cell.past {
    background: var(--past);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
}

.legend-item.neutral {
    background: var(--neutral);
}

.legend-item.own {
    background: var(--own);
}

.legend-item.other {
    background: var(--other);
}

.slot-action-btn {
    font-size: 0.72rem;
    line-height: 1.1;
    padding: 0.2rem 0.42rem;
}

.machine-entry {
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    padding: 0.25rem;
    margin-bottom: 0.3rem;
}

.machine-entry-compact {
    min-height: 3.15rem;
    max-height: 3.15rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    overflow: hidden;
}

.machine-set-label {
    margin-right: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compact-status-row {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
}

.compact-status {
    white-space: nowrap;
}

.machine-entry:last-child {
    margin-bottom: 0;
}

.machine-neutral {
    background: var(--neutral);
}

.machine-own {
    background: var(--own);
}

.machine-other {
    background: var(--other);
}

.machine-past {
    background: var(--past);
}

.markdown-editor {
    font-family: "Fira Code", "Consolas", monospace;
}

.settings-tab-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.settings-tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.settings-tab-label {
    cursor: pointer;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-weight: 600;
    font-size: 0.92rem;
}

.settings-tab-panel {
    display: none;
}

.settings-card {
    max-width: 680px;
}

.settings-submit {
    justify-self: start;
}

#settings-tab-account:checked~.settings-tab-nav label[for="settings-tab-account"],
#settings-tab-security:checked~.settings-tab-nav label[for="settings-tab-security"],
#settings-tab-language:checked~.settings-tab-nav label[for="settings-tab-language"] {
    background: var(--own);
    border-color: color-mix(in srgb, var(--own) 75%, #000 25%);
    color: #11201a;
}

#settings-tab-account:checked~#settings-panel-account,
#settings-tab-security:checked~#settings-panel-security,
#settings-tab-language:checked~#settings-panel-language {
    display: block;
}

#tab-technical:checked~.settings-tab-nav label[for="tab-technical"],
#tab-booking-types:checked~.settings-tab-nav label[for="tab-booking-types"],
#tab-info:checked~.settings-tab-nav label[for="tab-info"],
#tab-applications:checked~.settings-tab-nav label[for="tab-applications"],
#tab-queues:checked~.settings-tab-nav label[for="tab-queues"],
#tab-logs:checked~.settings-tab-nav label[for="tab-logs"],
#tab-users:checked~.settings-tab-nav label[for="tab-users"] {
    background: var(--own);
    border-color: color-mix(in srgb, var(--own) 75%, #000 25%);
    color: #11201a;
}

#tab-technical:checked~#panel-technical,
#tab-booking-types:checked~#panel-booking-types,
#tab-info:checked~#panel-info,
#tab-applications:checked~#panel-applications,
#tab-queues:checked~#panel-queues,
#tab-logs:checked~#panel-logs,
#tab-users:checked~#panel-users {
    display: block;
}

.info-markdown h1,
.info-markdown h2,
.info-markdown h3 {
    margin-top: 1rem;
}

.info-markdown p,
.info-markdown ul,
.info-markdown ol {
    margin-bottom: 0.8rem;
}

@media (max-width: 768px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .legend {
        font-size: 0.8rem;
    }

    .booking-type-tabs {
        width: 100%;
        margin-top: 0.5rem;
        margin-left: 0 !important;
    }
}