:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-alt: #eef2f8;
    --text: #172033;
    --muted: #68758d;
    --line: #dbe3f0;
    --primary: #1d5eff;
    --danger: #d84f5f;
    --success: #22a06b;
    --warning: #d19400;
    --shadow: 0 12px 30px rgba(18, 33, 63, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(29, 94, 255, 0.08), transparent 24%),
        linear-gradient(180deg, #f8fafe 0%, #f3f6fb 100%);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
code { font-size: 12px; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card, .panel, .stat-card, .modal-dialog {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(219, 227, 240, 0.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(100%, 420px);
    padding: 32px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    padding: 24px 18px;
    border-right: 1px solid var(--line);
    background: rgba(249, 251, 255, 0.84);
}

.brand {
    display: grid;
    gap: 4px;
    margin-bottom: 24px;
}

.brand strong { font-size: 22px; }
.brand span, .topbar p, .panel-head p, .stat-card span, .alert, label span, small { color: var(--muted); }

.nav {
    display: grid;
    gap: 8px;
}

.nav a {
    padding: 12px 14px;
    border-radius: 14px;
    color: var(--muted);
}

.nav a.active, .nav a:hover {
    background: var(--surface);
    color: var(--text);
}

.content { padding: 24px; }

.topbar, .panel-head, .toolbar, .form-actions, .actions, .quick-days, .price-box {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.topbar { margin-bottom: 22px; }
.topbar h1, .panel h2, .panel h3 { margin: 0 0 6px; }

.stats-grid, .calendar-grid, .grid-2, .grid-3, .split, .check-grid {
    display: grid;
    gap: 16px;
}

.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
.stat-card { padding: 20px; }
.stat-card strong { display: block; font-size: 30px; margin-top: 10px; }

.panel { padding: 20px; margin-bottom: 20px; }
.split { grid-template-columns: minmax(320px, 420px) 1fr; align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.calendar-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-card {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 16px;
    padding: 14px;
    text-align: left;
    cursor: pointer;
}

.calendar-card.status-free { border-color: rgba(34, 160, 107, 0.25); background: rgba(34, 160, 107, 0.08); }
.calendar-card.status-partial { border-color: rgba(209, 148, 0, 0.28); background: rgba(209, 148, 0, 0.08); }
.calendar-card.status-full { border-color: rgba(216, 79, 95, 0.28); background: rgba(216, 79, 95, 0.08); }

.button {
    border: 0;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    padding: 11px 16px;
    border-radius: 12px;
    font-weight: 600;
}

.button-muted { background: var(--surface-alt); color: var(--text); }
.button-danger { background: var(--danger); }
.button-small { padding: 8px 12px; font-size: 13px; }

.stack { display: grid; gap: 14px; }
label { display: grid; gap: 8px; font-size: 14px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    background: #fff;
    color: var(--text);
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inline-check input, .check-grid input { width: auto; }

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

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

th { background: #f8faff; font-size: 13px; color: var(--muted); }
.row-conflict { background: rgba(216, 79, 95, 0.08); }
.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
}

.alert.success { border-color: rgba(34, 160, 107, 0.3); color: var(--success); }
.alert.error { border-color: rgba(216, 79, 95, 0.3); color: var(--danger); }
.toolbar { margin-bottom: 14px; }
.toolbar input, .toolbar select { max-width: 320px; }

.pagination {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.pagination a {
    min-width: 38px;
    text-align: center;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--surface-alt);
}

.pagination a.active { background: var(--primary); color: #fff; }

.modal[hidden] { display: none; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 30;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(11, 17, 28, 0.46);
}

.modal-dialog {
    position: relative;
    width: min(980px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow: auto;
    margin: 16px auto;
    padding: 24px;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: 0;
    background: transparent;
    font-size: 28px;
    cursor: pointer;
}

.price-box {
    padding: 14px;
    border-radius: 14px;
    border: 1px dashed var(--line);
    background: #f8fbff;
}

.info-list {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
    .stats-grid, .calendar-grid, .grid-3, .split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .content { padding: 16px; }
    .stats-grid, .calendar-grid, .grid-2, .grid-3, .split, .check-grid { grid-template-columns: 1fr; }
    .topbar, .panel-head, .toolbar, .form-actions, .actions, .quick-days, .price-box { flex-direction: column; align-items: stretch; }
    .sidebar { padding: 16px; }
    .modal-dialog { padding: 18px; }
}
