/* לוח שלנו — אב־טיפוס. עיצוב לפי שפת הלוח המודפס */
:root {
  --accent: #8b3049;
  --accent-dark: #6e2439;
  --accent-tint: #fdf0f3;
  --accent-border: #ecd3da;
  --bg: #faf6f1;
  --bg2: #f5efe6;
  --card: #fffdf9;
  --line: #eee3d6;
  --line2: #f2e9dd;
  --ink: #3b342e;
  --muted: #6d6355;
  --faint: #9b9083;
  --shabbat: #f1e7cf;
  --shabbat-line: #e2d3ac;
  --memorial: #e9edf1;
  --memorial-ink: #5d6673;
  --ok: #4e7d5b;
  --ok-bg: #eef4ee;
  --warn: #b0672a;
  --warn-bg: #fbf1e4;
  --serif: 'Frank Ruhl Libre', 'Times New Roman', serif;
  --sans: 'Heebo', 'Arial Hebrew', sans-serif;
}
body.theme-blue { --accent: #2f4a6e; --accent-dark: #24395a; --accent-tint: #e8eef5; --accent-border: #cdd9e6; }
body.theme-olive { --accent: #55663c; --accent-dark: #42502e; --accent-tint: #edf0e4; --accent-border: #d6dcc4; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
button { font-family: var(--sans); cursor: pointer; border: none; background: none; font-size: 14px; color: inherit; }
input, select { font-family: var(--sans); font-size: 14px; color: var(--ink); }

.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; padding: 10px 20px; font-weight: 700; font-size: 14px; transition: background .15s, border-color .15s, box-shadow .15s, transform .06s; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: default; pointer-events: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fdf6ee; box-shadow: 0 2px 8px rgba(110,36,57,0.22); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: var(--card); border: 1.5px solid var(--accent); color: var(--accent); font-weight: 500; }
.btn-ghost { background: var(--card); border: 1px solid #d9cbb8; color: var(--muted); font-weight: 500; }
.btn-big { padding: 14px 30px; font-size: 16px; border-radius: 12px; }

.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 0 28px; height: 58px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.logo { font-family: var(--serif); font-weight: 900; font-size: 21px; color: var(--accent); }
.topbar .crumb { font-size: 13.5px; color: var(--muted); }
.nav-tabs { display: flex; gap: 4px; }
.nav-tabs a { padding: 7px 14px; border-radius: 999px; font-size: 13.5px; color: var(--muted); }
.nav-tabs a.active { background: var(--accent); color: #fdf6ee; font-weight: 700; }
.nav-tabs a:hover:not(.active) { background: var(--bg2); }

.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; font-size: 11.5px; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-accent { background: var(--accent-tint); color: var(--accent); border: 1px solid var(--accent-border); }
.chip-plain { background: var(--bg2); color: var(--muted); border: 1px solid var(--line); }

.page-wrap { max-width: 1180px; margin: 0 auto; padding: 30px 28px 60px; }
h1.page-title { font-family: var(--serif); font-weight: 900; font-size: 30px; color: var(--accent-dark); margin: 0 0 6px; }
.page-sub { color: var(--faint); font-size: 14.5px; line-height: 1.6; margin: 0 0 22px; max-width: 780px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex-grow: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.serif { font-family: var(--serif); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-off { background: #c2c2c2; }

/* ---------- landing ---------- */
.hero { display: flex; gap: 48px; align-items: center; padding: 40px 0 30px; }
.hero h1 { font-family: var(--serif); font-weight: 900; font-size: 44px; line-height: 1.2; color: var(--accent-dark); margin: 0 0 16px; }
.hero p { font-size: 16.5px; line-height: 1.65; color: var(--muted); margin: 0 0 22px; max-width: 520px; }

/* ---------- wizard ---------- */
.steps { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.step-pill { border-radius: 999px; padding: 4px 12px; background: var(--card); border: 1px solid #e0d5c5; color: #a2988a; }
.step-pill.active { background: var(--accent); color: #fdf6ee; border-color: var(--accent); font-weight: 700; }
.step-pill.done { color: var(--ok); border-color: var(--ok-bg); background: var(--ok-bg); }
.step-line { width: 16px; height: 1.5px; background: #d9cbb8; }
.tmpl-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; margin: 20px 0; }
.tmpl-card { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.tmpl-card.selected { border-color: var(--accent); box-shadow: 0 4px 14px rgba(110,36,57,0.14); }
.tmpl-thumb { border-radius: 8px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 10px; }
.tmpl-head { height: 56px; }
.tmpl-body { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.tmpl-mini-grid { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 3px; height: 42px; }
.tmpl-mini-grid div { border-radius: 2px; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 6px; }
.field input, .field select { width: 100%; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 13px; font-size: 15px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

/* ---------- tree ---------- */
.tree-root { background: var(--accent-dark); color: #fdf6ee; border-radius: 12px; padding: 12px 28px; display: inline-flex; flex-direction: column; align-items: center; box-shadow: 0 3px 10px rgba(110,36,57,0.25); }
.branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; align-items: start; }
.branch-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 13px; display: flex; flex-direction: column; gap: 7px; }
.branch-card.expanded { border: 1.5px solid var(--accent); }
.subbranch { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.branch-actions { display: flex; gap: 10px; margin-top: 2px; }
.branch-actions button { font-size: 12px; color: var(--accent); font-weight: 500; display: inline-flex; align-items: center; gap: 4px; padding: 0; }
.add-branch { border: 1.5px dashed #d9cbb8; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 100px; color: var(--accent); cursor: pointer; }

/* ---------- fill page ---------- */
.fill-shell { max-width: 640px; margin: 0 auto; background: var(--bg); min-height: 100vh; border-inline: 1px solid var(--line); }
.fill-head { background: var(--bg2); border-bottom: 1px solid var(--line); padding: 16px 18px 20px; }
.fill-head h1 { font-family: var(--serif); font-weight: 900; font-size: 26px; color: var(--accent-dark); margin: 6px 0; }
.fill-section { padding: 18px 14px 4px; }
.fill-section h2 { font-family: var(--serif); font-weight: 700; font-size: 18px; margin: 0; }
.person-row { display: flex; align-items: center; gap: 10px; padding: 12px 13px; border-bottom: 1px solid var(--line2); }
.person-row:last-child { border-bottom: none; }
.date-badge { text-align: left; }
.date-badge .heb { font-size: 14px; font-weight: 700; color: var(--accent); display: block; }
.date-badge .greg { font-size: 11px; color: var(--faint); }
.mini-input { background: #fff; border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; width: 100%; }
.mini-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.toggle { width: 36px; height: 21px; border-radius: 999px; background: #ddd2c2; padding: 2px; display: inline-flex; transition: background .15s; flex-shrink: 0; }
.toggle .knob { width: 17px; height: 17px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 2px rgba(59,52,46,.25); transition: transform .15s; }
.toggle.on { background: var(--ok); }
.toggle.on .knob { transform: translateX(-15px); }

/* crop preview */
.crop-box { position: relative; width: 128px; height: 156px; border-radius: 10px; overflow: hidden; border: 1.5px solid var(--accent); background: #fff; touch-action: none; }
.crop-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.crop-pill { position: absolute; top: 5px; right: 5px; background: rgba(253,246,238,.94); border-radius: 8px; padding: 2px 7px; text-align: center; z-index: 2; cursor: grab; touch-action: none; user-select: none; }
.crop-pill:active { cursor: grabbing; }
.age-badge { position: absolute; top: 4px; left: 5px; z-index: 2; width: 24px; height: 36px; cursor: grab; touch-action: none; user-select: none; filter: drop-shadow(0 1px 2px rgba(59,52,46,.35)); }
.age-badge svg { display: block; width: 100%; height: 100%; }
.age-badge:active { cursor: grabbing; }
.crop-pill .d { font-family: var(--serif); font-weight: 900; font-size: 14px; color: var(--accent); line-height: 1.1; display: block; }
.crop-pill .g { font-size: 8.5px; color: var(--faint); }
.crop-banner { position: absolute; bottom: 0; right: 0; left: 0; background: var(--accent); color: #fdf6ee; font-size: 10.5px; font-weight: 500; text-align: center; padding: 4px 2px; z-index: 2; }
.crop-hint { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 11.5px; color: var(--muted); }

/* ---------- dashboard ---------- */
.dash-cols { display: flex; gap: 18px; align-items: flex-start; }
.dash-side { width: 330px; flex-shrink: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 15px 17px; }
.kpi .n { font-family: var(--serif); font-weight: 900; font-size: 27px; }
.kpi .bar { height: 5px; border-radius: 999px; background: #efe6d8; margin-top: 8px; overflow: hidden; }
.kpi .bar > div { height: 100%; border-radius: 999px; background: var(--accent); }
.table-head, .table-row { display: grid; grid-template-columns: 1.4fr 1.1fr 1.1fr 1.3fr; gap: 8px; align-items: center; padding: 12px 18px; }
.table-head { font-size: 12px; color: var(--faint); border-bottom: 1px solid var(--line2); padding: 8px 18px; }
.table-row { border-bottom: 1px solid #f7f0e5; font-size: 13.5px; }
.table-row:last-child { border-bottom: none; }
.pbar { width: 60px; height: 5px; border-radius: 999px; background: #efe6d8; display: inline-block; overflow: hidden; vertical-align: middle; }
.pbar > div { height: 100%; border-radius: 999px; }

/* ---------- conflicts ---------- */
.conflict-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 17px 19px; display: flex; gap: 16px; margin-bottom: 14px; }
.conflict-card.resolved { background: #fdfaf5; border-color: #ece1d0; }
.conflict-card h3 { font-size: 15.5px; margin: 0; }
.conflict-card p { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin: 6px 0 10px; }
.conflict-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.conflict-actions .btn { padding: 8px 18px; font-size: 13px; border-radius: 9px; }

/* ---------- calendar pages ---------- */
.pages-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-a4 { width: 1123px; height: 794px; background: #fff; border: 1px solid #e0d5c5; box-shadow: 0 8px 26px rgba(59,52,46,.12); margin: 0 auto 26px; padding: 20px 30px; display: flex; flex-direction: column; page-break-after: always; break-after: page; overflow: hidden; }
.photo-hero { flex-grow: 1; background: #d8cfc2; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #8f8578; font-size: 14px; margin-top: 10px; overflow: hidden; }
.photo-hero img { width: 100%; height: 100%; object-fit: cover; }
.photo-name-band { display: flex; align-items: baseline; justify-content: center; gap: 14px; padding: 16px 0 4px; flex-shrink: 0; }
.photo-name-band .m { font-family: var(--serif); font-weight: 900; font-size: 52px; color: var(--accent); }
.photo-name-band .y { font-family: var(--serif); font-weight: 700; font-size: 22px; }
.photo-name-band .range { font-size: 12px; color: var(--faint); }
.grid-title { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 2px 6px; flex-shrink: 0; }
.grid-title .m { font-family: var(--serif); font-weight: 900; font-size: 26px; color: var(--accent); }
.grid-title .y { font-family: var(--serif); font-weight: 700; font-size: 15px; margin-inline-start: 7px; }
.grid-title .range { font-size: 11px; color: var(--faint); }
.bind-margin { border: 1.5px dashed #c9a2af; background: var(--accent-tint); border-radius: 4px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--accent); flex-shrink: 0; }
.month-header { display: flex; align-items: baseline; justify-content: space-between; margin: 14px 2px 10px; }
.month-header .m { font-family: var(--serif); font-weight: 900; font-size: 40px; color: var(--accent); }
.month-header .y { font-family: var(--serif); font-weight: 700; font-size: 18px; margin-inline-start: 8px; color: var(--ink); }
.month-header .range { font-size: 11.5px; color: var(--faint); }
.month-photo { height: 150px; background: #d8cfc2; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #8f8578; font-size: 12px; flex-shrink: 0; }
.wk-head { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 6px; font-size: 11.5px; color: var(--accent); font-weight: 700; text-align: center; margin: 10px 0 4px; }
.wk-grid { display: flex; flex-direction: column; gap: 6px; flex-grow: 1; }
.wk-row { display: grid; gap: 6px; flex-grow: 1; flex-basis: 0; min-height: 0; }
.day-cell { border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 5px 7px; position: relative; overflow: hidden; min-height: 74px; }
.day-cell .hd { font-family: var(--serif); font-weight: 900; font-size: 15px; }
.day-cell .gd { font-size: 8.5px; color: var(--faint); float: left; margin-top: 3px; }
.day-cell.shabbat { background: var(--shabbat); border-color: var(--shabbat-line); }
.day-cell.shabbat .hd { color: var(--accent); }
.day-cell.holiday { background: var(--accent-tint); border-color: var(--accent-border); }
.day-cell.holiday .hd { color: var(--accent); }
.day-cell.memorial { background: var(--memorial); border-color: #dde3e8; }
.day-cell.memorial .memo { display: flex; flex-direction: column; align-items: center; gap: 3px; margin-top: 6px; font-size: 8.5px; color: var(--memorial-ink); text-align: center; line-height: 1.4; }
.day-cell.event { border: 1.5px solid var(--accent); padding: 0; }
.day-cell.event .photo-wrap { position: absolute; inset: 0; display: flex; gap: 1px; }
.day-cell.event .photo-wrap img { width: 100%; height: 100%; object-fit: cover; flex: 1 1 0; min-width: 0; }
.day-cell.event .cell-pill { position: absolute; top: 4px; right: 4px; background: rgba(253,246,238,.94); border-radius: 6px; padding: 1px 6px; z-index: 2; text-align: center; }
.day-cell.event .cell-pill .d { font-family: var(--serif); font-weight: 900; font-size: 12px; color: var(--accent); display: block; line-height: 1.15; }
.day-cell.event .cell-pill .g { font-size: 7px; color: var(--faint); }
.day-cell.event .cell-banner { position: absolute; bottom: 0; left: 0; right: 0; background: var(--accent); color: #fdf6ee; font-size: 8.5px; font-weight: 500; text-align: center; padding: 3px 2px; z-index: 2; }
.day-cell.event.no-photo { padding: 5px 7px; background: var(--accent-tint); }
.day-cell.event.no-photo .evt-name { font-size: 9px; color: var(--accent); font-weight: 700; margin-top: 4px; line-height: 1.3; }
.cover-page { align-items: stretch; }
/* עמודי ה-A4 מוקטנים להתאמה לרוחב החלון (zoom נקבע ב-JS); בייצוא ובהדפסה — גודל מלא */
.pages-scale { }
.pages-scale-wrap { }

/* מצב ייצוא/הדפסה: משבצות שעוד אין בהן תמונה יוצאות לבנות ונקיות —
   בלי "העלאת תמונה" ובלי "עדיין בלי תמונה" בלוח המודפס */
body.exporting .ph-ui { display: none !important; }
body.exporting .photo-hero.empty { background: #fff; }
body.exporting .ph-half { background: #fff !important; }
body.exporting .ph-half span { visibility: hidden; }
body.exporting .pages-scale { zoom: 1 !important; }

.notice { background: var(--warn-bg); border: 1px solid #eeddc4; color: #7a5a2e; border-radius: 10px; padding: 10px 14px; font-size: 12.5px; line-height: 1.5; }
.ad-slot { margin: 14px 16px; padding: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 4px; }
.day-cell.event.editable { cursor: pointer; }
.day-cell.event.editable:hover { box-shadow: 0 0 0 2px var(--accent-border); }
.day-cell.event.memorial-photo { border-color: #8a94a0; }
.day-cell.event.memorial-photo .photo-wrap img { filter: grayscale(.3) brightness(.99); }
.overlay { position: fixed; inset: 0; background: rgba(59,52,46,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.overlay .panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; width: 380px; max-height: 86vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 18px 50px rgba(40,30,25,.3); }
.overlay .panel > * { flex-shrink: 0; }

.add-dash { border: 1.5px dashed #d9cbb8; border-radius: 12px; padding: 11px; text-align: center; color: var(--accent); font-weight: 500; cursor: pointer; }
.add-dash:hover { border-color: var(--accent); background: var(--accent-tint); }
/* מילוי מהיר — בוררי סוג/חודש/יום; בטלפון קטן מתכווצים לטובת שדה השם */
.qk-t { width: 84px; flex-shrink: 0; padding-inline: 7px; }
.qk-m { width: 92px; flex-shrink: 0; padding-inline: 7px; }
.qk-d { width: 62px; flex-shrink: 0; padding-inline: 7px; }
@media (max-width: 400px) { .qk-t { width: 76px; } .qk-m { width: 86px; } .qk-d { width: 58px; } }

/* ריבוע תמונה בשורת הרשימה — העלאה ישירה בלי לפתוח את הכרטיס */
.row-photo-add { width: 34px; height: 42px; border-radius: 7px; border: 1.5px dashed #cbbfae; display: flex; align-items: center; justify-content: center; color: var(--accent); cursor: pointer; flex-shrink: 0; }
.row-photo-add:hover { border-color: var(--accent); background: var(--accent-tint); }
.row-photo-add.mem { color: var(--faint); }

/* inline add-forms */
.add-form { background: var(--card); border: 1.5px solid var(--accent); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; margin-top: 10px; box-shadow: 0 4px 14px rgba(110,36,57,.10); }
.add-form .title { font-size: 13.5px; font-weight: 700; color: var(--accent-dark); }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { flex: 1 1 0; padding: 9px 6px; font-size: 13.5px; color: var(--muted); border-inline-start: 1px solid var(--line); }
.seg button:first-child { border-inline-start: none; }
.seg button.on { background: var(--accent); color: #fdf6ee; font-weight: 700; }
.add-form .actions { display: flex; gap: 9px; justify-content: flex-end; }
.add-form .actions .btn { padding: 8px 18px; font-size: 13.5px; border-radius: 9px; }

/* מסכי הניהול מתקפלים יפה גם בחלון צר / טלפון (דפי המילוי בנויים לנייד ממילא) */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; height: auto; min-height: 54px; padding: 8px 14px; gap: 6px 12px; }
  .topbar .crumb { display: none; }
  .nav-tabs { order: 10; width: 100%; justify-content: flex-start; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs a { flex-shrink: 0; }
  .page-wrap { padding: 20px 14px 48px; }
  h1.page-title { font-size: 25px; }
  .hero { flex-direction: column; align-items: center; padding: 20px 0 10px; gap: 28px; }
  .hero h1 { font-size: 31px; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dash-cols { flex-direction: column; }
  .dash-side { width: auto; align-self: stretch; }
  .table-head, .table-row { grid-template-columns: 1.2fr 1fr 1fr 1.1fr; gap: 5px; padding: 10px 12px; font-size: 12.5px; }
  .page-wrap .row, .fill-section .row { flex-wrap: wrap; }
  .pages-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .pages-toolbar .row { flex-wrap: wrap; }
  .fill-shell { border-inline: none; }
}

@media print {
  body { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .pages-toolbar, .no-print { display: none !important; }
  .pages-scale { transform: none; zoom: 1 !important; }
  .page-a4 { border: none; box-shadow: none; margin: 0; width: auto; height: 100vh; }
  .ph-ui { display: none !important; }
  .photo-hero.empty { background: #fff; }
  .ph-half { background: #fff !important; }
  .ph-half span { visibility: hidden; }
  @page { size: A4 landscape; margin: 0; }
}
