:root {
    --bg: #f4f6fb;
    --bg-soft: #eef2ff;
    --card: #ffffff;
    --ink: #0f172a;
    --ink-soft: #64748b;
    --line: #dbe4f0;
    --brand: #0b63f1;
    --brand-soft: #dbeafe;
    --danger: #b91c1c;
    --success: #0f766e;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", "Verdana", sans-serif;
    background: radial-gradient(circle at top left, #e0f2fe 0%, #f4f6fb 42%, #e2e8f0 100%);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: linear-gradient(120deg, #0f172a, #1e3a8a);
    color: #f8fafc;
    padding: 1rem 1.25rem;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.2);
}

.topbar h1 {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: 0.01em;
}

.topbar p {
    margin: 0.2rem 0 0;
    color: #dbeafe;
    font-size: 0.92rem;
}

.container {
    width: 100%;
    max-width: 1160px;
    margin: 1.2rem auto;
    padding: 0 1rem;
    flex: 1;
}

.container.narrow {
    max-width: 980px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-header h1 {
    margin: 0.2rem 0 0;
    font-size: 1.35rem;
}

.breadcrumb {
    font-size: 0.88rem;
    color: var(--ink-soft);
}

.breadcrumb a {
    color: var(--brand);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

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

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 1rem;
}

.admin-grid .wide,
.admin-grid .full-width {
    grid-column: span 2;
}

.panel-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    padding: 1rem;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.08);
}

.panel-card h2 {
    margin: 0;
    font-size: 1.08rem;
}

.panel-card h3 {
    margin: 0;
    font-size: 0.95rem;
    color: #334155;
}

.form-stack,
.form-inline,
.settings-grid {
    margin-top: 0.8rem;
    display: grid;
    gap: 0.75rem;
}

.form-stack.compact {
    grid-template-columns: 1fr;
}

.form-inline {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.settings-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.settings-grid .full-span {
    grid-column: 1 / -1;
}

.form-group {
    display: grid;
    gap: 0.35rem;
}

.form-group.inline-small {
    min-width: 220px;
}

label,
legend {
    font-size: 0.86rem;
    color: #334155;
    font-weight: 600;
}

input,
select,
button {
    font: inherit;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 0.48rem;
    padding: 0.45rem 0.55rem;
    background: #fff;
}

textarea {
    resize: vertical;
    min-height: 5.8rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: 2px solid #bfdbfe;
    outline-offset: 1px;
}

.btn {
    border: 1px solid transparent;
    border-radius: 0.5rem;
    padding: 0.48rem 0.75rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 10px 20px rgba(11, 99, 241, 0.28);
}

.btn-secondary {
    background: #fff;
    border-color: var(--line);
    color: #334155;
}

.btn-tiny {
    padding: 0.28rem 0.45rem;
    font-size: 0.76rem;
    border-color: var(--line);
    background: #fff;
}

.btn-danger {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #be123c;
}

.list-wrap,
.table-wrap {
    margin-top: 1rem;
}

.data-list {
    margin: 0.55rem 0 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.35rem;
    color: #1e293b;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.admin-table th,
.admin-table td {
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.55rem 0.4rem;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.day-fieldset {
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    padding: 0.6rem 0.75rem;
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    align-items: center;
}

.day-fieldset label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.settings-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.7rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.7rem;
    margin-bottom: 0.9rem;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.55rem;
}

.status-chip {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 0.42rem 0.76rem;
    background: #f8fafc;
    color: #1e293b;
    font-size: 0.86rem;
}

.mode-chip-view {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #334155;
}

.mode-chip-booking {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.schedule-grid {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.08);
    overflow: auto;
}

.schedule-grid table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.schedule-grid th,
.schedule-grid td {
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    text-align: center;
    padding: 0.5rem 0.35rem;
}

.schedule-grid th {
    background: #f8fafc;
    color: #334155;
    font-size: 0.84rem;
}

.schedule-grid td:first-child,
.schedule-grid th:first-child {
    text-align: left;
    min-width: 120px;
    font-weight: 600;
}

.schedule-grid tr:last-child td {
    border-bottom: none;
}

.schedule-grid th:last-child,
.schedule-grid td:last-child {
    border-right: none;
}

.slot {
    width: 100%;
    border: none;
    border-radius: 0.42rem;
    padding: 0.4rem;
    min-height: 2.2rem;
    font-size: 0.82rem;
}

.slot.free {
    background: #ecfeff;
    color: #0c4a6e;
}

.slot.booked.self {
    background: #1d4ed8;
    color: #fff;
}

.slot.booked.other {
    background: #e2e8f0;
    color: #334155;
}

.slot.closed {
    background: #fef3c7;
    color: #92400e;
}

.slot:disabled {
    opacity: 1;
    cursor: default;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 0.8rem;
    color: var(--ink-soft);
    font-size: 0.86rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 0.3rem;
}

.legend-free {
    background: #ecfeff;
}

.legend-self {
    background: #1d4ed8;
}

.legend-other {
    background: #e2e8f0;
}

.legend-closed {
    background: #fef3c7;
}

.message {
    margin-top: 0.85rem;
    font-size: 0.92rem;
    color: var(--ink-soft);
    min-height: 1.1rem;
}

.message.error {
    color: var(--danger);
}

.message.success {
    color: var(--success);
}

.muted {
    color: var(--ink-soft);
}

.footer {
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.85);
    text-align: center;
    color: var(--ink-soft);
    padding: 0.7rem 1rem;
    font-size: 0.82rem;
}

@media (max-width: 980px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-grid .wide,
    .admin-grid .full-width {
        grid-column: span 1;
    }
}

@media (max-width: 720px) {
    .topbar {
        padding: 0.9rem 0.95rem;
    }

    .container {
        padding: 0 0.7rem;
        margin-top: 0.95rem;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .status-chip {
        width: 100%;
        text-align: center;
    }

    .toolbar-actions {
        width: 100%;
        justify-content: stretch;
    }

    .toolbar-actions .btn {
        width: 100%;
    }
}
