@font-face {
  font-family: 'Heebo';
  src: url('fonts/heebo-hebrew.woff2') format('woff2');
  font-weight: 100 900;
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
  font-display: swap;
}
@font-face {
  font-family: 'Heebo';
  src: url('fonts/heebo-latin.woff2') format('woff2');
  font-weight: 100 900;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}

:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --ink: #12233d;
  --muted: #52607a;      /* 6.3:1 על לבן, 5.8:1 על --bg */
  --line: #dbe2ea;
  --primary: #193e70;    /* כחול אסותא אופטיק. 10.7:1 לטקסט לבן */
  --primary-soft: #e4ecf6;
  --accent: #8a5a00;     /* 5.6:1 על --note-bg */
  --note-bg: #fff4d9;
  --today-bg: #eef6e2;
  --today-ink: #3f6a12;  /* ירוק כהה לטקסט: 6.4:1 על לבן, 5.8:1 על --today-bg */
  --brand-green: #83b241; /* ירוק אסותא אופטיק. לקישוט בלבד: לבן עליו רק 2.5:1 */
  --late-ink: #9a3b00;   /* 5.8:1 על לבן */
  --danger: #a32222;
  --focus: #0b63ce;      /* 5.7:1 על לבן */
  --focus-dark: #b5dc7a; /* מסגרת מיקוד על הכותרת הכחולה: 6.9:1 */
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 'Heebo', Arial, sans-serif;
}
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- כותרת ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  border-bottom: 4px solid var(--brand-green);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button {
  font: inherit; font-size: 15px; color: #dfe8f5; background: transparent;
  border: 0; padding: 8px 14px; border-radius: 8px; cursor: pointer;
}
.tabs button:hover { background: rgba(255,255,255,.12); }
.tabs button[aria-selected="true"] { background: #fff; color: var(--primary); font-weight: 600; }
.top :focus-visible { outline-color: var(--focus-dark); }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }

/* ---------- סרגל ---------- */
.toolbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 16px;
}
h1 { font-size: 26px; margin: 0; line-height: 1.2; }
h2 { font-size: 19px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 15px; }
.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #7f8ba0; border-radius: 8px; padding: 8px 10px;
  min-height: 42px;
}
textarea { resize: vertical; width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
.search input { width: 320px; max-width: 100%; }

.btn {
  font: inherit; font-size: 15px; font-weight: 600;
  min-height: 42px; padding: 8px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid #7f8ba0; background: #fff; color: var(--ink);
}
.btn:hover { background: #eef2f7; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #12305a; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.small.done-btn { background: #e3f0d0; border-color: #b5d38a; color: #3f6a12; }
.btn.small.done-btn:hover { background: #d6e9bb; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 14px; font-weight: 500; }
.link-btn {
  font: inherit; font-size: 14px; background: none; border: 0; padding: 2px 4px;
  color: var(--primary); text-decoration: underline; cursor: pointer;
}
.link-btn.danger { color: var(--danger); }

/* ---------- טבלה ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto;
}
.grid { width: 100%; border-collapse: collapse; font-size: 15px; }
.grid th {
  text-align: right; font-weight: 600; color: var(--muted); font-size: 13px;
  padding: 12px; border-bottom: 1px solid var(--line); background: #f6f8fb; white-space: nowrap;
}
.grid td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tr.is-today td { background: var(--today-bg); }
.grid tr.is-today td:first-child { box-shadow: inset -4px 0 0 var(--brand-green); }
.cell-name { font-weight: 600; }
.cell-id { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.cell-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-notes { min-width: 200px; max-width: 360px; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-actions { display: flex; gap: 6px; margin-top: 4px; }
.muted { color: var(--muted); }
.actions { white-space: nowrap; text-align: left; }
.actions .btn + .btn { margin-inline-start: 6px; }

.badge {
  display: inline-block; font-size: 12px; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 999px; margin-top: 4px; white-space: nowrap;
}
.badge.today { background: #d6e9bb; color: var(--today-ink); }
.badge.past { background: #fde6d6; color: var(--late-ink); }
.badge.sent { background: var(--primary-soft); color: var(--primary); }
/* צבע הרקע של בחירת הסטטוס לפי הסטטוס הנוכחי */
.status-select { min-height: 34px; padding: 4px 8px; font-size: 14px; font-weight: 600; border-radius: 999px; }
/* צבעי הסטטוסים. אותם שישה צבעים לרשימת הבחירה ולתווית; הניגודיות של כל זוג מחושבת (4.5:1 ומעלה). */
.status-select.sc-blue, .status-pill.sc-blue   { background: var(--primary-soft); color: var(--primary); border-color: #b3c6e0; }  /* 9.0:1 */
.status-select.sc-yellow, .status-pill.sc-yellow { background: #fff1cc; color: #6b4a00; border-color: #e6cf8f; }                     /* 7.0:1 */
.status-select.sc-green, .status-pill.sc-green  { background: #e3f0d0; color: var(--today-ink); border-color: #b5d38a; }            /* 5.4:1 */
.status-select.sc-grey, .status-pill.sc-grey   { background: #e9ecf0; color: #4a4a4a; border-color: #c5ccd6; }                     /* 7.4:1 */
.status-select.sc-orange, .status-pill.sc-orange { background: #fde6d6; color: var(--late-ink); border-color: #f0c4a6; }             /* 5.3:1 */
.status-select.sc-purple, .status-pill.sc-purple { background: #ece6f7; color: #4b2a86; border-color: #cdbfe8; }                     /* 8.6:1 */

.empty { text-align: center; color: var(--muted); padding: 40px 16px; margin: 0; }

/* ---------- סינון ---------- */
.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-group label { font-size: 14px; color: var(--muted); }
.date-text { width: 140px; direction: ltr; text-align: right; }
.seg { display: flex; border: 0; padding: 0; margin: 0; gap: 4px; background: #e9eef4; border-radius: 9px; padding: 3px; }
.seg label {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 7px;
  cursor: pointer; font-size: 14px;
}
.seg input { min-height: 0; margin: 0; accent-color: var(--primary); }
.seg label:has(input:checked) { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }
#report-summary { margin: 0 0 10px; }

/* ---------- הגדרות ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; max-width: 560px;
}
.settings label { display: block; font-weight: 600; margin: 16px 0 6px; }
.settings input { width: 100%; text-align: left; }
.settings .hint { margin-top: 6px; }
.status-line { margin: 12px 0 0; min-height: 1.5em; }
.status-line.ok { color: var(--today-ink); }
.status-line.err { color: var(--danger); }

/* ---------- טופס ---------- */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(680px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(12, 30, 60, .3); color: var(--ink);
}
dialog::backdrop { background: rgba(14, 28, 52, .5); }
dialog form { padding: 24px; }
#confirm-dialog { width: min(440px, calc(100vw - 32px)); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin-top: 12px; }
.field { display: flex; flex-direction: column; }
.field.wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 14px; margin: 8px 0 4px; }
.field .date-text { width: 100%; }
.req { color: var(--danger); }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.field-error { color: var(--danger); font-size: 13px; margin: 4px 0 0; min-height: 0; }
.field-error:empty { display: none; }
[aria-invalid="true"] { border-color: var(--danger); }
.row-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.row-actions.end { justify-content: flex-start; }
.row-actions:has(> [hidden]:only-child) { display: none; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- תוספות: כניסה, משתמשים, הרשאות ---------- */
/* מה שמנהל לא רואה / מה שעובד לא רואה */
body:not(.is-admin) .admin-only { display: none !important; }
body:not(.is-employee) .employee-only { display: none !important; }

.skip-link {
  position: absolute; top: -60px; right: 12px; z-index: 10;
  background: #fff; color: var(--primary); font-weight: 600;
  padding: 10px 16px; border-radius: 8px; border: 2px solid var(--primary);
}
.skip-link:focus { top: 12px; }
main:focus { outline: none; }

.who { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.who-name { color: #fff; }
.btn.ghost { background: transparent; border-color: #dfe8f5; color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.14); }
.btn.block { display: block; width: 100%; margin-top: 18px; }

.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #193e70 0%, #12305a 100%);
}
.auth-card {
  width: min(420px, 100%); background: var(--surface); border-radius: 14px;
  padding: 28px 28px 24px; border-top: 6px solid var(--brand-green);
  box-shadow: 0 20px 60px rgba(8, 20, 45, .35);
}
.auth-brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
  font-size: 20px; font-weight: 700; color: var(--primary);
}
.auth-brand img { border-radius: 10px; }
.auth-card h1 { font-size: 22px; margin: 0 0 4px; }
.auth-card label { display: block; font-weight: 600; font-size: 15px; margin: 16px 0 6px; }
.auth-card input { width: 100%; text-align: left; }
.auth-card .link-btn { margin-top: 14px; font-size: 15px; padding: 6px 4px; }
.auth-card .hint { margin-top: 6px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-notice {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary); font-size: 15px;
}
.auth-notice:empty { display: none; }
.code-input {
  font-size: 26px; letter-spacing: 8px; text-align: center !important;
  font-variant-numeric: tabular-nums; font-weight: 600;
}

/* תווית סטטוס לקריאה בלבד (מנהל), באותם צבעים של רשימת הבחירה */
.status-pill {
  display: inline-block; font-size: 14px; font-weight: 600; line-height: 1.2;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent;
}

/* ---------- הגדרות (מנהל): רשימות לעריכה ---------- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.card h3 { font-size: 16px; margin: 20px 0 0; }
.opt-list { list-style: none; margin: 8px 0 0; padding: 0; }
.opt-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.opt-row:last-child { border-bottom: 0; }
.opt-main { flex: 1 1 140px; min-width: 0; }
.opt-name { font-weight: 600; overflow-wrap: anywhere; }
.opt-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.opt-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-inline-start: auto; }
.empty.small { padding: 16px 8px; font-size: 15px; }
.choice { border: 0; padding: 0; margin: 8px 0 0; min-width: 0; }
.choice legend, .field-label { font-weight: 600; font-size: 14px; padding: 0; margin: 8px 0 4px; }
.choice label { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; font-size: 15px; margin: 0; padding: 8px 0; cursor: pointer; }
.choice input { flex: none; width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; padding: 0; accent-color: var(--primary); }
.choice[disabled] label { cursor: default; color: var(--muted); }
.preview { margin: 4px 0 0; min-height: 34px; display: flex; align-items: center; }
#e-surgeon { margin-top: 8px; }
.cell-owner { font-weight: 600; color: var(--primary); white-space: nowrap; }
.cell-email { direction: ltr; text-align: right; overflow-wrap: anywhere; }
.owner-filter select { min-width: 150px; }
.filter-group input[type="search"] { width: 220px; max-width: 100%; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; max-width: 1100px; }
.cards .card { max-width: none; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 8px 0 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* לשוניות: בשולחן עבודה טקסט מלא בלי אייקון; בנייד אייקון ושם קצר (ראו למטה) */
.tab-icon, .tab-short { display: none; }
button, select, input, textarea, label, a { touch-action: manipulation; }
body { -webkit-tap-highlight-color: transparent; }

/* ---------- נייד: המערכת מתנהגת כמו אפליקציה ----------
   סרגל ניווט תחתון, שורות ככרטיסים, כפתורים בגודל מגע (44px ומעלה), טפסים במסך מלא.
   900px ולא 760px, כדי שגם טלפון במצב שוכב יקבל את התצוגה הזו. */
@media (max-width: 900px) {
  /* שדות ב-16px ומעלה: אחרת iPhone מגדיל את המסך בכל הקלדה */
  input, select, textarea { font-size: 16px; min-height: 46px; }
  .btn, .btn.small { min-height: 44px; padding: 8px 14px; font-size: 15px; }
  .link-btn { padding: 10px 6px; font-size: 15px; min-height: 40px; }
  h1 { font-size: 22px; }

  /* כותרת עליונה דקה שנשארת במקום */
  .top {
    position: sticky; top: 0; z-index: 15; flex-wrap: nowrap; gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-left)) 8px max(14px, env(safe-area-inset-right));
    border-bottom-width: 3px;
  }
  .brand { font-size: 17px; min-width: 0; }
  .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .who { flex: none; }
  .who-name { display: none; }
  .who .btn { min-height: 40px; padding: 6px 14px; }

  /* סרגל ניווט תחתון */
  .tabs {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
    padding: 5px max(6px, env(safe-area-inset-left)) calc(5px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right));
    background: #fff; border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(12, 30, 60, .08);
  }
  .tabs button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 54px; padding: 5px 2px; border-radius: 12px;
    font-size: 12px; font-weight: 500; line-height: 1.2; color: var(--muted);  /* 6.3:1 על לבן */
  }
  .tabs button:hover { background: #f1f4f8; }
  .tabs button[aria-selected="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; } /* 8.8:1 */
  .tabs :focus-visible, .top .tabs :focus-visible { outline-color: var(--focus); outline-offset: -2px; }
  .tab-icon { display: block; }
  .tab-long { display: none; }
  .tab-short { display: block; }

  main {
    padding: 14px max(14px, env(safe-area-inset-left)) calc(92px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-right));
  }
  /* מקום לכפתור ההוספה הצף, שלא יסתיר את הכרטיס האחרון */
  body.is-employee #view-active { padding-bottom: 64px; }

  .toolbar { margin-bottom: 12px; gap: 10px; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .search { flex: 1 1 100%; }
  .search input, .owner-filter, .owner-filter select { width: 100%; }

  /* כפתור הוספה צף מעל הסרגל התחתון */
  #add-btn {
    position: fixed; z-index: 18;
    inset-inline-end: max(14px, env(safe-area-inset-left));
    bottom: calc(76px + env(safe-area-inset-bottom));
    min-height: 52px; padding: 0 22px; border-radius: 999px; font-size: 16px;
    box-shadow: 0 6px 18px rgba(12, 30, 60, .35);
  }

  /* ----- שורות ככרטיסים ----- */
  .table-wrap { background: transparent; border: 0; overflow: visible; }
  .grid thead { display: none; }
  .grid, .grid tr, .grid td { display: block; width: 100%; }
  /* align-items: start — כשיש שני טורים (טלפון שוכב), כל כרטיס בגובה של עצמו */
  .grid tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; width: 100%; align-items: start; }
  .grid tr {
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    padding: 12px 14px; box-shadow: 0 1px 3px rgba(12, 30, 60, .06);
  }
  .grid td { border: 0; padding: 5px 0; display: flex; gap: 10px; max-width: none; min-width: 0; }
  .grid td::before {
    content: attr(data-label); flex: 0 0 104px; color: var(--muted); font-size: 13px; padding-top: 3px;
  }
  .grid td.cell-id, .grid td.cell-email { direction: rtl; }
  .grid tr.is-today { background: var(--today-bg); border-color: #b5d38a; }
  .grid tr.is-today td { background: transparent; }
  .grid tr.is-today td:first-child { box-shadow: none; }
  .grid td.actions {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start;
    border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px;
  }
  .grid td.actions::before { display: none; }
  .grid td.actions .btn { flex: 1 1 auto; margin: 0; }
  .grid td.actions:empty { display: none; }

  /* כרטיס של ניתוח: השם והסטטוס בשורה הראשונה, שדות ריקים לא מוצגים */
  .grid.patients tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; align-items: center; }
  .grid.patients td { grid-column: 1 / -1; }
  .grid.patients td.cell-name { grid-column: 1; grid-row: 1; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
  .grid.patients td.cell-status { grid-column: 2; grid-row: 1; width: auto; }
  .grid.patients td.cell-name::before, .grid.patients td.cell-status::before { display: none; }
  .grid.patients td.is-empty { display: none; }
  .grid.patients td.cell-notes { min-width: 0; }
  .status-select { min-height: 40px; font-size: 15px; padding: 4px 10px; }
  .cell-date .badge { margin-top: 0; align-self: center; }
  .note-actions { gap: 4px; margin-top: 0; }

  /* ----- סינון הדוח ----- */
  .filters { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 14px; }
  .filter-group { gap: 4px 8px; }
  .filter-group label { flex: 0 0 100%; }
  .filter-group select, .filter-group input, .filter-group input[type="search"], .filter-group .date-text {
    flex: 1 1 0; width: auto; min-width: 0;
  }
  .filters > .btn { width: 100%; }
  .seg { position: relative; }
  .seg label { flex: 1; justify-content: center; text-align: center; padding: 10px 4px; min-height: 44px; font-size: 14px; }
  /* העיגול של כפתור הרדיו מוסתר; המקלדת עדיין מגיעה אליו, והמסגרת מוצגת על התווית */
  .seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
  .seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }

  .cards { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 18px 16px; }
  .auth { padding: calc(20px + env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom)); min-height: 100dvh; }
  .auth-card { padding: 22px 18px 20px; }
  .auth-card .link-btn { margin-top: 8px; }
  .btn.block { min-height: 50px; font-size: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .field .date-text, .date-text { width: 100%; }

  /* ----- טפסים במסך מלא, עם כפתורי שמירה שנשארים למטה ----- */
  dialog.full {
    width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: none;
    margin: 0; border-radius: 0;
  }
  dialog.full form {
    min-height: 100%; display: flex; flex-direction: column;
    padding: calc(16px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
  }
  dialog.full .row-actions.end {
    position: sticky; bottom: 0; margin: auto -16px 0; flex-wrap: nowrap;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--line);
  }
  dialog.full .row-actions.end .btn { flex: 1; min-height: 50px; font-size: 16px; }
  dialog.full form > .field-error { margin-bottom: 12px; }
  .choice label { min-height: 44px; align-items: center; }
  .choice input { margin: 0; }

  /* אישור: גיליון שעולה מלמטה */
  #confirm-dialog {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0;
  }
  #confirm-dialog form { padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); }
  #confirm-dialog .row-actions.end { flex-wrap: nowrap; }
  #confirm-dialog .row-actions.end .btn { flex: 1; min-height: 50px; font-size: 16px; }

  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); width: max-content; text-align: center; }
}

/* טלפון שוכב: הגובה קטן, ולכן הכותרת נגללת עם הדף והסרגל התחתון נמוך יותר */
@media (max-width: 900px) and (max-height: 480px) {
  .top { position: static; }
  .tabs button { flex-direction: row; gap: 8px; min-height: 44px; font-size: 14px; }
  main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  #add-btn { bottom: calc(64px + env(safe-area-inset-bottom)); min-height: 46px; }
  .toast { bottom: calc(70px + env(safe-area-inset-bottom)); }
}

/* טלפון צר במיוחד: התוויות בכרטיס צרות יותר */
@media (max-width: 360px) {
  .grid td::before { flex-basis: 88px; }
  .tabs button { font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
