:root {
  --bg: #f1f3f7;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #7b8598;
  --line: #e3e7ee;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --danger: #e5484d;
  --shadow: 0 1px 2px rgba(24, 39, 75, .08), 0 2px 8px rgba(24, 39, 75, .06);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
}

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

.layout { display: flex; height: 100%; }
.app { display: flex; flex-direction: column; height: 100%; flex: 1 1 auto; min-width: 0; }

/* Left navigation rail */
.sidebar {
  flex: 0 0 76px;
  width: 76px;
  background: #1f2733;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 10px 8px;
}
.side-brand {
  color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .3px;
  text-align: center; padding: 6px 0 10px;
}
.side-brand span { color: var(--accent); }
.nav-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 8px; }
.nav-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #aab4c4;
  cursor: pointer;
  line-height: 1;
  text-decoration: none;
}
.nav-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-btn.active { background: var(--accent); color: #fff; }
.nav-ico { font-size: 20px; }
.nav-lbl { font-size: 11px; }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar {
    flex: 0 0 auto; width: auto;
    flex-direction: row; justify-content: center;
    padding: 6px 8px;
  }
  .nav-btn { flex-direction: row; gap: 6px; padding: 8px 12px; }
}

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; margin-right: 4px; }
.brand span { color: var(--accent); }
.header .spacer { flex: 1 1 auto; }
.spacer { flex: 1 1 auto; }
.filter-select, .filter-date {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); font: inherit; font-size: 13px;
}

.pipeline-select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  min-width: 180px;
}

.btn {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  white-space: nowrap;
}
.btn:hover { border-color: #c7cedb; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #2a63d6; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: #fdecec; }
.btn-sm { padding: 4px 8px; font-size: 12px; border-radius: 6px; }

/* Board */
.board-wrap { flex: 1 1 auto; overflow: auto; padding: 14px; }
.board { display: flex; gap: 12px; align-items: flex-start; min-height: 100%; }

.column {
  flex: 0 0 288px;
  width: 288px;
  background: #e9ecf3;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: 100%;
}
.column.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; background: #e2ebfb; }

.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.column-title { font-weight: 600; font-size: 13px; }
.column-title.won { color: #2e7d32; }
.column-title.lost { color: #9aa2af; }
.column-meta { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; }
.column-sum { display: block; font-size: 11px; }

.column-body {
  padding: 4px 8px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 24px;
}

.card {
  position: relative;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px;
  border: 1px solid transparent;
}
/* Unread: a red dot in the corner plus a subtle left accent and bolder title. */
.card.unread { box-shadow: inset 3px 0 0 #e5484d, var(--shadow); }
.card.unread .card-title { font-weight: 700; }
.unread-dot {
  position: absolute; top: 8px; right: 8px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #e5484d; box-shadow: 0 0 0 2px var(--panel);
}
.card:hover { border-color: #d5dae4; }
.card.dragging { opacity: .4; }
/* Cards from an Avito account are outlined in their teacher's colour (the
   colour itself comes from an inline border-color, which beats :hover). */
.card.has-teacher { border-width: 2px; border-left-width: 4px; }
.card-title { font-weight: 600; word-break: break-word; }
.card-price { color: #2e7d32; font-size: 13px; margin-top: 3px; }
.card-lost { color: #b4232a; font-size: 12px; margin-top: 3px; }
.card-fields { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.card-teacher {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.card-teacher .dot,
.deal-teacher .dot { border-radius: 50%; flex: none; }
.card-teacher .dot { width: 8px; height: 8px; }
.deal-teacher {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}
.deal-teacher .dot { width: 10px; height: 10px; }
.deal-teacher b { color: var(--ink); font-weight: 600; }
.hint-warn {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  margin: 8px 0;
}
.req { color: var(--danger); }
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  margin-left: 8px;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.trial-row { display: flex; gap: 8px; flex-wrap: wrap; }
.trial-row input[type="date"] { flex: 1 1 150px; }
.trial-row input[type="time"] { flex: 0 0 110px; }
.trial-row select { flex: 0 0 110px; }

/* Read-only view of the deal card (opens before editing). */
.view-field { margin-bottom: 12px; }
.view-field .vf-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.view-field .vf-value { font-size: 14px; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.contact-ro-head { display: flex; align-items: center; gap: 8px; }
.contact-ro-lines { margin-top: 4px; font-size: 13px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }

/* Card action bar — scoped to the left "карточка", not the whole modal, and
   pinned to the bottom of that pane: margin-top:auto drops it down when the
   fields are short, sticky keeps it visible while they scroll. */
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 14px 0 2px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--panel);
}
.chip {
  font-size: 11px;
  background: var(--bg);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.quick-add { padding: 6px 8px 8px; }
.quick-add textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel);
}
.add-deal { margin: 0 8px 8px; }

/* Modal */
.overlay {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow: auto;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 12px 40px rgba(16, 24, 40, .28);
}
.modal.wide { max-width: 680px; }
.modal.xl { max-width: 1700px; width: 95vw; }
.modal-body.flush { padding: 0; }

/* Two-pane deal card: fields + contacts left, communication tabs right.
   Sized to fill the viewport minus the overlay padding, the modal header and a
   comfortable bottom gap, so it's large but never overflows into a page scroll. */
.deal-card { display: flex; height: calc(100vh - 180px); }
.deal-left {
  flex: 0 0 42%; max-width: 42%;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line); overflow: hidden;
}
.deal-left.scripts-mode { flex-basis: 52%; max-width: 52%; }
.left-toolbar { flex: 0 0 auto; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.left-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 18px 20px; display: flex; flex-direction: column; gap: 12px;
}
.scripts-frame { flex: 1 1 auto; min-height: 0; width: 100%; border: 0; background: var(--panel); }
.deal-right { flex: 1 1 auto; min-width: 0; display: flex; }

.panels { display: flex; flex-direction: column; width: 100%; height: 100%; }
.panel-tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.panel-tab {
  border: none; background: transparent; color: var(--muted);
  padding: 8px 12px; border-radius: 8px 8px 0 0; cursor: pointer; font: inherit;
}
.panel-tab:hover { background: var(--bg); color: var(--ink); }
.panel-tab.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); font-weight: 600; }
.panel-content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.panel-content > * { flex: 1 1 auto; min-height: 0; }
/* Channel panel scrolls as a whole; notes scroll only their list (the input
   stays pinned at the bottom, like a chat composer). */
.panel-content > .channel { overflow-y: auto; }

/* Contacts */
.contacts { display: flex; flex-direction: column; gap: 8px; }
.contacts-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600;
}
.contact {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px;
  display: flex; flex-direction: column; gap: 6px; background: var(--bg);
}
.contact .row { gap: 6px; }
.contact input, .contact select {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel); color: var(--ink); font: inherit; font-size: 13px;
}

/* Notes — list scrolls above, the add-note composer is pinned at the bottom. */
.notes { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.notes-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.notes-input {
  flex: 0 0 auto; display: flex; gap: 8px; padding: 10px;
  border-top: 1px solid var(--line); background: var(--panel);
}
.notes-input textarea {
  flex: 1 1 auto; resize: vertical; min-height: 96px;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}
.note { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel); }
.note-body { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.note-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px; font-size: 11px; color: var(--muted);
}
.note-meta a { color: var(--accent); }

.channel { padding-top: 4px; }

@media (max-width: 820px) {
  .deal-card { flex-direction: column; }
  .deal-left { flex-basis: auto; max-width: 100%; border-right: none; border-bottom: 1px solid var(--line); }
}
.modal-head {
  display: flex; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.modal-foot .spacer { flex: 1; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > label { font-size: 12px; color: var(--muted); }
.field input[type=text],
.field input[type=number],
.field input[type=date],
.field select,
.field textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 64px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }

.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
/* Buttons keep their natural width instead of being squeezed by grown fields. */
.row > .btn { flex: 0 0 auto; }
.grow { flex: 1 1 auto; }

/* Settings lists (statuses / fields) */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border: 1px solid var(--line); border-radius: 8px;
}
.list-row input[type=color] { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.list-row .name { flex: 1 1 auto; }
.reorder { display: flex; flex-direction: column; }
.reorder button { border: none; background: none; color: var(--muted); line-height: 1; padding: 0 4px; }
.reorder button:hover { color: var(--ink); }

.pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}

/* States */
.banner {
  background: #fdecec; color: var(--danger);
  padding: 8px 16px; border-bottom: 1px solid #f6d0d0;
  display: flex; align-items: center; gap: 8px;
}
.center { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; }

/* Login */
.login-wrap { display: grid; place-items: center; height: 100%; padding: 20px; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 28px 26px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card .brand { font-size: 22px; text-align: center; }
.login-card h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; text-align: center; }
.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}
.login-card input:focus { border-color: var(--accent); outline: none; }
.login-card .btn-primary { padding: 10px; }
.login-err {
  background: #fdecec; color: var(--danger);
  border: 1px solid #f6d0d0; border-radius: 8px;
  padding: 8px 10px; font-size: 13px; text-align: center;
}

/* Avito */
.src-avito {
  display: inline-block;
  font-size: 10px; font-weight: 700; letter-spacing: .03em;
  background: #00AAFF; color: #fff;
  padding: 1px 5px; border-radius: 4px; margin-right: 5px;
  vertical-align: middle;
}
.greet-edit {
  border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 8px 8px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px; background: var(--bg);
  margin: -8px 0 4px;
}
.greet-edit textarea {
  width: 100%; resize: vertical; min-height: 46px;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit;
}
.panel-sep {
  margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
}

.chat { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.chat-head {
  padding: 7px 12px; background: var(--card); border-bottom: 1px solid var(--line);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.chat-client { text-transform: none; font-size: 14px; color: var(--ink); font-weight: 600; }
.ad-link { color: var(--accent); text-decoration: none; font-size: 14px; }
.ad-link:hover { text-decoration: underline; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #c3c9d5; }
.live-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }

/* Live notification toasts */
.toasts {
  position: fixed; left: 88px; bottom: 18px; z-index: 60;
  display: flex; flex-direction: column; gap: 8px; max-width: 320px;
}
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid #00AAFF;
  border-radius: 10px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(16, 24, 40, .18);
  cursor: pointer;
}
.toast:hover { border-color: #c7cedb; }
.toast-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
}
.toast-src { background: #00AAFF; color: #fff; border-radius: 4px; padding: 1px 5px; font-weight: 700; }
.toast-x { margin-left: auto; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.toast-title { font-weight: 600; margin-top: 3px; }
.toast-preview { font-size: 13px; color: var(--ink); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-acc { font-size: 11px; color: var(--muted); margin-top: 3px; }
.chat-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 6px; background: var(--bg);
}
.msg { max-width: 82%; padding: 7px 10px; border-radius: 10px; font-size: 13px; }
.msg.in { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg.out { align-self: flex-end; background: #e3efff; border: 1px solid #cbe0ff; }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-time { font-size: 10px; color: var(--muted); margin-top: 3px; }
.msg-img { max-width: 240px; max-height: 260px; border-radius: 8px; display: block; cursor: zoom-in; }
.msg-audio { max-width: 250px; height: 38px; display: block; }
.chat-input { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--line); }
.chat-input textarea {
  flex: 1 1 auto; resize: vertical; min-height: 96px;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}

/* Telegram client (chat list + conversation), embedded in the deal card */
.tgc { display: flex; height: 100%; min-height: 0; overflow: hidden; }
.tgc-list { flex: 0 0 280px; max-width: 280px; overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); }
.tgc-new { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.tgc-new-row { display: flex; gap: 6px; }
.tgc-new input { flex: 1 1 auto; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; }
.tgc-dialog { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.tgc-dialog:hover { background: var(--bg); }
.tgc-dialog.active { background: #e3efff; }
.tgc-dialog.matched { box-shadow: inset 3px 0 0 #22c55e; }
.tgc-ava { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; object-fit: cover; background: var(--line); }
.tgc-ava-ph { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; background: #64748b; }
.tgc-d-main { flex: 1 1 auto; min-width: 0; }
.tgc-d-top { display: flex; align-items: center; gap: 8px; }
.tgc-d-name { flex: 1; font-weight: 600; font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tgc-badge { background: #3b82f6; color: #fff; border-radius: 10px; font-size: 11px; line-height: 1; padding: 3px 7px; min-width: 18px; text-align: center; }
.tgc-d-prev { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.tgc-d-tag { font-size: 11px; color: #16a34a; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .tgc-ava { width: 28px; height: 28px; flex-basis: 28px; font-size: 12px; }
.msg-link { color: var(--accent); text-decoration: underline; word-break: break-all; }
.msg-contact { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.msg-write { align-self: flex-start; }
.tgc-chat { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.tgc-empty { display: flex; align-items: center; justify-content: center; height: 100%; padding: 16px; text-align: center; }
.msg-file { display: inline-block; color: var(--accent); text-decoration: none; font-size: 13px; word-break: break-word; }
.msg-file:hover { text-decoration: underline; }
.msg-cap { margin-top: 4px; }
.tgc-err { color: #dc2626; font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: #fef2f2; }
.btn-attach { flex: 0 0 auto; padding: 0 10px; font-size: 16px; }
@media (max-width: 820px) {
  .tgc-list { flex-basis: 42%; max-width: 42%; }
}

/* Calendar */
.cal-wrap { display: flex; gap: 14px; padding: 14px; height: 100%; overflow: auto; align-items: flex-start; }
.cal-side {
  flex: 0 0 220px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
}
.cal-side-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; margin-bottom: 8px;
}
.teacher-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.teacher-row:hover { background: var(--bg); }
.teacher-row.active { background: var(--accent-soft, #eff4ff); border-color: var(--accent); }

.cal-main { flex: 1 1 auto; min-width: 0; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.cal-title { color: var(--muted); font-size: 13px; }
.dot.all { background: linear-gradient(135deg, #2F6FED 50%, #E5484D 50%); }

/* Continuous time scale: 10-minute resolution, blocks sized by real duration. */
.cal2 { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal2-head { display: flex; background: var(--card); border-bottom: 1px solid var(--line); }
.cal2-gut { flex: 0 0 58px; width: 58px; position: relative; }
.cal2-cols { flex: 1 1 auto; display: flex; min-width: 0; }
.cal2-dayname {
  flex: 1 1 0; min-width: 0; text-align: center;
  padding: 8px 4px; font-size: 12px; font-weight: 600;
  border-left: 1px solid var(--line);
}
.cal2-dayname span { color: var(--muted); font-weight: 400; }
.cal2-dayname.today { background: var(--accent); color: #fff; }
.cal2-dayname.today span { color: rgba(255, 255, 255, .85); }

.cal2-body { display: flex; position: relative; }
.cal2-body .cal2-gut { background: var(--card); border-right: 1px solid var(--line); }
.cal2-hour {
  position: absolute; right: 6px; transform: translateY(-50%);
  font-size: 11px; color: var(--muted); white-space: nowrap;
}
.cal2-col {
  flex: 1 1 0; min-width: 0; position: relative;
  border-left: 1px solid var(--line);
  /* hour lines over lighter 10-minute lines */
  background-image:
    repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 42px),
    repeating-linear-gradient(to bottom, #eff2f7 0 1px, transparent 1px 7px);
}
.cal2-col.today { background-color: #f5f9ff; }
.cal2-col.clickable { cursor: pointer; }
.cal2-col.clickable:hover { box-shadow: inset 0 0 0 1px rgba(47, 111, 237, .25); }

.slot2 {
  position: absolute; box-sizing: border-box;
  color: #fff; border-radius: 5px; padding: 1px 5px;
  overflow: visible; cursor: pointer; font-size: 11px; line-height: 1.15;
}
.slot2-time { display: block; font-size: 10px; opacity: .9; }
/* Show the whole title (wraps to as many lines as needed) rather than clipping
   it with an ellipsis. Hovering still shows the full details tooltip. */
.slot2-name { display: block; white-space: normal; word-break: break-word; }
.slot2:hover { z-index: 6; }
/* Free time reads lighter; a booked lesson is solid and bold. */
.slot2.free { opacity: .5; }
.slot2.busy { opacity: 1; font-weight: 600; box-shadow: inset 3px 0 0 rgba(0, 0, 0, .35); }
.slot2:hover { outline: 2px solid rgba(0, 0, 0, .3); z-index: 2; }
.slot2 { user-select: none; }
.cal2-col.clickable .slot2 { cursor: grab; }
.slot2.dragging { cursor: grabbing; z-index: 5; opacity: .9; box-shadow: 0 6px 16px rgba(16, 24, 40, .35); }
.slot2.sel { outline: 3px solid #111827; outline-offset: -1px; z-index: 3; }

/* Floating actions for the current selection */
.sel-bar {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 8px 6px 14px; box-shadow: 0 8px 24px rgba(16, 24, 40, .18);
  font-size: 13px;
}
.sel-x {
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--danger); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer;
}
.sel-x:hover { background: #c93b3f; }

.legend { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.legend > div { display: flex; align-items: center; gap: 6px; }
.legend-box { width: 14px; height: 10px; border-radius: 3px; background: var(--accent); display: inline-block; }
.legend-box.free { opacity: .55; }
.legend-box.busy { opacity: 1; box-shadow: inset 3px 0 0 rgba(0, 0, 0, .35); }

.user-badge {
  font-size: 13px; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; background: var(--bg);
  border: 1px solid var(--line); white-space: nowrap;
}
.center .btn-primary { margin-top: 12px; }
.muted { color: var(--muted); }
.empty-col { color: var(--muted); font-size: 12px; text-align: center; padding: 10px 0; }

/* Раздел «Ученики» */
.stu-wrap { padding: 16px; height: 100%; overflow: auto; }
.stu-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.stu-head h2 { margin: 0; font-size: 20px; font-weight: 650; }
.stu-arch { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stu-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.stu-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
}
.stu-card:hover { border-color: #c7cedb; box-shadow: 0 2px 10px rgba(16,24,40,.06); }
.stu-card.arch { opacity: .55; }
.stu-name { font-weight: 640; display: flex; align-items: baseline; gap: 8px; }
.stu-grade { font-size: 12px; color: var(--muted); font-weight: 400; }
.stu-parent { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stu-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.stu-sub { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.stu-sub.ok   { background: #e8f7ee; color: #15803d; }
.stu-sub.low  { background: #fff4e5; color: #b45309; }
.stu-sub.out  { background: #fdecef; color: #be123c; }
.stu-sub.none { background: var(--bg); color: var(--muted); font-weight: 400; }
.stu-teacher { margin-left: auto; font-size: 11px; color: #fff; padding: 2px 7px; border-radius: 6px; }

/* Карточка ученика */
.stu-form { display: flex; flex-direction: column; gap: 10px; padding: 12px 2px; }
.stu-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.stu-form input, .stu-form select, .stu-form textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
  font-size: 14px; color: var(--ink); background: var(--panel);
}
.sub-now { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.sub-line { font-size: 15px; }
.sub-line b { font-size: 22px; }
.sub-bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.sub-fill { height: 100%; background: #3b82f6; }
.wd-row { display: flex; flex-wrap: wrap; gap: 8px; }
.wd { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.wd-btn {
  width: 44px; padding: 6px 0; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 13px;
}
.wd.on .wd-btn { background: #3b82f6; border-color: #3b82f6; color: #fff; font-weight: 600; }
.wd input { width: 74px; font-size: 12px; padding: 3px 4px; border: 1px solid var(--line); border-radius: 6px; }

/* Список занятий */
.les-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.les {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 13px;
}
.les.done { background: var(--bg); }
.les.off { opacity: .6; text-decoration: line-through; }
.les-when { font-variant-numeric: tabular-nums; font-weight: 600; }
.les-state { font-size: 12px; color: var(--muted); }
.les input { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 12px; }

/* Ученики: выбор контакта, способ оплаты, расписание по дням */
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.pick {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); cursor: pointer;
}
.pick:hover { border-color: var(--accent); }
.pick.off { opacity: .55; cursor: default; }
.pick-name { font-weight: 600; }
.pick-meta, .pick-deal, .pick-has { font-size: 12px; color: var(--muted); }
.pick-deal, .pick-has { text-align: right; }

.pay-switch { display: flex; gap: 0; }
.pay {
  flex: 1; padding: 8px 12px; border: 1px solid var(--line); background: var(--card);
  cursor: pointer; font-size: 14px;
}
.pay:first-child { border-radius: 8px 0 0 8px; }
.pay:last-child { border-radius: 0 8px 8px 0; border-left: none; }
.pay.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.stu-sched { font-size: 12px; color: var(--muted); margin-top: 2px; }
.plan-msg {
  font-size: 13px; padding: 6px 10px; border-radius: 6px;
  background: rgba(34, 197, 94, .12); color: #15803d;
}
.les-day { margin-bottom: 10px; }
.les-day-head { font-size: 12px; color: var(--muted); margin: 6px 0 2px; }
.stu-contact { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }

/* Занятия ученика месячной сеткой */
.mcal { display: flex; flex-direction: column; gap: 6px; }
.mcal-head { display: flex; align-items: center; gap: 6px; }
.mcal-title { margin-left: 6px; font-weight: 600; text-transform: capitalize; }
.mcal-week, .mcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mcal-week > div { font-size: 12px; color: var(--muted); text-align: center; padding: 2px 0; }
.mcal-cell {
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  padding: 4px; display: flex; flex-direction: column; gap: 3px; min-height: 58px;
}
.mcal-cell.other { opacity: .45; }
.mcal-cell.today { border-color: var(--accent); }
.mcal-day { font-size: 11px; color: var(--muted); }
.mcal-les {
  border: none; border-radius: 5px; padding: 2px 4px; font-size: 12px; line-height: 1.3;
  cursor: pointer; text-align: left; color: #fff; background: var(--accent);
}
.mcal-les.done { background: #64748b; }
.mcal-les.unpaid { background: #d97706; }
.mcal-les.off { background: transparent; color: var(--muted); text-decoration: line-through; border: 1px dashed var(--line); }
.mcal-les.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.mcal-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.mcal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.mcal-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.mcal-legend i.plan { background: var(--accent); }
.mcal-legend i.done { background: #64748b; }
.mcal-legend i.unpaid { background: #d97706; }
.mcal-legend i.off { border: 1px dashed var(--line); }
.mcal-pick {
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  padding: 8px 10px; display: flex; flex-direction: column; gap: 6px;
}
.panel-tabs.sub { margin-bottom: 0; }

/* ИИ-продажник: черновик в карточке и лента правок */
.draft {
  margin: 8px; padding: 10px; border: 1px solid var(--accent); border-radius: 10px;
  background: rgba(47, 111, 237, .06); display: flex; flex-direction: column; gap: 8px;
}
.draft-err { border-color: #dc2626; background: rgba(220, 38, 38, .07); color: #b91c1c; font-size: 13px; }
.draft-head { display: flex; align-items: center; gap: 8px; }
.draft-tag { font-size: 12px; font-weight: 600; color: var(--accent); }
.draft-warn { font-size: 12px; color: #b45309; }
.draft-text { width: 100%; resize: vertical; font: inherit; }
.draft-trial { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.rules-text { width: 100%; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; }
.fb {
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px;
}
.fb.off { opacity: .5; }
.fb-head { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.fb-was { color: var(--muted); }
.fb-note { color: #b45309; }
.fb-better { color: #15803d; }
