:root {
  --bg: #0e1116;
  --bg-2: #151a21;
  --bg-3: #1c232c;
  --line: #27303b;
  --text: #e8edf3;
  --muted: #8b98a9;
  --accent: #ff5a3c;
  --accent-2: #4ea8ff;
  --ok: #3ecf8e;
  --warn: #ffb648;
  --fail: #ff5f6d;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── Кнопки ───────────────────────────────────────────── */
.btn {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #232c37; border-color: #33404e; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn--primary:hover { background: #ff6c51; border-color: #ff6c51; }
.btn--ghost { background: transparent; }
.btn--icon { padding: 9px 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chip {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}
.chip:hover { color: var(--text); border-color: #3a4655; }

/* ── Вход ─────────────────────────────────────────────── */
.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2431 0%, var(--bg) 60%);
}
.auth__card {
  width: min(420px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  display: grid;
  gap: 14px;
}
.auth__logo { font-size: 34px; }
.auth h1 { margin: 0; font-size: 22px; }
.auth__sub { margin: -8px 0 6px; color: var(--muted); font-size: 14px; }
.auth__tabs { display: flex; gap: 8px; }
.tab {
  flex: 1;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}
.tab.is-active { background: var(--bg-3); color: var(--text); border-color: #3a4655; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid #2c3b4d; }
.auth__error { color: var(--fail); font-size: 13px; min-height: 18px; }

/* ── Каркас ───────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 248px 1fr; height: 100%; }
.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 18px;
}
.side__brand { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.side__logo { font-size: 22px; }
.side__nav { display: grid; gap: 4px; }
.nav {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}
.nav:hover { background: var(--bg-3); color: var(--text); }
.nav.is-active { background: var(--bg-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.side__foot { margin-top: auto; display: grid; gap: 10px; }
.side__user { display: grid; font-size: 13px; }
.side__user span { color: var(--muted); font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.view { display: none; flex-direction: column; height: 100%; min-height: 0; }
.view.is-active { display: flex; }
.view__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.view__head h2 { margin: 0; font-size: 17px; }
.view__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.view__actions select { background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.check { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }

/* ── Чат ──────────────────────────────────────────────── */
.chat { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: min(720px, 92%); display: grid; gap: 8px; }
.msg--user { margin-left: auto; }
.msg__body {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg--user .msg__body { background: #24313f; border-color: #2f3f50; }
.msg__body b { color: #fff; }
.msg__body em { color: var(--muted); font-style: normal; }
.msg__time { font-size: 11px; color: #5f6c7d; }
.msg--user .msg__time { text-align: right; }
.msg__buttons { display: flex; flex-wrap: wrap; gap: 6px; }

.composer { border-top: 1px solid var(--line); padding: 12px 22px 16px; background: var(--bg-2); }
.composer__row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
}
.composer__upload { margin-bottom: 10px; background: var(--bg-3); border: 1px dashed #3a4655; border-radius: 12px; padding: 12px; }
.upload__row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.upload__row input[type=file] { flex: 1; min-width: 220px; }
.upload__row select { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; max-width: 260px; }
.upload__progress { display: flex; gap: 10px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted); }
.bar { flex: 1; height: 6px; border-radius: 99px; background: #222b36; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }

/* ── Списки и детали ──────────────────────────────────── */
.split { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
.list { border-right: 1px solid var(--line); overflow-y: auto; }
.detail { overflow-y: auto; padding: 20px 24px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

.item { padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 4px; }
.item:hover { background: var(--bg-2); }
.item.is-active { background: var(--bg-3); box-shadow: inset 2px 0 0 var(--accent); }
.item__title { font-weight: 600; font-size: 14px; }
.item__meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.badge { border-radius: 999px; padding: 2px 8px; font-size: 11px; border: 1px solid var(--line); }
.badge--ok { color: var(--ok); border-color: #1f5a44; background: #10261f; }
.badge--warn { color: var(--warn); border-color: #6a5122; background: #251d10; }
.badge--fail { color: var(--fail); border-color: #642a30; background: #261216; }
.badge--muted { color: var(--muted); }

.checks { display: grid; gap: 8px; margin: 16px 0; }
.checkrow {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: start;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px;
}
.checkrow__title { font-weight: 600; font-size: 14px; }
.checkrow__detail { color: var(--muted); font-size: 12.5px; }
.checkrow__value { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }

.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.panel h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.quote { border-left: 3px solid var(--line); padding-left: 10px; color: var(--muted); font-size: 13px; margin: 4px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }

.transcript { max-height: 460px; overflow-y: auto; font-size: 13.5px; display: grid; gap: 6px; }
.tline { display: grid; grid-template-columns: 56px 1fr; gap: 10px; }
.tline time { color: var(--accent-2); font-family: var(--mono); font-size: 12px; cursor: pointer; }

.cards { padding: 20px 24px; display: grid; gap: 14px; align-content: start; overflow-y: auto; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Сетка ────────────────────────────────────────────── */
.grid-wrap { flex: 1; display: grid; grid-template-columns: 300px 1fr; min-height: 0; }
.grid-queue { border-right: 1px solid var(--line); overflow-y: auto; padding: 14px; }
.grid-queue h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.grid-days { overflow-y: auto; padding: 14px 20px; }
.day { margin-bottom: 18px; }
.day__head { font-weight: 600; margin-bottom: 8px; color: var(--muted); font-size: 13px; text-transform: capitalize; }
.slot {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; margin-bottom: 7px;
}
.slot--free { border-style: dashed; }
.slot--past { opacity: .45; }
.slot__time { font-family: var(--mono); color: var(--accent-2); }
.slot__title { font-weight: 600; font-size: 14px; }
.slot__sub { color: var(--muted); font-size: 12px; }
.qitem { background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; }
.qitem.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

/* ── Статистика ───────────────────────────────────────── */
.stats { padding: 20px 24px; overflow-y: auto; display: grid; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile b { display: block; font-size: 24px; font-weight: 650; }
.tile span { color: var(--muted); font-size: 12.5px; }
.spark { width: 100%; height: 120px; }

/* ── Toast и модалка ──────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #222c38; border: 1px solid #35414f; border-radius: 12px;
  padding: 11px 16px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: 90vw;
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { border-color: #6b2d33; background: #2a171a; }

dialog {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 16px; padding: 20px; width: min(460px, 92vw);
}
dialog::backdrop { background: rgba(6, 9, 13, .7); }
dialog form { display: grid; gap: 12px; }

/* ── Мобильный вид ────────────────────────────────────── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; gap: 10px; }
  .side__brand b, .side__foot .btn { display: none; }
  .side__nav { display: flex; gap: 4px; }
  .nav span { font-size: 17px; }
  .nav { padding: 8px 10px; font-size: 12px; }
  .side__foot { margin: 0 0 0 auto; }
  .split, .grid-wrap { grid-template-columns: 1fr; grid-template-rows: 220px 1fr; }
  .list, .grid-queue { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat, .composer { padding-left: 12px; padding-right: 12px; }
}
