/* مؤونة الأصالة — هوية بألوان النصر: أزرق كحلي + أصفر ذهبي */
:root {
  --navy: #0B2A6F;
  --navy-2: #13398F;
  --blue: #1746A2;
  --gold: #FFD100;
  --gold-2: #F2B705;
  --ink: #0E1B3D;
  --muted: #6B7699;
  --bg: #F3F5FB;
  --card: #FFFFFF;
  --line: #E3E8F4;
  --ok: #12A150;
  --bad: #E0322F;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(11, 42, 111, .08);
  --bs-primary: #1746A2;
  --bs-primary-rgb: 23, 70, 162;
}
* { -webkit-tap-highlight-color: transparent; }
html, body { font-family: 'Tajawal', system-ui, sans-serif; background: var(--bg); color: var(--ink); }
body.app { display: flex; min-height: 100vh; }
a { color: var(--blue); }
.num, .money { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ---------- الشريط الجانبي ---------- */
.sidebar {
  width: 260px; flex-shrink: 0; background: linear-gradient(180deg, var(--navy) 0%, #08215A 100%);
  color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; text-decoration: none; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand img { width: 46px; height: 46px; }
.sidebar .brand b { display: block; font-size: 1.1rem; font-weight: 800; color: var(--gold); }
.sidebar .brand small { color: rgba(255,255,255,.65); font-size: .75rem; }
.sidebar nav { padding: 10px 10px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin: 2px 0; border-radius: 12px; color: rgba(255,255,255,.82); text-decoration: none; font-weight: 500; transition: .15s; }
.sidebar nav a i { font-size: 1.15rem; width: 22px; text-align: center; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: var(--gold); color: var(--navy); font-weight: 800; box-shadow: 0 4px 14px rgba(255,209,0,.3); }
.nav-sec { font-size: .72rem; color: rgba(255,255,255,.4); padding: 14px 14px 4px; font-weight: 700; letter-spacing: .5px; }
.side-foot { padding: 12px 16px 18px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 6px; }
.side-foot a { color: rgba(255,255,255,.85); text-decoration: none; font-size: .9rem; }
.side-foot small { color: rgba(255,255,255,.5); }
.side-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: #fff; border-bottom: 3px solid var(--gold); position: sticky; top: 0; z-index: 1020; }
.topbar h1 { font-size: 1.3rem; font-weight: 800; margin: 0; color: var(--navy); }
.content { padding: 22px 24px 40px; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; right: -280px; transition: right .25s; }
  body.side-open .sidebar { right: 0; }
  body.side-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1030; }
  .content { padding: 16px 16px 40px; }
  .topbar { padding: 10px 16px; }
  .topbar h1 { font-size: 1.1rem; }
}

/* ---------- أزرار ---------- */
.btn { border-radius: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-gold { background: var(--gold); color: var(--navy); border: none; }
.btn-gold:hover, .btn-gold:focus { background: var(--gold-2); color: var(--navy); }
.btn-navy { background: var(--navy); color: #fff; border: none; }
.btn-navy:hover, .btn-navy:focus { background: var(--navy-2); color: #fff; }
.btn-primary { background: var(--blue); border-color: var(--blue); }
.btn-icon { width: 42px; height: 42px; padding: 0; border-radius: 12px; background: var(--bg); color: var(--navy); font-size: 1.25rem; border: none; }
.btn-icon:hover { background: #E6EBF7; }
.badge-dot { position: absolute; top: -4px; left: -4px; background: var(--bad); color: #fff; font-size: .7rem; min-width: 20px; height: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }

/* ---------- البطاقات ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 800; color: var(--navy); padding: 14px 18px; }
.kpi { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); position: relative; overflow: hidden; height: 100%; }
.kpi .lbl { color: var(--muted); font-size: .88rem; font-weight: 600; }
.kpi .val { font-size: 1.7rem; font-weight: 900; color: var(--navy); margin-top: 4px; line-height: 1.2; }
.kpi .val small { font-size: .85rem; color: var(--muted); font-weight: 600; }
.kpi .ico { position: absolute; left: 14px; top: 14px; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; background: #EEF2FC; color: var(--blue); }
.kpi.gold { background: linear-gradient(135deg, var(--gold) 0%, #FFE45C 100%); border: none; }
.kpi.gold .lbl { color: rgba(11,42,111,.7); }
.kpi.gold .ico { background: rgba(11,42,111,.12); color: var(--navy); }
.kpi.navy { background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%); border: none; }
.kpi.navy .lbl, .kpi.navy .val small { color: rgba(255,255,255,.7); }
.kpi.navy .val { color: #fff; }
.kpi.navy .ico { background: rgba(255,209,0,.18); color: var(--gold); }
.kpi .sub { font-size: .8rem; margin-top: 4px; color: var(--muted); }
.kpi .lbl { padding-left: 50px; }
@media (max-width: 575.98px) {
  .kpi { padding: 14px; }
  .kpi .ico { display: none; }
  .kpi .lbl { padding-left: 0; font-size: .8rem; }
  .kpi .val { font-size: 1.25rem; }
  .kpi .val small { font-size: .7rem; }
}

.table { --bs-table-bg: transparent; margin: 0; }
.table thead th { background: #F5F7FC; color: var(--muted); font-weight: 700; font-size: .85rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { vertical-align: middle; }
.table-wrap { overflow-x: auto; }
.form-control, .form-select { border-radius: 12px; border-color: var(--line); padding: .55rem .85rem; }
.form-control:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 .2rem rgba(23,70,162,.15); }
.form-label { font-weight: 700; font-size: .9rem; color: var(--navy); }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state i { font-size: 3rem; color: #C5CEE6; display: block; margin-bottom: 8px; }
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: #EEF2FC; display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 16px; }
.filter-bar .form-control, .filter-bar .form-select { width: auto; }
.alert-feed .item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.alert-feed .item:last-child { border: none; }
.alert-feed .dot { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.lvl-info .dot { background: #E7EEFD; color: var(--blue); }
.lvl-success .dot { background: #E3F6EB; color: var(--ok); }
.lvl-warning .dot { background: #FFF5D1; color: #A77800; }
.lvl-danger .dot { background: #FDE6E5; color: var(--bad); }
.alert-feed .unread { background: #FFFCEB; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; background: #EEF2FC; color: var(--navy); }

/* ---------- نموذج المقاسات ---------- */
.vbox { background: #fff; border: 2px solid var(--line); border-radius: 20px; padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); border-top: 5px solid var(--navy); }
.vbox.is-off { opacity: .6; }
.vbox-head { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.vsec { border-radius: 16px; padding: 14px; height: 100%; }
.sec-unit { background: #EEF3FE; border: 1px solid #D7E2FA; }
.sec-pack { background: #FFF8D9; border: 1px solid #F6E29A; }
.sec-stock { background: #F5F7FB; border: 1px solid var(--line); }
.vsec-t { display: flex; align-items: center; gap: 10px; font-weight: 900; color: var(--navy); margin-bottom: 10px; font-size: 1.05rem; }
.vsec-t small { display: block; font-weight: 500; font-size: .78rem; color: var(--muted); }
.vsec-t .ico { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; background: #fff; flex-shrink: 0; }
.sec-unit .ico { color: var(--blue); } .sec-pack .ico { color: #A77800; } .sec-stock .ico { color: var(--navy); }
.vsec .form-label { font-size: .85rem; margin-bottom: 4px; }
.vsec .input-group-text { background: #fff; font-size: .85rem; }
.sec-pack .pack-off { display: none; }
.sec-pack.pack-disabled .pack-fields { display: none !important; }
.sec-pack.pack-disabled .pack-off { display: block; }
.vsum { margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: #F3F5FB; font-size: .92rem; font-weight: 600; color: var(--navy); }
.vchip { display: inline-block; padding: 3px 12px; border-radius: 10px; margin: 0 2px; color: #fff; background: var(--navy); }
.vchip.p { background: var(--gold); color: var(--navy); }
.sizes-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #fff; border: 2px solid var(--gold); border-radius: 18px; padding: 14px 18px; position: sticky; top: 70px; z-index: 6; box-shadow: var(--shadow); }
.sizes-bar .add-var { padding: 12px 26px; font-size: 1.15rem; }
@media (max-width: 575.98px) { .sizes-bar { top: 60px; } .sizes-bar .add-var { width: 100%; } }
.ps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.ps-item { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 6px 10px; cursor: pointer; font-weight: 600; user-select: none; }
.ps-item:has(input:checked) { border-color: var(--blue); background: #E9F0FF; }
.ps-item img, .ps-item .em { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; background: #F1F4FB; flex-shrink: 0; }
.save-bar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 35%); padding: 18px 0 8px; z-index: 5; }

/* ---------- الدخول ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 20% 10%, #1A4DB3 0, transparent 45%), linear-gradient(160deg, var(--navy), #061A47); }
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 24px; padding: 34px 30px; box-shadow: 0 30px 70px rgba(0,0,0,.35); border-top: 6px solid var(--gold); }
.login-card img { width: 84px; display: block; margin: 0 auto 10px; }
.login-card h2 { text-align: center; color: var(--navy); font-weight: 900; margin: 0; }
.login-card p.sub { text-align: center; color: var(--muted); margin-bottom: 24px; }

/* ---------- الكاشير ---------- */
body.pos { height: 100vh; overflow: hidden; display: flex; flex-direction: column; background: #E9EDF7; }
.pos-top { display: flex; align-items: center; gap: 10px; background: var(--navy); color: #fff; padding: 8px 14px; border-bottom: 4px solid var(--gold); }
.pos-top .brand { display: flex; align-items: center; gap: 8px; color: var(--gold); font-weight: 900; text-decoration: none; font-size: 1.1rem; }
.pos-top .brand img { width: 36px; }
.pos-top .info { font-size: .85rem; color: rgba(255,255,255,.75); }
.pos-top .btn-top { background: rgba(255,255,255,.1); color: #fff; border: none; padding: 7px 12px; border-radius: 10px; font-weight: 700; }
.pos-top .btn-top:hover { background: rgba(255,255,255,.2); }
.pos-body { flex: 1; display: flex; min-height: 0; }
.pos-left { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 12px; gap: 10px; }
.pos-search { display: flex; gap: 8px; }
.pos-search input { font-size: 1.15rem; padding: 12px 16px; border-radius: 14px; border: 2px solid var(--line); }
.cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; flex-shrink: 0; }
.cats button { flex-shrink: 0; border: none; background: #fff; border-radius: 14px; padding: 10px 18px; font-weight: 800; font-size: 1.05rem; color: var(--navy); box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; }
.cats button .em { font-size: 1.5rem; }
.cats button.active { background: var(--navy); color: var(--gold); }
.grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start; padding: 2px; }
.pcard { background: #fff; border-radius: 18px; overflow: hidden; cursor: pointer; border: 3px solid transparent; box-shadow: var(--shadow); transition: transform .08s, border-color .1s; user-select: none; display: flex; flex-direction: column; position: relative; }
.pcard:active { transform: scale(.96); }
.pcard:hover { border-color: var(--gold); }
.pcard .img { aspect-ratio: 1/1; background: #F1F4FB center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 4rem; }
.pcard .nm { padding: 8px 10px 2px; font-weight: 800; font-size: 1.05rem; line-height: 1.3; color: var(--navy); }
.pcard .alt { padding: 0 10px; font-size: .82rem; color: var(--muted); direction: ltr; text-align: right; }
.pcard .pr { padding: 4px 10px 10px; font-weight: 900; color: var(--blue); font-size: 1.05rem; margin-top: auto; }
.pcard .stk { position: absolute; top: 8px; left: 8px; background: rgba(11,42,111,.85); color: #fff; font-size: .75rem; padding: 2px 8px; border-radius: 10px; font-weight: 700; }
.pcard .stk.low { background: var(--bad); }
.pcard .multi { position: absolute; top: 8px; right: 8px; background: var(--gold); color: var(--navy); font-size: .75rem; padding: 2px 8px; border-radius: 10px; font-weight: 800; }

.pos-cart { width: 420px; flex-shrink: 0; background: #fff; display: flex; flex-direction: column; border-right: 1px solid var(--line); box-shadow: -6px 0 24px rgba(11,42,111,.06); }
.cart-head { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); font-weight: 900; color: var(--navy); }
.cart-items { flex: 1; overflow-y: auto; }
.citem { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px dashed var(--line); }
.citem .ci-img { width: 52px; height: 52px; border-radius: 12px; background: #F1F4FB center/cover; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; }
.citem .ci-main { flex: 1; min-width: 0; }
.citem .ci-nm { font-weight: 800; color: var(--navy); line-height: 1.25; }
.citem .ci-u { font-size: .8rem; color: var(--muted); }
.citem .ci-u b { color: #fff; background: var(--blue); padding: 1px 8px; border-radius: 8px; font-size: .75rem; }
.citem .ci-u b.pack { background: var(--gold); color: var(--navy); }
.qtybox { display: flex; align-items: center; gap: 4px; }
.qtybox button { width: 38px; height: 38px; border-radius: 10px; border: none; background: #EEF2FC; color: var(--navy); font-size: 1.3rem; font-weight: 900; }
.qtybox button:active { background: var(--gold); }
.qtybox .q { min-width: 44px; text-align: center; font-weight: 900; font-size: 1.15rem; cursor: pointer; }
.citem .ci-tot { font-weight: 900; min-width: 70px; text-align: left; color: var(--ink); }
.cart-sum { padding: 12px 16px; border-top: 2px solid var(--line); background: #FAFBFE; }
.cart-sum .r { display: flex; justify-content: space-between; padding: 2px 0; color: var(--muted); font-weight: 600; }
.cart-sum .total { font-size: 2rem; font-weight: 900; color: var(--navy); display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.pay-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px 14px; background: #FAFBFE; }
.pay-btns .btn { padding: 9px 6px; font-size: 1.1rem; gap: 8px; line-height: 1.1; border-radius: 14px; }
.pay-btns .btn small { font-size: .72rem; font-weight: 600; opacity: .8; }
.pay-btns .btn i { font-size: 1.35rem; }
.pay-btns .btn[data-pay="cash"] { padding: 14px 6px; font-size: 1.35rem; }
.pay-big { grid-column: 1 / -1; }
.cart-empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.cart-empty i { font-size: 4rem; color: #D5DCEE; }

.vopt { display: grid; grid-template-columns: 1fr; gap: 10px; }
.vrow { border: 2px solid var(--line); border-radius: 16px; padding: 10px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vrow .vl { flex: 1; min-width: 120px; font-weight: 900; font-size: 1.25rem; color: var(--navy); }
.vrow .vl small { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.vrow .btn { padding: 12px 16px; font-size: 1.05rem; min-width: 130px; flex-direction: column; gap: 0; line-height: 1.2; }
.vrow .btn small { font-weight: 600; font-size: .78rem; opacity: .85; }
.change-big { font-size: 2.6rem; font-weight: 900; color: var(--ok); }
.quick-cash { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick-cash .btn { padding: 14px; font-size: 1.2rem; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.numpad button { padding: 16px; font-size: 1.5rem; font-weight: 900; border-radius: 14px; border: none; background: #EEF2FC; color: var(--navy); }
.numpad button:active { background: var(--gold); }
.pos-toast { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); background: var(--ok); color: #fff; padding: 14px 28px; border-radius: 16px; font-weight: 900; font-size: 1.2rem; z-index: 3000; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: none; }
.pos-toast.err { background: var(--bad); }
.modal-content { border-radius: 22px; border: none; }
.modal-header { border-bottom: 3px solid var(--gold); }
.modal-title { font-weight: 900; color: var(--navy); }

@media (max-width: 991.98px) {
  body.pos { overflow: auto; height: auto; }
  .pos-body { flex-direction: column; }
  .pos-cart { width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); max-height: 60vh; }
}

/* ---------- المالك ---------- */
.live-dot { width: 10px; height: 10px; background: var(--ok); border-radius: 50%; display: inline-block; box-shadow: 0 0 0 0 rgba(18,161,80,.6); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(18,161,80,0); } 100% { box-shadow: 0 0 0 0 rgba(18,161,80,0); } }
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.cam { background: #000; border-radius: 16px; overflow: hidden; position: relative; aspect-ratio: 16/9; }
.cam video, .cam img, .cam iframe { width: 100%; height: 100%; object-fit: contain; border: 0; display: block; }
.cam .cam-name { position: absolute; top: 10px; right: 10px; background: rgba(11,42,111,.85); color: var(--gold); padding: 3px 10px; border-radius: 10px; font-weight: 800; font-size: .85rem; z-index: 2; }
.cam .cam-full { position: absolute; bottom: 10px; left: 10px; z-index: 2; }

@media print {
  .sidebar, .topbar, .no-print, .filter-bar { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body.app { display: block; background: #fff; }
}
