/* Сфера CRM — тёмная тема. Токены → раскладка → компоненты → представления. */
:root {
  --bg: #0f1115; --bg-2: #151821; --bg-3: #1b1f2a; --bg-4: #232837; --line: #262b38; --line-2: #313749;
  --fg: #e6e8ee; --fg-2: #a7adbd; --fg-3: #6f778a; --accent: #3b82f6; --accent-2: #60a5fa; --accent-bg: rgba(59,130,246,.14);
  --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --violet: #8b5cf6; --teal: #14b8a6;
  --radius: 10px; --radius-s: 6px; --shadow: 0 10px 30px rgba(0,0,0,.45); --side: 232px; --top: 52px;
  --font: -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif; --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
a { color: var(--accent-2); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid var(--bg); } ::-webkit-scrollbar-track { background: transparent; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--fg-3); }
.hidden { display: none !important; }
.muted { color: var(--fg-2); } .dim { color: var(--fg-3); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; } .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.right { text-align: right; } .center { text-align: center; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; } .mt-s { margin-top: 6px; }

/* ---------- раскладка ---------- */
.app { display: grid; grid-template-columns: var(--side) 1fr; grid-template-rows: var(--top) 1fr; height: 100vh; }
.side { grid-row: 1 / 3; background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { height: var(--top); display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); font-weight: 600; letter-spacing: .2px; }
.brand .logo { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #1d4ed8); display: grid; place-items: center; color: #fff; font-size: 13px; }
.nav { padding: 8px; overflow: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--fg-2); margin: 1px 0; }
.nav a:hover { background: var(--bg-3); color: var(--fg); text-decoration: none; }
.nav a.active { background: var(--accent-bg); color: #fff; }
.nav a .ic { width: 18px; height: 18px; display: inline-grid; place-items: center; opacity: .9; }
.nav a .ic svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav .badge { margin-left: auto; }
.nav a .ext { margin-left: auto; display: inline-grid; place-items: center; opacity: .55; }
.nav a .ext svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav .sep { margin: 8px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--fg-3); }
.side .me { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.side .me:hover { background: var(--bg-3); }
.top { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg); }
.top h1 { font-size: 16px; margin: 0; font-weight: 600; }
.top .search { flex: 1; max-width: 460px; position: relative; }
.top .search input { width: 100%; padding-left: 32px; }
.top .search .ic { position: absolute; left: 10px; top: 9px; color: var(--fg-3); width: 16px; height: 16px; }
.top .search .ic svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.search-drop { position: absolute; top: 40px; left: 0; right: 0; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 30; max-height: 420px; overflow: auto; }
.search-drop a { display: block; padding: 8px 12px; color: var(--fg); border-bottom: 1px solid var(--line); }
.search-drop a:hover { background: var(--bg-4); text-decoration: none; } .search-drop .k { font-size: 11px; color: var(--fg-3); text-transform: uppercase; }
.main { overflow: auto; min-height: 0; position: relative; }
.page { padding: 16px 20px 40px; }
.page.full { padding: 0; height: 100%; }
.burger { display: none !important; }

/* ---------- элементы форм ---------- */
input, select, textarea { background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--radius-s); padding: 7px 10px; outline: none; min-width: 0; transition: border-color .12s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
input[type=date], input[type=datetime-local] { color-scheme: dark; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a7adbd' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 26px; }
textarea { min-height: 72px; resize: vertical; width: 100%; }
label.f { display: block; font-size: 12px; color: var(--fg-2); margin-bottom: 4px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; } .field > input, .field > select, .field > textarea { width: 100%; }
.grid { display: grid; gap: 12px; } .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: var(--radius-s); border: 1px solid var(--line-2); background: var(--bg-3); color: var(--fg); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--bg-4); border-color: #3b4256; } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: #2f74e6; }
.btn.danger { color: #fca5a5; border-color: rgba(239,68,68,.4); } .btn.danger:hover { background: rgba(239,68,68,.12); }
.btn.ok { color: #86efac; border-color: rgba(34,197,94,.4); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-2); } .btn.ghost:hover { background: var(--bg-3); color: var(--fg); }
.btn.sm { padding: 4px 8px; font-size: 12px; } .btn.icon { padding: 6px; }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--bg-4); color: var(--fg-2); font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.badge.accent { background: var(--accent-bg); color: var(--accent-2); } .badge.ok { background: rgba(34,197,94,.15); color: #86efac; } .badge.warn { background: rgba(245,158,11,.15); color: #fcd34d; } .badge.bad { background: rgba(239,68,68,.15); color: #fca5a5; }
.badge.red { background: var(--bad); color: #fff; }
.badge.new { background: var(--accent); color: #fff; font-weight: 600; }
.kcard.unseen { border-left: 3px solid var(--accent); }
.unseen-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--fg-3); }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--bg-4); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 12px; font-weight: 600; flex: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; } .avatar.lg { width: 40px; height: 40px; font-size: 15px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; color: var(--fg-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: #fff; border-color: var(--accent); }
.tabs.pipes { align-items: center; margin-bottom: 10px; }
.tabs.pipes button { font-weight: 600; }
.tabs.pipes button.pipe-act { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; font-size: 12px; padding: 6px 8px; color: var(--fg-3, var(--fg-2)); }
.tabs.pipes button.pipe-act:hover { color: #fff; }
.tabs.pipes button.pipe-act svg { width: 14px; height: 14px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { padding: 6px 9px; } .toolbar .search { min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-s); overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 6px 10px; color: var(--fg-2); cursor: pointer; } .seg button.active { background: var(--accent-bg); color: #fff; }
.empty { padding: 40px; text-align: center; color: var(--fg-3); }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--fg-2); text-transform: uppercase; letter-spacing: .4px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; } .kv .k { color: var(--fg-3); } .kv .v { min-width: 0; word-break: break-word; }

/* ---------- таблица ---------- */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; padding: 9px 12px; color: var(--fg-3); font-weight: 500; font-size: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--bg-2); z-index: 1; cursor: pointer; user-select: none; }
.tbl th.sorted { color: var(--accent-2); }
.tbl th.right { text-align: right; } .tbl th.center { text-align: center; } /* общие .right и .center слабее .tbl th */
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; } .tbl tbody tr:hover td { background: var(--bg-3); }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--fg-2); font-size: 13px; }

/* ---------- канбан ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: 60vh; }
.kcol { flex: 0 0 272px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 170px); }
.kcol.over { border-color: var(--accent); background: var(--accent-bg); }
.kcol .kh { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; position: sticky; top: 0; }
.kcol .kh .bar { position: absolute; left: 0; right: 0; top: 0; height: 3px; border-radius: var(--radius) var(--radius) 0 0; }
.kcol .kh .cnt { margin-left: auto; color: var(--fg-3); font-weight: 400; }
.kcol .ks { padding: 4px 12px 8px; font-size: 12px; color: var(--fg-3); border-bottom: 1px solid var(--line); }
.kcol .kb { padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kcard { background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px; cursor: grab; transition: border-color .12s, transform .12s; }
.kcard:hover { border-color: var(--accent); } .kcard.dragging { opacity: .5; }
.kcard .t { font-weight: 500; margin-bottom: 4px; } .kcard .m { font-size: 12px; color: var(--fg-2); display: flex; flex-wrap: wrap; gap: 4px 8px; }
.kcard .sum { color: #fff; font-weight: 600; } .kcard .stuck { color: #fcd34d; }

/* ---------- боковая панель (drawer) и модалки ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: flex; justify-content: flex-end; animation: fade .15s; }
.drawer { width: min(920px, 100%); background: var(--bg); border-left: 1px solid var(--line); height: 100%; overflow: auto; animation: slide .18s; box-shadow: var(--shadow); }
.drawer .dh { position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line); padding: 12px 20px; display: flex; align-items: center; gap: 10px; z-index: 2; }
.drawer .dh h2 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; min-width: 0; }
.drawer .db { padding: 16px 20px 40px; } .dh-actions { justify-content: flex-end; }
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 12px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow); animation: pop .15s; }
.modal.wide { width: min(860px, 100%); }
.modal .mh { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal .mb { padding: 16px 18px; } .modal .mf { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } } @keyframes slide { from { transform: translateX(30px); opacity: 0; } } @keyframes pop { from { transform: scale(.97); opacity: 0; } }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--bg-4); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); animation: pop .15s; max-width: 380px; }
.toast.ok { border-color: rgba(34,197,94,.5); } .toast.bad { border-color: rgba(239,68,68,.6); }

/* ---------- карточка сущности ---------- */
.card-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head .title { font-size: 20px; font-weight: 600; margin: 0; } .card-head .title input { font-size: 18px; font-weight: 600; background: transparent; border-color: transparent; padding: 2px 6px; width: 100%; }
.card-head .title input:hover, .card-head .title input:focus { border-color: var(--line-2); background: var(--bg-3); }
.card-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.stage-bar { display: flex; gap: 3px; margin: 10px 0 16px; overflow-x: auto; }
.stage-bar div { flex: 1; min-width: 26px; height: 22px; border-radius: 4px; background: var(--bg-4); cursor: pointer; position: relative; opacity: .5; }
.stage-bar div.done, .stage-bar div.cur { opacity: 1; } .stage-bar div.cur { outline: 2px solid #fff; outline-offset: 1px; }
.stage-bar div:hover { opacity: 1; }
.stage-bar div:hover::after { content: attr(data-name); position: absolute; top: 26px; left: 0; background: var(--bg-4); padding: 4px 8px; border-radius: 6px; white-space: nowrap; font-size: 12px; z-index: 5; border: 1px solid var(--line-2); }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl { display: flex; gap: 10px; }
.tl .ic { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-4); display: grid; place-items: center; flex: none; font-size: 13px; }
.tl .b { flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.tl .b .h { font-size: 12px; color: var(--fg-3); display: flex; gap: 8px; margin-bottom: 2px; } .tl .b .x { white-space: pre-wrap; word-break: break-word; }
.tl.comment .b { border-color: rgba(59,130,246,.35); } .tl.message .b { border-color: rgba(20,184,166,.4); }
.composer { display: flex; gap: 8px; align-items: flex-end; } .composer textarea { min-height: 44px; }
.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.fields-grid .field.full { grid-column: 1 / -1; }
.section { margin-bottom: 18px; } .section h4 { margin: 0 0 8px; font-size: 12px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .5px; }
.editable { border: 1px solid transparent; border-radius: 6px; padding: 5px 8px; min-height: 30px; cursor: text; } .editable:hover { border-color: var(--line-2); background: var(--bg-3); }
.products td input { width: 100%; padding: 4px 6px; }
.dropzone { border: 1px dashed var(--line-2); border-radius: 8px; padding: 14px; text-align: center; color: var(--fg-3); cursor: pointer; } .dropzone.over { border-color: var(--accent); color: var(--accent-2); }
.files { display: flex; flex-wrap: wrap; gap: 8px; } .files a { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 8px; color: var(--fg); background: var(--bg-3); font-size: 12px; }
.files img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.dup { border: 1px solid rgba(245,158,11,.5); background: rgba(245,158,11,.08); border-radius: 8px; padding: 8px 12px; font-size: 13px; }

/* ---------- дашборд ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.tile:hover { border-color: var(--line-2); } .tile .l { font-size: 12px; color: var(--fg-3); } .tile .v { font-size: 24px; font-weight: 600; margin-top: 2px; letter-spacing: -.5px; } .tile .s { font-size: 12px; color: var(--fg-2); }
.dash { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; } .dash .col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.funnel .r { display: grid; grid-template-columns: 200px 1fr 60px 100px; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }
.funnel .bar { height: 14px; border-radius: 4px; background: var(--accent); min-width: 2px; }
.list { display: flex; flex-direction: column; } .list a, .list .li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); color: var(--fg); font-size: 13px; }
.list a:hover { text-decoration: none; background: var(--bg-3); margin: 0 -8px; padding: 7px 8px; border-radius: 6px; } .list > :last-child { border-bottom: 0; }
.chart { width: 100%; height: auto; } .chart text { fill: var(--fg-3); font-size: 11px; } .chart .bar { fill: var(--accent); } .chart .bar:hover { fill: var(--accent-2); }

/* ---------- чаты ---------- */
.inbox { display: grid; grid-template-columns: 340px 1fr; height: 100%; }
.inbox .list-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.inbox .list-pane .toolbar { padding: 10px 12px 6px; margin: 0; border-bottom: 1px solid var(--line); }
.convs { overflow: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.conv:hover { background: var(--bg-3); } .conv.active { background: var(--accent-bg); }
.conv .n { font-weight: 500; display: flex; gap: 6px; align-items: center; } .conv .p { font-size: 12px; color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .t { font-size: 11px; color: var(--fg-3); margin-left: auto; white-space: nowrap; }
.kind-ic { width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex: none; }
.kind-telegram { background: #229ed9; } .kind-vk { background: #0077ff; } .kind-avito { background: #00aaff; } .kind-max { background: #7c3aed; } .kind-email, .kind-yandex_mail { background: #b45309; } .kind-site, .kind-form { background: #059669; } .kind-call { background: #16a34a; } .kind-other { background: #475569; }
.thread { display: flex; flex-direction: column; min-height: 0; }
.thread .th { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 72%; padding: 8px 12px; border-radius: 12px; background: var(--bg-3); white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }
.msg.out { align-self: flex-end; background: #1e3a8a; } .msg .mt { font-size: 11px; color: var(--fg-3); margin-top: 4px; } .msg.out .mt { color: #93c5fd; }
.msg .att a { display: inline-block; margin-top: 4px; }
.thread .composer { padding: 12px 16px; border-top: 1px solid var(--line); }

/* ---------- календарь ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .d { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; min-height: 110px; padding: 6px; font-size: 12px; }
.cal .d.today { border-color: var(--accent); } .cal .d .dn { color: var(--fg-3); margin-bottom: 4px; } .cal .d.other { opacity: .45; }
.cal .ev { display: block; padding: 2px 6px; border-radius: 4px; margin-bottom: 3px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.cal .ev.measure { background: #2563eb; } .cal .ev.install { background: #059669; } .cal .ev.task { background: #4b5563; } .cal .ev.done { opacity: .5; text-decoration: line-through; }
.cal .wd { text-align: center; color: var(--fg-3); font-size: 12px; padding: 4px 0; }

/* ---------- карта ---------- */
.map-page { display: grid; grid-template-columns: 1fr 340px; height: 100%; } #ymap { height: 100%; min-height: 400px; background: var(--bg-2); }
.map-list { overflow: auto; border-left: 1px solid var(--line); }

/* ---------- настройки ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; } .settings > div { min-width: 0; }
.card-grid > div, .dash .col, .report-grid > div { min-width: 0; }
.settings .snav a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--fg-2); } .settings .snav a.active { background: var(--accent-bg); color: #fff; } .settings .snav a:hover { text-decoration: none; background: var(--bg-3); }
.perm-grid { display: grid; grid-template-columns: 160px repeat(3, 110px); gap: 6px 10px; align-items: center; font-size: 13px; }
.tree .node { padding: 4px 0 4px 0; } .tree .node .row { padding: 4px 8px; border-radius: 6px; } .tree .node .row:hover { background: var(--bg-3); }
.integ { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.integ .card { display: flex; flex-direction: column; gap: 8px; }
.integ .card .head { display: flex; align-items: center; gap: 10px; } .integ .card .head b { flex: 1; }
.log { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: var(--mono); font-size: 12px; max-height: 300px; overflow: auto; white-space: pre-wrap; }
.status { width: 9px; height: 9px; border-radius: 50%; display: inline-block; } .status.ok { background: var(--ok); } .status.error { background: var(--bad); } .status.off { background: var(--fg-3); }
code, kbd { font-family: var(--mono); font-size: 12px; background: var(--bg-4); padding: 1px 5px; border-radius: 4px; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; font-size: 12px; }

/* ---------- вход ---------- */
.login { height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% -10%, rgba(59,130,246,.18), transparent), var(--bg); }
.login .box { width: min(380px, 92vw); background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 4px; font-size: 22px; } .login .sub { color: var(--fg-3); margin-bottom: 20px; }
.login .box input { width: 100%; padding: 10px 12px; }
.notif-drop { position: absolute; right: 60px; top: 48px; width: 380px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 30; max-height: 70vh; overflow: auto; }
.notif-drop a { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--fg); font-size: 13px; } .notif-drop a.unread { background: var(--accent-bg); } .notif-drop a:hover { text-decoration: none; background: var(--bg-4); }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

@media (max-width: 1000px) {
  .card-grid, .dash, .report-grid, .settings { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; } .inbox .list-pane.hide-m { display: none; } .thread.hide-m { display: none; }
  .map-page { grid-template-columns: 1fr; grid-template-rows: 1fr 200px; } .map-list { border-left: 0; border-top: 1px solid var(--line); }
  .fields-grid, .g3, .g4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); } .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .18s; } .side.open { transform: none; }
  .burger { display: inline-flex !important; } .page { padding: 12px 12px 40px; } .fields-grid, .g2, .g3, .g4 { grid-template-columns: 1fr; } .kv { grid-template-columns: 110px 1fr; }
  .drawer .dh { flex-wrap: wrap; padding: 10px 12px; } .dh-actions { order: 3; flex-basis: 100%; justify-content: flex-start; } .drawer .db { padding: 12px 12px 40px; }
  .top h1 { font-size: 15px; } .top .search { max-width: none; } .tiles { grid-template-columns: 1fr 1fr; } .drawer { width: 100%; } .notif-drop { right: 8px; left: 8px; width: auto; }
  /* длинный заголовок раздела («Согласования», «Рабочий стол») сжимается, а не растягивает страницу шире экрана:
     колонка сетки minmax(0, 1fr) не растет по содержимому шапки, заголовок обрезается многоточием */
  .top h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cal .d { min-height: 70px; } .kcol { flex-basis: 240px; }
}

/* ---------- звонки и ИИ-разбор ---------- */
.calls-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.mistake { border: 1px solid rgba(239,68,68,.35); background: rgba(239,68,68,.06); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.mistake .mt-title { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.mistake .num { width: 20px; height: 20px; border-radius: 50%; background: var(--bad); color: #fff; display: inline-grid; place-items: center; font-size: 11px; flex: none; }
.better { border-left: 3px solid var(--ok); background: rgba(34,197,94,.08); padding: 6px 10px; border-radius: 6px; font-size: 13px; }
.quote { color: var(--fg-2); font-style: italic; font-size: 13px; } .quote:hover { color: var(--accent-2); text-decoration: none; }
.transcript { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 150px); overflow: auto; padding: 2px 4px 2px 2px; }
.tline { padding: 6px 10px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); cursor: pointer; font-size: 13.5px; max-width: 92%; align-self: flex-start; }
.tline.mgr { align-self: flex-end; background: #16264a; border-color: #1e3a8a; }
.tline.err { border-color: rgba(239,68,68,.75); } .tline.now { outline: 2px solid var(--accent); } .tline.flash { animation: flash 1.6s; }
.tmeta { font-size: 11px; color: var(--fg-3); }
@keyframes flash { 0%, 60% { background: rgba(59,130,246,.35); } }
.talkbar { height: 10px; border-radius: 6px; background: var(--bg-4); overflow: hidden; } .talkbar div { height: 100%; background: var(--accent); }
.spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 24px; } .spark i { width: 6px; border-radius: 2px; display: block; }
.checks td { white-space: normal; }
audio { color-scheme: dark; height: 40px; }
@media (max-width: 1000px) { .calls-grid { grid-template-columns: 1fr; } .transcript { max-height: none; } }
/* Отчёты -> «Дилеры: скидки и рентабельность» (public/dealers.js). Палитра проверена на фоне карточки #151821. */
:root { --dl-s1: #3987e5; --dl-s2: #d95926; --dl-other: #6f778a; }
.dl-chart { display: block; margin-top: 6px; }
.dl-chart .grid { stroke: var(--line); stroke-width: 1; } .dl-chart .axis { stroke: var(--line-2); stroke-width: 1; }
.dl-chart .fit { stroke: var(--fg-3); stroke-width: 1.5; stroke-dasharray: 5 4; } .dl-chart .crosshair { stroke: var(--fg-3); stroke-width: 1; }
.dl-chart .axis-title, .dl-chart .colhead { fill: var(--fg-3); font-size: 11px; }
.dl-chart .lbl, .dl-chart .endlbl, .dl-chart .rowval { fill: var(--fg-2); font-size: 11.5px; }
.dl-chart .rowname { fill: var(--fg-2); font-size: 12px; } .dl-chart .strong { fill: var(--fg); font-weight: 600; } .dl-chart .sel { fill: #fff; font-weight: 600; }
.dl-chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dl-chart .line.s1 { stroke: var(--dl-s1); } .dl-chart .line.s2 { stroke: var(--dl-s2); }
.dl-chart .pt.s1, .dl-chart .end.s1 { fill: var(--dl-s1); } .dl-chart .pt.s2, .dl-chart .end.s2 { fill: var(--dl-s2); }
.dl-chart .end { stroke: var(--bg-2); stroke-width: 2; }
.dl-chart .dot { fill: var(--dl-s1); fill-opacity: .85; stroke: var(--bg-2); stroke-width: 2; } .dl-chart .dot.sel { fill-opacity: 1; stroke: #fff; }
.dl-chart .seg-disc { fill: var(--dl-s1); } .dl-chart .seg-other { fill: var(--dl-other); } .dl-chart .total { stroke: var(--fg); stroke-width: 2; }
.dl-chart .dl-hit { fill: transparent; outline: none; } .dl-chart .hitc, .dl-chart .rowhit { cursor: pointer; }
.dl-chart .rowhit:hover, .dl-chart .rowhit:focus { fill: rgba(255,255,255,.035); } .dl-chart .hitc:focus { stroke: var(--fg-2); stroke-width: 1; }
.dl-tip { position: fixed; z-index: 1000; display: none; pointer-events: none; max-width: 300px; padding: 8px 10px; border-radius: var(--radius-s); background: var(--bg-4); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 12px; line-height: 1.45; color: var(--fg-2); }
.dl-tip b { color: var(--fg); font-weight: 600; display: block; margin-bottom: 2px; }
.dl-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--fg-2); }
.dl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dl-key { display: inline-block; width: 16px; height: 3px; border-radius: 2px; } .dl-key.s1 { background: var(--dl-s1); } .dl-key.s2 { background: var(--dl-s2); }
.dl-key.other { background: var(--dl-other); } .dl-key.box, .dl-key.other { height: 10px; width: 12px; }
.dl-key.ink { background: var(--fg); width: 2px; height: 12px; }
.dl-cities tr.dl-sel td { background: var(--accent-bg); } .dl-cities tr.dl-total td { font-weight: 600; border-top: 1px solid var(--line-2); }
.dl-tile { cursor: default; } .dl-tile .s { margin-top: 2px; }
.dl-note { line-height: 1.5; max-width: 980px; }
.dl-citybtn { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.dl-total .dl-citybtn { font-weight: 600; } .dl-citybtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- раздел «Аналитика» (public/analytics.js) ---------- */
.an-tile { cursor: default; } .an-tile .s { margin-top: 2px; line-height: 1.5; }
.an .badge.an-d { font-size: 11px; padding: 1px 5px; margin-left: 2px; vertical-align: 1px; }
.an-cell { white-space: nowrap; }
.an .tbl tr.an-total td { font-weight: 600; border-top: 1px solid var(--line-2); }
.an .tbl tr.an-sel td { background: var(--accent-bg); }
.an .tbl sup { color: var(--fg-3); margin-left: 2px; cursor: help; }
.an-list { margin: 0; padding-left: 18px; line-height: 1.6; } .an-list li { margin: 2px 0; }
.an-access { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow: auto; margin-top: 8px; }
.an-access label.row { gap: 8px; align-items: center; } .an-access .badge { margin-left: 6px; }
.an .small.muted.mt { line-height: 1.5; max-width: 1100px; }
.an-mgr td:first-child { min-width: 180px; }
/* таблицы раздела: кнопка - только строка с раскрытием или выбором месяца (an-pick), остальные строки не нажимаются */
.an .tbl.an-t th { cursor: default; } .an .tbl.an-t tbody tr { cursor: default; } .an .tbl.an-t tbody tr.an-pick { cursor: pointer; }
.an .tbl tr.an-open > td { background: var(--accent-bg); }
.an-link { background: none; border: 0; border-bottom: 1px dashed rgba(96,165,250,.5); border-radius: 0; padding: 0 1px; margin: 0; font: inherit; color: var(--accent-2); cursor: pointer; text-align: inherit; }
.an-link:hover { color: #93c5fd; border-bottom-style: solid; } .an-link.an-open { color: var(--fg); border-bottom: 2px solid var(--accent); }
.an-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.an-link .an-cell { color: inherit; }
/* раскрытие под строкой таблицы или под плитками сводки */
.an .tbl-wrap { container-type: inline-size; }   /* раскрытие в широкой таблице - не шире видимой части (100cqw) */
.an .tbl tr.an-drill-row > td { padding: 0; background: var(--bg); cursor: default; white-space: normal; }
.an-drill { position: sticky; left: 0; box-sizing: border-box; max-width: 100cqw; padding: 12px 14px 14px; border-left: 3px solid var(--accent); text-align: left; }
.an-drill-box { margin: -4px 0 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.an-drill-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 10px; } .an-drill-head b { font-size: 14px; }
.an-drill h4 { margin: 14px 0 6px; font-size: 11.5px; font-weight: 500; color: var(--fg-3); text-transform: uppercase; letter-spacing: .5px; }
.an-drill .tbl td { padding: 6px 10px; } .an-drill .tbl th { padding: 7px 10px; }
.an-drill .badge { margin-right: 4px; }
.an-drill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 0 14px; }
.an-drill-grid > div { min-width: 0; }
.an-kpis { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.an-kpi { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 6px 10px; min-width: 120px; }
.an-kpi .l { font-size: 11.5px; color: var(--fg-3); } .an-kpi .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; } .an-kpi .s { font-size: 11.5px; color: var(--fg-2); }
.an-tile.an-tile-pick { cursor: pointer; } .an-tile-pick:hover { border-color: var(--accent); }
.an-tile-pick.an-open { border-color: var(--accent); background: var(--accent-bg); } .an-tile-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* столбик диаграммы - кнопка выбора месяца (views.js barChart, it.onclick) */
.chart .pick { cursor: pointer; outline: none; } .chart .pick .hit { fill: transparent; } .chart .pick:hover .hit { fill: var(--bg-3); }
.chart .pick:focus-visible .hit { stroke: var(--accent); stroke-width: 1.5; }
.chart .pick.sel .hit { fill: var(--accent-bg); } .chart .pick.sel .bar { fill: var(--accent-2); } .chart .pick.sel text { fill: var(--fg); font-weight: 600; }

/* ---------- Согласования (public/approvals.js, 08.11.2026) ---------- */
.ap .ap-tabs { margin-bottom: 10px; }
.ap .ap-filters select { max-width: 230px; }
.ap-agent { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; margin-bottom: 12px; border: 1px solid rgba(245,158,11,.45); background: rgba(245,158,11,.1); border-radius: var(--radius); color: #fcd34d; }
.ap-agent svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; flex: none; margin-top: 2px; }
.ap-sum { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 10px; color: var(--fg-2); font-size: 13px; min-height: 30px; }
.ap-list { display: flex; flex-direction: column; gap: 10px; }
.ap-one { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.ap-card { background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--line-2); border-radius: var(--radius); padding: 10px 14px 8px; }
.ap-card.lvl-high { border-left-color: var(--bad); } .ap-card.lvl-medium { border-left-color: var(--warn); } .ap-card.lvl-low { border-left-color: var(--ok); }
.ap-card.ap-focus { box-shadow: 0 0 0 2px var(--accent); }
.ap-head { display: flex; align-items: flex-start; gap: 10px; }
.ap-check, .ap-check-ph { margin-top: 6px; width: 16px; flex: none; }
.ap-risk { flex: none; min-width: 48px; text-align: center; padding: 3px 6px; border-radius: 8px; font-weight: 700; font-size: 13px; background: var(--bg-4); color: var(--fg-2); margin-top: 1px; }
.ap-risk.bad { background: rgba(239,68,68,.18); color: #fca5a5; } .ap-risk.warn { background: rgba(245,158,11,.18); color: #fcd34d; } .ap-risk.ok { background: rgba(34,197,94,.15); color: #86efac; }
.ap-title { font-size: 15px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; }
.ap-amount { margin-left: 4px; font-weight: 700; font-size: 16px; color: #fff; }
.ap-sub { color: var(--fg-2); font-size: 13px; margin-top: 2px; }
.ap-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ap-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0 74px; }
.ap-status { margin: 8px 0 0 74px; padding: 6px 10px; border-radius: 8px; background: var(--bg-3); font-size: 13px; color: var(--fg-2); display: flex; gap: 8px; align-items: center; }
.ap-status svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.ap-status.wait { background: var(--accent-bg); color: var(--accent-2); } .ap-status.bad { background: rgba(239,68,68,.12); color: #fca5a5; } .ap-status.done { background: rgba(34,197,94,.1); color: #86efac; }
.ap-body { margin: 8px 0 0 74px; display: flex; flex-direction: column; gap: 8px; }
.ap-factors { margin: 0; padding-left: 18px; font-size: 13px; } .ap-factors li { margin: 1px 0; } .ap-factors li.strong { color: #fca5a5; } .ap-factors li.weak { color: #fcd34d; }
.ap-advice { font-size: 13px; padding: 6px 10px; border-radius: 8px; background: var(--bg-3); } .ap-advice.ok b { color: #86efac; } .ap-advice.warn b { color: #fcd34d; } .ap-advice.bad b { color: #fca5a5; }
.ap-sec { display: flex; flex-direction: column; gap: 6px; }
.ap-lines td { vertical-align: top; font-size: 13px; } .ap-lines th { font-size: 12px; }
.ap-up { color: #fca5a5; font-weight: 600; } .ap-down { color: #86efac; font-weight: 600; }
.ap-spark { width: 90px; height: 22px; vertical-align: middle; } .ap-spark path { fill: none; stroke: var(--accent-2); stroke-width: 1.6; }
.ap-kv { grid-template-columns: 170px 1fr; }
.ap-months { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; } .ap-months span { white-space: nowrap; }
.ap-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-trip { padding: 6px 10px; border-radius: 8px; background: var(--bg-3); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.ap-dups { font-size: 13px; padding: 6px 10px; border-radius: 8px; background: rgba(239,68,68,.12); color: #fecaca; }
.ap-points { display: flex; flex-wrap: wrap; gap: 4px; } .ap-own { background: var(--accent-bg); }
.ap-files a { max-width: 260px; } .ap-files a span, .ap-files .tag { overflow: hidden; text-overflow: ellipsis; }
.ap-files svg, .ap-files .tag svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.ap-more { margin-left: 74px; } .ap-more-in { padding-top: 6px; }
.ap-toggle { margin: 4px 0 0 66px; }
.ap-ftoggle { display: none; } .ap-ftoggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.ap-talk { gap: 12px; }
.ap-talk-who { font-size: 14px; } .ap-talk-warn { color: #fcd34d; margin-top: 2px; }
.ap-talk-sec { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.ap-talk-sec a.btn { max-width: 100%; white-space: normal; text-align: left; text-decoration: none; }
.ap-talk-h { font-weight: 600; font-size: 13px; color: var(--fg-2); }
.ap-talk-link { display: flex; gap: 6px; width: 100%; } .ap-talk-link input { flex: 1; min-width: 0; }
.ap-talk-text { white-space: pre-wrap; word-break: break-word; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--bg-3); }
@media (max-width: 760px) {
  .ap-ftoggle { display: inline-flex; } .ap .ap-filters:not(.open) { display: none; }
  .ap-head { flex-wrap: wrap; } .ap-actions { width: 100%; justify-content: flex-start; }
  .ap-meta, .ap-status, .ap-body, .ap-more { margin-left: 0; } .ap-toggle { margin-left: -8px; }
  .ap-kv { grid-template-columns: 1fr; } .ap-lines th:nth-child(4), .ap-lines td:nth-child(4) { display: none; }
}
