/* The Tribe — Arabic, right to left, built for a phone held in one hand in a
   shop. Dark because a bright white screen in a lit shop is glare, and because
   it costs less battery on the OLED phones people here actually carry. */

:root {
  --bg: #111318;
  --surface: #1b1f27;
  --surface-2: #232833;
  --line: #2e3542;
  --text: #f2f4f8;
  --dim: #98a1b3;
  --accent: #3ba55d;
  --accent-dim: #2c7d46;
  --warn: #e5484d;
  --gold: #d4a24c;
  --tap: 48px; /* nothing a finger must hit is smaller than this */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, "Segoe UI", Tahoma, sans-serif;
  font-size: 16px; /* never smaller: this is read at arm's length, in a hurry */
  overscroll-behavior-y: contain;
}

.screen { display: block; min-height: 100%; }
[hidden] { display: none !important; }

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

.login-box {
  max-width: 380px;
  margin: 0 auto;
  padding: 15vh 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-box h1 { text-align: center; font-size: 34px; margin: 0 0 12px; letter-spacing: 1px; }
label { display: flex; flex-direction: column; gap: 6px; color: var(--dim); font-size: 14px; }
input, select {
  min-height: var(--tap);
  padding: 0 14px;
  font-size: 17px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: inherit;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.with-eye { position: relative; display: block; }
.with-eye input { width: 100%; padding-inline-end: 52px; }
.eye {
  position: absolute; inset-block-start: 0; inset-inline-end: 0;
  height: 100%; min-height: 0; width: 48px; padding: 0;
  background: none; border: none; font-size: 20px;
}

button {
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: var(--tap);
  padding: 0 16px;
  cursor: pointer;
}
button:active { transform: scale(0.98); }
.primary { background: var(--accent); border-color: var(--accent); font-weight: 700; }
.primary:disabled { background: var(--surface-2); border-color: var(--line); color: var(--dim); }
.big { min-height: 56px; font-size: 18px; width: 100%; }
.icon-btn { min-width: var(--tap); padding: 0 10px; background: none; border: none; font-size: 22px; }
.error { color: var(--warn); margin: 4px 0 0; font-size: 15px; line-height: 1.5; }

/* --- top bar and categories ----------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar input { flex: 1; }

.strip {
  position: sticky; top: 69px; z-index: 4;
  display: flex; gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  background: var(--bg);
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.strip button { white-space: nowrap; min-height: 38px; border-radius: 20px; font-size: 15px; }
.strip button.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }

/* --- the grid ------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* three per row on a phone */
  gap: 10px;
  padding: 4px 12px 120px;
}
@media (min-width: 620px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(6, 1fr); } }

.tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.tile .icon { font-size: 30px; line-height: 1; text-align: center; padding-top: 4px; }
.tile .name {
  font-size: 13px; line-height: 1.3; font-weight: 600;
  /* Two lines maximum, per the spec. A third line steals the size chips. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile .price { font-size: 14px; font-weight: 700; color: var(--accent); }
.tile .price .was { color: var(--dim); text-decoration: line-through; font-weight: 400; font-size: 12px; margin-inline-start: 5px; }

/* A number appears only when stock is low. Above the threshold, nothing. */
.low {
  position: absolute; inset-block-start: 6px; inset-inline-end: 6px;
  min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 11px;
  background: var(--warn); color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.empty { text-align: center; color: var(--dim); padding: 40px 20px; }

/* --- cart button ---------------------------------------------------------- */

.cart-fab {
  position: fixed;
  inset-block-end: calc(18px + env(safe-area-inset-bottom));
  /* Bottom right, physically, as the spec says — not "inline end", which in a
     right-to-left layout puts it on the left. Most people hold the phone in
     their right hand, and this is the button they press most. */
  right: 18px;
  z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 22px;
  border-radius: 28px;
  background: var(--accent); border-color: var(--accent);
  font-size: 17px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.cart-count {
  background: rgba(0,0,0,.35);
  min-width: 26px; height: 26px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

/* --- sheets: the cart and the product card -------------------------------- */

.sheet {
  position: fixed; inset: 0; z-index: 30;
  background: var(--bg);
  overflow-y: auto;
  padding: 0 14px calc(28px + env(safe-area-inset-bottom));
}
.sheet-head {
  position: sticky; top: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.sheet-head h2 { font-size: 19px; margin: 0; }

.lines { display: flex; flex-direction: column; gap: 8px; }
.line {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px;
}
.line .what { flex: 1; min-width: 0; }
.line .what b { display: block; font-size: 15px; }
.line .what span { color: var(--dim); font-size: 13px; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 38px; min-height: 38px; padding: 0; font-size: 20px; }
.qty b { min-width: 28px; text-align: center; }

.totals { margin: 16px 0; padding: 14px; background: var(--surface); border-radius: 14px; }
.totals .row { display: flex; justify-content: space-between; font-size: 18px; }

.channel, .payment { display: flex; gap: 8px; margin-bottom: 12px; }
.chan, .pay { flex: 1; }
.chan.on, .pay.on { background: var(--surface-2); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.delivery { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.card-block { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.card-block h3 { margin: 0 0 10px; font-size: 15px; color: var(--dim); font-weight: 600; }
.stock-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.stock-row:last-child { border-bottom: none; }
.stock-row .gone { color: var(--warn); }

/* --- connection and pending sales ----------------------------------------- */

.status {
  position: fixed;
  inset-block-end: calc(20px + env(safe-area-inset-bottom));
  left: 16px;  /* the opposite corner from the cart button */
  z-index: 19;
  display: flex; gap: 8px; align-items: center;
  font-size: 13px; color: var(--dim);
}
.status .pill {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 20px; padding: 7px 12px;
}
.status .pill.offline { border-color: var(--gold); color: var(--gold); }
.status .pill.pending { border-color: var(--gold); color: var(--gold); }

/* --- toast ---------------------------------------------------------------- */

.toast {
  position: fixed;
  inset-block-end: calc(84px + env(safe-area-inset-bottom));
  inset-inline: 16px;
  z-index: 40;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 16px;
  text-align: center;
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.toast.bad { border-color: var(--warn); color: var(--warn); }

/* --- adding a product, the sales room, shifts ----------------------------- */

/* The + sits beside the cart button rather than under it: a senior adding
   stock and a cashier selling are the two things done from this screen. */
.add-fab {
  position: fixed;
  inset-block-end: calc(18px + env(safe-area-inset-bottom));
  right: 92px;
  z-index: 20;
  width: 56px; height: 56px; padding: 0;
  border-radius: 28px;
  background: var(--surface-2); border-color: var(--line);
  font-size: 26px; font-weight: 400;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
/* With nothing in the cart the + moves into the corner, so there is never a
   gap where a button used to be. */
.add-fab.alone { right: 18px; }

.two, .three { display: flex; gap: 8px; align-items: flex-end; }
.two > label { flex: 1; }
.three > label { flex: 1; }
.three > button { width: 56px; padding: 0; font-size: 24px; }

hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* Suggestions: what this shop has typed before, most used first. Tappable, and
   never a closed list — the field beside them still takes anything. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chips button {
  min-height: 34px; padding: 0 12px;
  font-size: 14px; border-radius: 17px;
  background: var(--surface-2);
}
.chips button.on { background: var(--accent); border-color: var(--accent); font-weight: 700; }

.menu-item { width: 100%; text-align: start; min-height: 54px; font-size: 17px; }
.menu-item.danger { color: var(--warn); border-color: var(--warn); }
.badge {
  background: var(--warn); color: #fff;
  border-radius: 11px; padding: 2px 8px; font-size: 13px; font-weight: 700;
  margin-inline-start: 8px;
}

.order-row { display: flex; justify-content: space-between; align-items: center; }
.order-row .when { color: var(--dim); font-size: 13px; }
.chan-tag {
  font-size: 12px; padding: 3px 9px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--dim);
}
.chan-tag.social { color: var(--gold); border-color: var(--gold); }

.ret-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ret-line select, .ret-line input { min-height: 42px; font-size: 15px; }
.ret-qty { width: 74px; }
.ret-reason { flex: 1; min-width: 140px; }

.big-number { font-size: 30px; font-weight: 700; }
.short { color: var(--warn); }
.over { color: var(--gold); }

.muted { color: var(--dim); font-size: 13px; line-height: 1.6; margin: 0 0 10px; }

/* The delivery room. Each card is one box on its way somewhere, so the actions
   sit together at the foot of it and never float over the address. */
.delivery-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.delivery-actions button { flex: 1; min-width: 110px; }
.refuse-block { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.slip {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; white-space: pre-wrap; font-size: 13px; line-height: 1.7;
  user-select: all; margin-bottom: 12px;
}


/* --- selling one product --------------------------------------------------
   The sheet that opens when a product is tapped. The shelf stays visible and
   blurred behind it, because a cashier needs to know they are still on the
   grid, one product deep — not on some other screen they have to find their
   way back from. Blur is decoration; the scrim underneath does the work, so a
   phone whose browser will not blur still gets a readable sheet. */

.over { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; }
.scrim {
  position: absolute; inset: 0;
  background: rgba(10, 12, 16, 0.55);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.pick-panel {
  position: relative;
  width: 100%; max-height: 88vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.45);
}
.pick-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.pick-title { flex: 1; min-width: 0; }
.pick-title b { display: block; font-size: 19px; }
.pick-title span { color: var(--accent); font-weight: 700; }

.pick-label { color: var(--dim); font-size: 14px; margin: 0 0 8px; }
.pick-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }

/* Big on purpose. This is the one place with room for it, and it is being
   tapped by somebody holding a phone in one hand and a garment in the other. */
.pick-chip {
  min-height: 56px; min-width: 74px; padding: 0 16px;
  font-size: 18px; border-radius: 14px;
  background: var(--surface-2);
}
.pick-chip.on { background: var(--accent); border-color: var(--accent); font-weight: 700; }
.pick-chip .left { display: block; font-size: 11px; font-weight: 400; color: var(--dim); }
.pick-chip.on .left { color: rgba(255, 255, 255, 0.85); }
.pick-chip .left.short { color: var(--warn); }

.pick-qty { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.pick-qty button { width: 62px; min-height: 56px; font-size: 26px; padding: 0; }
.pick-qty b { font-size: 26px; min-width: 56px; text-align: center; }

.pick-foot {
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: 12px;
  padding-top: 12px; background: var(--surface);
  border-top: 1px solid var(--line);
}
.pick-sum { flex: 1; display: flex; flex-direction: column; }
.pick-sum span { color: var(--dim); font-size: 12px; }
.pick-sum b { font-size: 22px; }
.pick-foot .primary { flex: 1.2; }

.pick-note { color: var(--warn); font-size: 13px; margin: 0 0 12px; }

/* The tile's sizes are a summary now, not controls: everything that can be
   chosen is chosen in the sheet, where there is room to choose it properly. */
.tile .size-note { color: var(--dim); font-size: 12px; letter-spacing: 1px; }

/* The copy button lives in the card's corner: it is the thing done most often
   in this room, and it is not a step in the order's life like the others. */
.card-block { position: relative; }
.copy-corner {
  position: absolute; top: 10px; inset-inline-end: 10px;
  width: 44px; min-height: 44px; padding: 0;
  font-size: 19px; border-radius: 12px;
  background: var(--surface-2); color: var(--dim);
}
.copy-corner:active { color: var(--accent); border-color: var(--accent); }

/* Returned orders, seen from the outside.
   Amber for some of it, red for all of it — a customer bringing half an order
   back and a customer bringing the whole thing back are two different
   conversations, and the list should say which before anybody opens it. */
.line.some-back { border-color: var(--gold); }
.line.all-back { border-color: var(--warn); }
.card-block.some-back { border-color: var(--gold); }
.card-block.all-back { border-color: var(--warn); }

.back-tag {
  display: inline-block; padding: 2px 8px; border-radius: 8px;
  font-size: 12px; font-weight: 700;
  background: rgba(212, 162, 76, 0.16); color: var(--gold);
  margin-inline-start: 6px;
}
.all-back .back-tag { background: rgba(229, 72, 77, 0.16); color: var(--warn); }

/* The order's own total is never rewritten — what was sold is what was sold —
   so it stays visible with the net beside it rather than being replaced. */
.was { color: var(--dim); text-decoration: line-through; font-weight: 400; font-size: 13px; }
.refunded { color: var(--warn); }
.net { color: var(--accent); }
.back-note { display: block; color: var(--gold); font-size: 12px; }
.reason { display: block; color: var(--dim); font-size: 12px; }

/* Signing up, and the first thing an empty shop sees. */
.linky {
  background: none; border: none; color: var(--accent);
  font-size: 15px; text-decoration: underline; min-height: var(--tap);
}
.hint { color: var(--dim); font-size: 12px; line-height: 1.6; }
.hint.bad { color: var(--warn); }
.hint.good { color: var(--accent); }
#first-run { margin: 24px 14px; }

.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.check input { width: 22px; height: 22px; min-height: 22px; accent-color: var(--accent); }

/* The code a shop is handed, and the walk-through that follows it. */
.big-code {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--accent);
  border-radius: 16px; padding: 22px; margin: 18px 0;
}
.big-code b { font-size: 34px; letter-spacing: 3px; color: var(--accent); }
.big-code span { color: var(--dim); font-size: 14px; }

.tour-step { min-height: 190px; }
.tour-step h2 { margin: 6px 0 10px; font-size: 21px; }
.tour-step p { line-height: 1.9; color: var(--text); margin: 0; }
.tour-buttons { display: flex; gap: 8px; }
.tour-buttons button { flex: 1; }
.tour-buttons .primary { flex: 1.4; }

/* A discount, wherever it shows: on a tile, on a cart line, in the sheet. */
.offer-tag {
  display: inline-block; padding: 1px 7px; border-radius: 7px;
  font-size: 11px; font-weight: 700;
  background: rgba(59, 165, 93, 0.16); color: var(--accent);
  margin-inline-start: 6px;
}
.qty [data-cut] { font-size: 15px; color: var(--accent); }
