/* نظام المطاعم والمخزون — Edifice Vision */
:root {
  --p: #5b2a86; --p2: #7a44ab; --t: #13a89e; --t2: #0e8a82;
  --bg: #f4f2f9; --card: #fff; --ink: #1f1a2b; --mut: #7a7490; --line: #e6e2ef;
  --ok: #1d9b5e; --warn: #e59a12; --err: #d23c4a; --r: 14px;
  --sh: 0 2px 10px rgba(60, 30, 100, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Tajawal, "Segoe UI", Tahoma, sans-serif; background: var(--bg); color: var(--ink); font-size: 17px; line-height: 1.55; display: flex; min-height: 100vh; }
a { color: var(--p); }
h1, h2, h3 { margin: 0 0 14px; line-height: 1.35; } h2 { font-size: 24px; }
.card h3 { font-size: 21px; font-weight: 800; color: var(--p); padding-inline-start: 12px; border-inline-start: 5px solid var(--t); }
h3 { font-size: 21px; font-weight: 800; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink); font-size: 17px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--t) 40%, transparent); border-color: var(--t); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 15.5px; font-weight: 500; color: #5e5873; flex: 1; min-width: 0; }
label small { font-size: 13.5px; color: var(--mut); font-weight: 400; }
label.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); flex: 0 0 auto; }
label.chk input { width: 20px; height: 20px; accent-color: var(--t); }
fieldset { border: 1.5px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
legend { font-weight: 800; color: var(--p); padding: 0 8px; font-size: 18px; }

/* الشريط الجانبي */
.side { width: 265px; background: linear-gradient(180deg, var(--p), #3e1b60); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; gap: 12px; align-items: center; padding: 22px 18px; border-bottom: 1px solid #ffffff22; }
.brand img { width: 52px; height: 52px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.brand b { display: block; font-size: 20px; font-weight: 800; } .brand small { opacity: .8; font-size: 13.5px; }
.side nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.side nav a { display: flex; gap: 12px; align-items: center; color: #fff; text-decoration: none; padding: 12px 14px; border-radius: 12px; margin-bottom: 3px; opacity: .9; font-size: 17.5px; font-weight: 500; }
.side nav a:hover { background: #ffffff18; opacity: 1; }
.side nav a.on { background: var(--t); opacity: 1; font-weight: 700; }
.side nav span { width: 26px; text-align: center; font-size: 19px; }
.me { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid #ffffff22; }
.me b { font-size: 16.5px; } .me small { display: block; opacity: .75; font-size: 13.5px; }
.me .btn.ghost { color: #fff; border-color: #ffffff55; }
.by { font-size: 12.5px; opacity: .55; text-align: center; padding: 0 0 10px; }

.main { flex: 1; padding: 24px 30px 48px; min-width: 0; }
.main.solo { display: flex; align-items: center; justify-content: center; flex-direction: column; }
.top { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; padding-bottom: 14px; border-bottom: 2px solid var(--line); }
.top h1 { font-size: 30px; font-weight: 800; color: var(--p); margin: 0; flex: 1; }
.menu-btn { display: none; border: 0; background: var(--p); color: #fff; border-radius: 10px; padding: 6px 12px; font-size: 18px; }
.trial { background: #fff4dc; color: #8a5a00; padding: 8px 16px; border-radius: 22px; text-decoration: none; font-size: 15px; font-weight: 700; }

/* عناصر */
.card { background: var(--card); border-radius: 18px; padding: 24px; box-shadow: 0 4px 18px rgba(60, 30, 100, .07); margin-bottom: 22px; border: 1px solid var(--line); }
.card.narrow { max-width: 620px; margin-inline: auto; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.grid2.wide-first { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); }
.grid2 .full { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; } .row.gap { gap: 12px; } .wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; gap: 10px; } .row.end { justify-content: flex-end; }
.row input[type=search] { max-width: 260px; }
.inline { display: inline; }
.muted { color: var(--mut); } .center { text-align: center; } .nowrap { white-space: nowrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid transparent; padding: 11px 20px; border-radius: 12px; font-size: 16.5px; cursor: pointer; text-decoration: none; font-weight: 700; background: #ece8f4; color: var(--ink); white-space: nowrap; }
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--t); color: #fff; } .btn.primary:hover { background: var(--t2); }
.btn.warn { background: var(--warn); color: #fff; } .btn.danger { background: #fbe5e7; color: var(--err); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--p); }
.btn.wa { background: #25d366; color: #fff; }
.btn.sm { padding: 7px 13px; font-size: 15px; border-radius: 10px; }
.btn.big { padding: 15px 28px; font-size: 19px; }
.btn:disabled { opacity: .5; cursor: wait; }
.alert { padding: 15px 20px; border-radius: 12px; margin-bottom: 18px; font-weight: 600; font-size: 17px; }
.alert.ok { background: #e2f6ec; color: #11683f; } .alert.err { background: #fde8ea; color: #a2202d; } .alert.warn { background: #fff4dc; color: #8a5a00; }
.badge { background: var(--err); color: #fff; border-radius: 20px; padding: 1px 9px; font-size: 14px; }
.tag { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 14px; font-weight: 700; background: #eee; }
.tag.paid, .tag.z-reported, .tag.z-cleared { background: #e2f6ec; color: #11683f; } .tag.z-pending, .tag.z-signed { background: #fff4dc; color: #8a5a00; } .tag.z-rejected, .tag.z-error { background: #fde8ea; color: #a2202d; } .tag.open { background: #fff4dc; color: #8a5a00; } .tag.cancelled { background: #fde8ea; color: #a2202d; }
.tag.mv-purchase, .tag.mv-opening { background: #e2f6ec; color: #11683f; } .tag.mv-sale { background: #e9e3f5; color: var(--p); }
.tag.mv-waste, .tag.mv-purchase_del { background: #fde8ea; color: #a2202d; } .tag.mv-adjust { background: #e3f1fb; color: #1b5f8f; } .tag.mv-cancel { background: #fff4dc; color: #8a5a00; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; } .thumb.sm { width: 48px; height: 48px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 16.5px; }
.tbl th { text-align: right; color: var(--p); background: #f4f0fa; font-weight: 700; font-size: 15.5px; padding: 12px 12px; border-bottom: 2px solid #e2daf0; white-space: nowrap; }
.tbl tr:first-child th:first-child { border-start-start-radius: 10px; } .tbl tr:first-child th:last-child { border-start-end-radius: 10px; }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: #faf9fd; }
.tbl tr.b td { font-weight: 800; background: #f6f3fb; }
.tbl tr.warn td { background: #fffaf0; } .tbl tr.neg td { background: #fff3f4; }
.tbl tr.strike td { text-decoration: line-through; }
.tbl select, .tbl input { padding: 8px 10px; font-size: 16px; }
.neg-t { color: var(--err); font-weight: 700; } .pos-t { color: var(--ok); font-weight: 700; }
.card:has(> .tbl) { overflow-x: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 18px; margin-bottom: 22px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 18px 22px; box-shadow: 0 4px 18px rgba(60, 30, 100, .07); border-top: 5px solid var(--t); }
.kpi:nth-child(2n) { border-top-color: var(--p2); }
.kpi small { display: block; color: #5e5873; font-size: 16px; font-weight: 600; margin-bottom: 4px; } .kpi b { font-size: 32px; font-weight: 800; color: var(--ink); } .kpi span { color: var(--mut); font-size: 15px; margin-inline-start: 6px; }
.kpis.sm .kpi b { font-size: 26px; } .kpi.alertk { border-top-color: var(--err); }
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filters label { flex: 0 1 200px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs a { padding: 11px 20px; border-radius: 12px; font-size: 16.5px; font-weight: 600; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.tabs a.on { background: var(--p); color: #fff; border-color: var(--p); }

.bars { display: flex; gap: 10px; height: 230px; align-items: flex-end; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 4px; }
.bar span { width: 70%; background: linear-gradient(180deg, var(--t), var(--p2)); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar em { font-size: 13px; font-style: normal; color: var(--mut); } .bar small { font-size: 14.5px; font-weight: 600; }

/* الدخول والتثبيت */
.auth { background: #fff; padding: 40px 38px; border-radius: 24px; box-shadow: 0 14px 50px rgba(60, 30, 100, .14); width: 100%; max-width: 470px; border-top: 6px solid var(--t); }
.auth.wide { max-width: 900px; }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head img { max-height: 90px; } .auth-head h1 { color: var(--p); font-size: 32px; font-weight: 800; margin: 8px 0; } .auth-head p { color: var(--t); margin: 0; font-weight: 700; font-size: 18px; }
.auth form.grid2 { gap: 16px; }

/* التفعيل */
.lic-state { padding: 18px; border-radius: 14px; font-weight: 800; font-size: 19px; margin-bottom: 20px; text-align: center; }
.lic-state.active { background: #e2f6ec; color: #11683f; } .lic-state.trial { background: #fff4dc; color: #8a5a00; } .lic-state.expired { background: #fde8ea; color: #a2202d; }
.req-code { font-size: 40px; font-weight: 800; letter-spacing: 3px; direction: ltr; text-align: center; background: #f4f2f9; border: 2px dashed var(--p2); border-radius: 12px; padding: 12px; color: var(--p); margin-bottom: 8px; }

/* نافذة */
.dlg { border: 0; border-radius: 22px; padding: 28px; width: min(560px, 94vw); font-size: 17px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.dlg::backdrop { background: rgba(30, 15, 50, .45); }
.dlg .stack, .dlg > div, .dlg > label { margin-bottom: 12px; }

/* ===== الكاشير ===== */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 20px; height: calc(100vh - 120px); }
.pos-menu, .pos-cart { background: #fff; border-radius: var(--r); border: 1px solid var(--line); box-shadow: var(--sh); display: flex; flex-direction: column; min-height: 0; }
.pos-menu { padding: 18px; }
.pos-tools { display: flex; gap: 10px; margin-bottom: 10px; }
.cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; flex-shrink: 0; }
.cats button { border: 1.5px solid var(--line); background: #faf9fd; padding: 11px 22px; border-radius: 24px; font-size: 17px; cursor: pointer; white-space: nowrap; font-weight: 700; }
.cats button.on { background: var(--p); color: #fff; border-color: var(--p); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; overflow-y: auto; padding: 4px 2px; align-content: start; }
.item { border: 1.5px solid var(--line); background: #fff; border-radius: 16px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; transition: .12s; }
.item:hover { border-color: var(--t); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(19, 168, 158, .15); }
.item:active { transform: scale(.97); }
.item img, .item .ph { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; }
.item .ph { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #efe9f7, #dff5f3); font-size: 40px; font-weight: 800; color: var(--p2); }
.item b { font-size: 17px; line-height: 1.35; } .item em { font-style: normal; color: var(--t2); font-weight: 800; font-size: 19px; }
.cart-head { padding: 12px; border-bottom: 1px solid var(--line); }
.seg { display: flex; background: #f1eef7; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 12px; border-radius: 10px; font-size: 17px; cursor: pointer; font-weight: 700; color: var(--mut); }
.seg button.on { background: #fff; color: var(--p); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.editing { margin-top: 10px; background: #fff4dc; color: #8a5a00; padding: 8px 12px; border-radius: 10px; font-size: 15px; }
.cart-meta { display: flex; gap: 6px; padding: 10px 12px; flex-wrap: wrap; }
.cart-meta > * { flex: 1 1 30%; padding: 9px 11px; font-size: 16px; }
.cart-lines { flex: 1; overflow-y: auto; padding: 0 12px; min-height: 80px; }
.line { display: grid; grid-template-columns: 1fr auto 74px auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.ln-name b { font-size: 17px; display: block; } .ln-name small { color: var(--warn); font-size: 14px; }
.ln-qty { display: flex; align-items: center; gap: 6px; }
.ln-qty button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #faf9fd; cursor: pointer; font-size: 17px; font-weight: 800; }
.ln-qty span { min-width: 24px; text-align: center; font-weight: 800; font-size: 18px; }
.ln-tot { text-align: left; font-weight: 800; font-size: 17px; }
.ln-x button { border: 0; background: transparent; cursor: pointer; font-size: 17px; padding: 2px; opacity: .7; }
.cart-sum { padding: 14px 18px; border-top: 1px solid var(--line); background: #fbfafd; }
.disc { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.disc label { flex: 0 0 auto; white-space: nowrap; color: var(--ink); } .disc input { width: 100px; padding: 7px 10px; } .disc select { width: 80px; padding: 7px; }
.sumrow { display: flex; justify-content: space-between; padding: 3px 0; font-size: 16.5px; color: #5e5873; }
.sumrow b { color: var(--ink); }
.sumrow.total { font-size: 28px; color: var(--p); font-weight: 800; border-top: 1px solid var(--line); margin-top: 5px; padding-top: 7px; }
.sumrow.total b { color: var(--p); }
.cart-actions { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; padding: 14px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.change { font-size: 21px; } .change b { color: var(--ok); font-size: 30px; }

.print-only { display: none; }
@media print {
  .side, .top, .filters, .tabs, .btn, form.inline { display: none !important; }
  body { background: #fff; display: block; } .main { padding: 0; } .card { box-shadow: none; border: 0; }
  .print-only { display: block; } .grid2 { display: block; }
}
@media (max-width: 1000px) {
  .grid2, .grid2.wide-first { grid-template-columns: 1fr; }
  .pos { grid-template-columns: 1fr; height: auto; } .items { max-height: 55vh; } .cart-lines { max-height: 40vh; }
}
@media (max-width: 760px) {
  .side { position: fixed; inset-inline-start: 0; z-index: 50; transform: translateX(100%); transition: .2s; }
  .side.open { transform: none; }
  .menu-btn { display: block; } .main { padding: 12px; }
}

/* ===== تخطيط مضغوط للشاشات الكبيرة (مثل النسخة المكتبية) — الجوال يبقى كما هو ===== */
@media (min-width: 761px) {
  body { font-size: 14.5px; line-height: 1.5; }
  h1 { font-size: 22px; } h2 { font-size: 19px; } h1, h2, h3 { margin-bottom: 10px; }
  .card h3 { font-size: 16.5px; padding-inline-start: 10px; border-inline-start-width: 4px; }
  input, select, textarea { padding: 7px 10px; font-size: 14.5px; border-radius: 9px; border-width: 1px; }
  label { font-size: 13.5px; gap: 4px; } label small { font-size: 12px; }
  label.chk input { width: 16px; height: 16px; }
  .side { width: 232px; }
  .side nav { padding: 8px; }
  .side nav a { padding: 8px 12px; font-size: 15px; border-radius: 9px; margin-bottom: 2px; gap: 10px; }
  .side nav span { width: 22px; font-size: 16px; }
  .main { padding: 16px 22px 40px; }
  .card { padding: 16px; border-radius: 12px; margin-bottom: 14px; box-shadow: none; }
  .grid2 { gap: 14px; } .grid2.wide-first { grid-template-columns: minmax(0, 2.4fr) minmax(280px, 1fr); }
  .stack { gap: 10px; }
  .btn { padding: 7px 14px; font-size: 14px; border-radius: 9px; border-width: 1px; gap: 6px; }
  .btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
  .btn.big { padding: 10px 22px; font-size: 16px; }
  .tbl { font-size: 14px; } .tbl th { font-size: 13px; padding: 8px 10px; border-bottom-width: 1px; } .tbl td { padding: 7px 10px; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin-bottom: 14px; }
  .kpi { padding: 12px 16px; border-radius: 12px; box-shadow: none; border-top-width: 4px; }
  .kpi small { font-size: 13px; margin-bottom: 2px; } .kpi b { font-size: 24px; } .kpis.sm .kpi b { font-size: 21px; } .kpi span { font-size: 13px; }
  /* الفلاتر في صف واحد بدل عمود */
  .filters { gap: 8px; align-items: center; }
  .filters > input, .filters > select { width: auto; flex: 0 1 170px; min-width: 120px; }
  .filters > input[type=search], .filters > input[name=q] { flex: 1 1 260px; }
  .filters > input[type=number] { flex: 0 0 auto; min-width: 0; }
  .filters label { flex: 0 1 170px; }
  .tbl td .btn + .btn, .tbl td .btn + form, .tbl td form + .btn { margin-inline-start: 4px; }
  .nowrap, .tbl td.nowrap { white-space: nowrap; }
  .avatar { width: 34px; height: 34px; }
  .tbl td:not(:has(a, small, div, p, textarea, .btn, form, input, select)) { white-space: nowrap; }
  .card:has(.tbl) { overflow-x: auto; }
}
