@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: #f5f2ec;
  --surface: #ffffff;
  --ink: #14262b;
  --muted: #56666b;      /* 5.9:1 על לבן */
  --line: #e2ddd3;
  --primary: #1d5460;    /* 8.6:1 לטקסט לבן */
  --primary-soft: #e3eef0;
  --in: #1d5a2f;         /* 7.6:1 לטקסט לבן */
  --in-soft: #eaf4ec;
  --out: #8a3b12;        /* 6.6:1 לטקסט לבן */
  --out-soft: #fbeee4;
  --warn-bg: #fff4d9;
  --warn-ink: #7a4f00;   /* 6.5:1 על warn-bg */
  --danger: #a32222;     /* 7.5:1 על לבן */
  --border: #857c70;     /* מסגרות שדות וכפתורים — 4.1:1 על לבן, 3.7:1 על הרקע (לפחות 3:1 לרכיבי ממשק) */
  --focus: #9a6600;      /* טבעת פוקוס — 4.9:1 על לבן, 4.4:1 על הרקע. #c98a00 הקודם נמדד 2.95:1 ונפסל */
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 38, 43, .06), 0 4px 14px rgba(20, 38, 43, .05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Heebo', system-ui, sans-serif;
  font-size: 1rem;       /* לא בפיקסלים: כך הגדלת הטקסט בתפריט הנגישות (ושל הדפדפן) באמת פועלת */
  line-height: 1.45;
}
h1, h2 { margin: 0; font-weight: 700; }
h2 { font-size: 1.25rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; top: -40px; right: 8px; background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip-link:focus { top: 8px; outline-color: #fff; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* על רקע הכותרת הכהה טבעת הזהב נמדדת 1.7:1 — שם הטבעת לבנה (8.4:1) */
.topbar :focus-visible { outline-color: #fff; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--primary); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 28px; height: 28px; }
.brand h1 { font-size: 1.2rem; }
.tabs { display: flex; gap: 4px; }
.tabs a { color: #fff; text-decoration: none; padding: 8px 14px; border-radius: 8px; font-weight: 500; }
.tabs a:hover { background: rgba(255,255,255,.12); }
.tabs a[aria-current="page"] { background: #fff; color: var(--primary); font-weight: 700; }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }
.view > * + * { margin-top: 18px; }

.toast {
  position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow); z-index: 50; max-width: 90vw;
}
.toast.error { background: var(--danger); }

/* ---- שעון ---- */
.clock-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
  display: grid; gap: 14px; grid-template-columns: auto 1fr; align-items: center;
}
.clock-now { display: flex; flex-direction: column; line-height: 1.1; }
.clock-date { color: var(--muted); font-size: .95rem; }
.clock-time { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.clock-controls { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; justify-content: end; }
.branch-field { min-width: 160px; }
.clock-status { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.clock-status.open { color: var(--warn-ink); background: var(--warn-bg); padding: 8px 12px; border-radius: 8px; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: 10px 18px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--ink); background: var(--surface);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #16434d; }
.btn-secondary { background: var(--surface); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--primary-soft); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-in { background: var(--in); color: #fff; font-size: 1.15rem; padding: 12px 28px; }
.btn-out { background: var(--out); color: #fff; font-size: 1.15rem; padding: 12px 28px; }
.btn-in:hover:not(:disabled) { background: #164624; }
.btn-out:hover:not(:disabled) { background: #6e2e0d; }
.icon-btn { font: inherit; font-size: 1.5rem; line-height: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; width: 44px; height: 44px; cursor: pointer; }
.icon-btn:hover { background: var(--primary-soft); }
.spacer { flex: 1; }

/* ---- שדות ---- */
.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.field > span { font-weight: 500; }
.req { font-weight: 400; }
.field input, .field select, .field textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 42px;
}
.field textarea { min-height: 60px; resize: vertical; }
.hint { color: var(--muted); font-size: .9rem; margin: 0; }

/* ---- ניווט חודש ---- */
.month-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.month-nav h2 { min-width: 160px; text-align: center; }
.month-nav input[type="month"] { font: inherit; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; min-height: 44px; }

/* ---- טבלה ---- */
.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.entries { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.entries th, table.entries td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
table.entries th { background: var(--primary-soft); color: var(--ink); font-weight: 600; position: sticky; top: 0; }
table.entries td.wrap { white-space: normal; min-width: 140px; max-width: 280px; }
table.entries td.num { font-variant-numeric: tabular-nums; }
table.entries tbody tr.clickable { cursor: pointer; }
table.entries tbody tr.clickable:hover { background: #faf8f3; }
table.entries tbody tr.open td { background: var(--warn-bg); }
table.entries tbody tr.day-total td { background: #f7f4ee; color: var(--muted); font-size: .9rem; }
table.entries tr.today td:first-child { box-shadow: inset 4px 0 0 var(--in); }
.badge { display: inline-block; font-size: .78rem; padding: 1px 7px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
.badge.clock { background: var(--in-soft); color: var(--in); }
.empty { padding: 24px; text-align: center; color: var(--muted); margin: 0; }
.row-edit { font: inherit; background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; cursor: pointer; color: var(--primary); font-weight: 600; }
.row-edit:hover { background: var(--primary-soft); }

/* ---- סיכומים ---- */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.total { background: var(--primary); color: #fff; }
.stat.total .label { color: #d6e4e7; }
.stat .sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.stat.surgeries { border-inline-start: 4px solid var(--primary); }

.surgeries-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.surgeries-card input { width: 120px; font-size: 1.2rem; }

/* ---- דוחות ---- */
.report-form { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.range-mode { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; display: flex; gap: 14px; margin: 0; }
.range-mode legend { font-size: .85rem; color: var(--muted); padding: 0 4px; }
.range-mode label { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.report-actions { display: flex; gap: 8px; }
.months-list { display: flex; gap: 10px; flex-wrap: wrap; }
.months-list .stat { min-width: 200px; }

/* ---- הגדרות ---- */
.branch-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.branch-list li { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.branch-list li:last-child { border-bottom: 0; }
.branch-list li.inactive .name { color: var(--muted); text-decoration: line-through; }
.branch-list .name { flex: 1; font-weight: 500; }
.branch-list input { font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; flex: 1; }
.inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.link-btn { font: inherit; background: none; border: 0; color: var(--primary); cursor: pointer; text-decoration: underline; padding: 6px; min-height: 36px; }

/* ---- תחתית ---- */
.site-footer { max-width: 1280px; margin: 0 auto; padding: 8px 20px 90px; color: var(--muted); font-size: .9rem; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.site-footer a { color: var(--primary); font-weight: 600; }

/* ---- הצהרת נגישות ---- */
.statement { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 26px; max-width: 820px; margin: 0 auto; }
.statement h1 { font-size: 1.6rem; margin-bottom: 12px; }
.statement h2 { margin-top: 22px; margin-bottom: 8px; }
.statement p, .statement li { line-height: 1.6; }
.statement ul { padding-inline-start: 22px; }
.statement a { color: var(--primary); }
.statement .updated { color: var(--muted); font-size: .9rem; margin: 0 0 6px; }
.topbar .back-link { color: #fff; text-decoration: underline; text-underline-offset: 3px; padding: 8px 14px; border-radius: 8px; }

/* ---- דיאלוג ---- */
dialog { border: 0; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.25); padding: 0; width: min(680px, 94vw); }
dialog::backdrop { background: rgba(20, 38, 43, .45); }
dialog form { padding: 20px 22px; }
dialog h2 { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: 1 / -1; }
.form-hours { margin: 12px 0 0; font-weight: 600; min-height: 1.4em; }
.form-error { margin: 6px 0 0; color: var(--danger); min-height: 1.4em; font-weight: 500; }
.field input[aria-invalid="true"] { border: 2px solid var(--danger); }
.dialog-actions { display: flex; gap: 10px; margin-top: 14px; }

@media (max-width: 720px) {
  main { padding: 12px; }
  .clock-card { grid-template-columns: 1fr; }
  .clock-controls { justify-content: stretch; }
  .clock-controls .btn { flex: 1; justify-content: center; }
  .branch-field { flex-basis: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .tabs a { padding: 8px 10px; }
  .month-nav { display: grid; grid-template-columns: auto 1fr auto; }
  .month-nav h2 { min-width: 0; }
  .month-nav input[type="month"], .month-nav #btn-add { grid-column: 1 / -1; width: 100%; justify-content: center; }
  .month-nav .spacer { display: none; }
  table.entries { font-size: .88rem; }
  /* הטוסט מעל כפתור הנגישות (שמאל-למטה) כדי שלא יוסתר */
  .toast { bottom: 84px; }
}

.print-only { display: none; }

@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4 landscape; margin: 14mm 12mm 16mm; }
  html { font-size: 10pt; }
  body { background: #fff; color: #111; font-size: 10pt; line-height: 1.35; }
  .topbar, .no-print, .clock-card, .surgeries-card, .toast, .skip-link, .row-edit, .site-footer, .empty[hidden] { display: none !important; }
  .print-only { display: block; }
  main { max-width: none; padding: 0; }
  .view > * + * { margin-top: 10pt; }

  /* כותרת הדוח */
  .print-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12pt; border-bottom: 2pt solid var(--primary); padding-bottom: 6pt; }
  .print-header .print-brand { font-size: 10pt; color: var(--primary); font-weight: 600; letter-spacing: .02em; }
  .print-header .print-meta { font-size: 8.5pt; color: #555; }
  .report-head { display: block; margin-top: 6pt; }
  .report-head h2, .print-title { font-size: 18pt; font-weight: 700; color: #111; margin: 0; }

  /* אריחי סיכום: שורה אחת, מסגרת עדינה */
  .summary-grid { grid-template-columns: repeat(6, 1fr); gap: 6pt; page-break-inside: avoid; margin-top: 8pt; }
  .stat { box-shadow: none; border: 1pt solid #d6d2ca; border-radius: 4pt; padding: 6pt 8pt; background: #fff; }
  .stat .label { font-size: 8pt; color: #555; }
  .stat .value { font-size: 14pt; font-weight: 700; color: #111; }
  .stat .sub { font-size: 7.5pt; color: #555; }
  .stat.total { background: var(--primary-soft) !important; color: #111; border-color: var(--primary); }
  .stat.total .label { color: #333; }
  .stat.surgeries { border-inline-start: 3pt solid var(--primary); }

  /* הטבלה */
  .table-wrap { box-shadow: none; border: 0; border-radius: 0; overflow: visible; margin-top: 8pt; }
  table.entries { font-size: 9pt; border-collapse: collapse; }
  table.entries thead { display: table-header-group; }
  table.entries tr { page-break-inside: avoid; }
  table.entries th { background: var(--primary-soft) !important; color: #111; position: static; border: 0; border-bottom: 1.5pt solid var(--primary); padding: 5pt 6pt; font-size: 8.5pt; }
  table.entries td { border: 0; border-bottom: .6pt solid #ddd8ce; padding: 4pt 6pt; white-space: normal; vertical-align: top; }
  table.entries tbody tr:nth-child(even) td { background: #faf8f4; }
  table.entries tbody tr.open td { background: #fff4d9 !important; }
  table.entries tbody tr.day-total td { background: #efece6 !important; color: #333; font-style: italic; font-size: 8.5pt; }
  table.entries tr.today td:first-child { box-shadow: none; }
  table.entries td.wrap { max-width: none; }
  .badge { border: .6pt solid #999; background: #fff; color: #333; font-size: 7pt; padding: 0 4pt; }
  .badge.clock { display: none; }

  /* במסך החודש: הסיכום מודפס מעל הטבלה, כמו בדוח */
  #view-month { display: flex; flex-direction: column; }
  #view-month .print-header { order: 0; }
  #view-month .print-title { order: 1; }
  #view-month .summary-grid { order: 2; margin-top: 8pt; }
  #view-month .table-wrap { order: 3; }

  /* כותרת תחתונה בכל עמוד */
  .print-footer { position: fixed; bottom: 0; inset-inline: 0; font-size: 7.5pt; color: #777; border-top: .6pt solid #ccc; padding-top: 3pt; display: flex; justify-content: space-between; }
}
