:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fbff;
    --text: #1f2937;
    --muted: #64748b;
    --line: #dbe3ee;
    --line-strong: #c6d2e1;
    --primary: #1d4ed8;
    --primary-dark: #153ea8;
    --primary-soft: #eaf1ff;
    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #ffedd5;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.07);
    --shadow-strong: 0 18px 46px rgba(15, 23, 42, 0.14);
    --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }

body {
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
    background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--text);
    line-height: 1.5;
}

body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
.container { width: min(1320px, calc(100% - 32px)); margin: 0 auto; }
.hidden { display: none !important; }

.site-header {
    background: radial-gradient(circle at top left, rgba(255,255,255,0.18), transparent 30%), linear-gradient(135deg, #0f3b8c 0%, #1d4ed8 60%, #3b82f6 100%);
    color: #fff;
    padding: 38px 0 58px;
    box-shadow: var(--shadow-soft);
}

.header-block { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.hero-copy { max-width: 820px; }
.eyebrow { margin: 0 0 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; opacity: .88; }
.site-header h1 { margin: 0; font-size: clamp(32px, 4vw, 46px); line-height: 1.05; }
.subtitle { margin: 12px 0 0; max-width: 780px; font-size: 17px; opacity: .96; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.hero-chip {
    display: inline-flex; align-items: center; min-height: 36px; padding: 8px 14px; border-radius: 999px;
    background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2); font-size: 14px; font-weight: 700;
}

.user-panel { min-width: min(100%, 390px); }
.user-panel-main {
    display: flex; flex-direction: column; gap: 16px; width: 100%;
    background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.24); border-radius: 20px; padding: 16px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
}
.user-panel-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.user-panel-text { display: flex; flex-direction: column; gap: 4px; }
.user-panel-text strong { font-size: 21px; }
.user-panel-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.page-main { padding: 28px 0 44px; margin-top: -24px; }
.intro-panel { margin-bottom: 24px; }
.intro-card, .utility-card, .day-card {
    background: var(--panel); border: 1px solid rgba(219, 227, 238, .9); border-radius: var(--radius); box-shadow: var(--shadow-soft);
}
.intro-card { padding: 22px 24px; }
.auth-card { max-width: 860px; margin: 0 auto; }
.intro-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-kicker, .dialog-kicker, .utility-label {
    margin: 0 0 6px; color: var(--primary); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
}
.intro-head h2, .dialog-header h2 { margin: 0 0 8px; }
.intro-head p, .dialog-header p { margin: 0; }

.status-legend { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.legend-pill, .day-badge {
    display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 7px 12px;
    border-radius: 999px; font-size: 13px; font-weight: 800;
}
.legend-pill-ordinary { background: #dbeafe; color: #1d4ed8; }
.legend-pill-recovery { background: #ffedd5; color: #9a3412; }
.legend-pill-empty { background: #f8fafc; color: #64748b; border: 1px solid var(--line); }
.day-badge { background: var(--primary-soft); color: var(--primary-dark); white-space: nowrap; }

.instructions-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.instruction-item {
    display: flex; align-items: flex-start; gap: 14px; padding: 18px; background: #f8fbff; border: 1px solid var(--line); border-radius: 16px;
}
.instruction-item-primary { background: linear-gradient(180deg, #eff6ff 0%, #f8fbff 100%); border-color: #bfdbfe; }
.instruction-item h3 { margin: 0 0 6px; font-size: 18px; }
.instruction-item p { margin: 0; color: #475569; }
.instruction-step {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 999px;
    background: var(--primary); color: #fff; font-size: 15px; font-weight: 800;
}

.mobile-days-nav {
    display: none; margin-bottom: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-soft); padding: 16px;
}
.mobile-days-head { margin-bottom: 12px; }
.mobile-days-title { margin: 0; font-size: 14px; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: .08em; }
.mobile-days-copy { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.mobile-days-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-day-tab {
    border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 10px 14px; font-weight: 800; color: #334155; cursor: pointer;
}
.mobile-day-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.days-grid { display: grid; grid-template-columns: 1fr; gap: 22px; }
.day-card { overflow: hidden; }
.day-card, .room-section, .day-overview-section, .intro-card { max-width: 100%; }
.day-card-header {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px;
    background: linear-gradient(180deg, #fff 0%, #f8fbff 100%); border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer;
}
.day-card-header h2 { margin: 0; }
.day-card-header:hover { background: linear-gradient(180deg, #fdfefe 0%, #f1f7ff 100%); }
.day-title-block { display: flex; flex-direction: column; gap: 4px; }
.day-date-label { font-size: 13px; color: var(--muted); font-weight: 700; }
.day-header-right { display: flex; align-items: center; gap: 10px; }
.day-toggle-icon {
    display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 999px; background: #eff6ff;
    color: var(--primary-dark); font-size: 18px; transition: transform .18s ease;
}
.day-card-body { padding: 18px; display: grid; gap: 18px; }
.day-card.is-collapsed .day-card-body { display: none; }
.day-card.is-collapsed .day-toggle-icon { transform: rotate(-90deg); }

.room-section {
    border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: linear-gradient(180deg, #fcfdff 0%, #f8fbff 100%);
}
.room-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.room-title { margin: 0; font-size: 18px; }
.room-subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.room-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.room-column {
    border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 14px;
}
.room-column h4 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: #475569; }
.room-empty { margin: 0; color: var(--muted); font-style: italic; }
.stack-list { display: grid; gap: 10px; }

.room-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.room-timeline-wrap { margin-bottom: 12px; }
.room-timeline-table { min-width: 760px; }
.room-timeline-table th, .room-timeline-table td { text-align: left; }
.room-timeline-table th:nth-child(2), .room-timeline-table td:nth-child(2),
.room-timeline-table th:nth-child(4), .room-timeline-table td:nth-child(4),
.room-timeline-table th:nth-child(5), .room-timeline-table td:nth-child(5) { text-align: center; }
.timeline-time-cell { font-weight: 800; white-space: nowrap; }
.timeline-details-cell strong { display: block; margin-bottom: 4px; }
.timeline-subline { color: #475569; font-size: 14px; }
.timeline-actions-cell .btn { white-space: nowrap; }
.timeline-muted { color: var(--muted); }
.timeline-row-free td { background: #f0fdf4; }
.timeline-row-ordinary td { background: #eff6ff; }
.timeline-row-recovery td { background: #fff7ed; }

.booking-card, .free-interval-card, .availability-interval-card {
    border-radius: 14px; padding: 14px; border: 1px solid var(--line); background: #fff;
}
.booking-card.ordinary { background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%); border-color: #bfdbfe; }
.booking-card.recovery { background: linear-gradient(180deg, #fff7ed 0%, #fed7aa 100%); border-color: #fdba74; }
.free-interval-card, .availability-interval-card { background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%); border-color: #86efac; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-title { margin: 0; font-size: 15px; font-weight: 800; }
.card-meta { margin: 0; color: #334155; font-size: 14px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.card-chip {
    display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800;
}
.card-chip-ordinary { background: #dbeafe; color: #1d4ed8; }
.card-chip-recovery { background: #ffedd5; color: #9a3412; }
.card-chip-free { background: #dcfce7; color: #166534; }
.interval-note { margin: 4px 0 0; color: #166534; font-size: 13px; font-weight: 700; }
.day-empty-message {
    padding: 18px; border: 1px dashed var(--line-strong); border-radius: 16px; background: #fff; color: var(--muted); text-align: center;
}

.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.summary-table {
    width: 100%; min-width: 920px; border-collapse: separate; border-spacing: 0; table-layout: auto;
}
.summary-table th, .summary-table td {
    border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: center; vertical-align: middle;
}
.summary-table thead th {
    position: sticky; top: 0; z-index: 1; background: #f8fbff; color: #334155; font-size: 14px; font-weight: 800;
}
.summary-table thead th:first-child, .summary-table tbody td:first-child { border-left: 1px solid var(--line); }
.summary-table tbody tr:nth-child(even) td { background: #fcfdff; }
.empty-summary { text-align: center !important; color: var(--muted); font-style: italic; padding: 18px !important; }

.form-layout { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.compact-row { align-items: end; }
.form-group { display: grid; gap: 8px; }
.form-group label { font-size: 14px; font-weight: 700; color: #334155; }
.form-group input, .form-group select {
    width: 100%; min-height: 48px; border-radius: 14px; border: 1px solid var(--line-strong); background: #fff; padding: 12px 14px; color: var(--text);
}
.readonly-field input { background: #f8fafc; }
.auth-actions { display: flex; justify-content: flex-start; }

.btn {
    appearance: none; border: 0; border-radius: 14px; min-height: 44px; padding: 10px 16px; font-weight: 800; cursor: pointer; transition: transform .08s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:hover { box-shadow: var(--shadow-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: #e2e8f0; color: #0f172a; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #fff; color: var(--primary-dark); border: 1px solid #bfdbfe; }
.btn-large { min-height: 48px; padding: 12px 18px; }
.btn-small { min-height: 36px; padding: 8px 12px; border-radius: 12px; font-size: 13px; }

.overlay {
    position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(15, 23, 42, .58); backdrop-filter: blur(3px);
}
.dialog {
    position: relative; width: 100%; max-width: 660px; max-height: 90vh; overflow-y: auto; background: var(--panel); border-radius: 24px; padding: 28px;
    box-shadow: 0 30px 70px rgba(15, 23, 42, .24); border: 1px solid rgba(219, 227, 238, .85);
}
.dialog-small { max-width: 520px; }
.dialog-wide { max-width: 980px; }
.dialog-header { position: sticky; top: -28px; z-index: 5; margin-bottom: 18px; padding: 0 0 14px; background: var(--panel); }
.dialog-header.center { text-align: center; }
.dialog-message { margin-top: 6px; font-size: 16px; color: #334155; }
.dialog-close {
    position: absolute;
    top: 16px;
    right: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    z-index: 1100;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.dialog-close:hover {
    background: #eff6ff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
    transform: scale(1.03);
}
.dialog-close:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
}
.dialog-note {
    margin: 0 0 18px; padding: 14px 16px; border-radius: 16px; background: #f8fbff; border: 1px solid var(--line); color: #475569; font-weight: 600;
}
.dialog-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }
.compact-actions { margin-top: 12px; }
.steps-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 18px; }
.step-pill {
    display: inline-flex; align-items: center; min-height: 34px; padding: 7px 12px; border-radius: 999px; background: #eff6ff; color: var(--primary-dark); font-size: 13px; font-weight: 800;
}

.availability-box {
    margin-top: 20px; padding: 18px; border-radius: 18px; background: linear-gradient(180deg, #f6fbff 0%, #eef5ff 100%); border: 1px solid var(--line);
}
.availability-head h3 { margin: 0 0 6px; }
.availability-head p { margin: 0; color: #475569; }
.availability-intervals { display: grid; gap: 12px; margin-top: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.selected-interval-box {
    margin-top: 18px; padding: 16px; border-radius: 16px; border: 1px solid #bfdbfe; background: #fff;
}
.selected-interval-box h3 { margin: 0 0 6px; }
.selected-interval-box p { margin: 0 0 12px; color: #334155; }

.admin-summary-content { display: grid; gap: 14px; }
.admin-summary-block {
    border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: #f8fbff;
}
.admin-summary-block h3 { margin: 0 0 8px; }
.admin-summary-block p, .admin-summary-block ul { margin: 0; color: #334155; }
.admin-summary-block ul { padding-left: 18px; }


.mobile-timeline-list {
    display: none;
}

.mobile-timeline-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}
.mobile-timeline-card.mobile-free {
    background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
    border-color: #86efac;
}
.mobile-timeline-card.mobile-ordinary {
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #bfdbfe;
}
.mobile-timeline-card.mobile-recovery {
    background: linear-gradient(180deg, #fff7ed 0%, #fed7aa 100%);
    border-color: #fdba74;
}
.mobile-timeline-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.mobile-timeline-time {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
}
.mobile-timeline-duration {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.mobile-timeline-title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
}
.mobile-timeline-subtitle {
    margin: 4px 0 0;
    color: #334155;
    font-size: 14px;
}
.mobile-timeline-note {
    margin: 8px 0 0;
    color: #166534;
    font-size: 13px;
    font-weight: 700;
}
.mobile-timeline-actions {
    margin-top: 12px;
}
.mobile-timeline-actions .btn {
    width: 100%;
}

:focus-visible {
    outline: 3px solid rgba(29, 78, 216, .25);
    outline-offset: 2px;
}

@media (max-width: 980px) {
    .header-block, .intro-head, .room-header { flex-direction: column; align-items: flex-start; }
    .instructions-grid, .room-grid, .form-row, .availability-intervals { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    html, body { overflow-x: hidden; }
    .container { width: min(100%, calc(100% - 20px)); }
    .page-main { padding-top: 20px; }
    .site-header { padding: 28px 0 44px; }
    .subtitle { font-size: 15px; }
    .hero-chips, .status-legend { gap: 8px; }
    .hero-chip, .legend-pill, .day-badge { min-height: 32px; padding: 6px 10px; font-size: 12px; }
    .intro-card { padding: 18px; }
    .mobile-days-nav { display: block; position: sticky; top: 10px; z-index: 30; }
    .mobile-days-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .mobile-day-tab { width: 100%; min-height: 42px; padding: 8px 10px; font-size: 13px; }
    .day-table { display: none; }
    .day-table.mobile-active { display: block; }
    .day-card-header { display: none; }
    .day-card { border-radius: 18px; }
    .day-card-body { padding: 14px; overflow-x: hidden; }
    .day-overview-section, .room-section, .room-column { padding-left: 12px; padding-right: 12px; }
    .day-overview-head, .room-header, .card-head, .mobile-timeline-top { flex-direction: column; align-items: stretch; }
    .day-overview-head .btn, .room-actions .btn { width: 100%; }
    .room-section { padding: 14px; }
    .room-header { margin-bottom: 12px; }
    .room-title { font-size: 17px; }
    .room-subtitle { font-size: 13px; }
    .room-actions { width: 100%; }
    .room-actions .btn { flex: 1 1 100%; }
    .toggle-room-table-btn { display: none; }
    .room-timeline-wrap { display: none !important; }
    .room-cards-layout { display: none !important; }
    .mobile-timeline-list { display: grid; gap: 12px; }
    .summary-panel .table-wrap { overflow-x: auto; }
    .summary-table { min-width: 760px; width: max-content; }
    .dialog { padding: 22px 18px; border-radius: 20px; max-height: 92vh; }
    .dialog-header { top: -22px; }
    .dialog-actions { flex-direction: column; }
    .dialog-actions .btn { width: 100%; }
}


.mobile-export-buttons {
    display: none;
    margin-top: 12px;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.desktop-export-day-btn {
    white-space: nowrap;
}

.export-day-pdf-btn.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

@media (max-width: 820px) {
    .mobile-export-buttons {
        display: grid;
    }

    .mobile-export-buttons .btn {
        width: 100%;
    }

    .desktop-export-day-btn {
        display: none;
    }
}

.day-export-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 12px 18px 0;
}

@media (max-width: 820px) {
    .day-export-toolbar {
        display: none;
    }
}


.user-panel-actions .hidden { display: none !important; }
#admin-remove-user-select,
#admin-credentials-select { min-height: 220px; }
.admin-credentials-result {
    border: 1px solid var(--line);
    background: #f8fbff;
    border-radius: 16px;
    padding: 16px;
}


.single-column-row {
    grid-template-columns: minmax(0, 1fr);
}
