/* A24 CRM — стиль «Мессенджер»: мягкие панели, пузыри чата, бирюзовый акцент */
:root {
  --bg: #eaeef3; --panel: #fff; --soft: #f2f5f8; --soft2: #f6f8fa; --line: #eef1f4;
  --text: #1a1a1a; --muted: #5f6673; --faint: #8a909c;
  --accent: #0f766e; --accent-dark: #0b5a54; --accent-soft: #e6f4f2; --accent-ring: #ccebe7;
  --brand: #a32020; --late: #b3261e; --warn-bg: #fff3d6; --warn: #6b4a00;
  --ok-bg: #e3f1df; --ok: #2f6b1f; --r: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Onest, Arial, sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
.sr { position: absolute; left: -9999px; }
.muted { color: var(--muted); }
.page { min-height: 100vh; display: flex; flex-direction: column; padding: 14px; gap: 14px; }
.page.fixed { height: 100vh; }

/* шапка */
.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; }
.mark { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font: 800 11px/1 Onest, Arial, sans-serif; flex: none; }
.brand b { font-size: 17px; }
.segs { margin: 0 auto; display: flex; background: #dde3ea; border-radius: 22px; padding: 4px; }
.seg { font-size: 13px; text-decoration: none; color: #3d4350; padding: 8px 16px; border-radius: 18px; white-space: nowrap; }
.seg:hover { color: var(--text); }
.seg.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg .n { color: var(--late); font-weight: 700; margin-left: 2px; }
.me { display: flex; align-items: center; gap: 10px; font-size: 13px; position: relative; }
.av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.av.sm { width: 28px; height: 28px; font-size: 11px; }
.av.me-av { width: 34px; height: 34px; background: var(--accent-ring); color: var(--accent-dark); font-size: 12px; border: none; cursor: pointer; }
.menu { position: absolute; right: 0; top: 42px; background: #fff; border-radius: 14px; box-shadow: 0 8px 30px rgba(20,30,50,.15); padding: 6px; min-width: 220px; z-index: 30; display: none; }
.menu.open { display: block; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 9px; text-decoration: none; color: var(--text); background: none; border: none; cursor: pointer; font-size: 13px; }
.menu a:hover, .menu button:hover { background: var(--soft); }
.menu .who { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 12px; color: var(--muted); }

.panel { background: var(--panel); border-radius: var(--r); }
.btn { border: none; border-radius: 22px; padding: 11px 18px; font-weight: 600; font-size: 14px; cursor: pointer; min-height: 44px; background: var(--accent); color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn.ghost { background: var(--soft); color: var(--text); }
.btn.ghost:hover { background: #e6ebf0; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: none; cursor: pointer; padding: 6px 0; font-size: 13px; color: var(--accent); }
.link.grey { color: var(--muted); }
.pill { font-size: 13px; border: none; background: #fff; border-radius: 18px; padding: 9px 14px; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 20px; padding: 2px 8px; white-space: nowrap; background: var(--soft); color: #3d4350; }
.flash { padding: 10px 16px; border-radius: 14px; font-size: 13px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: #fde4e4; color: var(--late); }
.input { width: 100%; font-size: 14px; border: none; background: var(--soft); border-radius: 14px; padding: 11px 14px; }
label.f { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin: 12px 0 5px; }

/* разбор */
.grid3 { flex: 1; display: grid; grid-template-columns: 320px minmax(0, 1fr) 340px; gap: 14px; min-height: 0; }
.queue { padding: 10px; display: flex; flex-direction: column; gap: 2px; overflow: auto; min-height: 0; }
.qi { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; text-align: left; background: transparent; border: none; border-radius: 12px; padding: 9px 10px; cursor: pointer; }
.qi:hover { background: var(--soft); }
.qi.on { background: var(--accent); color: #fff; }
.qi .name { display: block; font-weight: 600; font-size: 14px; }
.qi .prev { display: block; font-size: 13px; opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qi .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 11px; }
.qi .late { color: var(--late); font-weight: 700; }
.qi.on .late { color: #fff; }
.qi.locked { opacity: .55; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.chat { display: flex; flex-direction: column; min-width: 0; overflow: hidden; min-height: 0; }
.chat-head { padding: 12px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-head .title b { font-size: 16px; }
.chat-head .sub { font-size: 12px; color: var(--muted); }
.chat-head select { font-size: 12px; border: none; background: var(--soft); border-radius: 14px; padding: 7px 10px; }
.msgs { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; background: var(--soft2); min-height: 0; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: #e6ebf0; border-radius: 12px; padding: 3px 12px; margin: 6px 0; }
.row { display: flex; }
.row.out { justify-content: flex-end; }
.bubble { max-width: 70%; background: #fff; border-radius: 18px 18px 18px 4px; padding: 9px 14px; position: relative; }
.row.out .bubble { background: var(--accent); color: #fff; border-radius: 18px 18px 4px 18px; }
.row.note .bubble { background: var(--warn-bg); color: var(--warn); border-radius: 14px; }
.row.note { justify-content: center; }
.bubble .who { font-size: 11px; opacity: .7; margin-bottom: 2px; }
.bubble .txt { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.bubble .at { font-size: 11px; opacity: .7; text-align: right; margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.bubble .err { color: #ffd7d7; font-weight: 600; }
.row:not(.out) .bubble .err { color: var(--late); }
.bubble .acts { display: flex; gap: 10px; font-size: 11px; margin-top: 4px; justify-content: flex-end; }   /* всегда видны: пузырь не «прыгает» при наведении */
.bubble .acts button { background: none; border: none; cursor: pointer; color: inherit; opacity: .6; padding: 0; text-decoration: underline; font: inherit; }
.bubble .acts button:hover, .bubble .acts button:focus-visible { opacity: 1; }
.bubble img, .bubble video { max-width: 260px; max-height: 220px; border-radius: 12px; display: block; margin-top: 6px; }
.bubble .file { display: inline-block; margin-top: 6px; color: inherit; }
.deleted { font-style: italic; opacity: .6; }
.lockbar { background: var(--warn-bg); color: var(--warn); font-size: 13px; padding: 8px 20px; }
.composer { padding: 10px 16px 14px; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); }
.tpls { display: flex; gap: 6px; flex-wrap: wrap; }
.tpl { font-size: 12px; background: var(--accent-soft); color: var(--accent-dark); border: none; border-radius: 16px; padding: 7px 12px; cursor: pointer; }
.tpl:hover { background: #d3ece8; }
.compose-row { display: flex; gap: 10px; align-items: flex-end; }
.compose-row textarea { flex: 1; font-size: 14px; border: none; background: var(--soft); border-radius: 18px; padding: 12px 16px; resize: none; min-height: 48px; max-height: 220px; }
.compose-row textarea.note { background: var(--warn-bg); }
.split { display: flex; flex: none; }
.split .btn { border-radius: 0; }
.split .btn:first-child { border-radius: 22px 0 0 22px; padding-right: 16px; }
.split .btn:last-child { border-radius: 0 22px 22px 0; background: var(--accent-dark); border-left: 1px solid rgba(255,255,255,.28); padding-left: 14px; }
.split .btn:last-child:hover { background: #084741; }
.attach { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--soft); cursor: pointer; display: grid; place-items: center; flex: none; }
.compose-links { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.compose-links .kbd { margin-left: auto; font-size: 12px; color: var(--faint); }
.compose-row textarea:focus, .input:focus, .pill:focus { outline: 2px solid var(--accent-ring); outline-offset: 0; }
.picked { font-size: 12px; color: var(--muted); }

.side { display: flex; flex-direction: column; gap: 14px; overflow: auto; min-width: 0; min-height: 0; }
.card { padding: 16px; }
.card .badge { font-size: 12px; color: var(--accent); font-weight: 600; }
.card .ttl { font-weight: 700; font-size: 16px; margin: 2px 0 12px; display: block; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: #f4f7f9; border-radius: 14px; padding: 10px 12px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 4px 0; }
.kv span:first-child { color: var(--muted); flex: none; }
.kv span:last-child { font-weight: 600; text-align: right; }
.shifts { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.shift { display: flex; justify-content: space-between; font-size: 12px; padding: 5px 8px; border-radius: 8px; background: var(--soft2); }
.shift.intern { background: var(--warn-bg); color: var(--warn); }
.hint { background: var(--warn-bg); color: var(--warn); border-radius: var(--r); padding: 14px 16px; font-size: 13px; line-height: 1.45; }
.cand { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }

/* канбан */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.board { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 14px; overflow-x: auto; align-items: stretch; }
.col { display: flex; flex-direction: column; gap: 10px; min-height: 300px; border-radius: var(--r); padding: 12px 10px 10px;
       background: rgba(255,255,255,.45); border: 1px solid #d3dbe4; border-top: 4px solid var(--c, #c9d2dc); transition: background .15s, border-color .15s; }
.col.drop { background: var(--accent-soft); border-color: var(--accent); border-style: dashed; border-top-style: solid; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 0 4px 10px; border-bottom: 1px solid #dde3ea; margin-bottom: 2px; }
.col-empty { flex: 1; display: grid; place-items: center; min-height: 120px; color: var(--faint); font-size: 13px;
             border: 1.5px dashed #d3dbe4; border-radius: 14px; }
.col-head b { font-size: 14px; }
.cnt { border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 700; }
.kcard { background: #fff; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 1px 2px rgba(20,30,50,.06); text-decoration: none; color: inherit; cursor: grab; }
.kcard:hover { box-shadow: 0 3px 10px rgba(20,30,50,.10); color: inherit; }
.kcard .top { display: flex; align-items: center; gap: 8px; }
.kcard .nm { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; }
.kcard .bubbletxt { font-size: 13px; color: #3d4350; line-height: 1.4; background: #f4f7f9; border-radius: 4px 12px 12px 12px; padding: 8px 10px; overflow-wrap: anywhere; }
.kcard .foot { display: flex; gap: 6px; font-size: 11px; color: var(--muted); flex-wrap: wrap; align-items: center; }
.kcard .new { margin-left: auto; background: var(--brand); color: #fff; border-radius: 10px; padding: 1px 7px; font-weight: 700; }

/* список и админка */
.tablewrap { overflow-x: auto; padding: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:hover td { background: #fafbfc; }
td a.rowlink { color: inherit; text-decoration: none; font-weight: 600; }
.bulk { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.wrap { max-width: 1100px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.box { padding: 18px 20px; }
.box h2 { margin: 0 0 6px; font-size: 16px; }
.formrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.formrow > div { flex: 1; min-width: 180px; }
code { background: var(--soft); border-radius: 6px; padding: 1px 6px; font-size: 12px; }
dialog { border: none; border-radius: var(--r); padding: 22px; width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(20,30,50,.25); }
dialog::backdrop { background: rgba(20,30,50,.35); }

@media (max-width: 1100px) {
  .grid3 { grid-template-columns: 280px minmax(0, 1fr); }
  .side { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .page.fixed { height: auto; }
  .grid3 { grid-template-columns: 1fr; }
  .queue { max-height: 260px; }
  .chat { min-height: 70vh; }
  .segs { order: 3; margin: 0; width: 100%; justify-content: center; }
  .bubble { max-width: 88%; }
  .compose-links .kbd { display: none; }
  .compose-row { flex-wrap: wrap; }
  .compose-row textarea { flex: 1 1 calc(100% - 54px); }
  .compose-row .split { width: 100%; }
  .compose-row .split .btn { flex: 1; justify-content: center; }
}
