:root {
  --accent: #16a34a;
  --accent-dark: #15803d;
  --accent-soft: #dcfce7;
  --accent-faint: #f0fdf4;
  --accent-tint: #e2f6e8; /* the add bars, a bit darker than faint */
  --bg: #eceef1;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --neg: #b91c1c;
  --nav: #c62828;
  --nav-dark: #a31f1f;
  --note: #f8f1d8;
  --note-border: #e6d498;
  --remarks: #d9480f; /* item remarks: a vivid orange on the note's yellow (the note's own remarks are green) */
  --radius: 8px;
  --avatar: 22px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 1px 3px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 30px rgb(0 0 0 / 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

/* always keep room for the scrollbar, so short and long pages line up */
html { scrollbar-gutter: stable; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

button, input, select { font: inherit; color: inherit; }

a { color: var(--accent-dark); text-decoration: none; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* numbers and dates keep their left to right order in hebrew */
.ltr, .price, .date-input, .note-title small { direction: ltr; unicode-bidi: isolate; }
.spacer { flex: 1; }

.icon { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; }
.icon svg { width: 100%; height: 100%; }

/* ---------- navbar ---------- */

#nav:empty { display: none; }

#nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: var(--nav);
  color: #fff;
}

.login-logo {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.nav-links {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: var(--radius);
  color: rgb(255 255 255 / 0.8);
  font-weight: 500;
  white-space: nowrap;
}

.nav-links a:hover { background: var(--nav-dark); color: #fff; }
.nav-links a.active { background: #fff; color: var(--nav); }

/* on the red bar: white logo, translucent controls */
#nav .avatar { box-shadow: 0 0 0 2px rgb(255 255 255 / 0.85); }
#nav .icon-button { color: #fff; }
#nav .icon-button:hover { background: var(--nav-dark); color: #fff; }

.nav-user { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.lang-item { width: 100%; border: 0; background: none; font: inherit; text-align: start; }
.lang-item.active { background: var(--accent-soft); }
.user-name { font-weight: 500; }

@media (max-width: 1100px) {
  .nav-links a span:not(.icon) { display: none; }
}

/* ---------- layout ---------- */

main { padding: 20px; max-width: 1600px; margin: 0 auto; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.toolbar h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  margin-inline-end: 4px;
  font-size: 18px;
  font-weight: 650;
  white-space: nowrap;
}

.toolbar h1 .icon { color: var(--accent); width: 20px; height: 20px; }
.toolbar > .input, .filters > .input { width: 150px; }
.toolbar > .ac, .filters > .ac { width: 150px; min-width: 0; }
.toolbar > .ms-button, .filters > .ms-button { width: 130px; min-width: 0; }
.toolbar .daterange .datepicker.with-time { width: 180px; }
.toolbar > .muted { margin-inline-end: 8px; white-space: nowrap; }

/* the filters sit in the toolbar row; on a phone they fold behind the filter button */
.filters { display: contents; }
.toolbar .filter-toggle, .toolbar .sort-select { display: none; }
.filter-toggle .count:not(:empty) { min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; }

.page-actions { display: flex; gap: 8px; margin-inline-start: auto; }
/* balance: the filter inputs shrink before the bar wraps (a line breaks by their 80px basis, then they grow back up to their width).
   the bar stays the table's width */
@media (min-width: 641px) {
  .toolbar-balance .filters > .input { flex: 1 1 70px; max-width: 150px; }
  .toolbar-balance .filters > .ms-button { flex: 1 1 80px; max-width: 130px; }
}

.totals { display: flex; gap: 12px; margin-inline-end: 8px; padding-inline-end: 12px; border-inline-end: 1px solid var(--border); color: var(--muted); font-size: 13px; white-space: nowrap; }
.totals:empty { display: none; }
.totals b { color: var(--text); font-size: 14px; }

/* ---------- controls ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.button:hover:not(:disabled) { background: var(--bg); }
.button:disabled { opacity: 0.45; cursor: default; }
.button.small { height: 28px; padding: 0 10px; font-size: 13px; }
.button.block { width: 100%; }
.button.secondary { background: #dcdfe4; border-color: #cbd0d6; } /* a gray fill a shade darker than the page: a plain white button next to inputs looks like one of them */
.button.secondary:hover:not(:disabled) { background: #cbd0d6; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--accent-dark); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.danger:hover { background: #b91c1c; }
.button.danger-outline { color: var(--danger); border-color: #fca5a5; }
.button.danger-outline:hover { background: var(--danger-soft); }
.button .icon { width: 16px; height: 16px; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-dark);
  font-weight: 500;
  cursor: pointer;
}

.link:hover { text-decoration: underline; }

/* a list value that fills the add row when clicked */
.pick {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.pick:hover, .pick:hover .client-name { text-decoration: underline; }

.input, .select, .ac-input, .date-input, .ms-button {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .select:focus, .ac-input:focus, .date-input:focus, .ms-button:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(22 163 74 / 0.15);
}

.input::placeholder, .ac-input::placeholder, .date-input::placeholder { color: var(--faint); }
.select.empty { color: var(--faint); }
.select option { color: var(--text); }
input:disabled, select:disabled { background: var(--bg); color: var(--muted); }

.invalid, .invalid .ac-input, .invalid .password-input, .input.invalid, .date-input.invalid { border-color: var(--danger) !important; }

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button { opacity: 0.4; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* autocomplete */
.ac { position: relative; display: flex; align-items: center; min-width: 150px; }
.ac-prefix { position: absolute; inset-inline-start: 6px; display: flex; pointer-events: none; }
.ac-prefix:empty { display: none; }
.ac.has-prefix .ac-input { padding-inline-start: 36px; }
/* the input is dir auto, which reads an empty one as ltr: until something is typed it follows the ui, so the placeholder is on the rtl ui's right */
[dir="rtl"] .ac-input:placeholder-shown { direction: rtl; }
.ac-list { max-width: min(360px, calc(100vw - 16px)); max-height: 280px; overflow-y: auto; padding: 4px; }
.ac-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.ac-item > span:not(.avatar) { min-width: 0; overflow: hidden; text-overflow: ellipsis; } /* long names are cut, the full one is the title */
.ac-item > :is(.avatar, small) { flex: none; }
.ac-item small { margin-inline-start: auto; padding-inline-start: 12px; color: var(--muted); }
.ac-item.active { background: var(--accent-soft); }
.ac-empty { padding: 8px; color: var(--muted); }

/* multiselect */
.ms-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 130px;
  max-width: 220px;
  text-align: start;
  cursor: pointer;
}
.ms-button span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-button.empty { color: var(--faint); }
.caret { border: 4px solid transparent; border-top-color: var(--muted); margin-top: 4px; }
.ms-list { padding: 4px; max-height: 300px; overflow-y: auto; }
.ms-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.ms-item:hover, .ms-item:has(input:focus-visible) { background: var(--bg); }

/* password field: an eye button at the end shows or hides the text */
.password-field { position: relative; display: flex; align-items: center; width: 100%; }
.password-input { padding-inline-end: 32px; }
.password-toggle { position: absolute; inset-inline-end: 2px; width: 28px; height: 28px; }
.password-toggle .icon { width: 16px; height: 16px; }

/* datepicker */
/* date fields keep the left to right layout in hebrew too: text on the left, calendar icon on the right */
.datepicker { position: relative; display: inline-flex; align-items: center; width: 140px; direction: ltr; }
.datepicker.with-time { width: 180px; }
.date-input { padding-inline-end: 32px; font-variant-numeric: tabular-nums; }
.calendar-button { position: absolute; inset-inline-end: 2px; width: 28px; height: 28px; }
.calendar-button .icon { width: 16px; height: 16px; }
.daterange { display: inline-flex; align-items: center; gap: 4px; }
.calendar { padding: 10px; width: 260px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.calendar-time { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); direction: ltr; }
.calendar-time .icon { color: var(--muted); }
.calendar-time .select { width: auto; height: 30px; padding: 0 6px; font-variant-numeric: tabular-nums; }
.calendar-time .button { margin-inline-start: auto; }
.weekday { color: var(--muted); font-size: 12px; padding: 4px 0; }
.day { height: 32px; border: 0; border-radius: 6px; background: none; cursor: pointer; font-variant-numeric: tabular-nums; }
.day:hover { background: var(--bg); }
.day.other { color: var(--faint); }
.day.today { box-shadow: inset 0 0 0 1px var(--accent); }
.day.selected { background: var(--accent); color: #fff; }
.flip.rotate .icon, [dir="rtl"] .flip:not(.rotate) .icon { transform: rotate(180deg); }
[dir="rtl"] .flip.rotate .icon { transform: none; }

/* popup */
.popup {
  position: fixed;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

/* ---------- avatar ---------- */

.avatar {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: var(--avatar);
  height: var(--avatar);
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.client { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
/* a long name would stretch its whole column, the add row input with it: cut it, the full name is the title */
table.list td .client { max-width: 260px; }
table.list td .client-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- list ---------- */

.bulk {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 3px;
  padding-inline-start: 10px;
  background: var(--accent-faint);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius);
  white-space: nowrap;
}

.bulk.visible { display: flex; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table.list { width: 100%; border-collapse: collapse; }

table.list th, table.list td {
  padding: 6px 10px;
  text-align: start;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.list th {
  position: sticky;
  top: 0;
  background: #fafafa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  user-select: none;
}

table.list th.sortable { cursor: pointer; }
table.list th.sortable:hover { color: var(--text); }
table.list th.sorted { color: var(--accent-dark); }
table.list th.sorted::after { content: " ▲"; font-size: 9px; }
table.list th.sorted.desc::after { content: " ▼"; }

table.list tbody tr:last-child td { border-bottom: 0; }
table.list tr.empty td { padding: 32px; text-align: center; color: var(--muted); }

table.list .check { width: 36px; }
table.list td.id, .id { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; width: 56px; white-space: nowrap; }
table.list .row-action { width: 70px; }
td.col-price, td.col-int { font-variant-numeric: tabular-nums; white-space: nowrap; }

table.list tr.new-row td { background: var(--accent-faint); padding-block: 6px; }
table.list tr.new-row .input, table.list tr.new-row .select { min-width: 80px; }
table.list tr.new-row .datepicker { width: 180px; }

/* orders: the add row and the folding search row are bars above the table, sized by their fields */
/* the add bar is a card, the search bar under it sits on the page as is */
.top-bars { margin-bottom: 12px; }
.add-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--accent-tint); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.add-bar > [data-label] { width: 180px; }
.add-bar > :is(.col-int, .col-price) { width: 100px; }
.add-bar > .col-type { width: 140px; }
.add-bar > .col-text { flex: 1 1 180px; max-width: 320px; }
.add-bar .ac { min-width: 0; }
.add-bar > .row-action { margin-inline-start: auto; }
.search-bar { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; }
.search-bar > .search-toggle { flex: none; margin-block: 3px; }
.search-bar > .filters { display: none; flex: 1; flex-wrap: wrap; align-items: center; gap: 8px; }
.search-bar.open > .filters { display: flex; }
.search-bar > .filters > :is(.input, .ac, .ms-button) { flex: 1 1 70px; max-width: 150px; }
.search-toggle { gap: 6px; }
.search-toggle .count:not(:empty) { min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; }
.search-toggle .chevron { font-size: 10px; transition: transform .15s; }
.search-bar.open .search-toggle .chevron { transform: rotate(180deg); }

.price { font-variant-numeric: tabular-nums; }
.price.neg { color: var(--neg); }
.price.pos { color: var(--accent-dark); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--bg); color: var(--muted); }
.badge-new { background: #fef3c7; color: #92400e; }
.badge-done { background: var(--accent-soft); color: var(--accent-dark); }
.badge-admin { background: #ede9fe; color: #5b21b6; }

/* type accent colors (front/js/colors.js): a soft background and a dark text on it */
.type-red { --type-bg: #fecaca; --type-fg: #991b1b; }
.type-orange { --type-bg: #fed7aa; --type-fg: #9a3412; }
.type-amber { --type-bg: #fde68a; --type-fg: #92400e; }
.type-lime { --type-bg: #d9f99d; --type-fg: #3f6212; }
.type-green { --type-bg: #bbf7d0; --type-fg: #166534; }
.type-teal { --type-bg: #99f6e4; --type-fg: #115e59; }
.type-sky { --type-bg: #bae6fd; --type-fg: #075985; }
.type-indigo { --type-bg: #c7d2fe; --type-fg: #3730a3; }
.type-purple { --type-bg: #e9d5ff; --type-fg: #6b21a8; }
.type-pink { --type-bg: #fbcfe8; --type-fg: #9d174d; }
.type-badge { background: var(--type-bg, var(--bg)); color: var(--type-fg, var(--text)); white-space: nowrap; }

.swatches { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; }
.swatches.disabled { opacity: 0.5; pointer-events: none; }
.swatch {
  display: inline-block; width: 22px; height: 22px; flex-shrink: 0; border-radius: 999px;
  background: var(--type-bg); border: 2px solid var(--type-fg); vertical-align: middle;
}
.swatches .swatch { cursor: pointer; }
.swatches .swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--type-fg, var(--text)); }
.swatches .swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* no color: white, crossed out */
.swatch-none { background: linear-gradient(to top right, transparent 45%, var(--faint) 45% 55%, transparent 55%), var(--surface); border-color: var(--border-strong); }

@keyframes flash {
  from { background: #86efac; }
  to { background: transparent; }
}

table.list tr.flash td { animation: flash 3s ease-out; }

/* a new order glows in the notes' yellow */
@keyframes flash-note {
  from { background: #f5e3a3; }
  to { background: transparent; }
}

table.list-orders tr.flash td { animation-name: flash-note; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 2px;
}

.pager-nav { display: flex; align-items: center; gap: 6px; }
.pager-nav span { padding: 0 8px; white-space: nowrap; }
.page-size { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.page-size .select { width: auto; height: 28px; }

/* ---------- modal ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(17 24 39 / 0.35);
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.modal.small { max-width: 400px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; }
.modal h2 { margin: 0; font-size: 17px; }
.modal h2 .id { font-weight: 400; }
.modal-body { padding: 8px 20px; overflow-y: auto; }
.modal-body p { margin: 4px 0 12px; }
.modal footer { display: flex; gap: 8px; padding: 12px 20px 16px; }

.form { display: grid; gap: 12px; }
.form-field { display: grid; gap: 4px; }
.form-field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.form-field .datepicker, .form-field .ac { width: 100%; }
.field-error { color: var(--danger); font-size: 12px; }
.field-error:empty { display: none; }

/* ---------- toasts ---------- */

#toasts {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  z-index: 200;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: 380px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.4s, transform 0.4s;
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--accent-dark); }
.toast.hide { opacity: 0; transform: translateY(8px); }

/* ---------- login ---------- */

.login { display: grid; place-items: center; min-height: calc(100vh - 40px); }

.login-card {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 340px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0 0 8px; }
.login-logo { width: 44px; height: 44px; margin: 0 auto; border-radius: 12px; font-size: 22px; }
.login-error { color: var(--danger); min-height: 1em; font-size: 13px; }

/* ---------- notes board ---------- */

/* the add line is a card like the orders add bar */
.add-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; padding: 8px 12px;
  background: var(--accent-tint); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.add-line > .ac { width: 160px; }
.add-line > .input[type="number"] { width: 70px; }
.add-line > .input:not([type="number"]) { flex: 1; min-width: 100px; }
.new-note { display: flex; align-items: center; gap: 6px; padding: 0 4px; color: var(--muted); white-space: nowrap; cursor: pointer; }

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}

.note {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--note);
  border: 1px solid var(--note-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.note-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 2px 6px;
  padding: 4px 8px;
  border-bottom: 1px dashed var(--note-border);
}
/* the buzzer circle overlaps the note's top end corner: the top row ends clear of it (the remarks row under it keeps the width) */
.buzzer + .note-head > :is(.note-title:not(:has(+ .note-send)), .note-send) { margin-inline-end: 20px; }

/* the note title: a top row of two columns, the client and then the date and pencil,
   and under it a short row for the remarks when there are any. everything sits at the top:
   the top row's cells are all the avatar's height, with their text centered in it.
   the name is never cut: a long one wraps beside the date */
.note-title { display: flex; align-items: flex-start; gap: 8px; flex: 1; min-width: 0; }
.note-title .pick { display: flex; flex: 0 1 auto; min-width: 0; }
.note-title .client { display: flex; align-items: flex-start; min-width: 0; }
.note-title .client-name { padding-block: calc((var(--avatar) - 1lh) / 2); white-space: normal; overflow-wrap: anywhere; font-weight: 600; }
.note-title small { display: flex; align-items: center; flex-shrink: 0; height: var(--avatar); margin-left: auto; color: color-mix(in srgb, var(--muted), var(--faint)); font-size: 11px; font-variant-numeric: tabular-nums; }
/* the date is ltr (for its digits), so its inline start is always its left: the margin that pushes it to the line end is set by the ui direction */
[dir="rtl"] .note-title small { margin-left: 0; margin-right: auto; }

/* the note's remarks: a row of their own under the client and time */
/* it starts under the client name, past the avatar and its gap */
.note-remarks-row { display: flex; flex-basis: 100%; min-width: 0; padding-inline-start: calc(var(--avatar) + 8px); }
.note-remarks {
  min-width: 0; padding: 0; border: 0; background: none; font: inherit; font-size: 12px; line-height: 1.25; color: var(--accent-dark);
  text-align: start; overflow-wrap: anywhere; cursor: text; unicode-bidi: plaintext;
}
.note-remarks:hover { text-decoration: underline dotted; }
.note-remarks-add { flex-shrink: 0; order: 1; opacity: 0.35; }
/* the title's buttons are the avatar's height, on a phone too */
.note-head :is(.note-remarks-add, .note-send) { width: var(--avatar); height: var(--avatar); }
.note-remarks-add[hidden] { display: none; }
.note-remarks-add:hover, .note-remarks-add:focus-visible { opacity: 1; }
.note-remarks-input { flex: 1; min-width: 0; height: 28px; padding: 2px 6px; font-size: 13px; }

/* small circle overlapping the note's top end corner (top right, top left in rtl) */
.buzzer {
  position: absolute;
  top: -9px;
  inset-inline-end: -9px;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  border: 2px solid var(--bg);
  border-radius: 999px;
  background: var(--muted);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow);
}

.note-send { color: var(--accent); }
/* the title's two icons, the remarks pencil and the send plane, are the same size */
.note-remarks-add .icon, .note-send .icon { width: 15px; height: 15px; }
.note-send:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-dark); }
/* the plane points forward: flip it in rtl */
[dir="rtl"] .note-send .icon { transform: scaleX(-1); }

.note-lines { display: grid; gap: 2px; min-height: 44px; padding: 4px; }

.line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  /* a light wash of its type's color. without a type there's nothing to mix, so no background */
  background: color-mix(in srgb, var(--type-bg) 45%, transparent);
  cursor: grab;
}

.line:hover { background: var(--type-bg, #fff); }
.line .qty { min-width: 22px; font-weight: 700; color: var(--accent-dark); font-variant-numeric: tabular-nums; }
.line .line-text { display: grid; flex: 1; min-width: 0; }
.line .line-text small { color: var(--remarks); }
.line .served {
  appearance: none; display: grid; place-content: center; flex-shrink: 0;
  width: 20px; height: 20px; margin: 0; border-radius: 5px;
  background: var(--surface); border: 1px solid var(--border-strong);
}
.line .served:checked { background: var(--accent); border-color: var(--accent); }
.line .served:checked::after {
  content: ''; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}
.line .price { font-size: 12px; }
.line-delete { width: 26px; height: 26px; }
.line-delete:hover:not(:disabled) { color: var(--danger) !important; background: var(--danger-soft) !important; }
.line-delete:disabled { opacity: 0.3; cursor: not-allowed; }
.line-delete .icon { width: 14px; height: 14px; }


@keyframes glow {
  0%, 30% { background: #bbf7d0; box-shadow: 0 0 0 3px #4ade80; }
  100% { background: color-mix(in srgb, var(--type-bg) 45%, transparent); box-shadow: 0 0 0 3px transparent; }
}

.line.glow { animation: glow 3s ease-out; }


/* ---------- drag and drop ---------- */

.drag-handle { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.note-head.drag-handle { cursor: grab; }
.dragging { display: none !important; }
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; }

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 300;
  pointer-events: none;
  opacity: 0.92;
  box-shadow: var(--shadow-lg);
  transform-origin: top left;
}

.drag-placeholder {
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: var(--accent-faint);
}

/* ---------- phone ---------- */

@media (max-width: 640px) {
  /* 16px text keeps ios from zooming into a focused field; taller controls are easier to tap */
  body, button, input, select { font-size: 16px; }
  .input, .select, .ac-input, .date-input, .ms-button, .button { height: 42px; }
  .button.small { height: 36px; font-size: 14px; }
  .icon-button { width: 38px; height: 38px; }
  input[type="checkbox"] { width: 20px; height: 20px; }

  /* one short row: the page tabs as icons, then the language globe and sign out */
  #nav { height: 48px; padding: 0 4px; gap: 2px; }
  .nav-links { gap: 0; }
  .nav-links a { flex: 1 1 0; justify-content: center; min-width: 0; padding: 7px 0; }
  .nav-links a .icon { width: 21px; height: 21px; }
  .nav-links a span:not(.icon) { display: none; }
  .nav-user { gap: 0; }
  .nav-user .avatar, .user-name { display: none; }
  #nav .nav-user .lang-button { width: 34px; height: 34px; }

  main { padding: 12px; }

  #toasts { inset-inline: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }

  /* toolbar: title and the filter and sort controls on top, everything else full width under them */
  .toolbar h1 { width: 100%; font-size: 20px; }
  .toolbar .filter-toggle { display: inline-flex; flex: 1; }
  .toolbar .sort-select { display: block; flex: 1; width: auto; min-width: 0; }
  .filters { display: none; flex-wrap: wrap; gap: 8px; width: 100%; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
  .filters-open .filters { display: flex; }
  .filters-open .filter-toggle { background: var(--accent-soft); border-color: var(--accent); }
  .filters > .input, .filters > .ac, .filters > .ms-button, .filters > .daterange { width: 100%; max-width: none; }
  .filters > .button { flex: 1; }
  .filters .daterange { flex-direction: column; gap: 8px; }
  .filters .daterange > .muted { display: none; }
  .filters .daterange .datepicker, .toolbar .daterange .datepicker.with-time { width: 100%; }
  .totals { order: 1; width: 100%; justify-content: space-between; margin: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
  .bulk, .bulk.visible { order: 2; flex-wrap: wrap; width: 100%; white-space: normal; padding: 8px 10px; }
  .page-actions { order: 3; flex-wrap: wrap; width: 100%; margin: 0; }
  .page-actions .button { flex: 1 1 auto; }

  /* list: every row is a compact card: the checkbox, the values and the row action on one line,
     long values are cut. columns with line: 2 go on a second, smaller line */
  .table-wrap { overflow: visible; background: none; border: 0; box-shadow: none; }
  table.list, table.list tbody { display: block; }
  table.list thead { display: none; }
  table.list tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
    margin-bottom: 6px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
  }
  table.list td { padding: 0; border: 0; }
  table.list td.check { flex: none; width: auto; }
  table.list tr:not(.new-row) td.id, table.list td.col-password { display: none; }
  table.list .row-action { flex: none; width: auto; order: 1; margin-inline-start: auto; }
  table.list .row-action .icon-button { width: 32px; height: 32px; }
  /* the first line never wraps: text values share its free width (and are cut), dates, numbers and badges keep theirs */
  table.list tr:not(.new-row) td[data-label] { order: 1; flex: 1 1 0; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  table.list tr:not(.new-row) td:is(.col-date, .col-price, .col-int, .col-enum, .col-password) { flex: none; }
  table.list tr:not(.new-row) td[data-label]:empty { display: none; }
  table.list tr:not(.new-row) td.col-date { order: 0; color: var(--muted); font-size: 13px; }
  /* orders read client, then date */
  table.list-orders tr:not(.new-row) td.col-date { order: 1; }
  /* a value is cut at its own end: a hebrew name in the english ui (or the opposite) keeps its start */
  table.list tr:not(.new-row) td, table.list td .pick { unicode-bidi: plaintext; text-align: left; }
  [dir="rtl"] table.list tr:not(.new-row) td, [dir="rtl"] table.list td .pick { text-align: right; }
  table.list td .pick { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  table.list td .client { display: flex; min-width: 0; max-width: 100%; }
  table.list td .client-name { overflow: hidden; text-overflow: ellipsis; }
  table.list td .year { display: none; }
  table.list td .avatar { width: 20px; height: 20px; font-size: 9px; }
  table.list tr:has(> .line-2:not(:empty))::after { content: ""; order: 2; flex-basis: 100%; }
  table.list tr:not(.new-row) td.line-2 { order: 3; flex: none; max-width: 100%; font-size: 13px; }
  table.list tr:not(.new-row) td.line-2:is(.col-text, .col-product) { flex: 1 1 0; min-width: 0; }
  table.list td.line-2.col-int::before { content: "×"; color: var(--muted); }
  table.list td.line-2.col-text { color: var(--muted); }
  table.list tr.flash { animation: flash 3s ease-out; }
  table.list tr.flash td { animation: none; }
  table.list-orders tr.flash { animation-name: flash-note; }
  table.list tr.empty td { width: 100%; padding: 24px; }

  /* the add row: a compact form card, the placeholders name the fields; numbers and type share a line */
  table.list tr.new-row { gap: 8px; padding: 10px; background: var(--accent-faint); border-color: var(--accent-soft); }
  table.list tr.new-row td { background: none; padding: 0; }
  table.list tr.new-row td:not([data-label]):not(.row-action), table.list tr.new-row td[data-label]:empty { display: none; }
  table.list tr.new-row td[data-label] { display: block; width: 100%; min-height: 0; border: 0; text-align: start; }
  table.list tr.new-row td[data-label]::before { display: none; }
  table.list tr.new-row td.col-int, table.list tr.new-row td.col-price { flex: 1 1 0; min-width: 0; }
  table.list tr.new-row td.col-price ~ td.col-type { flex: 1.5 1 0; min-width: 0; }
  table.list tr.new-row .datepicker, table.list tr.new-row .ac { width: 100%; }
  table.list tr.new-row .input, table.list tr.new-row .select { min-width: 0; }
  table.list tr.new-row .row-action { order: 2; width: 100%; }
  table.list tr.new-row .row-action .button { width: 100%; height: 42px; font-size: 16px; }
  /* the add bar is the same form card, the search bar is replaced by the filter button */
  .top-bars { margin-bottom: 6px; }
  .add-bar { padding: 10px; border-color: var(--accent-soft); border-radius: 10px; }
  .add-bar > [data-label] { width: 100%; }
  .add-bar > :is(.col-int, .col-price) { flex: 1 1 0; width: auto; min-width: 0; }
  .add-bar > .col-price ~ .col-type { flex: 1.5 1 0; width: auto; min-width: 0; }
  .add-bar > .col-text { flex: 1 1 100%; max-width: none; }
  .add-bar .datepicker { width: 100%; }
  .add-bar > .row-action { width: 100%; margin: 0; }
  .add-bar > .row-action .button { width: 100%; height: 42px; font-size: 16px; }
  .search-bar { display: none; }

  .pager { justify-content: center; }
  .pager > .muted { width: 100%; text-align: center; }

  /* dialogs slide up from the bottom */
  .overlay { place-items: end stretch; padding: 0; }
  .modal, .modal.small { max-width: none; max-height: 92dvh; border-radius: 16px 16px 0 0; }
  .modal footer { flex-wrap: wrap; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal footer .button { flex: 1; }
  .modal footer .spacer { display: none; }

  /* notes: the add line stacks, the notes take the full width */
  .add-line { padding: 10px; border-color: var(--accent-soft); border-radius: 10px; }
  .add-line > .ac { width: 100%; }
  .add-line > .input[type="number"] { width: 72px; }
  .add-line > .input:not([type="number"]) { flex: 1 1 calc(100% - 80px); }
  .add-line > .new-note { flex: 1; padding: 0; }
  .notes-grid { grid-template-columns: 1fr; gap: 16px; }
  .line { padding: 6px; }
  .line .served { width: 24px; height: 24px; }
  .line .price { font-size: 13px; }
  .line-delete { width: 36px; height: 36px; }
  .line-delete .icon { width: 16px; height: 16px; }

  .login { min-height: calc(100dvh - 24px); }
  .login-card { padding: 24px; }
}
