/* ÖRGON CRM — dark Örgon look (deep green-black, #00D978, Onest). */
:root {
  --bg: #06120d;
  --bg-2: #08170f;
  --panel: #0c1f17;
  --panel-2: #10281e;
  --panel-3: #143227;
  --line: rgba(160, 230, 196, .10);
  --line-2: rgba(160, 230, 196, .20);
  --text: #ecf8f2;
  --muted: #93b5a5;
  --dim: #6c8f7f;
  --green: #00d978;
  --green-2: #00b863;
  --green-soft: rgba(0, 217, 120, .12);
  --on-green: #04261a;
  --amber: #ffb547;
  --red: #ff6b6b;
  --blue: #5ab8ff;
  --violet: #b18cff;
  --pink: #ff7ab6;
  --radius: 14px;
  /* chart series (validated dark categorical slots vs panel #0c1f17) */
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Onest", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 8px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(160, 230, 196, .14); border-radius: 8px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }

/* ---------- Shell ---------- */
.crm { display: grid; grid-template-columns: 236px 1fr; height: 100vh; overflow: hidden; }
.rail {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px; gap: 14px; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 6px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--green); color: var(--on-green); box-shadow: 0 0 22px rgba(0, 217, 120, .3);
}
.logo-mark svg { width: 19px; height: 19px; }
.logo-word { font-size: 21px; font-weight: 800; letter-spacing: -.05em; color: var(--green); line-height: 1; }
.logo-word small { font-size: 10px; font-weight: 800; letter-spacing: .14em; color: var(--text); margin-left: 3px; vertical-align: 3px; }
.rail-search {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--panel); color: var(--dim); font-size: 13px; text-align: left;
}
.rail-search kbd { margin-left: auto; }
kbd {
  font-family: inherit; font-size: 11px; padding: 1px 6px; border-radius: 6px;
  border: 1px solid var(--line-2); color: var(--muted); background: var(--bg);
}
.rail nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.rail .group { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); padding: 12px 10px 4px; }
.rail nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.rail nav a:hover { background: var(--panel); color: var(--text); }
.rail nav a.active { background: var(--green-soft); color: var(--green); }
.rail nav a .n {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 999px;
  background: var(--green); color: var(--on-green); font-size: 11px; font-weight: 800; text-align: center;
}
.rail nav a.soon { opacity: .55; }
.rail nav a .soon-tag { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--dim); border: 1px solid var(--line-2); padding: 0 6px; border-radius: 999px; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; align-self: flex-start; }
.lang button { font-size: 11px; font-weight: 800; color: var(--dim); padding: 4px 9px; border-radius: 999px; letter-spacing: .05em; }
.lang button.on { background: var(--green); color: var(--on-green); }
.me { display: flex; align-items: center; gap: 9px; padding: 9px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.me b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { display: block; color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me div { min-width: 0; flex: 1; }
.me a { color: var(--dim); }
.me a:hover { color: var(--red); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: 58px; flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.topbar .sub { color: var(--dim); font-size: 12.5px; }
.top-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.burger { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.pill.ok::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.warn::before { background: var(--amber); }
.view { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.view.scroll { overflow-y: auto; }
.view.scroll > .page { flex: none; }

/* ---------- Buttons, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 13px; border-radius: 10px; font-weight: 650; font-size: 13px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  transition: background .15s, border-color .15s, transform .1s; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: rgba(160, 230, 196, .3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--on-green); }
.btn.primary:hover { background: #19e388; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel); color: var(--text); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input, .select, textarea.input {
  width: 100%; padding: 9px 11px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line-2); color: var(--text); outline: none;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(0, 217, 120, .15); }
.select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea.input { resize: vertical; min-height: 70px; }
.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #04261a;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
  background: rgba(255, 255, 255, .06); color: var(--text); border: 1px solid transparent; white-space: nowrap;
}
.chip i { width: 7px; height: 7px; border-radius: 50%; }
.chip button { color: var(--dim); font-size: 13px; line-height: 1; padding: 0 0 0 2px; }
.chip button:hover { color: var(--red); }
.ch-ico {
  width: 18px; height: 18px; border-radius: 5px; display: inline-grid; place-items: center;
  font-size: 9px; font-weight: 800; color: #fff; flex: none;
}
.ch-whatsapp { background: #1fa855; }
.ch-instagram { background: linear-gradient(135deg, #f58529, #dd2a7b 55%, #8134af); }
.ch-telegram { background: #2aa3e0; }
.ch-sms { background: #8b6cff; }
.ch-web { background: #4b6b5d; }
.st { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.st-open { color: var(--green); background: var(--green-soft); }
.st-pending { color: var(--amber); background: rgba(255, 181, 71, .12); }
.st-resolved { color: var(--muted); background: rgba(255, 255, 255, .06); }
.empty { padding: 40px 20px; text-align: center; color: var(--dim); }
.empty svg.i { width: 34px; height: 34px; margin: 0 auto 10px; display: block; color: var(--line-2); }

/* ---------- Inbox ---------- */
.inbox { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr) 320px; }
.convos { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.convos-tools { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 9px; border-bottom: 1px solid var(--line); }
.seg { display: flex; gap: 3px; padding: 3px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); }
.seg button { flex: 1; min-width: 0; padding: 5px 2px; border-radius: 8px; font-size: 11.5px; font-weight: 650; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; line-height: 1.25; }
.seg button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg button.on { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg button em { font-style: normal; font-size: 13px; font-weight: 800; color: var(--dim); }
.seg button.on em { color: var(--green); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters .select { width: auto; flex: 1; padding: 6px 26px 6px 9px; font-size: 12px; border-radius: 8px; }
.chan { display: flex; gap: 4px; }
.chan button { padding: 4px 8px; border-radius: 8px; font-size: 11.5px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); display: inline-flex; gap: 5px; align-items: center; }
.chan button.on { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.list { overflow-y: auto; overflow-x: hidden; flex: 1; padding: 6px; }
.chat-row {
  width: 100%; display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center;
  padding: 10px; border-radius: 12px; text-align: left; position: relative;
}
.chat-row:hover { background: var(--panel); }
.chat-row.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--green); }
.chat-row .av-wrap { position: relative; }
.chat-row .av-wrap .ch-ico { position: absolute; right: -3px; bottom: -3px; width: 15px; height: 15px; font-size: 7.5px; border: 2px solid var(--bg); box-sizing: content-box; }
.chat-row b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .preview { display: block; color: var(--dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .mid { min-width: 0; }
.chat-row .tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.chat-row .tags .chip { font-size: 10.5px; padding: 1px 6px; }
.chat-row .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 11px; color: var(--dim); }
.chat-row.unread b { color: #fff; }
.badge { min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; background: var(--green); color: var(--on-green); font-size: 10.5px; font-weight: 800; display: grid; place-items: center; }
.assignee-dot { font-size: 10.5px; color: var(--muted); max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: radial-gradient(1200px 500px at 70% -10%, rgba(0, 217, 120, .05), transparent 60%), var(--bg-2); }
.thread-head { min-height: 62px; padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--bg); }
.thread-head .who { flex: 1 1 200px; min-width: 200px; }
.thread-head .who > div { min-width: 0; }
.thread-head .who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .acts { flex: 0 0 auto; flex-wrap: wrap; margin-left: auto; }
.thread-head .who { display: flex; align-items: center; gap: 11px; }
.thread-head .who b { display: block; font-size: 15px; }
.thread-head .who small { color: var(--dim); font-size: 12px; }
.thread-head .acts { display: flex; gap: 6px; align-items: center; }
.messages { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; }
.day-sep { align-self: center; font-size: 11px; color: var(--dim); padding: 3px 10px; border-radius: 999px; background: var(--panel); margin: 8px 0; }
.bubble {
  max-width: min(72%, 560px); padding: 9px 12px 7px; border-radius: 15px; font-size: 13.8px;
  white-space: pre-wrap; word-wrap: break-word; position: relative;
}
.bubble time { display: block; font-size: 10.5px; margin-top: 3px; opacity: .65; text-align: right; }
.bubble.them { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 5px; }
.bubble.me { align-self: flex-end; background: #0b4d33; color: #eafff4; border-bottom-right-radius: 5px; }
.bubble.note {
  align-self: center; max-width: 80%; background: rgba(255, 181, 71, .09); border: 1px dashed rgba(255, 181, 71, .4);
  color: #ffe2b0; border-radius: 12px; font-size: 13px;
}
.bubble.note .who { font-weight: 700; font-size: 11px; color: var(--amber); display: block; margin-bottom: 2px; }
.sys { align-self: center; font-size: 11.5px; color: var(--dim); display: flex; gap: 6px; align-items: center; }
.sys::before, .sys::after { content: ""; width: 28px; height: 1px; background: var(--line); }
.empty-thread { margin: auto; text-align: center; color: var(--dim); max-width: 320px; }
.empty-thread svg.i { width: 46px; height: 46px; color: var(--green); opacity: .5; margin: 0 auto 12px; display: block; }

.composer-wrap { border-top: 1px solid var(--line); background: var(--bg); padding: 10px 14px 12px; position: relative; }
.comp-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.comp-tabs button { font-size: 12px; font-weight: 700; color: var(--dim); padding: 4px 10px; border-radius: 8px; }
.comp-tabs button.on { color: var(--green); background: var(--green-soft); }
.comp-tabs button.on.note-tab { color: var(--amber); background: rgba(255, 181, 71, .1); }
.composer { display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--line-2); border-radius: 13px; background: var(--panel); padding: 6px; }
.composer.note-mode { border-color: rgba(255, 181, 71, .45); background: rgba(255, 181, 71, .05); }
.composer textarea {
  flex: 1; border: 0; outline: none; background: transparent; resize: none; min-height: 38px; max-height: 160px;
  padding: 9px 6px; line-height: 1.4;
}
.composer .tool { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); }
.composer .tool:hover { background: var(--panel-3); color: var(--text); }
.composer .send { width: 38px; height: 38px; border-radius: 10px; background: var(--green); color: var(--on-green); display: grid; place-items: center; }
.composer.note-mode .send { background: var(--amber); }
.comp-hint { font-size: 11px; color: var(--dim); margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }
.ai-btn { display: inline-flex; gap: 6px; align-items: center; padding: 0 10px; height: 36px; border-radius: 9px; font-size: 12.5px; font-weight: 700; color: var(--green); background: var(--green-soft); }
.ai-btn:hover { background: rgba(0, 217, 120, .2); }
.tpl-pop {
  position: absolute; left: 14px; right: 14px; bottom: calc(100% - 4px); max-height: 300px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 13px; box-shadow: var(--shadow); padding: 6px; z-index: 5;
}
.tpl-pop button { width: 100%; text-align: left; padding: 8px 10px; border-radius: 9px; display: block; }
.tpl-pop button:hover, .tpl-pop button.on { background: var(--panel-3); }
.tpl-pop b { font-size: 13px; }
.tpl-pop code { font-size: 11px; color: var(--green); margin-left: 6px; }
.tpl-pop p { margin: 2px 0 0; font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.details { border-left: 1px solid var(--line); overflow-y: auto; background: var(--bg); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card h3 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); font-weight: 750; display: flex; align-items: center; gap: 6px; }
.card h3 .btn { margin-left: auto; text-transform: none; letter-spacing: 0; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.profile { display: flex; gap: 12px; align-items: center; }
.profile b { font-size: 15.5px; display: block; }
.profile small { color: var(--dim); }
.tag-box { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tag-add { font-size: 11.5px; color: var(--green); padding: 2px 8px; border: 1px dashed rgba(0, 217, 120, .45); border-radius: 999px; }
.stat3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat3 div { background: var(--bg); border-radius: 10px; padding: 8px; text-align: center; }
.stat3 b { display: block; font-size: 16px; }
.stat3 small { color: var(--dim); font-size: 11px; }
.order-line { display: flex; justify-content: space-between; font-size: 12.5px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.order-line:last-child { border-bottom: 0; }
.order-line a { color: var(--green); }

/* ---------- Timeline ---------- */
.tl { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 26px 1fr; gap: 10px; position: relative; padding-bottom: 14px; }
.tl-item::before { content: ""; position: absolute; left: 12px; top: 26px; bottom: 0; width: 1px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-3); color: var(--muted); }
.tl-dot svg.i { width: 13px; height: 13px; }
.tl-note .tl-dot { background: rgba(255, 181, 71, .14); color: var(--amber); }
.tl-create .tl-dot, .tl-status .tl-dot { background: var(--green-soft); color: var(--green); }
.tl-won .tl-dot, .tl-stage .tl-dot { background: var(--green-soft); color: var(--green); }
.tl-lost .tl-dot { background: rgba(255, 107, 107, .12); color: var(--red); }
.tl-merge .tl-dot { background: rgba(177, 140, 255, .14); color: var(--violet); }
.tl-body { font-size: 13px; padding-top: 3px; min-width: 0; }
.tl-body p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-body small { color: var(--dim); font-size: 11.5px; }
.tl-note .tl-body p { background: rgba(255, 181, 71, .06); border: 1px solid rgba(255, 181, 71, .18); border-radius: 10px; padding: 8px 10px; margin-top: 2px; }
.note-form { display: flex; gap: 8px; margin-bottom: 14px; }
.note-form textarea { min-height: 42px; }

/* ---------- Tables / record pages ---------- */
.page { padding: 18px 22px 30px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .input.search { max-width: 300px; padding-left: 34px; background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236c8f7f' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px 50% / 16px; }
.toolbar .select { width: auto; min-width: 130px; background-color: var(--panel); }
.toolbar .spacer { flex: 1; }
.bulkbar {
  display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 12px;
  background: var(--green-soft); border: 1px solid rgba(0, 217, 120, .3); font-size: 13px; flex-wrap: wrap;
}
.bulkbar b { color: var(--green); }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--panel); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--panel); cursor: default; }
table.t th.sort { cursor: pointer; }
table.t th.sort:hover { color: var(--text); }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr { cursor: pointer; }
table.t tbody tr:hover td { background: rgba(255, 255, 255, .02); }
table.t tbody tr.sel td { background: rgba(0, 217, 120, .06); }
table.t .who { display: flex; align-items: center; gap: 10px; font-weight: 650; }
table.t .who small { display: block; color: var(--dim); font-weight: 500; font-size: 11.5px; }
table.t input[type=checkbox] { accent-color: var(--green); width: 15px; height: 15px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; color: var(--dim); font-size: 12.5px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; }
.kpi small { color: var(--dim); font-size: 12px; font-weight: 600; }
.kpi b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: clamp(17px, 1.7vw, 24px); letter-spacing: -.02em; margin-top: 2px; }
.kpi .up { color: var(--green); font-size: 12px; font-weight: 700; }

/* ---------- Drawer / modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(2, 8, 5, .6); backdrop-filter: blur(2px); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); z-index: 41;
  background: var(--bg-2); border-left: 1px solid var(--line-2); box-shadow: var(--shadow);
  display: flex; flex-direction: column; animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.drawer-head h2 { margin: 0; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.drawer-tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.drawer-tabs button { padding: 10px 10px; font-size: 13px; font-weight: 650; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.drawer-tabs button.on { color: var(--text); border-color: var(--green); }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.modal {
  position: fixed; left: 50%; top: 12vh; transform: translateX(-50%); width: min(520px, calc(100% - 32px)); z-index: 41;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); padding: 18px;
  display: flex; flex-direction: column; gap: 12px; max-height: 76vh; overflow-y: auto;
}
.modal h2 { margin: 0; font-size: 17px; }

/* ---------- Command palette ---------- */
.palette { top: 10vh; padding: 0; gap: 0; width: min(620px, calc(100% - 32px)); overflow: hidden; }
.palette input { border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 16px 18px; font-size: 15.5px; outline: none; width: 100%; }
.palette .res { max-height: 56vh; overflow-y: auto; padding: 6px; }
.palette .grp { font-size: 10.5px; font-weight: 750; letter-spacing: .12em; color: var(--dim); text-transform: uppercase; padding: 10px 12px 4px; }
.palette .it { width: 100%; display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; text-align: left; }
.palette .it.on, .palette .it:hover { background: var(--panel-2); }
.palette .it small { color: var(--dim); margin-left: auto; font-size: 12px; max-width: 50%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel-3); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; animation: slide .2s; }
.toast.err { border-color: rgba(255, 107, 107, .5); color: #ffd0d0; }

/* ---------- Banners (WhatsApp setup) ---------- */
.banner { margin: 12px 16px 0; padding: 14px 16px; border-radius: var(--radius); border: 1px solid rgba(255, 181, 71, .35); background: rgba(255, 181, 71, .07); display: flex; gap: 16px; align-items: center; justify-content: space-between; }
.banner h2 { margin: 0 0 4px; font-size: 14.5px; }
.banner p { margin: 2px 0; color: var(--muted); font-size: 13px; }
.banner code { background: var(--bg); padding: 1px 6px; border-radius: 6px; color: var(--amber); }
.banner img { width: 150px; height: 150px; border-radius: 10px; background: #fff; padding: 6px; }

/* ---------- Soon / placeholder ---------- */
.soon-page { margin: auto; max-width: 520px; text-align: center; padding: 40px 20px; }
.soon-page .logo-mark { margin: 0 auto 16px; width: 54px; height: 54px; border-radius: 16px; }
.soon-page .logo-mark svg { width: 28px; height: 28px; }
.soon-page h2 { margin: 0 0 8px; font-size: 22px; }
.soon-page ul { text-align: left; color: var(--muted); line-height: 1.8; display: inline-block; margin: 14px 0 0; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tpl-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.tpl-card:hover { border-color: var(--line-2); }
.tpl-card b { font-size: 14px; }
.tpl-card code { color: var(--green); font-size: 12px; }
.tpl-card p { margin: 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-card small { color: var(--dim); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; }
.swatches button.on { border-color: #fff; }

/* ---------- Login (crm/login.html) ---------- */
.crm-login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 500px at 50% -10%, rgba(0, 217, 120, .14), transparent 60%), var(--bg); }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 22px; padding: 30px 28px; box-shadow: var(--shadow); }
.login-card .brand { padding: 0 0 18px; }
.login-card h1 { margin: 0 0 8px; font-size: 24px; letter-spacing: -.02em; }
.login-card .lead { color: var(--muted); margin: 0 0 20px; }
.login-card ul { margin: 0 0 22px; padding: 0; list-style: none; display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.login-card li::before { content: "✓"; color: var(--green); font-weight: 800; margin-right: 8px; }
.google { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; border-radius: 12px; background: #fff; color: #1f2937; font-weight: 700; }
.google:hover { background: #f1f5f3; }
.err { color: #ffd0d0; background: rgba(255, 107, 107, .12); border: 1px solid rgba(255, 107, 107, .3); padding: 10px 12px; border-radius: 10px; font-size: 13px; }

/* ---------- Bot editor (crm/bot_edit.html) ---------- */
.crm-edit { min-height: 100vh; }
.crm-edit .top { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.crm-edit .top h1 { margin: 0; font-size: 20px; }
.crm-edit .eyebrow { margin: 0 0 3px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.crm-edit .who { display: flex; gap: 14px; color: var(--muted); font-weight: 600; }
.crm-edit .who a:hover { color: var(--green); }
.edit-wrap { max-width: 1100px; margin: 0 auto; padding: 20px 24px 40px; }
.edit-wrap .lead { color: var(--muted); }
.edit-wrap .ok { color: var(--green); background: var(--green-soft); padding: 10px 12px; border-radius: 10px; }
.grid-head, .grid-row { display: grid; grid-template-columns: 70px 1fr 2fr 90px; gap: 8px; align-items: center; }
.grid-head { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); padding: 0 2px 6px; }
.grid-row { margin-bottom: 6px; }
.grid-row input[type=text], .grid-row input:not([type]) { padding: 8px 10px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line-2); color: var(--text); width: 100%; }
.grid-row label { font-size: 12px; color: var(--muted); }
.save { margin-top: 14px; padding: 10px 18px; border-radius: 10px; background: var(--green); color: var(--on-green); font-weight: 750; }


/* ---------- Deals (kanban) ---------- */
.deals-top { padding: 14px 22px 0; display: flex; flex-direction: column; gap: 12px; }
.deals-top .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi.k-green b { color: var(--green); }
.kpi.k-amber b { color: var(--amber); }
.kpi.k-red b { color: var(--red); }
.view-toggle { display: flex; padding: 3px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.view-toggle button { padding: 5px 10px; border-radius: 7px; font-size: 12px; font-weight: 700; color: var(--dim); }
.view-toggle button.on { background: var(--panel-3); color: var(--text); }
.board { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 14px 22px 18px; overflow-x: auto; align-items: stretch; }
.col { width: 280px; flex: none; display: flex; flex-direction: column; min-height: 0; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); }
.col-head { user-select: none; padding: 11px 12px 9px; border-bottom: 1px solid var(--line); position: relative; }
.col-head::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; border-radius: var(--radius) var(--radius) 0 0; background: var(--c, var(--blue)); }
.col-head .row { gap: 8px; }
.col-head b { font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head .cnt { font-size: 11px; font-weight: 800; color: var(--dim); background: var(--panel); padding: 1px 7px; border-radius: 999px; }
.col-head small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 650; }
.col-head .add { color: var(--dim); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; }
.col-head .add:hover { background: var(--panel-2); color: var(--green); }
.col-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; transition: background .15s; }
.col.drop .col-body { background: rgba(0, 217, 120, .05); box-shadow: inset 0 0 0 2px rgba(0, 217, 120, .35); border-radius: 0 0 var(--radius) var(--radius); }
.col.k-won .col-body, .col.k-lost .col-body { opacity: .9; }
.dcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; cursor: grab;
  display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, transform .15s, box-shadow .15s; user-select: none;
}
.dcard:hover { border-color: var(--line-2); }
.dcard.dragging { opacity: .45; transform: rotate(1.5deg); }
.dcard.ghost-gap { box-shadow: 0 -3px 0 var(--green); }
.dcard .t { font-weight: 700; font-size: 13.3px; line-height: 1.3; }
.dcard .amt { font-weight: 800; font-size: 14px; color: var(--green); }
.dcard .who { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); min-width: 0; }
.dcard .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard .foot { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--dim); }
.dcard .foot .due.late { color: var(--red); font-weight: 700; }
.dcard .foot .avatar { margin-left: auto; width: 22px; height: 22px; font-size: 9.5px; }
.dcard .tags { display: flex; gap: 4px; flex-wrap: wrap; }
.dcard .tags .chip { font-size: 10.5px; padding: 1px 6px; }
.col-empty { color: var(--dim); font-size: 12px; text-align: center; padding: 14px 6px; border: 1px dashed var(--line); border-radius: 10px; }
.stagebar { display: flex; gap: 3px; }
.stagebar button { flex: 1; min-width: 0; padding: 7px 4px; font-size: 11px; font-weight: 700; color: var(--dim); background: var(--panel); border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stagebar button.past { background: color-mix(in srgb, var(--c) 30%, var(--panel)); color: var(--text); }
.stagebar button.cur { background: var(--c); color: #04261a; }
.stagebar button:hover { filter: brightness(1.15); }
.closebar { display: flex; gap: 8px; }
.closebar .won { background: rgba(0, 217, 120, .14); color: var(--green); border-color: rgba(0, 217, 120, .4); flex: 1; }
.closebar .lost { background: rgba(255, 107, 107, .1); color: var(--red); border-color: rgba(255, 107, 107, .35); flex: 1; }
.result { padding: 10px 12px; border-radius: 12px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.result.won { background: rgba(0, 217, 120, .12); color: var(--green); }
.result.lost { background: rgba(255, 107, 107, .1); color: var(--red); }
.items { width: 100%; border-collapse: collapse; font-size: 13px; }
.items td { padding: 4px 3px; }
.items input { padding: 6px 8px; font-size: 12.5px; }
.items .num { width: 90px; }
.items .qty { width: 64px; }
.items tfoot td { padding-top: 8px; font-weight: 800; }
.deal-list .amt { font-weight: 800; color: var(--green); white-space: nowrap; }
.mini-deal { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; cursor: pointer; }
.mini-deal:last-child { border-bottom: 0; }
.mini-deal i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mini-deal span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-deal b { color: var(--green); white-space: nowrap; }
.stage-edit { display: grid; grid-template-columns: 26px 1fr 80px 92px 30px; gap: 6px; align-items: center; margin-bottom: 6px; }
.stage-edit input[type=color] { width: 26px; height: 26px; border: 0; padding: 0; background: none; border-radius: 6px; cursor: pointer; }
.stage-edit .input, .stage-edit .select { padding: 6px 8px; font-size: 12.5px; }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.reasons button { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.reasons button.on { border-color: var(--red); color: var(--red); background: rgba(255, 107, 107, .08); }
@media (max-width: 1000px) { .deals-top .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .deals-top { padding: 12px 14px 0; }
  .board { padding: 12px 14px 16px; scroll-snap-type: x mandatory; }
  .col { width: 84vw; scroll-snap-align: start; }
  #view-deals { overflow-y: auto; }
  #dl-body { flex: none !important; height: 74vh; }
  .deals-top .kpis { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 2px; }
  .deals-top .kpi { flex: 0 0 46%; scroll-snap-align: start; padding: 10px 12px; }
  .stage-edit { grid-template-columns: 26px 1fr 70px 30px; }
  .stage-edit .kind { display: none; }
}


/* ---------- Tasks ---------- */
.bell { position: relative; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line); background: var(--panel); }
.bell:hover { color: var(--text); }
.bell .n { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--amber); color: #3a2400; font-size: 10.5px; font-weight: 800; display: grid; place-items: center; }
.bell.hot .n { background: var(--red); color: #fff; }
.bell.hot { color: var(--red); border-color: rgba(255, 107, 107, .4); }
.quick-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.quick-add #qa-title { flex: 1 1 260px; }
.quick-add .select { width: auto; }
.quick-add input[type=datetime-local] { width: auto; color-scheme: dark; }
.presets { display: flex; gap: 4px; flex-wrap: wrap; }
.presets button { padding: 6px 9px; border-radius: 8px; font-size: 12px; font-weight: 650; color: var(--muted); border: 1px solid var(--line); }
.presets button:hover, .presets button.on { color: var(--green); border-color: rgba(0, 217, 120, .45); }
input[type=datetime-local], input[type=date] { color-scheme: dark; }
.tgroup { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.tgroup.mini { margin: 0; }
.tgroup h4 { margin: 0 0 2px; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); display: flex; gap: 8px; align-items: center; }
.tgroup h4 em { font-style: normal; background: var(--panel-2); color: var(--muted); padding: 0 7px; border-radius: 999px; letter-spacing: 0; }
.tgroup.g-overdue h4 { color: var(--red); }
.tgroup.g-today h4 { color: var(--amber); }
.task { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; transition: border-color .15s; }
.task:hover { border-color: var(--line-2); }
.task.late { border-left: 3px solid var(--red); }
.task.pr-high .body b::after { content: " !"; color: var(--red); font-weight: 900; }
.task .tick { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line-2); display: grid; place-items: center; flex: none; color: var(--on-green); }
.task .tick:hover { border-color: var(--green); background: var(--green-soft); }
.task.done .tick { background: var(--green); border-color: var(--green); }
.task .tick svg.i { width: 13px; height: 13px; stroke-width: 3; }
.task .kind { color: var(--muted); display: grid; place-items: center; }
.task .kind svg.i { width: 16px; height: 16px; }
.task .body { flex: 1; min-width: 0; }
.task .body b { font-size: 13.3px; font-weight: 650; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task.done .body b { text-decoration: line-through; color: var(--dim); }
.task .links { display: flex; gap: 10px; font-size: 11.5px; color: var(--dim); flex-wrap: wrap; margin-top: 2px; }
.task .links span { display: inline-flex; align-items: center; gap: 4px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task .links svg.i { width: 12px; height: 12px; }
.task .links .ch-ico { width: 14px; height: 14px; font-size: 7px; }
.task .links .res { color: var(--green); }
.task .due { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.task .due svg.i { width: 13px; height: 13px; }
.task.late .due { color: var(--red); font-weight: 700; }
.tgroup.mini .task { padding: 7px 9px; background: var(--bg); }
.tgroup.mini .task .avatar, .tgroup.mini .task .kind { display: none; }
.dcard .nt { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); min-width: 0; }
.dcard .nt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard .nt svg.i { width: 12px; height: 12px; }
.dcard .nt.late { color: var(--red); font-weight: 650; }
.dcard .nt.none { color: var(--amber); }
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cal-head b { font-size: 16px; text-transform: capitalize; min-width: 150px; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 11px; font-weight: 750; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; padding: 0 6px 4px; }
.cal-day { min-height: 104px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; min-width: 0; }
.cal-day:hover { border-color: var(--line-2); }
.cal-day.other { opacity: .45; }
.cal-day.today { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.cal-day .n { font-size: 12px; font-weight: 750; color: var(--muted); }
.cal-day.today .n { color: var(--green); }
.cal-ev { text-align: left; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: rgba(90, 184, 255, .12); color: #cfe9ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev.late { background: rgba(255, 107, 107, .14); color: #ffd0d0; }
.cal-ev.done { background: rgba(255, 255, 255, .05); color: var(--dim); text-decoration: line-through; }
@media (max-width: 860px) {
  .task .avatar { display: none; }
  .task { flex-wrap: wrap; }
  .task .body { flex-basis: calc(100% - 70px); }
  .task .due { margin-left: 32px; }
  .cal-day { min-height: 64px; padding: 4px; }
  .cal-ev { font-size: 0; padding: 0; height: 6px; border-radius: 3px; }
  .bell { width: 34px; height: 34px; }
}


/* ---------- Analytics ---------- */
.toolbar .seg button { flex-direction: row; padding: 6px 10px; white-space: nowrap; }
.an-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 14px; }
.an-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.an-grid .span2 { grid-column: span 2; }
.delta { font-size: 11.5px; font-weight: 700; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--dim); font-weight: 600; }
svg.viz { width: 100%; height: auto; display: block; overflow: visible; }
svg.viz .grid { stroke: rgba(160, 230, 196, .08); stroke-width: 1; }
svg.viz .ax { fill: var(--dim); font-size: 10.5px; font-family: inherit; }
svg.viz .hit { fill: transparent; cursor: crosshair; }
svg.viz .hit:hover { fill: rgba(255, 255, 255, .04); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -2px 0 10px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .viz-tip .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.viz-tip .sw { margin-right: 6px; vertical-align: -1px; }
.viz-tip { position: fixed; z-index: 70; pointer-events: none; background: #0a1a13; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.55; box-shadow: var(--shadow); max-width: 260px; }
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hb { display: grid; grid-template-columns: minmax(70px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hb-l { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.hb-track { height: 10px; background: rgba(255, 255, 255, .04); border-radius: 4px; overflow: hidden; }
.hb-bar { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hb b { font-weight: 750; white-space: nowrap; }
.hb b small { color: var(--dim); font-weight: 600; }
.heat { display: grid; grid-template-columns: 26px repeat(24, minmax(0, 1fr)); gap: 3px; }
.heat .hh { font-size: 9.5px; color: var(--dim); text-align: left; }
.heat .hd { font-size: 11px; color: var(--muted); align-self: center; }
.heat .hc { aspect-ratio: 1 / 1; border-radius: 3px; min-height: 10px; }
.heat .hc:hover { outline: 2px solid var(--text); outline-offset: -1px; }
.heat-scale { display: flex; align-items: center; gap: 3px; margin-top: 10px; font-size: 11px; color: var(--dim); }
.heat-scale i { width: 18px; height: 8px; border-radius: 2px; }
.heat-scale span { margin: 0 4px; }
.card .big { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.card .big.amber { color: var(--amber); }
.red { color: var(--red); }
p.red svg.i, p.dim svg.i { width: 14px; height: 14px; vertical-align: -2px; }
@media (max-width: 1280px) { .an-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .an-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .an-grid .span2 { grid-column: span 2; } }
@media (max-width: 860px) { .an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .an-grid { grid-template-columns: 1fr; } .an-grid .span2 { grid-column: auto; } #an-seg { overflow-x: auto; max-width: 100%; } }


/* ---------- Automation, broadcasts, AI ---------- */
.modal.wide { width: min(720px, calc(100% - 32px)); }
.recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.recipe { display: flex; gap: 8px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px dashed rgba(0, 217, 120, .4); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.recipe:hover { background: var(--green-soft); color: var(--text); }
.recipe svg.i { color: var(--green); }
.rules { display: flex; flex-direction: column; gap: 8px; }
.rule { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.rule:hover { border-color: var(--line-2); }
.rule.off { opacity: .55; }
.rule-top { display: flex; align-items: center; gap: 10px; }
.rule-flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rule-flow .chip { font-size: 12px; padding: 3px 9px; }
.rule-flow .chip.when { background: var(--green-soft); color: var(--green); }
.rule-flow .chip svg.i { width: 13px; height: 13px; }
.rule-flow .arrow { color: var(--dim); }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--panel-3); border: 1px solid var(--line-2); transition: background .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + span { background: var(--green); border-color: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); background: var(--on-green); }
.act-list { display: flex; flex-direction: column; gap: 6px; }
.act { display: grid; grid-template-columns: 180px 1fr 30px; gap: 6px; align-items: center; }
.act-f { display: flex; gap: 6px; min-width: 0; }
.act-f .input, .act-f .select, .act .select { padding: 7px 9px; font-size: 12.5px; }
.act-f input[type=number] { width: 80px; flex: none; }
.prog { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, .06); overflow: hidden; margin-bottom: 3px; }
.prog span { display: block; height: 100%; background: var(--green); border-radius: 0 4px 4px 0; transition: width .3s; }
.prog.big { height: 10px; }
.st-draft { color: var(--muted); background: rgba(255, 255, 255, .06); }
.st-sending, .st-pending { color: var(--amber); background: rgba(255, 181, 71, .12); }
.st-done, .st-sent { color: var(--green); background: var(--green-soft); }
.st-cancelled, .st-skipped { color: var(--dim); background: rgba(255, 255, 255, .05); }
.st-failed { color: var(--red); background: rgba(255, 107, 107, .12); }
.ai-card { border-color: rgba(0, 217, 120, .25); background: linear-gradient(160deg, rgba(0, 217, 120, .07), transparent 60%), var(--panel); }
.chip.mood-positive { color: var(--green); }
.chip.mood-negative { color: var(--red); }
@media (max-width: 860px) { .act { grid-template-columns: 1fr 30px; } .act .act-f { grid-column: 1 / -1; flex-wrap: wrap; } }


/* ---------- Connections ---------- */
.conns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.conn { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.conn h4 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.conn h4 small { color: var(--dim); font-weight: 600; font-size: 11.5px; }
.conn .steps { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.conn code { font-size: 11px; color: var(--green); word-break: break-all; }
.conn .qr { display: grid; place-items: center; }
.conn .qr:empty { display: none; }
.conn .qr img, .conn .qr svg { width: 220px; height: 220px; background: #fff; border-radius: 12px; padding: 8px; }
.conn .qr svg path { fill: #000; }
.conn-ok { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 700; font-size: 13px; }
.conn-ok.off { color: var(--dim); }
.conn .btn { align-self: flex-start; }
@media (max-width: 1100px) { .conns { grid-template-columns: 1fr; } }


/* ---------- WhatsApp call button ---------- */
.btn.wa-call { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn.wa-call:hover { background: #25c164; }
.btn.tel-call { color: var(--green); border-color: rgba(0, 217, 120, .45); }
.btn.tel-call:hover { background: var(--green-soft); }
@media (max-width: 860px) { .thread-head .btn.wa-call, .thread-head .btn.tel-call { padding: 5px 8px; } }

/* ---------- Voice recording ---------- */
.rec { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 6px; min-height: 38px; }
.rec b { font-variant-numeric: tabular-nums; font-size: 14px; }
.rec .btn:last-child { margin-left: auto; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: recblink 1s infinite; }
@keyframes recblink { 50% { opacity: .25; } }

/* ---------- Message media ---------- */
.bubble.has-media { padding: 6px 6px 5px; }
.bubble .voice { display: flex; align-items: center; gap: 6px; min-width: 240px; }
.bubble .voice > svg.i { color: var(--green); flex: none; margin-left: 4px; }
.bubble .voice audio { height: 36px; flex: 1; min-width: 180px; max-width: 320px; }
.bubble .voice .dl { color: var(--muted); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; }
.bubble .voice .dl:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.bubble .m-img { display: block; max-width: min(320px, 100%); max-height: 360px; border-radius: 10px; object-fit: cover; background: rgba(255, 255, 255, .05); }
.bubble .m-img.sticker { max-width: 160px; background: none; }
.bubble .m-video { display: block; max-width: min(360px, 100%); max-height: 360px; border-radius: 10px; background: #000; }
.bubble .m-file { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; color: var(--green); font-weight: 650; }
.bubble .m-cap { padding: 6px 6px 0; }
.media-lost { color: var(--muted); display: inline-flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.media-lost small { color: var(--dim); }
.media-lost svg.i { width: 14px; height: 14px; }
@media (max-width: 860px) { .bubble .voice { min-width: 0; } .bubble .voice audio { min-width: 140px; } }

/* ---------- Responsive ---------- */
.back-btn { display: none !important; }
@media (max-width: 1280px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox .details { display: none; }
  .inbox { position: relative; }
  .inbox.show-details .details { display: flex; position: absolute; right: 0; top: 0; bottom: 0; width: min(340px, 100%); z-index: 6; box-shadow: var(--shadow); }
}
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .crm { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .crm.rail-open .rail { transform: none; box-shadow: var(--shadow); }
  .burger { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); }
  .topbar { padding: 0 14px; }
  .topbar .sub, .top-end .pill { display: none; }
  .inbox, .inbox.show-details { grid-template-columns: 1fr; }
  .inbox .thread, .inbox .details { display: none; }
  .inbox.has-chat .convos { display: none; }
  .inbox.has-chat .thread { display: flex; }
  .inbox.has-chat.show-details .thread { display: none; }
  .inbox.has-chat.show-details .details { display: flex; position: static; width: auto; box-shadow: none; }
  .back-btn { display: grid !important; }
  .page { padding: 14px 16px 24px; }
  .grid2 { grid-template-columns: 1fr; }
  table.t .hide-m { display: none; }
  .bubble { max-width: 86%; }
  .thread-head { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .thread-head .who { flex: 1 1 calc(100% - 50px); }
  .thread-head .acts { flex: 1 1 100%; overflow-x: auto; }
  .thread-head .acts .select { flex: 1; min-width: 0; }
  .comp-hint { display: none; }
  .ai-btn span { display: none; }
  .messages { padding: 14px 12px; }
  .banner { flex-direction: column; align-items: flex-start; }
}
