@import url("../fonts/fonts.css");

/* ═══════════════════════════════════════════════════════════════════════
   crm-engine — מערכת העיצוב

   הרעיון: קרטוטקה. השולחן כהה, הכרטיסים בהירים ומונחים עליו. כל מה
   שמשתמש כתב מופיע בכתב יד אחד; כל מה שה-AI כתב מופיע בכתב שני, מסומן
   בפס משורג ובתווית — כדי שלא יתבלבלו לעולם.

   שני מלכודות שנמנעות כאן במכוון:
   1. אין החלפת ערכת נושא, ולכן אין אליאסי var() שנפתרים לפי :root במקום body.
   2. אין צביעת טקסט לפי הסלקטור button — כל צבע כפתור מגיע ממחלקה מפורשת.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* השולחן */
  --desk:      #263238;
  --desk-deep: #1C262B;
  --desk-up:   #33434B;
  --desk-line: #3E4F58;
  --on-desk:   #DCD5C4;
  --on-desk-dim: #96A2A8;

  /* נייר הכרטיס */
  --card:      #F1EBDA;
  --field:     #FAF7EF;
  --rule:      #D2C7AB;
  --rule-soft: #E3DBC6;

  /* שני כתבי היד */
  --ink:       #1B2A38;   /* אדם */
  --ink-dim:   #5D6976;
  --machine:   #63527A;   /* מכונה */
  --machine-bg:#EFE9F2;

  /* לשונית האינדקס — הצבע היחיד שנשמר לפעולה ולזיהוי */
  --tab:       #AE4E2A;
  --tab-deep:  #8B3D1F;
  --tab-soft:  #F6E3D8;

  --good:      #3B6845;
  --good-soft: #DCE8DC;
  --warn:      #9C7016;
  --warn-soft: #F6EBD2;
  --bad:       #93332A;
  --bad-soft:  #F5DFDA;

  --display: "Frank Ruhl Libre", "Times New Roman", serif;
  --body:    "Assistant", "Segoe UI", system-ui, sans-serif;
  /* מונו — לספרות, טלפונים ושעות בלבד. הקובץ הוא לטיני, ובעברית הוא נופל
     חזרה לגופן ברירת המחדל. */
  --data:    "IBM Plex Mono", ui-monospace, "Courier New", monospace;

  --r-card: 3px;    /* כרטיס נייר — פינות כמעט חדות */
  --r-ctl:  4px;
  --rail-w: 214px;
  --shadow-card: 0 1px 0 rgba(0,0,0,.22), 0 8px 22px -12px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--on-desk);
  background: var(--desk);
  /* טקסטורה עדינה של משטח מתכת — לא תמונה, גרדיאנט חוזר */
  background-image:
    repeating-linear-gradient(90deg, rgba(255,255,255,.014) 0 1px, transparent 1px 3px);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; margin: 0; line-height: 1.25; }

a { color: var(--tab); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--tab);
  outline-offset: 2px;
}

/* מספרים, טלפונים, זמנים — תמיד במונו וב-LTR כדי שהספרות יתיישרו */
.num, .phone, .clock {
  font-family: var(--data);
  font-weight: 500;
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
.phone { letter-spacing: .01em; }

/* ═══════════════════════ הפסקול העליון ═══════════════════════ */
.rail {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 54px;
  padding: 0 18px;
  background: var(--desk-deep);
  border-bottom: 1px solid var(--desk-line);
}

/* כל פריט בפסקול מקבל flex: none — אחרת הם מתכווצים והשמות נשברים לשתי שורות */
.brand { display: flex; align-items: baseline; gap: 9px; flex: none; white-space: nowrap; }
.brand-mark {
  /* לשונית האינדקס — הסימן של המערכת */
  width: 13px; height: 20px;
  background: var(--tab);
  clip-path: polygon(0 0, 100% 0, 100% 72%, 50% 100%, 0 72%);
}
.brand-name { font-family: var(--display); font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; font-weight: 600; color: var(--on-desk-dim); }

.rail-spacer { flex: 1; }

.rail-search {
  position: relative;
  flex: 0 1 340px;
  min-width: 0;
}
.rail-search input {
  width: 100%;
  height: 34px;
  /* לוגי ולא פיזי: ב-RTL הפדינג הגדול צריך להיות בצד שממנו מתחיל הטקסט */
  padding-inline-start: 34px;
  padding-inline-end: 12px;
  font: 400 14px var(--body);
  color: var(--on-desk);
  background: #171F23;
  border: 1px solid var(--desk-line);
  border-radius: var(--r-ctl);
}
.rail-search input::placeholder { color: #6F7C83; }
.rail-search .ic {
  position: absolute; inset-inline-start: 9px; top: 9px;
  width: 16px; height: 16px; color: #6F7C83; pointer-events: none;
}

.rail-pick {
  flex: 0 1 auto;
  min-width: 0;              /* בלי זה הבורר לא מתכווץ ודוחף את הדף במסך צר */
  max-width: 220px;
  height: 34px;
  padding: 0 10px;
  font: 500 13px var(--body);
  color: var(--on-desk);
  background: #171F23;
  border: 1px solid var(--desk-line);
  border-radius: var(--r-ctl);
  cursor: pointer;
}

.rail-who {
  display: flex; align-items: center; gap: 8px;
  flex: none; white-space: nowrap;
  font-size: 13px; color: var(--on-desk-dim);
}
.rail-who b { color: var(--on-desk); font-weight: 600; }

/* ═══════════════════════ המסגרת ═══════════════════════ */
.shell { display: flex; align-items: flex-start; min-height: calc(100vh - 54px); }

.nav {
  position: sticky; top: 54px;
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  height: calc(100vh - 54px);
  padding: 16px 12px;
  overflow-y: auto;
  border-inline-start: 1px solid var(--desk-line);
}

/* ═══ תוויות זעירות ═══
   בלטינית התבנית היא מונו + tracking + uppercase. בעברית אין uppercase,
   ו-tracking על אותיות עבריות קורע את המילה ("ע ב ו ד ה"). לכן כל תווית
   זעירה בעברית היא Assistant במשקל כבד ובגודל קטן, בלי ריווח אותיות. */
.micro {
  font-family: var(--body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.nav-group { margin-bottom: 20px; }
.nav-group-label {
  padding: 0 10px 7px;
  font-family: var(--body);
  font-size: 11px; font-weight: 700;
  color: #6F7C83;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 1px;
  font: 500 14.5px var(--body);
  color: var(--on-desk);
  text-align: start;
  background: none;
  border: 0;
  border-radius: var(--r-ctl);
  cursor: pointer;
}
.nav-item:hover { background: var(--desk-up); }
.nav-item.on {
  /* פריט נבחר מקבל לשונית — כמו כרטיס שנשלף מהמגירה */
  position: relative;
  background: var(--desk-up);
  color: #fff;
}
.nav-item.on::before {
  content: "";
  position: absolute; inset-inline-end: -12px; top: 6px; bottom: 6px;
  width: 3px; background: var(--tab);
}
.nav-item .ic { width: 17px; height: 17px; flex: 0 0 17px; opacity: .78; }
.nav-item.on .ic { opacity: 1; }
.nav-count {
  margin-inline-start: auto;
  padding: 1px 7px;
  font: 600 11px var(--data);
  color: var(--desk-deep);
  background: var(--on-desk-dim);
  border-radius: 9px;
}
.nav-count.hot { background: var(--tab); color: #fff; }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }

/* ═══════════════════════ כותרת מסך ═══════════════════════ */
.head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.head-title { font-size: 27px; }
.head-note { font-size: 13.5px; color: var(--on-desk-dim); padding-bottom: 4px; }
.head-acts { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════════════════ כרטיס ═══════════════════════ */
.card {
  position: relative;
  background: var(--card);
  color: var(--ink);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}
.card-pad { padding: 16px 18px; }

/* לשונית הכרטיס: הקצה המסומן שאומר מה בפנים לפני שפותחים */
.card-tab {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--rule);
}
.card-tab::before {
  content: "";
  width: 4px; height: 18px;
  background: var(--tab);
  border-radius: 1px;
}
.card-tab h3 { font-size: 16.5px; }
.card-tab .card-tab-note { font-size: 12.5px; color: var(--ink-dim); }
.card-tab .card-tab-acts { margin-inline-start: auto; display: flex; gap: 6px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; }

/* min-width: 0 חיוני על כל פריט בפריסה: ברירת המחדל היא auto, ולכן טבלה
   רחבה מרחיבה את הכרטיס והעמודה במקום להיגלל בתוך .tbl-wrap — והדף כולו
   יוצא רחב מהמסך. */
.grid > *, .split > * { min-width: 0; }
.card { min-width: 0; }

/* ═══════════════════════ מדדים ═══════════════════════ */
.stat { padding: 14px 16px; }
.stat-label {
  font-family: var(--body);
  font-size: 11px; font-weight: 700;
  color: var(--ink-dim);
}
.stat-value { font-family: var(--data); font-size: 28px; font-weight: 600; line-height: 1.15; margin-top: 3px; }
.stat-value small { font-family: var(--body); font-size: 13px; font-weight: 500; color: var(--ink-dim); }
.stat-note { font-size: 12.5px; color: var(--ink-dim); margin-top: 2px; }

/* מד מלאי — נפח דרייב, מכסת דקות */
.meter { height: 7px; background: var(--rule-soft); border-radius: 4px; overflow: hidden; margin-top: 9px; display: flex; }
.meter-fill { background: var(--good); }
.meter-fill.warn { background: var(--warn); }
.meter-fill.full { background: var(--bad); }
/* החלק הנעול מסומן בשרוגים — הוא תפוס ולא יתפנה בלוף המחיקה */
.meter-lock {
  background-image: repeating-linear-gradient(45deg,
    var(--ink-dim) 0 2px, transparent 2px 5px);
  background-color: var(--rule);
}

/* ═══════════════════════ טבלה ═══════════════════════ */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  padding: 8px 12px;
  font-family: var(--body);
  font-size: 11.5px; font-weight: 700;
  color: var(--ink-dim);
  text-align: start;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
/* קווי הסרגל של הכרטיס — לא גבולות סביב כל תא */
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.pick { cursor: pointer; }
.tbl tbody tr.pick:hover { background: #E8E0CB; }
.tbl-wrap { overflow-x: auto; }

.t-dim { color: var(--ink-dim); }
.t-strong { font-weight: 600; }
.t-name { font-family: var(--display); font-weight: 700; font-size: 15.5px; }
.t-clip { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* שתי שורות לסיכום — יותר פרטים בגובה שורה כמעט זהה */
.t-clip2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
           overflow: hidden; white-space: normal; line-height: 1.35; }

/* ═══ רוחבי עמודות בטבלת השיחות: שלוחה צרה, סיכום רחב, נתיב קצוץ ═══ */
.tbl .col-when, .tbl .col-dur, .tbl .col-state { white-space: nowrap; width: 1%; }
.tbl .col-ext { max-width: 13ch; }
.tbl .col-ext .t-name, .tbl .col-ext .phone {
  display: block; max-width: 13ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tbl .col-route { max-width: 24ch; }
.tbl .col-route .route {
  display: block; max-width: 24ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tbl .col-sum { min-width: 26ch; }
/* כותרת נגררת — סדר העמודות הוא של המשתמש */
.tbl th[draggable="true"] { cursor: grab; position: relative; }
.tbl th[draggable="true"]:active { cursor: grabbing; }
/* בפריסה קבועה (אחרי שינוי רוחב ידני) שום תא לא גולש על שכנו:
   בלי זה עמודה צרה מ"משתגעת" — הטקסט שלה נמרח על העמודות הסמוכות */
.tbl-fixed th, .tbl-fixed td { overflow: hidden; }
.tbl-fixed .col-when, .tbl-fixed .col-dur, .tbl-fixed .col-state { width: auto; }
/* במצב רוחב-ידני המשתמש קובע — מגבלות ה-max-width של ברירת המחדל משוחררות */
.tbl-fixed .col-ext, .tbl-fixed .col-route,
.tbl-fixed .col-ext .t-name, .tbl-fixed .col-ext .phone,
.tbl-fixed .col-route .route { max-width: none; }
/* חוצץ הרוחב בקצה השמאלי של כל כותרת (RTL: שם העמודה "נגמרת") */
.col-grip {
  position: absolute; top: 0; bottom: 0; left: -3px; width: 8px;
  cursor: col-resize; user-select: none;
}
.col-grip:hover { background: var(--brass, #b08d57); opacity: .4; }

/* ═══ דוח נציגים: פסי השעות ═══ */
.hour-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.hour-label { width: 5ch; color: var(--ink-dim); }
.hour-bar-wrap { flex: 1; position: relative; height: 15px;
                 background: var(--hair, #d9d2bd); border-radius: 3px; overflow: hidden; }
.hour-bar { position: absolute; inset-inline-start: 0; top: 0; bottom: 0;
            background: var(--brass, #b08d57); opacity: .45; border-radius: 3px; }
.hour-bar-ans { opacity: 1; background: var(--good, #2e7d32); }

/* ═══ לוח הטיפול (קנבן) ═══ */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
          align-items: start; }
@media (max-width: 860px) { .kanban { grid-template-columns: 1fr; } }
.kan-col { background: var(--panel-dim, rgba(0,0,0,.04)); border-radius: 10px;
           padding: 10px; min-height: 160px; }
.kan-head { font-weight: 700; margin-bottom: 9px; display: flex;
            justify-content: space-between; align-items: baseline; }
.kan-card { background: var(--panel, #fff); border: 1px solid var(--hair, #d9d2bd);
            border-radius: 8px; padding: 9px 11px; margin-bottom: 8px;
            cursor: grab; }
.kan-card:active { cursor: grabbing; }
.kan-over { outline: 2px dashed var(--brass, #b08d57); outline-offset: -4px; }

/* ═══════════════════════ כתב היד של המכונה ═══════════════════════ */
/* כל טקסט שנוצר ע"י AI מופיע כך: פס משורג בשוליים, צבע אחר, ותווית.
   זה החלק היחיד בעיצוב שנושא סימן מיוחד — כדי שלא יבלבלו בין מה
   שהמערכת שיערה למה שאדם רשם. */
.mach {
  position: relative;
  padding: 11px 16px 12px 14px;
  margin: 10px 0;
  color: var(--machine);
  background: var(--machine-bg);
  border-radius: 0 var(--r-card) var(--r-card) 0;
}
.mach::before {
  content: "";
  position: absolute; inset-inline-start: 0; top: 0; bottom: 0;
  width: 5px;
  background-image: repeating-linear-gradient(45deg,
    var(--machine) 0 2px, transparent 2px 4px);
}
.mach-label {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--body);
  font-size: 11px; font-weight: 700;
  opacity: .85;
  margin-bottom: 3px;
}
.mach-body { color: var(--ink); }
.mach h4 { font-family: var(--body); font-size: 14.5px; font-weight: 700; color: var(--machine); }

/* הצעה שממתינה לאישור — לא מוחלת עד שלוחצים */
.sug {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--rule);
}
.sug:last-child { border-bottom: 0; }
.sug-key {
  flex: 0 0 92px;
  font-family: var(--body);
  font-size: 12px; font-weight: 700;
  color: var(--ink-dim);
  padding-top: 2px;
}
.sug-val { flex: 1; min-width: 0; color: var(--ink); }

/* תמלול — טקסט רץ עם דוברים מסומנים */
.script {
  max-height: 460px; overflow-y: auto;
  padding: 14px 16px;
  font-size: 14.5px; line-height: 1.85;
  white-space: pre-wrap;
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: var(--r-card);
  color: var(--ink);
}
.script b { font-weight: 700; color: var(--tab-deep); }

/* ═══════════════════════ כפתורים ═══════════════════════ */
/* אין צביעה לפי הסלקטור button — כל וריאנט הוא מחלקה */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px;
  padding: 0 14px;
  font: 600 14px var(--body);
  border: 1px solid transparent;
  border-radius: var(--r-ctl);
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn .ic { width: 15px; height: 15px; }
.btn:disabled { opacity: .48; cursor: not-allowed; }

.btn-main { background: var(--tab); color: #fff; }
.btn-main:hover:not(:disabled) { background: var(--tab-deep); }

.btn-line { background: transparent; color: var(--on-desk); border-color: var(--desk-line); }
.btn-line:hover:not(:disabled) { background: var(--desk-up); }

/* על נייר בהיר — גרסה כהה של אותו כפתור */
.card .btn-line, .modal .btn-line { color: var(--ink); border-color: var(--rule); }
.card .btn-line:hover:not(:disabled), .modal .btn-line:hover:not(:disabled) { background: #E6DDC7; }

.btn-quiet { background: transparent; color: var(--ink-dim); padding: 0 8px; }
.btn-quiet:hover:not(:disabled) { background: #E6DDC7; color: var(--ink); }

.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); }

.btn-sm { min-height: 27px; padding: 0 9px; font-size: 12.5px; }
.btn-sm .ic { width: 13px; height: 13px; }

/* ═══════════════════════ מתגים ותוויות ═══════════════════════ */
/* המתג: הפקד והתווית הם אחים נפרדים ולא מתחרים על מקום באותו flex.
   בגרסה קודמת התווית הייתה ילדה של הפקד, ותווית ארוכה נחתכה מתחת למתג. */
.sw-row { display: flex; align-items: center; gap: 10px; }

.sw {
  position: relative;
  display: inline-flex;
  flex: none;
  cursor: pointer;
}
/* ה-input מכסה את כל הפקד — כך הלחיצה על המתג עצמו עובדת, והפוקוס נשמר */
.sw input {
  position: absolute; inset: 0;
  margin: 0; opacity: 0; cursor: pointer;
}
.sw-track {
  position: relative;
  display: block;
  width: 40px; height: 22px;
  background: var(--rule);
  border-radius: 12px;
  transition: background .15s;
  /* pointer-events: none חיוני — המסלול הוא אח מאוחר יותר עם position:relative
     ולכן נצבע מעל ה-input ובלע את הקליק. בלי זה המתג עצמו אינו לחיץ בכלל. */
  pointer-events: none;
}
.sw-label { flex: 1 1 auto; min-width: 0; font-size: 14px; cursor: pointer; }

/* הכפתור ממוקם ב-right פיזי ולא ב-inset-inline-end, ונע ע"י שינוי right
   ולא ב-transform. ב-RTL ‏inset-inline-end הוא הצד השמאלי, ולכן הגרסה
   הלוגית + translateX הוציאה את הכפתור מחוץ למתג ועל גבי התווית.
   כבוי = צד ימין (תחילת הקריאה) · דלוק = צד שמאל. */
.sw-track::after {
  content: "";
  position: absolute; top: 3px; right: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: right .15s;
}
.sw input:checked + .sw-track { background: var(--good); }
.sw input:checked + .sw-track::after { right: 21px; }
@media (prefers-reduced-motion: reduce) {
  .sw-track, .sw-track::after { transition: none; }
}
.sw input:focus-visible + .sw-track { outline: 2px solid var(--tab); outline-offset: 2px; }
/* חיווי מילולי לצד המתג — לא מסתמכים על צבע בלבד */
.sw-state {
  font-family: var(--body); font-size: 12px; font-weight: 700;
  color: var(--ink-dim);
  flex: none; white-space: nowrap;
  min-width: 4.5ch;           /* "לא כלול" ו-"כלול" באותו רוחב — הטקסט לא מקפיץ את השורה */
}

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  font-size: 12px; font-weight: 600;
  border-radius: 11px;
  background: var(--rule-soft); color: var(--ink-dim);
}
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad  { background: var(--bad-soft);  color: var(--bad); }
.pill-tab  { background: var(--tab-soft);  color: var(--tab-deep); }
.pill-mach { background: var(--machine-bg); color: var(--machine); }
.pill-lock { background: var(--ink); color: var(--card); }

/* ═══════════════════════ שדות ═══════════════════════ */
.fields { display: grid; gap: 13px; }
.fields-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* :not([class]) חיוני — תוויות אחרות בתוך .field (למשל תווית של מתג) הן גם
   <label>, והכלל הזה הפך אותן ל-block וקטע את הפריסה שלהן. תווית שדה רגילה
   נכתבת תמיד כ-<label> בלי מחלקה. */
.field > label:not([class]), .field > .field-label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-dim);
}
.field-hint { margin-top: 4px; font-size: 12.5px; color: var(--ink-dim); }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  font: 400 14.5px var(--body);
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: var(--r-ctl);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--tab);
  outline: 1px solid var(--tab);
  outline-offset: -1px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
input[type=number] { font-family: var(--data); direction: ltr; text-align: end; }

/* שדה החיפוש בפסקול מוגדר למעלה, אבל הכלל הגנרי של input מגיע אחריו עם
   padding מקוצר — ולכן הוא דורס את הפדינג הלוגי ומסתיר טקסט מתחת לאייקון.
   הכלל הזה מחזיר אותו בסלקטור ספציפי יותר. */
.rail .rail-search input[type=search] {
  min-height: 0;
  height: 34px;
  padding-block: 0;
  padding-inline-start: 34px;
  padding-inline-end: 12px;
  color: var(--on-desk);
  background: #171F23;
  border-color: var(--desk-line);
}

/* שדה סוד: מוצג ריק תמיד, עם חיווי אם הוגדר */
.secret-set {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--body); font-size: 12.5px; font-weight: 700;
  color: var(--good);
}

/* ═══════════════════════ מקופל ═══════════════════════ */
details.fold { border-top: 1px solid var(--rule); margin-top: 14px; }
details.fold > summary {
  padding: 11px 0 10px;
  font: 600 14px var(--body);
  color: var(--ink-dim);
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center; gap: 7px;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: "";
  width: 0; height: 0;
  border: 4px solid transparent;
  border-inline-end-color: var(--ink-dim);
  transition: transform .15s;
}
details.fold[open] > summary::before { transform: rotate(-90deg); }
details.fold > .fold-body { padding-bottom: 14px; }

/* ═══════════════════════ מסך ריק ═══════════════════════ */
.blank {
  padding: 46px 22px;
  text-align: center;
  color: var(--ink-dim);
}
.blank .blank-mark {
  width: 34px; height: 44px;
  margin: 0 auto 14px;
  background: var(--rule);
  clip-path: polygon(0 0, 100% 0, 100% 76%, 50% 100%, 0 76%);
}
.blank h3 { font-size: 18px; color: var(--ink); margin-bottom: 5px; }
.blank p { margin: 0 auto 16px; max-width: 46ch; font-size: 14px; }

/* על השולחן (מחוץ לכרטיס) */
.blank-desk { color: var(--on-desk-dim); }
.blank-desk h3 { color: var(--on-desk); }
.blank-desk .blank-mark { background: var(--desk-up); }

/* ═══════════════════════ חלון ═══════════════════════ */
.veil {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  background: rgba(12,18,21,.72);
}
.veil[hidden] { display: none; }

.modal {
  width: min(620px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  color: var(--ink);
  border-radius: var(--r-card);
  box-shadow: 0 26px 70px -18px rgba(0,0,0,.72);
}
.modal-wide { width: min(940px, 100%); }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
}
.modal-head::before { content: ""; width: 4px; height: 18px; background: var(--tab); }
.modal-head h3 { font-size: 17px; }
.modal-head .btn-quiet { margin-inline-start: auto; }
.modal-body { padding: 18px; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-start;
  padding: 13px 18px;
  border-top: 1px solid var(--rule);
  background: #EAE2CD;
}

/* אזהרת עלות — הפופאפ שמופיע לפני הפעלת אחסון בדרייב */
.notice-cost {
  padding: 14px 16px;
  background: var(--warn-soft);
  border-inline-start: 5px solid var(--warn);
  border-radius: 0 var(--r-card) var(--r-card) 0;
  color: var(--ink);
}
.notice-cost strong { display: block; font-size: 16px; margin-bottom: 5px; color: var(--warn); }
.notice-cost p { margin: 0 0 8px; white-space: pre-line; }

.notice {
  padding: 11px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  border-radius: var(--r-card);
  border-inline-start: 4px solid var(--ink-dim);
  background: var(--rule-soft);
  color: var(--ink);
}
.notice-bad  { border-inline-start-color: var(--bad);  background: var(--bad-soft); }
.notice-good { border-inline-start-color: var(--good); background: var(--good-soft); }
.notice-warn { border-inline-start-color: var(--warn); background: var(--warn-soft); }

/* ═══════════════════════ הודעות רגע ═══════════════════════ */
.toasts {
  position: fixed; inset-block-end: 18px; inset-inline-start: 18px;
  z-index: 120;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  min-width: 240px; max-width: 400px;
  padding: 11px 15px;
  font-size: 14px; font-weight: 500;
  color: var(--card);
  background: var(--desk-deep);
  border-inline-start: 4px solid var(--good);
  border-radius: var(--r-ctl);
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.7);
  animation: rise .18s ease-out;
}
.toast.bad  { border-inline-start-color: var(--bad); }
.toast.warn { border-inline-start-color: var(--warn); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ═══════════════════════ שיחה חיה ═══════════════════════ */
/* השורה שמופיעה כשמישהו על הקו. הנורה פועמת — זה החיווי היחיד
   שזז בממשק, ולכן הוא נקרא מיד. */
.live {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 16px;
  background: var(--card);
  border-inline-start: 5px solid var(--good);
  border-radius: 0 var(--r-card) var(--r-card) 0;
  box-shadow: var(--shadow-card);
  margin-bottom: 10px;
  color: var(--ink);
}
.live-lamp {
  width: 9px; height: 9px; flex: 0 0 9px;
  background: var(--good);
  border-radius: 50%;
  animation: pulse 1.7s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .28; } }
@media (prefers-reduced-motion: reduce) {
  .live-lamp { animation: none; }
  .toast { animation: none; }
}
.live-who { min-width: 0; }
.live-name { font-family: var(--display); font-size: 17px; font-weight: 700; }
.live-meta { font-size: 12.5px; color: var(--ink-dim); }
.live-acts { margin-inline-start: auto; display: flex; gap: 7px; }

/* ═══════════════════════ פריטים ברשימה ═══════════════════════ */
.row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-note { font-size: 13px; color: var(--ink-dim); }
.row-acts { display: flex; gap: 6px; align-items: center; }

/* נתיב השיחה: "תפריט גישה 029667003 → קבוצת חיוג שלוחה 1 → תור מכירות".
   נשבר לשורות במקום להרחיב את הטבלה, כי מסלול ארוך היה דוחף את הדף
   הצידה בנייד. החץ אינו סימן קישוט — הוא סדר השלבים שהשיחה עברה. */
.route {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-dim);
  overflow-wrap: anywhere;
}
.row.done .row-title { text-decoration: line-through; color: var(--ink-dim); }

/* הערה שאדם כתב — בלי סימון מיוחד, זו ברירת המחדל של המערכת */
.note-item { padding: 10px 0; border-bottom: 1px solid var(--rule-soft); }
.note-item:last-child { border-bottom: 0; }
.note-body { white-space: pre-wrap; }
.note-by { margin-top: 3px; font-size: 12px; color: var(--ink-dim); }

/* תוצאת חיפוש — הקטע המודגש */
.hit { padding: 12px 0; border-bottom: 1px solid var(--rule-soft); }
.hit:last-child { border-bottom: 0; }
.hit-top { display: flex; align-items: baseline; gap: 9px; margin-bottom: 3px; }
.hit-snip { font-size: 14px; color: var(--ink-dim); }
.hit-snip mark { background: var(--tab-soft); color: var(--tab-deep); font-weight: 600; padding: 0 2px; }

/* ═══════════════════════ עזרים ═══════════════════════ */
.ic { display: inline-block; width: 1em; height: 1em; fill: none; stroke: currentColor;
      stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.14em; }
.hide { display: none !important; }
.mut { color: var(--ink-dim); }
.mut-desk { color: var(--on-desk-dim); }
.gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.gap-lg { gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.right { margin-inline-start: auto; }
.nowrap { white-space: nowrap; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.spin {
  width: 15px; height: 15px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: turn .7s linear infinite;
}
@keyframes turn { to { transform: rotate(360deg); } }

audio { width: 100%; height: 36px; margin-top: 8px; }

/* ═══════════════════════ מסך צר ═══════════════════════ */
@media (max-width: 940px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  /* align-items: stretch חיוני — בבסיס הוא flex-start, ובעמודה זה גורם
     ל-main להתרחב לפי התוכן ולא לפי המסך, והדף יוצא רחב מהמסך. */
  .shell { flex-direction: column; align-items: stretch; }
  /* בטלפון הניווט נגלש לשורות ולא נגלל אופקית: כל הפריטים נראים, ואין
     תוכן שגולש מחוץ למסך ומייצר גלילה אופקית של כל הדף. */
  .nav {
    position: static;
    flex: none; width: 100%; height: auto;
    display: flex; flex-wrap: wrap; gap: 4px;
    overflow: visible;
    padding: 9px 12px;
    border-inline-start: 0;
    border-bottom: 1px solid var(--desk-line);
  }
  .nav-group { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; }
  .nav-group-label { display: none; }
  .nav-item {
    width: auto; margin: 0; white-space: nowrap;
    padding: 6px 9px; font-size: 13.5px;
  }
  .nav-item.on::before {
    inset-inline-end: 6px; inset-inline-start: 6px; top: auto; bottom: -1px;
    width: auto; height: 2px;
  }
  .main { padding: 16px 14px 48px; }
  .rail-search { display: none; }
  .brand-sub { display: none; }
  .head-title { font-size: 22px; }
  .head { gap: 10px; }
  .head-acts { width: 100%; margin-inline-start: 0; }
  .card-tab { flex-wrap: wrap; }
  .card-tab-acts { margin-inline-start: 0; }
  .modal-foot { flex-wrap: wrap; }
}

/* מסך טלפון: הפסקול מצטמצם לסמל, לבורר הלקוח וליציאה. השם המלא של
   המשתמש והמילה "מנוע CRM" יורדים — הם לא נחוצים כדי לעבוד. */
@media (max-width: 560px) {
  .rail { gap: 8px; padding: 0 12px; }
  .brand-name { display: none; }
  .rail-who b { display: none; }
  .rail-pick { max-width: none; }
  .main { padding: 14px 12px 44px; }
  .card-pad { padding: 13px 14px; }
  .card-tab { padding: 10px 14px; }
  .stat { padding: 12px 14px; }
  .fields-2 { grid-template-columns: 1fr; }
  .btn { padding: 0 11px; }
}

/* ═══════════════════════ מסך כניסה ═══════════════════════ */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(400px, 100%);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--r-card);
  box-shadow: 0 30px 80px -24px rgba(0,0,0,.8);
  overflow: hidden;
}
.gate-top {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--rule);
}
.gate-top .brand-mark { margin-bottom: 12px; width: 16px; height: 24px; }
.gate-top h1 { font-size: 24px; }
.gate-top p { margin: 5px 0 0; font-size: 13.5px; color: var(--ink-dim); }
.gate-body { padding: 20px 24px 24px; }
.gate-body .btn-main { width: 100%; margin-top: 6px; }
