/* Dealer portal. The visual idea is a courier waybill: warm paper, black
   ink, signal orange, barcode strips and perforated dividers. */

:root {
  --paper: #f3efe6;
  --paper-2: #ebe5d8;
  --card: #fffdf8;
  --ink: #1b1c1a;
  --ink-2: #4a4b46;
  --muted: #7b7a72;
  --rule: #d6cfbf;
  --accent: #e0531f;
  --accent-ink: #b63f12;
  --ok: #2f6b3f;
  --warn: #9a6a00;
  --err: #b3261e;
  --radius: 3px;
  --display: "Secular One", "IBM Plex Sans Hebrew", sans-serif;
  --body: "IBM Plex Sans Hebrew", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--paper);
  /* paper grain */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--ink); }
a:hover { color: var(--accent-ink); }

.mono { font-family: var(--mono); letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.inline { display: inline; }

/* ---------- pilot banner ---------- */

.pilot {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  color: var(--ink);
  background:
    repeating-linear-gradient(-45deg, transparent 0 14px, rgba(27, 28, 26, 0.07) 14px 28px),
    #f6c445;
  border-bottom: 1.5px solid var(--ink);
  text-align: center;
}
.pilot strong {
  font-family: var(--display);
  font-weight: 400;
  background: var(--ink);
  color: #f6c445;
  padding: 0 0.5rem;
  border-radius: 2px;
}

.pilot-short { display: none; }

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  background: var(--ink);
  color: var(--paper);
  border-bottom: 4px solid var(--accent);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  color: var(--paper);
  text-decoration: none;
}
.brand:hover { color: var(--paper); }
.brand-mark {
  width: 14px;
  height: 14px;
  background: var(--accent);
  align-self: center;
  transform: rotate(45deg);
}
.brand-name { font-family: var(--display); font-size: 1.45rem; letter-spacing: 0.01em; }
.brand-sub {
  font-size: 0.8rem;
  color: #c9c3b4;
  border-inline-start: 1px solid #55554e;
  padding-inline-start: 0.6rem;
}

.nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; font-size: 0.95rem; }
.nav a { color: var(--paper); text-decoration: none; }
.nav a:hover { color: #ffb08f; }
.nav .who { color: #c9c3b4; font-size: 0.85rem; }
.nav .link { color: #c9c3b4; }

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

.page {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(1.2rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem) 3rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.display {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.7rem, 4.5vw, 2.4rem);
  line-height: 1.1;
  margin: 0;
}
.display-sm { font-family: var(--display); font-size: 1.4rem; margin: 0.2rem 0; }

.foot {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 1.2rem;
  border-top: 1px dashed var(--rule);
}

/* ---------- the sheet (a waybill) ---------- */

.sheet {
  position: relative;
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 2.2rem clamp(1rem, 4vw, 2.2rem) 1.8rem;
  box-shadow: 6px 6px 0 var(--paper-2), 6px 6px 0 1.5px var(--ink);
  animation: rise 0.35s ease-out both;
}
.sheet.narrow { max-width: 440px; margin: 2rem auto; }
.sheet.center { text-align: center; }
.sheet.empty { text-align: center; padding-top: 2.6rem; }

.barcode {
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 10px;
  background: repeating-linear-gradient(90deg,
    var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px,
    var(--ink) 8px 11px, transparent 11px 12px, var(--ink) 12px 13px, transparent 13px 17px);
  opacity: 0.9;
}

.perforation {
  margin: 1.6rem calc(-1 * clamp(1rem, 4vw, 2.2rem));
  border-top: 2px dashed var(--rule);
  position: relative;
}
.perforation::before,
.perforation::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
}
.perforation::before { inset-inline-start: -9px; clip-path: inset(0 0 0 50%); }
.perforation::after { inset-inline-end: -9px; clip-path: inset(0 50% 0 0); }
[dir="rtl"] .perforation::before { clip-path: inset(0 50% 0 0); }
[dir="rtl"] .perforation::after { clip-path: inset(0 0 0 50%); }

/* ---------- form ---------- */

fieldset.section { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.section legend {
  font-family: var(--display);
  font-size: 1.25rem;
  padding: 0;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}
.num {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--card);
  background: var(--ink);
  padding: 0.1rem 0.45rem;
  border-radius: 2px;
  transform: translateY(-2px);
}

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem 1.2rem; }
.grid > .field { grid-column: span 1; }
.span-2 { grid-column: span 2 !important; }
.span-4 { grid-column: 1 / -1 !important; }
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2, .span-4 { grid-column: 1 / -1 !important; }
}

.stack { display: grid; gap: 1rem; margin-top: 1.2rem; }

.field { display: flex; flex-direction: column; gap: 0.25rem; position: relative; scroll-margin-top: 0.8rem; }
.field > span { font-size: 0.82rem; font-weight: 600; color: var(--ink-2); }
.field input,
.field textarea {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 0.35rem 0.1rem;
  outline: none;
  transition: border-color 0.15s, background-color 0.15s;
  width: 100%;
}
.field textarea { border: 1.5px solid var(--ink); padding: 0.5rem; resize: vertical; }
.field input:focus,
.field textarea:focus { border-color: var(--accent); background: #fff7f1; }
.field input[type="number"] { font-family: var(--mono); }
.field em { font-style: normal; font-size: 0.78rem; }
.field .hint { color: var(--muted); }
.field .err { color: var(--err); font-weight: 600; }
.has-error input, .has-error textarea { border-color: var(--err); background: #fdf1ef; }

.check { display: flex; gap: 0.5rem; align-items: center; font-size: 0.9rem; color: var(--ink-2); }
.check input { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }

/* autocomplete */
.combo-list {
  position: absolute;
  z-index: 20;
  inset-inline: 0;
  top: 100%;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--card);
  border: 1.5px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  max-height: 16rem;
  overflow-y: auto;
}
.combo-list li { padding: 0.45rem 0.7rem; cursor: pointer; display: flex; gap: 0.6rem; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--ink); color: var(--paper); }
.combo-list li .mono { opacity: 0.75; }
.combo-list li.none { color: var(--muted); cursor: default; }
.combo-list li.none:hover { background: none; color: var(--muted); }

/* product lines */
.lines { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.5rem; }
.line {
  display: grid;
  grid-template-columns: auto 1fr 4.5rem 2rem;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 0.7rem;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  animation: rise 0.2s ease-out both;
}
.line .sku { font-size: 0.85rem; background: var(--card); border: 1px solid var(--rule); padding: 0 0.35rem; }
.line .qty input {
  width: 100%;
  font: 600 1rem var(--mono);
  text-align: center;
  border: 1.5px solid var(--ink);
  background: var(--card);
  padding: 0.2rem;
}
.line .remove {
  border: 0;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-2);
}
.line .remove:hover { color: var(--err); }
@media (max-width: 520px) {
  .line { grid-template-columns: 1fr 4rem 2rem; }
  .line .sku { grid-column: 1 / -1; justify-self: start; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: 600 1rem var(--body);
  padding: 0.7rem 1.3rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn-accent { background: var(--accent); color: #fff; box-shadow: 3px 3px 0 var(--ink); }
.btn-accent:hover { color: #fff; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn-accent:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.masthead .btn-accent { border-color: var(--accent); box-shadow: none; }
.btn-ghost { background: var(--card); color: var(--ink); }
.btn-ghost:hover { background: var(--paper-2); }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.9rem; }
.btn.wide { width: 100%; }
button.link { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.actions { display: flex; justify-content: flex-end; gap: 0.8rem; margin-top: 1.8rem; flex-wrap: wrap; }

/* ---------- notices & stamps ---------- */

.notice {
  border-inline-start: 4px solid var(--ink);
  background: var(--paper-2);
  padding: 0.6rem 0.9rem;
  margin: 0 0 1.2rem;
}
.notice.err { border-color: var(--err); background: #fbe9e6; color: #7d1a14; }
.notice.ok { border-color: var(--ok); background: #e7f0e7; color: #1f4a2a; }

.stamp {
  display: inline-block;
  font: 600 0.78rem var(--body);
  letter-spacing: 0.02em;
  padding: 0.12rem 0.55rem;
  border: 2px solid currentColor;
  border-radius: 3px;
  transform: rotate(-2.5deg);
  white-space: nowrap;
  color: var(--ok);
  background: rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}
.stamp-pending { color: var(--warn); }
.stamp-failed { color: var(--accent-ink); }
.stamp-lg { font-size: 1rem; padding: 0.3rem 0.9rem; border-width: 3px; }

.tag { font-size: 0.78rem; border: 1px solid var(--rule); padding: 0 0.35rem; }

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

.waybills { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.waybill {
  border: 1.5px solid var(--ink);
  background: var(--card);
  box-shadow: 4px 4px 0 var(--paper-2), 4px 4px 0 1.5px var(--ink);
  animation: rise 0.3s ease-out both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.waybill-link { display: block; color: inherit; text-decoration: none; }
.waybill-link:hover { color: inherit; background: #fffaf2; }
.wb-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 1rem;
  border-bottom: 1.5px dashed var(--rule);
}
.wb-num { font-weight: 600; font-size: 1.05rem; }
.wb-body { display: grid; grid-template-columns: 1fr 1.3fr; gap: 1rem; padding: 0.8rem 1rem; }
@media (max-width: 600px) { .wb-body { grid-template-columns: 1fr; } }
.wb-to { display: flex; flex-direction: column; }
.k { font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.wb-items { list-style: none; margin: 0; padding: 0; font-size: 0.92rem; }
.wb-items .qty, .review-lines .qty { font-weight: 600; color: var(--accent-ink); }
.wb-foot { display: flex; gap: 1.2rem; padding: 0 1rem 0.7rem; font-size: 0.8rem; }

/* ---------- review / detail ---------- */

.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 600px) { .review-grid { grid-template-columns: 1fr; } }
.review-grid p { margin: 0.1rem 0; }
.label { font: 600 0.75rem var(--body); color: var(--muted); margin: 0 0 0.3rem; letter-spacing: 0.03em; }
.big { font-family: var(--display); font-size: 1.35rem; }
.review-lines { list-style: none; padding: 0; margin: 0.4rem 0 0.8rem; display: grid; gap: 0.35rem; }
.review-lines .sku { font-size: 0.85rem; color: var(--ink-2); }

.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.ordnum { font-size: clamp(1.6rem, 5vw, 2.3rem); font-weight: 600; margin: 0; }

/* ---------- admin tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th {
  text-align: start;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1.5px solid var(--ink);
  padding: 0.4rem 0.5rem;
}
table.data td { padding: 0.5rem; border-bottom: 1px dashed var(--rule); vertical-align: top; }
table.data tr.inactive td { color: var(--muted); text-decoration: line-through; }
.kpis { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.kpi { border: 1.5px solid var(--ink); background: var(--card); padding: 0.6rem 1rem; min-width: 9rem; }
.kpi b { display: block; font: 600 1.6rem var(--mono); }
.setup-link {
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
  background: var(--paper);
  border: 1.5px dashed var(--ink);
  padding: 0.7rem;
  user-select: all;
}

/* ---------- phones ---------- */

@media (max-width: 640px) {
  .pilot { padding: 0.25rem 0.8rem; font-size: 0.8rem; gap: 0.5rem; }
  .pilot-long { display: none; }
  .pilot-short { display: inline; }
  .masthead { padding: 0.55rem 1rem; gap: 0.3rem 1rem; }
  .brand-name { font-size: 1.2rem; }
  .brand-sub { display: none; }
  .nav { gap: 0.4rem 0.9rem; font-size: 0.9rem; }
  .nav .nav-new { display: none; }  /* every dealer page has its own button */
  .nav .who { order: 3; flex-basis: 100%; font-size: 0.78rem; }
  .page { padding-top: 1rem; }
  .page-head { margin-bottom: 1rem; }
  .actions { flex-direction: column-reverse; align-items: stretch; }
  .actions .btn { width: 100%; padding: 0.85rem 1rem; }
  .actions form.inline { display: block; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
