/* ==========================================================================
   מהדרין — עיצוב
   זית עמוק לפעולה ולמה שתקין, קרום-לחם (ענבר) למה שדורש תשומת לב, אדום רק לאיחור/מחיקה.
   רקע אפור-ירקרק בהיר (לא שמנת), לבן למשטחי עבודה. בלי צללים — קו דק מפריד.
   טקסט 17px (המשתמש העיקרי — אבא, בטלפון), מטרות לחיצה 44px לפחות, מספרים בספרות טבלאיות.
   Rubik לכל הטקסט; Fredoka רק לסימן המסחרי ולכותרת התאריך הגדולה. הגופנים מהשרת עצמו (נטפרי).
   ========================================================================== */
@font-face { font-family: 'Rubik'; font-style: normal; font-weight: 300 900; font-display: swap; src: url(/fonts/rubik-hebrew.woff2) format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: 'Rubik'; font-style: normal; font-weight: 300 900; font-display: swap; src: url(/fonts/rubik-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/fredoka-hebrew.woff2) format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/fredoka-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --paper: #f3f5ef;
  --card: #ffffff;
  --ink: #18231c;
  --ink-2: #4b574f;
  --ink-3: #6f7a72;
  --rule: #d9dfd5;
  --rule-2: #e9ede6;
  --olive: #3b6b32;
  --olive-deep: #284d22;
  --olive-wash: #e4eedf;
  --crust: #c98a2b;
  --crust-text: #8c560e;
  --crust-wash: #fbf0dc;
  --red: #a8322a;
  --red-wash: #f8e4e1;
  --focus: #3b6b32;
  --r: 10px;
  --nav-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 17px/1.5 'Rubik', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--olive-deep); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------- מבנה ---------------- */
.app { min-height: 100vh; }
.side { display: none; }
.main { padding: 0 0 calc(var(--nav-h) + 24px); min-width: 0; }
.top {
  position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; min-height: 58px;
}
.top h1 { font-size: 20px; font-weight: 600; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .back { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; margin-inline-start: -8px; }
.top .back:hover { background: var(--rule-2); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 720px; }

.bnav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 30; height: var(--nav-h); background: var(--card);
  border-top: 1px solid var(--rule); display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom);
}
.bnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--ink-3); font-size: 12.5px; }
.bnav a svg { width: 24px; height: 24px; }
.bnav a.on { color: var(--olive-deep); font-weight: 600; }
.bnav a.on svg { stroke-width: 2.2; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 232px 1fr; }
  .bnav { display: none; }
  .main { padding-bottom: 40px; }
  .side {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; background: var(--card);
    border-inline-end: 1px solid var(--rule); padding: 18px 12px; gap: 2px; overflow-y: auto;
  }
  .side .mark { padding: 4px 12px 18px; }
  .side a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); }
  .side a svg { width: 22px; height: 22px; flex: none; }
  .side a:hover { background: var(--rule-2); }
  .side a.on { background: var(--olive-wash); color: var(--olive-deep); font-weight: 600; }
  .side .sep { height: 1px; background: var(--rule); margin: 10px 8px; }
  .side .who { margin-top: auto; padding: 12px; font-size: 14px; color: var(--ink-3); }
}

.mark { font-family: 'Fredoka', 'Rubik', sans-serif; font-weight: 600; font-size: 26px; color: var(--olive-deep); letter-spacing: .2px; line-height: 1; }
.mark small { display: block; font-family: 'Rubik', sans-serif; font-weight: 400; font-size: 13px; color: var(--ink-3); letter-spacing: 0; margin-top: 4px; }

/* ---------------- כפתורים וקלט ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  border-radius: var(--r); border: 1px solid var(--rule); background: var(--card); color: var(--ink); cursor: pointer;
  text-decoration: none; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: #bfc8bb; background: #fafbf8; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--olive); border-color: var(--olive); color: #fff; }
.btn.primary:hover { background: var(--olive-deep); border-color: var(--olive-deep); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--rule-2); }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 15px; }
.btn.wide { width: 100%; }
.btn svg { width: 20px; height: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions.end { justify-content: flex-end; }

label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 14.5px; color: var(--ink-2); margin-bottom: 4px; }
input.i, select.i, textarea.i {
  width: 100%; min-height: 46px; padding: 8px 12px; border: 1px solid #c9d1c5; border-radius: 8px; background: #fff; font-size: 17px;
}
textarea.i { min-height: 84px; resize: vertical; line-height: 1.45; }
input.i:focus, select.i:focus, textarea.i:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input.i.ltr { direction: ltr; text-align: right; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--olive); }
.hint { font-size: 14px; color: var(--ink-3); margin: -8px 0 14px; }
.err { color: var(--red); font-size: 15px; margin: 6px 0; }

/* ---------------- משטחים, רשימות, תגיות ---------------- */
.panel { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; margin-bottom: 16px; }
.panel > h2, .sec-h { font-size: 17px; font-weight: 600; margin: 0; padding: 14px 16px 6px; }
.panel .body { padding: 6px 16px 16px; }
.sec-h { padding: 18px 2px 8px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sec-h a, .sec-h button { font-size: 15px; font-weight: 500; }

.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--rule-2); min-height: 58px;
  text-decoration: none; color: inherit;
}
.list > .row:first-child, .list > li:first-child > .row { border-top: 0; }
a.row:hover, button.row:hover { background: #fafbf8; }
button.row { width: 100%; border-left: 0; border-right: 0; border-bottom: 0; background: transparent; text-align: start; cursor: pointer; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 14.5px; color: var(--ink-3); }
.row .end { text-align: end; flex: none; }

.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px; font-size: 13.5px; font-weight: 500; white-space: nowrap; background: var(--rule-2); color: var(--ink-2); }
.pill.ok { background: var(--olive-wash); color: var(--olive-deep); }
.pill.warn { background: var(--crust-wash); color: var(--crust-text); }
.pill.bad { background: var(--red-wash); color: var(--red); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: #c5ccc1; }
.dot.ok { background: var(--olive); }
.dot.warn { background: var(--crust); }

.banner { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; background: var(--crust-wash); color: #5d3d0a; display: flex; gap: 10px; align-items: flex-start; }
.banner.info { background: var(--olive-wash); color: var(--olive-deep); }
.banner.bad { background: var(--red-wash); color: #6d1d16; }
.banner .grow { flex: 1; }

.empty { text-align: center; padding: 34px 16px; color: var(--ink-3); }
.empty .btn { margin-top: 12px; }

/* ---------------- טבלאות ---------------- */
.tblw { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.tbl th { text-align: start; font-weight: 600; font-size: 14px; color: var(--ink-2); background: #f7f9f5; padding: 10px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--rule-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .n { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { font-weight: 600; background: #f7f9f5; border-top: 1px solid var(--rule); }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: #fafbf8; }

/* ---------------- כותרת התאריך (מסך הבית / הזמנות) ---------------- */
.dayhead { padding: 18px 2px 4px; }
.dayhead .d { font-family: 'Fredoka', 'Rubik', sans-serif; font-weight: 600; font-size: 30px; line-height: 1.15; color: var(--ink); margin: 0; }
.dayhead .sub { color: var(--ink-2); margin-top: 4px; }
.datebar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.datebar input[type=date] { width: auto; min-height: 44px; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--rule); background: var(--card); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.iconbtn:hover { background: #fafbf8; }
.iconbtn svg { width: 22px; height: 22px; }

/* סבב ההזמנות: חנות בשורה, סימון הזמינה / עוד לא */
.round .row .units { font-weight: 600; }
.round .row.missing .t { color: var(--ink-2); }

/* ---------------- מספרי מפתח ---------------- */
.figs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--rule-2); border-radius: 12px; overflow: hidden; border: 1px solid var(--rule); margin-bottom: 16px; }
@media (min-width: 720px) { .figs { grid-template-columns: repeat(4, 1fr); } }
.fig { background: var(--card); padding: 12px 14px; }
.fig .l { font-size: 14px; color: var(--ink-3); }
.fig .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.fig .v.bad { color: var(--red); }
.fig .v.good { color: var(--olive-deep); }

/* ---------------- פנקס ההזמנה ---------------- */
.pad-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 12px; }
.search { position: relative; flex: 1; min-width: 200px; }
.search input { padding-inline-start: 40px; }
.search svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ink-3); pointer-events: none; }
.grp { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.grp > button.gh {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 16px; min-height: 54px; background: transparent; border: 0; cursor: pointer; text-align: start; font-weight: 600;
}
.grp > button.gh .cnt { margin-inline-start: auto; font-weight: 500; font-size: 14.5px; color: var(--olive-deep); }
.grp > button.gh svg { width: 20px; height: 20px; transition: transform .15s; color: var(--ink-3); }
.grp.open > button.gh svg { transform: rotate(-90deg); }
.prow { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 16px; border-top: 1px solid var(--rule-2); min-height: 60px; }
.prow .nm { flex: 1; min-width: 0; }
.prow .nm .p { font-size: 14px; color: var(--ink-3); }
.prow .nm .p.miss { color: var(--crust-text); }
.prow.has { background: #f7faf4; }
.prow.has .nm > div:first-child { font-weight: 600; }
.step { display: flex; align-items: center; gap: 4px; flex: none; }
.step button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--rule); background: #fff; font-size: 24px; line-height: 1; cursor: pointer; display: grid; place-items: center; color: var(--olive-deep); }
.step button:active { background: var(--olive-wash); }
.step input { width: 62px; height: 44px; text-align: center; border: 1px solid #c9d1c5; border-radius: 8px; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.step input:focus { outline: 2px solid var(--focus); border-color: var(--focus); }
.short { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--crust-text); }
.short input { width: 56px; height: 38px; text-align: center; border: 1px solid #e2c99c; border-radius: 8px; background: var(--crust-wash); }
.free { padding: 12px 16px; border-top: 1px solid var(--rule-2); display: grid; gap: 8px; grid-template-columns: 1fr 90px 100px 44px; align-items: end; }
.free label span { font-size: 13px; color: var(--ink-3); display: block; }
@media (max-width: 560px) { .free { grid-template-columns: 1fr 1fr; } .free .wide2 { grid-column: 1 / -1; } }

/* "סרט הקופה" — הסכום הרץ, תמיד בתחתית */
.tape {
  position: fixed; inset-inline: 0; bottom: var(--nav-h); z-index: 25; background: var(--olive-deep); color: #fff;
  display: flex; align-items: center; gap: 14px; padding: 10px 16px; padding-bottom: calc(10px + 0px);
}
@media (min-width: 900px) { .tape { bottom: 0; inset-inline-start: 232px; } }
.tape .q { font-size: 15px; opacity: .85; }
.tape .tot { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; }
.tape .grow { flex: 1; min-width: 0; }
.tape .w { font-size: 13.5px; color: #ffe2b0; }
.tape .btn.primary { background: #fff; color: var(--olive-deep); border-color: #fff; min-width: 110px; font-weight: 600; }
.tape .btn.primary:hover { background: var(--olive-wash); }
.with-tape { padding-bottom: 96px; }

/* ---------------- רשימה לכזית ---------------- */
.slip { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; margin-bottom: 12px; padding: 12px 16px; }
.slip h3 { margin: 0 0 6px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.slip h3 .btn { margin-inline-start: auto; }
.slip ul { margin: 0; padding: 0; list-style: none; }
.slip li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px dashed var(--rule); }
.slip li:first-child { border-top: 0; }
.slip li b { font-variant-numeric: tabular-nums; }
.slip .note { font-size: 14px; color: var(--crust-text); margin-top: 6px; }

/* ---------------- לשוניות ---------------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--rule); margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; background: var(--card); position: sticky; top: 58px; z-index: 15; }
.tabs a { padding: 12px 12px 10px; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a.on { color: var(--olive-deep); border-bottom-color: var(--olive); font-weight: 600; }

/* ---------------- מחירון ---------------- */
.pm { border-collapse: separate; border-spacing: 0; font-size: 15.5px; min-width: 100%; }
.pm th, .pm td { border-bottom: 1px solid var(--rule-2); padding: 6px 8px; background: var(--card); }
.pm thead th { position: sticky; top: 0; background: #f7f9f5; font-size: 14px; font-weight: 600; color: var(--ink-2); white-space: nowrap; z-index: 2; }
.pm .rh { position: sticky; inset-inline-start: 0; z-index: 1; min-width: 150px; font-weight: 500; border-inline-end: 1px solid var(--rule); }
.pm thead .rh { z-index: 3; }
.pm tr.sub .rh { font-weight: 400; padding-inline-start: 24px; color: var(--ink-2); }
.pm input { width: 86px; height: 40px; border: 1px solid transparent; border-radius: 6px; text-align: center; font-variant-numeric: tabular-nums; background: #f7f9f5; font-size: 16px; }
.pm input:hover { border-color: var(--rule); }
.pm input:focus { outline: 2px solid var(--focus); background: #fff; }
.pm input.miss { background: var(--crust-wash); border-color: #e6cb98; }
.pm input.saved { background: var(--olive-wash); }
.pm td.cost { background: #fbfcfa; }
.pm .fut { display: block; font-size: 11.5px; color: var(--crust-text); text-align: center; }

/* ---------------- גרפים ---------------- */
.smgrid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 760px) { .smgrid { grid-template-columns: 1fr 1fr; } }
.smc { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 12px 14px 8px; }
.smc .h { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.smc .h b { font-weight: 600; }
.smc svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); margin: 4px 0 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.chart-tip { position: fixed; z-index: 60; background: var(--ink); color: #fff; font-size: 14px; padding: 6px 10px; border-radius: 8px; pointer-events: none; white-space: nowrap; }

/* ---------------- חלונות ---------------- */
dialog.dlg { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(20, 35, 25, .28); color: var(--ink); }
dialog.dlg::backdrop { background: rgba(24, 35, 28, .45); }
.dlg .dh { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--rule-2); }
.dlg .dh h2 { margin: 0; font-size: 19px; flex: 1; }
.dlg .db { padding: 16px 18px 6px; overflow-y: auto; }
.dlg .df { display: flex; gap: 8px; justify-content: flex-start; padding: 12px 18px 16px; border-top: 1px solid var(--rule-2); flex-wrap: wrap; }

.toast { position: fixed; z-index: 80; inset-inline: 0; bottom: calc(var(--nav-h) + 16px); display: flex; justify-content: center; pointer-events: none; }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.toast div { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 16px; max-width: calc(100vw - 32px); pointer-events: auto; }
.toast div.bad { background: var(--red); }

/* ---------------- כניסה ---------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: min(380px, 100%); }
.login .mark { font-size: 44px; text-align: center; margin-bottom: 6px; }
.login .tag { text-align: center; color: var(--ink-3); margin: 0 0 26px; }

.bad-text { color: var(--red); }
.legend i.sw1 { background: #3b6b32; }
.legend i.sw2 { background: #c98a2b; }
.ubar-cell { width: 28%; min-width: 70px; }
.ubar { height: 10px; background: var(--olive); border-start-end-radius: 4px; border-end-end-radius: 4px; }
.tbl td.sub { padding-inline-start: 30px; color: var(--ink-2); }
svg.up { transform: rotate(-90deg); }
svg.down { transform: rotate(90deg); }
.iconbtn:disabled { opacity: .35; cursor: default; }
details > summary { cursor: pointer; list-style: none; font-weight: 500; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: '+'; margin-inline-start: auto; color: var(--ink-3); font-size: 20px; }
details[open] > summary::after { content: '−'; }
a.smc { display: block; text-decoration: none; color: inherit; }
a.smc:hover { border-color: #bfc8bb; }
a.panel.row { border-top: 1px solid var(--rule); }
input::placeholder, textarea::placeholder { color: #a9b2a5; }
.loading { padding: 40px 16px; text-align: center; color: var(--ink-3); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: end; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media print {
  .side, .bnav, .top .back, .noprint, .tape, .toast { display: none !important; }
  body { background: #fff; font-size: 13pt; }
  .main { padding: 0; }
  .top { position: static; border: 0; }
  .slip { break-inside: avoid; border-color: #999; }
}
