:root {
  --navy: #14213d; --navy-2: #1f3a68; --gold: #c9a227; --gold-2: #f3e3a3;
  --bg: #f3f4f7; --card: #fff; --line: #e4e7ee; --text: #1c2333; --muted: #6b7385;
  --green: #2e7d32; --green-bg: #e8f5e9; --red: #c62828; --red-bg: #fdecea; --orange: #e65100; --orange-bg: #fff3e0;
  --blue: #1f6f8b; --blue-bg: #e3f2f7;
  --radius: 16px; --shadow: 0 1px 2px rgba(20,33,61,.06), 0 8px 24px rgba(20,33,61,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Tajawal', Tahoma, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 15px; direction: rtl; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
code { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ---------- تسجيل الدخول ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-brand { background: radial-gradient(circle at 20% 20%, #2a4a85, var(--navy) 60%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-brand::after { content: ''; position: absolute; inset: auto -120px -120px auto; width: 420px; height: 420px; border-radius: 50%; border: 50px solid rgba(201,162,39,.18); }
.login-brand h1 { font-size: 40px; margin: 0 0 12px; line-height: 1.3; }
.login-brand p { color: #c8d1e6; font-size: 17px; line-height: 1.9; max-width: 460px; }
.feat { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 520px; position: relative; z-index: 1; }
.feat div { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.feat b { color: var(--gold); display: block; margin-bottom: 2px; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 28px; margin: 0 0 6px; }
.demo { margin-top: 22px; background: #fff; border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted); }
.demo button { border: 0; background: var(--bg); border-radius: 8px; padding: 4px 9px; margin: 3px 0 3px 4px; cursor: pointer; font-size: 12.5px; }
.demo button:hover { background: var(--gold-2); }

/* ---------- الهيكل ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #d7deee; padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; gap: 10px; align-items: center; padding: 6px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 8px; }
.logo-mark { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, var(--gold), #f6d76b); display: grid; place-items: center; color: var(--navy); font-weight: 800; font-size: 20px; flex: none; }
.logo b { color: #fff; display: block; font-size: 15px; line-height: 1.35; }
.logo small { color: #9fb0d0; font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; color: #c3cde3; font-weight: 500; transition: .15s; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: var(--gold); color: var(--navy); font-weight: 700; }
.nav .ico { width: 22px; text-align: center; font-size: 17px; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; }
.me { display: flex; gap: 10px; align-items: center; padding: 6px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--navy-2); display: grid; place-items: center; color: var(--gold); font-weight: 700; flex: none; }
.me b { color: #fff; font-size: 14px; display: block; }
.me small { font-size: 12px; color: #9fb0d0; }
.side-foot .row-btns { display: flex; gap: 6px; margin-top: 8px; }
.side-foot .row-btns button { flex: 1; background: rgba(255,255,255,.07); border: 0; color: #d7deee; padding: 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.side-foot .row-btns button:hover { background: rgba(255,255,255,.14); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 14px; padding: 16px 28px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.imp-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: linear-gradient(90deg, #6a3fa0, #3949ab); color: #fff; padding: 10px 28px; font-size: 14px; }
.imp-bar .btn { margin-inline-start: auto; }
.top h1 { font-size: 21px; margin: 0; flex: 1; }
.top .in { width: auto; }
.top .row { flex-wrap: nowrap; }
.content { padding: 24px 28px 60px; }

/* ---------- مكونات ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h3 { margin: 0 0 14px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.card h3 .grow { flex: 1; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mt { margin-top: 18px; }
.kpi { position: relative; overflow: hidden; }
.kpi small { color: var(--muted); font-size: 13.5px; }
.kpi .v { font-size: 26px; font-weight: 800; margin-top: 6px; }
.kpi .s { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi::before { content: ''; position: absolute; inset: 0 0 auto auto; width: 5px; height: 100%; background: var(--c, var(--gold)); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: #c7cddb; background: #fafbfc; }
.btn.pri { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.pri:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.btn.gold:hover { filter: brightness(1.05); }
.btn.red { background: var(--red); color: #fff; border-color: var(--red); }
.btn.green { background: var(--green); color: #fff; border-color: var(--green); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 14px 22px; font-size: 16px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.in, select.in, textarea.in { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; outline: none; transition: .15s; }
.in:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,.18); }
.in.big { font-size: 22px; font-weight: 700; padding: 12px 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.muted { color: var(--muted); }
.err { background: var(--red-bg); color: var(--red); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.ok-box { background: var(--green-bg); color: var(--green); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.tbl-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: right; font-weight: 600; color: var(--muted); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.t td { padding: 11px 12px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
.t tr:hover td { background: #fcfcfd; }
.t tfoot td { font-weight: 800; background: var(--navy); color: var(--gold); }
.t .thumb { width: 40px; height: 40px; border-radius: 9px; object-fit: cover; vertical-align: middle; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-orange { background: var(--orange-bg); color: var(--orange); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-grey { background: #eef0f4; color: var(--muted); }
.b-gold { background: var(--gold-2); color: #6b5410; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { border: 0; background: none; padding: 10px 16px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--navy); border-color: var(--gold); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 8px; }

/* ---------- نافذة منبثقة وتنبيه ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,22,40,.55); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .15s; backdrop-filter: blur(2px); }
.modal { background: #fff; border-radius: 20px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.3); animation: pop .18s; }
.modal.wide { max-width: 860px; }
.modal-h { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-h h2 { font-size: 18px; margin: 0; flex: 1; }
.modal-h .x { border: 0; background: var(--bg); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.modal-b { padding: 20px 22px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.toasts { position: fixed; bottom: 22px; left: 22px; z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); animation: pop .2s; font-weight: 500; max-width: 420px; }
.toast.bad { background: var(--red); }
.toast.good { background: var(--green); }

/* ---------- صورة بديلة ---------- */
.ph { display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 34px; background: linear-gradient(135deg, var(--c1, #1f3a68), var(--c2, #14213d)); }

/* ---------- نقطة البيع ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.cat-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; }
.chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; padding: 6px 12px 6px 6px; border-radius: 99px; cursor: pointer; white-space: nowrap; font-weight: 600; }
.chip img, .chip .ph { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; font-size: 13px; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.tile { background: #fff; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform .15s, box-shadow .15s; border: 2px solid transparent; position: relative; user-select: none; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(20,33,61,.14); border-color: var(--gold); }
.tile:active { transform: scale(.97); }
.tile .img { aspect-ratio: 1; width: 100%; object-fit: cover; display: block; }
.tile .cap { padding: 10px 12px 12px; }
.tile .cap b { display: block; font-size: 15px; line-height: 1.4; }
.tile .cap .price { color: var(--navy); font-weight: 800; font-size: 17px; margin-top: 4px; }
.tile .stk { position: absolute; top: 10px; left: 10px; background: rgba(255,255,255,.92); border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 700; }
.tile .stk.low { background: var(--red); color: #fff; }
.tile.cat .cap { text-align: center; font-size: 18px; }
.tile.cat .cnt { position: absolute; top: 10px; right: 10px; background: var(--gold); color: var(--navy); border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 800; }
.tile.out { opacity: .5; }
.crumb { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.crumb h2 { margin: 0; font-size: 20px; }

.ticket { position: sticky; top: 86px; display: flex; flex-direction: column; max-height: calc(100vh - 110px); padding: 0; overflow: hidden; }
.ticket-h { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; padding: 18px 20px; }
.ticket-h .lbl { color: #9fb0d0; font-size: 13px; }
.ticket-h .total { font-size: 34px; font-weight: 800; color: var(--gold); margin: 2px 0 10px; }
.ticket-h .mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 12.5px; }
.ticket-h .mini div { background: rgba(255,255,255,.08); border-radius: 10px; padding: 7px 9px; }
.ticket-h .mini b { display: block; font-size: 15px; color: #fff; }
.ticket-acts { display: flex; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ticket-acts .btn { flex: 1; }
.lines { overflow-y: auto; flex: 1; padding: 6px 10px 10px; }
.line { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px dashed var(--line); }
.line img, .line .ph { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; flex: none; font-size: 16px; }
.line .info { flex: 1; min-width: 0; }
.line .info b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line .info small { color: var(--muted); font-size: 12px; }
.line .amt { font-weight: 800; }
.line.void { opacity: .45; }
.line.void .amt, .line.void b { text-decoration: line-through; }
.line.new { animation: flash 1.2s; }
.line.wd .amt { color: var(--red); }
@keyframes flash { 0% { background: var(--gold-2); } 100% { background: transparent; } }
.x-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px; border-radius: 6px; }
.x-btn:hover { background: var(--red-bg); color: var(--red); }

.qty-modal .hero { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.qty-modal .hero img, .qty-modal .hero .ph { width: 110px; height: 110px; border-radius: 18px; object-fit: cover; flex: none; }
.qty-modal .hero h3 { margin: 0 0 6px; font-size: 20px; }
.stepper { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 8px 0 14px; }
.stepper button { width: 58px; height: 58px; border-radius: 16px; border: 0; background: var(--bg); font-size: 28px; font-weight: 700; cursor: pointer; }
.stepper button:hover { background: var(--gold-2); }
.stepper input { width: 120px; text-align: center; font-size: 32px; font-weight: 800; border: 2px solid var(--line); border-radius: 16px; padding: 8px; }
.quick { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 46px; height: 40px; cursor: pointer; font-weight: 700; }
.quick button:hover { border-color: var(--gold); }
.sum-box { background: var(--bg); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.sum-box .r { display: flex; justify-content: space-between; padding: 4px 0; }
.sum-box .r.tot { border-top: 1px dashed #cfd5e1; margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 800; }
.sum-box .r.bad { color: var(--red); font-weight: 700; }
.sum-box .r.good { color: var(--green); font-weight: 700; }

.no-shift { max-width: 520px; margin: 40px auto; text-align: center; }
.no-shift .big { font-size: 60px; }

/* ---------- الرسوم ---------- */
.bars .b { margin-bottom: 14px; }
.bars .b .lb { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.bars .track { background: var(--bg); border-radius: 99px; height: 14px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 99px; transition: width .6s; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-left: 5px; vertical-align: -1px; }
.chart svg { width: 100%; height: auto; display: block; }

.br-card { border-top: 5px solid var(--c); }
.cred { background: var(--gold-2); border-radius: 12px; padding: 12px; margin-top: 12px; font-size: 14px; }
.cred code { background: #fff; padding: 2px 8px; border-radius: 6px; direction: ltr; display: inline-block; }

.blocked { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 30px; }

@media (max-width: 1100px) {
  .pos { grid-template-columns: 1fr; }
  .ticket { position: static; max-height: none; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .login { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .content { padding: 16px; }
  .fields, .g2 { grid-template-columns: 1fr; }
}
