:root {
  --bg: #f2f4f8; --card: #fff; --soft: #f6f7fa; --text: #141821; --muted: #6b7280; --line: #e6e8ee;
  --acc: #f97316; --acc2: #ea580c; --accs: #fff1e6; --blue: #2563eb; --blues: #e8f0ff;
  --ok: #15803d; --oks: #dcfce7; --warn: #b45309; --warns: #fef3c7; --bad: #b91c1c; --bads: #fee2e2;
  --pur: #6d28d9; --purs: #ede9fe; --inds: #e0e7ff;
  --sh: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e16; --card: #131a26; --soft: #1a2232; --text: #eef1f6; --muted: #97a3b6; --line: #243045;
    --accs: #3a1f0c; --blue: #60a5fa; --blues: #132443; --ok: #4ade80; --oks: #0f2a1a; --warn: #fbbf24; --warns: #33260b;
    --bad: #f87171; --bads: #3a1414; --pur: #c4b5fd; --purs: #251b45; --inds: #1c2347;
    --sh: 0 1px 2px #0006, 0 8px 24px #0005; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0e16; --card: #131a26; --soft: #1a2232; --text: #eef1f6; --muted: #97a3b6; --line: #243045;
  --accs: #3a1f0c; --blue: #60a5fa; --blues: #132443; --ok: #4ade80; --oks: #0f2a1a; --warn: #fbbf24; --warns: #33260b;
  --bad: #f87171; --bads: #3a1414; --pur: #c4b5fd; --purs: #251b45; --inds: #1c2347;
  --sh: 0 1px 2px #0006, 0 8px 24px #0005; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 'Cairo', Tahoma, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
body.modal-open { overflow: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.3; }

/* ── Boot ── */
#boot { position: fixed; flex-direction: column; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: #0b1220; color: #f97316; font: 800 30px 'Cairo', Arial, sans-serif; letter-spacing: 6px; }

/* ── Header ── */
#top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(135deg, #0b1220, #1f2937); color: #fff; border-bottom: 3px solid var(--acc);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 21px; letter-spacing: 2px; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { display: inline-flex; flex-shrink: 0; border-radius: 12px; overflow: hidden; object-fit: cover; background: #111827; }
.logo.txt { align-items: center; justify-content: center; border: 2px solid #f97316; color: #f97316; font-family: 'Arial Black', Arial, Helvetica, sans-serif; font-weight: 900; letter-spacing: 1px; line-height: 1; direction: ltr; }
.who { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.whobtn { display: flex; flex-direction: column; align-items: flex-end; padding: 4px 8px; border: 0; border-radius: 10px; background: transparent; color: #fff; text-align: left; font-weight: 700; font-size: 13px; line-height: 1.25; cursor: pointer; }
.whobtn:hover { background: #ffffff12; }
.whobtn small { color: #94a3b8; font-size: 11px; font-weight: 600; }
.whobtn.side { align-items: flex-start; width: 100%; padding: 8px 4px; color: #cbd5e1; font-size: 13px; }
.offline { padding: 3px 10px; border-radius: 999px; background: #b91c1c; color: #fff; font-size: 12px; font-weight: 800; white-space: nowrap; }
.linkbtn { display: block; margin: 12px auto 0; border: 0; background: none; color: var(--acc2); font-weight: 700; font-size: 14px; cursor: pointer; }
.spin { display: inline-block; width: 16px; height: 16px; margin-left: 6px; vertical-align: -3px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.busy .btn, body.busy .st-sel { opacity: .6; pointer-events: none; }
body.busy { cursor: progress; }
.lockbtn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid #ffffff22; background: #ffffff12; color: #fff; font-size: 17px; cursor: pointer; }

/* ── Main ── */
#main { max-width: 680px; margin: 0 auto; padding: 16px 14px calc(104px + env(safe-area-inset-bottom)); }
.ptitle { font-size: 21px; font-weight: 800; margin: 2px 0 14px; display: flex; align-items: center; gap: 8px; }
.ptitle::before { content: ""; width: 5px; height: 24px; border-radius: 3px; background: var(--acc); }

/* ── Bottom nav (phone) ── */
#bnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; gap: 2px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: #0b1220; border-top: 1px solid #ffffff18;
}
#bnav a {
  flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 56px; padding: 4px 2px; border-radius: 14px; color: #a8b3c5; text-decoration: none; font-size: 12px; font-weight: 700;
}
#bnav a .i { font-size: 22px; line-height: 1.1; }
#bnav a.on { background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #fff; }
#bnav em, #side em { position: absolute; top: 4px; left: 50%; margin-left: 6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: #ef4444; color: #fff; font: 800 11px/19px 'Cairo', Arial, sans-serif; font-style: normal; text-align: center; }

/* ── Sidebar (desktop) ── */
#side { display: none; }
@media (min-width: 1000px) {
  body { padding-right: 252px; }
  #bnav { display: none !important; }
  #side {
    display: flex; flex-direction: column; gap: 2px; position: fixed; top: 0; bottom: 0; right: 0; width: 252px; z-index: 35;
    padding: 18px 12px; overflow-y: auto; background: linear-gradient(180deg, #111827, #0b1220); color: #fff;
  }
  #side[hidden] { display: none !important; }
  #top .brand { visibility: hidden; }
  #main { max-width: 1120px; padding: 24px 28px 48px; }
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; margin-bottom: 8px; border-bottom: 1px solid #ffffff14; }
.side-brand b { display: block; font-size: 20px; letter-spacing: 2px; }
.side-brand small { color: #94a3b8; font-size: 11px; }
#side .grp { color: #64748b; font-size: 11.5px; font-weight: 800; padding: 10px 12px 2px; }
#side a { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; color: #b8c2d3; text-decoration: none; font-weight: 700; font-size: 14.5px; }
#side a:hover { background: #ffffff0f; color: #fff; }
#side a.on { background: linear-gradient(90deg, var(--acc), var(--acc2)); color: #fff; box-shadow: 0 6px 16px #f9731640; }
#side a .i { width: 22px; text-align: center; }
#side em { position: static; margin: 0 auto 0 0; }
.side-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 8px; color: #94a3b8; }
.side-foot .btn.ghost { background: #ffffff10; color: #fff; border-color: #ffffff22; }

/* ── Cards & KPIs ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 14px; box-shadow: var(--sh); }
.card.soft { background: var(--soft); box-shadow: none; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-h b { font-size: 15.5px; font-weight: 800; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--sh); color: inherit; text-decoration: none; }
a.kpi:active { transform: scale(.98); }
.kpi .ic { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 6px; }
.kl { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.kv { font-size: 18px; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.kpi small { color: var(--muted); font-size: 11.5px; }
.t-g { background: var(--oks); } .t-b { background: var(--blues); } .t-o { background: var(--accs); } .t-r { background: var(--bads); }
.t-y { background: var(--warns); } .t-p { background: var(--purs); } .t-i { background: var(--inds); }
.ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); } .muted { color: var(--muted); }
.small { font-size: 12.5px; } .mb { margin-bottom: 10px; } .center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 22px 10px; font-weight: 600; }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 700; margin: 4px 0 10px; }
.lnk { color: var(--acc2); font-weight: 800; text-decoration: none; font-size: 13.5px; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: var(--warns); border-color: transparent; font-weight: 700; font-size: 13.5px; }
.alert-card { display: flex; align-items: center; gap: 8px; background: var(--blues); border-color: transparent; color: var(--text); text-decoration: none; font-weight: 700; }
.alert-card span { margin-right: auto; color: var(--blue); font-weight: 800; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--soft); color: var(--muted); }
.badge.ok { background: var(--oks); color: var(--ok); } .badge.bad { background: var(--bads); color: var(--bad); }
.badge.warn { background: var(--warns); color: var(--warn); } .badge.blue { background: var(--blues); color: var(--blue); }
.badge.purple { background: var(--purs); color: var(--pur); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 18px;
  border: 0; border-radius: 14px; background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #fff;
  font-weight: 800; font-size: 15.5px; text-decoration: none; cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 12px #f9731633; transition: transform .12s, filter .12s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--soft); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn.danger { background: var(--bads); color: var(--bad); box-shadow: none; }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: 13.5px; border-radius: 11px; }
.btn.lg { min-height: 56px; font-size: 17px; }
.btn.block { display: flex; width: 100%; margin-bottom: 12px; }
.card .btn.block:last-child, .sheet .btn.block:last-child, .lockbox .btn.block:last-child { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions > .btn { flex: 1 1 140px; }

/* ── Forms ── */
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--soft); color: var(--text); font-size: 16px; outline: 0; -webkit-appearance: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--acc); box-shadow: 0 0 0 3px #f9731626; background: var(--card); }
input:disabled { opacity: .7; }
input.big { min-height: 54px; font-size: 16.5px; border-radius: 14px; }
select {
  padding-left: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2397a3b6' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center;
}
select.auto { width: auto; min-height: 40px; }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; flex-shrink: 0; padding: 0; -webkit-appearance: auto; appearance: auto; accent-color: var(--acc); }
input[type=date] { display: block; min-height: 48px; direction: ltr; text-align: right; }
.fld { display: block; min-width: 0; margin-bottom: 10px; }
.fld > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.form2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.form2 .full { grid-column: 1 / -1; }
@media (max-width: 359px) { .form2 { grid-template-columns: 1fr; } }
.lbl { margin: 6px 0; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.chk { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-weight: 600; cursor: pointer; }
.toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.toolbar .btn { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > select, .row > input { flex: 1 1 130px; width: auto; }
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Segmented control & chips ── */
.seg { display: flex; gap: 4px; padding: 4px; margin-bottom: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 800; font-size: 14.5px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--acc2); box-shadow: var(--sh); }
.seg.mini { margin: 0; }
.seg.mini button { min-height: 34px; padding: 0 10px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; min-height: 38px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); font-weight: 700; font-size: 13.5px; white-space: nowrap; cursor: pointer; }
.chip.on { background: var(--acc); border-color: var(--acc); color: #fff; }
.chip em { font-style: normal; opacity: .75; margin-right: 3px; }

/* ── Product thumbs, POS ── */
.thumb { width: 52px; height: 52px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 12px; object-fit: cover; background: linear-gradient(135deg, #fde7d3, #fbd5b5); font-size: 24px; }
.thumb.lg { width: 96px; height: 96px; font-size: 44px; border-radius: 18px; }
.plist { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.pitem { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft); color: var(--text); text-align: right; cursor: pointer; }
.pitem:active { transform: scale(.99); }
.pitem:disabled { opacity: .55; cursor: not-allowed; }
.pi-b { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pi-b b, .pi-b small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-b small { color: var(--muted); font-size: 12px; }
.pi-m { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; font-weight: 700; }
.price { color: var(--acc2); font-weight: 800; }
.plus { width: 40px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--acc); color: #fff; font-size: 22px; font-weight: 800; }
.cline { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "n x" "s t"; align-items: center; gap: 8px 10px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.cline:last-child { border-bottom: 0; }
.cl-n { grid-area: n; min-width: 0; display: flex; flex-direction: column; }
.cl-n b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-n small { color: var(--muted); font-size: 12px; }
.cl-t { grid-area: t; font-size: 15px; }
.x { grid-area: x; width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--bads); color: var(--bad); font-weight: 800; cursor: pointer; }
.stepper { grid-area: s; justify-self: start; display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.stepper button { width: 42px; height: 42px; border: 0; background: transparent; color: var(--text); font-size: 18px; font-weight: 800; cursor: pointer; }
.stepper input { width: 52px; min-height: 42px; height: 42px; padding: 0; border: 0; border-radius: 0; background: var(--card); text-align: center; font-weight: 800; }
.sum { margin: 10px 0 12px; padding: 12px 14px; border-radius: 14px; background: var(--soft); }
.sum > div, .kv-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14px; }
.sum .grand, .kv-list .grand { margin-top: 4px; padding-top: 9px; border-top: 1px dashed var(--line); font-size: 17px; font-weight: 800; }
.kv-list > div > span { color: var(--muted); }
.kv-list > div > b { text-align: left; overflow-wrap: anywhere; }
.kv-list { margin-bottom: 8px; }

/* ── Product grid ── */
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 700px) { .pgrid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
.pcard { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--sh); color: var(--text); text-align: right; cursor: pointer; }
.pcard:active { transform: scale(.98); }
.pcard .thumb { width: 100%; height: 124px; margin-bottom: 6px; font-size: 44px; }
.pcard > b { font-size: 14.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard > small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .badge { align-self: flex-start; margin-top: 4px; white-space: normal; }
.pview { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.pview h3 { margin: 0 0 2px; }
.pview .badge { margin-top: 6px; }
.imgpick { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.imgpick .thumb { width: 84px; height: 84px; font-size: 36px; }

/* ── Lists ── */
.scard { padding: 12px 14px; margin-bottom: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh); cursor: pointer; }
.scard.dead { opacity: .62; }
.sc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sc-items { margin: 4px 0; font-size: 13.5px; }
.sc-tot { font-size: 16px; }
.sc-st { margin-top: 8px; }
.st-sel { min-height: 42px; font-weight: 800; }
.sumbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 10px 14px; margin-bottom: 10px; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; font-size: 14px; }
.lrow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 4px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: right; cursor: pointer; }
.lrow:last-child { border-bottom: 0; }
.lrow > div:not(.iq) { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.lrow small { color: var(--muted); font-size: 12px; }
.lrow .av { font-size: 26px; }
.iq { display: flex; flex-direction: column; align-items: center; min-width: 54px; padding: 4px 8px; border-radius: 12px; background: var(--soft); }
.iq b { font-size: 18px; line-height: 1.2; } .iq small { font-size: 10.5px; color: var(--muted); }
.iq.warn { background: var(--warns); color: var(--warn); } .iq.bad { background: var(--bads); color: var(--bad); }
.mrow { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.mrow:last-child { border-bottom: 0; }
.mrow > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mrow small { color: var(--muted); font-size: 12px; }
.mq { min-width: 50px; padding: 4px 6px; border-radius: 10px; background: var(--soft); text-align: center; font-weight: 800; }
.mq.ok { background: var(--oks); } .mq.bad { background: var(--bads); }
.mafter { min-width: 34px; color: var(--muted); font-weight: 800; text-align: center; }
.rank { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank:last-child { border-bottom: 0; }
.rank b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk { width: 28px; height: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--accs); color: var(--acc2); font-weight: 800; }
.ritem { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft); cursor: pointer; }
.ritem > span { display: flex; flex-direction: column; }
.ritem small { color: var(--muted); font-size: 12px; }
.ritem.off { opacity: .5; }
.logline { padding: 2px 0; color: var(--muted); font-size: 12.5px; }
.pb-add { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.pb-add select, .pb-add .btn { grid-column: 1 / -1; }
.mgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 700px) { .mgrid { grid-template-columns: repeat(3, 1fr); } }
.mtile { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--sh); color: var(--text); text-align: right; text-decoration: none; cursor: pointer; }
.mtile .ic { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; border-radius: 13px; background: var(--accs); font-size: 23px; }

/* ── Tables ── */
.tbl { overflow-x: auto; margin-bottom: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 800; }
tr.tot td { font-weight: 800; }

/* ── Charts ── */
.legend { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-left: 5px; border-radius: 3px; vertical-align: middle; }
.legend b { margin-right: auto; color: var(--text); font-size: 14px; }
i.st { background: var(--acc); } i.on { background: var(--blue); }
.chart { display: flex; align-items: stretch; gap: 3px; height: 176px; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.col:hover { background: var(--soft); }
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; height: 150px; border-bottom: 1px solid var(--line); }
.bars i { display: block; width: 36%; max-width: 14px; border-radius: 4px 4px 0 0; }
.cl { max-width: 100%; height: 16px; overflow: visible; white-space: nowrap; font-size: 10.5px; font-weight: 700; }
.split { display: flex; height: 14px; margin: 4px 0 12px; overflow: hidden; border-radius: 999px; background: var(--soft); }
.split i { display: block; height: 100%; }
.split.empty i { opacity: .25; }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cmp > div { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 14px; background: var(--soft); }
.cmp span { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.cmp b { font-size: 16px; } .cmp small { color: var(--muted); font-size: 11.5px; }

/* ── Modal (bottom sheet on phones) ── */
#modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: flex-end; justify-content: center; background: #0a0f1c99; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#modal.open { display: flex; }
.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); background: var(--card); border-radius: 24px 24px 0 0; animation: up .22s ease;
}
@media (min-width: 700px) { #modal { align-items: center; } .sheet { border-radius: 24px; max-height: 88vh; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { margin: 0 0 14px; font-size: 19px; }

/* ── Toasts ── */
#toasts { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 80; width: min(92vw, 460px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 1000px) { #toasts { bottom: 24px; } }
.toast { padding: 12px 18px; border-radius: 14px; background: #111827; color: #fff; font-weight: 700; font-size: 14.5px; text-align: center; box-shadow: 0 10px 30px #0005; animation: up .2s ease; transition: opacity .3s, transform .3s; }
.toast.ok { background: #15803d; } .toast.bad { background: #b91c1c; } .toast.warn { background: #b45309; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ── Save error bar ── */
#savebar { position: sticky; top: 0; z-index: 45; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: #b91c1c; color: #fff; font-weight: 700; font-size: 13.5px; }

/* ── Lock screen ── */
#lock { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; background: radial-gradient(circle at 50% 0, #9a3412, #0b1220 62%); }
.lockbox { width: min(360px, 100%); text-align: center; color: #fff; }
.lockbox h1 { margin: 12px 0 2px; font-size: 30px; letter-spacing: 4px; }
.lockbox p { margin: 0 0 18px; color: #cbd5e1; }
.lockbox.wide { width: min(420px, 100%); padding: 24px; background: var(--card); color: var(--text); border-radius: 24px; text-align: right; }
.lockbox.wide h1 { letter-spacing: 0; text-align: center; font-size: 24px; }
.lockbox.wide p { text-align: center; color: var(--muted); }
.lockbox .logo { border-radius: 20px; }
.dots { display: flex; justify-content: center; gap: 16px; margin: 6px 0 26px; }
.dots i { width: 16px; height: 16px; border: 2px solid #ffffff88; border-radius: 50%; transition: .15s; }
.dots i.on { background: var(--acc); border-color: var(--acc); transform: scale(1.1); }
.keypad { direction: ltr; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 300px; margin: 0 auto; }
.keypad button { height: 66px; border: 1px solid #ffffff22; border-radius: 20px; background: #ffffff10; color: #fff; font-size: 26px; font-weight: 700; cursor: pointer; }
.keypad button:active { background: var(--acc); }
.keypad .k-sm { font-size: 16px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* ── Receipt (always paper-white) ── */
.receipt { max-width: 420px; margin: 0 auto 12px; padding: 18px 16px; background: #fff; color: #111; border: 1px solid #e5e7eb; border-radius: 16px; font-size: 13.5px; }
.r-head { text-align: center; }
.r-head .logo { margin: 0 auto 6px; }
.r-head h2 { margin: 2px 0; font-size: 22px; letter-spacing: 2px; }
.r-head div { color: #555; font-size: 12.5px; }
.r-title { margin: 10px 0; padding: 6px; text-align: center; font-weight: 800; border-top: 2px dashed #ddd; border-bottom: 2px dashed #ddd; }
.r-void { margin-right: 6px; padding: 0 8px; color: #b91c1c; border: 2px solid #b91c1c; border-radius: 8px; }
.r-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 10px; }
.r-meta span { display: block; color: #666; font-size: 11.5px; }
.r-meta b { font-size: 13px; }
.r-cust { margin-bottom: 10px; padding: 8px 10px; border-radius: 10px; background: #f5f6f8; font-size: 12.5px; }
.receipt table { font-size: 12.5px; }
.receipt th { background: #f3f4f6; color: #555; }
.receipt th, .receipt td { padding: 6px 4px; border-bottom: 1px solid #eee; white-space: normal; }
.r-tot { margin-top: 8px; }
.r-tot > div { display: flex; justify-content: space-between; padding: 4px 0; }
.r-tot .grand { margin-top: 4px; padding-top: 8px; border-top: 2px solid #111; font-size: 17px; font-weight: 800; }
.r-rets, .r-notes { margin-top: 8px; color: #444; font-size: 12px; }
.r-foot { margin-top: 14px; padding-top: 10px; text-align: center; color: #555; font-weight: 700; border-top: 2px dashed #ddd; }
.pdf-host { position: fixed; top: 0; left: -10000px; width: 420px; direction: rtl; font-family: 'Cairo', Tahoma, Arial, sans-serif; }
.pdf-host .receipt { border: 0; border-radius: 0; margin: 0; }

/* ── Print: only the receipt ── */
#print-area { display: none; }
@media print {
  @page { margin: 8mm; }
  body { background: #fff !important; padding: 0 !important; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area .receipt { max-width: none; margin: 0; padding: 0; border: 0; }
}
