/* كنز — برنامج المحاسبة */
:root {
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, 'Noto Sans Arabic', system-ui, -apple-system, sans-serif;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --accent: #f5b21a;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #151a30;
  --text-muted: #5d6680;
  --border: #e4e7f0;
  --border-strong: #cdd3e3;
  --shadow-xs: 0 1px 2px rgba(20, 27, 60, .05);
  --shadow-sm: 0 1px 3px rgba(20, 27, 60, .08), 0 1px 2px rgba(20, 27, 60, .04);
  --shadow-md: 0 8px 22px rgba(20, 27, 60, .09), 0 2px 5px rgba(20, 27, 60, .05);
  --shadow-lg: 0 22px 48px rgba(20, 27, 60, .18), 0 4px 12px rgba(20, 27, 60, .07);
  --radius: 16px;
  --radius-lg: 22px;
  color-scheme: light;
}
[data-theme="dark"] {
  --primary: #6366f1;
  --primary-dark: #5457e6;
  --primary-soft: rgba(129, 140, 248, .16);
  --bg: #0b0f1d;
  --card: #121830;
  --text: #eceffa;
  --text-muted: #9aa4c7;
  --border: #232c4a;
  --border-strong: #34406a;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, .5);
  --shadow-lg: 0 22px 48px rgba(0, 0, 0, .65);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 15px; background: var(--bg); color: var(--text); direction: rtl; min-height: 100vh; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }

.acc {
  --side-w: 272px;
  --hover: #f0f2f9;
  --focus: rgba(79, 70, 229, .2);
  --soft: #f7f8fc;
  --ok-bg: #e3f6ec; --ok-fg: #0b6b45;
  --warn-bg: #fff2d4; --warn-fg: #8a5200;
  --bad-bg: #fde8e8; --bad-fg: #a02424;
  --info-bg: #e9ebff; --info-fg: #3730a3;
  --muted-bg: #eef0f6; --muted-fg: #4a5470;
  --neg: #c42626;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #a855f7 100%);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
[data-theme="dark"] .acc {
  --hover: #1a2342;
  --focus: rgba(129, 140, 248, .32);
  --soft: #0f1527;
  --ok-bg: rgba(52, 211, 153, .14); --ok-fg: #6ee7b7;
  --warn-bg: rgba(251, 191, 36, .14); --warn-fg: #fcd34d;
  --bad-bg: rgba(248, 113, 113, .14); --bad-fg: #fca5a5;
  --info-bg: rgba(129, 140, 248, .18); --info-fg: #c7d2fe;
  --muted-bg: #1b2440; --muted-fg: #c4cbe3;
  --neg: #f87171;
}
.acc h1, .acc h2, .acc h3, .acc h4, .acc p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.acc a { color: var(--primary); }
[data-theme="dark"] .acc a { color: #a5b4fc; }
[hidden] { display: none !important; }

/* ─── الأيقونات (بدل الإيموجي) ─── */
.i { width: 1.2em; height: 1.2em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.24em; }
.i-fill { fill: currentColor; stroke: none; }
.btn .i, .icon-btn .i { width: 1.15em; height: 1.15em; vertical-align: -.2em; }

/* ─── الهيكل ─── */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; background: var(--card); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; padding-bottom: 12px; }
.side > * { flex-shrink: 0; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px 10px; font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; color: var(--text) !important; text-decoration: none; }
.brand-badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; box-shadow: 0 5px 14px rgba(67, 56, 202, .35); }
.brand-logo { width: 100%; height: 100%; display: block; border-radius: 12px; }
.brand-sub { display: block; font-size: .72rem; font-weight: 500; color: var(--text-muted); line-height: 1.2; letter-spacing: 0; }
.side-co { display: flex; align-items: center; gap: 10px; margin: 6px 14px 8px; padding: 10px 12px; border-radius: 12px; background: var(--soft); border: 1px solid var(--border); font-size: .84rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-co .i { color: var(--primary); }
button.side-co { width: calc(100% - 28px); font: inherit; font-size: .84rem; font-weight: 600; text-align: start; cursor: pointer; transition: border-color .15s, background .15s; }
button.side-co:hover { border-color: var(--primary); background: var(--primary-soft); }
button.side-co:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.co-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.co-more { color: var(--text-muted); }
.co-list { display: grid; gap: 8px; margin-bottom: 12px; }
.co-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.co-row.on { border-color: var(--primary); background: var(--primary-soft); }
.co-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-sec { margin: 18px 22px 6px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; color: var(--text-muted); }
.nav-a { position: relative; display: flex; align-items: center; gap: 12px; margin: 1px 10px; padding: 8px 12px; border-radius: 10px; color: var(--text) !important; text-decoration: none; font-weight: 500; font-size: .92rem; transition: background-color .15s, color .15s; }
.nav-a:hover { background: var(--hover); }
.nav-a .ic { width: 20px; display: inline-grid; place-items: center; flex: none; color: var(--text-muted); transition: color .15s; }
.nav-a .ic .i { width: 19px; height: 19px; vertical-align: 0; }
.nav-a:hover .ic { color: var(--text); }
.nav-a.on { background: var(--primary-soft); color: var(--primary) !important; font-weight: 600; }
[data-theme="dark"] .nav-a.on { color: #c7d2fe !important; }
.nav-a.on .ic { color: var(--primary); }
[data-theme="dark"] .nav-a.on .ic { color: #a5b4fc; }
.nav-a.on::before { content: ''; position: absolute; inset-inline-start: -10px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--primary); }
.side-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--border); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 10px 24px; background: var(--bg); background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--border); }
.topbar-title { flex: 1; min-width: 0; font-weight: 700; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none !important; }
.view { padding: 28px 28px 44px; max-width: 1240px; width: 100%; margin: 0 auto; }
.scrim { display: none; }

/* قائمة «جديد» السريعة */
.quick { position: relative; }
.quick > summary { list-style: none; }
.quick > summary::-webkit-details-marker { display: none; }
.quick-menu { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 40; min-width: 230px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 6px; display: grid; }
.quick-menu a { display: flex; gap: 12px; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--text) !important; text-decoration: none; font-weight: 500; font-size: .92rem; }
.quick-menu a:hover { background: var(--hover); }
.quick-menu a .i { color: var(--text-muted); }

/* ─── عناصر عامة ─── */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; margin-bottom: 22px; }
.page-head h2 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.35; }
.page-head .sub { color: var(--text-muted); font-size: .92rem; margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { display: inline-flex; width: auto; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 11px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.3; cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background-color .15s, border-color .15s, box-shadow .15s, transform .08s, color .15s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff !important; box-shadow: 0 1px 2px rgba(49, 46, 129, .4), inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 16px rgba(79, 70, 229, .34), inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn-ghost { background: var(--card); border-color: var(--border-strong); color: var(--text) !important; box-shadow: var(--shadow-xs); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: #dc2626; color: #fff !important; }
.btn-danger:hover { background: #b91c1c; }
.btn-text-danger { background: var(--card); border-color: var(--border-strong); color: var(--neg) !important; }
.btn-text-danger:hover { border-color: var(--neg); background: var(--bad-bg); }
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: .84rem; border-radius: 9px; gap: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.icon-btn { background: none; border: 0; width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; cursor: pointer; color: var(--text-muted); font-size: 1rem; font-family: inherit; flex: none; transition: background-color .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.btn:focus-visible, .icon-btn:focus-visible, .nav-a:focus-visible, .kpi:focus-visible, .tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.theme-toggle.icon-btn { border: 0; padding: 0; background: none; color: var(--text-muted); font-size: 1rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; box-shadow: var(--shadow-xs); }
.card + .card, .card + .tbl-wrap, .tbl-wrap + .card, .stack > * + * { margin-top: 16px; }
.card-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; }
.card-h h3 { font-size: 1.02rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-h h3 .i { color: var(--primary); }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.grid { display: grid; gap: 16px; }
.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)); }
.n { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.neg { color: var(--neg); }
.cur { color: var(--text-muted); font-weight: 500; font-size: .8em; }
.pos { color: #047857; }
[data-theme="dark"] .pos { color: #34d399; }

.kpi { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 3px; color: inherit !important; text-decoration: none; min-width: 0; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s, transform .15s; }
a.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-l { color: var(--text-muted); font-size: .8rem; font-weight: 600; }
.kpi-v { font-size: 1.55rem; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kpi-s { font-size: .78rem; color: var(--text-muted); }
.kpi-ic { position: absolute; top: 14px; inset-inline-end: 14px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.kpi-ic .i { width: 18px; height: 18px; vertical-align: 0; }
.kpi-ic.ok { background: var(--ok-bg); color: var(--ok-fg); }
.kpi-ic.warn { background: var(--warn-bg); color: var(--warn-fg); }
.kpi-ic.bad { background: var(--bad-bg); color: var(--bad-fg); }
.kpi-ic.info { background: var(--info-bg); color: var(--info-fg); }
.kpi-ic.muted { background: var(--muted-bg); color: var(--muted-fg); }
input.inp[type="search"], .pos-search .inp, .pos-cust .inp { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b93ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; background-size: 18px; padding-inline-start: 42px; }
.pos-cust .inp { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b93ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2'/><circle cx='12' cy='7' r='4'/></svg>"); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; line-height: 1.7; }
.badge-ok, .badge-warn, .badge-bad, .badge-muted { padding-inline-start: 8px; }
.badge-ok::before, .badge-warn::before, .badge-bad::before, .badge-muted::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-bad { background: var(--bad-bg); color: var(--bad-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }
.badge-muted { background: var(--muted-bg); color: var(--muted-fg); }

.note { padding: 12px 16px; border-radius: 14px; font-size: .9rem; font-weight: 500; line-height: 1.75; border: 1px solid color-mix(in srgb, currentColor 16%, transparent); }
.note b { font-weight: 700; }
.note-info { background: var(--info-bg); color: var(--info-fg); }
.note-warn { background: var(--warn-bg); color: var(--warn-fg); }
.note-ok { background: var(--ok-bg); color: var(--ok-fg); }
.note-bad { background: var(--bad-bg); color: var(--bad-fg); }
.note a { color: inherit !important; font-weight: 800; }

.empty { text-align: center; padding: 48px 20px; background: var(--card); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-ic { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; line-height: 1; background: var(--primary-soft); color: var(--primary); }
.empty-ic .i { width: 1em; height: 1em; stroke-width: 1.6; vertical-align: 0; }
.empty h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 6px; }
.empty p { color: var(--text-muted); max-width: 440px; margin: 0 auto 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs a, .tabs button { padding: 9px 14px; border: 0; background: none; font: inherit; font-weight: 600; font-size: .92rem; color: var(--text-muted) !important; text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tabs .on { color: var(--primary) !important; border-bottom-color: var(--primary); }

/* ─── الجداول ─── */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-xs); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: start; font-size: .76rem; font-weight: 600; color: var(--text-muted); background: var(--soft); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; letter-spacing: .02em; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr[data-href], .tbl tbody tr[data-i].clickable { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--soft); }
.tbl tbody tr[data-href]:hover td, .tbl tbody tr[data-i].clickable:hover td { background: var(--hover); }
.tbl .num { text-align: end; white-space: nowrap; }
.tbl th.num { text-align: end; }
.tbl tfoot td { font-weight: 700; background: var(--soft); border-top: 2px solid var(--border); }
.tbl .grp td { font-weight: 800; background: var(--soft); }
.tbl .sub-row td { font-size: .85rem; color: var(--text-muted); }
.tbl .strong td { font-weight: 900; }
.tbl .code { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .nowrap { white-space: nowrap; }
.tbl-note { font-size: .82rem; color: var(--text-muted); margin-top: 8px; }
.ind-1 { padding-inline-start: 26px !important; }
.ind-2 { padding-inline-start: 44px !important; }
.ind-3 { padding-inline-start: 62px !important; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .inp { width: auto; min-width: 0; }
.toolbar .grow { flex: 1 1 200px; }
.sum-bar { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 10px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; font-size: .88rem; }
.sum-bar b { font-weight: 700; }

/* ─── النماذج ─── */
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld-l { font-size: .84rem; font-weight: 600; color: var(--text); }
.fld-h { color: var(--text-muted); font-size: .78rem; line-height: 1.5; }
.fld-e { color: var(--neg); font-size: .8rem; font-weight: 700; }
.inp { width: 100%; padding: 9px 13px; min-height: 42px; border: 1px solid var(--border-strong); border-radius: 11px; background: var(--card); color: var(--text); font: inherit; font-size: .95rem; transition: border-color .15s, box-shadow .15s, background-color .15s; }
.inp::placeholder { color: #8b93ad; opacity: 1; }
.inp:hover { border-color: #b3bbd3; }
[data-theme="dark"] .inp:hover { border-color: #46538a; }
select.inp { appearance: none; -webkit-appearance: none; padding-inline-start: 36px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b93ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: left 12px center; background-size: 16px; }
.inp:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }
.inp.has-err { border-color: var(--neg); }
.inp[readonly] { background: var(--soft); }
textarea.inp { min-height: 76px; resize: vertical; line-height: 1.6; }
.inp[data-num] { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px 14px; }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 10; background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); padding: 12px 0; border-top: 1px solid var(--border); margin-top: 16px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > .inp { flex: 1; }

.combo { position: relative; width: 100%; }
.combo-list { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 50; max-height: 280px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 240px; }
.combo-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: .92rem; }
.combo-list li small { color: var(--text-muted); font-size: .78rem; white-space: nowrap; }
.combo-list li.on, .combo-list li:hover { background: var(--hover); }
.combo-list li.none { color: var(--text-muted); cursor: default; background: none; }

/* محرر البنود */
.lines { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.line { display: grid; grid-template-columns: 26px minmax(170px, 3fr) minmax(70px, .8fr) minmax(90px, 1fr) minmax(64px, .7fr) minmax(96px, .9fr) minmax(96px, 1fr) 36px; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.lines.no-tax .line { grid-template-columns: 26px minmax(170px, 3fr) minmax(70px, .8fr) minmax(90px, 1fr) minmax(64px, .7fr) minmax(96px, 1fr) 36px; }
.lines.no-tax .c-tax { display: none; }
.line-h { font-size: .76rem; font-weight: 800; color: var(--text-muted); background: var(--soft); border-radius: var(--radius) var(--radius) 0 0; }
.line .inp { min-height: 36px; padding: 6px 9px; font-size: .92rem; }
.c-idx { color: var(--text-muted); font-size: .8rem; text-align: center; }
.c-tot { text-align: end; font-weight: 800; white-space: nowrap; }
.c-sub { display: block; font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.c-desc .fld-e { display: block; margin-top: 2px; }
.adj-line { display: grid; grid-template-columns: minmax(170px, 2.2fr) minmax(70px, .7fr) minmax(96px, .9fr) minmax(96px, .9fr) minmax(104px, 1fr) 36px; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.adj-line .inp { min-height: 36px; padding: 6px 9px; }
.adj-line:last-child { border-bottom: 0; }
.jl-line { display: grid; grid-template-columns: minmax(200px, 2.4fr) minmax(100px, 1fr) minmax(100px, 1fr) minmax(120px, 1.4fr) 36px; gap: 8px; align-items: start; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.jl-line .inp { min-height: 36px; padding: 6px 9px; }
.jl-line:last-child { border-bottom: 0; }
.lines-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 10px; }
.doc-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 14px; margin-top: 14px; align-items: start; }
.totals { display: grid; gap: 7px; }
.totals .row { display: flex; justify-content: space-between; gap: 16px; font-size: .93rem; }
.totals .grand { font-size: 1.15rem; font-weight: 900; padding-top: 9px; border-top: 2px solid var(--border); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--soft); border: 1px solid var(--border); border-radius: 12px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; font: inherit; font-weight: 600; font-size: .88rem; color: var(--text-muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ─── نوافذ وإشعارات ─── */
.dlg { margin: auto; border: 0; padding: 0; border-radius: 22px; background: var(--card); color: var(--text); width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: var(--shadow-lg); overflow: hidden; }
.dlg-wide { width: min(780px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(12, 16, 36, .52); backdrop-filter: blur(3px); }
.dlg-box { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 8px 12px; }
.dlg-head h2 { font-size: 1.1rem; font-weight: 700; padding-inline-start: 8px; }
.dlg-body { padding: 6px 22px 22px; overflow-y: auto; }
.dlg-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.dlg-msg { line-height: 1.8; }
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 8px; background: #15192e; color: #fff; padding: 11px 18px; border-radius: 14px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg); transition: opacity .3s, transform .3s; text-align: center; }
.toast-err { background: #b91c1c; }
.toast-warn { background: #b45309; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* الكاميرا والباركود */
.cam-box { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; }
.cam-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-line { position: absolute; inset-inline: 12%; top: 50%; height: 2px; background: #ef4444; box-shadow: 0 0 10px #ef4444; }
.bc { background: #fff; padding: 6px; border-radius: 8px; display: inline-block; }
.bc svg { width: 220px; height: 64px; display: block; }

/* الوحدات المتعددة */
.line .unit-sel { margin-top: 4px; min-height: 30px; padding: 3px 6px; font-size: .8rem; }
.unit-rows { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.unit-row { display: grid; grid-template-columns: minmax(110px, 1.3fr) minmax(70px, .7fr) minmax(90px, .9fr) minmax(130px, 1.2fr) 36px; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.unit-row:last-child { border-bottom: 0; }
.unit-row .inp { min-height: 36px; padding: 6px 9px; }
@media (max-width: 560px) { .unit-row { grid-template-columns: 1fr 1fr 36px; } .unit-row.line-h { display: none; } .unit-row [data-uk="price"], .unit-row [data-uk="barcode"] { grid-column: span 1; } }
/* الدفعات: صفوف دفعات الرصيد الافتتاحي في بطاقة المنتج، وسطر الدفعة تحت بنود الفواتير والتسوية */
.lot-rows { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.lot-row { display: grid; grid-template-columns: minmax(120px, 1.4fr) minmax(130px, 1.1fr) minmax(80px, .7fr) 36px; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.lot-row:last-child { border-bottom: 0; }
.lot-row .inp { min-height: 36px; padding: 6px 9px; }
.lot-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.lot-line .inp { min-height: 34px; padding: 4px 8px; font-size: .85rem; width: auto; max-width: 100%; }
.lot-line .lot-n { width: 11rem; }
.lot-line .lot-d { width: 9.5rem; }
.a-lot { grid-column: 1 / -1; }
/* الأرقام التسلسلية: مربع الأرقام تحت بند الفاتورة أو التسوية مع عدّاد واختيار من المتوفر */
.serial-line { margin-top: 6px; }
.serial-line textarea.inp { min-height: 56px; padding: 6px 9px; font-size: .85rem; resize: vertical; }
.serial-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 4px; }
.serial-meta .c-sub { margin-top: 0; }
.serial-meta .inp { width: auto; max-width: 100%; min-height: 32px; padding: 3px 8px; font-size: .82rem; }
@media (max-width: 560px) { .lot-row { grid-template-columns: 1fr 1fr 36px; } .lot-row.line-h { display: none; } .lot-row [data-olk="lot"] { grid-column: 1 / -1; } .lot-line .lot-n, .lot-line .lot-d, .lot-line select.inp { flex: 1 1 8rem; width: auto; } }

/* مسير الرواتب والتحويلات المخزنية */
.pay-tbl td { padding: 6px 6px; }
.pay-tbl .pay-inp { min-width: 76px; width: 100%; min-height: 34px; padding: 5px 7px; font-size: .88rem; }
.pay-tbl tfoot td { white-space: nowrap; }
.tr-line { grid-template-columns: minmax(170px, 2.4fr) minmax(90px, .8fr) minmax(100px, .9fr) 36px; }
@media (max-width: 760px) { .tr-line { grid-template-columns: repeat(2, minmax(0, 1fr)) 36px; grid-template-areas: "p p del" "cur act act"; } }
.paper.slip { break-after: page; margin-bottom: 18px; }
.paper.slip:last-child { break-after: auto; }
.paper.slip .grid { gap: 12px; }

/* ─── الكاشير (نقطة البيع) ─── */
.pos-screen { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 14px; align-items: start; }
.pos-products { min-width: 0; }
.pos-search { display: flex; gap: 8px; margin-bottom: 10px; }
.pos-search .inp { flex: 1; font-size: 1.02rem; min-height: 46px; }
.pos-cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.chip { border: 1px solid var(--border-strong); background: var(--card); color: var(--text); border-radius: 999px; padding: 5px 14px; font: inherit; font-weight: 600; font-size: .85rem; cursor: pointer; white-space: nowrap; transition: border-color .15s, background-color .15s; }
.chip:hover { border-color: var(--primary); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.pos-tile { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: start; padding: 12px 14px; min-height: 92px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); color: var(--text); font: inherit; cursor: pointer; box-shadow: var(--shadow-xs); transition: border-color .15s, transform .1s, box-shadow .15s; }
.pos-tile:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.pos-tile:active { transform: scale(.97); }
.pos-tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pos-tile .t-n { font-weight: 700; font-size: .9rem; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pos-tile .t-p { font-weight: 700; color: var(--primary); margin-top: auto; font-variant-numeric: tabular-nums; }
.pos-tile .t-s { font-size: .72rem; color: var(--text-muted); }
.pos-tile.out { opacity: .65; }
.pos-tile.out .t-s { color: var(--neg); font-weight: 700; }
.pos-tile.hit { animation: pos-hit .35s ease; }
@keyframes pos-hit { 0% { box-shadow: 0 0 0 0 var(--focus); } 50% { box-shadow: 0 0 0 6px var(--focus); } 100% { box-shadow: 0 0 0 0 transparent; } }
.pos-cart { position: sticky; top: 70px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100dvh - 90px); min-width: 0; }
.pos-cust { padding: 10px; border-bottom: 1px solid var(--border); }
.pos-lines { flex: 1; overflow-y: auto; min-height: 110px; }
.pos-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 30px; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.pl-name { background: none; border: 0; text-align: start; font: inherit; font-weight: 700; font-size: .9rem; color: var(--text); cursor: pointer; padding: 0; min-width: 0; overflow-wrap: anywhere; }
.pl-name small { display: block; font-weight: 600; font-size: .75rem; }
.pl-qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.pl-qty button { width: 30px; height: 30px; border: 0; background: var(--soft); color: var(--text); font: inherit; font-weight: 900; cursor: pointer; }
.pl-qty span { min-width: 30px; text-align: center; font-weight: 800; font-size: .9rem; font-variant-numeric: tabular-nums; }
.pl-tot { font-weight: 800; white-space: nowrap; font-size: .9rem; }
.pos-line .icon-btn { width: 30px; height: 30px; }
.pos-empty { text-align: center; color: var(--text-muted); padding: 28px 10px; font-size: .9rem; line-height: 2; }
.pos-totals { padding: 10px 12px; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.pos-totals .row { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.pos-totals .grand { font-size: 1.3rem; font-weight: 900; }
.pos-disc { display: flex; justify-content: flex-start; }

/* ─── الأقساط: نموذج الفاتورة وصفحتها وورقتها المطبوعة ─── */
.inst-gen { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 8px; align-items: end; margin-bottom: 12px; }
.inst-n { color: var(--text-muted); font-size: .8rem; text-align: center; }
.inst-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 8px; align-items: center; margin-bottom: 6px; }
.inst-sum { margin: 10px 0; font-size: .9rem; }
.inst-sum.ok { color: var(--ok-fg); font-weight: 700; }
.inst-sum.neg { color: var(--neg); font-weight: 700; }
@media (max-width: 520px) { .inst-gen { grid-template-columns: 1fr 1fr; } .inst-row { grid-template-columns: 22px minmax(0, 1.5fr) minmax(0, 1fr) 30px; gap: 6px; } }
.pp-inst { margin-top: 10px; font-size: .85em; }
.pp-inst h4 { margin-bottom: 4px; }
.pp-inst table { width: 100%; border-collapse: collapse; }
.pp-inst td { padding: 2px 6px; border-bottom: 1px solid #e5e7eb; }
.pos-actions { padding: 10px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.pos-pay { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border: 0; border-radius: 12px; font: inherit; font-weight: 900; font-size: 1.05rem; color: #fff; cursor: pointer; transition: filter .15s; }
.pos-pay:hover { filter: brightness(1.08); }
.pos-pay small { opacity: .75; font-size: .75rem; }
.pos-cash { background: #047857; }
.pos-card { background: var(--primary); }
.pos-pay:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.pos-pay:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pos-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pos-row > * { flex: 1 1 auto; }
.pos-bar { display: none; }
.pos-due, .pos-change { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--soft); border: 1px solid var(--border); font-weight: 700; margin-bottom: 12px; }
.pos-change { margin: 12px 0 0; }
.pos-due b, .pos-change b { font-size: 1.45rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.pos-change b.neg { color: var(--neg); }
.pos-big { font-size: 1.4rem !important; font-weight: 800; min-height: 52px !important; }
.pos-notes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@media (max-width: 900px) {
  .pos-screen { grid-template-columns: minmax(0, 1fr); }
  .pos-cart { position: static; max-height: none; }
  .pos-bar { display: flex; position: sticky; bottom: 0; z-index: 20; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
}

/* ─── شاشة القفل ─── */
dialog.lock { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 16px; border: 0; background: var(--bg); color: var(--text); display: grid; place-items: center; overflow-y: auto; }
dialog.lock:not([open]) { display: none; }
dialog.lock::backdrop { background: var(--bg); }
.lock-box { width: min(400px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 22px 20px; display: grid; gap: 14px; text-align: center; }
.lock-box h2 { font-size: 1.1rem; font-weight: 900; }
.lock-brand { display: flex; align-items: center; justify-content: center; gap: 10px; text-align: start; }
.lock-brand b { display: block; font-size: 1.05rem; font-weight: 900; }
.lock-brand small { color: var(--text-muted); font-weight: 700; font-size: .78rem; }
.lock-users { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.lock-user { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border: 1.5px solid var(--border); border-radius: 999px; background: var(--card); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; text-align: start; }
.lock-user small { display: block; font-size: .72rem; color: var(--text-muted); font-weight: 600; line-height: 1.2; }
.lock-user.on { border-color: var(--primary); background: var(--info-bg); }
.lock-user .av { width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: .85rem; flex: none; }
.lock-l { font-weight: 700; font-size: .9rem; display: block; margin-bottom: 6px; }
.lock-pin, .lock-code { text-align: center; font-size: 1.5rem; letter-spacing: .35em; font-weight: 900; min-height: 52px; }
.lock-code { letter-spacing: .12em; font-size: 1.15rem; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.pad button { height: 52px; border: 1px solid var(--border); border-radius: 12px; background: var(--soft); color: var(--text); font: inherit; font-size: 1.3rem; font-weight: 800; cursor: pointer; }
.pad button:active { background: var(--hover); transform: scale(.97); }
.lock-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.lock-actions .btn { flex: 1; }
.lock-forgot { background: none; border: 0; color: var(--text-muted); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; text-decoration: underline; }
.lock-msg:empty { display: none; }
.recovery-code { margin-top: 12px; padding: 14px; text-align: center; font-size: 1.5rem; font-weight: 900; letter-spacing: .12em; border: 2px dashed var(--primary); border-radius: 12px; background: var(--soft); font-family: ui-monospace, Menlo, Consolas, monospace; user-select: all; }
#lock-btn { font-weight: 800; }
/* الكاشير لا يرى أزرار التعديل والحذف في صفحات المستندات */
html[data-role="cashier"] .page-head [data-del], html[data-role="cashier"] .page-head a[href$="/edit"] { display: none !important; }

/* ─── لوحة التحكم والترحيب ─── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; color: var(--text) !important; text-decoration: none; font-weight: 600; font-size: .92rem; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s, transform .15s; }
.tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tile .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; font-size: 1.2rem; background: var(--primary-soft); color: var(--primary); }
.tile .ic .i { width: 20px; height: 20px; vertical-align: 0; }
.list-mini { display: grid; }
.list-mini a, .list-mini .it { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--border); color: var(--text) !important; text-decoration: none; font-size: .9rem; }
.list-mini a:last-child, .list-mini .it:last-child { border-bottom: 0; }
.list-mini a:hover { color: var(--primary) !important; }
.list-mini .meta { color: var(--text-muted); font-size: .8rem; }
.acc { --series-1: #2a78d6; --series-2: #eb6834; }
[data-theme="dark"] .acc { --series-1: #3987e5; --series-2: #d95926; }
.chart { display: block; direction: rtl; overflow: visible; }
.chart text { font-family: var(--font); }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .base { stroke: var(--text-muted); stroke-opacity: .55; stroke-width: 1; }
.chart .ax { fill: var(--text-muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .hit { fill: transparent; }
.chart .bandg { outline: none; }
.chart .bandg.on .hit, .chart .bandg:focus-visible .hit { fill: var(--hover); }
.chart .bandg.on path { filter: brightness(1.1); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--text-muted); font-weight: 700; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }
.legend .sw-s1 { background: var(--series-1); }
.legend .sw-s2 { background: var(--series-2); }
.chart-tip { position: absolute; top: 0; z-index: 5; min-width: 170px; padding: 8px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .82rem; pointer-events: none; }
.tip-t { font-weight: 800; margin-bottom: 4px; }
.tip-r { display: flex; align-items: center; gap: 8px; line-height: 1.8; }
.tip-r b { font-weight: 800; font-variant-numeric: tabular-nums; }
.tip-r span { color: var(--text-muted); }
.tip-r i { display: inline-block; width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tip-r .key-s1 { background: var(--series-1); }
.tip-r .key-s2 { background: var(--series-2); }
.tip-r .key-none { background: transparent; }

.welcome { max-width: 1000px; margin: 0 auto; }
.hero-acc { text-align: center; padding: 48px 16px 30px; position: relative; isolation: isolate; }
.hero-acc::before { content: ''; position: absolute; inset: 0 6% auto; height: 260px; z-index: -1; background: radial-gradient(60% 100% at 50% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent); pointer-events: none; }
.hero-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 14px 34px rgba(67, 56, 202, .35); }
.hero-acc .ic { font-size: 3rem; line-height: 1; }
.hero-acc h1 { font-size: clamp(1.7rem, 4.2vw, 2.6rem); font-weight: 700; letter-spacing: -.01em; line-height: 1.35; margin: 16px 0 10px; }
.hero-acc p { color: var(--text-muted); font-size: 1.05rem; max-width: 640px; margin: 0 auto; line-height: 1.8; }
.hero-acc .actions { justify-content: center; margin-top: 20px; }
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 10px 0 20px; }
.feature { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-xs); }
.feature b { display: block; font-size: 1rem; margin: 6px 0 4px; }
.feature p { color: var(--text-muted); font-size: .88rem; line-height: 1.7; }
.feature .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; background: var(--primary-soft); color: var(--primary); margin-bottom: 4px; }
.feature .ic .i { width: 22px; height: 22px; vertical-align: 0; }

/* ─── معاينة المستند (ورقة بيضاء دائماً) ─── */
.paper-wrap { overflow-x: auto; }
.paper { background: #fff; color: #111827; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); padding: 30px; max-width: 840px; margin: 0 auto; font-size: 13px; line-height: 1.6; }
.paper * { color: inherit; }
.paper .muted { color: #6b7280; }
.pp-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 14px; border-bottom: 3px solid #4f46e5; }
.pp-co { display: flex; gap: 12px; align-items: flex-start; }
.pp-co img { max-width: 90px; max-height: 70px; object-fit: contain; }
.pp-co h2 { font-size: 18px; font-weight: 900; margin: 0 0 2px; }
.pp-title { text-align: end; }
.pp-title h1 { font-size: 20px; font-weight: 900; color: #4f46e5; margin: 0; }
.pp-title .en { font-size: 11px; color: #6b7280; letter-spacing: .5px; }
.pp-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; margin: 14px 0; padding: 10px 12px; background: #f8fafc; border-radius: 8px; }
.pp-meta > div > span { display: block; font-size: 11px; color: #6b7280; }
.pp-meta > div > b { font-weight: 800; }
.pp-party { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; margin-bottom: 12px; }
.pp-party h2 { font-size: 12px; color: #6b7280; margin: 0 0 2px; font-weight: 700; }
.pp-party .nm { font-size: 15px; font-weight: 800; }
.pp-lines { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.pp-lines th { background: #eef2ff; color: #3730a3; font-weight: 800; padding: 7px 6px; text-align: start; border-bottom: 2px solid #c7d2fe; white-space: nowrap; }
.pp-lines td { padding: 7px 6px; border-bottom: 1px solid #e5e7eb; vertical-align: top; }
.pp-lines .num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pp-bottom { display: grid; grid-template-columns: 1fr minmax(240px, 300px); gap: 20px; margin-top: 10px; align-items: start; }
.pp-totals { display: grid; gap: 4px; }
.pp-totals div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.pp-totals .grand { font-size: 15px; font-weight: 900; border-top: 2px solid #111827; padding-top: 6px; margin-top: 2px; }
.pp-words { margin-top: 8px; padding: 8px 10px; background: #f8fafc; border-radius: 8px; font-weight: 700; font-size: 12px; }
.pp-qr { display: flex; gap: 12px; align-items: center; }
.pp-qr svg { width: 120px; height: 120px; flex: none; }
.pp-note { margin-top: 14px; font-size: 12px; color: #374151; white-space: pre-line; }
.pp-foot { margin-top: 22px; padding-top: 10px; border-top: 1px solid #e5e7eb; display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: #6b7280; }
.pp-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 34px; text-align: center; font-size: 12px; }
.pp-sign div { border-top: 1px dashed #9ca3af; padding-top: 6px; color: #374151; }
.pp-stamp { display: inline-block; padding: 3px 12px; border: 2px solid; border-radius: 8px; font-weight: 900; font-size: 13px; transform: rotate(-4deg); }
.pp-stamp.paid { color: #047857; }
.pp-stamp.due { color: #dc2626; }
.pp-box { border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px; }
.pp-amount { font-size: 22px; font-weight: 900; color: #4f46e5; }
.pp-report h1 { font-size: 18px; }
.pp-report .tbl { font-size: 11.5px; }
.pp-report .tbl th { background: #eef2ff; color: #3730a3; }
.pp-report .tbl td, .pp-report .tbl th { padding: 5px 7px; border-color: #e5e7eb; }
.pp-report .tbl .grp td, .pp-report .tbl tfoot td { background: #f8fafc; }

/* الفاتورة ثنائية اللغة: الإنجليزي سطر صغير تحت العربي */
.paper .pp-en { display: block; font-style: normal; font-size: .8em; font-weight: 600; color: #6b7280; line-height: 1.25; }
.paper .pp-lot { display: block; font-style: normal; font-size: .76em; font-weight: 500; color: #6b7280; line-height: 1.25; }
.pp-lines th .pp-en { color: #4f46e5; }
.receipt .pp-lines th .pp-en { color: #374151; }
.pp-en-name { font-weight: 700; }
.pp-totals .grand .pp-en { font-size: .6em; }

/* إيصال حراري 80 مم */
.paper.receipt { max-width: 80mm; padding: 10px; font-size: 11px; box-shadow: none; }
.paper.receipt.r58 { max-width: 58mm; padding: 6px; font-size: 10px; }
.receipt.r58 .pp-title h1 { font-size: 12px; }
.receipt.r58 .pp-meta { grid-template-columns: 1fr; }
.receipt.r58 .pp-lines th, .receipt.r58 .pp-lines td { padding: 3px 1px; }
.receipt.r58 .pp-qr svg { width: 88px; height: 88px; }
.receipt .pp-head { flex-direction: column; align-items: center; text-align: center; border-bottom: 1px dashed #111827; gap: 6px; }
.receipt .pp-co { flex-direction: column; align-items: center; }
.receipt .pp-title { text-align: center; }
.receipt .pp-title h1 { font-size: 14px; color: #111827; }
.receipt .pp-meta { grid-template-columns: 1fr 1fr; background: none; padding: 6px 0; border-bottom: 1px dashed #111827; border-radius: 0; margin: 6px 0; }
.receipt .pp-lines th { background: none; color: #111827; border-bottom: 1px solid #111827; padding: 4px 2px; }
.receipt .pp-lines td { padding: 4px 2px; }
.receipt .pp-bottom { grid-template-columns: 1fr; }
.receipt .pp-qr { flex-direction: column; }
.receipt .pp-qr svg { width: 110px; height: 110px; }

.labels { display: grid; direction: rtl; }
.labels .lbl { background: #fff; color: #000; text-align: center; overflow: hidden; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1mm; break-inside: avoid; font-family: var(--font); }
.labels .lbl-n { font-size: 9pt; font-weight: 700; line-height: 1.2; max-height: 2.4em; overflow: hidden; }
.labels .lbl-b svg { width: 100%; height: 12mm; display: block; }
.labels .lbl-p { font-size: 9pt; font-weight: 800; }
.lbl-a4 { display: block; width: 210mm; }
.lbl-a4 .label-sheet { display: grid; grid-template-columns: repeat(3, 70mm); grid-auto-rows: 37mm; width: 210mm; height: 296mm; }
.lbl-a4 .lbl { padding: 2mm 4mm; }
.lbl-a4 .lbl-b { width: 58mm; }
.labels .label-sheet { break-after: page; page-break-after: always; }
.labels .label-sheet:last-child { break-after: auto; page-break-after: auto; }
.lbl-roll { display: block; width: var(--label-width); }
.lbl-roll .label-sheet { width: var(--label-width); height: var(--label-height); overflow: hidden; }
.lbl-roll .lbl { width: var(--label-width); height: var(--label-height); padding: 1mm 2mm; gap: .5mm; box-sizing: border-box; }
.lbl-roll .lbl-b { width: 100%; min-width: 0; flex: 0 1 auto; min-height: 0; }
.lbl-roll .lbl-b svg { width: 100%; height: 10mm; max-height: 100%; }
.lbl-roll .lbl-n { font-size: 7pt; max-height: 1.2em; flex: 0 0 auto; }
.lbl-roll .lbl-p { font-size: 7pt; line-height: 1.2; flex: 0 0 auto; }
#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; }
  body.printing { background: #fff !important; }
  #print-area .paper { box-shadow: none; border: 0; border-radius: 0; padding: 0; max-width: none; margin: 0; }
  #print-area .paper.receipt { max-width: 74mm; }
  #print-area .paper.receipt.r58 { max-width: 54mm; }
  #print-area .pp-lines th, #print-area .pp-meta, #print-area .pp-words { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-area .tbl-wrap { border: 0; overflow: visible; }
  #print-area tr { break-inside: avoid; }
}

/* ─── البحث السريع (Ctrl+K) وورقة «جديد» والشريط السفلي ─── */
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--card); color: var(--text-muted); font: inherit; font-size: .72rem; font-weight: 600; line-height: 1.5; text-align: center; direction: ltr; }
.search-pill { display: inline-flex; align-items: center; gap: 10px; min-width: 250px; height: 38px; padding: 0 8px 0 12px; border: 1px solid var(--border-strong); border-radius: 11px; background: var(--card); color: var(--text-muted); font: inherit; font-size: .88rem; cursor: pointer; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s, color .15s; }
.search-pill[hidden] { display: none; }
.search-pill:hover { border-color: var(--primary); color: var(--text); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-pill:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.search-pill .i { width: 17px; height: 17px; vertical-align: 0; }
.sp-ic { display: inline-grid; place-items: center; flex: none; }
.sp-t { flex: 1; text-align: start; white-space: nowrap; }
.sp-k { flex: none; }

dialog.pal { position: fixed; inset: 0; margin: 11vh auto auto; width: min(640px, calc(100vw - 24px)); max-width: none; max-height: none; padding: 0; border: 0; background: transparent; color: var(--text); overflow: visible; }
dialog.pal::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.pal-box { background: var(--card); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; }
.pal-in { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.pal-in > .i { width: 20px; height: 20px; flex: none; vertical-align: 0; }
.pal-input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; font-size: 1.05rem; color: var(--text); padding: 4px 0; }
.pal-input::placeholder { color: var(--text-muted); opacity: .8; }
.pal-list { max-height: min(54vh, 460px); overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.pal-g { padding: 10px 12px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: var(--text-muted); }
.pal-row { display: flex; width: 100%; align-items: center; gap: 12px; padding: 8px 10px; border: 0; border-radius: 12px; background: none; font: inherit; color: var(--text); text-align: start; cursor: pointer; }
.pal-row.on { background: var(--primary-soft); }
.pal-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--soft); color: var(--text-muted); flex: none; transition: background-color .12s, color .12s; }
.pal-ic .i { width: 18px; height: 18px; vertical-align: 0; }
.pal-row.on .pal-ic { background: var(--primary); color: #fff; }
.pal-t { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: .94rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-sub { flex: 0 1 auto; min-width: 0; color: var(--text-muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-k { flex: none; color: var(--primary); font-weight: 700; opacity: 0; }
.pal-row.on .pal-k { opacity: 1; }
.pal-none { padding: 30px 16px; text-align: center; color: var(--text-muted); }
.pal-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 18px; border-top: 1px solid var(--border); background: var(--soft); color: var(--text-muted); font-size: .76rem; }
.pal-foot kbd { margin-inline: 1px; }
.kk { display: inline-flex; direction: ltr; gap: 2px; margin-inline-end: 4px; vertical-align: middle; }

dialog.sheet { position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 560px; max-height: 90dvh; padding: 0; border: 0; background: transparent; color: var(--text); overflow: auto; }
dialog.sheet::backdrop { background: rgba(15, 23, 42, .5); }
.sheet-box { background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); }
.sheet-grip { width: 42px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 4px auto 14px; }
.sheet-box h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; }
.sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sheet-a { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px; padding: 14px 6px 12px; border-radius: 16px; background: var(--soft); border: 1px solid var(--border); color: var(--text) !important; text-decoration: none; font-weight: 600; font-size: .8rem; text-align: center; line-height: 1.4; }
.sheet-a:active { background: var(--primary-soft); }
.sheet-ic { width: 42px; height: 42px; border-radius: 13px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.sheet-ic .i { width: 21px; height: 21px; vertical-align: 0; }
[data-theme="dark"] .sheet-ic { color: #c7d2fe; }

.tabbar { display: none; }
@media (max-width: 960px) {
  .quick { display: none; } /* على الجوال زر «+» في الشريط السفلي يغني عنها */
  .search-pill { min-width: 0; width: 38px; padding: 0; justify-content: center; border-color: transparent; background: none; box-shadow: none; }
  .search-pill:hover { box-shadow: none; background: var(--hover); }
  .search-pill .sp-t, .search-pill .sp-k { display: none; }
  .search-pill .i { width: 20px; height: 20px; }
  .tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 45; display: flex; align-items: stretch; justify-content: space-around; gap: 2px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--card); background: color-mix(in srgb, var(--card) 90%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); border-top: 1px solid var(--border); box-shadow: 0 -8px 26px rgba(15, 23, 42, .07); }
  .tabbar[hidden], body.no-tabbar .tabbar { display: none; }
  .tab { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 4px 2px 2px; border: 0; background: none; border-radius: 14px; color: var(--text-muted) !important; text-decoration: none; font: inherit; font-size: .7rem; font-weight: 600; line-height: 1.2; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tab:focus-visible { outline: 3px solid var(--focus); outline-offset: -2px; }
  .tab-ic { display: grid; place-items: center; width: 54px; height: 30px; border-radius: 15px; transition: background-color .15s, color .15s; }
  .tab .i { width: 22px; height: 22px; vertical-align: 0; }
  .tab.on { color: var(--primary) !important; }
  [data-theme="dark"] .tab.on { color: #c7d2fe !important; }
  .tab.on .tab-ic { background: var(--primary-soft); }
  .tab-add { flex: 0 0 76px; justify-content: flex-start; padding-top: 0; }
  .tab-plus { display: grid; place-items: center; width: 54px; height: 54px; margin-top: -24px; border-radius: 50%; background: var(--primary); color: #fff; box-shadow: 0 8px 20px rgba(79, 70, 229, .45), 0 0 0 5px var(--bg); transition: transform .12s, background-color .15s; }
  .tab-add:active .tab-plus { transform: scale(.94); background: var(--primary-dark); }
  .tab-plus .i { width: 26px; height: 26px; }
  body:not(.no-tabbar) .view { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body:not(.no-tabbar) #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  dialog.pal { margin-top: 8vh; }
  .pal-foot, .pal-in kbd { display: none; }
  .pal-sub { max-width: 40%; }
}

/* ─── الجوال ─── */
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; top: 0; bottom: 0; right: 0; width: 282px; max-width: 86vw; z-index: 60; transform: translateX(105%); transition: transform .22s ease; box-shadow: var(--shadow-lg); border: 0; }
  .app.nav-open .side { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 55; }
  .menu-btn { display: inline-grid !important; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-bottom { grid-template-columns: minmax(0, 1fr); }
  .doc-bottom > [data-totals] { order: -1; }
}
@media (max-width: 760px) {
  .line-h { display: none; }
  .line, .lines.no-tax .line { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-areas: "desc desc desc del" "qty price disc tax" "tot tot tot tot"; row-gap: 6px; }
  .lines.no-tax .line { grid-template-areas: "desc desc desc del" "qty price disc disc" "tot tot tot tot"; }
  .c-idx { display: none; }
  .c-desc { grid-area: desc; } .c-qty { grid-area: qty; } .c-price { grid-area: price; } .c-disc { grid-area: disc; }
  .c-tax { grid-area: tax; } .c-tot { grid-area: tot; text-align: start; } .c-del { grid-area: del; justify-self: end; }
  .adj-line { grid-template-columns: repeat(3, minmax(0, 1fr)) 36px; grid-template-areas: "p p p del" "cur act delta delta" "cost cost cost cost"; row-gap: 6px; }
  .a-p { grid-area: p; } .a-cur { grid-area: cur; } .a-act { grid-area: act; } .a-delta { grid-area: delta; } .a-cost { grid-area: cost; } .a-del { grid-area: del; justify-self: end; }
  .adj-line [data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; }
  .jl-line { grid-template-columns: repeat(2, minmax(0, 1fr)) 36px; grid-template-areas: "acc acc del" "dr cr cr" "memo memo memo"; row-gap: 6px; }
  .j-acc { grid-area: acc; } .j-dr { grid-area: dr; } .j-cr { grid-area: cr; } .j-memo { grid-area: memo; } .j-del { grid-area: del; justify-self: end; }
  .jl-line [data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; }
  .line [data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; }
  .pp-bottom, .pp-party { grid-template-columns: 1fr; }
  .paper { padding: 16px; }
}
@media (max-width: 560px) {
  .view { padding: 12px 12px 24px; }
  .topbar { padding: 8px 12px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .page-head h2 { font-size: 1.2rem; }
  .kpi-v { font-size: 1.2rem; }
  .hide-sm { display: none; }
  .tbl { font-size: .85rem; }
  .tbl td, .tbl th { padding: 8px 9px; }
  .pp-head { flex-direction: column; }
  .pp-title { text-align: start; }
  .pp-lines { font-size: 11px; }
  .pp-lines th, .pp-lines td { padding: 5px 3px; }
  .pp-lines th { white-space: normal; }
  .pp-lines .c-n, .pp-lines .c-net, .pp-lines .rate { display: none; }
  .quick-menu { position: fixed; top: 58px; left: 12px; right: 12px; inset-inline-end: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .acc *, .acc *::before { transition: none !important; animation: none !important; }
}

/* ─── المرفقات ─── */
.att-card { margin-top: 14px; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.att { position: relative; min-width: 0; }
.att-open { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--soft); cursor: pointer; color: inherit; font: inherit; text-align: center; }
.att-open:hover { border-color: var(--primary); }
.att-open img { width: 100%; height: 96px; object-fit: cover; border-radius: 8px; background: #fff; }
.att-ic { display: grid; place-items: center; height: 96px; font-size: 40px; }
.att-open small { font-size: .72rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-del { position: absolute; top: 2px; inset-inline-end: 2px; width: 28px; height: 28px; background: var(--card); box-shadow: var(--shadow-sm); }
.att-missing .att-open img { opacity: .25; }
.att-view { text-align: center; }
.att-view img { max-width: 100%; max-height: 70dvh; border-radius: 10px; }

/* ─── قراءة الإيصال ─── */
.scan-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.scan-video video { width: 100%; max-height: 52dvh; border-radius: 12px; background: #000; object-fit: cover; display: block; }
.scan-row { display: flex; gap: 14px; align-items: center; }
.scan-prev { width: 92px; height: 124px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); flex: none; background: #fff; }
.scan-bar { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; margin-top: 8px; }
.scan-bar i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .3s; }
.scan-bar i.busy { width: 30%; transition: none; animation: scan-busy 1.2s ease-in-out infinite; }
@keyframes scan-busy { from { margin-inline-start: -30%; } to { margin-inline-start: 100%; } }
.scan-tbl th { width: 40%; color: var(--text-muted); font-weight: 600; text-align: start; background: none; }
.scan-text { white-space: pre-wrap; font-family: inherit; font-size: .8rem; max-height: 200px; overflow: auto; background: var(--soft); padding: 10px; border-radius: 10px; margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { .scan-bar i.busy { animation: none; width: 100%; opacity: .5; } }
.side-install { width: calc(100% - 24px); margin: 0 12px 10px; }

/* ─── ملخص اليوم ─── */
.seg a { padding: 6px 12px; border-radius: 9px; font-weight: 600; font-size: .88rem; color: var(--text-muted); text-decoration: none; }
.seg a.on { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }
.today-tabs { margin-bottom: 14px; }
.today-hint { margin-bottom: 14px; }
.today-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 14px; }
.today-grid .today-card { margin-top: 0; }
.today-wide { grid-column: 1 / -1; }
.today-card { transition: box-shadow .2s, border-color .2s; }
.today-card.speaking { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.today-ic { font-size: 1.15rem; margin-inline-end: 4px; }
.today-text { line-height: 2; font-size: .98rem; }
.today-foot { margin-top: 14px; }
.today-teaser .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn.speaking { animation: today-pulse 1.4s ease-in-out infinite; }
@keyframes today-pulse { 50% { opacity: .75; } }
@media (prefers-reduced-motion: reduce) { .btn.speaking { animation: none; } }
@media (max-width: 560px) { .today-wide .list-mini a { flex-direction: column; align-items: flex-start; gap: 3px; } }

/* ─── الاشتراك والميزات المقفلة ─── */
.nav-a.locked { opacity: .62; }
.nav-a .lk { margin-inline-start: auto; font-size: .76rem; }
.lock-page { padding-block: 40px; }
.lock-page .actions { justify-content: center; }
.sub-hero { --tone: var(--primary); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 32px; align-items: center; padding: 24px 26px; border-radius: var(--radius-lg); position: relative; overflow: hidden; border-color: color-mix(in srgb, var(--tone) 38%, var(--border)); }
.sub-hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(70% 150% at 100% 0%, color-mix(in srgb, var(--tone) 13%, transparent), transparent 70%); pointer-events: none; }
.sub-hero > * { position: relative; }
.sub-hero.tone-ok { --tone: #10b981; }
.sub-hero.tone-warn { --tone: #f59e0b; }
.sub-hero.tone-bad { --tone: #ef4444; }
.sub-hero.tone-info { --tone: var(--primary); }
.sub-hero-main { display: flex; gap: 16px; align-items: center; min-width: 0; }
.sub-ic { width: 56px; height: 56px; border-radius: 17px; display: grid; place-items: center; flex: none; color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, var(--card)); }
.sub-ic .i { width: 28px; height: 28px; vertical-align: 0; stroke-width: 1.6; }
.sub-kicker { font-size: .78rem; font-weight: 600; color: var(--text-muted); }
.sub-plan { font-size: 1.5rem; font-weight: 700; line-height: 1.35; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.sub-line { color: var(--text-muted); font-size: .92rem; margin-top: 4px; line-height: 1.7; }
.sub-hero-side { min-width: 220px; text-align: center; }
.sub-days b { display: block; font-size: 2.6rem; font-weight: 700; line-height: 1.1; color: var(--tone); letter-spacing: -.02em; }
.sub-days span { display: block; font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
.sub-meter { height: 8px; border-radius: 99px; background: var(--muted-bg); margin-top: 14px; overflow: hidden; }
.sub-meter span { display: block; height: 100%; border-radius: 99px; background: var(--tone); }
.sub-hero-actions { grid-column: 1 / -1; }
.sub-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; margin-top: 16px; align-items: start; }
@media (max-width: 760px) { .sub-hero { grid-template-columns: minmax(0, 1fr); padding: 20px 18px; } .sub-hero-side { text-align: start; min-width: 0; } .sub-grid { grid-template-columns: minmax(0, 1fr); } .sub-plan { font-size: 1.25rem; } }



/* ─── نسخة العرض: الشريط، عدّاد الفواتير، والعلامة المائية على الفاتورة ─── */
.demo-bar { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 12px; padding: 7px 16px; background: var(--info-bg); color: var(--info-fg); border-bottom: 1px solid var(--border); font-size: .88rem; font-weight: 600; text-align: center; }
.demo-bar[hidden] { display: none; }
.demo-bar.is-low { background: var(--warn-bg); color: var(--warn-fg); }
.demo-bar.is-blocked { background: var(--bad-bg); color: var(--bad-fg); }
.demo-bar .btn-ghost { border-color: currentColor; color: inherit; }
.demo-meter { height: 8px; }
.demo-meter span { background: var(--tone, var(--primary)); }

.paper.is-demo { position: relative; }
.demo-mark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 1; overflow: hidden; border-radius: inherit; }
.demo-mark span { transform: rotate(-24deg); font-size: 72px; font-weight: 900; letter-spacing: .04em; white-space: nowrap; color: rgba(220, 38, 38, .15); border: 6px solid rgba(220, 38, 38, .15); border-radius: 16px; padding: 4px 28px; }
.paper.receipt .demo-mark span { font-size: 30px; border-width: 3px; padding: 2px 12px; }
@media (max-width: 760px) { .demo-mark span { font-size: 46px; } .paper.receipt .demo-mark span { font-size: 26px; } }
@media print { .demo-mark span { color: rgba(220, 38, 38, .22); border-color: rgba(220, 38, 38, .22); -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
.feat-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 10px 14px; }
.feat-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); transition: border-color .15s, box-shadow .15s; }
.feat-row.is-on:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.feat-row.is-off { background: var(--soft); }
.feat-row.is-off .feat-ic { background: var(--muted-bg); color: var(--muted-fg); }
.feat-row.is-off b { color: var(--text-muted); }
.feat-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; background: var(--primary-soft); color: var(--primary); }
.feat-ic .i { width: 20px; height: 20px; vertical-align: 0; }
.dev-code { padding: 8px 14px; border-radius: 10px; background: var(--soft); border: 1px solid var(--border); font-weight: 700; letter-spacing: .08em; font-size: 1rem; user-select: all; }

/* ─── شاشة القفل بكود المالك: تغطي البرنامج كله حتى يُقبل كود صالح ─── */
.gate { position: fixed; inset: 0; z-index: 3000; overflow: auto; display: flex; padding: 20px 16px; background: var(--bg) radial-gradient(60% 50% at 50% 0%, var(--primary-soft), transparent 70%) no-repeat; }
.gate-card { margin: auto; width: 100%; max-width: 460px; padding: 28px 24px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); text-align: center; }
.gate-brand { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 18px; font-size: 1.4rem; font-weight: 800; }
.gate-brand .brand-badge { width: 56px; height: 56px; border-radius: 16px; }
.gate-brand .brand-logo { border-radius: 16px; }
.gate-card h1 { font-size: 1.35rem; font-weight: 800; margin-bottom: 8px; }
.gate-text { color: var(--text-muted); margin-bottom: 4px; }
.gate .note { margin-top: 14px; text-align: start; }
.gate form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; text-align: start; }
.gate-go { width: 100%; min-height: 46px; font-size: 1rem; }
.gate-ask { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.gate-dev { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gate-safe { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.gate-safe .btn { margin-top: 10px; }
@media (max-width: 480px) { .gate { padding: 12px; } .gate-card { padding: 22px 16px; } }

/* ─── صفحات مستقلة: لوحة المالك وصفحة الأسعار ─── */
.site-page { line-height: 1.55; }
.site-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 20px; background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.site-brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.1rem; color: var(--text) !important; text-decoration: none; }
.site-top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-wrap { max-width: 1000px; width: 100%; margin: 0 auto; padding: 20px 16px 48px; }
.owner-tabs { margin-bottom: 14px; }
.owner-tabs button { padding: 6px 12px; border-radius: 9px; border: 0; background: none; font: inherit; font-weight: 700; font-size: .88rem; color: var(--text-muted); cursor: pointer; }
.owner-tabs button.on { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }
.cust-list { display: grid; gap: 10px; }
.cust { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.cust-main { min-width: 0; flex: 1 1 260px; }
.cust-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.cust-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.feat-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 6px 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--soft); }
.dur { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg-opt span { display: inline-block; padding: 6px 12px; border-radius: 9px; border: 1.5px solid var(--border); background: var(--card); font-weight: 700; font-size: .86rem; color: var(--text-muted); }
.seg-opt input:checked + span { border-color: var(--primary); color: var(--primary); background: var(--info-bg); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.code-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; word-break: break-all; }
.test-list { list-style: none; display: grid; gap: 4px; margin-top: 10px; font-size: .92rem; }
@media (max-width: 560px) { .site-top { padding: 8px 12px; } .site-wrap { padding-inline: 12px; } .cust-acts .btn { flex: 1 1 auto; } }

/* ─── صفحة الباقات ─── */
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { padding: 6px 12px; border-radius: 9px; color: var(--text-muted) !important; text-decoration: none; font-weight: 700; font-size: .9rem; }
.site-nav a:hover { background: var(--hover); color: var(--text) !important; }
.sales-wrap { max-width: 1060px; }
.sales-wrap h2 { font-size: 1.5rem; font-weight: 900; }
.sales-hero { padding-top: 24px; }
.trust { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-top: 22px; color: var(--text-muted); font-weight: 700; font-size: .9rem; }
.sales-sec { margin-top: 38px; scroll-margin-top: 70px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.sec-head p { flex-basis: 100%; margin-top: -4px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; align-items: stretch; }
.plan { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 24px 22px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.plan-featured { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow-md); }
.plan-badge { position: absolute; top: -12px; inset-inline-start: 20px; padding: 2px 12px; border-radius: 999px; background: var(--grad); color: #fff; font-size: .75rem; font-weight: 800; }
.plan h3 { font-size: 1.25rem; font-weight: 900; }
.plan-tag { color: var(--text-muted); font-size: .9rem; min-height: 2.8em; }
.plan-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.plan-price b { font-size: 1.9rem; font-weight: 900; line-height: 1.2; }
.plan-price b.plan-ask { font-size: 1.1rem; }
.plan-price span { color: var(--text-muted); font-weight: 700; font-size: .88rem; }
.plan-save { color: var(--ok-fg); font-weight: 800; font-size: .82rem; }
.plan-list { list-style: none; display: grid; gap: 6px; font-size: .92rem; font-weight: 600; margin-top: 4px; }
.plan-cta { margin-top: auto; padding-top: 10px; }
.plan-cta .btn { width: 100%; }
.compare-tbl th.num, .compare-tbl td.num { text-align: center; min-width: 92px; }
.compare-tbl td:first-child { min-width: 220px; }
.compare-base td { background: var(--soft); }
.base-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 8px 18px; }
.base-list li::before { content: ''; display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.22em; margin-inline-end: .55em; background: var(--ok-fg); -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='m9 12 2 2 4-4'/></svg>") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='m9 12 2 2 4-4'/></svg>") center / contain no-repeat; }
.steps { list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.steps li { counter-increment: s; position: relative; padding: 16px 16px 16px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); display: grid; gap: 4px; }
.steps li::before { content: counter(s); width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: grid; place-items: center; margin-bottom: 4px; }
.steps li span { color: var(--text-muted); font-size: .92rem; }
.faq { display: grid; gap: 8px; }
.faq details { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 4px 16px; }
.faq summary { cursor: pointer; font-weight: 800; padding: 10px 0; list-style-position: inside; }
.faq details[open] summary { color: var(--primary); }
.faq p { color: var(--text-muted); padding-bottom: 12px; line-height: 1.9; }
.final-cta { text-align: center; padding: 28px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.final-cta p { margin: 6px 0 16px; }
.site-foot { max-width: 1060px; margin: 0 auto; padding: 20px 16px 40px; text-align: center; color: var(--text-muted); font-size: .85rem; border-top: 1px solid var(--border); }
.site-foot a { color: var(--primary); }
[data-theme="dark"] .site-foot a { color: #a5b4fc; }
@media (max-width: 760px) { .site-nav { display: none; } }

/* ─── تثبيت التطبيق ─── */
.install-me { padding: 12px 14px; border: 1.5px solid var(--primary); border-radius: 12px; background: var(--info-bg); }
.install-me h3 { font-size: 1rem; font-weight: 800; margin-bottom: 6px; }
.install-steps { margin: 6px 0 0; padding-inline-start: 22px; display: grid; gap: 4px; line-height: 1.8; font-size: .92rem; }
.install-others { margin-top: 12px; }
.install-others summary { cursor: pointer; font-weight: 800; color: var(--text-muted); }
.install-others h4 { margin: 10px 0 2px; font-size: .92rem; }
.dl-steps { display: grid; gap: 8px; }
.dl-steps details { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 4px 16px; }
.dl-steps summary { cursor: pointer; font-weight: 800; padding: 10px 0; list-style-position: inside; }
.dl-steps details[open] summary { color: var(--primary); }
.dl-steps .install-steps { padding-bottom: 12px; }
.hash-list { display: grid; gap: 8px; }
.hash-row { display: grid; gap: 4px; padding: 10px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.hash-row code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; color: var(--text-muted); word-break: break-all; user-select: all; }
.hash-help { margin-top: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 4px 16px; }
.hash-help summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.hash-help .install-steps { padding-bottom: 12px; }
.dl-grid { grid-template-columns: repeat(4, 1fr); }
.dl-grid .plan-cta .btn { white-space: normal; text-align: center; }
@media (max-width: 960px) { .dl-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .dl-grid { grid-template-columns: 1fr; } }
.notes-list { grid-template-columns: 1fr; }
.notes-list li::before { content: ''; display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.22em; margin-inline-end: .55em; background: var(--info-fg); -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='M12 16v-4M12 8h.01'/></svg>") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='M12 16v-4M12 8h.01'/></svg>") center / contain no-repeat; }
.install-app { margin-bottom: 12px; }
.install-alt h3 { font-size: 1rem; font-weight: 800; }
.install-alt h4 { margin: 8px 0 0; font-size: .9rem; color: var(--text-muted); }

/* ─── سجل التحديثات (لوحة المالك) ─── */
.upd + .upd { margin-top: 12px; }
.upd-cur { border-color: var(--primary); }
.upd .card-h h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.upd-v { font-size: .85rem; letter-spacing: .02em; }
.upd-items { margin: 0; padding-inline-start: 22px; display: grid; gap: 6px; line-height: 1.8; }
.upd-chip { text-decoration: none; margin-inline-start: 6px; vertical-align: middle; }
.owner-tabs [data-new-tab] { margin-inline-start: 4px; }

