/* ── AnswerBack dashboard ─────────────────────────────────────────────── */
:root {
  --bg: #0a0f1c;
  --bg-soft: #0e1526;
  --card: #111a2e;
  --card-2: #16213a;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e6edf7;
  --text-dim: #8b9ab5;
  --text-faint: #5b6a85;
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --accent-2: #34d399;
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(2, 6, 17, 0.55);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(16, 185, 129, 0.09), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(59, 130, 246, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 22px 60px; }

/* ── Header ───────────────────────────────────────────────────────────── */
header.top {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 0 22px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #059669 60%, #047857);
  display: grid; place-items: center;
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.35);
}
.brand h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.brand h1 span { color: var(--accent-2); }
.brand .tag { font-size: 12.5px; color: var(--text-dim); margin-top: 1px; }

.pills { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text-dim); display: flex; align-items: center; gap: 7px;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.pill.ok .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.pill.warn .dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

/* ── Stats row ────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .label { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-size: 30px; font-weight: 750; letter-spacing: -0.03em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value.money { color: var(--accent-2); }
.stat .sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

/* ── Layout grid ──────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card .head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card .head h2 { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; }
.card .head .count {
  font-size: 11.5px; font-weight: 700; color: var(--accent-2);
  background: var(--accent-soft); padding: 2px 9px; border-radius: 999px;
}
.card .head .spacer { margin-left: auto; }
.card .body { padding: 0; }

.btn {
  font: inherit; font-size: 13px; font-weight: 650; color: var(--text);
  background: var(--card-2); border: 1px solid var(--border-strong);
  padding: 7px 14px; border-radius: 10px; cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent-2); }
.btn.primary {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: transparent; color: #04110b;
}
.btn.primary:hover { filter: brightness(1.1); color: #04110b; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { color: var(--red); }

/* ── Slim, quiet scrollbars everywhere — never chunky ─────────────────── */
* { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, 0.22) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.22); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.45); }

/* ── Conversations ────────────────────────────────────────────────────── */
.conv-split { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 300px; }
.conv-list { border-right: 1px solid var(--border); max-height: min(620px, calc(100vh - 300px)); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; min-width: 0; }
html[dir="rtl"] .conv-list { border-right: none; border-left: 1px solid var(--border); }
.conv-item {
  padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.12s; min-width: 0;
}
.conv-item:hover { background: var(--card-2); }
.conv-item.active { background: var(--accent-soft); border-left: 3px solid var(--accent); padding-left: 11px; }
html[dir="rtl"] .conv-item.active { border-left: none; border-right: 3px solid var(--accent); padding-left: 14px; padding-right: 11px; }
/* Mixed Hebrew/English/phone-number content: isolate each line's direction so bidi
   never reorders or overflows it, and ellipsize instead of spilling out of the card. */
.conv-item .phone { font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 7px; min-width: 0; }
.conv-item .phone .num { direction: ltr; unicode-bidi: isolate; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.conv-item .phone .ch { flex: none; font-size: 9.5px; font-weight: 700; letter-spacing: .03em; color: var(--accent-2); background: var(--accent-soft); padding: 1px 6px; border-radius: 999px; text-transform: uppercase; }
html[dir="rtl"] .conv-item .phone { flex-direction: row-reverse; justify-content: flex-end; }
.conv-item .preview { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; unicode-bidi: plaintext; }
.conv-item .meta { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; unicode-bidi: plaintext; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thread-col { display: flex; flex-direction: column; min-width: 0; }
.thread { max-height: min(540px, calc(100vh - 360px)); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.thread-foot { border-top: 1px solid var(--border); padding: 11px 14px; display: flex; flex-direction: column; gap: 9px; }
.tf-status { font-size: 12px; color: var(--text-dim); }
.tf-status b { color: var(--accent-2); }
.tf-status.human b { color: var(--amber); }
.tf-input { display: flex; gap: 8px; }
.tf-input input { flex: 1; font: inherit; font-size: 13px; color: var(--text); background: var(--card-2); border: 1px solid var(--border-strong); border-radius: 9px; padding: 8px 12px; outline: none; }
.tf-input input:focus { border-color: var(--accent); }
.tf-input button { width: 38px; border: none; border-radius: 9px; background: var(--accent); color: #04130c; font-size: 15px; font-weight: 800; cursor: pointer; }
.tf-input button:disabled { opacity: .4; cursor: default; }
.thread .empty, .conv-list .empty, .leads .empty {
  color: var(--text-faint); font-size: 13px; padding: 30px 20px; text-align: center;
}

.bubble {
  max-width: 78%; padding: 9px 13px; border-radius: 16px;
  font-size: 13.5px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
  unicode-bidi: plaintext; /* each bubble follows its own text's direction (HE vs EN vs RU) */
}
.bubble.ai { align-self: flex-start; background: var(--card-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.bubble.caller { align-self: flex-end; background: linear-gradient(135deg, #0d9668, #059669); color: #eafff6; border-bottom-right-radius: 5px; }
html[dir="rtl"] .bubble.ai { align-self: flex-end; border-radius: 16px; border-bottom-right-radius: 5px; }
html[dir="rtl"] .bubble.caller { align-self: flex-start; border-radius: 16px; border-bottom-left-radius: 5px; }
.bubble .who { display: block; font-size: 10px; font-weight: 700; opacity: 0.65; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.bubble .atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.bubble .att { display: block; line-height: 0; }
.bubble .att img { max-width: 160px; max-height: 200px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.18); object-fit: cover; cursor: zoom-in; }

/* ── Leads table ──────────────────────────────────────────────────────── */
.leads table { width: 100%; border-collapse: collapse; font-size: 13px; }
.leads th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-faint);
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.leads td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.leads tr:last-child td { border-bottom: none; }
.leads .badge {
  font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.badge.new { background: rgba(59, 130, 246, 0.15); color: #7cb1ff; }
.badge.notified { background: var(--accent-soft); color: var(--accent-2); }
.badge.emergency { background: rgba(239, 68, 68, 0.15); color: #ff8a8a; }

/* ── Phone simulator ──────────────────────────────────────────────────── */
.sim-card { position: sticky; top: 16px; }
.sim-blurb { padding: 12px 18px 4px; font-size: 12.5px; color: var(--text-dim); }

.phone {
  width: 320px; margin: 14px auto 20px;
  background: #05070d; border-radius: 44px; padding: 10px;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), inset 0 0 0 2px #1a2336;
}
.screen {
  background: linear-gradient(180deg, #0b1120, #090e1a);
  border-radius: 36px; height: 560px; position: relative;
  display: flex; flex-direction: column; overflow: hidden;
}
.notch {
  width: 110px; height: 26px; background: #05070d; border-radius: 999px;
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5;
}
.statusbar {
  display: flex; justify-content: space-between; padding: 14px 24px 4px;
  font-size: 12px; font-weight: 650; color: var(--text-dim);
}

/* idle / call states */
.sim-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.sim-stage .avatar {
  width: 84px; height: 84px; border-radius: 50%;
  background: linear-gradient(135deg, #1e3a5f, #14532d);
  display: grid; place-items: center; font-size: 34px;
}
.sim-stage.ringing .avatar { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
  50% { box-shadow: 0 0 0 22px rgba(16, 185, 129, 0); }
}
.sim-stage .biz-name { font-size: 19px; font-weight: 700; }
.sim-stage .call-status { font-size: 13px; color: var(--text-dim); }
.sim-stage .call-status.missed { color: var(--amber); font-weight: 650; }

/* sms thread inside phone */
.sms-head {
  padding: 8px 16px 10px; text-align: center; border-bottom: 1px solid var(--border);
}
.sms-head .name { font-size: 13px; font-weight: 700; }
.sms-head .num { font-size: 10.5px; color: var(--text-faint); }
.sms-thread { flex: 1; overflow-y: auto; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 7px; }
.sms-thread .bubble { font-size: 13px; }
.sms-thread .sysnote { text-align: center; font-size: 10.5px; color: var(--text-faint); padding: 4px 0; }

.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 70%, 100% { opacity: 0.25; } 35% { opacity: 1; } }

.sms-input { display: flex; gap: 8px; padding: 10px 12px 14px; border-top: 1px solid var(--border); }
.sms-input input {
  flex: 1; font: inherit; font-size: 13.5px; color: var(--text);
  background: var(--card-2); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 9px 15px; outline: none;
}
.sms-input input:focus { border-color: var(--accent); }
.sms-input button {
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #04110b; font-size: 16px; font-weight: 800;
  display: grid; place-items: center;
}
.sms-input button:disabled { opacity: 0.4; cursor: default; }

/* lead progress under phone */
.lead-live { padding: 0 18px 16px; }
.lead-live h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 8px; }
.lead-live .row { display: flex; align-items: center; gap: 9px; font-size: 13px; padding: 4px 0; color: var(--text-faint); }
.lead-live .row.got { color: var(--text); }
.lead-live .tick { width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; font-size: 10px; flex: none; }
.lead-live .row.got .tick { background: var(--accent); border-color: var(--accent); color: #04110b; font-weight: 800; }

/* owner alert toast */
.owner-toast {
  position: fixed; right: 24px; bottom: 24px; width: 330px; z-index: 60;
  background: linear-gradient(180deg, #1c2438, #141c30);
  border: 1px solid var(--amber); border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: all 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.owner-toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.owner-toast .ot-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--amber); margin-bottom: 6px; }
.owner-toast .ot-body { font-size: 13px; line-height: 1.5; }

/* token gate */
.gate {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(5, 8, 15, 0.85); backdrop-filter: blur(6px);
  place-items: center;
}
.gate.show { display: grid; }
.gate .box {
  width: 360px; background: var(--card); border: 1px solid var(--border-strong);
  border-radius: 18px; padding: 26px; text-align: center;
}
.gate h2 { font-size: 17px; margin-bottom: 6px; }
.gate p { font-size: 13px; color: var(--text-dim); margin-bottom: 16px; }
.gate input {
  width: 100%; font: inherit; color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 12px; outline: none;
}
.gate input:focus { border-color: var(--accent); }

footer { text-align: center; margin-top: 34px; font-size: 12px; color: var(--text-faint); }

/* setup hint card */
.setup { padding: 14px 18px; font-size: 12.5px; color: var(--text-dim); line-height: 1.7; }
.setup code {
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 6px; font-size: 11.5px; color: var(--accent-2);
  word-break: break-all;
}

@media (max-width: 1080px) {
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .sim-card { position: static; }
}

/* ── Business switcher + modal ────────────────────────────────────────── */
.biz-select {
  font: inherit; font-size: 13px; font-weight: 650; color: var(--text);
  background: var(--card-2); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 7px 10px; cursor: pointer; outline: none;
  max-width: 220px;
}
.biz-select:focus { border-color: var(--accent); }

.gate .box.biz-box { width: 480px; max-width: calc(100vw - 32px); text-align: left; max-height: 90vh; overflow-y: auto; position: relative; }
.biz-x-wrap { position: sticky; top: 0; height: 0; z-index: 5; text-align: right; }
.modal-x {
  position: relative; top: 2px; width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--card-2); color: var(--text-dim);
  font-size: 15px; line-height: 1; cursor: pointer; transition: all .15s ease;
}
.modal-x:hover { border-color: var(--red); color: var(--red); }
.biz-box h2, .biz-box > p { text-align: center; }
.biz-box form label {
  display: block; font-size: 11.5px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px;
}
.biz-box form input:not([type=checkbox]), .biz-box form textarea, .biz-box form select {
  display: block; width: 100%; font: inherit; font-size: 13.5px; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 9px 12px; margin-top: 4px; outline: none; resize: vertical;
}
.biz-box form select { cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px;
}
.biz-box form input:not([type=checkbox]):focus, .biz-box form textarea:focus, .biz-box form select:focus { border-color: var(--accent); }
.biz-box form input:disabled, .biz-box form textarea:disabled, .biz-box form select:disabled { opacity: 0.5; cursor: not-allowed; background: var(--card-2); }
.biz-box .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.biz-box .three { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.biz-box .three > label:first-child { grid-column: 1 / -1; } /* timezone spans full width; opens/closes share the next row */
.hours-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.hours-title { font-size: 11.5px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.chk { display: flex !important; align-items: center; gap: 7px; margin: 0 !important;
  text-transform: none !important; letter-spacing: normal !important; font-size: 12.5px !important;
  color: var(--text) !important; cursor: pointer; user-select: none; white-space: nowrap; }
.chk input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; flex: none; }
.is-off { opacity: 0.4; pointer-events: none; }
.days { display: flex; gap: 6px; margin-top: 6px; }
.days button {
  flex: 1; padding: 9px 0; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg-soft);
  color: var(--text-dim); font: inherit; font-weight: 700; font-size: 12.5px;
  transition: all .12s ease;
}
.days button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }
.modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.form-err { color: #ff8a8a; font-size: 12.5px; margin-top: 8px; min-height: 16px; }

/* Per-lead manager actions (Book / Delete) */
.lead-act {
  padding: 4px 9px; margin-left: 5px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg-soft);
  color: var(--text-dim); font: inherit; font-size: 11.5px; font-weight: 600;
  transition: all .12s ease;
}
.lead-act.book:hover { border-color: var(--accent); color: var(--accent-2); }
.lead-act.del:hover { border-color: var(--red); color: var(--red); }
