/* 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); }
.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); }
.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; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
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; }
.customer-list { display: grid; gap: 4px; max-height: calc(100vh - 220px); overflow-y: auto; }
.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); }
.site-card { margin-bottom: 16px; }
.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; }
.zone-title { font-size: 13px; color: var(--sand-dark); font-weight: 700; margin: 12px 0 6px; }
.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; }
.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; }
.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; } }
.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; }
}

@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; }
.history-count { justify-content: space-between; margin-bottom: 8px; }
