:root {
  --ink: #17231f;
  --muted: #5d6b66;
  --line: #dde3df;
  --bg: #f3f5f2;
  --surface: #ffffff;
  --brand: #14342f;
  --accent: #0d7a5f;
  --accent-soft: #e0f2ec;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warn: #a15c07;
  --warn-soft: #fdf1dc;
  --info: #1d5fa8;
  --info-soft: #e5effa;
  --radius: 12px;
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", Roboto, Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 16px; line-height: 1.5; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.top h1 { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .who { font-size: 13px; opacity: .8; }
.icon-btn {
  min-width: 44px; min-height: 44px; padding: 0 10px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.12); color: #fff; font-size: 14px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 14px 16px 110px; }
.wrap.wide { max-width: 1400px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #eec5c1; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 56px; font-size: 18px; }
:focus-visible { outline: 3px solid #5fb8a0; outline-offset: 2px; }

/* Login */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; max-width: 380px; margin: 0 auto; padding: 24px 16px; gap: 18px; }
.login h1 { font-size: 26px; }
.login .names { display: grid; gap: 10px; }
.pin-input {
  width: 100%; height: 60px; text-align: center; font-size: 28px; letter-spacing: .4em;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; direction: ltr; }
.pin-pad button { height: 60px; font-size: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.error { color: var(--danger); font-weight: 600; }
.muted { color: var(--muted); font-size: 14px; }

/* Tabs */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.tab {
  flex: none; min-height: 44px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-weight: 600; font-size: 15px; white-space: nowrap;
}
.tab[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab .count { font-variant-numeric: tabular-nums; margin-inline-start: 6px; opacity: .75; }
.tab.alarm:not([aria-pressed="true"]) { border-color: var(--danger); color: var(--danger); }

/* Board */
.board { display: grid; gap: 14px; }
.column { display: none; flex-direction: column; gap: 10px; min-width: 0; }
.column.on { display: flex; }
.column > h2 { display: none; font-size: 15px; color: var(--muted); }
@media (min-width: 1000px) {
  .board { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
  .column { display: flex; }
  .column > h2 { display: block; }
  .board-tabs { display: none; }
}

/* Cards */
.card {
  display: block; width: 100%; padding: 14px; text-align: start; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.card-link { display: block; text-decoration: none; }
.card.late { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-id { font-weight: 800; font-size: 17px; }
.spacer { flex: 1; }
.card-name { font-weight: 600; margin-top: 4px; }
.card-items { color: var(--muted); font-size: 14px; margin-top: 2px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.card .btn { margin-top: 10px; }
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.info { background: var(--info-soft); color: var(--info); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* Notices */
.notice { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }
.notice small { display: block; font-weight: 400; }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice .btn { margin-top: 8px; }

/* Order page */
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.section > h2 { font-size: 15px; color: var(--muted); margin-bottom: 8px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }

.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.step.locked { opacity: .5; }
.step.done { border-color: #a9d8c7; background: #f6fbf9; }
.step-head { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.step-mark {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line); font-size: 14px; font-weight: 800; color: var(--muted);
}
.step.done .step-mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.step-body { margin-top: 10px; display: grid; gap: 10px; }
.item-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.item-row:first-child { border-top: 0; padding-top: 0; }
.item-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.item-row.full .item-name { color: var(--accent); }
.stepper { display: flex; align-items: center; gap: 4px; flex: none; }
.stepper button { width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 22px; cursor: pointer; }
.stepper .value { min-width: 54px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr; }
.region-tag { font-size: 24px; font-weight: 800; text-align: center; padding: 12px; background: var(--warn-soft); color: var(--warn); border-radius: 10px; }
.photo { display: block; width: 100%; max-height: 520px; object-fit: contain; border-radius: 10px; background: #eef1ee; }
.sticky-action {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 4;
  padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.sticky-action > div { max-width: 720px; margin: 0 auto; display: grid; gap: 8px; }
.sticky-action .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.timeline time { color: var(--muted); font-size: 13px; display: block; }
.actions { display: grid; gap: 8px; margin-bottom: 12px; }

/* Forms */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea, .input {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.item-input { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.product-fields { border-bottom: 0; padding-bottom: 0; }
.mini { display: grid; gap: 2px; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.mini.wide { grid-column: 1 / -1; font-size: 14px; }
.mini .input { min-width: 0; color: var(--ink); font-weight: 400; }
.cancel-edit { margin-top: 8px; }
.product-row .log-sub { display: block; font-weight: 400; }
#product-filter { margin-bottom: 6px; }
.sticker-tag { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.region-tag .sticker-tag { display: grid; justify-items: center; margin-top: 8px; font-size: 20px; }
.region-tag .swatch { width: 100%; height: 72px; border-radius: 10px; }
.notice .sticker-tag { margin-top: 8px; }
.card-name + .sticker-tag { margin-top: 6px; font-size: 14px; }
.swatch { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); flex: none; }
.scanner { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: #000; }
#quote-result:not(:empty) { margin-top: 12px; }
.dialog .facts { margin-bottom: 12px; }
.item-input .remove { grid-column: 3; min-height: 44px; align-self: end; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; color: var(--danger); font-size: 14px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 22px; height: 22px; }
.fab {
  position: fixed; bottom: max(18px, env(safe-area-inset-bottom)); inset-inline-end: 16px; z-index: 4;
  min-height: 56px; padding: 0 22px; border-radius: 999px; background: var(--accent); color: #fff;
  font-weight: 700; display: flex; align-items: center; text-decoration: none; box-shadow: 0 4px 14px rgba(13,60,48,.3);
}
.list-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list-row:first-of-type { border-top: 0; }
.list-row .grow { flex: 1; min-width: 120px; font-weight: 600; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 14px; }

/* Dialog and toast */
.dialog { border: 0; border-radius: 14px; padding: 18px; width: min(92vw, 420px); }
.dialog::backdrop { background: rgba(10,25,20,.5); }
.dialog h2 { font-size: 18px; margin-bottom: 10px; }
.dialog .choices { display: grid; gap: 8px; margin-bottom: 10px; }
.dialog .buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.toast {
  position: fixed; bottom: 92px; inset-inline: 16px; z-index: 20; max-width: 480px; margin: 0 auto;
  padding: 12px 16px; border-radius: 10px; background: #1b2b26; color: #fff; text-align: center; font-weight: 600;
}
.toast.bad { background: var(--danger); }

/* Bottom navigation */
.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 6; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; min-height: 54px; display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-weight: 600; font-size: 15px; color: var(--muted);
}
.bottom-nav a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.fab { bottom: calc(68px + env(safe-area-inset-bottom)); }
.wrap { padding-bottom: 150px; }
.wrap.has-action { padding-bottom: 180px; }
.toast { bottom: 150px; }

/* Lists */
.stack { display: grid; gap: 10px; }
.list-title { margin-top: 6px; font-size: 15px; }
.space { margin-bottom: 8px; }
.progress { margin-top: 6px; font-size: 13.5px; font-weight: 700; color: var(--warn); }
.progress.done-line { color: var(--accent); }
.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search .input { flex: 1; min-width: 0; }

/* Late orders */
.late-section { background: var(--danger-soft); border: 1px solid #eec5c1; border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.late-section h2 { font-size: 17px; color: var(--danger); }
.late-section p { font-size: 14px; color: var(--danger); margin-bottom: 10px; }
.late-list { display: grid; gap: 10px; }
@media (min-width: 1000px) { .late-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Log */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.filters > .input { margin-bottom: 12px; }
.filters.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.filters.inline .field { margin: 0; flex: 1 1 130px; }
.filters p { margin-top: 8px; }
.day { margin-bottom: 14px; }
.day > h2 { position: sticky; top: 64px; z-index: 2; background: var(--bg); padding: 6px 0; font-size: 15px; display: flex; justify-content: space-between; }
.day .count { color: var(--muted); }
.log-list { padding: 0 14px; margin: 0; }
.log-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); text-decoration: none; flex-wrap: wrap; }
.log-row:first-child { border-top: 0; }
.log-time { color: var(--muted); font-size: 13px; flex: none; }
.log-main { flex: 1 1 180px; min-width: 0; display: grid; }
.log-title { font-weight: 600; overflow-wrap: anywhere; }
.log-sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

/* Reports */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 2px; }
.tile-label { color: var(--muted); font-size: 13.5px; }
.tile-value { font-size: 28px; font-weight: 800; line-height: 1.2; text-align: start; }
.tile-note { color: var(--muted); font-size: 12.5px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th { text-align: start; color: var(--muted); font-weight: 600; font-size: 13px; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
td.num { direction: rtl; font-variant-numeric: tabular-nums; white-space: nowrap; }
.two-col { display: grid; gap: 12px; }
@media (min-width: 760px) { .two-col { grid-template-columns: 1fr 1fr; } }
.pin-input { letter-spacing: normal; margin-bottom: 10px; height: 56px; font-size: 20px; }
h3 { font-size: 15px; margin: 8px 0 0; }
.icon-btn { font-family: inherit; }

/* Auto-assignment */
.workload { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.workload .pill { font-size: 14px; padding: 4px 12px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.assignee { font-weight: 700; color: var(--ink); }
.assigned { text-align: center; padding: 8px 0 16px; }
.assigned strong { display: block; font-size: 32px; line-height: 1.3; margin: 6px 0; color: var(--accent); }
