:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #e2e6ee;
  --brand: #1d4ed8;
  --brand-soft: #e8efff;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fff4e0;
  --bad: #c62828;
  --bad-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  font-family: "Segoe UI", "Rubik", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 16px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.spacer { flex: 1; }

/* ---- כותרת ---- */
header.top {
  position: sticky; top: 0; z-index: 20; background: #0f2a5c; color: #fff;
  display: flex; align-items: center; gap: 6px; padding: 0 14px; height: 54px; flex-wrap: nowrap; overflow-x: auto;
}
header.top .brand { font-weight: 700; font-size: 18px; margin-inline-end: 14px; white-space: nowrap; }
header.top nav { display: flex; gap: 2px; }
header.top nav a {
  color: #dbe5ff; text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; position: relative;
}
header.top nav a.active, header.top nav a:hover { background: rgba(255, 255, 255, .14); color: #fff; }
header.top nav a .badge { position: absolute; top: 2px; inset-inline-start: 2px; }
header.top .who { white-space: nowrap; font-size: 14px; opacity: .9; }
header.top button.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* ---- כפתורים ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  min-height: 42px; font-weight: 600; text-decoration: none; color: var(--text);
}
.btn:hover { border-color: #c5cde0; background: #fafbff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1a43bd; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.big { font-size: 19px; min-height: 58px; padding: 12px 22px; border-radius: 12px; }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 14px; border-radius: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: #fff; font-weight: 600; }

/* ---- טפסים ---- */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
label.f > span { font-weight: 600; color: var(--text); }
input.i, select.i, textarea.i {
  border: 1px solid #cfd6e4; border-radius: 9px; padding: 9px 11px; background: #fff; min-height: 42px; width: 100%;
}
input.i:focus, select.i:focus, textarea.i:focus { outline: 2px solid #9db8ff; border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.hint { font-size: 13px; color: var(--muted); }

/* ---- טבלאות ---- */
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
table.t th { font-size: 13px; color: var(--muted); font-weight: 600; background: #f8f9fc; position: sticky; top: 0; }
table.t td.num, table.t th.num { text-align: right; }
table.t tr.clickable { cursor: pointer; }
table.t tr.clickable:hover td { background: #f6f8ff; }
.table-wrap { overflow: auto; }

/* ---- תגיות ---- */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; background: #eef1f6; color: #3d4757; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--brand-soft); color: var(--brand); }
.badge { background: #ef4444; color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; }

/* ---- הודעות ---- */
#toasts { position: fixed; bottom: 18px; left: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast { background: #1f2937; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); font-weight: 600; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.toast.warn { background: var(--warn); }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; }
.alert.bad { background: var(--bad-soft); color: #8a1c1c; border: 1px solid #f5c2c2; }
.alert.warn { background: var(--warn-soft); color: #7a3e06; border: 1px solid #f6d8a8; }
.alert.ok { background: var(--ok-soft); color: #11572c; border: 1px solid #b7e2c4; }
.alert.info { background: var(--brand-soft); color: #173a99; border: 1px solid #c9d8ff; }

/* ---- חלון ---- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: min(640px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { width: min(980px, 100%); }
.modal .mh { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal .mh h2 { margin: 0; }
.modal .mb { padding: 18px 20px; }
.modal .mf { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-start; }
.modal.alarm .mh { background: var(--bad); color: #fff; border-radius: 16px 16px 0 0; }
.modal.caution .mh { background: var(--warn); color: #fff; border-radius: 16px 16px 0 0; }

/* ---- כניסה ---- */
.login { max-width: 380px; margin: 10vh auto; }
.login .card { padding: 26px; }

/* ---- עמדה ---- */
.station { display: grid; grid-template-columns: 300px 1fr 330px; gap: 14px; align-items: start; }
@media (max-width: 1250px) { .station { grid-template-columns: 260px 1fr; } .station .side-r { grid-column: 1 / -1; order: -1; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; } }
@media (max-width: 800px) { .station { grid-template-columns: 1fr; } .station .side-r { grid-template-columns: 1fr; } }
.olist { max-height: calc(100vh - 210px); overflow: auto; margin: 10px -6px 0; }
.olist .o { padding: 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.olist .o:hover { background: #f6f8ff; }
.olist .o.sel { background: var(--brand-soft); border-color: #bcd0ff; }
.olist .o .n { font-weight: 700; }
.scale-box { text-align: center; }
.scale-read { white-space: nowrap; font-size: clamp(44px, 5.2vw, 72px); font-weight: 800; letter-spacing: 1px; line-height: 1.1; margin: 8px 0; direction: ltr; font-variant-numeric: tabular-nums; }
.scale-read.unstable { color: #94a3b8; }
.scale-read.off { color: #cbd5e1; font-size: 34px; }
.scale-read .unit { font-size: .38em; font-weight: 700; margin-inline-start: 8px; color: var(--muted); }
.scale-hint { margin-top: 6px; font-weight: 700; color: var(--muted); min-height: 1.4em; }
.scale-hint.go { color: var(--ok); font-size: 18px; }
.station .side-r { position: sticky; top: 66px; }
@media (max-width: 1250px) { .station .side-r { position: static; } }
#hdr-scale { font-size: 15px; font-weight: 800; direction: ltr; background: rgba(255,255,255,.14); color: #fff; padding: 4px 12px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#hdr-scale.off { opacity: .55; font-weight: 600; }
#hdr-scale.unstable { color: #fde68a; }
.scan-input { font-size: 20px; min-height: 52px; text-align: center; letter-spacing: 1px; }
.weigh-panel { border: 3px solid var(--brand); background: var(--brand-soft); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.weigh-panel .wn { font-size: 20px; font-weight: 800; }
.weigh-panel .wv { font-size: 40px; font-weight: 800; direction: ltr; text-align: center; }
.items td .prog { font-weight: 800; font-size: 18px; }
tr.st-done td { background: #f2fbf5; }
tr.st-over td { background: #fff7ea; }
tr.st-out td { background: #f4f4f6; color: #7b8494; }
tr.st-extra td { background: var(--bad-soft); }
tr.flash td { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: #bbf7d0; } 100% { } }
.cust-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.cust-head .nm { font-size: 30px; font-weight: 800; line-height: 1.15; }
.cust-head .cmeta { color: var(--muted); font-size: 15px; margin-top: 2px; }
.cust-head .cside { text-align: left; }
.cnote { margin-top: 10px; background: #fff3c4; border: 2px solid #f0c94a; color: #5b4300; border-radius: 10px; padding: 10px 14px; font-size: 19px; font-weight: 700; }
.feedback { margin-top: 10px; border-radius: 12px; padding: 14px 16px; font-size: 22px; font-weight: 800; min-height: 60px; display: flex; align-items: center; transition: background .2s; }
.feedback.idle, .feedback.next { background: #eef3ff; color: #173a99; }
.feedback.done { background: #dcfce7; color: #14532d; }
.feedback.ok { background: #16a34a; color: #fff; }
.feedback.bad { background: #dc2626; color: #fff; }
.feedback.warn { background: #f59e0b; color: #1f1300; }
.feedback.info { background: #475569; color: #fff; }
.items .pname { font-weight: 800; font-size: 19px; }
.items td { padding-top: 12px; padding-bottom: 12px; }
.items .prog { font-weight: 800; font-size: 26px; white-space: nowrap; }
.items .prog .of { font-size: 17px; color: var(--muted); font-weight: 700; }
.items .sum { font-weight: 700; font-size: 17px; }
.items .btn { white-space: nowrap; }
.st { display: inline-block; padding: 5px 12px; border-radius: 999px; font-weight: 800; font-size: 15px; white-space: nowrap; }
.st.ok { background: #16a34a; color: #fff; }
.st.todo { background: #fde68a; color: #6b3d00; }
.st.warn { background: #fb923c; color: #fff; }
.st.grey { background: #cbd5e1; color: #334155; }
.st.bad { background: #dc2626; color: #fff; }
tr.st-todo td:first-child { box-shadow: inset -6px 0 0 #f59e0b; }
tr.st-done td:first-child { box-shadow: inset -6px 0 0 #16a34a; }
tr.st-extra td:first-child { box-shadow: inset -6px 0 0 #dc2626; }
tr.st-out td:first-child { box-shadow: inset -6px 0 0 #94a3b8; }
.total-bar { position: sticky; bottom: 0; background: var(--card); z-index: 5; padding-bottom: 8px; box-shadow: 0 -6px 12px -8px rgba(16,24,40,.18); }
.total-bar .tb-status { font-weight: 700; font-size: 16px; }
.btn.finish { min-width: 220px; font-size: 21px; }
.big-empty { font-size: 22px; padding: 70px 10px; }
.cust-results { display: grid; gap: 6px; margin-top: 8px; }
.cust-opt { justify-content: flex-start; gap: 10px; text-align: right; }
.keys { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.keys span { font-size: 12px; background: #eef1f6; border-radius: 6px; padding: 2px 8px; color: #475569; }
.scale-box { border-width: 3px; transition: border-color .2s; }
.scale-box.is-stable { border-color: #16a34a; }
.scale-box.is-moving { border-color: #f59e0b; }
.scale-box.is-off { border-color: var(--line); }
.scale-box.is-flag { border-color: var(--bad); background: #fff5f5; }
.olist .o .n { font-size: 17px; }
.olist .o { padding: 12px 10px; border-bottom: 1px solid var(--line); border-radius: 0; }
.olist .o.sel { border-radius: 10px; }
.total-bar { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--line); flex-wrap: wrap; }
.total-bar .tt { font-size: 28px; font-weight: 800; }
.flash-bad { animation: flashbad .9s ease-out; }
@keyframes flashbad { 0%, 40% { box-shadow: 0 0 0 6px rgba(198, 40, 40, .55); } 100% { box-shadow: none; } }
.paybtns { display: grid; gap: 10px; }
.big-num { font-size: 40px; font-weight: 800; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

/* ---- הדפסה ---- */
.print-only { display: none; }
@media print {
  body { background: #fff; }
  header.top, #toasts, .no-print, .modal-back { display: none !important; }
  .print-only { display: block !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
}
.labels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.label { border: 1px dashed #cbd5e1; border-radius: 8px; padding: 8px; text-align: center; break-inside: avoid; }
.label .ln { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.label svg { max-width: 100%; height: 70px; }
.print-only#print-slip { font-family: Arial, "Segoe UI", sans-serif; color: #000; }
#print-slip.w80 { width: 76mm; font-size: 12.5px; }
#print-slip.w58 { width: 54mm; font-size: 11px; }
#print-slip.wA4 { width: auto; max-width: 170mm; font-size: 15px; }
#print-slip .ph { text-align: center; font-weight: 800; font-size: 1.35em; line-height: 1.25; padding-bottom: 4px; border-bottom: 2px solid #000; margin-bottom: 4px; }
#print-slip .pmeta { font-size: .92em; }
#print-slip .pcust { font-size: 1.12em; margin: 4px 0; }
#print-slip .pt { width: 100%; border-collapse: collapse; margin-top: 4px; }
#print-slip .pt th { border-bottom: 1px solid #000; font-size: .85em; text-align: right; padding: 2px 1px; }
#print-slip .pt td { border-bottom: 1px dotted #777; padding: 3px 1px; vertical-align: top; }
#print-slip .pt .c { text-align: center; white-space: nowrap; }
#print-slip .pt .l { text-align: left; white-space: nowrap; }
#print-slip .pn { font-weight: 700; }
#print-slip .pd { font-size: .82em; }
#print-slip .ptotal { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.45em; border-top: 2px solid #000; margin-top: 6px; padding-top: 4px; }
#print-slip .ppay { font-weight: 700; margin-top: 2px; }
#print-slip .pfoot { text-align: center; margin-top: 8px; font-weight: 700; }
#print-slip .pfine { text-align: center; font-size: .78em; margin-top: 6px; }
@media print { body.printing-slip > *:not(#print-slip) { display: none !important; } body.printing-slip { margin: 0; } }
.slip { max-width: 380px; margin: 0 auto; font-size: 14px; }
.slip table { width: 100%; border-collapse: collapse; }
.slip td { padding: 3px 0; border-bottom: 1px dotted #ccc; }
