: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; }
html {
    min-height: 100%;
}
body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    min-height: 100vh;
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at calc(240px + 10%) 10%, rgba(47,111,106,.12), transparent 40%),
        radial-gradient(circle at 90% 0%, rgba(196,123,58,.12), transparent 35%);
    background-repeat: no-repeat;
}
/* тёмная полоса меню на ВСЮ высоту документа (не только viewport) */
body.has-sidebar {
    background-color: var(--bg);
    background-image:
        linear-gradient(180deg, #243445, var(--side)),
        radial-gradient(circle at calc(240px + 10%) 10%, rgba(47,111,106,.12), transparent 40%),
        radial-gradient(circle at 90% 0%, rgba(196,123,58,.12), transparent 35%);
    background-size: 240px 100%, auto, auto;
    background-position: left top, 0 0, 0 0;
    background-repeat: no-repeat, no-repeat, no-repeat;
    background-attachment: scroll, scroll, scroll;
}

.app-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    width: 240px;
    flex: 0 0 240px;
    align-self: stretch;
    background: linear-gradient(180deg, #243445, var(--side));
    color: var(--side-text);
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    min-height: 100%;
    position: static !important;
    top: auto !important;
}
.brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
    color: #fff;
    margin-bottom: .15rem;
}
.brand-logo-wrap {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,.08);
    overflow: hidden;
}
.sidebar .brand img.brand-logo,
img.brand-logo {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    object-fit: contain;
    display: block;
}
.brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .01em;
    line-height: 1.25;
    /* только по пробелам — не рвать «Ветеринарной» посередине */
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
    text-wrap: balance;
}
.role { font-size: .8rem; color: #9aafc0; margin-bottom: 1rem; }
.account-link {
    color: inherit;
    text-decoration: none;
    display: inline-block;
    padding: .2rem .15rem;
    border-radius: 6px;
}
.account-link:hover,
.account-link.active { color: #fff; text-decoration: underline; }
.sidebar nav { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 auto; }
.sidebar nav a {
    color: var(--side-text);
    text-decoration: none;
    padding: .55rem .75rem;
    border-radius: 8px;
}
.sidebar nav a:hover,
.sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.sidebar .brand:hover { background: transparent; color: #fff; }
.sidebar nav a.nav-help {
    margin-top: .75rem;
    padding-top: .7rem;
    border-top: 1px solid rgba(255,255,255,.12);
    border-radius: 0 0 8px 8px;
}
.account-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
}
.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 1 auto;
    min-width: 0;
    padding: 1.5rem 2rem;
    background: transparent;
}
.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; }

table.wrap.table-compact {
    padding: .45rem .55rem;
}
table.wrap.table-compact th,
table.wrap.table-compact td {
    padding: .22rem .4rem;
    font-size: .88rem;
    line-height: 1.25;
}

.split-btn { position: relative; display: inline-block; }
.split-btn[open] { z-index: 40; }
.split-btn > summary {
    list-style: none;
    cursor: pointer;
}
.split-btn > summary::-webkit-details-marker { display: none; }
.split-btn > summary::marker { content: ''; }
.split-btn > summary::after { content: ' ▾'; }
.split-menu {
    position: absolute;
    z-index: 41;
    top: calc(100% + 4px);
    left: 0;
    min-width: 240px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: .35rem;
}
.split-menu a {
    display: block;
    padding: .45rem .65rem;
    border-radius: 6px;
    color: inherit !important;
    text-decoration: none;
}
.split-menu a:hover { background: #eef3f8; }

.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); }
.btn-add-line {
    display: flex;
    width: 100%;
    justify-content: center;
    align-items: center;
    gap: .45rem;
    min-height: 56px;
    margin-top: .85rem;
    font-size: 1.15rem;
    font-weight: 700;
    border: 2px dashed var(--accent);
    background: #eef6ff;
    color: var(--accent) !important;
    border-radius: 12px;
    cursor: pointer;
}
.btn-add-line:hover { background: #dceeff; }
.btn-rm {
    white-space: nowrap;
    padding: .4rem .7rem;
}
.lines-empty td {
    text-align: center;
    color: var(--muted);
    padding: 1.25rem .5rem;
}
.muted { color: var(--muted); font-size: .85rem; }
.combo { position: relative; min-width: 0; }
.combo-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    width: 100%;
    padding: .55rem .65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.combo-trigger:focus,
.combo-trigger.is-open { outline: none; border-color: var(--accent); }
.combo-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.combo-label.is-placeholder { color: var(--muted); }
.combo-chevron { color: var(--muted); font-size: .8rem; flex-shrink: 0; }
.combo-invalid .combo-trigger { border-color: var(--danger); background: #fff5f5; }
.combo-list[hidden] { display: none !important; }
.combo-list:not([hidden]) {
    display: flex;
    position: fixed;
    z-index: 80;
    flex-direction: column;
    max-height: 360px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(20, 32, 48, .12);
    overflow: hidden;
}
.combo-search-wrap {
    flex-shrink: 0;
    padding: .45rem .5rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
}
.combo-search {
    width: 100%;
    padding: .4rem .6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #f7f9fc;
}
input[type="search"] {
    -webkit-appearance: none;
    appearance: none;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}
.combo-options { overflow: auto; flex: 1; padding: .25rem 0; }
.combo-group {
    padding: .35rem .75rem .15rem;
    font-size: .75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.combo-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    font: inherit;
    padding: .45rem .75rem;
    cursor: pointer;
    color: var(--text);
}
.combo-item:hover,
.combo-item.is-active { background: #eef4fb; }
.combo-item.is-selected { font-weight: 600; }
.combo-empty,
.combo-more {
    padding: .45rem .75rem;
    color: var(--muted);
    font-size: .85rem;
}
.inline-delete { display: inline; margin: 0; }
.inline-delete button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--danger);
    cursor: pointer;
}
.inline-delete button:hover { text-decoration: underline; }

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; color: var(--text); }
.badge.scheduled { background: #dcecff; }
.badge.completed { background: #d9f5e4; }
.badge.cancelled { background: #f8d4d4; }
.badge.no_show { background: #fff0cc; }
.badge.paid { background: #d9f5e4; }
.badge.unpaid { background: #f8d4d4; }
.badge.partial { background: #fff0cc; }
.badge.active { background: #d9f5e4; }
.badge.closed,
.badge.fired,
.badge.inactive,
.badge.deceased,
.badge.lost { background: #e8eef5; color: #5a6570; }
.badge.created { background: #dcecff; }
.badge.updated { background: #fff0cc; }
.badge.deleted { background: #f8d4d4; }
.badge.status_changed { background: #e8d4f8; }

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.1rem;
}
.filter-block {
    margin-bottom: .85rem;
}
.filter-block .filter-pills {
    margin-bottom: .35rem;
}
.filter-label {
    font-size: .8rem;
    color: var(--muted);
    margin-bottom: .35rem;
    font-weight: 600;
    letter-spacing: .02em;
}
.pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    text-decoration: none;
    font-size: .88rem;
}
.pill:hover { border-color: rgba(47,111,106,.45); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff !important; }
.pill .count { opacity: .7; font-size: .85em; }
.pill.active .count { opacity: .85; }

.report-tabs {
    margin: 0 0 1.25rem;
    padding-bottom: .85rem;
    border-bottom: 1px solid var(--border);
}
.report-tabs .pill { font-weight: 600; }

/* —— График смен —— */
.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-cell.is-past { background: #f4f6f8; }
.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(18, 28, 40, .48);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
}
.sched-popup[hidden] { display: none !important; }
.sched-popup-inner {
    width: min(420px, 100%);
    padding: 1.35rem 1.4rem 1.5rem;
    max-height: 92vh;
    overflow-y: auto;
    border: none;
    border-radius: 16px;
    box-shadow:
        0 4px 6px rgba(18, 28, 40, .06),
        0 20px 48px rgba(18, 28, 40, .22);
}
.sched-popup-inner > h3 {
    margin: 0 0 .35rem;
    font-size: 1.2rem;
    letter-spacing: -.01em;
}
.sched-popup-inner > p {
    margin: 0 0 1.1rem;
    line-height: 1.4;
}

/* —— Выбор клиента / питомца —— */
.picker-layer { z-index: 60; }
.picker-modal {
    width: min(480px, 100%);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: min(88vh, 640px);
}
.picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1.15rem 1.25rem .85rem;
    border-bottom: 1px solid var(--border);
}
.picker-head h3 {
    margin: 0;
    font-size: 1.15rem;
    letter-spacing: -.01em;
}
.picker-head .btn.ghost {
    border: none;
    color: var(--muted) !important;
    padding: .35rem .55rem;
    min-height: auto;
    font-size: .85rem;
}
.picker-head .btn.ghost:hover {
    color: var(--text) !important;
    background: #eef2f6;
}
.picker-body {
    padding: 1rem 1.25rem 1.25rem;
    overflow-y: auto;
    flex: 1;
}
.picker-tabs {
    display: flex;
    gap: .3rem;
    margin: 0 1.25rem .9rem;
    background: #e8eef4;
    padding: .28rem;
    border-radius: 12px;
}
.picker-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: .6rem .75rem;
    border-radius: 9px;
    cursor: pointer;
    font: inherit;
    font-size: .92rem;
    font-weight: 600;
    color: var(--muted);
    min-height: 42px;
    transition: background .15s, color .15s, box-shadow .15s;
}
.picker-tab:hover:not(.active) { color: var(--text); }
.picker-tab.active {
    background: #fff;
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(30, 42, 56, .1);
}
.picker-search {
    margin-bottom: .75rem;
    padding: .7rem .9rem .7rem 2.4rem;
    border-radius: 11px;
    border-color: #c9d5e2;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667788' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E")
        .85rem 50% / 16px no-repeat #f7f9fb;
    font-size: .95rem;
}
.picker-search:focus {
    outline: none;
    border-color: var(--accent);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(47, 111, 106, .18);
}
.picker-list {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    max-height: 320px;
    overflow-y: auto;
    padding-right: .15rem;
}
.picker-item {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: .75rem;
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 12px;
    padding: .7rem .85rem;
    cursor: pointer;
    font: inherit;
    min-height: 60px;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.picker-item:hover, .picker-item:focus {
    border-color: rgba(47, 111, 106, .45);
    background: #f2f9f7;
    box-shadow: 0 2px 8px rgba(47, 111, 106, .1);
    outline: none;
}
.picker-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .02em;
    color: #fff;
    background: linear-gradient(135deg, #3a8a84, var(--accent));
    flex-shrink: 0;
}
.picker-avatar.pet {
    background: linear-gradient(135deg, #d4924e, var(--accent-2));
    border-radius: 12px;
}
.picker-item-main {
    display: flex;
    flex-direction: column;
    gap: .18rem;
    min-width: 0;
}
.picker-item-main strong {
    font-size: .95rem;
    font-weight: 650;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.picker-item-main span {
    color: var(--muted);
    font-size: .82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.picker-item-go {
    color: var(--accent);
    font-size: 1.1rem;
    opacity: 0;
    transition: opacity .15s;
}
.picker-item:hover .picker-item-go,
.picker-item:focus .picker-item-go { opacity: 1; }
.picker-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--muted);
    font-size: .92rem;
    line-height: 1.45;
    background: #f7f9fb;
    border: 1px dashed var(--border);
    border-radius: 12px;
}
.picker-field { margin-bottom: .9rem; }
.picker-field > label {
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: #7a8b9c;
    margin-bottom: .4rem;
}
.picker-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .65rem;
    width: 100%;
    min-height: 52px;
    padding: .7rem .95rem;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: #fff;
    font: inherit;
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.picker-trigger > span:first-child {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.picker-trigger:disabled {
    opacity: .5;
    cursor: not-allowed;
    background: #f3f5f8;
}
.picker-trigger:not(:disabled):hover {
    border-color: rgba(47, 111, 106, .5);
}
.picker-trigger:not(:disabled):focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 106, .16);
}
.picker-trigger.is-filled {
    border-color: rgba(47, 111, 106, .35);
    background: linear-gradient(180deg, #f7fcfb, #fff);
}
.picker-trigger.is-filled #clientTriggerText,
.picker-trigger.is-filled #petTriggerText,
.picker-trigger.is-filled .picker-value {
    color: var(--text);
    font-weight: 600;
}
.picker-placeholder { color: var(--muted); font-weight: 400; }
.picker-chevron {
    color: var(--muted);
    font-size: .75rem;
    flex-shrink: 0;
}
.picker-sub {
    margin-top: 1rem;
    padding: .9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f7f9fb;
}
.check-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}
.check-row input { width: auto; accent-color: var(--accent); }
.picker-pane .full { grid-column: 1 / -1; }
.picker-pane .grid label {
    font-size: .8rem;
    font-weight: 600;
    color: #5a6b7c;
}
.picker-pane input,
.picker-pane select,
.picker-pane textarea {
    border-radius: 10px;
    border-color: #c9d5e2;
    padding: .6rem .75rem;
}
.picker-pane input:focus,
.picker-pane select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 106, .16);
}
.picker-owner-line {
    margin: -.25rem 1.25rem .85rem;
    padding: .45rem .75rem;
    background: #eef6f5;
    color: var(--accent);
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 600;
}
.picker-actions {
    display: flex;
    gap: .65rem;
    margin-top: 1.1rem;
    padding-top: .25rem;
}
.picker-actions .btn { flex: 1; min-height: 44px; font-weight: 600; }
.picker-actions .btn.ghost {
    flex: 0 0 auto;
    min-width: 6.5rem;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 106, .14);
}

.role-hint { display: block; color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.role-hint.missing { color: #b8860b; }
.role-hint a { color: var(--accent); }

.chip-appt {
    background: color-mix(in srgb, var(--chip-color, #4A90D9) 28%, #fff);
    color: #1c2430;
    border-left: 3px solid var(--chip-color, #4A90D9);
}
.chip-appt.chip-cancelled,
.chip-appt.chip-no_show { opacity: .55; }
.chip-appt.chip-completed {
    background: color-mix(in srgb, #2f9e66 18%, #fff);
}
.chip-link { color: inherit; text-decoration: none; flex: 1; }
.chip-link:hover { text-decoration: underline; }
.busy-slots {
    background: #fff8e8;
    border: 1px solid #f0d9a8;
    border-radius: 8px;
    padding: .6rem .75rem;
    font-size: .85rem;
}
.busy-slots ul { margin: .35rem 0 0; padding-left: 1.1rem; }
.busy-slots li { margin: .15rem 0; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table, table.wrap { min-width: 480px; }

/* §15 Инструкции */
.help-layout {
    display: grid;
    grid-template-columns: minmax(200px, 240px) 1fr;
    gap: 1.5rem;
    align-items: start;
}
.help-nav {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem .85rem;
    position: sticky;
    top: 1rem;
}
.help-nav-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 1rem;
}
.help-nav-group {
    margin-bottom: .9rem;
}
.help-nav-group-title {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin: 0 0 .35rem .5rem;
}
.help-nav a {
    display: block;
    padding: .4rem .55rem;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: .92rem;
}
.help-nav a:hover { background: rgba(47,111,106,.08); }
.help-nav a.active {
    background: var(--accent);
    color: #fff !important;
}
.help-article {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.35rem 1.5rem 1.75rem;
    max-width: 720px;
}
.help-article h1 {
    margin: 0 0 1.1rem;
    font-size: 1.45rem;
}
.help-article h2 {
    margin: 1.4rem 0 .55rem;
    font-size: 1.05rem;
    color: var(--accent);
}
.help-article p { margin: 0 0 .75rem; line-height: 1.5; }
.help-article ol, .help-article ul {
    margin: 0 0 1rem;
    padding-left: 1.25rem;
    line-height: 1.5;
}
.help-article li { margin: .35rem 0; }
.help-article ol { list-style: none; padding-left: 0; counter-reset: helpstep; }
.help-article ol > li {
    counter-increment: helpstep;
    position: relative;
    padding-left: 2.1rem;
    margin: .55rem 0;
}
.help-article ol > li::before {
    content: counter(helpstep);
    position: absolute;
    left: 0;
    top: 0;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent) 18%, #fff);
    color: var(--accent);
    font-weight: 700;
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.help-warn {
    margin-top: 1.25rem;
    padding: .9rem 1rem;
    border-radius: 10px;
    border: 1px solid #e8c56a;
    background: #fff8e8;
}
.help-warn h2 {
    margin: 0 0 .5rem;
    color: #8a5a10;
    font-size: 1rem;
}
.help-warn ul { margin-bottom: 0; }
.help-article a { color: var(--accent); }
.help-contacts {
    margin-top: 1.75rem;
    padding-top: .9rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .88rem;
}
.help-contacts a { font-weight: 600; }

.rate-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: .75rem;
    margin-top: .35rem;
}
.rate-field {
    border: 1px solid var(--rate-border, var(--border));
    background: var(--rate-bg, #fff);
    border-left: 5px solid var(--rate-accent, var(--accent));
    border-radius: 10px;
    padding: .75rem .85rem .85rem;
}
.rate-field:focus-within {
    box-shadow: 0 0 0 2px var(--rate-accent);
}
.rate-field-head {
    font-weight: 700;
    font-size: .95rem;
    color: var(--rate-accent);
    line-height: 1.3;
    margin-bottom: .25rem;
}
.rate-field-desc {
    font-size: .82rem;
    color: #4a5a68;
    margin: 0 0 .55rem;
    line-height: 1.35;
}
.rate-field label { margin-top: .15rem; }
.rate-field input, .rate-field select { background: #fff; }
.rate-field-services { margin: 0 0 .55rem; font-size: .8rem; }
.rate-field-services summary {
    cursor: pointer;
    color: var(--rate-accent);
    font-weight: 600;
}
.rate-field-services ul {
    margin: .35rem 0 0;
    padding-left: 1.1rem;
    max-height: 9rem;
    overflow: auto;
}
.rate-legend {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: .65rem;
    margin-top: .75rem;
}
.rate-fixed { --rate-accent: #4a5d73; --rate-bg: #f3f5f8; --rate-border: #cfd6de; }
.rate-tone-0 { --rate-accent: #2f6f6a; --rate-bg: #eef6f5; --rate-border: #c5ddd9; }
.rate-tone-1 { --rate-accent: #c47b3a; --rate-bg: #fbf3ea; --rate-border: #ead4bb; }
.rate-tone-2 { --rate-accent: #3a5f9c; --rate-bg: #eef2f9; --rate-border: #c5d0e4; }
.rate-tone-3 { --rate-accent: #6b4c9a; --rate-bg: #f4eef9; --rate-border: #d5c6e6; }
.rate-tone-4 { --rate-accent: #2a7a8c; --rate-bg: #eaf5f7; --rate-border: #b9d6dc; }
.rate-tone-5 { --rate-accent: #5a6b4a; --rate-bg: #f1f4ec; --rate-border: #cdd6c0; }
.rate-tone-6 { --rate-accent: #8a4a5a; --rate-bg: #f8eef1; --rate-border: #e0c5cc; }
.rate-tone-7 { --rate-accent: #6a5a3a; --rate-bg: #f6f1e8; --rate-border: #ddd0b8; }

@media (max-width: 900px) {
    body.has-sidebar {
        background-image:
            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%);
        background-size: auto, auto;
    }
    .app-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex: none;
        min-height: auto;
        position: static !important;
    }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar nav a { padding: .65rem .85rem; min-height: 44px; }
    .sidebar nav a.nav-help { margin-top: .25rem; border-top: none; }
    .help-layout { grid-template-columns: 1fr; }
    .help-nav { position: static; }
    .content { padding: 1rem; }
    form.grid { grid-template-columns: 1fr; }
    .account-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; }
}

.line-staff {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem .65rem;
    align-items: end;
}
.line-staff-field {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 8.5rem;
    flex: 1;
}
.line-staff-field[hidden],
.line-staff-warn[hidden] {
    display: none !important;
}
.line-staff-warn {
    display: block;
    font-size: .78rem;
    color: #b8860b;
    max-width: 16rem;
}
.line-staff-label {
    font-size: .78rem;
    color: var(--muted);
}
.line-staff select {
    min-height: 2.2rem;
}
