/* LuxSense palette — pastel set the client chose in color-options.html (v1.11). --line stays darker than the
   picker's derived value so table and input borders remain visible. */
:root {
  --bg: #ffffff;
  --panel: #f8f7f7;
  --sand: #f1e5da;
  --sand-dark: #9a7c64;
  --blush: #f9e4db;
  --coral: #f0c6b4;
  --line: #e9ded9;
  --text: #1a1a1a;
  --text-2: #69727d;
  --red: #c0392b;
  --red-bg: #fbe9e7;
  --green: #4f8a5b;
  --green-bg: #e8f2ea;
  --coral-bg: #fcf5f2;
  --grey-bg: #eef0f2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Open Sans', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
a { color: var(--sand-dark); }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }

/* ---------- buttons + inputs ---------- */
.btn {
  border: 1px solid var(--coral);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--coral-bg); }
.btn-primary { background: var(--sand); border-color: var(--sand); }
.btn-primary:hover { background: #e8d6c6; }
.btn-blush { background: var(--blush); border-color: var(--coral); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--panel); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; padding: 2px 6px;
  color: var(--text-2); font-size: 16px; line-height: 1; border-radius: 6px;
}
.icon-btn:hover { background: var(--panel); color: var(--text); }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blush); border-color: var(--coral); }
label { display: block; font-weight: 600; font-size: 14px; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
.form-error { color: var(--red); min-height: 1.5em; margin: 8px 0 0; }

/* ---------- login ---------- */
.auth-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(160deg, var(--panel), var(--blush));
}
.auth-card {
  width: min(380px, 100%); background: var(--bg); border-radius: 16px; padding: 32px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08); display: grid; gap: 14px;
}
.auth-card h1 { margin: 0; }

/* ---------- top bar ---------- */
.brand { font-weight: 700; font-size: 20px; letter-spacing: 0.5px; }
.brand span { font-weight: 400; color: var(--sand-dark); }
.brand-lg { font-size: 28px; text-align: center; }
.env-badge {
  font-style: normal; font-size: 12px; font-weight: 600; background: var(--text); color: var(--bg);
  padding: 2px 8px; border-radius: 99px; vertical-align: middle;
}
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; background: var(--sand); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--text); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 14px;
}
.nav a:hover { background: rgba(255, 255, 255, 0.4); }
.nav a.active { background: var(--bg); box-shadow: inset 0 -3px 0 var(--coral); }
/* sub-menu (הגדרות ▾) */
.nav-group { position: relative; }
.nav-group-btn {
  border: 0; background: transparent; font: inherit; color: var(--text); padding: 6px 12px; border-radius: 8px;
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.nav-group-btn:hover { background: rgba(255, 255, 255, 0.4); }
.nav-group-btn.active { background: var(--bg); box-shadow: inset 0 -3px 0 var(--coral); }
.submenu {
  display: none; position: absolute; top: 100%; inset-inline-start: 0; z-index: 20; min-width: 180px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  padding: 6px;
}
/* open on click / Enter (.open) or mouse hover; keyboard users open it with Enter and Tab into the links */
.nav-group.open .submenu, .nav-group:hover .submenu { display: grid; gap: 2px; }
.submenu a { display: block; white-space: nowrap; }
.submenu a:hover { background: var(--coral-bg); }
.submenu a.active { box-shadow: inset 3px 0 0 var(--coral); background: var(--coral-bg); }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.view { padding: 24px; max-width: 1500px; margin: 0 auto; }
.footer { text-align: center; padding: 16px; font-size: 12px; }

/* ---------- generic layout ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar h1 { margin: 0; flex: 1; }
.toolbar .grow { flex: 1; }
.card {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; border-top: 4px solid var(--sand); }
/* dashboard counters are buttons: they filter the table or open a page */
button.stat {
  border: 0; border-top: 4px solid var(--sand); font: inherit; color: inherit; text-align: start; width: 100%; cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
button.stat:hover { background: var(--coral-bg); box-shadow: var(--shadow); }
button.stat:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.stat.active { background: var(--coral-bg); box-shadow: inset 0 0 0 3px var(--sand-dark); }
.dash-table-head { justify-content: space-between; margin-bottom: 8px; }
.dash-table-head h2 { margin: 0; }
.stats-hint { color: var(--text-2); font-size: 13px; margin: -16px 0 20px; }
.filter-note { margin: -4px 0 12px; font-size: 14px; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: var(--sand-dark); text-decoration: underline; cursor: pointer; }
.stat b { display: block; font-size: 28px; line-height: 1.2; }
.stat span { color: var(--text-2); font-size: 13px; }
.stat.red { border-top-color: var(--red); }
.stat.coral { border-top-color: var(--coral); }
.stat.green { border-top-color: var(--green); }
.empty { text-align: center; color: var(--text-2); padding: 32px 16px; }

/* ---------- tables ---------- */
.inventory { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; align-items: start; margin-bottom: 12px; }
.inventory h2 { margin-top: 0; }
/* clickable inventory rows and their details window (CR-11/12) */
.inv-row { cursor: pointer; }
.inv-row:hover, .inv-row:focus-visible { background: var(--coral-bg); outline: none; }
.inv-row .inv-name { color: var(--sand-dark); text-decoration: underline; text-underline-offset: 3px; }
.inv-type-counts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.inv-customer { border-top: 1px solid var(--line); padding: 8px 0; }
.inv-site { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 4px 0 4px 0; margin-inline-start: 14px; }
.inv-devices { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; margin-inline-start: 18px; }
.inv-inactive { opacity: 0.6; }
.ready-input { width: 80px; padding: 4px 6px; text-align: center; }
/* v1.47: phones waiting for approval on טכנאים */
.requests-card { margin-bottom: 16px; border-color: var(--coral); }
.request-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.request-row > div { flex: 1 1 260px; }
.request-row select { width: auto; max-width: 260px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
/* v1.44: a list fitted to the screen scrolls inside its box; header and total row stay in view */
.table-wrap.scroll-fit { overflow: auto; }
.table-wrap.scroll-fit thead th { position: sticky; top: 0; z-index: 1; }
.table-wrap.scroll-fit tfoot td { position: sticky; bottom: 0; background: var(--panel); }
table { width: 100%; border-collapse: collapse; background: var(--bg); }
th, td { text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--panel); font-size: 13px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfaf9; }
td.actions { white-space: nowrap; text-align: left; }
.mono { font-family: Consolas, monospace; direction: ltr; unicode-bidi: embed; }

/* ---------- chips ---------- */
.chip {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--grey-bg); color: var(--text-2); white-space: nowrap;
}
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.coral { background: var(--coral-bg); color: #a4583a; }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.sand { background: #f3e8de; color: var(--sand-dark); }

/* ---------- registry ---------- */
.registry { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
/* a wide device table scrolls inside its card instead of pushing the page sideways (v1.48: more row buttons) */
.registry > section { min-width: 0; }
/* v1.44: on a wide screen the list and the address cards scroll inside a box sized to the screen (fitRegistry in admin.js) */
.customer-list { display: grid; gap: 4px; align-content: start; }
.customer-list.scroll-fit, .customer-devices.scroll-fit { overflow-y: auto; padding-inline-end: 4px; }
.letter-range { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; }
.letter-range select { width: auto; padding: 4px 6px; }
.customer-item {
  text-align: right; border: 1px solid transparent; background: transparent; padding: 10px 12px; border-radius: 8px;
  font: inherit; cursor: pointer; display: flex; justify-content: space-between; gap: 8px;
}
.customer-item:hover { background: var(--bg); }
.customer-item.active { background: var(--bg); border-color: var(--coral); }
/* a customer with no active device (shown with "הכל", or when chosen) — v1.31 */
.customer-item.inactive > span:first-child { color: var(--text-2); }
.customer-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; }
.site-card { margin-bottom: 16px; }
/* maps (address locations) — Leaflet works left-to-right inside the RTL page */
.map-box { height: 60vh; min-height: 320px; border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0 16px; direction: ltr; }
.map-small { height: 55vh; }
.map-box.placing { cursor: crosshair; outline: 3px solid var(--coral); }
.map-box .leaflet-popup-content { direction: rtl; text-align: right; }
.geo-pin span { display: block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45); }
.geo-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 5px; vertical-align: middle; }
.geo-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.route-groups-bar { margin: 12px 0 0; }
.section-title { margin: 20px 0 8px; color: var(--sand-dark); }
.route-pin span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff;
  color: #fff; font: 700 11px/1 'Open Sans', Arial, sans-serif; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45); }
.route-chip { display: inline-block; min-width: 22px; padding: 1px 8px; border-radius: 99px; color: #fff; font-size: 12px; font-weight: 700; text-align: center; }
.stock-low { color: var(--red); }
/* v1.32 (CR-20): low-stock banner on the dashboard — perfumes under their alert threshold */
.low-stock-banner { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
  background: var(--coral-bg); border: 1px solid var(--coral); border-radius: var(--radius);
  padding: 10px 14px; margin: 0 0 16px; }
.low-stock-banner b { color: #a4583a; }
.low-stock-banner span { flex: 1; min-width: 240px; }
.low-stock-banner .btn { margin-inline-start: auto; }
.customer-counts { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-inline-start: 8px; vertical-align: middle; font-size: 13px; font-weight: 600; }
/* the customer's addresses + devices scroll on their own, like the customer list beside them; the customer's
   name and buttons stay on top */
.site-card[hidden] { display: none; }
/* customer search with a suggestion list under the box (CR-17) */
.search-box { position: relative; }
.search-suggest {
  position: absolute; top: 100%; inset-inline: 0; z-index: 15; margin-top: 4px; max-height: 320px; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); padding: 4px;
}
.suggest-item { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.suggest-item:hover, .suggest-item.active { background: var(--coral-bg); }
.suggest-item b, .customer-item b { color: var(--sand-dark); }
.suggest-empty { padding: 8px; }
.site-card.flash { box-shadow: 0 0 0 3px var(--coral); transition: box-shadow 0.3s; }
.site-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.site-head h3 { margin: 0; flex: 1; }

/* ---------- scheduler ---------- */
.scheduler { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.week { overflow-x: auto; padding-bottom: 4px; }
.pool { position: sticky; top: 72px; max-height: calc(100vh - 100px); overflow-y: auto; }
.pool h3 { display: flex; justify-content: space-between; }
/* v1.33: waiting list folded per area (route number), ordered by distance */
.pool-area-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.pool-area-tools span { flex: 1; }
.pool-area { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--bg); }
.pool-area summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; cursor: pointer; }
.pool-area summary b { color: var(--sand-dark); }
.pool-area[open] summary { border-bottom: 1px solid var(--line); }
.pool-address { display: grid; gap: 6px; padding: 8px 10px; }
.pool-address + .pool-address { border-top: 1px dashed var(--line); }
.pool-address-head { font-size: 12px; font-weight: 600; color: var(--text-2); }
.week { display: grid; gap: 10px; }
.day {
  background: var(--panel); border-radius: var(--radius); min-height: 380px; display: flex; flex-direction: column;
  border: 2px solid transparent;
}
.day.today { border-color: var(--sand); }
.day.past { opacity: 0.55; }
.day-head { padding: 8px 10px; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; }
.day-head small { color: var(--text-2); font-weight: 400; }
.day-body { padding: 0 8px 8px; display: grid; gap: 8px; align-content: start; flex: 1; }
.drop-zone {
  border: 2px dashed var(--line); border-radius: 8px; padding: 14px 6px; text-align: center; color: var(--text-2);
  font-size: 12px; min-height: 52px;
}
.route { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.route.published { border-color: var(--sand-dark); }
.route-head {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line);
  background: #fbf7f3; border-radius: 8px 8px 0 0; cursor: grab;
}
.route-head b { flex: 1; font-size: 14px; }
.route-foot { padding: 6px 8px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
/* v1.32 (CR-16): perfume needed per route — chip list under the stops */
.route-needed { padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border-top: 1px dashed var(--line); }
.chip.small { font-size: 11px; padding: 1px 7px; }
.stops { list-style: none; margin: 0; padding: 4px; display: grid; gap: 4px; }
.view-switch { display: inline-flex; gap: 4px; }
.link-date { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: inherit; cursor: pointer; }
.link-date:hover, .month-date:hover { color: var(--sand-dark); text-decoration: underline; }
.month-head { text-align: center; font-size: 13px; font-weight: 700; color: var(--text-2); padding: 2px 0; }
.day.month-cell { min-height: 118px; }
.day.month-cell.other-month { opacity: 0.45; }
.day.month-cell.past.other-month { opacity: 0.35; }
.month-date { background: none; border: 0; font: inherit; font-weight: 700; text-align: start; padding: 6px 8px 2px; cursor: pointer; color: inherit; }
.month-cell .day-body { gap: 4px; padding: 0 4px 6px; }
.route.mini {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 3px 6px; font-size: 12px; cursor: pointer;
}
.route.mini[draggable="true"] { cursor: grab; }
.route.mini b { font-size: 12px; }
.route.mini .chip { font-size: 11px; padding: 0 6px; }
.dev-card {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px;
  cursor: grab; display: grid; gap: 2px; border-inline-start: 4px solid var(--sand);
}
.dev-card.overdue { border-inline-start-color: var(--red); }
.dev-card.due-today { border-inline-start-color: var(--coral); }
.dev-card.done { cursor: default; opacity: 0.7; border-inline-start-color: var(--green); }
.dev-card .row1 { display: flex; justify-content: space-between; gap: 6px; font-weight: 600; }
.dev-card .row2 { color: var(--text-2); }
.dev-card .icons { display: flex; gap: 4px; flex-wrap: wrap; }
.dragging { opacity: 0.4; }
.drop-hover { outline: 3px solid var(--coral); outline-offset: 1px; background: var(--coral-bg) !important; }
.drop-before { box-shadow: 0 -3px 0 var(--coral); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; vertical-align: middle; }

/* ---------- modal ---------- */
.modal {
  border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.modal::backdrop { background: rgba(26, 26, 26, 0.35); }
.modal-head { padding: 16px 20px; background: var(--sand); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; overflow-y: auto; max-height: calc(100vh - 200px); }
.modal-foot { padding: 12px 20px; display: flex; gap: 8px; justify-content: flex-start; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.days-pick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.days-pick label {
  display: flex; align-items: center; gap: 4px; font-weight: 400; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px;
}
.days-pick input { width: auto; margin: 0; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 600; }
/* dropdown + free-text box ("אחר") for definition-list fields */
.combo { display: flex; gap: 6px; margin-top: 4px; }
.combo select, .combo input { margin-top: 0; font-weight: 400; min-width: 0; }
.inline-label { display: flex; align-items: center; gap: 6px; }
/* active / inactive switch (CR-09): two-part switch in forms, pill button in lists */
.switch-field { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.seg-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.seg-switch label { margin: 0; cursor: pointer; }
.seg-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-switch span { display: block; padding: 6px 16px; font-weight: 600; color: var(--text-2); }
.seg-switch .on input:checked + span { background: var(--green); color: #fff; }
.seg-switch .off input:checked + span { background: var(--grey-bg); color: var(--text); }
.seg-switch input:focus-visible + span { outline: 2px solid var(--coral); outline-offset: -2px; }
.seg-switch .all input:checked + span { background: var(--sand); color: var(--text); }
.seg-small span { padding: 3px 12px; font-size: 13px; }
.hidden-note { margin: 6px 0 0; }
.switch-btn {
  border: 0; border-radius: 99px; padding: 3px 10px 3px 26px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  position: relative; white-space: nowrap;
}
.switch-btn::after {
  content: ''; position: absolute; top: 50%; left: 4px; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.switch-btn.on { background: var(--green); color: #fff; }
.switch-btn.off { background: var(--grey-bg); color: var(--text-2); padding: 3px 26px 3px 10px; }
.switch-btn.off::after { left: auto; right: 4px; }
.switch-btn:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }

/* activity schedules in the device form (CR-07/08) */
.schedule-list { display: grid; gap: 10px; margin: 6px 0 8px; }
.schedule-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; background: var(--panel); }
.schedule-days { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.schedule-days label { display: flex; align-items: center; gap: 3px; font-weight: 400; }
.schedule-days input { width: auto; margin: 0; }
.schedule-days [data-remove-schedule] { margin-inline-start: auto; }
.schedule-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.schedule-fields label { font-size: 13px; }
.schedule-fields .schedule-note { grid-column: 1 / -1; }
@media (max-width: 640px) { .schedule-fields { grid-template-columns: 1fr 1fr; } }
/* v1.32 (CR-10): address codes editor — several codes per address, each a row */
.code-list { display: grid; gap: 8px; margin: 6px 0 8px; }
.code-row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(120px, 1fr) minmax(140px, 1.4fr) auto; gap: 8px; align-items: center; }
.code-row input, .code-row select { width: 100%; }
@media (max-width: 640px) { .code-row { grid-template-columns: 1fr 1fr auto; } .code-row [data-code="note"] { grid-column: 1 / -2; } }
.details dd { white-space: pre-line; }
/* read-only line inside a form (e.g. the last visit's amounts) */
.static-field { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.static-field span { font-weight: 600; }
.static-field b { font-weight: 400; color: var(--text-2); }
.inline-label select { width: auto; }
.check-row input { width: auto; }
.details { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.details dt { color: var(--text-2); }
.details dd { margin: 0; }
.qr-box { text-align: center; }
.qr-box svg { width: 220px; height: 220px; }
.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.copy-row input { direction: ltr; font-size: 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120px); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; transition: transform 0.25s;
  max-width: calc(100vw - 32px);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

/* ---------- printing QR labels ---------- */
.print-area { display: none; }
/* Label printer: one 100 × 60 mm label per page (the printer driver's paper size must also be set to 100 × 60 mm) */
@media print {
  @page { size: 100mm 60mm; margin: 0; }
  html, body { margin: 0; padding: 0; background: #fff; }
  body.printing > *:not(.print-area) { display: none !important; }
  body.printing .print-area { display: block; }
  .label {
    box-sizing: border-box; width: 100mm; height: 60mm; padding: 4mm; overflow: hidden;
    display: flex; gap: 4mm; align-items: center;
    break-after: page; break-inside: avoid;
    color: #000; font-family: 'Open Sans', Arial, sans-serif; font-size: 9.5pt; line-height: 1.25;
  }
  .label:last-child { break-after: auto; } /* no blank label at the end */
  .label svg { width: 50mm; height: 50mm; flex-shrink: 0; }
  .label-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1.2mm; overflow: hidden; max-height: 52mm; }
  .label-text b { font-size: 12pt; line-height: 1.2; }
  .label-text .line { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
  .label .mono { font-size: 14pt; font-weight: 700; letter-spacing: 0.5pt; direction: ltr; text-align: right; }
  .label .brand-small { font-size: 7.5pt; color: #444; margin-top: auto; white-space: nowrap; }
  /* device sticker (no QR), laid out like the client's existing label: text on the right, logo on the left */
  .brand-label { gap: 3mm; padding: 3.5mm 4mm; font-size: 9pt; line-height: 1.3; font-weight: 700; }
  .brand-label .label-text { gap: 0.4mm; max-height: 53mm; }
  .brand-label .perfume { font-size: 15pt; line-height: 1.15; margin-bottom: 1.2mm; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .brand-label .line { -webkit-line-clamp: 1; }
  .brand-label .brand-logo { width: 27mm; height: auto; flex-shrink: 0; align-self: center; }

  /* "הספקה לטכנאים" (v1.30): A4 pages on a normal printer, not the label size above */
  @page sheet { size: A4 portrait; margin: 12mm; }
  .sheet {
    page: sheet; break-after: page; direction: rtl;
    color: #000; font-family: 'Open Sans', Arial, sans-serif; font-size: 10pt; line-height: 1.35;
  }
  .sheet:last-child { break-after: auto; }
  .sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8mm; border-bottom: 2px solid #000; padding-bottom: 3mm; margin-bottom: 4mm; }
  .sheet-head h1 { font-size: 17pt; margin: 0; }
  .sheet-head img { width: 30mm; height: auto; }
  .sheet-sub { font-size: 9.5pt; color: #333; }
  .sheet h2 { font-size: 12.5pt; margin: 5mm 0 2mm; }
  .sheet p { margin: 1mm 0; }
  .sheet .muted { color: #555; }
  .sheet-note { font-size: 9pt; color: #333; border: 1px dashed #777; padding: 2mm 3mm; margin-top: 3mm; }
  .sheet-table { width: 100%; border-collapse: collapse; }
  .sheet-table th, .sheet-table td { border: 1px solid #888; padding: 1.5mm 2mm; text-align: right; vertical-align: top; }
  .sheet-table th { background: #eee; font-weight: 700; }
  .sheet-table tr { break-inside: avoid; }
  .sheet-table thead { display: table-header-group; } /* header repeats on every page */
  .stops-table { font-size: 9pt; }
  .stops-table tr.done td { color: #777; text-decoration: line-through; }
  .stops-table tr.done td.tick { text-decoration: none; }
  .sheet-table .tick { width: 9mm; text-align: center; }
  .sheet-table .box { display: inline-block; width: 4mm; height: 4mm; border: 1.2px solid #000; }
}

@media (max-width: 1000px) {
  .registry, .scheduler { grid-template-columns: 1fr; }
  .pool { position: static; max-height: none; }
  .form-grid { grid-template-columns: 1fr; }
  .view { padding: 16px; }
}

/* ---------- history: Excel-style column filters ---------- */
.col-filter-btn {
  border: 1px solid var(--line); background: var(--bg); color: var(--text-2); border-radius: 6px;
  font-size: 11px; line-height: 1; padding: 3px 5px; cursor: pointer; margin-inline-start: 4px;
}
.col-filter-btn:hover { color: var(--text); border-color: var(--sand); }
.col-filter-btn.active { background: var(--sand); border-color: var(--sand-dark); color: var(--text); }
.col-filter-pop {
  position: absolute; z-index: 50; width: 260px; max-width: calc(100vw - 16px);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14); padding: 10px; display: grid; gap: 8px;
}
.col-filter-list { max-height: 260px; overflow-y: auto; display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 6px; }
.col-filter-list .check-row { font-weight: 400; }
.col-filter-list .check-row span:first-of-type { flex: 1; }
.col-filter-list .check-row[hidden] { display: none; }
.col-filter-foot { display: flex; gap: 8px; }
.table-count { justify-content: space-between; margin-bottom: 8px; }
.table-count[hidden] { display: none; }
/* paging under lists (v1.35) */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-top: 8px; font-size: 13px; color: var(--text-2); }
.pager:empty { display: none; }
.pager-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.pager .btn.current { background: var(--sand); border-color: var(--sand-dark); font-weight: 700; }
.pager .btn:disabled { opacity: 0.45; cursor: default; }
.pager-size select { font: inherit; padding: 2px 4px; margin-inline-start: 4px; }
.pager-compact { justify-content: center; }
@media print { .pager { display: none; } }
/* definitions: the "not in the list" values are folded so the main list can fit the screen (v1.37) */
.unlisted-box { margin-top: 20px; }
.unlisted-box > summary { cursor: pointer; list-style-position: inside; }
.unlisted-box > summary h2 { display: inline; }
.unlisted-box[open] > summary { margin-bottom: 10px; }
/* reminders (v1.40): open count in the top bar, the technician's text under the title */
.nav-badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-inline-start: 4px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.nav-badge[hidden] { display: none; }
.reminder-details { margin-top: 4px; white-space: pre-wrap; color: var(--text-2); font-size: 13px; }

/* ---------- v1.51: phones (up to 700px). The computer layout above is unchanged ---------- */
.nav-toggle, .phone-only { display: none; }
@media (max-width: 700px) {
  .phone-only { display: initial; }
  .desktop-only { display: none; }
  /* folding menu */
  .topbar { gap: 8px 12px; padding: 8px 12px; }
  .nav-toggle {
    display: inline-block; margin-inline-start: auto; border: 1px solid var(--line); background: var(--bg); color: var(--text);
    font: inherit; font-weight: 700; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  }
  .topbar .nav, .topbar .topbar-user { display: none; }
  .topbar.nav-open .nav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; flex-basis: 100%; }
  .topbar.nav-open .topbar-user { display: flex; flex-basis: 100%; justify-content: space-between; }
  .topbar.nav-open .nav a, .topbar.nav-open .nav-group-btn { padding: 10px 12px; background: rgba(255, 255, 255, 0.35); }
  .topbar.nav-open .nav-group { grid-column: 1 / -1; }
  .topbar.nav-open .submenu { position: static; display: grid; box-shadow: none; margin-top: 4px; }
  .view { padding: 12px; }

  /* scheduling: days and technicians one under another instead of side by side */
  .scheduler { display: block; }
  .scheduler > .pool { display: none; }
  .week:not(.month-view) { grid-template-columns: 1fr !important; overflow-x: visible; }
  .pool-open-btn { display: block; width: 100%; margin-bottom: 12px; padding: 12px; font-size: 16px; }
  /* the waiting list as a sheet from the bottom of the screen */
  .scheduler.pool-open > .pool {
    display: block; position: fixed; inset: auto 0 0 0; top: auto; z-index: 40; max-height: 78vh; overflow-y: auto;
    border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25); padding: 14px 14px 24px;
  }
  .scheduler.pool-open > .pool h3 { position: sticky; top: -14px; background: inherit; padding: 6px 0; z-index: 1; align-items: center; gap: 8px; }
  .pool h3 .chip { margin-inline-end: auto; }
  /* bigger targets for fingers */
  .dev-card { padding: 10px 12px; font-size: 15px; }
  .route-head { padding: 10px 12px; cursor: pointer; }
  .route-foot .btn { padding: 8px 14px; }
  .drop-zone { display: none; }
  /* month: 6–7 narrow columns, each route a dot (tap the date to open the day) */
  .month-view { grid-template-columns: repeat(var(--month-cols, 6), minmax(0, 1fr)) !important; gap: 4px; }
  .day.month-cell { min-height: 54px; }
  .month-cell .day-body { display: flex; flex-direction: row; flex-wrap: wrap; gap: 3px; padding: 0 4px 4px; }
  .month-cell .route.mini { font-size: 0; padding: 0; width: 10px; height: 10px; border-radius: 50%; min-height: 0; border-width: 1px; }
  .month-cell .route.mini > * { display: none; }
  .month-cell .route.mini.published { background: var(--sand-dark); }
  .month-head { font-size: 11px; }
  .month-date { padding: 4px 4px 2px; font-size: 13px; }
  .toolbar { gap: 6px; }
}
@media (max-width: 700px) {
  /* v1.52: שיבוץ מסלולים toolbar on a phone — row 1 יום / שבוע / חודש, row 2 previous / this / next, then the rest */
  .schedule-toolbar > * { order: 5; }
  .schedule-toolbar > h1 { order: 0; flex-basis: 100%; }
  .schedule-toolbar > .view-switch { order: 1; flex-basis: 100%; display: flex; gap: 6px; }
  .schedule-toolbar > .view-switch .btn { flex: 1; padding: 10px 6px; }
  .schedule-toolbar > #period-prev, .schedule-toolbar > #period-today, .schedule-toolbar > #period-next { order: 2; flex: 1 1 0; padding: 10px 6px; }
  .schedule-toolbar > .period-label { order: 3; flex-basis: 100%; text-align: center; }
}

/* v1.53: whole-group scheduling and planned trips on each waiting-list group */
.pool-area summary .area-tools { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-inline-start: 6px; vertical-align: middle; }
.pool-area summary .area-tools .btn { padding: 2px 8px; font-size: 12px; }
.trip-chip { border: 1px solid var(--sand-dark); background: #f3e8de; color: var(--sand-dark); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
.trip-chip:hover { background: var(--sand); color: var(--text); }

/* ---------- v1.54: tables on a phone — every row is a card, every cell "column name: value" ---------- */
@media (max-width: 700px) {
  .view table:not(.sheet-table), .view table:not(.sheet-table) tbody, .view table:not(.sheet-table) tfoot,
  .view table:not(.sheet-table) tr, .view table:not(.sheet-table) td { display: block; width: 100%; }
  .view .table-wrap { border: 0; overflow: visible; }
  /* the header becomes a row of small filter buttons (▾ keeps working) */
  .view table:not(.sheet-table) thead { display: block; }
  .view table:not(.sheet-table) thead tr { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 0 6px; }
  .view table:not(.sheet-table) thead th {
    display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 99px;
    font-size: 11px; background: var(--panel); white-space: nowrap;
  }
  .view table:not(.sheet-table) thead th:empty { display: none; }
  .view table:not(.sheet-table) tbody tr, .view table:not(.sheet-table) tfoot tr {
    border: 1px solid var(--line); border-radius: 10px; margin: 0 0 8px; padding: 6px 10px; background: var(--bg);
  }
  .view table:not(.sheet-table) tfoot tr { background: var(--panel); }
  .view table:not(.sheet-table) td {
    border: 0; padding: 3px 0; text-align: start; position: relative; min-height: 24px; overflow-wrap: anywhere;
  }
  .view table:not(.sheet-table) td[data-label] { padding-inline-start: 40%; }
  .view table:not(.sheet-table) td[data-label]::before {
    content: attr(data-label); position: absolute; inset-inline-start: 0; top: 3px; width: 37%;
    color: var(--text-2); font-size: 12px; font-weight: 600;
  }
  .view table:not(.sheet-table) td:empty { display: none; }
  .view td.actions { white-space: normal; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
  .view td.actions[data-label] { padding-inline-start: 0; }
  .view td.actions[data-label]::before { display: none; }
  .registry > section { scroll-margin-top: 70px; }
}

/* v1.55: month view — a day with routes is coloured (light = has drafts, stronger = everything published) */
.day.month-cell.has-routes { background: #f6ece2; border-color: var(--sand); }
.day.month-cell.has-routes.all-published { background: #ead6c3; border-color: var(--sand-dark); }
.day.month-cell.has-routes .month-date { color: var(--sand-dark); }
.day.month-cell.today { border-color: var(--coral); }

/* v1.56: month and year above the month calendar */
.month-wrap { min-width: 0; }
.month-title { margin: 0 0 8px; font-size: 20px; text-align: center; color: var(--sand-dark); }
/* v1.57: previous / next month beside the title */
.month-title-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 8px; }
.month-title-row .month-title { margin: 0; min-width: 140px; }
.month-title-row .btn { font-size: 18px; padding: 4px 14px; line-height: 1; }

/* v1.59: search box on the definitions pages */
.def-search { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; }
.def-search .search-box { flex: 1 1 260px; max-width: 420px; }
.def-search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

/* v1.60: on a phone, card outlines are clearer (darker, thicker border + soft shadow) so each card stands apart */
@media (max-width: 700px) {
  :root { --card-line: #cbb8a8; --card-shadow: 0 2px 6px rgba(80, 55, 35, 0.12); }
  .view table:not(.sheet-table) tbody tr, .view table:not(.sheet-table) tfoot tr,
  .card, .route, .pool-area, .dev-card, .customer-item {
    border: 2px solid var(--card-line); box-shadow: var(--card-shadow);
  }
  .view table:not(.sheet-table) tbody tr { margin-bottom: 12px; }
  .route.published { border-color: var(--sand-dark); }
  .customer-item.active { border-color: var(--coral); border-width: 2px; }
  .dev-card { border-inline-start: 4px solid var(--sand-dark); }
  .dev-card.overdue { border-inline-start: 4px solid var(--red); }
  .dev-card.due-today { border-inline-start: 4px solid var(--coral); }
  .dev-card.done { border-inline-start: 4px solid var(--green); }
}

/* v1.65: approved changes of technicians' hours, above the scheduler */
.availability-card { margin-bottom: 12px; background: #fff8e6; border-color: #f0dcae; }

/* v1.66: a chip on the schedule that opens the full visit */
.chip-link { border: 0; font: inherit; font-size: inherit; cursor: pointer; text-decoration: underline; }
.visit-details { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.visit-details dt { color: var(--text-2, #69727d); }
.visit-details dd { margin: 0; font-weight: 600; white-space: pre-line; overflow-wrap: anywhere; }
