:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1d2433; --muted: #667085; --line: #dde1e8;
  --brand: #4a4a4a; --brand-ink: #fff; --accent: #0b6bcb;
  --ok: #157347; --ok-bg: #e3f4ea; --warn: #8a5a00; --warn-bg: #fff3d6; --alert: #b42318; --alert-bg: #fde7e4;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Segoe UI", Arial, "Noto Sans Hebrew", sans-serif; line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .3rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: .8rem 0 .3rem; }
small { font-weight: normal; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.ltr, .ltr-input { direction: ltr; unicode-bidi: embed; }
.ltr-input { text-align: left; }
.warn-text { color: var(--warn); font-weight: 600; }

.env-banner { background: #fde68a; color: #5b4300; text-align: center; padding: .25rem; font-size: .85rem; }
.topbar { background: var(--brand); color: var(--brand-ink); display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.2rem; padding: .5rem 1rem; }
.topbar a, .topbar .link { color: var(--brand-ink); text-decoration: none; }
.topbar .brand { font-weight: 700; font-size: 1.15rem; }
.topbar .brand span { font-weight: 400; opacity: .8; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .3rem 1rem; flex: 1; }
.topbar nav a { padding: .2rem .1rem; opacity: .92; }
.topbar nav a:hover { opacity: 1; text-decoration: underline; }
.topbar .who { display: flex; gap: .8rem; align-items: center; font-size: .9rem; }
.topbar form { margin: 0; }
button.link { background: none; border: 0; cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }

.page { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.page.narrow { max-width: 480px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.row.between { justify-content: space-between; align-items: center; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .8rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 1rem; }
.grid2 > .card { margin: 0; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #b9c0cc; border-radius: 8px; padding: .5rem .6rem; min-height: 40px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid #93c5fd; outline-offset: 1px; }
input[type=checkbox] { width: auto; min-height: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.filters label { min-width: 150px; flex: 1; }
.filters .actions { display: flex; gap: .4rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid #b9c0cc; background: #fff; color: var(--ink); border-radius: 8px; padding: .5rem 1rem; min-height: 40px; font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #0a5cb0; }
.btn.danger { background: #fff; color: var(--alert); border-color: var(--alert); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 56px; font-size: 1.15rem; width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: #8fd1a9; color: #0b4f2b; }
.flash.warn { background: var(--warn-bg); border-color: #e6c36b; color: #5b4300; }
.flash.error { background: var(--alert-bg); border-color: #f1a49b; color: #7a1a12; }

.badge { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .8rem; background: #e8ebf0; color: #344054; white-space: nowrap; }
.badge.ok, .badge.service_status-completed, .badge.billing_status-invoiced, .badge.visit_status-submitted { background: var(--ok-bg); color: var(--ok); }
.badge.warn, .badge.service_status-awaiting_part, .badge.service_status-needs_followup, .badge.billing_status-awaiting_invoice, .badge.visit_status-report_pending { background: var(--warn-bg); color: var(--warn); }
.badge.alert, .badge.service_status-new, .badge.service_status-cancelled, .badge.visit_status-cancelled { background: var(--alert-bg); color: var(--alert); }
.badge.service_status-in_progress, .badge.service_status-assigned, .badge.visit_status-working, .badge.visit_status-traveling { background: #dbeafe; color: #1d4ed8; }

.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.tab { padding: .4rem .9rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab b { background: #e8ebf0; color: var(--ink); border-radius: 999px; padding: 0 .45rem; margin-inline-start: .3rem; font-size: .8rem; }
.tab b.alert { background: var(--alert); color: #fff; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: start; background: #f0f2f5; font-size: .85rem; color: var(--muted); padding: .55rem .7rem; white-space: nowrap; }
table.grid td { padding: .55rem .7rem; border-top: 1px solid var(--line); vertical-align: top; }
table.grid tr.prio-urgent td:first-child { border-inline-start: 4px solid var(--alert); }
table.grid tr.prio-high td:first-child { border-inline-start: 4px solid #d97706; }
td.empty { text-align: center; color: var(--muted); padding: 1.5rem; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 .8rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
dl.facts.compact { font-size: .93rem; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .25rem 0; border-top: 1px solid var(--line); }
.quote { background: #f7f8fa; border-inline-start: 4px solid var(--line); padding: .6rem .8rem; margin: 0 0 .8rem; }
details { margin: .6rem 0; }
summary { cursor: pointer; color: var(--accent); }

.visit { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin-top: .8rem; background: #fcfcfd; }
.visit.cancelled { opacity: .6; }
.times { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; font-size: .9rem; color: var(--muted); margin: .4rem 0; }
.report { border-top: 1px dashed var(--line); margin-top: .6rem; padding-top: .6rem; }

.results { display: flex; flex-direction: column; gap: .3rem; margin-top: .5rem; }
.results button { text-align: start; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; font: inherit; cursor: pointer; }
.results button:hover { background: #eef5ff; }
.chosen { background: var(--ok-bg); border-radius: 8px; padding: .5rem .8rem; }
.login { margin-top: 3rem; }

/* ===== טכנאי (נייד) ===== */
body.tech { font-size: 1.05rem; }
.tech .page { padding: .7rem; max-width: 640px; }
.tech input, .tech select, .tech textarea { min-height: 48px; font-size: 1.05rem; }
.tech .btn { min-height: 52px; font-size: 1.05rem; }
.call-card { display: block; text-decoration: none; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .7rem; }
.call-card.urgent { border-inline-start: 6px solid var(--alert); }
.call-card.high { border-inline-start: 6px solid #d97706; }
.call-card .top { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.call-card .cust { font-weight: 700; font-size: 1.1rem; }
.actions-bar { display: grid; gap: .6rem; margin: .8rem 0; }
.actions-bar .btn.primary { min-height: 64px; font-size: 1.3rem; }
.part-row { display: grid; grid-template-columns: 1fr 90px 48px; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.part-row .sku { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); }
.part-row button { min-height: 48px; }
.suggest { display: flex; flex-direction: column; gap: .3rem; margin: .3rem 0 .6rem; }
.suggest button { text-align: start; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .6rem; font: inherit; }
.sig-wrap { border: 2px dashed #94a3b8; border-radius: var(--radius); background: #fff; touch-action: none; }
.sig-wrap canvas { width: 100%; height: 200px; display: block; touch-action: none; }
.sync { display: inline-flex; gap: .4rem; align-items: center; font-size: .9rem; padding: .25rem .7rem; border-radius: 999px; }
.sync.local { background: var(--warn-bg); color: var(--warn); }
.sync.server { background: var(--ok-bg); color: var(--ok); }
.sync.sending { background: #dbeafe; color: #1d4ed8; }
.sync.error { background: var(--alert-bg); color: var(--alert); }
.receipt { text-align: center; padding: 2rem 1rem; }
.receipt .tick { font-size: 3.5rem; color: var(--ok); }
.preview { background: #f7f8fa; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; }
.sticky-submit { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: .8rem 0 .3rem; }

@media (max-width: 700px) {
  .grid2 { grid-template-columns: 1fr; }
  .topbar { padding: .5rem; }
  dl.facts { grid-template-columns: 1fr; }
  dl.facts dt { margin-top: .4rem; }
}
@media print { .topbar, .env-banner, .btn { display: none; } }
.nowrap { white-space: nowrap; }
.stretch .btn { width: 100%; }


/* ===== מראה "MagicNet": סרגל כהה, לשונית פעילה אדומה, טבלה צפופה ===== */
:root { --tab-on: #d9534f; --cyan: #17a2b8; --btn-cyan: #3ab8e0; --btn-red: #d9534f; }
.topbar { padding: 0 1rem; gap: 0 1rem; align-items: stretch; border-bottom: 2px solid #d9534f; }
.topbar nav { gap: 0; }
.navtab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; padding: .45rem 1rem; min-width: 84px; font-size: .85rem; opacity: 1 !important; text-decoration: none !important; }
.navtab .ico { font-size: 1.5rem; line-height: 1.2; }
.navtab:hover { background: #5c5c5c; }
.navtab.on { background: var(--tab-on); }
.topbar .who { align-self: center; }
.topbar .brand { align-self: center; order: 3; margin-inline-start: auto; }
.page.wide { max-width: 1500px; }
h1.pagetitle { font-size: 1.25rem; text-align: start; margin: 1rem 0 .4rem; padding-bottom: .4rem; border-bottom: 2px solid var(--cyan); }

.searchbar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; background: #f2f2f2; border-bottom: 2px solid var(--cyan); padding: .9rem 1rem; margin-bottom: .6rem; }
.searchbar .q { flex: 1 1 260px; max-width: 420px; border-radius: 6px; min-height: 44px; }
.radios { display: flex; gap: 1.1rem; flex-wrap: wrap; }
label.radio { flex-direction: row; align-items: center; gap: .4rem; color: var(--ink); font-weight: 600; cursor: pointer; }
label.radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
label.radio .dot { width: 22px; height: 22px; border-radius: 50%; background: #cfcfcf; border: 2px solid #bdbdbd; display: inline-block; }
label.radio input:checked + .dot { background: #e0443e; border-color: #e0443e; box-shadow: inset 0 0 0 4px #f2f2f2; }
label.radio input:focus-visible + .dot { outline: 3px solid #93c5fd; outline-offset: 2px; }
.btn.red { background: var(--btn-red); border-color: var(--btn-red); color: #fff; min-width: 90px; }
.btn.red:hover { background: #c9302c; }
.btn.cyan { background: var(--btn-cyan); border-color: var(--btn-cyan); color: #fff; margin-inline-start: auto; min-width: 140px; }
.btn.cyan:hover { background: #28a5cf; }

details.bar { margin: 0 0 .4rem; }
details.bar > summary { list-style: none; background: #6b6b6b; color: #fff; padding: .35rem .8rem; font-weight: 700; border-bottom: 2px solid #d0d0d0; cursor: pointer; display: flex; align-items: center; gap: .5rem; }
details.bar > summary::-webkit-details-marker { display: none; }
details.bar > summary::before { content: "+"; font-weight: 700; width: 1rem; }
details.bar[open] > summary::before { content: "−"; }
.panel { background: #fff; border: 1px solid var(--line); border-top: 0; padding: .8rem; }
.quick { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { text-decoration: none; background: #f2f2f2; border: 1px solid #cfcfcf; color: var(--ink); padding: .3rem .8rem; border-radius: 4px; }
.chip.on { background: #4a4a4a; color: #fff; border-color: #4a4a4a; }
.chip b { background: #dcdcdc; color: var(--ink); border-radius: 999px; padding: 0 .45rem; margin-inline-start: .3rem; font-size: .8rem; }
.chip b.alert { background: var(--alert); color: #fff; }

.summary { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .6rem 1.5rem; margin: .8rem 0 .5rem; font-size: .9rem; }
.stats { display: flex; flex-wrap: wrap; gap: .2rem 1.5rem; }
.stats b { margin-inline-start: .25rem; }
.legend { display: grid; grid-template-columns: repeat(3, auto); gap: 0; font-size: .75rem; text-align: center; }
.lg { padding: .1rem .7rem; min-width: 84px; }

table.dense th { background: #4a4a4a; color: #fff; font-size: .82rem; padding: .45rem .5rem; text-align: center; }
table.dense td { padding: .4rem .5rem; font-size: .84rem; text-align: center; border-top: 1px solid #fff; vertical-align: middle; }
table.dense td.subject { text-align: start; min-width: 220px; }
table.dense a.plain { color: var(--ink); text-decoration: none; }
table.dense a.plain:hover { text-decoration: underline; }
table.dense .small { font-size: .75rem; color: inherit; opacity: .8; }
.table-wrap { border-radius: 0; }
.st-attention, .lg.attention { background: #ffb3ba; }
.st-traveling, .lg.traveling { background: #f4b942; }
.st-working, .lg.working { background: #b7a2c7; }
.st-assigned, .lg.assigned { background: #b6d4ee; }
.st-waiting, .lg.waiting { background: #fff0a8; }
.st-done, .lg.done { background: #80cdb9; }
.st-cancelled { background: #e0e0e0; color: #666; }
table.board tbody tr:hover td { filter: brightness(.96); }
@media (max-width: 900px) { .btn.cyan { margin-inline-start: 0; } .legend { grid-template-columns: repeat(2, auto); } }

/* השהיית עבודה */
.pause-banner { font-size: 1.05rem; }
.btn.resume { background: #157347; border-color: #157347; }
.btn.resume:hover { background: #0f5c38; }
details.pause-box { margin: .4rem 0 1rem; }
details.pause-box > summary { list-style: none; color: var(--ink); }
details.pause-box > summary::-webkit-details-marker { display: none; }
details.pause-box[open] > summary { background: #f0f2f5; }
details.pause-box form { margin-top: .6rem; }

/* ===== לוגו שרתעש ===== */
.brandbar { background: #fff; display: flex; align-items: center; gap: 1rem; padding: .35rem 1rem; border-bottom: 1px solid var(--line); }
.brandbar .who { margin-inline-end: auto; }
.brandbar .who a { color: var(--ink); }
.brandbar .who button.link { color: var(--accent); }
.logo-link { display: inline-flex; line-height: 0; }
img.logo { height: 36px; width: auto; display: block; }
.site-header .topbar { padding: 0 1rem; }
.login-logo { display: block; width: 200px; max-width: 70%; height: auto; margin: 0 auto .4rem; }
.login-title { text-align: center; font-size: 1.15rem; color: var(--muted); font-weight: 600; margin: 0 0 1rem; }
@media (max-width: 700px) { .brandbar { padding: .3rem .6rem; } img.logo { height: 30px; } }
@media print { .brandbar .who { display: none; } }
.brandbar .who { display: flex; gap: .9rem; align-items: center; font-size: .9rem; }
.brandbar .who a { text-decoration: none; font-weight: 600; }
.brandbar .who form { margin: 0; }
.brandbar .who button.link { text-decoration: none; }
img.logo { height: 42px; }
@media (max-width: 700px) { img.logo { height: 32px; } .brandbar .who { font-size: .8rem; gap: .6rem; } }

/* ---- טופס פתיחת קריאה (בסגנון מגיקנט) ---- */
.newcall { background: #fff; border: 1px solid var(--line); border-radius: 4px; margin: 0 0 1rem; }
.nc-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.nc-head h1 { margin: 0; font-size: 1.15rem; font-weight: 500; flex: 1; text-align: center; }
.nc-close { background: #e0443e; color: #fff; width: 38px; height: 34px; border-radius: 4px; display: grid; place-items: center; text-decoration: none; font-weight: 700; }
.nc-tool { color: #333; text-decoration: none; font-size: .8rem; display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.nc-tool .ico { color: #e0443e; font-size: 1.3rem; }
.nc-sec { padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.nc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem 1.1rem; margin-bottom: .7rem; }
.nc-grid .span2 { grid-column: span 2; }
.nc-grid .span4 { grid-column: span 4; }
.nc-grid label { color: #222; font-weight: 600; font-size: .82rem; }
.nc-grid input, .nc-grid select, .nc-grid textarea { font-weight: 400; }
.nc-grid input[readonly] { background: #f3f3f3; color: #555; }
.nc-hint { color: var(--muted); font-size: .82rem; align-self: end; padding-bottom: .5rem; }
.nc-foot { padding: .9rem 1.2rem; }
.nc-foot .btn { background: #e0443e; border-color: #e0443e; }
@media (max-width: 800px) { .nc-grid { grid-template-columns: 1fr 1fr; } .nc-grid .span4 { grid-column: span 2; } }
@media (max-width: 520px) { .nc-grid { grid-template-columns: 1fr; } .nc-grid .span2, .nc-grid .span4 { grid-column: auto; } }

/* בורר טכנאים (רשימה נפתחת עם תיבות סימון) */
.field { display: flex; flex-direction: column; gap: .25rem; color: #222; font-weight: 600; font-size: .82rem; }
details.multi { position: relative; font-weight: 400; }
details.multi > summary { list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 4px; background: #fff; padding: .5rem .7rem; min-height: 2.4rem; display: flex; align-items: center; justify-content: space-between; }
details.multi > summary::-webkit-details-marker { display: none; }
details.multi > summary::after { content: "▾"; color: #777; margin-inline-start: .5rem; }
details.multi:not(.has-value) .multi-text { color: #777; }
details.multi[open] > summary { border-color: #5b9bd5; }
.multi-list { position: absolute; z-index: 20; inset-inline: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.15); max-height: 260px; overflow: auto; padding: .3rem; }
.multi-list .check { display: flex; align-items: center; gap: .5rem; padding: .45rem .5rem; font-weight: 400; cursor: pointer; border-radius: 3px; }
.multi-list .check:hover { background: #f1f5f9; }
.multi-list input { width: 1.1rem; height: 1.1rem; }
.nc-grid .multi-list label.check, .multi-list label.check { flex-direction: row; align-items: center; justify-content: flex-start; font-weight: 400; }

/* קבצים מצורפים */
.files { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; gap: .6rem; }
.files li { display: flex; align-items: center; gap: .8rem; border: 1px solid var(--line); border-radius: 6px; padding: .5rem; background: #fff; }
.files .thumb { width: 64px; height: 64px; flex: none; border-radius: 4px; overflow: hidden; background: #eef1f5; display: grid; place-items: center; }
.files .thumb img { width: 100%; height: 100%; object-fit: cover; }
.files .thumb.doc { font-weight: 700; color: #5b6b82; font-size: .8rem; }
.files .fmeta { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.attach-form input[type=file] { padding: .6rem; background: #f8fafc; }
body.tech .attach-form .btn { min-height: 3rem; }

/* עוזר AI */
.ai-card textarea { width: 100%; }
.ai-item { border: 1px solid var(--line); border-radius: 6px; padding: .6rem .8rem; margin-top: .7rem; background: #fbfcfe; }
.ai-item summary { cursor: pointer; }
.ai-answer { white-space: pre-wrap; line-height: 1.65; margin: .7rem 0; }

/* מסך התראות */
.notif-grid td.c, .notif-grid th { text-align: center; }
.notif-grid td:first-child, .notif-grid th:first-child { text-align: right; min-width: 170px; }
.notif-grid input[type=checkbox] { width: 20px; height: 20px; }
.notif-grid textarea { width: 100%; min-width: 130px; font-size: .85rem; }
.notif-grid tr.sep td { border-top: 2px solid var(--line, #ddd); }
.tag { background: #eef; border-radius: 4px; padding: 0 .4em; font-size: .8rem; }
