/* ═══════════════════════════════════════════════════════════
   دفتر — نظام التصميم
   مستوحى من دفتر الحسابات: حبر كحلي، ورق فاتح، ونحاسي للإجراء.
   ═══════════════════════════════════════════════════════════ */

:root {
  --ink: #10233A;
  --ink-soft: #1C3554;
  --ink-mute: #5B6C82;
  --paper: #F4F6F8;
  --surface: #FFFFFF;
  --brass: #C9922C;          /* للخلفيات والحدود — لا يصلح نصاً على أبيض */
  --brass-text: #96690F;     /* النص النحاسي على خلفية فاتحة (تباين 4.9:1) */
  --brass-soft: #FBF3E1;
  --sea: #0E7C86;
  --sea-soft: #E4F3F4;
  --clay: #B4472F;
  --clay-soft: #FBEBE7;
  --line: #DDE3EA;
  --radius: 14px;
  --nav-w: 250px;
  --shadow: 0 1px 2px rgba(16, 35, 58, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--paper); color: var(--ink);
  font-family: Tajawal, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--ink); }

/* ————————————————————————— الهيكل ————————————————————————— */

#app { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--nav-w); flex: 0 0 var(--nav-w);
  background: var(--ink); color: #B9C7D8;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px; }
.brand .mark {
  width: 38px; height: 38px; border-radius: 11px; background: var(--brass);
  color: var(--ink); font-weight: 800; font-size: 20px;
  display: flex; align-items: center; justify-content: center; flex: 0 0 38px;
}
.brand .name { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand .sub { color: #8AA0BB; font-size: 11px; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 14px; }
.quick button {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 11px 6px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid #2E4A6B; color: #fff;
  font-size: 12.5px; font-weight: 700; transition: .15s;
}
.quick button svg { width: 18px; height: 18px; }
.quick button:hover { background: #1C3554; }
.quick button.primary { background: var(--brass); border-color: var(--brass); color: var(--ink); }
.quick button.primary:hover { filter: brightness(1.07); }
.quick button.accent { border-color: var(--brass); color: var(--brass); }

.nav { flex: 1; padding: 4px 10px 16px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-radius: 10px; margin-bottom: 3px; text-decoration: none;
  color: #B9C7D8; font-size: 14px; font-weight: 500;
  border-inline-end: 3px solid transparent; transition: .15s;
}
.nav a svg { width: 20px; height: 20px; flex: 0 0 20px; opacity: .8; }
.nav a:hover { background: #182D48; color: #fff; }
.nav a.active {
  background: var(--ink-soft); color: #fff; font-weight: 700;
  border-inline-end-color: var(--brass);
}
.nav a.active svg { color: var(--brass); opacity: 1; }
.nav-foot { padding: 8px 18px 16px; color: rgba(255,255,255,.35); font-size: 11px; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

#topbar {
  height: 62px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
#topbar h1 { font-size: 22px; font-weight: 800; margin: 0; }
#topbar .spacer { flex: 1; }

#view { flex: 1; padding: 16px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ————————————————————————— مكوّنات ————————————————————————— */

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 12px;
}
.panel-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px 0;
}
.panel-head h2 { font-size: 16px; font-weight: 700; margin: 0; flex: 1; min-width: 120px; }
.panel-body { padding: 18px; }
.panel-accent { height: 3px; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; gap: 14px; align-items: flex-start;
  text-align: start; width: 100%; cursor: default; font: inherit; color: inherit;
}
.stat.clickable { cursor: pointer; transition: .15s; }
.stat.clickable:hover { border-color: var(--ink-mute); box-shadow: var(--shadow); }
.stat .rail { width: 4px; height: 52px; border-radius: 4px; flex: 0 0 4px; background: var(--ink); }
.stat > span:last-child { display: block; }
.stat .label { display: block; font-size: 12.5px; color: var(--ink-mute); font-weight: 600; }
.stat .value { display: block; font-size: 22px; font-weight: 800; margin-top: 4px; word-break: break-word; line-height: 1.3; }
.stat .hint { display: block; font-size: 12px; color: var(--ink-mute); margin-top: 3px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px;
  border-radius: 7px; font-size: 12px; font-weight: 700; white-space: nowrap;
  border: 1px solid; background: transparent;
}
.tag-sea { color: var(--sea); border-color: rgba(14,124,134,.3); background: var(--sea-soft); }
.tag-brass { color: var(--brass-text); border-color: rgba(201,146,44,.35); background: var(--brass-soft); }
.tag-clay { color: var(--clay); border-color: rgba(180,71,47,.3); background: var(--clay-soft); }
.tag-mute { color: var(--ink-mute); border-color: var(--line); background: var(--paper); }

/* أزرار */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 700; font-size: 14px;
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { border-color: var(--ink-mute); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-soft); border-color: var(--ink-soft); }
.btn-brass { background: var(--brass); color: var(--ink); border-color: var(--brass); }
.btn-brass:hover { filter: brightness(1.07); }
.btn-sea { background: var(--sea); color: #fff; border-color: var(--sea); }
.btn-danger { color: var(--clay); border-color: rgba(180,71,47,.4); }
.btn-danger:hover { background: var(--clay-soft); }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 9px; border-radius: 9px; }
.btn-icon svg { width: 19px; height: 19px; }
.btn-block { width: 100%; }
.btn-lg { padding: 15px 20px; font-size: 16px; }

/* حقول */
.login-section-title { margin: 4px 0 8px; color: var(--brass-text); font-size: 13px; font-weight: 800; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--ink-mute); font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea, .input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); outline: none; transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--brass); box-shadow: 0 0 0 3px rgba(201,146,44,.14);
}
.field textarea { resize: vertical; min-height: 62px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 160px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .field { margin-bottom: 0; }

.chip {
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: .15s;
}
.chip:hover { border-color: var(--ink-mute); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }

/* جداول */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; min-width: 520px; }
table.grid th {
  background: var(--paper); text-align: start; padding: 11px 14px;
  font-size: 12px; font-weight: 700; color: var(--ink-mute); white-space: nowrap;
}
table.grid td { padding: 11px 14px; border-top: 1px solid var(--line); font-size: 13.5px; }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover td { background: #FAFBFC; }
table.grid .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid .strong { font-weight: 700; }
.mono { font-weight: 700; letter-spacing: .4px; color: var(--ink-soft); font-size: 13px; }
.muted { color: var(--ink-mute); font-size: 12.5px; }

.empty { text-align: center; padding: 40px 24px; }
.empty .icon {
  width: 64px; height: 64px; border-radius: 18px; background: var(--paper);
  border: 1px solid var(--line); display: flex; align-items: center;
  justify-content: center; margin: 0 auto 14px;
}
.empty .icon svg { width: 28px; height: 28px; color: var(--ink-mute); }
.empty h3 { margin: 0 0 6px; font-size: 16px; }
.empty p { margin: 0 0 16px; color: var(--ink-mute); font-size: 13.5px; }

/* رسم أعمدة بسيط */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bars .bar .v { font-size: 10px; color: var(--ink-mute); margin-bottom: 4px; }
.bars .bar .fill {
  width: 100%; background: var(--ink); border-radius: 5px 5px 0 0; min-height: 3px;
  transition: height .45s cubic-bezier(.2,.8,.2,1);
}
.bars .bar.zero .fill { background: var(--line); }
.bars .bar .k { font-size: 10px; color: var(--ink-mute); margin-top: 6px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ————————————————————————— نقطة البيع ————————————————————————— */

.pos { display: grid; grid-template-columns: 1fr 360px; gap: 14px; align-items: start; }
.pos-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pos-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; text-align: start; cursor: pointer; min-height: 108px;
  display: flex; flex-direction: column; justify-content: space-between; transition: .12s;
  font: inherit; color: inherit;
}
.pos-item:hover { border-color: var(--brass); box-shadow: var(--shadow); }
.pos-item:active { transform: scale(.98); }
.pos-item.out { border-color: rgba(180,71,47,.35); }
.pos-item > span { display: block; }
.pos-item .nm { font-size: 13.5px; font-weight: 600; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pos-item .pr { color: var(--brass-text); font-weight: 800; font-size: 13.5px; }
.pos-item .st { font-size: 11px; color: var(--ink-mute); }

.cart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: sticky; top: 78px; }
.cart-head { background: var(--ink); color: #fff; padding: 13px 16px; display: flex; align-items: center; gap: 10px; }
.cart-head .t { flex: 1; font-weight: 700; }
.cart-list { max-height: 300px; overflow-y: auto; }
.cart-line { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-top: 1px solid var(--line); }
.cart-line:first-child { border-top: 0; }
.cart-line .nm { flex: 1; min-width: 0; }
.cart-line .nm b { display: block; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-line .nm span { font-size: 11px; color: var(--ink-mute); }
.qbtn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 17px; line-height: 1;
  flex: 0 0 34px; color: var(--ink);
}
.qbtn:hover { border-color: var(--ink); }
.cart-line .q { width: 38px; text-align: center; font-weight: 700; font-size: 15px; }
.cart-line .amt { width: 78px; text-align: end; font-weight: 700; font-size: 13px; }
.cart-foot { padding: 14px; border-top: 1px solid var(--line); }
.total-box {
  background: var(--ink); color: #fff; border-radius: 12px;
  padding: 12px 14px; display: flex; align-items: center; gap: 10px; margin: 10px 0;
}
.total-box .t { flex: 1; font-size: 14px; font-weight: 600; }
.total-box .v { font-size: 21px; font-weight: 800; color: var(--brass); }

.seg { display: flex; background: var(--paper); border: 1px solid var(--line); border-radius: 11px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; padding: 9px 8px; border: 0; border-radius: 8px; background: transparent;
  cursor: pointer; font-weight: 700; font-size: 13.5px; color: var(--ink-mute); transition: .15s;
}
.seg button.on { color: #fff; }
.seg button.on.cash { background: var(--sea); }
.seg button.on.credit { background: var(--brass); color: var(--ink); }

.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px;
  background: var(--surface); cursor: pointer; text-align: start; transition: .15s;
  display: flex; gap: 10px; align-items: center; font: inherit; color: inherit;
}
.mode-card > span { display: block; min-width: 0; }
.mode-card b { display: block; font-size: 14.5px; font-weight: 800; }
.mode-card span span { display: block; font-size: 11.5px; color: var(--ink-mute); }
.mode-card.on { color: #fff; border-width: 2px; }
.mode-card.on span { color: rgba(255,255,255,.85); }
.mode-card.on.cash { background: var(--sea); border-color: var(--sea); }
.mode-card.on.credit { background: var(--brass); border-color: var(--brass); color: var(--ink); }
.mode-card.on.credit span { color: rgba(16,35,58,.7); }

.note { border-radius: 10px; padding: 11px 14px; display: flex; gap: 10px; align-items: center; font-size: 13px; font-weight: 600; }
.note-sea { background: var(--sea-soft); color: var(--sea); }
.note-clay { background: var(--clay-soft); color: var(--clay); }
.note-brass { background: var(--brass-soft); color: #8a6415; }
.note .v { margin-inline-start: auto; font-size: 15px; font-weight: 800; }

/* ————————————————————————— نموذج الصنف ————————————————————————— */
.product-form-shell { padding-bottom: 4px; }
.product-form-hero { display: flex; gap: 12px; align-items: center; padding: 14px; margin: 0 0 4px; border: 1px solid rgba(201,146,44,.24); border-radius: 14px; background: linear-gradient(135deg, var(--brass-soft), var(--surface)); }
.product-form-hero-icon { width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 46px; border-radius: 13px; background: var(--ink); color: var(--brass); }
.product-form-kicker { display: block; color: var(--brass-text); font-size: 11px; font-weight: 800; margin-bottom: 2px; }
.product-form-hero strong { display: block; color: var(--ink); font-size: 17px; }
.product-form-hero p { margin: 3px 0 0; color: var(--ink-mute); font-size: 12px; }
.product-form-section { padding: 16px 0 2px; border-bottom: 1px solid var(--line); }
.product-form-section:last-of-type { border-bottom: 0; }
.product-form-section-head { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 12px; }
.product-form-section-icon { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 32px; border-radius: 10px; background: var(--paper); color: var(--brass-text); }
.product-form-section-head h4 { margin: 0; color: var(--ink); font-size: 14px; }
.product-form-section-head p { margin: 2px 0 0; color: var(--ink-mute); font-size: 12px; }
.product-form-grid { display: grid; gap: 10px; align-items: start; }
.product-form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.product-form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.product-form-hint { margin: -2px 0 6px; color: var(--ink-mute); font-size: 11.5px; }
.product-form-summary { margin: 14px 0 0; padding: 13px; border-radius: 13px; background: var(--ink); color: #fff; }
.product-form-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.product-form-summary-grid div { min-width: 0; padding: 8px 9px; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; background: rgba(255,255,255,.06); }
.product-form-summary-grid span { display: block; color: #B7C5D5; font-size: 10.5px; margin-bottom: 3px; }
.product-form-summary-grid b { display: block; color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-form-summary-grid b.positive { color: #79D6B0; }
.product-form-summary-grid b.negative { color: #FF9D92; }
.product-form-summary-name { margin: 9px 2px 0; color: #DCE6F0; font-size: 12px; font-weight: 700; }

/* ————————————————————————— سجل حركة الصنف ————————————————————————— */
.product-history-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.product-history-head > div:first-child { flex: 1; min-width: 180px; }
.product-history-head > div:first-child b { font-size: 15px; }
.product-history-tabs { display: flex; gap: 6px; }
.product-history-tabs .chip { padding: 7px 11px; font-size: 12px; }
.product-history-filters { display: grid; grid-template-columns: minmax(170px, 1fr) 150px 140px 140px; gap: 8px; margin-bottom: 10px; }
.product-history-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.product-history-stats > div { padding: 10px 12px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); }
.product-history-stats span { display: block; color: var(--ink-mute); font-size: 11px; }
.product-history-stats b { display: block; margin-top: 2px; font-size: 14px; }
.product-history-stats b.positive { color: var(--sea); }
.product-history-stats b.negative { color: var(--clay); }
.product-audit-change { display: flex; gap: 7px; align-items: baseline; padding: 3px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.product-audit-change:last-child { border-bottom: 0; }
.product-audit-change b { color: var(--ink-soft); min-width: 95px; }
.product-audit-change span { color: var(--ink-mute); }

/* ————————————————————————— حوارات ————————————————————————— */

.overlay {
  position: fixed; inset: 0; background: rgba(16,35,58,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px;
  max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 50px rgba(16,35,58,.28);
}
.modal.wide { max-width: 640px; }
.modal-head { padding: 18px 20px 12px; display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; }
.modal-body { padding: 0 20px 4px; overflow-y: auto; }
.modal-foot { padding: 14px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .start { margin-inline-end: auto; }
.err { color: var(--clay); font-size: 13px; margin: 8px 0 0; font-weight: 600; }

#toast {
  position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(50%);
  background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 600; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: .2s; max-width: 88vw; text-align: center;
}
#toast.show { opacity: 1; bottom: 34px; }
#toast.err { background: var(--clay); }

/* ————————————————————————— مستندات الطباعة ————————————————————————— */

.doc {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; max-width: 820px; margin: 0 auto;
}
.doc-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.doc-head .co { flex: 1; min-width: 200px; }
.doc-head .co h2 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.doc-badge { background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 16px; text-align: end; }
.doc-badge .k { font-size: 14px; font-weight: 700; }
.doc-badge .n { font-size: 17px; font-weight: 800; color: var(--brass); letter-spacing: .5px; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 26px; margin: 16px 0; }
.doc-meta .label { font-size: 12.5px; color: var(--ink-mute); font-weight: 600; }
.doc-meta .value { font-size: 14px; font-weight: 700; }
.doc-total { background: var(--ink); color: #fff; border-radius: 10px; padding: 12px 14px;
  display: flex; align-items: center; }
.doc-total .t { flex: 1; font-size: 13px; font-weight: 600; }
.doc-total .v { font-size: 17px; font-weight: 800; color: var(--brass); }
.doc-sign { border-top: 1px solid var(--line); margin-top: 34px; padding-top: 6px;
  font-size: 12.5px; color: var(--ink-mute); }
.tafqit { background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin: 16px 0; font-size: 13.5px; font-weight: 600; line-height: 1.8; }

/* إيصال حراري 80مم */
.receipt {
  width: 302px; max-width: 100%; margin: 0 auto; background: #fff;
  border: 1px solid var(--line); border-radius: 6px; padding: 16px; font-size: 12.5px;
}
.receipt .center { text-align: center; }
.receipt h2 { margin: 0 0 2px; font-size: 16px; font-weight: 800; }
.receipt .dash { border-top: 1px dashed #9aa7b6; margin: 9px 0; }
.receipt .r { display: flex; gap: 8px; margin: 2px 0; }
.receipt .r .k { color: var(--ink-mute); flex: 1; font-size: 12px; }
.receipt .r .v { font-weight: 700; }
.receipt .big { background: #EFEFEF; padding: 8px 10px; display: flex; margin: 6px 0; }
.receipt .big .k { flex: 1; font-weight: 800; font-size: 14px; }
.receipt .big .v { font-weight: 800; font-size: 15px; }

.permissions-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}
.permissions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.permissions-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.permission-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.permission-option:hover {
  border-color: var(--brass);
  background: var(--brass-soft);
  transform: translateY(-1px);
}
.permission-option input {
  flex: 0 0 auto;
  margin-top: 3px;
  accent-color: var(--brass-text);
}
.permission-option span {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
}
.permission-option small {
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.45;
}
.user-permissions-summary {
  display: inline-block;
  max-width: 330px;
  line-height: 1.7;
}

/* ————————————————————————— تنقّل الجوال ————————————————————————— */

#mobilenav { display: none; }
#drawer-backdrop { display: none; }

@media (max-width: 1000px) {
  .pos { grid-template-columns: 1fr; }
  .cart { position: static; }
}

@media (max-width: 820px) {
  .product-form-grid-2, .product-form-grid-3 { grid-template-columns: 1fr; gap: 0; }
  .product-history-filters { grid-template-columns: 1fr 1fr; }
  .product-history-filters .input:first-child { grid-column: 1 / -1; }
  .permissions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .permissions-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .user-permissions-summary { max-width: 190px; }
  .product-history-stats { grid-template-columns: 1fr; }
  .product-history-tabs { width: 100%; }
  .product-history-tabs .chip { flex: 1; }
  .product-audit-change { flex-direction: column; gap: 0; }
  .product-form-summary-grid { grid-template-columns: 1fr 1fr; }
  .product-form-summary-grid div:last-child { grid-column: 1 / -1; }
  .product-form-hero { align-items: flex-start; }
  .product-form-hero-icon { width: 40px; height: 40px; flex-basis: 40px; }
  #sidebar {
    position: fixed; inset-inline-start: 0; top: 0; z-index: 90;
    transform: translateX(100%); transition: transform .22s ease;
  }
  [dir="rtl"] #sidebar { transform: translateX(100%); }
  #sidebar.open { transform: translateX(0) !important; }
  #drawer-backdrop.open {
    display: block; position: fixed; inset: 0; background: rgba(16,35,58,.4); z-index: 80;
  }
  #topbar { padding: 0 12px; }
  #topbar h1 { font-size: 18px; }
  #view { padding: 12px 12px 78px; }
  .panel-body { padding: 14px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; }
  .stat { padding: 13px; gap: 11px; }
  .stat .value { font-size: 19px; }
  .mode-cards { grid-template-columns: 1fr; }

  #mobilenav {
    display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 60;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  #mobilenav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px; text-decoration: none; color: var(--ink-mute); font-size: 10.5px; font-weight: 600;
  }
  #mobilenav a svg { width: 22px; height: 22px; }
  #mobilenav a { min-height: 46px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .btn-icon { min-width: 42px; min-height: 42px; }
  .chip { min-height: 40px; display: inline-flex; align-items: center; }
  .field input, .field select, .input { min-height: 44px; font-size: 16px; }
  .pos-item { min-height: 116px; }
  #mobilenav a.active { color: var(--ink); }
  #mobilenav a.active svg { color: var(--brass); }
  .modal { max-height: 94vh; border-radius: 16px; }
  .modal-foot { justify-content: stretch; }
  .modal-foot .btn { flex: 1; }
  .modal-foot .start { margin-inline-end: 0; }
}

@media (max-width: 420px) {
  .quick { grid-template-columns: 1fr 1fr; }
  .permissions-grid { grid-template-columns: 1fr; }
  #view { padding: 10px 10px 78px; }
}

/* ————————————————————————— تفضيلات المستخدم ————————————————————————— */

/* من يعاني من دوار الحركة يوقفها من إعدادات جهازه — نحترم ذلك */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* من يحتاج تبايناً أعلى (شاشة تحت الشمس، أو ضعف بصر) */
@media (prefers-contrast: more) {
  :root {
    --ink-mute: #43536B;
    --line: #B9C4D2;
    --brass-text: #7E5A10;
  }
  .btn, .input, .field input, .field select, .panel, .stat { border-width: 1.5px; }
}

/* ————————————————————————— الطباعة ————————————————————————— */

@media print {
  @page { margin: 10mm; }
  #sidebar, #topbar, #mobilenav, #toast, .no-print, #drawer-backdrop { display: none !important; }
  #app, #main, #view { display: block; padding: 0; margin: 0; max-width: none; }
  body { background: #fff; }
  .doc, .receipt { border: 0; padding: 0; max-width: none; width: auto; }
  .doc-total, .doc-badge, .receipt .big { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ═══════════════════════════════════════════════════════════
   الفاتورة المطبوعة — تصميم A4 رسمي
   ═══════════════════════════════════════════════════════════ */

.inv {
  background: #fff; max-width: 820px; margin: 0 auto;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; color: var(--ink);
}

/* شريط علوي ملوّن حسب نوع الفاتورة */
.inv-band { height: 6px; }

.inv-top {
  display: flex; gap: 20px; align-items: flex-start;
  padding: 22px 26px 18px; flex-wrap: wrap;
}
.inv-brand { display: flex; gap: 14px; align-items: flex-start; flex: 1; min-width: 240px; }
.inv-mark {
  width: 54px; height: 54px; border-radius: 14px; flex: 0 0 54px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: #fff;
}
.inv-co h1 { margin: 0 0 3px; font-size: 21px; font-weight: 800; letter-spacing: -.2px; }
.inv-co .line { font-size: 12.5px; color: var(--ink-mute); line-height: 1.7; }

.inv-doc { text-align: end; min-width: 190px; }
.inv-doc .kind {
  display: inline-block; padding: 5px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 800; color: #fff; margin-bottom: 8px;
}
.inv-doc .no {
  font-size: 22px; font-weight: 800; letter-spacing: .6px; line-height: 1.2;
}
.inv-doc .no small { font-size: 12px; color: var(--ink-mute); font-weight: 600; display: block; }
.inv-doc .date { font-size: 12.5px; color: var(--ink-mute); margin-top: 6px; }

/* بطاقتا الطرف وبيانات الدفع */
.inv-parties {
  display: flex; gap: 14px; padding: 0 26px 18px; flex-wrap: wrap;
}
.inv-card {
  flex: 1; min-width: 230px; border: 1px solid var(--line);
  border-radius: 10px; padding: 13px 15px; background: #FBFCFD;
}
.inv-card .cap {
  font-size: 11px; font-weight: 700; color: var(--ink-mute);
  letter-spacing: .3px; margin-bottom: 5px;
}
.inv-card .who { font-size: 16px; font-weight: 800; margin-bottom: 3px; }
.inv-card .det { font-size: 12.5px; color: var(--ink-mute); line-height: 1.8; }
.inv-card .kv { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; }
.inv-card .kv b { font-weight: 700; }

/* جدول الأصناف */
.inv-items { padding: 0 26px; }
table.inv-table { width: 100%; border-collapse: collapse; }
table.inv-table thead th {
  background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 700;
  padding: 10px 10px; text-align: start; white-space: nowrap;
}
table.inv-table thead th:first-child { border-start-start-radius: 8px; }
table.inv-table thead th:last-child { border-start-end-radius: 8px; }
table.inv-table td {
  padding: 9px 10px; font-size: 12.5px; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.inv-table tbody tr:nth-child(even) td { background: #FAFBFC; }
table.inv-table .n { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.inv-table .idx { color: var(--ink-mute); width: 30px; }
table.inv-table .nm b { font-weight: 700; }
table.inv-table .nm span { color: var(--ink-mute); font-size: 11.5px; }
table.inv-table tfoot td {
  background: #F2F4F7; font-weight: 700; font-size: 12.5px; padding: 9px 10px;
  border-top: 2px solid var(--ink);
}

/* الإجماليات */
.inv-bottom { display: flex; gap: 18px; padding: 18px 26px 0; flex-wrap: wrap; }
.inv-notes { flex: 1; min-width: 230px; }
.inv-notes .cap { font-size: 11px; font-weight: 700; color: var(--ink-mute); margin-bottom: 4px; }
.inv-notes p { margin: 0 0 12px; font-size: 12.5px; line-height: 1.8; }

.inv-sums { width: 290px; max-width: 100%; }
.inv-sums .row2 {
  display: flex; justify-content: space-between; font-size: 13px;
  padding: 5px 0; border-bottom: 1px dashed var(--line);
}
.inv-sums .row2 span { color: var(--ink-mute); }
.inv-sums .row2 b { font-weight: 700; }
.inv-grand {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--ink); color: #fff; border-radius: 10px;
  padding: 12px 14px; margin-top: 10px;
}
.inv-grand span { font-size: 13.5px; font-weight: 600; }
.inv-grand b { font-size: 20px; font-weight: 800; }
.inv-paid { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 2px; }

/* ختم الحالة */
.inv-stamp {
  display: inline-block; margin-top: 12px; padding: 7px 18px;
  border: 2px solid; border-radius: 8px; font-weight: 800; font-size: 14px;
  transform: rotate(-4deg); letter-spacing: .5px;
}
.inv-stamp.paid { color: var(--sea); border-color: var(--sea); background: var(--sea-soft); }
.inv-stamp.due { color: var(--clay); border-color: var(--clay); background: var(--clay-soft); }

.inv-tafqit {
  margin: 16px 26px 0; background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 14px; font-size: 13px; line-height: 1.8;
}
.inv-tafqit b { font-weight: 800; }
.inv-tafqit .eq { color: var(--ink-mute); font-size: 12px; }

.inv-signs { display: flex; gap: 34px; padding: 26px 26px 6px; flex-wrap: wrap; }
.inv-signs div { flex: 1; min-width: 150px; }
.inv-signs .ln { border-top: 1px solid var(--ink-mute); margin-bottom: 5px; }
.inv-signs .cap { font-size: 12px; color: var(--ink-mute); }

.inv-foot {
  margin-top: 16px; padding: 11px 26px; background: var(--paper);
  border-top: 1px solid var(--line); display: flex; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-mute);
}

@media (max-width: 640px) {
  .inv-top, .inv-parties, .inv-items, .inv-bottom, .inv-signs, .inv-foot { padding-inline: 14px; }
  .inv-tafqit { margin-inline: 14px; }
  .inv-sums { width: 100%; }
  table.inv-table td, table.inv-table thead th { padding: 7px 6px; font-size: 11.5px; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  .inv { border: 0; border-radius: 0; max-width: none; }
  .inv-band, .inv-mark, table.inv-table thead th, .inv-grand, .inv-stamp,
  .inv-doc .kind, table.inv-table tbody tr:nth-child(even) td, .inv-foot, .inv-card {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  table.inv-table { page-break-inside: auto; }
  table.inv-table tr { page-break-inside: avoid; page-break-after: auto; }
  table.inv-table thead { display: table-header-group; }   /* يتكرر رأس الجدول في كل صفحة */
  table.inv-table tfoot { display: table-footer-group; }
  .inv-bottom, .inv-signs, .inv-tafqit { page-break-inside: avoid; }
}

/* ═══════════ ورقة ملصقات الباركود ═══════════ */

.labels-sheet {
  display: flex; flex-wrap: wrap; gap: 3mm;
  background: var(--paper); padding: 10px; border-radius: 10px;
}
.lbl {
  background: #fff; border: 1px dashed var(--line); border-radius: 3px;
  padding: 1.5mm; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between; overflow: hidden;
}
.lbl-nm {
  font-weight: 700; line-height: 1.2; text-align: center; width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lbl-bc { display: flex; align-items: center; justify-content: center; flex: 1; }
.lbl-bc svg { max-width: 100%; height: auto; }
.lbl-pr { font-weight: 800; line-height: 1.1; }

@media print {
  .labels-sheet {
    background: #fff; padding: 0; gap: 2mm;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .lbl { border: 0; page-break-inside: avoid; }
  .panel-head, .panel { border: 0; }
  .panel-head h2 { display: none; }
}

/* ═══════════ دليل الإعداد ═══════════ */

.guide-list { margin: 0 0 12px; padding-inline-start: 22px; line-height: 2.1; font-size: 14px; }
.guide-list li { margin-bottom: 3px; }
.guide-list b { font-weight: 700; }

.guide-sql {
  background: var(--ink); color: #E8EEF5; border-radius: 10px;
  padding: 13px 15px; overflow-x: auto; direction: ltr; text-align: left;
  font-size: 12.5px; line-height: 1.7; margin: 0 0 10px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

@media print { .guide-sql { background: #fff; color: #000; border: 1px solid #ccc; } }

/* أرشيف التنبيهات الجماعية */
.notification-archive-body {
  max-width: 360px;
  margin-top: 4px;
  white-space: normal;
  line-height: 1.7;
}

@media (max-width: 820px) {
  .notification-archive-body { max-width: 220px; }
}

/* زر خروج الحساب الفرعي — يبقى ظاهراً حتى عند ضيق الشريط العلوي */
.subaccount-logout {
  margin: 8px 14px 14px;
  padding: 10px;
  border: 1px solid rgba(180,71,47,.45);
  border-radius: 10px;
  background: rgba(180,71,47,.08);
}
.subaccount-label {
  color: #F1C2B7;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-sublogout { flex: 0 0 auto; }
@media (max-width: 820px) {
  #topbar { overflow-x: auto; }
  .topbar-sublogout { flex: 0 0 auto; }
}

/* تصفية سجل نشاط الحسابات */
.activity-filter-bar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px 0;
}
.activity-filter-bar .field {
  min-width: 250px;
  flex: 0 1 360px;
  margin-bottom: 0;
}
@media (max-width: 560px) {
  .activity-filter-bar { padding-inline: 12px; }
  .activity-filter-bar .field { min-width: 100%; flex-basis: 100%; }
}


/* ═══════════════════════════════════════════════════════════
   طبقة الصقل البصري — المحاسب التجاري
   هوية هادئة، تباين واضح، ومساحات مريحة للعمل اليومي.
   ═══════════════════════════════════════════════════════════ */
:root {
  --ink: #0D2238;
  --ink-soft: #173B5A;
  --ink-mute: #60748A;
  --paper: #F3F6F8;
  --surface: #FFFFFF;
  --brass: #D3A13A;
  --brass-text: #895F0B;
  --brass-soft: #FBF3DF;
  --sea: #087E83;
  --sea-soft: #E3F4F3;
  --clay: #BD5038;
  --clay-soft: #FBEAE5;
  --line: #D9E3EA;
  --radius: 16px;
  --shadow: 0 10px 26px rgba(13, 34, 56, .07);
  --shadow-lg: 0 22px 60px rgba(7, 28, 48, .14);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}

html, body {
  background: linear-gradient(145deg, #F8FAFB 0%, var(--paper) 68%, #EEF4F6 100%);
}

body { letter-spacing: -.01em; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(211,161,58,.38);
  outline-offset: 2px;
}

#sidebar {
  background: linear-gradient(180deg, #0B2036 0%, #102B48 60%, #0A1C30 100%);
  box-shadow: 10px 0 32px rgba(9, 31, 51, .10);
}
.brand { padding: 22px 20px 16px; gap: 13px; }
.brand .mark {
  width: 42px; height: 42px; flex-basis: 42px; border-radius: 13px;
  background: linear-gradient(145deg, #E2B34D, #C68A22);
  box-shadow: 0 7px 16px rgba(211,161,58,.22);
}
.brand .name { font-size: 14.5px; }
.brand .sub { margin-top: 2px; color: #A8BAD0; }
.quick { gap: 9px; padding: 2px 15px 17px; }
.quick button {
  min-height: 64px; border-color: rgba(183, 205, 226, .22);
  background: rgba(255,255,255,.035); transition: transform .18s var(--ease-out), background .18s, border-color .18s;
}
.quick button:hover { transform: translateY(-2px); background: rgba(255,255,255,.09); border-color: rgba(211,161,58,.64); }
.quick button.primary { background: linear-gradient(145deg, #E0B248, #C88D25); box-shadow: 0 8px 18px rgba(0,0,0,.14); }
.quick button.primary:hover { filter: none; }
.nav { padding: 7px 11px 18px; }
.nav a {
  padding: 12px 13px; border-radius: 12px; margin-bottom: 4px; color: #B8C8D9;
  transition: transform .18s var(--ease-out), background .18s, color .18s;
}
.nav a:hover { transform: translateX(-2px); background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(23,59,90,.92), rgba(37,76,111,.72)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }
.nav a.active svg { filter: drop-shadow(0 2px 5px rgba(211,161,58,.28)); }
.nav-foot { padding: 12px 20px 20px; color: rgba(224,235,245,.48); line-height: 1.9; }

#topbar {
  height: 70px; padding: 0 26px; gap: 12px;
  background: rgba(255,255,255,.88); border-bottom-color: rgba(217,227,234,.86);
  box-shadow: 0 4px 18px rgba(13,34,56,.035); backdrop-filter: blur(14px);
}
#topbar h1 { font-size: 23px; letter-spacing: -.03em; }
#view { padding: 24px; max-width: 1320px; }

.panel, .stat, .pos-item, .cart {
  border-color: rgba(217,227,234,.9); box-shadow: var(--shadow);
}
.panel { margin-bottom: 16px; }
.panel-head { padding: 18px 20px 0; }
.panel-head h2 { font-size: 16.5px; }
.panel-body { padding: 20px; }
.panel-accent { height: 4px; }
.stats { gap: 14px; margin-bottom: 16px; }
.stat { min-height: 108px; padding: 18px; border-radius: var(--radius); transition: transform .18s var(--ease-out), box-shadow .18s, border-color .18s; }
.stat.clickable:hover { transform: translateY(-3px); border-color: rgba(96,116,138,.4); box-shadow: 0 15px 32px rgba(13,34,56,.10); }
.stat .rail { width: 5px; flex-basis: 5px; height: 58px; border-radius: 8px; }
.stat .value { font-size: 24px; letter-spacing: -.03em; }

.btn {
  min-height: 42px; border-color: rgba(217,227,234,.95); border-radius: 11px;
  box-shadow: 0 2px 7px rgba(13,34,56,.035);
  transition: transform .16s var(--ease-out), box-shadow .16s, border-color .16s, background .16s;
}
.btn:hover { transform: translateY(-1px); border-color: #AEBFCE; box-shadow: 0 6px 16px rgba(13,34,56,.08); }
.btn:active { transform: scale(.97); }
.btn-primary, .btn-sea, .btn-brass { box-shadow: 0 7px 16px rgba(13,34,56,.11); }
.btn-primary:hover, .btn-sea:hover, .btn-brass:hover { box-shadow: 0 10px 20px rgba(13,34,56,.15); }
.btn-brass { background: linear-gradient(145deg, #E1B34B, #C88E25); }
.btn-sea { background: linear-gradient(145deg, #098A8B, #087274); }

.field > span { margin-bottom: 6px; }
.field input, .field select, .field textarea, .input {
  min-height: 44px; border-color: #D5E0E8; border-radius: 11px;
  box-shadow: inset 0 1px 2px rgba(13,34,56,.025); transition: border-color .16s, box-shadow .16s, background .16s;
}
.field input:hover, .field select:hover, .field textarea:hover, .input:hover { border-color: #B6C7D5; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--brass); box-shadow: 0 0 0 4px rgba(211,161,58,.15), inset 0 1px 2px rgba(13,34,56,.02);
}

.chip { border-radius: 10px; transition: transform .16s var(--ease-out), border-color .16s, background .16s; }
.chip:hover { transform: translateY(-1px); }
table.grid th { background: #F4F7F9; padding: 13px 14px; }
table.grid td { padding: 13px 14px; }
table.grid tr.clickable:hover td { background: #F8FBFC; }

.note { border-radius: 12px; padding: 12px 15px; }
.empty { padding: 58px 24px; }
.empty .icon { background: linear-gradient(145deg, #F5F8FA, #E8F0F4); box-shadow: inset 0 0 0 1px rgba(217,227,234,.75); }

/* بطاقة الدخول — مساحة ترحيبية واضحة بدل نموذج صغير معزول */
.login-screen {
  position: relative; min-height: 100vh; overflow: hidden; padding: clamp(24px, 5vw, 72px);
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: radial-gradient(circle at 12% 8%, rgba(211,161,58,.16), transparent 30%),
    radial-gradient(circle at 88% 88%, rgba(8,126,131,.20), transparent 32%),
    linear-gradient(135deg, #081A2C 0%, #0D2946 54%, #102F4D 100%);
}
.login-glow { position: absolute; width: 360px; height: 360px; border-radius: 50%; pointer-events: none; filter: blur(2px); opacity: .32; }
.login-glow-a { top: -190px; inset-inline-end: 8%; background: radial-gradient(circle, rgba(211,161,58,.38), transparent 66%); }
.login-glow-b { bottom: -210px; inset-inline-start: 5%; background: radial-gradient(circle, rgba(8,126,131,.35), transparent 66%); }
.login-layout { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(350px, .8fr); gap: clamp(36px, 7vw, 108px); align-items: center; width: min(1080px, 100%); }
.login-intro { max-width: 570px; padding: 12px 0; }
.login-brand { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 52px; }
.login-brand > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.login-brand b { font-size: 16px; letter-spacing: -.02em; }
.login-brand small { color: #A9BED2; font-size: 11px; }
.login-mark, .login-card-mark { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 14px; color: var(--ink); background: linear-gradient(145deg, #E3B64E, #C98E26); font-size: 22px; font-weight: 800; box-shadow: 0 10px 22px rgba(0,0,0,.18); }
.login-kicker { display: inline-flex; align-items: center; gap: 8px; color: #E5B34A; font-size: 12px; font-weight: 800; letter-spacing: .03em; }
.login-kicker::before { content: ''; width: 22px; height: 2px; border-radius: 2px; background: #E5B34A; }
.login-intro h1 { margin: 18px 0 18px; font-size: clamp(36px, 5vw, 60px); line-height: 1.08; letter-spacing: -.055em; font-weight: 800; }
.login-intro h1 em { color: #E5B34A; font-style: normal; }
.login-lead { max-width: 500px; margin: 0; color: #B5C7D9; font-size: 15px; line-height: 2; }
.login-features { display: grid; gap: 12px; margin-top: 36px; max-width: 500px; }
.login-feature { display: flex; align-items: flex-start; gap: 11px; padding: 10px 0; }
.login-feature-mark { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: 0 0 32px; border: 1px solid rgba(229,179,74,.30); border-radius: 10px; color: #E5B34A; background: rgba(229,179,74,.08); }
.login-feature > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.login-feature b { font-size: 13px; color: #F6F9FB; }
.login-feature small { color: #91A9BF; font-size: 11.5px; line-height: 1.55; }
.login-card-wrap { width: 100%; max-width: 430px; justify-self: end; }
.login-card-top { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; padding-inline: 4px; }
.login-card-top > span:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.login-card-top b { color: #fff; font-size: 19px; }
.login-card-top small { color: #9DB4C9; font-size: 12px; }
.login-card { padding: 24px; background: rgba(255,255,255,.98); color: var(--ink); border: 1px solid rgba(255,255,255,.7); border-radius: 20px; box-shadow: 0 28px 70px rgba(0,0,0,.24); }
.login-card .note { margin-bottom: 14px !important; }
.login-section-title { margin: 0 0 16px; padding: 0 0 10px; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 14px; }
.login-section-title::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-inline-end: 8px; border-radius: 50%; background: var(--brass); vertical-align: 1px; }
.login-submit { min-height: 48px; margin-top: 16px !important; font-size: 15px; }
.login-trust { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 15px; color: var(--ink-mute); font-size: 11px; }
.login-trust-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sea); box-shadow: 0 0 0 4px var(--sea-soft); }
.login-help, .login-credit { text-align: center; }
.login-help { margin: 16px 0 0; color: #9DB4C9; font-size: 12px; }
.login-credit { margin: 9px 0 0; color: #748EA5; font-size: 11px; }
.login-credit a { color: #A9C0D4; text-decoration: none; }
.login-credit a:hover { color: #E5B34A; }

/* تحسينات نقطة البيع والمحررات */
.pos-item { transition: transform .18s var(--ease-out), box-shadow .18s, border-color .18s; }
.pos-item:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(13,34,56,.09); }
.cart { box-shadow: 0 14px 34px rgba(13,34,56,.10); }
.cart-head { background: linear-gradient(110deg, #0B2036, #173B5A); padding: 15px 17px; }
.total-box, .product-form-summary { background: linear-gradient(135deg, #0B2036, #173B5A); }

@media (max-width: 920px) {
  .login-layout { grid-template-columns: 1fr; max-width: 520px; gap: 30px; }
  .login-intro { max-width: none; text-align: center; }
  .login-brand { margin-bottom: 30px; }
  .login-kicker { justify-content: center; }
  .login-lead { margin-inline: auto; }
  .login-features { grid-template-columns: repeat(3, 1fr); text-align: start; gap: 8px; margin-inline: auto; }
  .login-feature { flex-direction: column; align-items: center; text-align: center; padding: 0; }
  .login-card-wrap { justify-self: center; }
}

@media (max-width: 820px) {
  #topbar { height: 64px; padding: 0 14px; }
  #topbar h1 { font-size: 19px; }
  #view { padding: 16px 14px 84px; }
  .panel-body { padding: 16px; }
  .stats { gap: 10px; }
  .stat { min-height: 96px; padding: 14px; }
}

@media (max-width: 560px) {
  .login-screen { padding: 24px 16px 36px; align-items: flex-start; }
  .login-layout { padding-top: 12px; gap: 24px; }
  .login-intro h1 { margin: 14px 0 12px; font-size: 37px; }
  .login-lead { font-size: 13px; line-height: 1.85; }
  .login-brand { margin-bottom: 22px; }
  .login-features { grid-template-columns: 1fr; gap: 6px; margin-top: 22px; }
  .login-feature { flex-direction: row; align-items: center; text-align: start; }
  .login-card { padding: 20px 16px; border-radius: 17px; }
  .login-card-top b { font-size: 17px; }
  .login-help { line-height: 1.7; }
}

@media (prefers-reduced-motion: no-preference) {
  .login-card, .login-intro { animation: login-rise .55s var(--ease-out) both; }
  .login-card-wrap { animation-delay: .06s; }
}
@keyframes login-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }


/* ═══════════════════════════════════════════════════════════
   طبقة الاستجابة النهائية — هاتف، جهاز لوحي، وحاسبة
   ═══════════════════════════════════════════════════════════ */
html, body { max-width: 100%; overflow-x: hidden; }
#app, #main, #view { min-width: 0; }
.panel, .panel-body, .panel-head, .toolbar, .row { max-width: 100%; }
.table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 820px) {
  #menu-btn { display: inline-flex !important; flex: 0 0 auto; }
  #topbar {
    height: auto; min-height: 58px; flex-wrap: wrap; align-content: center;
    gap: 6px; padding: 8px 12px;
  }
  #topbar h1 {
    flex: 1 1 150px; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; font-size: 17px;
  }
  #topbar .spacer { display: none; }
  #topbar > .tag, #topbar > .btn {
    min-width: 0; max-width: 100%; overflow: hidden;
    text-overflow: ellipsis;
  }
  #topbar > .tag { padding-inline: 7px; font-size: 10.5px; }
  #topbar > .btn { padding-inline: 9px; font-size: 12px; }
  #view > * { min-width: 0; }
  .panel-head { min-width: 0; }
  .panel-head h2 { min-width: 0; overflow-wrap: anywhere; }
  .toolbar > *, .row > * { min-width: 0; max-width: 100%; }
  .row > .grow { min-width: 0; flex: 1 1 220px; }
  .modal { width: min(100%, 640px); }
  .modal-body { min-width: 0; }
  .modal-foot .btn { white-space: normal; line-height: 1.35; }
}

@media (max-width: 560px) {
  #topbar { padding: 7px 10px; }
  #topbar h1 { font-size: 16px; flex-basis: 120px; }
  #topbar > .tag, #topbar > .btn { font-size: 10.5px; }
  #topbar > .tag svg, #topbar > .btn svg { width: 14px; height: 14px; }
  #view { padding: 10px 10px 82px; }
  .panel { border-radius: 12px; }
  .panel-head { padding: 12px 12px 0; }
  .panel-body { padding: 12px; }
  .panel-head .btn, .toolbar .btn { flex: 1 1 145px; white-space: normal; line-height: 1.3; }
  .row > .grow { flex-basis: 100%; }
  .field { margin-bottom: 10px; }
  .field input, .field select, .field textarea, .input { min-width: 0; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 11px 10px; gap: 8px; }
  .stat .rail { height: 42px; }
  .stat .label { font-size: 11px; }
  .stat .value { font-size: 17px; }
  .stat .hint { font-size: 11px; }
  .permissions-grid { grid-template-columns: 1fr; }
  .permissions-box { padding: 10px; }
  #mobilenav { gap: 1px; padding-inline: 2px; }
  #mobilenav a { min-width: 0; padding-inline: 1px; font-size: 9.5px; }
  #mobilenav a svg { width: 20px; height: 20px; }
  #mobilenav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table-wrap { margin-inline: -2px; }
  table.grid th, table.grid td { padding-inline: 9px; }
  .modal { max-height: calc(100dvh - 20px); border-radius: 14px; }
  .modal-head { padding: 14px 14px 10px; }
  .modal-body { padding-inline: 14px; }
  .modal-foot { padding: 10px 14px 14px; }
}

@media (max-width: 360px) {
  #topbar h1 { font-size: 15px; }
  #topbar > .tag, #topbar > .btn { font-size: 10px; padding-inline: 6px; }
  .stats { grid-template-columns: 1fr; }
  .quick { gap: 6px; padding-inline: 10px; }
  #view { padding-inline: 8px; }
}
