:root {
  --primary: #0891b2;
  --primary-dark: #0e7490;
  --cta: #059669;
  --cta-dark: #047857;
  --danger: #dc2626;
  --warn: #d97706;
  --bg: #ecfeff;
  --card: #ffffff;
  --text: #164e63;
  --muted: #5b7a86;
  --line: #cfe8ee;
  --radius: 14px;
  font-family: "Noto Sans Arabic", Tahoma, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: 18px; line-height: 1.5; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.3; }
h2 { font-size: 22px; }
h3 { font-size: 19px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 15px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: embed; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; background: var(--primary); color: #fff;
}
.topbar .title { font-weight: 700; flex: 1; }
.topbar select { color: var(--text); background: #fff; }
.topbar button { background: transparent; border: 1px solid rgba(255,255,255,.6); color: #fff; border-radius: 10px; padding: 6px 12px; }
.badge { background: var(--warn); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 14px; }
main { max-width: 900px; margin: 0 auto; padding: 18px 16px 110px; }
.tabs {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  border: 0; background: none; padding: 14px 4px; font-weight: 600; color: var(--muted);
  border-top: 4px solid transparent; transition: color .2s, border-color .2s;
}
.tabs button.active { color: var(--primary-dark); border-top-color: var(--primary); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 140px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .label { color: var(--muted); font-size: 15px; }
.stat .value { font-size: 26px; font-weight: 700; }
.stat.big .value { font-size: 40px; color: var(--cta-dark); }

/* controls */
label { display: block; font-weight: 600; margin: 10px 0 6px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; min-height: 52px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
textarea { min-height: 80px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 12px 20px;
  border-radius: 12px; border: 0; background: var(--primary); color: #fff; font-weight: 700; transition: background .2s;
}
.btn:hover { background: var(--primary-dark); }
.btn.cta { background: var(--cta); width: 100%; font-size: 20px; }
.btn.cta:hover { background: var(--cta-dark); }
.btn.ghost { background: #fff; color: var(--primary-dark); border: 1.5px solid var(--primary); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg button {
  min-height: 56px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 700;
  transition: background .2s, border-color .2s;
}
.seg button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 52px; padding: 8px 16px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; }
.chips button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 52px; height: 52px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-size: 26px; font-weight: 700; }
.stepper input { width: 80px; text-align: center; min-height: 52px; }

/* lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; text-align: start; width: 100%;
}
button.item:hover { border-color: var(--primary); }
.item .sub { color: var(--muted); font-size: 14px; }
.tag { border-radius: 8px; padding: 2px 8px; font-size: 14px; font-weight: 600; background: #e0f2fe; color: var(--primary-dark); white-space: nowrap; }
.tag.warn { background: #fef3c7; color: #92400e; }
.tag.bad { background: #fee2e2; color: #991b1b; }
.tag.ok { background: #d1fae5; color: #065f46; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

.product { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fff; }
.product .head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-weight: 700; }
.product .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.product .fields label { margin: 0 0 4px; font-size: 15px; }
.totals { font-size: 20px; }
.totals .grand { font-size: 28px; font-weight: 800; color: var(--cta-dark); }

.toast {
  position: fixed; bottom: 90px; inset-inline: 16px; z-index: 20; margin: 0 auto; max-width: 600px; padding: 14px 18px;
  border-radius: 12px; background: var(--text); color: #fff; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.err { background: var(--danger); }
.result { text-align: center; padding: 24px 16px; }
.result .big { font-size: 32px; font-weight: 800; color: var(--cta-dark); }

/* login */
.login { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; direction: ltr; }
.keypad button { min-height: 68px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; font-size: 28px; font-weight: 700; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 16px 0; direction: ltr; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--primary); }
.pin-dots span.on { background: var(--primary); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
