/* Uncle Reda back-office: ketchup red for actions, mustard for selection, pickle green
   for "all good", charcoal grill for the top bar. Lalezar only for big numbers. */
:root {
  --ketchup: #c8231c;
  --ketchup-dark: #9e1913;
  --mustard: #f2b705;
  --mustard-soft: #fff3c4;
  --pickle: #2f7d4f;
  --pickle-soft: #e3f2e8;
  --amber: #b45309;
  --amber-soft: #fdf0dc;
  --grill: #2b2522;
  --ink: #1f1f1f;
  --ink-2: #55504b;
  --line: #dedad3;
  --paper: #f7f7f5;
  --white: #ffffff;
  --radius-s: 8px;
  --radius-m: 14px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --display: "Lalezar", "IBM Plex Sans Arabic", sans-serif;
  --tap: 52px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--paper); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.big { font-family: var(--display); font-weight: 400; font-size: 2.6rem; line-height: 1; letter-spacing: 0; }
.muted { color: var(--ink-2); }
.hint { color: var(--ink-2); font-size: .92rem; margin: .4rem 0 0; }

/* ---------- buttons ---------- */
.btn { min-height: 44px; padding: .55rem 1.1rem; border-radius: var(--radius-s); border: 2px solid transparent; background: var(--white); cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; transition: background .15s, border-color .15s, transform .08s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ketchup); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--ketchup-dark); }
.btn-dark { background: var(--grill); color: var(--white); }
.btn-outline { border-color: var(--line); }
.btn-outline:hover { border-color: var(--ink-2); }
.btn-quiet { background: transparent; color: inherit; }
.btn-danger { background: var(--white); color: var(--ketchup); border-color: var(--ketchup); }
.btn-xl { min-height: var(--tap); font-size: 1.15rem; padding: .7rem 1.4rem; width: 100%; }
.btn-sm { min-height: 36px; padding: .3rem .8rem; font-size: .92rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.toolbar .btn { min-height: var(--tap); }
.choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice { min-height: 48px; padding: .5rem 1rem; border-radius: var(--radius-s); border: 2px solid var(--line); background: var(--white); cursor: pointer; font-weight: 600; }
.choice[aria-pressed="true"] { background: var(--mustard-soft); border-color: var(--mustard); }
.choice-lg { min-height: 64px; min-width: 9.5rem; font-size: 1.05rem; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--grill); }
.login-card { width: min(420px, 100%); background: var(--white); border-radius: var(--radius-m); padding: 2rem; display: grid; gap: 1rem; }
.login-logo { width: 190px; max-width: 70%; margin: 0 auto -.5rem; display: block; }
.login-card h1 { font-size: 1.2rem; font-weight: 600; }

/* ---------- fields ---------- */
.field { display: grid; gap: .3rem; }
.field > span { font-weight: 600; font-size: .95rem; }
.field input, .field select, .field textarea { min-height: 48px; border: 2px solid var(--line); border-radius: var(--radius-s); padding: .5rem .75rem; background: var(--white); width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--grill); outline: none; }
.fields { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-error { color: var(--ketchup); font-weight: 600; margin: 0; min-height: 1.2em; }

/* ---------- top bar ---------- */
.bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .5rem 1rem; background: var(--grill); color: var(--white); }
.brand { display: flex; align-items: center; gap: .5rem; line-height: 1.1; color: inherit; text-decoration: none; }
.brand img { height: 46px; width: auto; }
.brand > span { display: grid; }
.brand-name { font-family: var(--display); font-size: 1.7rem; color: var(--mustard); }
.brand-branch { font-size: .8rem; opacity: .8; }
.tabs { flex: 1; display: flex; flex-wrap: wrap; gap: .25rem; }
.tab { text-decoration: none; min-height: var(--tap); min-width: 5.5rem; padding: .35rem .8rem; border: 0; border-radius: var(--radius-s); background: transparent; color: #e9e4df; cursor: pointer; display: grid; justify-items: center; gap: .1rem; font-weight: 600; font-size: .9rem; }
.tab svg { width: 22px; height: 22px; }
.tab:hover { background: rgba(255,255,255,.08); }
.tab[aria-current="page"] { background: var(--ketchup); color: var(--white); }
.who { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.who-role { background: rgba(255,255,255,.12); padding: .2rem .6rem; border-radius: 99px; white-space: nowrap; }

/* ---------- page ---------- */
.view { padding: 1.25rem; max-width: 1400px; margin: 0 auto; outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-head p { margin: .2rem 0 0; color: var(--ink-2); }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.1rem; }
.panel + .panel { margin-top: 1rem; }
.split { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); align-items: start; }
.stack { display: grid; gap: 1rem; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-size: 1.1rem; margin-bottom: .3rem; }

/* status tags: always text + color, never color alone */
.tag { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 99px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.tag-ok { background: var(--pickle-soft); color: var(--pickle); }
.tag-low { background: var(--amber-soft); color: var(--amber); }
.tag-bad { background: #fde4e2; color: var(--ketchup-dark); }
.tag-plain { background: #ece9e4; color: var(--ink-2); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--ink-2); font-weight: 600; }
td.n, th.n { text-align: end; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }

/* ---------- cashier ---------- */
.pos { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
.cats { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .5rem; }
.tiles { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { min-height: 96px; padding: .7rem; border: 2px solid var(--line); border-radius: var(--radius-m); background: var(--white); cursor: pointer; display: grid; align-content: space-between; text-align: start; gap: .4rem; }
.tile:hover { border-color: var(--ink-2); }
.tile:active { background: var(--mustard-soft); border-color: var(--mustard); }
.tile-name { font-weight: 700; line-height: 1.3; }
.tile-price { font-weight: 600; color: var(--ketchup); }
.tile-sizes { font-size: .8rem; color: var(--ink-2); }

/* the order ticket: a thermal receipt, the one bold element on the page */
.ticket { position: sticky; top: 76px; display: grid; gap: 1rem; }
.receipt { background: var(--white); padding: 1.2rem 1.1rem 1.4rem; border-radius: 4px; box-shadow: 0 1px 0 var(--line); position: relative;
  -webkit-mask: radial-gradient(circle 7px at 7px 100%, transparent 98%, #000) -7px 100% / 14px 100% repeat-x, linear-gradient(#000, #000) 0 0 / 100% calc(100% - 7px) no-repeat;
          mask: radial-gradient(circle 7px at 7px 100%, transparent 98%, #000) -7px 100% / 14px 100% repeat-x, linear-gradient(#000, #000) 0 0 / 100% calc(100% - 7px) no-repeat; }
.receipt h2 { font-family: var(--display); font-weight: 400; font-size: 1.6rem; }
.receipt-lines { list-style: none; margin: .8rem 0; padding: .6rem 0; border-block: 2px dashed var(--line); display: grid; gap: .5rem; min-height: 4rem; }
.receipt-line { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; }
.stepper { display: inline-flex; align-items: center; border: 2px solid var(--line); border-radius: var(--radius-s); }
.stepper button { width: 38px; height: 38px; border: 0; background: transparent; font-size: 1.2rem; font-weight: 700; cursor: pointer; }
.stepper span { min-width: 1.8rem; text-align: center; font-weight: 700; }
.line-name small { display: block; color: var(--ink-2); }
.sums { display: grid; gap: .25rem; font-size: .95rem; }
.sums div { display: flex; justify-content: space-between; }
.sums .discount { color: var(--pickle); }
.grand { display: flex; justify-content: space-between; align-items: end; margin: .8rem 0 1rem; }
.grand .big { color: var(--ketchup); }
.ticket-actions { display: grid; gap: .5rem; }
.recent-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.recent-row:last-child { border-bottom: 0; }

/* warnings after an order */
.notice { border-inline-start: 5px solid var(--amber); background: var(--amber-soft); padding: .7rem .9rem; border-radius: var(--radius-s); }
.notice-bad { border-color: var(--ketchup); background: #fdecea; }
.notice-ok { border-color: var(--pickle); background: var(--pickle-soft); }
.notice ul { margin: .3rem 0 0; padding-inline-start: 1.2rem; }

/* recipes */
.recipe-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) auto; gap: .8rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.recipe-row:last-child { border-bottom: 0; }
.size-costs { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .92rem; color: var(--ink-2); }
.cat-title { margin: 1.2rem 0 .2rem; font-size: 1rem; color: var(--ink-2); }
.editor-lines { display: grid; gap: .5rem; margin: .5rem 0; }
.editor-line { display: grid; grid-template-columns: minmax(0, 2fr) 110px 70px 80px 44px; gap: .5rem; align-items: center; }
.editor-line select, .editor-line input { min-height: 46px; border: 2px solid var(--line); border-radius: var(--radius-s); padding: .3rem .5rem; width: 100%; background: var(--white); }
.editor-cost { display: flex; justify-content: space-between; align-items: center; padding: .6rem .8rem; background: var(--paper); border-radius: var(--radius-s); }
.size-block { border-top: 1px solid var(--line); padding-top: .8rem; margin-top: .8rem; }

/* bars for reports */
.bars { display: grid; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 9rem 1fr auto; gap: .6rem; align-items: center; font-size: .95rem; }
.bar-track { height: 14px; background: #eeebe6; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--ketchup); border-radius: 99px; }

/* statements */
.kpis { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-m); padding: .9rem 1rem; }
.kpi > span { display: block; color: var(--ink-2); font-size: .9rem; }
.kpi strong { font-size: 1.5rem; }
.statement { display: grid; }
.st-row { display: flex; justify-content: space-between; padding: .45rem 0; border-bottom: 1px dotted var(--line); }
.st-row.sub { padding-inline-start: 1.2rem; color: var(--ink-2); }
.st-row.result { font-weight: 700; border-bottom: 2px solid var(--ink); padding: .65rem 0; }
.st-row.final { border: 0; padding-top: 1rem; align-items: end; }
.st-row.final .big { color: var(--pickle); }
.st-row.final .big.neg { color: var(--ketchup); }
.ratio-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

/* dialog */
.sheet { border: 0; border-radius: var(--radius-m); padding: 0; width: min(720px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); }
.sheet::backdrop { background: rgba(31, 26, 23, .55); }
.sheet-body { padding: 1.3rem; display: grid; gap: 1rem; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.sheet-foot { display: flex; gap: .6rem; justify-content: flex-start; flex-wrap: wrap; }
.sheet-foot .btn { min-height: var(--tap); min-width: 8rem; }

.toast { position: fixed; inset-inline: 0; bottom: 1.2rem; margin: 0 auto; width: fit-content; max-width: calc(100vw - 2rem); background: var(--grill); color: var(--white); padding: .8rem 1.2rem; border-radius: var(--radius-s); font-weight: 600; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--ketchup); }

@media (max-width: 1050px) {
  .pos, .split { grid-template-columns: 1fr; }
  .ticket { position: static; }
}
@media (max-width: 720px) {
  .bar { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; }
  .recipe-row { grid-template-columns: 1fr; }
  .editor-line { grid-template-columns: 1fr 90px 60px 40px; }
  .editor-line .line-cost { display: none; }
  .bar-row { grid-template-columns: 6rem 1fr auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .bar, .toolbar, .btn { display: none !important; }
  body { background: #fff; }
  .panel { border: 0; }
}

/* ---------- v4 additions ---------- */
.btn-kitchen { background: var(--mustard); color: var(--grill); min-height: 40px; }
.subtabs { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 1rem; border-bottom: 2px solid var(--line); }
.subtab { min-height: 46px; padding: .4rem 1rem; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; background: transparent; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.subtab[aria-selected="true"] { color: var(--ketchup); border-bottom-color: var(--ketchup); }
.pay-methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-bottom: .6rem; }
.pay-choice { min-height: 52px; padding: .3rem; }
.code { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; background: #ece9e4; border-radius: 6px; padding: .05rem .4rem; font-size: .85rem; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { background: var(--paper); border: 1px solid var(--line); border-radius: 99px; padding: .1rem .55rem; font-size: .85rem; white-space: nowrap; }
.menu-table td { vertical-align: top; }
.row-off { opacity: .55; }
.size-line, .receive-line { display: grid; gap: .5rem; align-items: center; }
.size-line { grid-template-columns: minmax(0, 2fr) 120px 44px; }
.receive-line { grid-template-columns: minmax(0, 2fr) repeat(auto-fit, minmax(90px, 1fr)); }
.size-line input, .size-line select, .receive-line input, .receive-line select, .count-input { min-height: 46px; border: 2px solid var(--line); border-radius: var(--radius-s); padding: .3rem .5rem; width: 100%; background: var(--white); }
.count-input { max-width: 140px; }
.neg-text { color: var(--ketchup); }
.pos-text { color: var(--pickle); }
.choice-cards { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.choice-card { text-align: start; border: 2px solid var(--line); background: var(--white); border-radius: var(--radius-m); padding: 1rem; cursor: pointer; display: grid; gap: .4rem; min-height: 120px; }
.choice-card strong { font-size: 1.1rem; }
.choice-card span { color: var(--ink-2); }
.choice-card:hover { border-color: var(--ketchup); }
label.choice { display: inline-flex; align-items: center; gap: .4rem; }
.app-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.app-cards .panel + .panel { margin-top: 0; }
.perm-grid { display: grid; gap: .4rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.perm { display: flex; gap: .5rem; align-items: center; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-s); min-height: 44px; }
.sheet-wide { width: min(1040px, calc(100vw - 2rem)); }
.print-frame { position: fixed; width: 0; height: 0; border: 0; visibility: hidden; }
.toolbar .kpi { padding: .4rem .8rem; }
code.copy { user-select: all; background: var(--white); padding: .1rem .4rem; border-radius: 6px; word-break: break-all; direction: ltr; display: inline-block; }
@media (max-width: 720px) { .pay-methods { grid-template-columns: repeat(2, 1fr); } .brand img { height: 36px; } }

/* narrow screens: brand + user on the first row, every section visible on the rows below */
@media (max-width: 1180px) {
  .tabs { order: 3; flex-basis: 100%; }
  .who { margin-inline-start: auto; }
  .tab { min-width: 0; flex: 1 1 5.5rem; }
}
