:root {
    --bg: #f0f3f7;
    --side: #1e2a38;
    --side-text: #d7e0ea;
    --accent: #2f6f6a;
    --accent-2: #c47b3a;
    --card: #ffffff;
    --text: #1c2430;
    --muted: #667788;
    --border: #d9e1ea;
    --danger: #b33a3a;
    --ok: #2f7d4a;
    --font: "Segoe UI", "PT Sans", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    background:
        radial-gradient(circle at 10% 10%, rgba(47,111,106,.12), transparent 40%),
        radial-gradient(circle at 90% 0%, rgba(196,123,58,.12), transparent 35%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #243445, var(--side));
    color: var(--side-text);
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    min-height: 100vh;
    position: sticky;
    top: 0;
}
.brand { font-size: 1.35rem; font-weight: 700; color: #fff; letter-spacing: .02em; }
.role { font-size: .8rem; color: #9aafc0; margin-bottom: 1rem; }
.sidebar nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidebar a {
    color: var(--side-text);
    text-decoration: none;
    padding: .55rem .75rem;
    border-radius: 8px;
}
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,.1); color: #fff; }
.logout-form button {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    padding: .5rem;
    border-radius: 8px;
    cursor: pointer;
}

.content { flex: 1; padding: 1.5rem 2rem; }
.content.full { max-width: 480px; margin: 4rem auto; }

h1 { margin: 0 0 1rem; font-size: 1.6rem; }
h2 { margin: 1.5rem 0 .75rem; font-size: 1.15rem; }

.toolbar { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
}
.stat .value { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat .label { color: var(--muted); font-size: .9rem; }

.card, table.wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .5rem; border-bottom: 1px solid var(--border); font-size: .95rem; }
th { color: var(--muted); font-weight: 600; }

.btn, button.btn, a.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff !important;
    border: none;
    border-radius: 8px;
    padding: .55rem 1rem;
    text-decoration: none;
    cursor: pointer;
    font-size: .9rem;
}
.btn.secondary { background: #4a5d73; }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; color: var(--accent) !important; border: 1px solid var(--accent); }

form.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
form.grid .full { grid-column: 1 / -1; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
input, select, textarea {
    width: 100%;
    padding: .55rem .65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
}
.messages { margin-bottom: 1rem; }
.msg { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .4rem; }
.msg.success { background: #e5f6eb; color: var(--ok); }
.msg.error { background: #fdecec; color: var(--danger); }

.appt-list { display: flex; flex-direction: column; gap: .5rem; }
.appt {
    border-left: 5px solid var(--accent);
    background: var(--card);
    border-radius: 8px;
    padding: .75rem 1rem;
    border: 1px solid var(--border);
}
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; background: #e8eef5; }
.badge.scheduled { background: #dcecff; }
.badge.completed { background: #d9f5e4; }
.badge.cancelled { background: #f8d4d4; }
.badge.no_show { background: #fff0cc; }

/* —— График смен —— */
.schedule-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.schedule-title { font-size: 1.2rem; min-width: 10rem; text-align: center; }
.sched-legend { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.sched-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}
.sched-dow {
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
    font-weight: 600;
    padding: .35rem 0;
}
.sched-cell {
    min-height: 120px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .4rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    position: relative;
}
.sched-cell.other-month { opacity: .45; }
.sched-cell.is-today { outline: 2px solid var(--accent); }
.sched-daynum { font-weight: 700; font-size: .9rem; }
.sched-chips { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .72rem;
    line-height: 1.2;
    padding: .25rem .4rem;
    border-radius: 6px;
    max-width: 100%;
    word-break: break-word;
}
.chip-x {
    margin-left: auto;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 .15rem;
    color: inherit;
    opacity: .7;
}
.chip-x:hover { opacity: 1; }
.chip-surgeon { background: #f8d4d4; color: #7a2222; }
.chip-surgeon_assistant { background: #ffe4cc; color: #8a4b12; }
.chip-hospital_doctor { background: #dcecff; color: #1a4a8a; }
.chip-hospital_assistant { background: #cceeff; color: #0a5a7a; }
.chip-evening { background: #e4e4e4; color: #444; }
.btn-add-chip {
    margin-top: auto;
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--muted);
    border-radius: 6px;
    padding: .3rem;
    cursor: pointer;
    font-size: .75rem;
}
.btn-add-chip:hover { border-color: var(--accent); color: var(--accent); }
.sched-popup {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 40, .35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
}
.sched-popup[hidden] { display: none !important; }
.sched-popup-inner { width: min(380px, 100%); padding: 1.25rem; }

.role-hint { display: block; color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.role-hint.missing { color: var(--danger); }
.role-hint a { color: var(--accent); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table, table.wrap { min-width: 480px; }

@media (max-width: 900px) {
    body { flex-direction: column; }
    .sidebar { width: 100%; min-height: auto; position: static; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar a { padding: .65rem .85rem; min-height: 44px; }
    .content { padding: 1rem; }
    form.grid { grid-template-columns: 1fr; }
    .btn, button.btn, a.btn { min-height: 44px; padding: .7rem 1rem; }
    .sched-grid { grid-template-columns: repeat(7, minmax(72px, 1fr)); overflow-x: auto; }
    .sched-cell { min-height: 100px; min-width: 72px; }
    table.wrap { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
