:root {
  --bg: #f4f2ee;
  --ink: #16181d;
  --muted: #6b7079;
  --line: #e6e3dd;
  --card: #ffffff;
  --accent: #00a884;
  --accent-soft: #e3f6ef;
  --warn: #c2410c;
  --wa-bg: #efeae2;
  --wa-out: #d9fdd3;
  --wa-in: #ffffff;
  --wa-head: #f6f6f6;
  --tick: #53bdeb;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Rubik, "Noto Sans Hebrew", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

/* ---------- layout: half phone, half CRM ---------- */
.app { display: grid; grid-template-columns: 1fr 1fr; height: 100dvh; }
.tabs { display: none; }

.stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: 28px 24px; overflow: hidden;
  background: radial-gradient(120% 80% at 20% 0%, #ffffff 0%, var(--bg) 55%), var(--bg);
  border-inline-end: 1px solid var(--line);
}
.stage-copy { max-width: 420px; text-align: center; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.stage-copy h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.15; letter-spacing: -.01em; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- iPhone ---------- */
.iphone {
  --h: min(720px, calc(100dvh - 190px));
  position: relative; height: var(--h); aspect-ratio: 9 / 19.2;
  padding: 11px; border-radius: 56px;
  background: linear-gradient(145deg, #2b2d31, #0d0e10);
  box-shadow: 0 0 0 2px #45474c inset, 0 30px 60px -20px rgba(20, 20, 30, .45), 0 10px 20px -10px rgba(20, 20, 30, .3);
  flex-shrink: 0;
}
.island { position: absolute; top: 22px; left: 50%; transform: translateX(-50%); width: 31%; height: 30px; border-radius: 20px; background: #000; z-index: 3; }
.screen { position: relative; height: 100%; border-radius: 46px; overflow: hidden; background: var(--wa-bg); display: flex; flex-direction: column; }

.statusbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 30px 6px; background: var(--wa-head); font-size: 15px; font-weight: 600; direction: ltr; }
.sb-icons { display: flex; gap: 6px; align-items: center; }
.sb-icons svg { height: 11px; fill: currentColor; }

.wa-head { display: flex; align-items: center; gap: 9px; padding: 6px 14px 9px; background: var(--wa-head); border-bottom: 1px solid #e2e2e2; }
.back { width: 11px; color: #0a7cff; flex-shrink: 0; }
[dir="rtl"] .back { transform: scaleX(-1); }
.avatar { position: relative; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; overflow: hidden; flex-shrink: 0; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 4px; }
.who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.who b { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { font-size: 12px; color: var(--muted); }
.hicon { width: 23px; color: #0a7cff; flex-shrink: 0; }

.wa-body {
  flex: 1; overflow-y: auto; padding: 10px 10px 6px; display: flex; flex-direction: column; gap: 3px;
  background-color: var(--wa-bg);
  background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1.2px);
  background-size: 14px 14px;
  scrollbar-width: none;
}
.wa-body::-webkit-scrollbar { display: none; }
.day-chip { align-self: center; background: #fff; color: #54656f; font-size: 12px; padding: 4px 10px; border-radius: 8px; margin: 2px 0 6px; box-shadow: 0 1px .5px rgba(0,0,0,.08); }
.e2e { align-self: center; max-width: 88%; text-align: center; background: #fdf4c5; color: #54656f; font-size: 11.5px; padding: 6px 10px; border-radius: 8px; margin-bottom: 8px; }

.msg { unicode-bidi: plaintext; position: relative; max-width: 80%; padding: 6px 9px 7px; border-radius: 9px; font-size: 14.5px; line-height: 1.35; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px .5px rgba(0,0,0,.1); animation: pop .18s ease-out; }
.msg.in { align-self: flex-start; background: var(--wa-in); border-start-start-radius: 2px; }
.msg.out { align-self: flex-end; background: var(--wa-out); border-start-end-radius: 2px; }
.msg + .msg.in:not(.first), .msg + .msg.out:not(.first) { border-radius: 9px; }
.msg.first { margin-top: 6px; }
.meta { float: inline-end; display: inline-flex; gap: 3px; align-items: center; margin: 6px 0 -4px 10px; margin-inline-start: 10px; font-size: 11px; color: #667781; line-height: 1; }
.ticks { width: 16px; height: 11px; color: #8696a0; }
.ticks.read { color: var(--tick); }
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9aa5ab; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.suggest { display: flex; gap: 6px; padding: 6px 10px 2px; overflow-x: auto; scrollbar-width: none; background: var(--wa-bg); }
.suggest::-webkit-scrollbar { display: none; }
.suggest button { flex-shrink: 0; border: 1px solid #cfe9df; background: #fff; color: #087f64; border-radius: 16px; padding: 5px 11px; font-size: 13px; }
.suggest button:hover { background: var(--accent-soft); }

.wa-input { display: flex; align-items: center; gap: 8px; padding: 7px 10px 6px; background: var(--wa-head); border-top: 1px solid #e2e2e2; }
.plus { width: 24px; color: #0a7cff; flex-shrink: 0; }
.wa-input input { flex: 1; min-width: 0; border: 1px solid #ddd; border-radius: 18px; padding: 8px 13px; font: 15px var(--font); outline: none; background: #fff; }
.wa-input input:focus { border-color: #b9dccf; }
.send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.send svg { width: 18px; }
[dir="rtl"] .send svg { transform: scaleX(-1); }
.send:disabled { opacity: .5; cursor: default; }
.home-bar { height: 22px; background: var(--wa-head); position: relative; }
.home-bar::after { content: ""; position: absolute; left: 50%; top: 8px; transform: translateX(-50%); width: 36%; height: 5px; border-radius: 3px; background: #111; }

/* ---------- CRM ---------- */
.crm { position: relative; overflow-y: auto; padding: 26px 28px 20px; display: flex; flex-direction: column; gap: 16px; }
.crm-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.crm-title { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.badge { display: inline-block; vertical-align: 3px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 1px 6px; margin-inline-start: 4px; }
.crm-meta { margin: 4px 0 0; color: var(--muted); font-size: 13px; display: flex; gap: 7px; align-items: center; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(0,168,132,.5); animation: ping 2s infinite; }
.ghost { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 9px; padding: 7px 12px; font-size: 13px; white-space: nowrap; }
.ghost:hover { border-color: #cfcac2; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.kpi b { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi b.bump { animation: bump .6s ease; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.muted { color: var(--muted); font-size: 12.5px; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.day { min-height: 230px; border-radius: 10px; background: #faf9f7; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.day.today { background: var(--accent-soft); }
.day.closed { background: repeating-linear-gradient(135deg, #faf9f7 0 6px, #f3f1ed 6px 12px); }
.day h3 { margin: 0 0 3px; font-size: 11.5px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; }
.day.today h3 { color: #087f64; }
.mtg { border-radius: 8px; background: #fff; border: 1px solid var(--line); border-inline-start: 3px solid #b8c4ce; padding: 5px 7px; font-size: 12.5px; line-height: 1.25; min-width: 0; }
.mtg b { display: block; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); font-weight: 600; }
.mtg span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mtg.mine { border-inline-start-color: var(--accent); background: var(--accent-soft); border-color: #bfe8d9; }
.mtg.mine b { color: #087f64; }
.mtg.cancelled { opacity: .55; text-decoration: line-through; border-inline-start-color: var(--warn); }
.mtg.flash { animation: flash 1.6s ease; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.contacts, .feed { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow-y: auto; }
.contacts li { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid #f1efeb; }
.contacts li:last-child, .feed li:last-child { border-bottom: 0; }
.contacts li.mine { background: linear-gradient(90deg, var(--accent-soft), transparent 70%); border-radius: 8px; padding-inline: 6px; }
[dir="rtl"] .contacts li.mine { background: linear-gradient(-90deg, var(--accent-soft), transparent 70%); }
.ava { width: 28px; height: 28px; border-radius: 50%; background: #e9e6e0; color: #57534e; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.mine .ava { background: var(--accent); color: #fff; }
.c-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.c-main b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-main small { color: var(--muted); font-size: 12px; direction: ltr; text-align: start; }
.pill { font-size: 11px; font-weight: 600; border-radius: 20px; padding: 2px 8px; background: #f1efeb; color: #57534e; white-space: nowrap; }
.pill.booked { background: var(--accent-soft); color: #087f64; }
.pill.cancelled { background: #fdeee6; color: var(--warn); }
.pill.lead { background: #eef2ff; color: #4338ca; }
.feed li { display: grid; grid-template-columns: auto 1fr; gap: 2px 9px; padding: 7px 0; border-bottom: 1px solid #f1efeb; font-size: 13px; }
.feed li i { grid-row: span 2; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #b8c4ce; }
.feed li.booked i { background: var(--accent); }
.feed li.cancelled i { background: var(--warn); }
.feed li.rescheduled i { background: #6366f1; }
.feed li small { color: var(--muted); font-size: 11.5px; }
.feed li.fresh { animation: flash 1.6s ease; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 0; }
.powered { margin: auto 0 0; text-align: center; color: #a29e97; font-size: 12px; }

.contacts li { cursor: pointer; border-radius: 8px; }
.contacts li:hover { background: #f7f6f3; }
.mtg[data-cid] { cursor: pointer; }
.mtg[data-cid]:hover { border-color: #cfcac2; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view#viewer { animation: fade .18s ease; }
.back-btn { border: 0; background: none; padding: 4px 2px; display: grid; place-items: center; }
.avatar.seeded { background: #dfe5e7; color: #54656f; font-size: 14px; }
.wa-head .pill { flex-shrink: 0; }
.viewer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; background: var(--wa-head); border-top: 1px solid #e2e2e2; font-size: 12.5px; color: var(--muted); }
.viewer-foot button { border: 0; background: var(--accent); color: #fff; border-radius: 16px; padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.sheet-empty { margin: auto; color: var(--muted); font-size: 13px; }
.contacts li.open { outline: 2px solid var(--accent); outline-offset: -2px; }

.toast { position: fixed; bottom: 22px; inset-inline-end: 24px; max-width: 340px; background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 12px; font-size: 14px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.4); opacity: 0; transform: translateY(10px); transition: .25s ease; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: none; }

.notfound { max-width: 420px; margin: 18vh auto; padding: 0 16px; text-align: center; }
.notfound p { color: var(--muted); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes blink { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
@keyframes ping { 70% { box-shadow: 0 0 0 7px rgba(0,168,132,0); } 100% { box-shadow: 0 0 0 0 rgba(0,168,132,0); } }
@keyframes flash { 0%, 35% { box-shadow: 0 0 0 3px rgba(0,168,132,.45); } 100% { box-shadow: 0 0 0 0 rgba(0,168,132,0); } }
@keyframes bump { 30% { transform: scale(1.18); color: var(--accent); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- smaller screens ---------- */
@media (max-width: 1180px) {
  .cols { grid-template-columns: 1fr; }
  .stage-copy h1 { font-size: 22px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .tabs { display: flex; gap: 4px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: #fff; border-bottom: 1px solid var(--line); }
  .tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px; font-weight: 600; color: var(--muted); position: relative; }
  .tabs button[aria-selected="true"] { background: var(--accent-soft); color: #087f64; }
  .tabs .dot { position: absolute; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-inline-start: 4px; }
  [data-pane] { display: none; }
  .app[data-tab="chat"] [data-pane="chat"], .app[data-tab="crm"] [data-pane="crm"] { display: flex; }
  .stage { padding: 0; gap: 0; border: 0; min-height: 0; }
  .stage-copy, .island, .statusbar, .home-bar { display: none; }
  .iphone { height: 100%; width: 100%; aspect-ratio: auto; padding: 0; border-radius: 0; background: none; box-shadow: none; }
  .screen { border-radius: 0; }
  .wa-input { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .wa-input input { font-size: 16px; }
  .crm { padding: 16px 14px; }
  .kpis { gap: 8px; }
  .kpi { padding: 10px; }
  .kpi b { font-size: 22px; }
  .week { grid-template-columns: repeat(7, 118px); overflow-x: auto; padding-bottom: 4px; }
  .contacts li { cursor: pointer; border-radius: 8px; }
.contacts li:hover { background: #f7f6f3; }
.mtg[data-cid] { cursor: pointer; }
.mtg[data-cid]:hover { border-color: #cfcac2; }

.sheet { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: flex-end; background: rgba(22, 24, 29, .28); animation: fade .15s ease; }
.sheet-card { width: min(440px, 100%); height: 100%; background: #fff; display: flex; flex-direction: column; box-shadow: -20px 0 40px -20px rgba(0,0,0,.3); animation: slide .2s ease-out; }
[dir="rtl"] .sheet-card { animation-name: slide-rtl; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; padding-top: max(16px, env(safe-area-inset-top)); }
.sheet-note { margin: 0; padding: 0 16px 10px; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); }
.x { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f1efeb; color: var(--ink); display: grid; place-items: center; flex-shrink: 0; }
.x svg { width: 18px; }
.sheet-thread { flex: 1; padding: 12px; }
.sheet-thread .msg { animation: none; }
.sheet-empty { margin: auto; color: var(--muted); font-size: 13px; }

.toast { inset-inline: 16px; bottom: 16px; max-width: none; }
}
