/* ============================================================
   Ковка — платформа ИИ-обзвона. Дизайн-система Fluent 2.
   ============================================================ */
:root {
  --brand: #0F6CBD; --brand-2: #115EA3; --brand-soft: #EFF6FC;
  --bg: #F3F2F1; --surface: #FFFFFF; --surface-2: #FAF9F8;
  --line: #E1DFDD; --line-2: #EDEBE9;
  --text: #201F1E; --text-2: #605E5C; --text-3: #8A8886;
  --ok: #107C10; --warn: #CA5010; --err: #A4262C; --info: #0F6CBD; --hot: #D83B01;
  --shadow: 0 1.6px 3.6px rgba(0,0,0,.08), 0 .3px .9px rgba(0,0,0,.06);
  --shadow-2: 0 6.4px 14.4px rgba(0,0,0,.10), 0 1.2px 3.6px rgba(0,0,0,.06);
  --radius: 8px; --radius-s: 6px;
  --nav-w: 268px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #2899F5; --brand-2: #479EF5; --brand-soft: #0B2238;
    --bg: #1B1A19; --surface: #252423; --surface-2: #2D2C2B;
    --line: #3B3A39; --line-2: #323130;
    --text: #F3F2F1; --text-2: #C8C6C4; --text-3: #979593;
    --shadow: 0 1.6px 3.6px rgba(0,0,0,.4); --shadow-2: 0 6.4px 14.4px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 15px; height: 15px; } .icon.lg { width: 22px; height: 22px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-2); }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow); }
.brand .logo .icon { stroke: #fff; }
.brand b { font-size: 16px; font-weight: 600; letter-spacing: .2px; }
.brand small { display: block; color: var(--text-3); font-size: 11.5px; font-weight: 400; }
.nav { flex: 1; overflow-y: auto; padding: 10px 12px 24px; }
.nav .group { margin-top: 16px; padding: 4px 10px; font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--text-3); }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 11px; margin: 1px 0; border-radius: var(--radius-s); color: var(--text-2); font-weight: 500; cursor: pointer; transition: background .12s, color .12s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav a.active .icon { stroke: var(--brand); }
.nav a .badge { margin-left: auto; }

/* ---------- Topbar + main ---------- */
.main { overflow-y: auto; height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: rgba(255,255,255,.82); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { .topbar { background: rgba(37,36,35,.82); } }
.topbar h1 { font-size: 19px; font-weight: 600; margin: 0; }
.topbar .sub { color: var(--text-3); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px 56px; max-width: 1500px; width: 100%; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px){ .g3,.g4 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 720px){ .g2,.g3,.g4 { grid-template-columns: 1fr;} }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .pad { padding: 18px 20px; }
.card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.card .hint { color: var(--text-3); font-size: 12.5px; margin: 0 0 14px; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.section-head h2 { font-size: 16px; margin: 0; font-weight: 600; }
.section-head .spacer { flex: 1; }

/* ---------- Stat tiles ---------- */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.stat .k { color: var(--text-3); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.stat .v { font-size: 27px; font-weight: 700; letter-spacing: -.5px; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--text-3); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface); color: var(--text); font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: .12s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.danger { color: var(--err); border-color: var(--line); }
.btn.danger:hover { background: #fdf3f3; border-color: var(--err); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .icon { stroke-width: 2; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field .desc { font-size: 11.5px; color: var(--text-3); margin: 4px 0 0; }
input, select, textarea { width: 100%; font-family: inherit; font-size: 13.5px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 9px 11px; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
textarea.code { font-family: "SF Mono", "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type=range] { flex: 1; padding: 0; }
.slider-row output { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 42px; text-align: right; }

/* ---------- Segmented ---------- */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 3px; gap: 3px; }
.segmented button { border: none; background: transparent; padding: 7px 14px; border-radius: 5px; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line-2); }
.badge.ok { background: #e9f6e9; color: var(--ok); border-color: #cdeccd; }
.badge.err { background: #fdeded; color: var(--err); border-color: #f6d4d4; }
.badge.warn { background: #fdf2e9; color: var(--warn); border-color: #f7ddc6; }
.badge.info { background: var(--brand-soft); color: var(--brand); border-color: #cfe4f7; }
.badge.hot { background: #fdece5; color: var(--hot); border-color: #f8d3c2; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok);} .dot.err { background: var(--err);} .dot.warn { background: var(--warn);} .dot.active { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--surface-2); }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }

/* ---------- Kanban ---------- */
.board-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 18px; align-items: flex-start; min-height: 60vh; }
.col { flex: 0 0 290px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: 78vh; }
.col.dragover { outline: 2px dashed var(--brand); outline-offset: -2px; background: var(--brand-soft); }
.col-head { padding: 11px 14px; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.col-head .bar { width: 4px; height: 16px; border-radius: 3px; }
.col-head .name { font-weight: 600; font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-head .cnt { color: var(--text-3); font-size: 12px; font-weight: 600; }
.col-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.deal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 11px 12px; box-shadow: var(--shadow); cursor: grab; transition: box-shadow .12s, transform .05s; }
.deal:hover { box-shadow: var(--shadow-2); }
.deal:active { cursor: grabbing; }
.deal.dragging { opacity: .4; }
.deal .t { font-weight: 600; font-size: 13px; margin-bottom: 5px; line-height: 1.3; }
.deal .meta { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 11.5px; margin-top: 3px; }
.deal .tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.deal .amount { font-weight: 700; color: var(--text); }
.col-ai .col-head { background: linear-gradient(90deg, rgba(216,59,1,.10), transparent); }

/* ---------- Slide-over (client/deal card) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.34); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .18s; }
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 560px; max-width: 94vw; background: var(--surface); box-shadow: var(--shadow-2); z-index: 51; transform: translateX(100%); transition: transform .22s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-head .avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 16px; flex: none; }
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-head .sub { color: var(--text-3); font-size: 12.5px; }
.drawer-body { overflow-y: auto; padding: 18px 22px 40px; flex: 1; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13px; }
.kv .k { color: var(--text-3); }
.tl { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 16px; }
.tl .item { position: relative; padding: 0 0 16px; }
.tl .item::before { content: ''; position: absolute; left: -23px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); }
.tl .item .when { color: var(--text-3); font-size: 11.5px; margin-bottom: 3px; }
.tl .item .txt { white-space: pre-wrap; font-size: 13px; }

/* ---------- Report card ---------- */
.report { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.report ul { margin: 6px 0 0; padding-left: 18px; } .report li { margin: 3px 0; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.stars { color: var(--hot); letter-spacing: 2px; }

/* ---------- Misc ---------- */
.muted { color: var(--text-3); } .small { font-size: 12px; }
.empty { text-align: center; color: var(--text-3); padding: 48px 20px; }
.empty .icon { width: 40px; height: 40px; opacity: .4; margin-bottom: 10px; stroke-width: 1.4; }
.spin { width: 18px; height: 18px; border: 2.5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg);} }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-3); padding: 30px; justify-content: center; }
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 100; display: flex; flex-direction: column; gap: 9px; }
.toast { background: var(--text); color: #fff; padding: 11px 16px; border-radius: var(--radius-s); box-shadow: var(--shadow-2); font-size: 13px; display: flex; align-items: center; gap: 9px; animation: slideIn .2s; max-width: 380px; }
.toast.ok { background: #0E700E; } .toast.err { background: #A4262C; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }
.divider { height: 1px; background: var(--line-2); margin: 18px 0; }
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabbar button { border: none; background: transparent; padding: 10px 14px; font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabbar button.active { color: var(--brand); border-bottom-color: var(--brand); }
pre.snippet { background: #1e1e1e; color: #d4d4d4; padding: 14px 16px; border-radius: var(--radius-s); overflow-x: auto; font-size: 12.5px; font-family: "SF Mono", Consolas, monospace; line-height: 1.5; }
.flex { display: flex; align-items: center; gap: 10px; } .flex.wrap { flex-wrap: wrap; } .flex.between { justify-content: space-between; }
audio { height: 34px; }
.kbd { font-family: monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-size: 12px; }
