/* LeadFlow CRM — design system.
   RTL Hebrew first. Light and dark from one token set. No web fonts, no CDN:
   the app has to work on a laptop with no internet, and a dashboard that waits
   on a font server is a dashboard that flashes blank. */

:root {
  color-scheme: light;

  --bg:            #f4f6fb;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-3:     #eef2f9;
  --line:          #e2e8f2;
  --line-strong:   #cbd5e6;

  --text:          #0f172a;
  --text-2:        #475569;
  --text-3:        #7c8aa3;
  --text-inv:      #ffffff;

  --brand:         #2f6df6;
  --brand-2:       #1d4ed8;
  --brand-soft:    #e8efff;
  --brand-ring:    rgba(47, 109, 246, .28);

  --ok:            #10a05f;
  --ok-soft:       #e2f6ec;
  --warn:          #d98307;
  --warn-soft:     #fdf1de;
  --bad:           #e0453d;
  --bad-soft:      #fdeaea;
  --info:          #7a5af8;
  --info-soft:     #efeaff;

  --grade-a:       #10a05f;
  --grade-b:       #2f6df6;
  --grade-c:       #d98307;
  --grade-d:       #94a3b8;

  --ig:            #e1306c;
  --fb:            #1877f2;
  --wa:            #25d366;
  --gg:            #ea4335;
  --tt:            #111827;

  --radius:        14px;
  --radius-sm:     10px;
  --radius-lg:     20px;
  --shadow-sm:     0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow:        0 4px 14px rgba(15, 23, 42, .08);
  --shadow-lg:     0 18px 48px rgba(15, 23, 42, .18);

  --sidebar-w:     248px;
  --topbar-h:      64px;
  --ease:          cubic-bezier(.22, .61, .36, 1);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #0b1120;
  --surface:       #121a2c;
  --surface-2:     #182236;
  --surface-3:     #1f2b42;
  --line:          #243149;
  --line-strong:   #32415e;

  --text:          #e8eefc;
  --text-2:        #a3b0c9;
  --text-3:        #7686a3;

  --brand-soft:    #17243f;
  --ok-soft:       #10281d;
  --warn-soft:     #2a2010;
  --bad-soft:      #2c1618;
  --info-soft:     #1d1836;

  --shadow-sm:     0 1px 2px rgba(0, 0, 0, .4);
  --shadow:        0 6px 18px rgba(0, 0, 0, .45);
  --shadow-lg:     0 24px 56px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Rubik", "Assistant", "Noto Sans Hebrew", system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  direction: rtl;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Numbers, ids, phones and money read left-to-right even inside Hebrew text.
   Without this a phone number renders with its country code on the wrong end. */
.ltr, .num, .mono {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: right;
}
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 20px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ layout */
#app { min-height: 100%; }

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--info));
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 2px 8px var(--brand-ring);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.02em; }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: -3px; }

.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-group { margin-bottom: 14px; }
.nav-label {
  font-size: 10.5px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer; font-weight: 500;
  transition: background .14s var(--ease), color .14s var(--ease);
  user-select: none;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-2); font-weight: 650; }
[data-theme="dark"] .nav-item.active { color: #9dbcff; }
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item .pill {
  margin-inline-start: auto; font-size: 11px; font-weight: 700;
  background: var(--bad); color: #fff; border-radius: 20px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.nav-item .pill.quiet { background: var(--surface-3); color: var(--text-2); }

.sidebar-foot { padding: 10px; border-top: 1px solid var(--line); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); cursor: pointer;
}
.user-chip:hover { background: var(--surface-3); }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 18px; }
.topbar-spacer { flex: 1; }

.search {
  position: relative; width: min(420px, 38vw);
}
.search input {
  width: 100%; padding: 9px 36px 9px 12px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px;
}
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.search .ico { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }

.content { padding: 22px; flex: 1; min-width: 0; }
.content.flush { padding: 0; }

/* ----------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .14s var(--ease), border-color .14s var(--ease), transform .08s var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--bad); border-color: var(--line-strong); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.icon { padding: 8px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="datetime-local"], select, textarea {
  width: 100%; padding: 9px 11px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}
select { cursor: pointer; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong);
  position: relative; transition: background .18s var(--ease);
}
/* THE KNOB IS POSITIONED PHYSICALLY, ON PURPOSE.
 *
 * It used to sit at `inset-inline-end` - a LOGICAL property, so on this
 * right-to-left page it started on the LEFT - and then moved with
 * `translateX(-16px)`, which is PHYSICAL and moved it further left, straight
 * off the end of the track. The switch looked empty when it was on.
 *
 * Mixing the two is the whole bug. A toggle is a physical object: the knob
 * slides from left to right as it turns on, in every language. So both the
 * resting position and the travel are physical, and the control behaves
 * identically whichever direction the page runs in. */
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .18s var(--ease); box-shadow: var(--shadow-sm);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }

/* -------------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { margin-inline-end: auto; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1200px) { .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .grid.k2, .grid.k3, .grid.k4 { grid-template-columns: minmax(0, 1fr); } }

.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.kpi .value { font-size: 27px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi .meta { font-size: 12px; color: var(--text-3); }
.kpi .delta { font-size: 12px; font-weight: 650; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--bad); }

/* ------------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; line-height: 1.7;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge.ok   { background: var(--ok-soft);   color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad  { background: var(--bad-soft);  color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand{ background: var(--brand-soft);color: var(--brand-2); }
[data-theme="dark"] .badge.brand { color: #9dbcff; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.grade {
  width: 24px; height: 24px; border-radius: 7px;
  display: inline-grid; place-items: center;
  font-weight: 800; font-size: 12px; color: #fff; flex-shrink: 0;
}
.grade.A { background: var(--grade-a); }
.grade.B { background: var(--grade-b); }
.grade.C { background: var(--grade-c); }
.grade.D { background: var(--grade-d); }

.chan {
  width: 20px; height: 20px; border-radius: 6px;
  display: inline-grid; place-items: center; flex-shrink: 0;
  color: #fff; font-size: 11px; font-weight: 700;
}
.chan.instagram { background: linear-gradient(135deg, #f9ce34, #ee2a7b, #6228d7); }
.chan.facebook  { background: var(--fb); }
.chan.whatsapp  { background: var(--wa); }
.chan.google    { background: var(--gg); }
.chan.tiktok    { background: var(--tt); }
.chan.website, .chan.landing { background: #0ea5e9; }
.chan.phone     { background: #64748b; }
.chan.manual, .chan.referral { background: #94a3b8; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-grid; place-items: center;
  color: #fff; font-size: 11.5px; font-weight: 700; flex-shrink: 0;
}
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }

/* ------------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: start; font-size: 11.5px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr { cursor: pointer; transition: background .1s var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--text-3); }

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.toolbar select, .toolbar input { width: auto; min-width: 130px; padding: 6px 10px; font-size: 12.5px; }

.empty {
  padding: 54px 20px; text-align: center; color: var(--text-3);
}
.empty .big { font-size: 34px; margin-bottom: 8px; opacity: .6; }
.empty h3 { color: var(--text-2); margin-bottom: 4px; }

/* ------------------------------------------------------------------- kanban */
.board {
  display: flex; gap: 14px; padding: 18px 22px; overflow-x: auto;
  align-items: flex-start; min-height: calc(100vh - var(--topbar-h));
}
.column {
  width: 300px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column;
  max-height: calc(100vh - var(--topbar-h) - 36px);
}
.column-head {
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.column-head .swatch { width: 9px; height: 9px; border-radius: 3px; }
.column-head .name { font-weight: 650; font-size: 13.5px; }
.column-head .count {
  margin-inline-start: auto; font-size: 11.5px; font-weight: 700;
  background: var(--surface-3); color: var(--text-2); padding: 1px 8px; border-radius: 999px;
}
.column-sum { padding: 6px 14px; font-size: 11.5px; color: var(--text-3); border-bottom: 1px solid var(--line); }
.column-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; flex: 1; min-height: 80px; }
.column.drop-target { outline: 2px dashed var(--brand); outline-offset: -4px; background: var(--brand-soft); }

.lead-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 12px;
  cursor: grab; box-shadow: var(--shadow-sm);
  transition: box-shadow .14s var(--ease), transform .08s var(--ease);
}
.lead-card:hover { box-shadow: var(--shadow); }
.lead-card.dragging { opacity: .45; transform: rotate(1.5deg); }
.lead-card .row { display: flex; align-items: center; gap: 7px; }
.lead-card .title { font-weight: 650; font-size: 13px; margin-inline-end: auto; }
.lead-card .sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.lead-card .foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; flex-wrap: wrap; }

/* -------------------------------------------------------------------- drawer */
.scrim {
  position: fixed; inset: 0; background: rgba(8, 15, 30, .46);
  z-index: 90; opacity: 0; animation: fade .16s var(--ease) forwards;
  backdrop-filter: blur(2px);
}
@keyframes fade { to { opacity: 1; } }

/* SLIDING PANELS AND THE DIRECTION TRAP.
 *
 * `inset-inline-start` is logical - it means the RIGHT edge on this page and the
 * left edge on an English one. `translateX` is physical and means left in both.
 * Combining them without thinking gives a panel that slides in from the wrong
 * side: the drawer used to START at left:-496 - already half on screen, over the
 * content - and then jump across to the right edge where it belongs.
 *
 * The off-screen direction is a variable, flipped once for RTL, so both panels
 * are correct in either language instead of one being written for each. */
:root { --panel-hidden: -100%; }
[dir="rtl"] { --panel-hidden: 100%; }

.drawer {
  position: fixed; inset-block: 0; inset-inline-start: 0;
  width: min(760px, 96vw); background: var(--bg);
  z-index: 91; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(var(--panel-hidden)); animation: slidein .24s var(--ease) forwards;
}
@keyframes slidein { to { transform: translateX(0); } }
.drawer-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: flex-start; gap: 12px;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
/* A flex column shrinks its children by default. Any panel with overflow:hidden
   — the AI panel — then collapses to a sliver instead of pushing the scroll
   height up. Nothing inside a scrolling column should shrink. */
.drawer-body > * { flex-shrink: 0; }
.drawer-foot {
  padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface);
  display: flex; gap: 8px; flex-wrap: wrap;
}

.modal-scrim {
  position: fixed; inset: 0; background: rgba(8, 15, 30, .5); z-index: 100;
  display: grid; place-items: center; padding: 20px;
  opacity: 0; animation: fade .14s var(--ease) forwards;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.modal-head { padding: 18px 20px 0; }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 13px; }
.modal-foot { padding: 0 20px 18px; display: flex; gap: 8px; justify-content: flex-start; }

/* ------------------------------------------------------------------ timeline */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 11px 0; }
.tl-rail { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.tl-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px;
  background: var(--surface-3); color: var(--text-2); flex-shrink: 0;
}
.tl-line { width: 2px; flex: 1; background: var(--line); margin-top: 4px; min-height: 8px; }
.tl-item:last-child .tl-line { display: none; }
.tl-body { flex: 1; min-width: 0; padding-bottom: 4px; }
.tl-title { font-weight: 600; font-size: 13px; }
.tl-time { font-size: 11.5px; color: var(--text-3); }
.tl-text { font-size: 13px; color: var(--text-2); margin-top: 3px; white-space: pre-wrap; word-break: break-word; }

/* ------------------------------------------------------------------ AI panel */
.ai-panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--info-soft), var(--surface) 70%);
  padding: 16px; position: relative; overflow: hidden;
}
.ai-panel .ai-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ai-panel .ai-title { font-weight: 700; font-size: 14px; }
.ai-summary { font-size: 13.5px; line-height: 1.65; }
.ai-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.ai-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; }
.ai-stat .k { font-size: 11px; color: var(--text-3); font-weight: 600; }
.ai-stat .v { font-size: 14px; font-weight: 650; margin-top: 1px; }
.ai-reply {
  margin-top: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 12px;
}
.ai-reply .k { font-size: 11px; color: var(--text-3); font-weight: 600; margin-bottom: 5px; }
.ai-reply .t { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }
.degraded-note {
  margin-top: 10px; font-size: 12px; color: var(--warn);
  background: var(--warn-soft); border-radius: var(--radius-sm); padding: 8px 10px;
}

/* --------------------------------------------------------------------- meter */
.meter { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; transition: width .4s var(--ease); }

.score-ring { --v: 0; width: 46px; height: 46px; flex-shrink: 0; position: relative; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .val {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 750;
}

/* --------------------------------------------------------------------- chart */
.chart { width: 100%; }
.chart .bar { transition: height .35s var(--ease), y .35s var(--ease); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }

/* --------------------------------------------------------------------- login
   The first screen: a brand panel beside a glass card on a desktop, stacked on
   a phone. Two accents join the brand blue here and only here - purple and
   turquoise - and every one of these tokens is defined in BOTH themes (the dark
   values are lifted so they stay visible on navy). Every grid track is
   minmax(0, …): a bare fr refuses to shrink below its content (test-ui-css.js).
   The button gradient was measured for AA with white bold text: light
   #1d4ed8 7.1:1 -> #6d28d9 7.1:1, dark #2563eb 5.2:1 -> #7c3aed 5.7:1. */
:root {
  --accent-2:          #7c3aed;
  --accent-3:          #06b6d4;
  --login-bg-a:        #1d4ed8;
  --login-bg-b:        #6d28d9;
  --login-bg-c:        #0891b2;
  --login-btn-a:       #1d4ed8;
  --login-btn-b:       #6d28d9;
  --login-glass:       rgba(255, 255, 255, .88);
  --login-glass-line:  rgba(255, 255, 255, .6);
  --login-hero-text:   #ffffff;
  --login-hero-muted:  rgba(255, 255, 255, .8);
  --login-chip:        rgba(255, 255, 255, .16);
  --login-chip-line:   rgba(255, 255, 255, .3);
}
[data-theme="dark"] {
  --accent-2:          #a78bfa;
  --accent-3:          #22d3ee;
  --login-bg-a:        #0b1120;
  --login-bg-b:        #1e1b4b;
  --login-bg-c:        #083344;
  --login-btn-a:       #2563eb;
  --login-btn-b:       #7c3aed;
  --login-glass:       rgba(18, 26, 44, .84);
  --login-glass-line:  rgba(255, 255, 255, .12);
  --login-hero-text:   #eef2ff;
  --login-hero-muted:  rgba(238, 242, 255, .74);
  --login-chip:        rgba(255, 255, 255, .08);
  --login-chip-line:   rgba(255, 255, 255, .16);
}
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  position: relative; overflow: hidden; isolation: isolate;
  background: linear-gradient(135deg, var(--login-bg-a) 0%, var(--login-bg-b) 55%, var(--login-bg-c) 100%);
  background-size: 200% 200%;
  animation: login-drift 22s ease-in-out infinite alternate;
}
/* Two soft blobs that drift slowly behind everything. z-index -1 inside the
   page's own stacking context puts them under the content, over the gradient. */
.login-page::before, .login-page::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%;
  filter: blur(40px); opacity: .55; pointer-events: none;
}
.login-page::before {
  width: 46vmax; height: 46vmax; inset-inline-start: -12vmax; top: -14vmax;
  background: radial-gradient(circle at 30% 30%, var(--accent-3), transparent 62%);
  animation: login-float 26s ease-in-out infinite alternate;
}
.login-page::after {
  width: 40vmax; height: 40vmax; inset-inline-end: -10vmax; bottom: -16vmax;
  background: radial-gradient(circle at 60% 60%, var(--accent-2), transparent 62%);
  animation: login-float 30s ease-in-out infinite alternate-reverse;
}
@keyframes login-drift { from { background-position: 0% 0%; } to { background-position: 100% 100%; } }
@keyframes login-float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(6vmax, 4vmax, 0) scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .login-page, .login-page::before, .login-page::after { animation: none; }
}
.login-stage {
  width: min(980px, 100%); display: grid; align-items: center; gap: 32px;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}
.login-stage > * { min-width: 0; }
.login-hero { color: var(--login-hero-text); padding: 12px 8px; }
.login-hero .brand-mark {
  width: 64px; height: 64px; border-radius: 18px; font-size: 30px;
  background: linear-gradient(135deg, var(--accent-3), var(--accent-2));
  box-shadow: 0 14px 34px rgba(0, 0, 0, .28);
}
.login-hero h1 {
  margin: 18px 0 6px; font-size: 32px; line-height: 1.15; letter-spacing: -.02em;
  color: var(--login-hero-text); overflow-wrap: anywhere;
}
.login-hero .login-tag {
  margin: 0 0 20px; font-size: 15px; color: var(--login-hero-muted);
  max-width: 46ch; overflow-wrap: anywhere;
}
.login-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.login-chips li {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px;
  background: var(--login-chip); border: 1px solid var(--login-chip-line);
  font-size: 12.5px; font-weight: 600; color: var(--login-hero-text);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); overflow-wrap: anywhere;
}
.login-chips .ico { font-size: 14px; opacity: .95; }
.login-card {
  width: min(440px, 100%); justify-self: center;
  background: var(--login-glass); border: 1px solid var(--login-glass-line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.login-card .card-body { padding: 28px 26px; display: flex; flex-direction: column; gap: 14px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 6px; text-align: center; }
.login-brand .brand-mark { width: 46px; height: 46px; border-radius: 13px; font-size: 22px; }
.login-brand .brand-name { font-size: 18px; }
.login-brand .brand-sub { overflow-wrap: anywhere; }
.login-form { display: flex; flex-direction: column; gap: 13px; }
.btn.login-btn {
  width: 100%; padding: 12px 16px; border: 0; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--login-btn-a), var(--login-btn-b));
  color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 10px 24px rgba(47, 109, 246, .32);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), filter .12s var(--ease);
}
.btn.login-btn:hover { filter: brightness(1.08); box-shadow: 0 12px 28px rgba(47, 109, 246, .42); }
.btn.login-btn:active { transform: translateY(1px); }
.btn.login-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--brand); }
.btn.login-btn:disabled { opacity: .6; cursor: not-allowed; filter: none; }
/* The error lives in the card, next to the fields it is about - not in a
   toast in the far corner that is gone before it is read. */
.login-error {
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bad-soft); color: var(--bad); border: 1px solid rgba(224, 69, 61, .35);
  font-size: 13px; font-weight: 600; overflow-wrap: anywhere;
}
.login-error[hidden] { display: none; }
@media (max-width: 820px) {
  .login-page { padding: 20px 16px; align-content: start; }
  .login-stage { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .login-hero { text-align: center; padding: 6px 4px 0; }
  .login-hero .brand-mark { margin: 0 auto; width: 52px; height: 52px; border-radius: 15px; font-size: 24px; }
  .login-hero h1 { font-size: 24px; margin-top: 12px; }
  .login-hero .login-tag { margin: 0 auto 12px; font-size: 13.5px; }
  .login-chips { justify-content: center; }
  .login-card .card-body { padding: 22px 18px; }
}

/* -------------------------------------------------------------------- toasts */
.toasts {
  position: fixed; inset-block-end: 20px; inset-inline-start: 20px;
  z-index: 200; display: flex; flex-direction: column; gap: 9px;
}
.toast {
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--brand);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 11px 15px; min-width: 260px; max-width: 400px;
  animation: toastin .22s var(--ease);
  font-size: 13px;
}
.toast.ok  { border-inline-start-color: var(--ok); }
.toast.bad { border-inline-start-color: var(--bad); }
.toast .t { font-weight: 650; }
.toast .d { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }

/* --------------------------------------------------------------------- misc */
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sep { height: 1px; background: var(--line); margin: 4px 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 8px 13px; font-size: 13px; font-weight: 600; color: var(--text-2);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* Same variable as the drawer: this one happened to be correct in Hebrew and
     would have slid the menu into the middle of the screen in English. */
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; z-index: 80; transform: translateX(var(--panel-hidden)); transition: transform .22s var(--ease); }
  .sidebar.open { transform: translateX(0); }
  .search { width: 100%; }
  .content { padding: 14px; }
}

/* ============================================================== THE DIALER
   Sized for someone who is on the phone and not looking closely: the number is
   the biggest thing on the screen, and every outcome is a target you can hit
   without aiming. The colour split matters - an agent must never reach for
   "closed the deal" and land on "not interested". */

.dialer-wrap { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .dialer-wrap { grid-template-columns: minmax(0, 1fr); } }

.dialer-now { padding: 20px; }
.dialer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialer-name { font-size: 22px; font-weight: 700; line-height: 1.2; }
.dialer-sub { color: var(--text-2); margin-top: 2px; }

/* The number is a tel: link, so on a phone or a softphone this is the dial. */
.dialer-phone {
  display: block; margin: 14px 0 10px;
  font-size: 30px; font-weight: 700; letter-spacing: .5px;
  color: var(--brand); text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.dialer-phone:hover { color: var(--brand-2); text-decoration: underline; }

.dialer-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }

.dialer-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.dialer-buttons .btn { justify-content: center; padding: 12px 10px; font-weight: 600; }
.dialer-buttons .btn .ico { margin-inline-end: 6px; }

/* Outcome colours. Soft fills rather than solid ones: eight solid buttons in a
   row is a traffic light, not a tool. */
.btn.ok   { background: var(--ok-soft);   border-color: var(--ok);   color: var(--ok); }
.btn.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.btn.bad  { background: var(--bad-soft);  border-color: var(--bad);  color: var(--bad); }
.btn.ok:hover   { background: var(--ok);   color: #fff; }
.btn.warn:hover { background: var(--warn); color: #fff; }
.btn.bad:hover  { background: var(--bad);  color: #fff; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* A tickable package, sized to be hit while holding a phone. The whole label is
   the target, not just the 13px box inside it. */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface-2); cursor: pointer; user-select: none;
  font-size: 13px; line-height: 1;
}
.chip:hover { border-color: var(--brand); }
.chip input { margin: 0; cursor: pointer; }
.chip:has(input:checked) {
  background: var(--brand-soft); border-color: var(--brand); color: var(--brand-2); font-weight: 600;
}

/* ======================================================== PACKAGE CARDS
   A table was the wrong tool here. Seven columns of which two were always
   "—" and one always said the same thing, with a promo price, an ongoing
   price and a duration crammed into a single cell - and an expanding
   calculation that broke the row alignment the moment anybody used it.

   A card holds the same facts in reading order: what it costs today, what it
   costs after, then the small print. The one number an agent says out loud is
   the biggest thing on it. */

.pkg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.pkg {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  display: flex;
  flex-direction: column;
}
.pkg:hover {
  border-color: var(--brand);
  box-shadow: 0 6px 20px rgba(15, 23, 42, .08);
  transform: translateY(-1px);
}

.pkg-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pkg-name { font-weight: 700; font-size: 16px; line-height: 1.25; }
.pkg-cat { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.pkg-flags { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex-shrink: 0; }

.pkg-price { margin-top: 14px; display: flex; align-items: baseline; gap: 6px; }
.pkg-big {
  font-size: 30px; font-weight: 800; color: var(--brand); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pkg-per { color: var(--text-3); font-size: 13px; }
.pkg-then { margin-top: 4px; font-size: 13px; color: var(--text-2); }

.pkg-facts {
  margin-top: 12px; display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-size: 12px; color: var(--text-3);
}
.pkg-facts > span { white-space: nowrap; }
/* A package nobody can earn on is a setup mistake, not a quiet default. */
.pkg-warn { color: var(--warn); font-weight: 600; }

.pkg-foot { margin-top: auto; padding-top: 12px; }
.pkg-foot .annual-out { margin-top: 8px; }
/* The revealed calculation lives inside the card, so it gets room instead of
   being squeezed into a table cell. */
.pkg-foot .annual-out table { font-size: 12px; }
.pkg-foot .annual-out td { padding: 3px 4px; }

/* ================================================== THE FOUR LEAD STATES
   The one thing an agent reads before anything else on a row. Four colours,
   learned once, then never read as words again:

     סגול  חדש          nobody has spoken to them yet
     צהוב  במעקב        spoken to, still open - work to be done
     ירוק  עסקה נסגרה   closed
     אדום  לא נסגר      dead

   Purple gets its own token rather than borrowing --info: --info is the AI
   accent and already carries a meaning on this screen. A colour that means two
   things means neither. */

:root {
  --state-new:       #7c3aed;
  --state-new-soft:  #f1ebfe;
}
[data-theme="dark"] {
  --state-new:       #b69bff;
  --state-new-soft:  #211a3a;
}

.badge.st-new      { background: var(--state-new-soft); color: var(--state-new); font-weight: 700; }
.badge.st-followup { background: var(--warn-soft);      color: var(--warn);      font-weight: 700; }
.badge.st-won      { background: var(--ok-soft);        color: var(--ok);        font-weight: 700; }
.badge.st-lost     { background: var(--bad-soft);       color: var(--bad);       font-weight: 700; }


/* Light-theme badge text, darkened to clear 4.5:1 against the soft fill.
   Measured: followup was 2.61:1 with the shared --warn token, won 3.00:1,
   lost 3.56:1 - all below AA for text this size, bold or not. */
.badge.st-followup { color: #8f5108; }   /* 5.62:1 */
.badge.st-won      { color: #0b7d49; }   /* 4.61:1 */
.badge.st-lost     { color: #c1362f; }   /* 4.73:1 */
.badge.st-new      { color: #6d28d9; }   /* 6.11:1 */
/* The dark palette dims the amber and red text tokens for body copy; on a small
   filled badge that reads as grey, so they are lifted back to legible here. */
[data-theme="dark"] .badge.st-followup { color: #f0b429; }
[data-theme="dark"] .badge.st-lost     { color: #ff8a84; }
[data-theme="dark"] .badge.st-won      { color: #4ade80; }
[data-theme="dark"] .badge.st-new      { color: var(--state-new); }

/* WhatsApp, in WhatsApp's own green, so the eye finds it without reading. It
   sits under the phone number because on a sales floor the order is: try the
   call, and if they do not pick up, message them. */
.dialer-reach { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; }
.btn.wa {
  background: #25d366; border-color: #1eb855; color: #05321a; font-weight: 700;
}
.btn.wa:hover { background: #1eb855; border-color: #179c47; color: #fff; }

/* A long unbreakable string - a product name with no spaces, a pasted URL, a
   long email - used to push the whole page sideways on a narrow screen. Found
   by measuring scrollWidth against clientWidth per element, not by eye.
   `min-width:0` is the part that is easy to miss: a flex child refuses to
   shrink below its content without it, so wrapping alone does not help. */
.pkg-top > div { min-width: 0; }
.pkg-name, .pkg-cat, .pkg-then { overflow-wrap: anywhere; }

/* Same weakness, same fix, for the places a CUSTOMER-supplied name is shown. */
.cell-main, .cell-sub { overflow-wrap: anywhere; }
.dialer-name, .dialer-sub { overflow-wrap: anywhere; }
.lead-card .title { overflow-wrap: anywhere; min-width: 0; }

/* Two-column splits that were written as inline `style="grid-template-columns:…"`.
   An inline style beats every media query, so those screens could not collapse
   on a phone and pushed the page sideways by almost a full screen width.
   As classes they obey the same breakpoint as every other grid.
   `minmax(0, …)` rather than a bare fr: a plain fr track refuses to shrink
   below its content, which is the other half of the same bug. */
.grid.g-main { grid-template-columns: 1.6fr minmax(0, 1fr); }
.grid.g-side { grid-template-columns: minmax(0, 1fr) 2fr; }
@media (max-width: 900px) {
  .grid.g-main, .grid.g-side { grid-template-columns: minmax(0, 1fr); }
}

/* Two sections of a bundle, side by side: what the television side gives you
   and what the internet side gives you. `minmax(0, 1fr)` for the same reason as
   everywhere else - a bare 1fr track refuses to shrink and pushes the dialog
   wider than the screen. Stacks on a phone. */
.pkg-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 620px) { .pkg-cols { grid-template-columns: minmax(0, 1fr); } }

.pkg-sec-title {
  font-weight: 700; font-size: 13px; color: var(--brand);
  padding-bottom: 4px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
}
.pkg-sec ul { margin: 0; padding-inline-start: 18px; }
.pkg-sec li { margin: 2px 0; overflow-wrap: anywhere; }
