:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --border: #e3e5ee;
  --text: #1c1f2e;
  --muted: #6b7088;
  --accent: #5b5bd6;
  --accent-soft: #ececfd;
  --accent-text: #ffffff;
  --green: #18875a;
  --green-soft: #e3f6ed;
  --red: #c93b3b;
  --red-soft: #fdeaea;
  --amber: #a5650a;
  --amber-soft: #fdf2df;
  --gray-soft: #eceef3;
  --shadow: 0 1px 2px rgba(20, 22, 40, .06), 0 4px 16px rgba(20, 22, 40, .05);
  --radius: 12px;
  --sidebar: 232px;
  color-scheme: light;
}
/* Тёмная тема: выбрана вручную (data-theme="dark") или «как в системе» */
:root[data-theme="dark"] {
  --bg: #12131a;
  --surface: #1b1d27;
  --surface-2: #232633;
  --border: #2e3140;
  --text: #e8e9f0;
  --muted: #9a9eb3;
  --accent: #8b8bf5;
  --accent-soft: #2a2b4a;
  --accent-text: #11121a;
  --green: #4fd19a;
  --green-soft: #173327;
  --red: #f27b7b;
  --red-soft: #3a1f22;
  --amber: #f0b75c;
  --amber-soft: #3a2d17;
  --gray-soft: #2a2d3a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12131a;
    --surface: #1b1d27;
    --surface-2: #232633;
    --border: #2e3140;
    --text: #e8e9f0;
    --muted: #9a9eb3;
    --accent: #8b8bf5;
    --accent-soft: #2a2b4a;
    --accent-text: #11121a;
    --green: #4fd19a;
    --green-soft: #173327;
    --red: #f27b7b;
    --red-soft: #3a1f22;
    --amber: #f0b75c;
    --amber-soft: #3a2d17;
    --gray-soft: #2a2d3a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 650; font-size: 15px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--text); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.me { display: flex; align-items: center; gap: 10px; }
.me .who { min-width: 0; }
.me .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* меню пользователя (как в Claude) */
.user-menu-wrap { position: relative; }
.me-btn {
  width: 100%; border: none; background: transparent; color: var(--text); font: inherit; text-align: left;
  padding: 8px; border-radius: 10px; cursor: pointer;
}
.me-btn:hover, .me-btn[aria-expanded="true"] { background: var(--surface-2); }
.me-btn .who { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.me-btn > svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.me-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.user-menu > a, .user-menu > button {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  border: none; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.user-menu > a:hover, .user-menu > button:hover { background: var(--surface-2); text-decoration: none; }
.user-menu svg { width: 17px; height: 17px; color: var(--muted); }
.um-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.um-sep { height: 1px; background: var(--border); margin: 4px 0; }
.um-theme { display: flex; gap: 2px; padding: 4px; margin: 2px 4px; background: var(--surface-2); border-radius: 9px; }
.um-theme button { flex: 1; border: none; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; padding: 5px 0; border-radius: 7px; cursor: pointer; }
.um-theme button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
img.avatar { object-fit: cover; background: var(--surface-2); }
.profile-photo .avatar { width: 64px; height: 64px; font-size: 22px; }
.kcol-other { background: transparent; border: 1px dashed var(--border); }

.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin-right: auto; }

.mobile-bar { display: none; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .mobile-bar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 30;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 10px 16px; font-weight: 600;
  }
  .main { padding: 16px 16px 60px; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
}

/* ---------- components ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin-right: auto; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.stat .value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .value.pos { color: var(--green); }
.stat .value.neg { color: var(--red); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--red); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 36px; padding: 0; }
.btn svg { width: 16px; height: 16px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 550; white-space: nowrap;
  background: var(--gray-soft); color: var(--muted);
}
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 650; font-size: 13px;
}

/* forms */
.form { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .form { grid-template-columns: 1fr; } }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 10px; min-height: 36px; width: 100%;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="checkbox"] { width: auto; min-height: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar .search { flex: 1; min-width: 200px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.form-actions .left { margin-right: auto; }
.error-text { color: var(--red); font-size: 13px; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -18px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 550; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* modal */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 16, 30, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%; max-width: 620px; padding: 22px;
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; margin-bottom: 18px; gap: 10px; }
.modal-head h2 { margin-right: auto; font-size: 18px; }

.toast-box { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: var(--bg);
  padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 340px;
  animation: toast-in .2s ease-out;
}
.toast.err { background: var(--red); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* login */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth { width: 100%; max-width: 400px; }
.auth .brand { justify-content: center; padding-bottom: 8px; font-size: 18px; }
.auth form { display: grid; gap: 14px; }

/* schedule */
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-title { font-weight: 600; min-width: 190px; text-align: center; }
.cal { display: grid; grid-template-columns: 52px repeat(7, minmax(110px, 1fr)); }
.cal-scroll { overflow: auto; max-height: calc(100vh - 210px); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.cal-head {
  position: sticky; top: 0; z-index: 3; background: var(--surface);
  border-bottom: 1px solid var(--border); padding: 8px 6px; text-align: center; font-size: 12.5px;
}
.cal-head.today { color: var(--accent); }
.cal-head b { display: block; font-size: 17px; }
.cal-times { position: relative; }
.cal-time { height: 56px; font-size: 11px; color: var(--muted); text-align: right; padding: 0 6px; transform: translateY(-7px); }
.cal-day { position: relative; border-left: 1px solid var(--border); }
.cal-slot { height: 28px; border-bottom: 1px dashed transparent; cursor: pointer; }
.cal-slot:nth-child(2n) { border-bottom: 1px solid var(--border); }
.cal-slot:hover { background: var(--accent-soft); }
.cal-day.today { background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 2; pointer-events: none; }
.ev {
  position: absolute; z-index: 1; border-radius: 7px; padding: 3px 6px;
  font-size: 12px; line-height: 1.25; overflow: hidden; cursor: pointer;
  border-left: 3px solid var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, var(--surface));
  color: var(--text);
}
.ev:hover { filter: brightness(.97); box-shadow: var(--shadow); }
.ev b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.st-done { opacity: .75; }
.ev.st-cancel_student, .ev.st-cancel_tutor { opacity: .5; text-decoration: line-through; }
.ev.st-missed { border-left-style: dotted; }

.agenda-day { margin-bottom: 18px; }
.agenda-day h3 { margin-bottom: 6px; text-transform: capitalize; }
.agenda-day h3.today { color: var(--accent); }

/* kanban */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 300px; }
.kcol.over { outline: 2px dashed var(--accent); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 10px; font-weight: 600; }
.kcol-head .count { margin-left: auto; color: var(--muted); font-weight: 500; }
.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.kcard:active { cursor: grabbing; }
.kcard .title { font-weight: 600; margin-bottom: 2px; }
.kcard.dragging { opacity: .4; }

/* student page */
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.profile-head .avatar { width: 52px; height: 52px; font-size: 19px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; } }
.balance-big { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: none; background: var(--surface); padding: 0 12px; height: 34px; font: inherit; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.quick-status { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* messages */
.badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 120px); min-height: 420px; }
.inbox .card + .card { margin-top: 0; }
.inbox-list { overflow-y: auto; padding: 10px; }
.inbox-thread { display: flex; flex-direction: column; min-height: 0; padding: 0; }
.conv { display: block; padding: 10px; border-radius: 9px; color: var(--text); }
.conv:hover { background: var(--surface-2); text-decoration: none; }
.conv.active { background: var(--accent-soft); }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-bottom { display: flex; align-items: center; gap: 6px; margin-top: 4px; min-width: 0; }
.conv-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.thread-link { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.thread-link .seg button { height: 30px; font-size: 13px; }
.role-line { margin-top: 3px; }
.form-section { margin: 6px 0 -4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kv dt.kv-section { grid-column: 1 / -1; margin-top: 8px; font-weight: 600; color: var(--text); }
.role-line .chip { font-size: 11px; padding: 1px 7px; }
.thread-link select { width: auto; max-width: 320px; min-height: 30px; padding: 4px 8px; }
.back-btn { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; max-width: 75%; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg .bubble { padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; background: var(--surface-2); }
.msg.out .bubble { background: var(--accent); color: var(--accent-text); }
.msg .small { margin-top: 2px; font-size: 11px; }
.reply { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); align-items: flex-end; }
.reply textarea { min-height: 44px; }
.inbox-thread.loading > * { opacity: .55; transition: opacity .15s; }
@media (max-width: 860px) {
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox.has-active .inbox-list { display: none; }
  .inbox:not(.has-active) .inbox-thread { display: none; }
  .inbox-thread { height: calc(100vh - 150px); }
  .back-btn { display: inline-flex; }
}

/* ---------- пакет доработок: журнал, окна, шаблоны, графики, мобильная навигация ---------- */
/* отметка урока из списка */
.mark-btn { flex-shrink: 0; }
.mark-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 10px 21px; border-bottom: 1px solid var(--border); }
.mark-bar .btn { height: 36px; }

/* журнал */
.audit-text { margin-top: 2px; word-break: break-word; }
details.history { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 10px; }
details.history summary, details summary { cursor: pointer; color: var(--muted); }
details.history .list-item { padding: 8px 0; }

/* свободные окна */
.avail { display: flex; flex-direction: column; gap: 6px; }
.avail-day { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 36px; }
.avail-day > b { width: 28px; }
.avail-slots { display: flex; gap: 6px; flex-wrap: wrap; }
.avail-slot { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 9px; padding: 2px 2px 2px 6px; }
.avail-slot input { width: 96px; min-height: 30px; padding: 3px 6px; }
.cal-slot.free { background: color-mix(in srgb, var(--green) 9%, transparent); }
.cal-slot.free:hover { background: var(--accent-soft); }
.free-key { display: inline-block; width: 14px; height: 10px; border-radius: 3px; vertical-align: middle;
  background: color-mix(in srgb, var(--green) 18%, transparent); }
.suggest-res { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.suggest-tutor h3 { margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.suggest-day { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
.suggest-day > span:first-child { width: 92px; flex-shrink: 0; }
.wd-pick { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; color: var(--text); }
.wd-pick label { display: flex; align-items: center; gap: 4px; }

/* шаблоны ответов */
.tpl-wrap { position: relative; }
.tpl-menu { position: absolute; bottom: 44px; left: 0; z-index: 20; width: min(340px, 80vw); max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; }
.tpl-menu button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left;
  border: none; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); font: inherit; }
.tpl-menu button:hover { background: var(--surface-2); }
.tpl-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-vars { display: flex; flex-wrap: wrap; gap: 4px; }
.wait-line { color: var(--amber); margin-top: 3px; }
.stat-num { font-size: 20px; font-weight: 650; }

/* графики (цвета серий — проверенная палитра, отдельно для тёмной темы) */
.chart-box {
  position: relative;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --grid: #e1e0d9; --axis: #c3c2b7; --tick: #898781;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-0: var(--surface-2);
}
:root[data-theme="dark"] .chart-box {
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #2c2c2a; --axis: #383835;
  --seq-1: #104281; --seq-2: #184f95; --seq-3: #256abf; --seq-4: #3987e5; --seq-5: #6da7ec; --seq-6: #b7d3f6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .chart-box {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #2c2c2a; --axis: #383835;
    --seq-1: #104281; --seq-2: #184f95; --seq-3: #256abf; --seq-4: #3987e5; --seq-5: #6da7ec; --seq-6: #b7d3f6;
  }
}
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis { stroke: var(--axis); stroke-width: 1; }
svg.chart .tick { fill: var(--tick); font-size: calc(11px * var(--k, 1)); font-variant-numeric: tabular-nums; }
svg.chart .s1 { fill: var(--series-1); }
svg.chart .s2 { fill: var(--series-2); }
svg.chart .s3 { fill: var(--series-3); }
svg.chart .hit { fill: transparent; }
svg.chart .col.on .hit, svg.chart .col:hover .hit { fill: var(--surface-2); opacity: .7; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.s1 { background: var(--series-1); } .sw.s2 { background: var(--series-2); } .sw.s3 { background: var(--series-3); }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; white-space: pre-line; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 8px; padding: 6px 9px; font-size: 12.5px; min-width: 140px; }
.heat { display: grid; gap: 2px; font-size: 10.5px; color: var(--muted); }
.heat-c { display: block; height: 18px; border-radius: 3px; background: var(--seq-0); }
.heat-c.on { outline: 2px solid var(--text); }
.heat-h { text-align: center; } .heat-d { align-self: center; }
.heat-c.q1 { background: var(--seq-1); } .heat-c.q2 { background: var(--seq-2); } .heat-c.q3 { background: var(--seq-3); }
.heat-c.q4 { background: var(--seq-4); } .heat-c.q5 { background: var(--seq-5); } .heat-c.q6 { background: var(--seq-6); }
.heat-scale { display: flex; align-items: center; gap: 2px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.heat-scale i { width: 18px; height: 10px; } .heat-scale span { margin: 0 4px; }
.section-title { margin: 28px 0 12px; }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 90px; align-items: center; gap: 10px; }
.funnel-track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.funnel-bar { display: block; height: 100%; background: #2a78d6; border-radius: 0 4px 4px 0; }
.funnel-num { text-align: right; font-variant-numeric: tabular-nums; }
.meter { display: inline-block; width: 50px; height: 6px; border-radius: 3px; background: #cde2fb; vertical-align: middle; overflow: hidden; }
.meter span { display: block; height: 100%; background: #2a78d6; }
table.cohorts td.coh { color: var(--text); }
table.cohorts td.coh.q4, table.cohorts td.coh.q5, table.cohorts td.coh.q6 { color: #fff; }
table.cohorts td.q0 { background: transparent; } table.cohorts td.q1 { background: #cde2fb; } table.cohorts td.q2 { background: #9ec5f4; }
table.cohorts td.q3 { background: #6da7ec; } table.cohorts td.q4 { background: #3987e5; } table.cohorts td.q5 { background: #256abf; }
table.cohorts td.q6 { background: #184f95; }
table.cohorts td.q1, table.cohorts td.q2, table.cohorts td.q3 { color: #0b0b0b; }

/* мобильная нижняя панель */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 32;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative;
    padding: 6px 2px; font: inherit; font-size: 11px; color: var(--muted); background: none; border: none; cursor: pointer; border-radius: 9px;
  }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .badge { position: absolute; top: 0; left: 55%; margin: 0; min-width: 18px; height: 18px; font-size: 10.5px; }
  .main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .toast-box { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .inbox-thread { height: calc(100vh - 210px); }
  .list-item .btn.sm { height: 36px; }
  .funnel-row { grid-template-columns: 100px 1fr 70px; }
}

.grid > .card + .card { margin-top: 0; }
.seg { max-width: 100%; overflow-x: auto; }
.seg button { flex-shrink: 0; }