:root {
  --ground: #f6f2ea;
  --surface: #fffdf9;
  --ink: #2b2520;
  --muted: #6a6158;
  --line: #eae3d6;
  /* Cards and widgets: a heavier edge than inner dividers and fields. */
  --card-border: 1.5px solid #e0d5c1;
  --accent: #e6d8bc;
  --soft: #f1eadc;
  --selected: #efe4cc;
  --bar: #bba477;
  --bar-off: #ede7db;
  --late: #8a4538;
  --late-bg: #f7ece7;
  --focus: #8a7650;
  --focus-ring: 0 0 0 3px rgba(138, 118, 80, 0.16);
  --shadow: 0 12px 32px rgba(43, 37, 32, 0.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* No grey flash on tap; the press itself is shown by a soft change of colour. */
html { -webkit-tap-highlight-color: transparent; }
a, button, summary, label, .dd-button { touch-action: manipulation; }
/* Moving between pages fades instead of flashing. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.page { max-width: 560px; margin: 0 auto; padding: 16px 20px 112px; }
.page.bare { padding-bottom: 32px; }

.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.logo { position: relative; display: block; width: 108px; height: 62px; overflow: hidden; }
.logo img { position: absolute; left: -16px; top: -32px; width: 140px; height: 140px; }
.top-start { display: flex; align-items: center; gap: 10px; }
.round {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid var(--line); border-radius: 22px;
  background: var(--surface);
}

h1 { margin: 0; font-size: 22px; font-weight: 500; line-height: 1.4; }
h2 { margin: 28px 0 12px; font-size: 15px; font-weight: 600; }
h3 { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.4; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.sub { margin: 2px 0 20px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.only-wide { display: none !important; }
.js .no-js { display: none !important; }

/* Labelled facts under a name: «رقم الطلب 14  الموديل …  العدد 2». */
.facts { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; color: var(--ink); }
.facts > span { white-space: nowrap; }
.facts i { font-style: normal; color: var(--muted); }

/* Amounts: the number, with a small currency beside it. */
.amt { white-space: nowrap; }
.cur { margin-inline-start: 3px; font-size: .72em; font-weight: 400; color: var(--muted); }

/* Widgets */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  min-height: 92px; padding: 14px;
  border: var(--card-border); border-radius: 22px;
  background: var(--surface);
  text-decoration: none;
}
.tile[aria-current="true"] { background: var(--selected); border-color: var(--selected); }
.tile b { font-size: 26px; font-weight: 500; line-height: 1.1; }
.tile.late b { color: var(--late); }
.tile > span { font-size: 12px; line-height: 1.4; }
.tile b .cur { font-size: 12px; }
/* A long amount in a narrow tile: the currency drops to its own line instead of running out of the card. */
.tile b .amt { display: inline-flex; flex-wrap: wrap; align-items: baseline; }

/* Cards */
.stack { display: flex; flex-direction: column; gap: 12px; }
.card { padding: 18px; border: var(--card-border); border-radius: 22px; background: var(--surface); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card h3 a { text-decoration: none; }
.pill { flex: none; display: inline-block; padding: 3px 10px; border-radius: 10px; background: var(--soft); font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.late { background: var(--late-bg); color: var(--late); }
.pill.paid { background: var(--selected); }
.pill.off { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.payment.cancelled { opacity: .6; }
.payment.cancelled h3 { text-decoration: line-through; }
.empty { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; }

.steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; margin-top: 16px; }
.steps i { display: block; height: 4px; border-radius: 2px; background: var(--bar-off); }
.steps i.on { background: var(--bar); }
.stage-text { margin-top: 8px; font-size: 13px; }
.piece-head { display: flex; gap: 14px; align-items: flex-start; }
.piece-photo { position: relative; flex: none; width: 64px; height: 84px; overflow: hidden; border-radius: 12px; background: var(--selected); }
.piece-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.piece-text { flex: 1 1 auto; min-width: 0; }
.piece-text .pill { margin-bottom: 4px; }
/* How many pieces, as a number in a box. */
.count-box { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 58px; padding: 4px 10px; border: 1px solid #d9ccb4; border-radius: 12px; background: var(--surface); }
.count-box small { color: var(--muted); font-size: 11px; line-height: 1.3; }
.count-box b { font-size: 20px; font-weight: 600; line-height: 1.2; }
.job-piece-head h3 .pill { font-size: 12px; font-weight: 500; }
.piece-text h3 .muted { font-size: 13px; font-weight: 400; white-space: nowrap; }
.work-note { margin-top: 8px; padding: 8px 12px; border-radius: 12px; background: var(--late-bg); color: var(--late); font-size: 13px; }

.actions { display: flex; align-items: stretch; gap: 8px; margin-top: 16px; }
.actions form { display: flex; gap: 8px; margin: 0; min-width: 0; }
.actions form.grow { flex: 1 1 auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 16px;
  border: 0; border-radius: 15px;
  background: var(--accent);
  font-size: 15px; font-weight: 500; text-align: center; text-decoration: none; white-space: nowrap;
  cursor: pointer;
}
.btn.grow { flex: 1 1 auto; }
.btn.block { width: 100%; }
.btn.quiet { border: 1px solid var(--line); background: transparent; font-size: 14px; font-weight: 400; }
.btn:disabled { opacity: .6; cursor: default; }

/* Fields: one look everywhere, and the border itself marks the field being typed in. */
label { display: block; font-size: 13px; color: var(--muted); }
input, select, textarea, .dd-button {
  display: block; width: 100%; min-width: 0; min-height: 48px; margin-top: 4px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 15px;
  background: var(--surface);
  color: var(--ink); font-size: 16px; text-align: right;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus, .dd-button:focus, .dd[data-open] .dd-button {
  outline: none; border-color: var(--focus); box-shadow: var(--focus-ring);
}
input[type="file"] { display: none; }
/* Number fields without the browser's up and down arrows. */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
textarea { min-height: 88px; resize: vertical; }
select { padding-left: 36px; background: var(--surface) url("/chevron.svg") no-repeat left 14px center; }
.actions select, .actions .dd { flex: 1 1 40%; min-width: 0; margin-top: 0; }
.actions .dd-button { margin-top: 0; }
[dir="ltr"] { text-align: right; }

.with-unit { position: relative; display: block; }
.with-unit input { padding-left: 52px; }
.with-unit .cur { position: absolute; left: 14px; top: calc(50% + 2px); transform: translateY(-50%); font-size: 13px; }

/* Dates: same width as every field on iPhone, and the day written in Arabic over the native value. */
.date-field { position: relative; display: block; }
.date-field input { min-height: 48px; line-height: 26px; }
.date-field input::-webkit-date-and-time-value { text-align: right; }
.date-field input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; opacity: 0; cursor: pointer; }
.date-text { display: none; }
.js .date-field input { color: transparent; }
.js .date-field input::-webkit-datetime-edit { color: transparent; }
.js .date-text {
  position: absolute; inset: 4px 0 0; display: flex; align-items: center; padding: 0 14px;
  color: var(--ink); font-size: 16px; pointer-events: none; white-space: nowrap; overflow: hidden;
}
.js .date-text::after { content: ""; margin-inline-start: auto; width: 18px; height: 18px; background: url("/calendar.svg") no-repeat center; }

/* Our own dropdown, built over every select by app.js. */
.dd { position: relative; display: block; }
.dd-native { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.dd-button { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; }
.dd-button::after { content: ""; flex: none; width: 12px; height: 12px; background: url("/chevron.svg") no-repeat center; transition: transform .15s; }
.dd[data-open] .dd-button::after { transform: rotate(180deg); }
.dd-button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-button { justify-content: flex-start; }
.dd-button::after { margin-inline-start: auto; }
/* An open list stays above the cards and buttons that follow it. */
.dd[data-open] { z-index: 31; }
.linked .actions:has(.dd[data-open]), .actions:has(.dd[data-open]), .card:has(.dd[data-open]) { position: relative; z-index: 31; }
.dd-thumb { position: relative; flex: none; width: 36px; height: 46px; overflow: hidden; border-radius: 8px; background: var(--selected); }
.dd-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dd-button .dd-thumb { width: 28px; height: 36px; margin-block: -4px; border-radius: 7px; }
.dd-option .dd-thumb + span { flex: 1 1 auto; }
.with-thumbs .dd-option { justify-content: flex-start; gap: 12px; min-height: 60px; padding: 6px 10px; }
.with-thumbs .dd-list { gap: 4px; }
.with-thumbs .dd-list { max-height: 360px; }
.dd-option { overflow-wrap: anywhere; }
.dd-list {
  position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 30;
  display: flex; flex-direction: column; gap: 2px;
  max-height: 300px; overflow-y: auto; padding: 6px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow);
}
.dd-list.up { top: auto; bottom: calc(100% + 6px); }
.dd-list.floating, .dd-list.floating.up { position: fixed; inset-inline: auto; z-index: 50; }
.dd-option { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: 11px; color: var(--ink); font-size: 15px; cursor: pointer; }
.dd-option[aria-selected="true"] { background: var(--selected); font-weight: 600; }
.dd-option[aria-selected="true"]::after { content: ""; flex: none; width: 16px; height: 16px; background: url("/check.svg") no-repeat center; }
.dd-option.active { background: var(--soft); }
.dd-option[aria-selected="true"].active { background: var(--selected); }
.dd-option[aria-disabled="true"] { color: var(--muted); cursor: default; }

.fields { display: grid; gap: 14px; }
/* A long choice never widens its column; it is cut with an ellipsis instead. */
.fields > *, .fields label, .dd { min-width: 0; }
.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields.four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.fields.five { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.fields.five input { padding-inline: 8px; text-align: center; }
.size-row { padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--ground); }
.size-row + .size-row { margin-top: 8px; }
.size-row-head { display: flex; justify-content: space-between; align-items: center; min-height: 32px; margin-bottom: 4px; font-size: 14px; font-weight: 500; }
.size-row-head .link-btn { min-height: 32px; }
.span-all { grid-column: 1 / -1; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 14px; font-size: 16px; font-weight: 600; }
.wizard-step { margin-bottom: 24px; }
.wizard-nav { display: flex; gap: 8px; margin-top: 20px; }
.line { margin-bottom: 12px; }
.line-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 500; }
.link-btn { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--muted); font-size: 14px; text-decoration: underline; cursor: pointer; }

/* Messages */
.notice { margin-bottom: 12px; padding: 14px 18px; border-radius: 18px; background: var(--soft); font-size: 14px; }
.notice.error { background: var(--late-bg); color: var(--late); }
.done { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.done-icon { flex: none; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 18px; background: var(--soft); }
.done-text { flex: 1 1 auto; min-width: 0; }
.done-text b { display: block; font-weight: 500; }
.done form { margin: 0; }
/* A note shown over the content when the page kept its place below it. */
/* A short note at the top of the screen, clear of every button; a tap closes it. */
.toast {
  position: fixed; inset-inline: 16px; top: calc(10px + env(safe-area-inset-top)); z-index: 45;
  max-width: 440px; margin: 0 auto; padding: 10px 16px;
  border: var(--card-border); border-radius: 16px; background: var(--surface);
  box-shadow: 0 6px 18px rgba(43, 37, 32, 0.12); font-size: 14px; cursor: pointer;
  animation: toast-in .22s ease-out; transition: opacity .25s, transform .25s;
}
.notice.toast.error { background: var(--late-bg); }
.done.toast { gap: 10px; margin: 0; padding: 6px 8px 6px 14px; }
.done.toast .done-icon { width: 28px; height: 28px; }
.done.toast .done-text { display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; }
.done.toast .btn { min-height: 38px; padding: 0 14px; font-size: 13px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
.toast-out { opacity: 0; transform: translateY(-10px); pointer-events: none; }

/* Search, chips, tabs and filters */
.search { display: flex; gap: 8px; margin: 16px 0; }
.search input { margin-top: 0; }
.search-field { position: relative; flex: 1 1 auto; min-width: 0; }
.search-field input:has(+ .search-clear) { padding-left: 48px; }
.search-clear {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 18px; color: var(--muted);
}
@media (hover: hover) { .search-clear:hover { background: var(--soft); color: var(--ink); } }
.search-clear svg { width: 18px; height: 18px; }
.search-note { margin: -8px 4px 8px; }

/* A card or row that opens the order wherever it is tapped; its own buttons still work on their own. */
.linked { position: relative; }
.card-link { text-decoration: none; }
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 0; border-radius: inherit; }
.linked .actions, .linked .mrow-act, .linked .orow-act, .linked form, .linked button, .linked a:not(.card-link), .linked .dd { position: relative; z-index: 1; }
@media (hover: hover) {
  .card.linked:hover, .mrow.linked:hover, .scard:hover, .tiny-card:hover, .hub-tile:hover { border-color: var(--accent); }
  .orow.linked:hover { background: #fffaf1; }
}
/* Every choice in view: chips wrap onto more lines instead of scrolling sideways. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface);
  font-size: 14px; white-space: nowrap; text-decoration: none; cursor: pointer;
}
.chip.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.chip.late { color: var(--late); }
.chip[aria-current="true"] { background: var(--selected); border-color: var(--selected); font-weight: 600; }
.n { padding: 0 7px; border-radius: 10px; background: var(--soft); font-size: 12px; font-weight: 600; line-height: 20px; }
.chip[aria-current="true"] .n { background: var(--surface); }
.chips-bar { display: flex; flex-direction: column; gap: 8px; }
.chips-bar .chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.chips-bar .chip { justify-content: space-between; min-width: 0; padding: 0 12px; }
.chips-bar .chip { gap: 4px; padding: 0 10px; font-size: 13px; }
.chip-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chips-bar .chip .n { flex: none; }
.chips-bar .filter-btn { align-self: stretch; justify-content: center; }
.filter-btn { flex: none; }
.filters.inline-filters { display: none; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.filters.range { flex-wrap: nowrap; }
.filters.range label { flex: 1 1 0; min-width: 0; }
.date-field.short .date-text { font-size: 15px; }
.head-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
a.pill { text-decoration: none; }
.filters > * { flex: 1 1 140px; min-width: 0; }
.filters select, .filters .dd-button, .filters input { margin-top: 0; min-height: 44px; font-size: 14px; }
.filters label { flex: 1 1 160px; }
.filters .btn { flex: 0 0 auto; min-height: 44px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; width: 100%; padding: 4px; border-radius: 16px; background: var(--soft); }
.seg a { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 10px; border-radius: 12px; color: var(--muted); font-size: 14px; text-decoration: none; white-space: nowrap; }
.seg a[aria-current="true"] { background: var(--surface); color: var(--ink); font-weight: 600; }
.tabs { display: flex; flex-wrap: wrap; gap: 0 22px; border-bottom: 1px solid var(--line); }
.tabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 15px; text-decoration: none; white-space: nowrap; }
.tabs a[aria-current="page"] { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.page-tabs { margin: 14px 0 16px; }
.tab-bar { display: flex; flex-direction: column; margin-top: 20px; scroll-margin-top: 12px; }
.tab-bar .search { margin-bottom: 4px; }
.toolbar { display: flex; gap: 8px; align-items: center; }
.toolbar .search { flex: 1; margin: 0; }
.chips-row { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.chips-row .filters { margin: 6px 0 0; }

.group-head { display: flex; justify-content: space-between; align-items: center; margin: 22px 4px 8px; font-size: 14px; font-weight: 600; }
.group-head.late { color: var(--late); }

/* The orders list: a stacked row on the phone, columns from the iPad. */
.olist { border: var(--card-border); border-radius: 22px; background: var(--surface); overflow: hidden; }
.ohead { display: none; }
.orow { display: grid; gap: 6px; padding: 14px 16px; border-top: 1px solid var(--line); }
.orow:first-of-type, .ohead + .orow { border-top: 0; }
.orow-main { display: flex; flex-direction: column; text-decoration: none; }
.orow-main b { font-weight: 600; }
.orow-stage { font-size: 13px; }
.orow-stage .steps { margin-top: 6px; max-width: 160px; }
.orow-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.orow-act { display: none; }
.orow-act .actions { margin-top: 0; flex-wrap: wrap; }
.orow-act .actions form.grow { flex-wrap: wrap; }
.orow-act .actions .dd { flex: 1 1 100%; }
.orow-act .btn { min-height: 40px; font-size: 13px; padding: 0 12px; }
.orow-act .dd-button, .orow-act select { min-height: 40px; font-size: 14px; }

/* The money lists */
.mlist { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.mrow { display: grid; gap: 8px; padding: 16px; border: var(--card-border); border-radius: 22px; background: var(--surface); }
.mrow-main { display: flex; flex-direction: column; text-decoration: none; }
.mrow-main b { font-weight: 600; }
.mrow-money { display: flex; flex-direction: column; gap: 4px; }
.mrow-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mrow-line b { font-weight: 600; }
.mrow-when:empty, .mrow-act:empty { display: none; }
.mrow-act { display: flex; gap: 8px; }
.mrow-act > * { flex: 1 1 0; }
.mrow-act form { display: flex; margin: 0; }
.mrow-act .btn { width: 100%; min-height: 42px; font-size: 13px; padding: 0 10px; }
.bar { display: block; height: 4px; border-radius: 2px; background: var(--bar-off); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--bar); width: 0; }
.bar i.w10 { width: 10%; } .bar i.w20 { width: 20%; } .bar i.w30 { width: 30%; } .bar i.w40 { width: 40%; } .bar i.w50 { width: 50%; }
.bar i.w60 { width: 60%; } .bar i.w70 { width: 70%; } .bar i.w80 { width: 80%; } .bar i.w90 { width: 90%; } .bar i.w100 { width: 100%; }

/* Sheets: from the bottom on phone and iPad, a side panel on a wide screen. */
/* Their box follows the part of the screen the keyboard leaves visible (the two values come from app.js). */
.sheet-backdrop, .panel-wrap { position: fixed; inset-inline: 0; top: var(--view-top, 0); height: var(--view-height, 100%); z-index: 40; display: flex; align-items: flex-end; background: rgba(43, 37, 32, 0.32); }
.sheet-dismiss { position: absolute; inset: 0; padding: 0; border: 0; background: none; }
.sheet, .panel {
  position: relative; width: 100%; max-height: min(92vh, calc(var(--view-height, 100vh) - 12px)); overflow-y: auto;
  padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0; background: var(--surface);
}
.sheet::before, .panel::before { content: ""; display: block; width: 40px; height: 4px; margin: -6px auto 14px; border-radius: 2px; background: var(--line); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.sheet-head h2 { margin: 0; font-size: 17px; }
.panel .button-row form { flex: 1 1 40%; margin: 0; }

/* Model cards with photos */
.prod-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.prod { display: flex; flex-direction: column; overflow: hidden; border: var(--card-border); border-radius: 20px; background: var(--surface); text-decoration: none; }
.prod.on { border-color: var(--focus); box-shadow: var(--focus-ring); }
.prod.off { opacity: .65; }
.prod-photo { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 3 / 4; background: var(--selected); color: var(--bar); }
.prod.off .prod-photo { background: var(--bar-off); }
.prod-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.prod-code { position: absolute; top: 8px; right: 8px; padding: 1px 8px; border-radius: 8px; background: var(--surface); font-size: 11px; font-weight: 600; }
.prod-info { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; font-size: 14px; }
.prod-info b { font-weight: 600; line-height: 1.35; }
.prod-info .muted { font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0; }
.tags:empty { display: none; }
.tags .pill { font-size: 11px; padding: 2px 8px; }
.view-note { margin: 4px 4px 0; }
/* The model's state: one choice with its meaning under it. */
.state-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.state-form legend { margin-bottom: 8px; font-size: 15px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-top: 6px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); font-size: 14px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--focus); background: #fbf6ec; }
.choice input[type="radio"] { flex: none; width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; padding: 0; border-radius: 50%; -webkit-appearance: auto; appearance: auto; accent-color: var(--focus); }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.choice .muted { font-size: 12px; }
details.danger { margin-top: 14px; }
details.danger summary { color: var(--late); }
details.danger form { gap: 10px; }
.photo-field { display: flex; gap: 14px; align-items: center; }
.photo-preview { position: relative; flex: none; display: flex; align-items: center; justify-content: center; width: 88px; height: 118px; overflow: hidden; border-radius: 16px; background: var(--selected); color: var(--bar); }
.photo-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: flex; flex-direction: column; gap: 8px; }
.file-btn { color: var(--ink); cursor: pointer; }


/* Stock */
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.head-actions .btn { flex: 1 1 auto; }
.head-actions.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
.head-actions.three .btn { padding: 4px 8px; font-size: 14px; white-space: normal; line-height: 1.3; }
.head-actions.four { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; }
.head-actions.four .btn { padding: 4px 8px; font-size: 14px; white-space: normal; line-height: 1.3; }
.place-links { display: flex; gap: 8px; margin-top: 12px; }
.place-links .btn { flex: 1 1 0; gap: 6px; }
.sgrid { display: grid; gap: 12px; margin-top: 12px; }
.scard { display: flex; gap: 12px; padding: 12px; border: var(--card-border); border-radius: 22px; background: var(--surface); text-decoration: none; }
.scard-photo { position: relative; flex: none; display: flex; align-items: center; justify-content: center; width: 80px; height: 106px; overflow: hidden; border-radius: 14px; background: var(--selected); color: var(--bar); }
.scard-photo img, .thumb img, .model-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scard-info { display: flex; flex: 1 1 auto; flex-direction: column; gap: 3px; min-width: 0; font-size: 14px; }
.scard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.scard-info b { font-size: 15px; font-weight: 600; line-height: 1.35; }
.sizes { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.size { display: inline-flex; gap: 4px; padding: 2px 9px; border-radius: 9px; background: var(--soft); font-size: 12px; white-space: nowrap; }
.size i { font-style: normal; color: var(--muted); }
.slist { border: var(--card-border); border-radius: 22px; background: var(--surface); overflow: hidden; }
.srow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.srow:first-child { border-top: 0; }
.srow.on { background: #fffaf1; }
.srow.no-thumb { grid-template-columns: minmax(0, 1fr) auto; }
.thumb { position: relative; display: flex; align-items: center; justify-content: center; width: 44px; height: 58px; overflow: hidden; border-radius: 10px; background: var(--selected); color: var(--bar); }
.thumb.big { width: 56px; height: 74px; }
.srow-main { display: flex; flex-direction: column; min-width: 0; }
.srow-main b { font-weight: 600; }
.srow-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-weight: 500; }
.srow-act { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.srow-act > .btn, .srow-act > details > summary.btn { min-height: 40px; font-size: 13px; padding: 0 12px; }
.srow-act > .btn { flex: 1 1 0; }
details.inline { margin: 0; flex: 1 1 0; }
details.inline summary { justify-content: center; }
details.inline summary::after { display: none; }
details.inline[open] { flex-basis: 100%; }
details.inline form { margin-top: 10px; }
.count { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.count input { width: 76px; min-height: 42px; margin-top: 0; text-align: center; }
.count .with-unit input { width: 120px; }
.pick-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.send-bar {
  position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px;
  border: var(--card-border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); font-size: 14px;
}
.model-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.model-head p { margin: 0; }
.model-photo { position: relative; flex: none; display: flex; align-items: center; justify-content: center; width: 88px; height: 118px; overflow: hidden; border-radius: 16px; background: var(--selected); color: var(--bar); }
.tiny-card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; }
.tiny-card b { font-weight: 600; }

.linked-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; padding: 14px 18px; text-decoration: none; font-size: 14px; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 13px; font-weight: 500; }
.group-head .btn.small { min-height: 34px; }
.group-acts { display: flex; gap: 8px; flex-shrink: 0; }

/* The products section: one big tile per part, all in view. */
.hub { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.hub-tile {
  display: flex; flex-direction: column; gap: 14px; min-height: 140px; padding: 18px;
  border: var(--card-border); border-radius: 22px; background: var(--surface); text-decoration: none;
}
.hub-tile:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; }
.hub-icon { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 16px; background: var(--soft); color: var(--focus); }
.hub-text { display: flex; flex-direction: column; gap: 2px; }
.hub-text b { font-size: 17px; font-weight: 600; }

/* The boutique sheet, made for A4 */
.ship-sheet { max-width: 794px; margin: 12px auto 0; padding: 32px; background: #fff; border: var(--card-border); border-radius: 18px; }
.ship-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 16px; border-bottom: 2px solid var(--ink); }
.ship-head dl { display: grid; grid-template-columns: auto auto; gap: 4px 16px; margin: 0; font-size: 13px; }
.ship-head dt { color: var(--muted); }
.ship-head dd { margin: 0; font-weight: 600; }
.ship-sheet h1 { margin: 20px 0 12px; font-size: 19px; font-weight: 600; }
.ship-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ship-table th { padding: 9px 6px; text-align: right; font-size: 12px; background: var(--soft); border-bottom: 1px solid #d9ccb4; }
.ship-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ship-table td[dir="ltr"] { white-space: nowrap; }
.page.bare:has(.ship-sheet) { max-width: 860px; }
/* On a phone the table becomes one card per line, so nothing runs off the screen. */
@media screen and (max-width: 640px) {
  .ship-sheet { padding: 16px; }
  .ship-head { flex-direction: column; }
  .ship-table thead { display: none; }
  .ship-table, .ship-table tbody { display: block; }
  .ship-table tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 12px; align-items: center;
    padding: 12px 0; border-bottom: 1px solid var(--line);
  }
  .ship-table td { display: block; padding: 0; border: 0; }
  .ship-table td:nth-child(1) { display: none; }
  .ship-table td:nth-child(2) { grid-row: 1 / span 4; }
  .ship-table td:nth-child(3), .ship-table td:nth-child(4), .ship-table td:nth-child(5), .ship-table td:nth-child(6) { grid-column: 2; }
  .ship-table td:nth-child(4)::before { content: "الكود: "; color: var(--muted); }
  .ship-table td:nth-child(5)::before { content: "المقاس: "; color: var(--muted); }
  .ship-table td:nth-child(6)::before { content: "العدد: "; color: var(--muted); }
  .ship-table td:nth-child(7) { grid-column: 3; grid-row: 2; color: var(--muted); font-size: 12px; }
  .ship-table td:nth-child(8) { grid-column: 3; grid-row: 1; font-weight: 600; }
  .ship-table td[dir="ltr"] { direction: rtl; text-align: right; }
  .ship-total { width: 100%; }
  .ship-sign { gap: 16px; }
}
.ship-total { width: 280px; margin: 14px 0 16px auto; padding: 12px 14px; border: 1px solid #d9ccb4; border-radius: 12px; display: grid; gap: 6px; font-size: 14px; }
.ship-sign { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; margin-top: 48px; font-size: 13px; }
.ship-sign p:last-child { margin-top: 32px; padding-top: 6px; border-top: 1px solid #8c8276; }

/* The job order: one header, then a compact block per kind of piece, two to an A4 sheet. */
.job-sheet { max-width: 794px; margin: 12px auto 20px; padding: 24px; background: #fff; border: var(--card-border); border-radius: 18px; }
.page.bare:has(.job-sheet) { max-width: 860px; }
/* The title and the order's facts at the start, the logo alone at the far end. */
.job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
.job-title h2 { margin: 0 0 10px; font-size: 24px; }
/* Each fact in its own cell, so nothing runs into the next. */
.job-facts { display: grid; grid-template-columns: repeat(5, auto); margin: 0; border: 1px solid #d9ccb4; border-radius: 12px; overflow: hidden; font-size: 13px; }
.job-facts > div { padding: 8px 14px; border-inline-start: 1px solid #d9ccb4; }
.job-facts > div:first-child { border-inline-start: 0; }
.job-facts dt { color: var(--muted); font-size: 12px; }
.job-facts dd { margin: 0; font-weight: 600; font-size: 15px; white-space: nowrap; }
.job-head .logo { flex: none; }
.job-big { font-size: 19px; }
.job-due { font-size: 16px; }
.job-piece { margin-top: 14px; padding: 12px 14px; border: 1px solid #d9ccb4; border-radius: 14px; break-inside: avoid; page-break-inside: avoid; }
.job-piece-head { display: flex; align-items: center; gap: 10px; }
.job-piece-head h3 { flex: 1 1 auto; display: flex; align-items: center; gap: 8px; font-size: 17px; }
.job-piece-head h3 .muted { font-size: 13px; font-weight: 400; }
.job-index { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 13px; background: var(--ink); color: #fff; font-size: 14px; }
.job-piece-body { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; margin-top: 10px; }
.job-piece-body figure { display: flex; align-items: center; justify-content: center; height: 230px; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.job-photo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.job-photo .muted { padding: 8px; text-align: center; }
.sketch { display: block; width: 100%; height: 100%; font-family: inherit; }
.job-details { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.job-list { display: grid; grid-template-columns: auto 1fr; margin: 0; border: 1px solid #d9ccb4; border-radius: 10px; overflow: hidden; font-size: 15px; }
.job-list dt, .job-list dd { padding: 6px 12px; border-top: 1px solid #e6dcc8; }
.job-list dt:first-of-type, .job-list dd:first-of-type { border-top: 0; }
.job-list dt { color: var(--muted); background: #faf6ee; border-inline-end: 1px solid #e6dcc8; }
.job-list dd { margin: 0; font-weight: 600; }
.job-details .job-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; text-align: center; }
.job-details .job-grid.count-1 { grid-template-columns: minmax(0, 1fr); }
.job-details .job-grid div { padding: 6px 8px; border: 1px solid #d9ccb4; border-radius: 10px; }
.job-details .job-grid small { display: block; color: var(--muted); font-size: 13px; }
.job-details .job-grid b { font-size: 24px; font-weight: 600; line-height: 1.3; }
.job-note { padding: 8px 12px; border: 2px solid var(--late); border-radius: 10px; color: var(--late); font-size: 15px; font-weight: 600; }
.job-notes { margin-top: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; }
.job-notes small { display: block; color: var(--muted); font-size: 12px; }
.job-sign { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; margin-top: 22px; font-size: 14px; break-inside: avoid; }
.job-sign p:last-child { margin-top: 24px; padding-top: 6px; border-top: 1px solid #8c8276; font-size: 12px; }
/* Printing one piece: the others stay on screen only. */
body[data-print-one] .job-piece:not(.print-this) { display: none; }
@media screen and (max-width: 640px) {
  .job-sheet { padding: 14px; }
  .job-head .logo { display: none; }
  .job-title { width: 100%; }
  .job-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-facts > div { border-inline-start: 0; border-top: 1px solid #d9ccb4; }
  .job-facts > div:nth-child(2n) { border-inline-start: 1px solid #d9ccb4; }
  .job-facts > div:nth-child(-n + 2) { border-top: 0; }
  .job-facts > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .job-piece-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-piece-body figure { height: 190px; }
  .job-details { grid-column: 1 / -1; }
  .job-piece-head { flex-wrap: wrap; }
}

/* Older lists (search results, delivered orders) */
.tiny { display: block; padding: 14px; border: var(--card-border); border-radius: 18px; background: var(--surface); text-decoration: none; }
.tiny b { display: block; font-weight: 500; }

/* Order details */
/* Label and value rows, parted by a faint line. */
.rows { display: grid; margin-top: 10px; font-size: 14px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-top: 1px solid #f0e9dc; }
.row:first-child { border-top: 0; padding-top: 4px; }
.row span:first-child { color: var(--muted); }
.row.total { border-top: 1px solid var(--line); font-weight: 600; }
.row.total span:first-child { color: var(--ink); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.button-row .btn { flex: 1 1 40%; }
.button-row form.grow { display: flex; flex: 1 1 40%; margin: 0; }
details { margin-top: 12px; }
.card > details:first-child { margin-top: 0; }
summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; font-size: 14px; color: var(--muted); cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: ""; width: 12px; height: 12px; background: url("/chevron.svg") no-repeat center; }
details[open] summary::after { transform: rotate(180deg); }
details form { display: grid; gap: 12px; margin: 4px 0 0; }

/* Settings: grouped rows, each opening its own edit sheet. */
.set-group { border: var(--card-border); border-radius: 22px; background: var(--surface); overflow: hidden; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 12px 18px; border-top: 1px solid var(--line); }
.set-row:first-child { border-top: 0; }
.set-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-label { font-size: 15px; font-weight: 500; }
.set-value { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.set-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.set-row > .btn, .set-row > form { flex: none; }
.set-row > form { margin: 0; }
.set-note { margin: -6px 4px 10px; }
.set-logout { margin-top: 28px; }

/* Settings */
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tag { font-size: 12px; color: var(--muted); }

/* Job order */
.job-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; text-align: center; }
.job-grid div { padding: 10px 4px; border: 1px solid var(--line); border-radius: 12px; }
.job-grid small { display: block; color: var(--muted); font-size: 12px; }
.job-grid b { font-weight: 500; font-size: 16px; }
.write-in { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; }

/* Bottom bar */
.nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 10;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  padding: 10px 8px calc(14px + env(safe-area-inset-bottom));
}
.nav-inner { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 560px; margin: 0 auto; }
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 48px;
  color: var(--muted); font-size: 12px; text-decoration: none;
}
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* Login */
.login { max-width: 400px; margin: 0 auto; padding: 48px 20px; }
.login .logo { margin: 0 auto 24px; }
.login form { display: grid; gap: 14px; margin-top: 16px; }

.nav-brand { display: none; }
/* Order page: one column on small screens with the money card last, side by side when wide. */
.split { display: flex; flex-direction: column; }
.split-side, .split-main { display: contents; }
.split-last { order: 1; }

/* iPad and up */
@media (min-width: 768px) {
  .page { max-width: 1100px; padding-inline: 32px; }
  .page.wide { max-width: 1320px; }
  .page.narrow { max-width: 720px; }
  .only-wide { display: inline-flex !important; }
  .short { max-width: 320px; }
  .page > .card.muted, .page > .card.empty { max-width: 720px; }
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
  .filter-btn { display: none; }
  .chips-bar .chips { display: flex; flex-wrap: wrap; }
  .filters.inline-filters { display: flex; }
  .seg { width: auto; min-width: 380px; }
  .tiles.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tab-bar { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 16px; }
  .tab-bar .search { margin: 0 0 6px; width: 340px; }
  .chips-row { flex-direction: row; align-items: center; justify-content: space-between; }
  .chips-row .filters { margin: 0; flex: 0 0 220px; }
  .filters { flex-wrap: nowrap; }

  .orow { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; align-items: center; padding: 14px 18px; }
  .orow-pills { flex-direction: column; align-items: flex-start; }
  .orow-act { display: block; }

  .mrow { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.3fr) auto; align-items: center; gap: 16px; padding: 16px 18px; }
  .mrow-when { display: none; }
  .mrow-act > * { flex: 0 0 auto; }
  .mrow-act .btn { width: auto; padding: 0 14px; }

  .prod-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .sgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hub { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hub-tile:last-child:nth-child(odd) { grid-column: auto; min-height: 140px; flex-direction: column; align-items: stretch; }
  .head-actions { flex-wrap: nowrap; }
  .head-actions.three, .head-actions.four { display: flex; justify-content: flex-start; }
  .head-actions.three .btn, .head-actions.four .btn { flex: 0 0 auto; padding: 0 18px; }
  .place-links .btn { flex: 0 0 auto; }
  .srow { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .srow.no-thumb { grid-template-columns: minmax(0, 1fr) auto auto; }
  .srow-act { grid-column: auto; flex-wrap: nowrap; justify-content: flex-end; }
  .srow-act > .btn { flex: 0 0 auto; }
  details.inline { flex: 0 0 auto; position: relative; }
  details.inline[open] form { position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; width: 280px; padding: 14px; border: var(--card-border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }

  .sheet-backdrop, .panel-wrap { align-items: center; justify-content: center; padding: 24px; }
  .sheet, .panel { max-width: 520px; max-height: calc(var(--view-height, 100vh) - 48px); border-radius: 28px; padding: 24px; }
  .sheet::before, .panel::before { display: none; }
}

/* Side by side once the content area is wide enough (the side menu takes 232px from 1024px). */
@media (min-width: 900px) {
  .split { display: grid; grid-template-columns: minmax(290px, 360px) minmax(0, 1fr); gap: 20px; align-items: start; }
  .split-side, .split-main { display: block; }
  .split-main h2:first-child { margin-top: 0; }
}

@media (min-width: 1024px) {
  body:has(> .nav) { padding-inline-start: 232px; }
  .page { padding-bottom: 40px; }
  .nav {
    inset-inline: 0 auto; top: 0; bottom: 0;
    width: 232px; padding: 24px 16px;
    border-top: 0; border-inline-end: 1px solid var(--line); border-radius: 0;
  }
  .nav-inner { display: flex; flex-direction: column; gap: 4px; max-width: none; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; border-radius: 15px; font-size: 15px; }
  .nav a:hover { background: var(--soft); }
  .nav a[aria-current="page"] { background: var(--selected); }
  .nav-brand { display: block; margin: 0 6px 24px; }
  .top .logo { display: none; }
  .top { justify-content: flex-end; }
  .top:has(.top-start) { justify-content: space-between; }
  .toast { inset-inline: 248px 16px; }

  .ohead { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
  .orow-pills { flex-direction: row; flex-wrap: wrap; }
  .mrow { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.3fr) minmax(0, .7fr) auto; }
  .mrow-when { display: block; }
  .prod-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .sgrid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
  .send-bar { bottom: 16px; }
}

/* Wide screens: the model being edited opens beside the cards instead of over them. */
@media (min-width: 1200px) {
  .with-panel { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
  .with-panel .panel-wrap { position: static; display: block; height: auto; padding: 0; background: none; }
  .with-panel .sheet-dismiss { display: none; }
  .with-panel .panel { max-height: none; overflow: visible; border: var(--card-border); border-radius: 22px; padding: 22px; max-width: none; }
}

/* Pressing and opening: soft, quick, and the same everywhere. */
.btn, .chip, .round, .tile, .card.linked, .scard, .prod, .tiny, .tiny-card, .mrow, .orow, .seg a, .tabs a, .nav a, .dd-option, summary, .hub-tile {
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:active, .chip:active, .round:active, .seg a:active, .nav a:active { opacity: .72; }
.tile:active, .card.linked:active, .scard:active, .prod:active, .tiny:active, .tiny-card:active, .mrow.linked:active, .orow.linked:active, .hub-tile:active { background: #f8f1e4; }
/* Sheets are never faded: if a phone pauses the animation, what is inside must still be visible. */
@keyframes fade-in { from { background-color: transparent; } }
@keyframes rise-in { from { transform: translateY(20px); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-4px); } }
.sheet-backdrop, .panel-wrap { animation: fade-in .2s ease-out; }
.sheet, .panel { animation: rise-in .28s cubic-bezier(.2, .8, .2, 1); }
.dd-list:not([hidden]) { animation: drop-in .14s ease-out; }
details[open] > :not(summary) { animation: drop-in .2s ease-out; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

@page { size: A4; margin: 12mm; }
@media print {
  .ship-sheet { border: 0; padding: 0; margin: 0; max-width: none; }
  .job-sheet { border: 0; border-radius: 0; padding: 0; margin: 0; max-width: none; }
  .job-piece-body figure { height: 68mm; }
  .thumb, .job-list dt { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; font-size: 13px; padding: 0; }
  .split { display: block; }
  .no-print, .nav { display: none !important; }
  .page { max-width: none; padding: 0; }
  .card { break-inside: avoid; border-radius: 10px; }
  .stack { gap: 8px; }
}

/* The landing page screen: its models in order, the numbers left on it, and its links. */
.page-list { margin: 0; padding: 0; list-style: none; }
.page-list .set-row { justify-content: flex-start; }
.page-list .set-text { flex: 1 1 auto; }
.page-row-act { display: flex; flex: none; align-items: center; gap: 6px; }
.page-row-act form { margin: 0; }
.round.small { width: 36px; height: 36px; border-radius: 18px; font-size: 16px; cursor: pointer; }
.round.small:disabled { opacity: .35; cursor: default; }
.round.small svg { width: 16px; height: 16px; }
.card.warn { margin-bottom: 12px; padding: 14px 18px; background: var(--late-bg); border-color: var(--late-bg); color: var(--late); font-size: 14px; }
.share-link { direction: ltr; font-size: 12px; word-break: break-all; user-select: all; -webkit-user-select: all; }
.set-sub { margin: 18px 4px 10px; font-size: 14px; }
.pick-grid { display: grid; gap: 8px; max-height: 55vh; overflow-y: auto; }
.pick { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 15px; cursor: pointer; }
.pick:has(input:checked) { border-color: var(--focus); background: var(--selected); }
.pick.off { opacity: .55; cursor: default; }
.pick > span:last-child { display: flex; flex-direction: column; }
.pick { min-width: 0; }
/* A small round tick, for choosing several things from a list. */
.pick input, .choice input[type="checkbox"] {
  flex: none; width: 22px; height: 22px; min-height: 0; margin: 0; padding: 0;
  border: 1.5px solid var(--bar); border-radius: 50%; background: var(--surface) center / 14px no-repeat;
  cursor: pointer;
}
.pick input:checked, .choice input[type="checkbox"]:checked { border-color: var(--focus); background-color: var(--focus); background-image: url("/check-light.svg"); }
.pick input:focus, .choice input[type="checkbox"]:focus { box-shadow: var(--focus-ring); }
.pick input:disabled { opacity: .4; cursor: default; }
.pick .thumb { flex: none; }
.choice input[type="checkbox"] { margin-top: 1px; }
/* The landing page's models, folded away until asked for. */
.page-models { margin-top: 18px; }
.page-models > summary { padding: 20px 18px; border: var(--card-border); border-radius: 22px; background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 600; }
.page-models > summary .muted { font-weight: 400; }
.page-models > .set-note { margin-top: 12px; }
.page-models > .set-group, .page-models > .page-list { margin-top: 12px; }
.banner-add { margin-top: 10px; }
.banner-add-btn { border-style: dashed; }
/* Choosing several models from the list. */
.page-head-act { display: flex; gap: 8px; }
.prod-check { display: none; position: absolute; top: 8px; inset-inline-start: 8px; width: 26px; height: 26px; border: 1.5px solid var(--surface); border-radius: 50%; background: rgba(43, 37, 32, .28) center / 16px no-repeat; }
.pill.on-page { display: none; }
.selecting .pill.on-page { display: inline-flex; }
.selecting .prod[data-model-id] .prod-check { display: block; }
.selecting .prod:not([data-model-id]) { opacity: .4; }
.prod.picked { border-color: var(--focus); box-shadow: var(--focus-ring); }
.prod.picked .prod-check { border-color: var(--surface); background-color: var(--focus); background-image: url("/check-light.svg"); }
.selecting .panel-main { padding-bottom: 150px; }
.select-bar { position: fixed; inset-inline: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30; margin: 0; padding: 12px 14px; border: var(--card-border); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.select-bar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.select-bar-links { display: flex; gap: 14px; }
.select-bar-act { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.select-bar-act .btn { width: 100%; padding-inline: 8px; }
.select-bar-act .btn:disabled { opacity: .45; }
@media (min-width: 1024px) { .select-bar { inset-inline: 248px 16px; bottom: 16px; max-width: 560px; } }
/* Selling at an exhibition: large photos, and one wide button on each. */
.sale-search { margin: 0 0 12px; }
.sale-card { position: relative; }
.sale-grid { gap: 10px; }
.sale-card .prod-photo { aspect-ratio: 1 / 1; }
.sale-card .prod-photo img { object-position: center 20%; }
.sale-card .prod-info { flex: 1 1 auto; padding: 8px 10px 10px; }
.sale-btn { margin: 0 8px 8px; min-height: 48px; font-size: 15px; }
@media (min-width: 560px) { .sale-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.sale-final b { font-weight: 600; }
.sale-pay .btn:disabled { opacity: .45; }
.sale-orders { margin-top: 10px; font-size: 13px; }
.sale-undo { margin: 0; }
.panel-more { display: grid; gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.panel-more form { margin: 0; }
.archive-link { margin-top: 16px; }
.page-head:has(+ .tiles) { margin-bottom: 14px; }
.back-to { margin: 0 0 12px; }
.money-total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 16px 0 10px; padding: 16px 18px; border: var(--card-border); border-radius: 22px; background: var(--surface); }
.money-total b { font-size: 28px; font-weight: 500; line-height: 1.1; }
.sale-count { position: absolute; top: 8px; inset-inline-start: 8px; display: flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--surface); font-size: 13px; font-weight: 600; }
.sale-more { margin-top: 0; }
.sale-more > .fields { margin-top: 8px; }
.sale-pay-title { margin: 4px 0 -4px; color: var(--muted); font-size: 13px; }
.sale-pay { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sale-pay .btn { min-height: 64px; font-size: 18px; }
/* The keyboard is up: the bottom bar steps aside. */
.keyboard-open .nav { display: none; }
.page-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 15px; }


/* Counts: + and − around the number. */
.stepper { display: flex; align-items: stretch; width: 100%; min-height: 48px; margin-top: 4px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); overflow: hidden; }
.stepper:focus-within { border-color: var(--focus); box-shadow: var(--focus-ring); }
.stepper input { flex: 1 1 auto; width: 44px; min-height: 0; margin: 0; padding: 0 2px; border: 0; border-radius: 0; background: none; text-align: center; font-weight: 500; }
.stepper input:focus { box-shadow: none; }
.step { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; border: 0; background: var(--soft); color: var(--ink); cursor: pointer; transition: background-color .15s, opacity .15s; }
.step:active { background: var(--selected); }
.step:disabled { color: var(--muted); opacity: .4; cursor: default; }
.step svg { width: 18px; height: 18px; }
html:not(.js) .step { display: none; }
.field { display: block; min-width: 0; }
.field-title { display: block; font-size: 13px; color: var(--muted); }
.field-hint { margin-top: 8px; }
.count-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.count-line .stepper { width: 150px; margin-top: 0; }

/* A piece in a "how many" list. */
.pick-row { display: block; padding: 12px 0; }
.pick-head { display: flex; align-items: center; gap: 12px; }
.pick-head .srow-main { flex: 1 1 auto; }
.pick-head .thumb { flex: none; }
.pick-count { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.pick-count .stepper { width: 150px; margin-top: 0; }

/* Sending to a boutique: the piece on one line, the two entries on the next, the same in every card. */
form[data-send] > .muted { margin: 14px 4px 10px; }
.send-list { display: grid; gap: 10px; }
.send-card { padding: 14px; border: var(--card-border); border-radius: 22px; background: var(--surface); transition: background-color .15s; }
.send-card.on { background: #fffaf1; }
.send-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.send-bar::after { content: ""; position: absolute; inset-inline: -20px; top: 100%; height: 34px; background: var(--ground); }
.send-bar { position: sticky; }

/* A photo at the start of a work card or an order row. */
.with-thumb { display: flex; align-items: flex-start; gap: 12px; }
.with-thumb > .thumb { flex: none; }
.with-thumb-text { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; }
.orow-main.with-thumb { flex-direction: row; }

/* Before and after a price change. */
.price-change { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.price-change s { color: var(--muted); font-size: 12px; font-weight: 400; }
.head-actions.single { margin: 10px 0 0; }
.sheet-sub { margin: -10px 0 14px; }

/* A form's message under the field that needs attention. */
.field-error { display: block; margin-top: 5px; color: var(--late); font-size: 12.5px; }
input.invalid, select.invalid, textarea.invalid, .dd-button.invalid, .stepper.invalid { border-color: var(--late); }
input.invalid:focus, textarea.invalid:focus, .dd-button.invalid:focus { box-shadow: 0 0 0 3px rgba(138, 69, 56, 0.14); }
.count-line:has(.field-error), .pick-count:has(.field-error) { flex-wrap: wrap; }
.count-line .field-error, .pick-count .field-error { width: 100%; }
.btn[data-busy]::before { content: ""; width: 14px; height: 14px; margin-inline-end: 8px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Lists kept in settings. */
.list-entries { margin-bottom: 14px; }
.list-entries .set-row { min-height: 54px; padding-block: 8px; }
.list-add { margin-top: 12px; }

/* More photos of a model. */
.photos-block { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 15px; }
.photos-head { display: flex; align-items: center; justify-content: space-between; }
.photo-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.photo-tile { display: flex; flex-direction: column; align-items: center; margin: 0; }
.photo-tile form { margin: 0; }
.photo-tile .link-btn { min-height: 34px; padding: 0 2px; font-size: 12px; }
.photo-frame { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 12px; background: var(--selected); }
.photo-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-add { border: 1px dashed var(--bar); background: transparent; color: var(--ink); font-size: 13px; text-align: center; cursor: pointer; }
.photo-add[data-busy] { opacity: .5; pointer-events: none; }

/* The landing page screen: room between its blocks. */
.page-add { margin-top: 12px; }
.after-tiles { margin-top: 12px; }
.page-list + .set-note { margin-top: 8px; }
.person-link { gap: 2px; color: inherit; text-decoration: none; }
.person-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; }
.person-head { margin: 0 0 12px; }
.person-chips { margin-top: 12px; }
.person-order { color: inherit; text-decoration: none; }
a.notice.follow-link { display: block; margin: 12px 0 0; color: inherit; text-decoration: none; font-weight: 500; }
.pick-grid { margin-top: 2px; }

/* The sheet as it is drawn into a PDF on a phone: laid out as on paper. */
.as-pdf .ship-sheet, .as-pdf .job-sheet { border: 0; border-radius: 0; padding: 0; margin: 0; width: 794px; max-width: none; }
.as-pdf .no-print { display: none !important; }
.drawing-pdf .ship-table td::before { content: none !important; }
.as-pdf .job-piece-body figure { height: 257px; }
.field-error.span-all { margin-top: 0; }
.sheet-backdrop.on-top { z-index: 44; }
.lead-note { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: 10px; background: var(--ground); color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.thumb-more { position: absolute; z-index: 1; bottom: 4px; left: 4px; min-width: 22px; padding: 1px 6px; border-radius: 10px; background: var(--ink); color: var(--surface); font-size: 11px; font-weight: 600; line-height: 1.5; text-align: center; }
.thumb-stack { position: relative; flex: none; width: 58px; height: 68px; }
.thumb-stack .thumb { position: absolute; width: 42px; height: 56px; border: 2px solid var(--surface); }
.thumb-stack .thumb:first-child { top: 0; left: 0; }
.thumb-stack .thumb:last-child { right: 0; bottom: 0; }
.order-lines { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px solid var(--line); list-style: none; font-size: 13px; }
.order-lines li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.order-lines i { font-style: normal; color: var(--muted); }
.order-lines em { flex-basis: 100%; font-style: normal; color: var(--muted); font-size: 12px; }
.orow-main .order-lines { margin-top: 6px; padding-top: 6px; }
.instant-switch { margin-top: 6px; }
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.switch-track { position: relative; flex: none; width: 38px; height: 22px; border-radius: 11px; background: var(--line); transition: background .15s; }
.switch-knob { position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: right .15s; }
.switch[aria-checked="true"] .switch-track { background: var(--focus); }
.switch[aria-checked="true"] .switch-knob { right: 19px; }
.switch[aria-checked="false"] { color: var(--muted); }
