:root {
  --bg: #f5f6f8; --surface: #fff; --text: #1d2330; --muted: #677084; --line: #e2e5eb; --accent: #4353d8; --accent-ink: #fff;
  --free-bg: #f3fbf5; --free-line: #7fbf95; --free-ink: #1f6b3c;
  --hold-bg: #fff4d4; --hold-line: #e9b949; --hold-ink: #6f4e00;
  --paid-bg: #dbf3e3; --paid-line: #6fc08b; --paid-ink: #14532d;
  --done-bg: #e9ecf1; --done-line: #c5cbd6; --done-ink: #475066;
  --bad-bg: #fde4e4; --bad-line: #e59a9a; --bad-ink: #8a1f1f;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 6px; }
code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.num { text-align: right; white-space: nowrap; }
.warn-text { color: #9a5b00; }
.pad { padding: 0 14px 12px; }

.top { display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top nav a { padding: 6px 12px; border-radius: 8px; color: var(--text); }
.top nav a.on { background: #eceefb; color: var(--accent); font-weight: 600; }
.top nav a:hover { text-decoration: none; background: #f0f1f5; }
.who { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px; background: #e6e8ee; color: #3b4458; font-size: 12px; font-weight: 600; text-align: center; line-height: 20px; }
.badge.warn { background: var(--hold-bg); color: var(--hold-ink); }
.badge.alert { background: #e5484d; color: #fff; }
.banner { padding: 8px 20px; background: #eef0f4; border-bottom: 1px solid var(--line); font-size: 14px; }
.banner.warn { background: var(--hold-bg); color: var(--hold-ink); }
.banner.in { border: 0; border-radius: 0; }
main { padding: 18px 20px 60px; max-width: 1500px; margin: 0 auto; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.toolbar h1 { margin-left: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip:hover { text-decoration: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { background: #f1f2f6; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #3644bd; }
.btn.danger { color: var(--bad-ink); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
button.link { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card.narrow { max-width: 640px; }

/* очередь «ждут оплаты» */
.todo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.todo h2 { font-size: 15px; margin-bottom: 8px; }
.todo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 8px; }
.todo-item { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; cursor: pointer; color: var(--text); }
.todo-item:hover { background: #f7f8fa; }
.todo-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.todo-item .state { font-size: 12.5px; color: #b3261e; white-space: nowrap; font-weight: 600; }
.todo-item .state.ok { color: var(--free-ink); font-weight: 500; }
.todo-item .muted { font-size: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #c2c7d2; flex: none; margin-right: 6px; }
.dot.need { background: #e5484d; }
.dot.ok { background: #36a15a; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin: 0 2px 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 14px; height: 14px; border-radius: 4px; border: 1px solid; display: inline-block; }

/* календарь */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 140px; display: flex; flex-direction: column; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day.past { opacity: .6; }
.day > header { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.sp { padding: 6px 8px 8px; border-bottom: 1px dashed var(--line); }
.sp:last-child { border-bottom: 0; }
.sp.closed { background: repeating-linear-gradient(135deg, #f4f5f7, #f4f5f7 6px, #eceef2 6px, #eceef2 12px); }
.sp-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
.closed-note, .empty { font-size: 12.5px; color: var(--muted); padding: 2px 0; }

.slot { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; width: 100%; text-align: left; margin-top: 5px; padding: 6px 8px; border: 1px solid; border-radius: 8px; font: inherit; font-size: 13.5px; cursor: pointer; line-height: 1.3; }
.slot .t { font-weight: 700; grid-row: span 2; align-self: center; }
.slot .w { overflow: hidden; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.slot .st { font-size: 12px; opacity: .9; }
.slot.wide { grid-template-columns: 1fr; }
.slot.wide .t { grid-row: auto; }
.s-free { background: var(--free-bg); border-color: var(--free-line); color: var(--free-ink); border-style: dashed; }
.s-soon, .s-off { background: #f6f7f9; border-color: #cfd4dd; color: #7b8496; border-style: dashed; }
.s-off { cursor: default; grid-template-columns: auto 1fr auto; align-items: center; }
.s-off .t { grid-row: auto; }
.s-hold { background: var(--hold-bg); border-color: var(--hold-line); color: var(--hold-ink); }
.s-paid { background: var(--paid-bg); border-color: var(--paid-line); color: var(--paid-ink); }
.s-done { background: var(--done-bg); border-color: var(--done-line); color: var(--done-ink); }
.s-no_show, .s-cancelled { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-ink); }
.slot:hover:not(.s-off) { filter: brightness(.97); }
.pill { display: inline-block; padding: 1px 9px; border: 1px solid; border-radius: 12px; font-size: 12.5px; font-weight: 600; white-space: nowrap; border-style: solid; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 0 6px; border-radius: 6px; font-size: 16px; line-height: 18px; color: var(--muted); }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: #eceef2; }
.menu-body { position: absolute; right: 0; top: 22px; z-index: 4; width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 25, 40, .14); padding: 8px; display: grid; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); }
.menu-body > button { text-align: left; padding: 7px 8px; border: 0; background: none; border-radius: 6px; font: inherit; cursor: pointer; }
.menu-body > button:hover { background: #f1f2f6; }
.menu-body form { display: flex; align-items: end; gap: 6px; padding: 4px 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.menu-body form label { font-size: 12.5px; color: var(--muted); display: grid; gap: 2px; flex: 1; }

/* формы */
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #cfd4dd; border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c5cbf5; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; margin: 0 6px 0 0; }
textarea { resize: vertical; }
.form { display: grid; gap: 10px; }
.form > .btn, .form > button { justify-self: start; }
.form > label, .form fieldset > label, .grid3 > label { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.form label.check, .form label.radio { display: flex; align-items: center; color: var(--text); font-size: 14px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px 10px; margin: 0; display: grid; gap: 8px; }
fieldset.row { display: flex; gap: 16px; }
legend { font-size: 12.5px; color: var(--muted); padding: 0 4px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline .btn { white-space: nowrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.hint { font-size: 12.5px; color: var(--muted); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: start; }
.checks { display: grid; gap: 6px; padding-top: 18px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week label { display: grid; gap: 3px; font-size: 12.5px; color: var(--muted); }
.sp-form { padding: 12px 0; border-top: 1px solid var(--line); }
.staff-row { grid-template-columns: 1.3fr 1fr 1.2fr auto auto; align-items: end; padding: 8px 0; border-top: 1px solid var(--line); }
.status-line { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.status-line .dot { margin-right: 0; }

/* модальное окно и карточка записи */
dialog#modal { border: 0; border-radius: 14px; padding: 20px 22px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(20, 25, 40, .3); }
dialog#modal::backdrop { background: rgba(20, 25, 40, .45); }
dialog#confirm { border: 0; border-radius: 12px; padding: 18px 20px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(20, 25, 40, .35); }
dialog#confirm::backdrop { background: rgba(20, 25, 40, .35); }
dialog#confirm p { margin: 0 0 14px; }
dialog#modal .x { position: absolute; right: 12px; top: 10px; border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.bk-head { display: flex; align-items: center; gap: 10px; margin-right: 26px; }
.bk-head h2 { margin: 0; }
.when { margin: 6px 0 10px; }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 0 0 10px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.step { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.step h3 { margin: 0 0 4px; }
.step p { margin: 0 0 8px; font-size: 13.5px; }
.fold { border-top: 1px solid var(--line); padding: 8px 0; }
.fold summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.fold[open] summary { margin-bottom: 10px; }
.events { margin: 0; padding-left: 18px; font-size: 13.5px; }

/* таблицы и списки */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.num { text-align: right; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #f7f8fa; }
.empty-page { color: var(--muted); padding: 40px 0; text-align: center; }

.dlg-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.dlg-row { display: flex; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.dlg-row:last-child { border-bottom: 0; }
.dlg-row:hover { background: #f7f8fa; text-decoration: none; }
.dlg-row.attention { box-shadow: inset 3px 0 0 #e5484d; }
.dlg-row .pill { margin-left: 6px; }

.dlg { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.chat { padding: 0; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-head h1 { display: inline; font-size: 17px; margin-right: 8px; }
.messages { padding: 14px; height: min(52vh, 620px); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: #fafbfc; }
.msg { max-width: 78%; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .bubble { padding: 8px 11px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); background: #fff; }
.msg.bot, .msg.staff { align-self: flex-end; }
.msg.bot .meta, .msg.staff .meta { text-align: right; }
.msg.bot .bubble { background: #eef0fb; border-color: #d9dcf5; }
.msg.staff .bubble { background: #dff3e6; border-color: #bfe3cb; }
.msg.note { align-self: center; max-width: 92%; font-size: 12.5px; color: var(--muted); background: #eef0f4; border-radius: 10px; padding: 3px 10px; text-align: center; }
.reply { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); align-items: end; }
.side h3:first-child { margin-top: 0; }

/* вход */
body.center { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { max-width: 440px; }
.login h1 { margin-bottom: 10px; }
.login ol { padding-left: 20px; }
.error { color: var(--bad-ink); background: var(--bad-bg); padding: 8px 10px; border-radius: 8px; }
.dev { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 10px; display: grid; gap: 6px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #1d2330; color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { background: #b3261e; }

@media (max-width: 1200px) { .days { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .days { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dlg { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  .checks { padding-top: 0; }
  .staff-row { grid-template-columns: 1fr; }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  main { padding: 12px 12px 60px; }
  .top { padding: 8px 12px; gap: 10px; }
  .msg { max-width: 92%; }
}
@media (max-width: 520px) {
  .days { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .todo-list { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 90px 1fr; }
  .inline { flex-direction: column; }
}
