/* B2B Агент — panel styles. Graphite ramp, one amber accent, 4px grid.
   Direction after unslop by Damir Sokolovsky (@heydamir), CC BY 4.0. */

:root {
  --bg-deep: #0f0f10;
  --bg: #141415;
  --card: #19191b;
  --raised: #232325;
  --raised-2: #2b2b2e;
  --line: rgba(237, 237, 237, 0.08);
  --line-strong: rgba(237, 237, 237, 0.14);
  --text: #ededed;
  --text-2: #a1a1a6;
  --muted: #85858b;
  --accent: #e8a33d;
  --accent-ink: #1a1306;
  --accent-soft: rgba(232, 163, 61, 0.12);
  --pos: #4cc38a;
  --neg: #e5484d;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/20px var(--sans);
  -webkit-font-smoothing: antialiased;
}
[x-cloak] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sec { color: var(--text-2); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

svg.i { width: 16px; height: 16px; stroke-width: 1.5; flex: none; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font: 600 12px/1 var(--mono);
}
.brand-name { font-weight: 500; font-size: 16px; }
.brand-switch { width: 100%; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 12px; color: var(--muted); padding: 0 8px; margin: 0 0 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 8px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; cursor: pointer;
  border: 0; background: none; width: 100%; text-align: left;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.on { background: var(--raised); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06); }
.nav-item .count { margin-left: auto; font: 12px/16px var(--mono); color: var(--muted); }
.nav-item.on .count { color: var(--accent); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-top: 1px solid var(--line); padding-top: 16px; }
.side-user .who { min-width: 0; flex: 1; }
.side-user .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; padding: 24px 32px 48px; max-width: 1560px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 16px; min-height: 40px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; line-height: 1.15; font-weight: 500; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .grow { flex: 1; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--raised); color: var(--text);
  white-space: nowrap; text-decoration: none;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), transform 120ms var(--ease);
}
.btn:hover { background: var(--raised-2); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 500; }
.btn.primary:hover { background: #f0b052; }
.btn.ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--card); color: var(--text); }
.btn.danger:hover { color: var(--neg); border-color: rgba(229,72,77,0.4); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 6px; }
.btn.icon { width: 32px; padding: 0; }
.btn.sm.icon { width: 28px; }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px; border-radius: 8px;
  background: var(--raised); border: 1px solid var(--line); color: var(--text);
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.textarea { height: auto; min-height: 88px; padding: 8px 12px; resize: vertical; line-height: 20px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: rgba(232,163,61,0.6); }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
:focus-visible { outline: 2px solid rgba(232,163,61,0.7); outline-offset: 2px; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; }
.row > .input { flex: 1; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch { display: inline-block; position: relative; width: 36px; height: 20px; flex: none; cursor: pointer; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: 10px; background: var(--raised-2);
  border: 1px solid var(--line-strong); transition: background-color 150ms var(--ease);
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 7px;
  background: var(--text-2); transition: transform 180ms var(--ease), background-color 150ms var(--ease);
}
.switch input:checked + i { background: var(--accent); border-color: transparent; }
.switch input:checked + i::after { transform: translateX(16px); background: var(--accent-ink); }

/* ---------- Surfaces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.card.pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2, .card h2 { font-size: 15px; font-weight: 500; margin: 0; }
.card-body { padding: 20px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty svg.i { width: 20px; height: 20px; }

/* Signature: requisites on hairline plates */
.req {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 4px;
  border: 1px solid var(--line-strong); background: var(--bg-deep);
  font: 12px/16px var(--mono); color: var(--text-2); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.req b { font-weight: 400; color: var(--muted); margin-right: 6px; }
.req.link { text-decoration: none; transition: border-color 150ms var(--ease), color 150ms var(--ease); }
.req.link:hover { border-color: rgba(232,163,61,0.5); color: var(--text); }
.reqs { display: flex; flex-wrap: wrap; gap: 4px; }

.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--muted); flex: none; }
.dot.on { background: var(--pos); box-shadow: 0 0 0 3px rgba(76,195,138,0.14); }
.dot.off { background: var(--neg); }
.tag { font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 400; font-size: 12px; color: var(--muted); padding: 0 12px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.r, .table th.r { text-align: right; }
.table tbody tr { transition: background-color 150ms var(--ease); }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover { background: var(--raised); }

/* ---------- Overview ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.stat { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.stat .label { font-size: 13px; color: var(--text-2); }
.stat .fig { font-size: 28px; line-height: 1; font-weight: 500; font-variant-numeric: tabular-nums; }
.stat .note { font-size: 12px; color: var(--muted); }
.overview { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 12px; }
.overview.split-side-first { grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr); align-items: start; }
.overview.split-side-last { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }
.overview.split-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--muted); font: 11px var(--mono); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 2px; border-radius: 1px; margin-right: 6px; vertical-align: middle; }

/* Moment: the pipeline */
.funnel-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--raised); gap: 2px; }
.funnel-bar span { display: block; height: 100%; transition: flex-grow 400ms var(--ease); }
.funnel-list { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.funnel-row { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; height: 32px; }
.funnel-row .sw { width: 8px; height: 8px; border-radius: 2px; }
.funnel-row .val { color: var(--muted); font: 12px var(--mono); min-width: 88px; text-align: right; }
.funnel-total { display: flex; align-items: baseline; gap: 8px; margin-bottom: 16px; }
.funnel-total .fig { font-size: 32px; line-height: 1; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- INN search ---------- */
.inn-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 12px; align-items: start; }
.runs { max-height: 236px; overflow-y: auto; }
.inn-table td { min-width: 120px; }
.inn-table td:first-child { min-width: 200px; }
.inn-table tr.call td { background: rgba(232,163,61,0.05); }
.req.has { color: var(--pos); border-color: rgba(76,195,138,0.35); }
.req.no-tg { color: var(--neg); border-color: rgba(229,72,77,0.35); }
.sm-select { height: 32px; width: 140px; padding: 0 8px; font-size: 13px; }
.sm-input { height: 32px; min-width: 180px; font-size: 13px; }

/* ---------- Dialogs ---------- */
.chat-shell { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 136px); min-height: 480px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; }
.chat-list-head { padding: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.chat-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--line); transition: background-color 150ms var(--ease);
}
.chat-item:hover { background: var(--raised); }
.chat-item.on { background: var(--raised); box-shadow: inset 2px 0 0 var(--accent); }
.chat-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.chat-item .time { font: 12px var(--mono); color: var(--muted); }
.chat-item .last { grid-column: 1 / -1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font: 500 12px/20px var(--mono); text-align: center; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; }
.chat-pane-head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); min-height: 56px; }
.msgs { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 72%; padding: 8px 12px; border-radius: 12px; background: var(--raised); white-space: pre-wrap; word-break: break-word; }
.msg.out { align-self: flex-end; background: #2c2618; border: 1px solid rgba(232,163,61,0.18); }
.msg .meta { font: 11px/16px var(--mono); color: var(--muted); margin-top: 4px; }
.msg .btns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.composer { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer .textarea { min-height: 36px; height: 36px; max-height: 160px; }

/* ---------- Drafts ---------- */
.drafts { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
.draft { display: flex; flex-direction: column; }
.draft-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px; }
.draft-reason { padding: 0 20px 12px; color: var(--text-2); font-size: 13px; }
.draft-ctx { margin: 0 20px 12px; padding: 12px; border-radius: 8px; background: var(--bg-deep); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-y: auto; }
.draft-ctx .l { font-size: 13px; color: var(--text-2); white-space: pre-wrap; }
.draft-ctx .l.out { color: var(--muted); }
.draft-ctx .l b { font-weight: 400; font: 11px var(--mono); color: var(--muted); margin-right: 8px; }
.draft-text { margin: 0 20px; width: auto; }
.draft-foot { display: flex; gap: 8px; padding: 16px 20px; margin-top: auto; }

/* ---------- CRM ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(232px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--bg-deep); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 120px; transition: border-color 150ms var(--ease); }
.col.drop { border-color: rgba(232,163,61,0.5); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 12px; font-weight: 500; }
.col-head .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; flex: none; }
.col-head .n { font: 12px var(--mono); color: var(--muted); }
.col-head .v { margin-left: auto; font: 12px var(--mono); color: var(--muted); }
.col-cards { display: flex; flex-direction: column; gap: 8px; }
.lead {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.lead:hover { border-color: var(--line-strong); background: #1d1d20; }
.lead .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.lead .c { color: var(--text-2); font-size: 13px; }
.lead .foot { display: flex; align-items: center; justify-content: space-between; font: 12px var(--mono); color: var(--muted); }

.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 21;
  background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column;
}
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 18px; font-weight: 500; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 24px; }
.section-title { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.timeline { display: flex; flex-direction: column; }
.timeline .ev { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.timeline .ev:last-child { border-bottom: 0; }
.timeline .ev .w { font: 12px var(--mono); color: var(--muted); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 30; display: grid; place-items: center; padding: 16px; }
.modal { width: min(480px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; font-weight: 500; margin: 0; flex: 1; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg-deep); border: 1px solid var(--line); border-radius: 10px; }
.tabs button { flex: 1; height: 30px; border: 0; border-radius: 6px; background: none; color: var(--text-2); cursor: pointer; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.tabs button.on { background: var(--raised); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06); }

/* Moment: the QR ticket */
.qr-ticket {
  background: #f4f1ea; color: #1f1b16; border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}
.qr-box { width: 224px; height: 224px; display: grid; place-items: center; }
.qr-box img, .qr-box canvas { display: block; }
.qr-steps { margin: 0; padding: 0 0 0 20px; font-size: 13px; line-height: 20px; color: #5e554a; align-self: stretch; }
.qr-perf { align-self: stretch; border-top: 1px dashed rgba(31,27,22,0.2); padding-top: 12px; display: flex; justify-content: space-between; font: 12px var(--mono); color: #7b7266; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 24px; }
.auth-card h1 { font-size: 28px; font-weight: 500; line-height: 1.15; margin: 0; }
.auth-card p { color: var(--text-2); margin: 8px 0 0; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.toast {
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 14px;
  min-width: 240px; max-width: 420px; display: flex; gap: 10px; align-items: flex-start;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: rise 300ms var(--ease);
}
.toast.err svg.i { color: var(--neg); }
.toast.ok svg.i { color: var(--pos); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.enter { animation: rise 360ms var(--ease) both; }

.code {
  font: 12px/18px var(--mono); background: var(--bg-deep); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; white-space: pre-wrap; word-break: break-all; color: var(--text-2);
}
.progress { height: 4px; border-radius: 2px; background: var(--raised); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); transition: transform 400ms var(--ease); transform-origin: left; }
.status { font-size: 13px; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); white-space: nowrap; }

/* ---------- Mobile ---------- */
.menu-btn { display: none; }
@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .overview, .overview[class*=split], .inn-top { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 25; width: 264px; left: 0; transform: translateX(-100%); transition: transform 300ms var(--ease); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 16px 16px 48px; }
  .page-head h1 { font-size: 24px; }
  .chat-shell { grid-template-columns: 1fr; height: auto; }
  .chat-shell.has-chat .chat-list { display: none; }
  .chat-shell:not(.has-chat) .chat-pane { display: none; }
  .msgs { min-height: 50vh; }
  .chart .axis text { font-size: 26px; }  /* viewBox units: ~11px on a phone */
  .drafts { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .table.resp thead { display: none; }
  .table.resp tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .table.resp td { display: block; border: 0; padding: 4px 12px; }
}
