/* ==========================================================================
   Cosmic — מערכת העיצוב
   ורוד עמום על נייר חמים. הוורוד שמור לפעולה, להיום ולעכשיו בלבד;
   כל השאר נייר ודיו. מצב ערב זמין דרך data-theme="dark".
   ========================================================================== */

:root {
  --paper:      #FDF7F9;
  --surface:    #FFFFFF;
  --surface-2:  #FCF2F5;
  --ink:        #2E1F2A;
  --ink-2:      #5A4553;
  --muted:      #8C7885;
  --line:       #F2E4EA;
  --line-2:     #F9EFF3;
  --wash:       rgba(196,80,111,.08);

  --rose:       #C4506F;
  --rose-press: #A93E5B;
  --rose-soft:  #F9E7ED;
  --rose-tint:  #FDF3F6;

  --sand:       #B98A5E;
  --mulberry:   #8E5E96;
  --teal:       #3E8E7E;
  --amber:      #C98A2B;
  --crit:       #C4453F;

  --shadow-sm: 0 1px 2px rgba(46,31,42,.06), 0 1px 3px rgba(196,80,111,.05);
  --shadow-md: 0 2px 4px rgba(46,31,42,.05), 0 8px 24px rgba(196,80,111,.09);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --rail-w: 232px;
  --hour-h: 76px;
}

:root[data-theme="dark"] {
  --paper: #171116;  --surface: #211926;  --surface-2: #2A2030;
  --ink: #F6EDF1;    --ink-2: #D6C4CE;    --muted: #9F8B98;
  --line: #372B36;   --line-2: #2C2230;   --wash: rgba(228,140,165,.06);
  --rose: #E48CA5;   --rose-press: #F0A3B8;
  --rose-soft: #3B2530; --rose-tint: #2A1E27;
  --sand: #D2A87C;   --mulberry: #B78EBE; --teal: #63B49F;
  --amber: #E0AC5A;  --crit: #E4726C;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 8px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Assistant", "Rubik", "Heebo", -apple-system, BlinkMacSystemFont,
               "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; border-radius: 4px; }

a { color: var(--rose); }

.num, .money {
  font-variant-numeric: tabular-nums;
  direction: ltr; unicode-bidi: isolate; display: inline-block;
}
.money { font-weight: 600; }

.eyebrow { font-size: 11px; letter-spacing: .09em; color: var(--muted); font-weight: 600; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh;
       background: linear-gradient(180deg, var(--wash) 0, transparent 460px); }

.rail {
  background: var(--surface); border-inline-start: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding-inline-start: 6px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  background: linear-gradient(150deg, var(--rose) 0%, var(--mulberry) 100%);
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(196,80,111,.35);
}
.brand-name { font-size: 19px; font-weight: 700; }
.brand-sub  { font-size: 11px; color: var(--muted); margin-top: -4px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  border-radius: var(--r-sm); color: var(--ink-2); font: inherit;
  font-size: 14.5px; font-weight: 500; text-decoration: none;
  background: none; border: 0; width: 100%; text-align: start; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--rose-soft); color: var(--rose); font-weight: 600; }

.rail-foot { margin-top: auto; }

/* תווית קצרה לשורת הטאבים בטלפון; בתפריט הצד תמיד המלאה */
.lbl-short { display: none; }

/* בדסקטופ הקבוצה הזאת אינה קיימת כמכולה — הפריטים שלה יושבים ישירות
   בתפריט הצד. display:contents גובר על התכונה hidden שבמסמך. */
.nav-more   { display: contents; }
.more-btn,
.only-mobile { display: none; }

/* ---------- topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 16px 28px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.page-sub   { font-size: 12.5px; color: var(--muted); margin: 0; }
.spacer     { margin-inline-start: auto; }

.search { position: relative; width: min(300px, 32vw); }
.search input {
  width: 100%; font: inherit; font-size: 14px; padding: 9px 14px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: 999px;
}

.btn {
  font: inherit; font-size: 14px; font-weight: 600; border-radius: 999px;
  border: 1px solid transparent; padding: 9px 17px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn-primary { background: var(--rose); color: #fff; box-shadow: 0 2px 10px rgba(196,80,111,.28); }
.btn-primary:hover { background: var(--rose-press); }
.btn-primary:active { transform: translateY(1px); }
:root[data-theme="dark"] .btn-primary { color: #23161D; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
/* מחיקה — שקטה עד שנוגעים בה, כדי שלא תמשוך לחיצה מקרית */
.btn-danger { color: var(--crit); }
.btn-danger:hover { background: color-mix(in srgb, var(--crit) 10%, transparent); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 35%, transparent); }
.btn-sm { padding: 6px 13px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; cursor: pointer; font: inherit; font-size: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
}
.icon-btn:hover { background: var(--rose-soft); color: var(--rose); }
.icon-btn.is-on { background: var(--rose-soft); color: var(--rose); border-color: var(--rose); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--rose-soft); color: var(--rose);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}

/* ---------- panels & tables ---------- */
.view { padding: 24px 28px 60px; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 15.5px; font-weight: 700; }

.kpis { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 15px 16px 13px; box-shadow: var(--shadow-sm);
}
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin-top: 3px; }
.kpi-foot  { font-size: 12px; color: var(--muted); margin-top: 3px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 620px; }
table.data th {
  text-align: start; font-size: 11.5px; letter-spacing: .06em; color: var(--muted);
  font-weight: 700; padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--rose-tint); }
tr.row-link, tr.today-row { cursor: pointer; }
tr.today-row:focus-visible { outline: 2px solid var(--rose); outline-offset: -2px; }
tr.row-link:focus-visible { outline: 2px solid var(--rose); outline-offset: -2px; }

.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-person .name { font-weight: 600; }
.cell-person .sub  { font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.pill-ok    { background: color-mix(in srgb, var(--teal) 13%, transparent);  color: var(--teal); }
.pill-wait  { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.pill-late,
.pill-failed{ background: color-mix(in srgb, var(--crit) 13%, transparent);  color: var(--crit); }
.pill-draft { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.pill-rose  { background: var(--rose-soft); color: var(--rose); }

/* ---------- calendar ---------- */
.cal-wrap { display: grid; grid-template-columns: 1fr 296px; gap: 18px; align-items: start; }
.cal-scroll { overflow-x: auto; }
/* רוחב היום ורוחב עמודת השעות נגזרים מרמת הזום, בדיוק כמו הגובה.
   כך «להתרחק» פירושו לראות יותר ימים על המסך — ולא רק טקסט קטן.
   ה-minmax נותן לעמודות להתרחב כשיש מקום, ולכן בדסקטופ שום דבר לא מצטמצם. */
.cal { display: grid; min-width: 0;
       grid-template-columns: var(--gutter-w, 54px) repeat(6, minmax(var(--col-w, 124px), 1fr)); }
.cal-corner { border-bottom: 1px solid var(--line); }
.cal-day {
  border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line-2);
  padding: 10px 8px 8px; text-align: center;
}
.cal-day .dow  { font-size: 12px; color: var(--muted); font-weight: 600; }
.cal-day .dnum { font-size: 17px; font-weight: 700; margin-top: 1px; }
.cal-day.today .dow  { color: var(--rose); }
.cal-day.today .dnum {
  color: #fff; background: var(--rose); width: 28px; height: 28px; line-height: 28px;
  border-radius: 50%; margin: 1px auto 0; font-size: 14px;
}
:root[data-theme="dark"] .cal-day.today .dnum { color: #23161D; }

.cal-time { height: var(--hour-h); font-size: clamp(9px, calc(var(--gutter-w, 54px) / 5), 11px);
            color: var(--muted); padding-inline-end: 5px; text-align: end;
            transform: translateY(-6px); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-col  { position: relative; border-inline-start: 1px solid var(--line-2); }
.cal-col.today { background: var(--rose-tint); }
.cal-slot { height: var(--hour-h); border-bottom: 1px solid var(--line-2); }

.appt {
  position: absolute; inset-inline: 4px; width: calc(100% - 8px);
  /* --t ו---l הם שעות; --hour-h מתרגם אותן לפיקסלים לפי רמת הזום.
     הרצפה מבטיחה שגם טיפול של רבע שעה יישאר לחיץ וקריא. */
  top: calc(var(--hour-h) * var(--t, 0));
  /* הרצפה מתכווצת יחד עם הזום: בזום רגיל טיפול של רבע שעה עדיין קריא,
     ובזום רחוק לא «מתנפחים» תורים קצרים ומסתירים את התמונה. */
  height: max(calc(var(--hour-h) * 0.6), calc(var(--hour-h) * var(--l, 1) - 4px));
  border-radius: 8px; padding: 5px 9px 5px 7px;
  /* רקע גוון של צבע הטיפול — לבן על לבן לא נקרא כתור */
  background: color-mix(in srgb, var(--c, var(--rose)) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c, var(--rose)) 28%, var(--surface));
  border-inline-start: 3px solid var(--c, var(--rose));
  box-shadow: var(--shadow-sm); overflow: hidden; cursor: pointer;
  text-align: start; font: inherit; display: block;
  transition: transform .12s, box-shadow .12s;
}
:root[data-theme="dark"] .appt {
  background: color-mix(in srgb, var(--c, var(--rose)) 22%, var(--surface));
  border-color: color-mix(in srgb, var(--c, var(--rose)) 40%, var(--surface));
}
.appt { z-index: 2; }
.appt:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); z-index: 5; }
.appt .a-time { font-size: 10.5px; color: var(--ink-2); font-variant-numeric: tabular-nums;
                display: block; line-height: 1.2; }
.appt .a-name { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.25;
                display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt .a-svc  { font-size: 11.5px; color: var(--ink-2); line-height: 1.25;
                display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- חסימת זמן ---------- */
.blocked {
  position: absolute; inset-inline: 4px; width: calc(100% - 8px);
  top: calc(var(--hour-h) * var(--t, 0));
  height: max(20px, calc(var(--hour-h) * var(--l, 1) - 2px));
  border: 0; border-radius: 7px; cursor: pointer; font: inherit;
  /* פסים אלכסוניים — קוד ויזואלי מוכר ל«לא זמין», ולא צבע שמתחרה בתורים */
  background: repeating-linear-gradient(135deg,
              var(--surface-2) 0 7px, color-mix(in srgb, var(--muted) 22%, var(--surface)) 7px 14px);
  color: var(--ink-2); font-size: 11.5px; font-weight: 600;
  display: flex; align-items: flex-start; justify-content: flex-start;
  padding: 3px 7px; overflow: hidden;
  /* מתחת לתורים תמיד: תור שכבר נקבע בתוך חופשה חייב להישאר גלוי,
     אחרת החסימה מסתירה בדיוק את מה שצריך לתאם מחדש. */
  z-index: 0;
}
.blocked span {
  background: var(--surface); border-radius: 4px; padding: 0 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.blocked:hover { outline: 2px solid var(--muted); outline-offset: -2px; }

.mon-blocked {
  display: block; font-size: 10.5px; font-weight: 600; color: var(--ink-2);
  background: repeating-linear-gradient(135deg,
              var(--surface-2) 0 6px, color-mix(in srgb, var(--muted) 20%, var(--surface)) 6px 12px);
  border-radius: 4px; padding: 1px 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- מסך מלא ----------
   היומן לוקח את כל החלון: בלי תפריט צד, בלי כותרת עליונה ובלי הפאנל
   הצדדי. ה-Fullscreen API מוסיף על זה את שורת הדפדפן — ובאייפון, שבו
   הוא לא נתמך, המצב הזה לבדו הוא כבר כל ההבדל. */
body.cal-full .rail,
body.cal-full .topbar,
body.cal-full .cal-wrap > .panel:nth-child(2) { display: none; }

body.cal-full .app  { grid-template-columns: 1fr; }
body.cal-full .view { padding: 0; }
body.cal-full .cal-wrap { grid-template-columns: 1fr; gap: 0; }

body.cal-full .cal-wrap > .panel:first-child,
body.cal-full .view > .panel {
  position: fixed; inset: 0; z-index: 60; border-radius: 0; border: 0;
  display: flex; flex-direction: column; box-shadow: none;
}
body.cal-full .cal-scroll { flex: 1; overflow: auto; }
body.cal-full .mon { flex: 1; grid-auto-rows: minmax(0, 1fr); }
body.cal-full .panel-head { padding: 10px 16px; }

/* «תור חדש» ו«חסימת זמן» חיים בכותרת העליונה, שמוסתרת במסך מלא.
   כאן הם חוזרים כאייקונים בשורת הכלים — אותה פעולה, לא עותק שני. */
.only-full { display: none; }
body.cal-full .only-full { display: grid; }

/* ---------- מתג תצוגה ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg-btn {
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 14px;
  color: var(--ink-2); text-decoration: none; background: var(--surface);
}
.seg-btn + .seg-btn { border-inline-start: 1px solid var(--line); }
.seg-btn:hover { background: var(--surface-2); }
.seg-btn.is-on { background: var(--rose-soft); color: var(--rose); }

/* ---------- תצוגת חודש ---------- */
.mon { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mon-dow {
  padding: 9px 6px; text-align: center; font-size: 11.5px; font-weight: 700;
  color: var(--muted); border-bottom: 1px solid var(--line);
}
.mon-day {
  min-height: 108px; padding: 6px; border-inline-start: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 4px;
}
.mon-day:nth-child(7n + 1) { border-inline-start: 0; }
.mon-day.is-out { background: var(--surface-2); }
.mon-day.is-out .mon-num { color: var(--muted); }
.mon-day.is-today { background: var(--rose-tint); }

.mon-head { display: flex; align-items: center; gap: 6px; }
.mon-num {
  font-size: 13.5px; font-weight: 700; color: var(--ink);
  min-width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
}
/* כל התא פותח את השבוע — שטח מגע גדול בטלפון, ולא מספר קטן */
.day-link { cursor: pointer; }
.day-link:hover { background: var(--rose-tint); }
.day-link:hover .mon-num { background: var(--rose-soft); color: var(--rose); }
.day-link.is-today:hover .mon-num { background: var(--rose); color: #fff; }
.day-link:focus-visible { outline: 2px solid var(--rose); outline-offset: -2px; }
.mon-num.is-today { background: var(--rose); color: #fff; }
:root[data-theme="dark"] .mon-num.is-today { color: #23161D; }
.mon-count { margin-inline-start: auto; font-size: 10.5px; color: var(--muted); }

.mon-items { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.mon-appt {
  font: inherit; font-size: 11.5px; text-align: start; cursor: pointer;
  border: 0; border-inline-start: 3px solid var(--c, var(--rose));
  background: color-mix(in srgb, var(--c, var(--rose)) 14%, var(--surface));
  color: var(--ink); border-radius: 5px; padding: 2px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mon-appt:hover { background: color-mix(in srgb, var(--c, var(--rose)) 26%, var(--surface)); }
.mon-appt .num { color: var(--ink-2); margin-inline-end: 4px; }
.mon-who { }
.mon-more {
  font-size: 11px; color: var(--rose); text-decoration: none;
  padding: 1px 6px; font-weight: 600;
}
.mon-more:hover { text-decoration: underline; }

/* רשימת הטיפולים בתוך תור */
.svc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.svc-row  { display: flex; align-items: center; gap: 8px; }
.svc-row select { flex: 1; min-width: 0; }
.svc-row .svc-del {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  cursor: pointer; font: inherit; line-height: 1;
}
.svc-row .svc-del:hover { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 35%, transparent); }

/* שורת פריט חופשי — משהו שנעשה בקליניקה ואינו במחירון */
.svc-row.is-custom { flex-wrap: wrap; }
.svc-row.is-custom select { flex: 1 1 100%; }
.svc-row .svc-name  { flex: 2 1 120px; min-width: 0; }
.svc-row .svc-price { flex: 0 1 84px; min-width: 0; text-align: center; }
.svc-row .svc-name[hidden], .svc-row .svc-price[hidden] { display: none; }

/* שורת אמצעי תשלום בהגדרות */
.pay-row {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px 14px; margin-bottom: 10px; background: var(--surface);
}
.pay-row.is-on { border-color: color-mix(in srgb, var(--rose) 40%, var(--line)); background: var(--rose-tint); }
.pay-head { display: flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 600; font-size: 14px; }
.pay-head input { flex: none; }
.pay-row input[type="url"], .pay-row textarea {
  width: 100%; margin-top: 9px; font: inherit; direction: ltr;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px;
  background: var(--surface); color: var(--ink);
}
.pay-row textarea { direction: rtl; text-align: right; resize: vertical; }
.pay-hint { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); }

/* פיצול תשלום בין כמה אמצעים */
.split-box { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; }
.split-row { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }
.split-row select { flex: 1; min-width: 0; }
.split-row input { flex: 0 1 88px; min-width: 0; text-align: center; }
.split-foot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.split-foot.is-off { color: var(--crit); font-weight: 600; }

/* אישור חיבור לספק החשבוניות */
.conn-check { padding: 14px 18px 0; }
.conn-line { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.conn-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.conn-dot.is-ok  { background: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 20%, transparent); }
.conn-dot.is-off { background: var(--crit); box-shadow: 0 0 0 3px color-mix(in srgb, var(--crit) 20%, transparent); }
.conn-when { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.conn-result {
  margin-top: 10px; padding: 9px 12px; border-radius: var(--r-sm);
  font-size: 12.5px; line-height: 1.6; background: var(--rose-tint); color: var(--ink-2);
}
.conn-result.is-good { background: color-mix(in srgb, var(--teal) 12%, transparent); }
.conn-result.is-bad  { background: color-mix(in srgb, var(--crit) 12%, transparent); }

/* בקרת הזום */
.zoom { display: inline-flex; align-items: center; gap: 4px; }
.zoom .icon-btn { width: 28px; height: 28px; font-size: 16px; line-height: 1; }
.zoom-level { font-size: 11.5px; color: var(--muted); min-width: 38px; text-align: center; }

/* תור קצר — השעה והשם באותה שורה, כדי שגם שם הטיפול ייכנס */
.appt-tight { padding-top: 4px; }
.appt-tight .a-time { display: inline; }
.appt-tight .a-name { display: inline; font-size: 12.5px; }
.appt-tight .a-svc  { font-size: 11px; }

/* בזום הרחוק ביותר נשארים השעה והשם בלבד — שם הטיפול לא היה נכנס
   ממילא, וחצי שורה חתוכה גרועה משורה אחת שלמה. */
/* עמודה צרה: שם הטיפול יורד ראשון, ואם גם זה לא מספיק — נשארת השעה */
.appt-narrow .a-svc { display: none; }
.appt-narrow .a-name { font-size: 11.5px; }
.appt-tiny .a-name { display: none; }
.appt-tiny .a-time { font-size: 10px; font-weight: 700; color: var(--ink); }

.appt-mini { padding: 2px 7px 2px 5px; }
.appt-mini .a-time { display: inline; font-size: 10px; }
.appt-mini .a-name { display: inline; font-size: 11.5px; }
.appt-mini .a-svc  { display: none; }

.nowline { position: absolute; inset-inline: 0; height: 0; z-index: 6; pointer-events: none;
           top: calc(var(--hour-h) * var(--t, 0)); }
.nowline::before { content: ""; display: block; height: 1.5px; background: var(--rose); opacity: .85; }
.nowline::after  { content: ""; position: absolute; inset-inline-start: -4px; top: -3px;
                   width: 8px; height: 8px; border-radius: 50%; background: var(--rose); }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus { border-color: var(--rose); }

/* שדה שבו כבר נבחרה לקוחה — סימון שקט שהבחירה תפוסה */
input.has-selection {
  border-color: var(--rose) !important;
  background: var(--rose-tint);
  font-weight: 600;
}

.alert {
  padding: 10px 14px; border-radius: var(--r-sm); font-size: 13.5px;
  background: color-mix(in srgb, var(--crit) 10%, transparent);
  color: var(--crit); margin-bottom: 14px;
}
.banner {
  background: var(--amber); color: #241800; text-align: center;
  padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.banner form { display: inline; }
.banner button { background: none; border: 0; font: inherit; text-decoration: underline; cursor: pointer; color: inherit; }

/* ---------- auth ---------- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(180deg, var(--wash) 0, transparent 520px), var(--paper);
}
.auth-card {
  width: min(400px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 30px 28px; box-shadow: var(--shadow-md);
}
.auth-card h1 { margin: 14px 0 4px; font-size: 22px; }
.auth-card p.lede { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(46,31,42,.45); backdrop-filter: blur(2px); }
.modal-card {
  position: relative; width: min(480px, 100%); max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-md);
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 700; }

.cal-slot { cursor: pointer; transition: background .1s; }
.cal-slot:hover { background: var(--rose-soft); }

.picker {
  position: absolute; inset-inline: 0; top: 100%; z-index: 5;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); box-shadow: var(--shadow-md);
  max-height: 220px; overflow-y: auto;
}
.picker:empty { display: none; }
.pick {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; background: none; border: 0; border-bottom: 1px solid var(--line-2);
  font: inherit; font-size: 13.5px; text-align: start; cursor: pointer; color: var(--ink);
}
.pick:last-child { border-bottom: 0; }
.pick:hover, .pick.is-active { background: var(--rose-tint); }
.pick span { margin-inline-start: auto; font-size: 12px; color: var(--muted); }
.pick-new { color: var(--rose); font-weight: 600; }

.inline-form {
  background: var(--rose-tint); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px; margin-bottom: 14px;
}
.inline-form[hidden] { display: none; }

.chip-selected {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--rose-soft); color: var(--rose);
  border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600;
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cal-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row;
    align-items: center; gap: 4px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-inline-start: 0; border-top: 1px solid var(--line); z-index: 40;
  }
  .brand, .rail-foot, .nav-label { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  /* טאב שנשבר לשתי שורות מעווה את כל השורה: הכיתוב נשאר בשורה אחת,
     ממורכז מתחת לאייקון, וכל הטאבים באותו גובה. */
  .nav-item { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 2px;
              min-width: 0; flex: 1 1 0; align-items: center; justify-content: flex-start;
              text-align: center; white-space: nowrap; }
  .lbl-full  { display: none; }
  .lbl-short { display: inline; }

  /* ---- טבלה רחבה → כרטיסים ----
     בטלפון טבלה של שש עמודות נגללת לצדדים, ועמודת הפעולות יושבת מעבר
     לקצה. `cards-sm` הופכת כל שורה לכרטיס: הכותרת למעלה, שאר השדות
     כזוגות «תווית — ערך», והכפתורים בתחתית. אופט-אין בכוונה — טבלה של
     שלוש עמודות צרות קריאה יותר כטבלה. */
  table.cards-sm       { display: block; min-width: 0; }
  table.cards-sm thead { display: none; }
  table.cards-sm tbody { display: block; }
  table.cards-sm tr {
    display: block; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-md);
    padding: 12px 14px; margin-bottom: 10px;
  }
  table.cards-sm tr[hidden] { display: none; }
  table.cards-sm tbody tr:hover { background: var(--surface); }
  /* התווית יושבת בתוך השורה ולא כעמודה: ‏flex היה מפצל «15» מ«דק׳»
     לשני פריטים ומרחיק אותם לשני קצוות. */
  table.cards-sm td { display: block; border: 0; padding: 4px 0; font-size: 14px; }
  /* שדה בלי ערך (מרווח, חדר, סיכום) לא תופס שורה בכרטיס */
  table.cards-sm td.is-empty { display: none; }
  table.cards-sm td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted); font-size: 12.5px; font-weight: 600;
  }
  table.cards-sm td.td-title {
    font-size: 15.5px; font-weight: 700; padding: 0 0 8px;
  }
  table.cards-sm td.td-actions {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--line-2);
  }
  table.cards-sm td.td-actions form { display: inline; }


  /* כרטיס הלקוחה — טופס והיסטוריה זה לצד זה נכנסים לשתי עמודות של
     180 פיקסלים. בטלפון הם נערמים. */
  .two-col { grid-template-columns: 1fr !important; }

  /* אותה מחלה של שורת הטאבים, בכותרת פאנל: כפתור שנשבר לשתי שורות.
     הכפתור נשאר שלם, ואם אין מקום — יורד כולו לשורה הבאה. */
  .panel-head { flex-wrap: wrap; row-gap: 8px; }
  .panel-head .btn { white-space: nowrap; }

  /* חודש בטלפון: התא צר מדי לשם, ושם חתוך גרוע משעה שלמה. הצבע
     ממשיך להבדיל בין סוגי הטיפול, והלחיצה פותחת את הכרטיס המלא. */
  .cal-day { padding: 8px 2px 6px; }
  .cal-day .dnum { font-size: 15px; }
  .cal-day.today .dnum { width: 24px; height: 24px; line-height: 24px; font-size: 13px; }
  .mon-day { min-height: 74px; padding: 4px 3px; }
  .mon-appt { font-size: 10px; padding: 1px 3px; text-align: center; }
  .mon-appt .num { margin: 0; }
  .mon-who { display: none; }
  .mon-dow { padding: 7px 2px; font-size: 10.5px; }
  .mon-more { font-size: 10px; padding: 0 3px; }

  /* «עוד» — מגירה שנפתחת מעל שורת הטאבים */
  .more-btn { display: flex; }
  .only-mobile { display: block; }
  .nav-more {
    display: flex; flex-direction: column; gap: 2px;
    position: fixed; inset-inline: 10px; bottom: calc(66px + env(safe-area-inset-bottom));
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-md); box-shadow: var(--shadow-md);
    padding: 8px; z-index: 45;
  }
  .nav-more[hidden] { display: none; }
  .nav-more .nav-item {
    flex-direction: row; gap: 11px; font-size: 14.5px; padding: 10px 12px;
    text-align: start; justify-content: flex-start; white-space: normal;
  }
  .nav-more .nav-item svg { width: 18px; height: 18px; }
  .nav-item svg { width: 21px; height: 21px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .search { width: 100%; order: 3; }
  .view { padding: 16px 16px 96px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* טפסים שנבנו כשורה של שדות נמעכים בטלפון עד כדי חוסר שימוש —
     שדה «מחיר» ברוחב שתי ספרות. בצר, כל שדה מקבל שורה משלו. */
  .form-row { grid-template-columns: 1fr !important; }
  .form-row button { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
