/* ===== ميزان — الأنماط الأساسية =====
   نستخدم الخصائص المنطقية (inline-start / inline-end) حتى تعمل الواجهة
   في الاتجاهين: العربية (RTL) والإنجليزية (LTR) بنفس الكود. */

:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --border: #dfe3ea;
    --text: #1f2933;
    --muted: #6b7684;
    --primary: #1f5fbf;
    --primary-dark: #174a96;
    --primary-soft: #e8f0fc;
    --success: #1f8f4e;
    --danger: #c0392b;
    --sidebar-w: 260px;
    --topbar-h: 52px;
    --radius: 8px;
    --font: "Cairo", "Segoe UI", "Helvetica Neue", Tahoma, Arial, "Noto Sans Arabic", sans-serif;
}
/* خط Cairo (رخصة OFL) مضمّن مع البرنامج ليعمل بلا إنترنت — أوضح للعربية والأرقام */
@font-face { font-family: "Cairo"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/cairo-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Cairo"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/cairo-arabic-600-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Cairo"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/cairo-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Cairo"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/cairo-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cairo"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/cairo-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cairo"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/cairo-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 12px; font-weight: 600; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; margin: 0 0 10px; font-weight: 600; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 0.9em; }
.lead { font-size: 1.1rem; }

/* ---------- الشريط العلوي ---------- */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
    padding: 0 18px;
    position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.1rem; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800;
}
.brand-logo { height: 36px; width: auto; object-fit: contain; }
.brand-logo-lg { height: 72px; }
.topbar-sep { width: 1px; height: 24px; background: var(--border); }
.topbar-business { font-weight: 600; color: var(--muted); }
.topbar-spacer { flex: 1; }
.topbar-link { padding: 6px 10px; border-radius: 6px; color: var(--text); }
.topbar-link:hover { background: var(--primary-soft); color: var(--primary); }
.topbar-link.lang { border: 1px solid var(--border); font-weight: 600; }

/* ---------- الهيكل: قائمة جانبية + محتوى ---------- */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    padding: 12px 0;
    display: flex; flex-direction: column;
    flex-shrink: 0;
}
.nav-list { padding: 4px 10px; display: flex; flex-direction: column; gap: 1px; }
.nav-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.nav-group { padding: 4px 10px; }
.nav-group-title {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); padding: 10px 10px 4px; font-weight: 700;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px; border-radius: 6px;
    color: var(--text); font-size: 0.93rem; font-weight: 500;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--muted); }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { color: var(--primary); }
.ico { vertical-align: -4px; }
.nav-bottom { margin-top: auto; border-top: 1px solid var(--border); padding: 10px 10px 0; }
.nav-customize { color: var(--primary); font-weight: 600; }

.content { flex: 1; padding: 24px 28px; max-width: 1200px; min-width: 0; }
.main-plain { padding: 32px 20px; }
.page-narrow { max-width: 720px; margin: 0 auto; }

/* ---------- البطاقات ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.card-link { display: block; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.card-link:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(31,95,191,.12); }
.card-title { font-weight: 600; font-size: 1.05rem; }
.card-sub { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.card-list { margin-bottom: 24px; }

/* ---------- النماذج ---------- */
.form { max-width: 820px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; }
.field > span { font-weight: 600; font-size: 0.9rem; }
.field-row { display: flex; gap: 14px; }
input, select, textarea {
    font: inherit; padding: 9px 11px;
    border: 1px solid var(--border); border-radius: 6px;
    background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.btn {
    font: inherit; font-weight: 600; cursor: pointer;
    padding: 9px 18px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.error { color: var(--danger); margin-bottom: 10px; }
.toast {
    display: inline-block; background: #e6f6ec; color: var(--success);
    border: 1px solid #bfe6cc; border-radius: 6px; padding: 8px 14px; margin: 8px 0 12px; font-weight: 600;
}
.notice { background: #fff8e1; border: 1px solid #f3dd8a; border-radius: 6px; padding: 12px 14px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head h1 { flex: 1; }
.page-actions { display: flex; gap: 8px; }
.page-foot { margin-top: 20px; }
.h-icon { opacity: .7; margin-inline-end: 4px; }

/* ---------- الملخص ---------- */
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0 20px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 20px; min-width: 170px;
}
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--primary); unicode-bidi: plaintext; }
.stat-label { color: var(--muted); font-size: 0.85rem; }

/* ---------- شاشة التخصيص ---------- */
.module-group { margin: 22px 0; }
.module-group h2 { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: .06em; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.module-card {
    display: flex; align-items: flex-start; gap: 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; cursor: pointer; transition: border-color .15s, background .15s;
}
.module-card:hover { border-color: var(--primary); }
.module-card.on { border-color: var(--primary); background: var(--primary-soft); }
.module-card.locked { cursor: default; opacity: .8; }
.module-card input { width: 18px; height: 18px; margin-top: 3px; flex-shrink: 0; accent-color: var(--primary); }
.module-icon { font-size: 1.2rem; width: 26px; text-align: center; }
.module-text { display: flex; flex-direction: column; }
.module-name { font-weight: 600; }
.module-desc { color: var(--muted); font-size: 0.82rem; }

/* ---------- وحدة قيد الإنشاء ---------- */
.placeholder {
    text-align: center; padding: 60px 20px; color: var(--muted);
    background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.placeholder-icon { font-size: 3rem; margin-bottom: 8px; opacity: .5; }

/* ---------- خطأ Blazor ---------- */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff3cd; border-top: 1px solid #ffeeba; padding: 12px 20px; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; inset-inline-end: 12px; top: 10px; }

/* ---------- شاشات صغيرة ---------- */
@media (max-width: 800px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; border-inline-end: none; border-bottom: 1px solid var(--border); }
    .field-row { flex-direction: column; gap: 0; }
    .content { padding: 16px; }
}

/* ---------- الجداول ---------- */
.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: start; vertical-align: middle; }
.grid th { background: var(--bg); font-size: 0.82rem; color: var(--muted); font-weight: 700; }
.grid tbody tr:hover { background: #fafbfd; }
.grid .num, .grid th.num { text-align: end; white-space: nowrap; unicode-bidi: plaintext; }
.grid .center { text-align: center; }
.grid .row-group td { background: #f8f9fb; font-weight: 600; }
.grid .row-inactive td { color: var(--muted); }
.grid .row-total td { font-weight: 700; background: var(--primary-soft); border-top: 2px solid var(--primary); }
.grid .row-subtotal td { font-weight: 700; border-top: 1px solid #c9d3e3; }
.grid .row-section td { font-weight: 700; background: var(--bg); text-transform: uppercase; font-size: 0.82rem; color: var(--muted); letter-spacing: .05em; }
.grid .row-net td { font-size: 1.05rem; }
.grid .col-code { width: 110px; }
.grid .col-type { width: 130px; }
.grid .col-actions { width: 80px; text-align: end; white-space: nowrap; }
.grid a { color: var(--text); }
.grid a:hover { color: var(--primary); text-decoration: underline; }
.grid.lines input, .grid.lines select { padding: 6px 8px; }
.grid.lines td { padding: 4px 6px; }
.grid.lines input.num { text-align: end; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; unicode-bidi: plaintext; }
.indent { display: inline-block; width: calc(var(--lvl, 0) * 18px); }
.tag { display: inline-block; font-size: 0.7rem; padding: 1px 6px; border-radius: 4px; background: var(--primary-soft); color: var(--primary); margin-inline-start: 6px; vertical-align: middle; }
.tag-off { background: #f1f1f1; color: var(--muted); }
.ok { color: var(--success); font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }

/* ---------- شريط الأدوات ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 10px 0 14px; }
.search { max-width: 340px; }
.period { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field.inline { margin: 0; flex: none; }
.field.inline > span { font-size: 0.78rem; color: var(--muted); }
.field.inline input, .field.inline select { width: auto; min-width: 150px; padding: 7px 9px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 12px; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.btn-mini { padding: 3px 8px; font-size: 0.85rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.confirm-inline { display: inline-flex; gap: 8px; align-items: center; color: var(--danger); font-weight: 600; }
.actions { display: flex; gap: 10px; align-items: center; }
.form.wide { max-width: none; }
textarea { resize: vertical; }

/* ---------- اللوحة الجانبية (Drawer) ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 50; }
.drawer {
    position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(460px, 100%);
    background: var(--surface); box-shadow: -4px 0 24px rgba(0,0,0,.15); z-index: 51;
    display: flex; flex-direction: column;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; }
.drawer-body { padding: 18px; overflow: auto; flex: 1; }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }

/* ---------- التقارير والطباعة ---------- */
.report-cards .card-link { margin-bottom: 10px; }
.report.statement td:last-child { width: 200px; }
.print-only { display: none; }
.report-title { text-align: center; margin-bottom: 16px; }
.report-title h1 { margin: 0; font-size: 1.3rem; }
.report-title h2 { margin: 4px 0; font-size: 1.1rem; }
.report-title p { margin: 0; color: var(--muted); }
@media print {
    .topbar, .sidebar, .no-print, #blazor-error-ui { display: none !important; }
    .print-only { display: block; }
    .shell { display: block; }
    .content { padding: 0; max-width: none; }
    body { background: #fff; font-size: 12px; }
    .grid { border: none; }
    .grid th, .grid td { padding: 4px 6px; }
    a { color: inherit; text-decoration: none; }
}

/* ---------- الملخص (إضافات) ---------- */
.stat-link { color: var(--text); display: block; }
.stat-link:hover { border-color: var(--primary); }
.stat-good .stat-value { color: var(--success); }
.stat-bad .stat-value { color: var(--danger); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid.compact td { padding: 6px 8px; }
.grid.compact { border: none; margin-bottom: 10px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- المبيعات ---------- */
.mt { margin-top: 24px; }
.badge { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: #e6f6ec; color: var(--success); }
.badge-warn { background: #fff4e0; color: #b26a00; }
.badge-due { background: #fdecea; color: var(--danger); }
.badge-draft { background: #eef0f4; color: var(--muted); }
.badge-off { background: #f1f1f1; color: var(--muted); text-decoration: line-through; }
.status-filter { width: auto; }
.grid.lines td select + input.line-desc { margin-top: 4px; font-size: 0.85rem; }
.totals-row { display: flex; gap: 24px; align-items: flex-start; margin-top: 16px; }
.totals-row .field { flex: 1; }
.totals { min-width: 340px; border-collapse: collapse; }
.totals td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.totals tr.grand td { font-weight: 700; font-size: 1.05rem; background: var(--primary-soft); }
.totals td.num { text-align: end; }

/* ---------- نموذج الفاتورة للطباعة ---------- */
.print-page { padding: 16px; background: #e9ecf1; min-height: 100vh; }
.print-toolbar { max-width: 210mm; margin: 0 auto 12px; display: flex; gap: 8px; }
.invoice-sheet {
    background: #fff; width: 210mm; min-height: 280mm; margin: 0 auto; padding: 14mm 12mm;
    box-shadow: 0 2px 12px rgba(0,0,0,.12); font-size: 12px; color: #111; display: flex; flex-direction: column;
}
.inv-head { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--acc, #1f5fbf); padding-bottom: 10px; }
.inv-seller { display: flex; gap: 12px; align-items: flex-start; }
.inv-logo { max-height: 78px; max-width: 150px; object-fit: contain; }
.inv-header-note { color: var(--acc, #1f5fbf); font-weight: 600; }
.inv-biz { font-size: 1.35rem; font-weight: 700; }
.inv-biz-en { font-size: 1rem; font-weight: 600; color: #333; }
.inv-title-box { text-align: center; align-self: center; }
.inv-title { font-size: 1.3rem; font-weight: 700; color: var(--acc, #1f5fbf); }
.inv-title-other { font-size: 0.95rem; color: #555; }
.inv-draft { margin-top: 6px; color: #c0392b; border: 2px dashed #c0392b; padding: 2px 8px; font-weight: 700; display: inline-block; }
.inv-qr svg { width: 110px; height: 110px; }
.inv-meta { display: flex; gap: 16px; margin: 12px 0; }
.meta { flex: 1; border-collapse: collapse; }
.meta th, .meta td { padding: 4px 8px; border: 1px solid #dde; text-align: start; vertical-align: top; }
.meta th { background: #f3f5f8; font-weight: 600; width: 45%; }
.meta .meta-head { background: color-mix(in srgb, var(--acc, #1f5fbf) 12%, #fff); color: var(--acc, #1f5fbf); text-align: center; width: auto; }
.inv-lines { width: 100%; border-collapse: collapse; margin-top: 6px; }
.inv-lines th, .inv-lines td { border: 1px solid #cdd3dc; padding: 5px 6px; text-align: center; }
.inv-lines th { background: var(--acc, #1f5fbf); color: #fff; font-weight: 600; font-size: 0.8rem; }
.inv-lines .th-other { font-weight: 400; opacity: .85; font-size: 0.72rem; }
.inv-lines .start { text-align: start; }
.inv-foot { display: flex; justify-content: space-between; gap: 24px; margin-top: 14px; }
.inv-terms { flex: 1; }
.inv-totals { min-width: 300px; border-collapse: collapse; }
.inv-totals th, .inv-totals td { padding: 5px 8px; border: 1px solid #cdd3dc; }
.inv-totals th { background: #f3f5f8; text-align: start; font-weight: 600; }
.inv-totals td { text-align: end; }
.inv-totals .th-other { font-weight: 400; color: #666; font-size: 0.72rem; }
.inv-totals tr.grand th, .inv-totals tr.grand td { background: color-mix(in srgb, var(--acc, #1f5fbf) 12%, #fff); font-weight: 700; font-size: 1rem; }
.inv-sign { display: flex; justify-content: space-around; gap: 24px; margin-top: 28px; text-align: center; font-size: .85em; color: #444; }
.inv-sign > div { min-width: 180px; }
.sign-line { border-bottom: 1px solid #888; height: 28px; margin-bottom: 4px; }
.inv-bank { white-space: pre-line; }
/* قالب حديث: شريط ملوّن في الرأس */
.tpl-modern .inv-head { background: var(--acc); color: #fff; padding: 12px 14px; border-radius: 10px; border-bottom: none; }
.tpl-modern .inv-head .small, .tpl-modern .inv-biz-en, .tpl-modern .inv-title-other, .tpl-modern .inv-header-note { color: #fff; opacity: .92; }
.tpl-modern .inv-title { color: #fff; }
.tpl-modern .inv-logo { background: #fff; border-radius: 6px; padding: 3px; }
.tpl-modern .inv-lines th { border-color: var(--acc); }
.tpl-modern .meta th { background: color-mix(in srgb, var(--acc) 10%, #fff); }
/* قالب بسيط: بلا تعبئات، خطوط رفيعة */
.tpl-minimal .inv-head { border-bottom: 1px solid #333; }
.tpl-minimal .inv-lines th { background: none; color: #111; border-bottom: 2px solid #111; }
.tpl-minimal .inv-lines th, .tpl-minimal .inv-lines td { border-left: none; border-right: none; border-color: #ddd; }
.tpl-minimal .meta th { background: none; }
.tpl-minimal .inv-totals tr.grand th, .tpl-minimal .inv-totals tr.grand td { background: none; border-top: 2px solid #111; }
.tpl-minimal .inv-title { color: #111; }
@media print { .tpl-modern .inv-head, .inv-lines th, .inv-totals tr.grand th, .inv-totals tr.grand td, .meta th { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
.inv-end { margin-top: auto; padding-top: 16px; text-align: center; border-top: 1px solid #dde; }
@media print {
    .print-page { padding: 0; background: #fff; }
    .invoice-sheet { box-shadow: none; width: auto; min-height: auto; margin: 0; padding: 0; }
    .inv-lines th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    @page { size: A4; margin: 12mm; }
}

/* ---------- وحدات الأصناف والملصقات ---------- */
h3.sub { margin: 16px 0 6px; font-size: 0.95rem; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.with-btn { display: flex; gap: 6px; align-items: center; }
.with-btn input { flex: 1; }
.unit-row { display: grid; grid-template-columns: 1.3fr 0.7fr 0.9fr 0.9fr 1.6fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.unit-row input { padding: 7px 8px; }
.unit-head { margin-bottom: 8px; }
.scan-box { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.scan-box input { max-width: 380px; }
.labels { display: flex; flex-wrap: wrap; gap: 8px; max-width: 210mm; margin: 0 auto; }
.label { width: 58mm; border: 1px dashed #bbb; padding: 4px 6px; text-align: center; background: #fff; font-size: 11px; page-break-inside: avoid; }
.label-biz { font-size: 9px; color: #555; }
.label-name { font-weight: 700; }
.label-unit { margin-bottom: 2px; }
.label svg { width: 100%; height: auto; }
@media print { .label { border: none; } }

.line-bc { font-size: 0.7rem; color: #555; }
.inv-warn { font-size: 0.7rem; color: #b26a00; max-width: 140px; margin-top: 4px; }

.row-neg td { background: #fff5f5; }

/* ---------- نقاط البيع ---------- */
.pos-open { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.pos-open .card { width: 420px; }
.pos { display: flex; flex-direction: column; height: 100vh; margin: -16px; background: var(--bg); }
.pos-bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.pos-body { display: flex; flex: 1; min-height: 0; }
.pos-items { flex: 1; display: flex; flex-direction: column; padding: 12px; min-width: 0; }
.pos-search input { font-size: 1.1rem; padding: 12px; }
.pos-cats { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; }
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; overflow: auto; flex: 1; align-content: start; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; text-align: start; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 4px; min-height: 84px; }
.tile:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(31,95,191,.15); }
.tile:active { background: var(--primary-soft); }
.tile-name { font-weight: 600; line-height: 1.25; }
.tile-price { color: var(--primary); font-weight: 700; font-family: ui-monospace, monospace; }
.tile-units { display: flex; flex-wrap: wrap; gap: 4px; }
.unit-chip { font-size: 0.72rem; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.unit-chip:hover { background: var(--primary-soft); border-color: var(--primary); }
.pos-cart { width: 400px; background: var(--surface); border-inline-start: 1px solid var(--border); display: flex; flex-direction: column; }
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.cart-head h2 { margin: 0; }
.cart-customer { margin: 8px 12px; width: auto; }
.cart-lines { flex: 1; overflow: auto; padding: 0 12px; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cl-name { font-weight: 600; }
.cl-qty { display: flex; align-items: center; gap: 2px; }
.cl-qty input { width: 58px; padding: 4px; text-align: center; }
.cl-total { min-width: 70px; text-align: end; font-weight: 600; }
.cart-totals { padding: 10px 12px; border-top: 1px solid var(--border); }
.cart-totals > div { display: flex; justify-content: space-between; padding: 3px 0; }
.cart-totals .grand { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.btn-pay { margin: 0 12px 12px; padding: 16px; font-size: 1.2rem; }
.pay-modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--surface); border-radius: 12px; padding: 22px; width: min(560px, 95vw); z-index: 60; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.pay-row { display: flex; gap: 12px; }
.pay-row label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.pay-row input.big { font-size: 1.6rem; padding: 10px; text-align: end; }
.pay-quick { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.pay-summary > div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 1.05rem; }
.pay-summary .ok { color: var(--success); font-weight: 700; font-size: 1.3rem; }
.pos-flash { position: fixed; bottom: 20px; inset-inline-start: 20px; background: #e6f6ec; color: var(--success); border: 1px solid #bfe6cc; padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 40; }

/* ---------- إيصال حراري 80mm ---------- */
.receipt-toolbar { max-width: 80mm; }
.receipt { width: 80mm; margin: 0 auto; background: #fff; padding: 6mm 4mm; font-size: 12px; font-family: var(--font); color: #000; }
.receipt hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }
.r-center { text-align: center; }
.r-biz { font-weight: 700; font-size: 15px; }
.r-title { text-align: center; font-weight: 700; margin: 8px 0; }
.r-row { display: flex; justify-content: space-between; gap: 8px; }
.r-line { margin: 4px 0; }
.r-total { font-weight: 700; font-size: 14px; border-top: 1px solid #000; padding-top: 4px; margin-top: 4px; }
.r-qr { text-align: center; margin: 10px 0 6px; }
.r-qr svg { width: 34mm; height: 34mm; }
@media print {
    .receipt { width: 72mm; padding: 0; }
    .pos { display: none; }
    body:has(.receipt) { background: #fff; }
    @page :has(.receipt) { size: 80mm auto; margin: 3mm; }
}

/* ---- الموظفون والرواتب ---- */
.row-off td { color: var(--muted); }
.table-scroll { overflow-x: auto; max-width: 100%; }
.grid.payroll { font-size: 0.86rem; white-space: nowrap; }
.grid.payroll th, .grid.payroll td { padding: 6px 7px; }
.grid.payroll input { width: 84px; padding: 5px 6px; }
.grid.payroll input.days { width: 55px; }
.payslip { border: 1px solid #ccc; border-radius: 8px; padding: 18px 22px; margin: 0 auto 18px; max-width: 760px; page-break-after: always; background: #fff; }
.payslip:last-child { page-break-after: auto; }
.payslip-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #333; padding-bottom: 10px; margin-bottom: 12px; }
.payslip-head h1 { font-size: 1.2rem; margin: 0; }
.payslip-head h2 { font-size: 1rem; margin: 4px 0 0; color: var(--muted); }
.payslip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.payslip table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.payslip td { padding: 4px 6px; border-bottom: 1px solid #eee; }
.payslip .row-total td { font-weight: 700; border-top: 2px solid #333; border-bottom: none; }
.payslip-net { margin-top: 14px; font-size: 1.15rem; font-weight: 700; display: flex; justify-content: space-between; border: 2px solid #333; padding: 8px 12px; border-radius: 6px; }
.payslip-sign { display: flex; justify-content: space-between; margin-top: 36px; color: var(--muted); font-size: 0.85rem; }
@media print { .payslip { border: none; max-width: none; } }

/* ---- تسجيل الدخول والمستخدمون ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 6px 24px rgba(0,0,0,.06); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 1.3rem; font-weight: 700; }
.login-box h1 { font-size: 1.15rem; margin: 6px 0 18px; color: var(--muted); font-weight: 600; }
.topbar-user { color: var(--muted); font-size: .9rem; margin-inline-end: 8px; }
.perm-grid { display: grid; grid-template-columns: 1fr; gap: 3px 12px; margin: 6px 0 14px; }
.perm-grid label { font-size: .88rem; display: flex; gap: 8px; align-items: center; }
.perm-grid label input, .perm-biz-head input { width: 16px; height: 16px; flex: none; accent-color: var(--primary); }
.perm-biz { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.perm-biz-head { display: flex; align-items: center; gap: 10px; font-weight: 600; }

/* ---------- هيئة الزكاة ---------- */
.zatca-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; }

/* ---------- حقل التاريخ الميلادي ---------- */
.date-input { display: inline-flex; align-items: stretch; width: 100%; position: relative; }
.date-input .date-text { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px; padding-right: 34px; text-align: left; }
.date-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: none; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.date-btn:hover { background: var(--primary-soft); color: var(--primary); }
.cal-backdrop { position: fixed; inset: 0; z-index: 70; }
.cal { position: absolute; top: calc(100% + 4px); left: 0; z-index: 71; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.15); padding: 8px 10px; width: 260px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cal-title { font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: .72rem; color: var(--muted); padding: 2px 0; }
.cal-day { border: none; background: transparent; border-radius: 6px; padding: 5px 0; cursor: pointer; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; color: var(--text); }
.cal-day:hover { background: var(--primary-soft); }
.cal-day.today { font-weight: 700; color: var(--primary); }
.cal-day.sel { background: var(--primary); color: #fff; }
.cal-foot { display: flex; justify-content: flex-end; margin-top: 4px; }
.export-btns { display: inline-flex; gap: 6px; }

/* ---------- الكاشير: تعليق وإرجاع ---------- */
.hold-prompt { display: flex; gap: 6px; padding: 6px 10px; background: var(--primary-soft); }
.hold-prompt input { flex: 1; }
.held-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }

/* ---------- اختيار وحدات الملصقات ---------- */
.label-units { max-width: 720px; margin: 0 auto 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.label-unit-row { display: grid; grid-template-columns: auto 1.6fr 1.2fr .8fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.label-unit-row:last-of-type { border-bottom: none; }
.lu-copies input { width: 64px; padding: 4px 6px; margin-inline-start: 4px; }
.label-links { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }

/* ---------- لوحة الاختصارات ---------- */
.palette { position: fixed; top: 12vh; left: 50%; transform: translateX(-50%); width: min(640px, 94vw); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.2); padding: 16px 18px; z-index: 60; }
.palette h2 { margin: 0 0 10px; font-size: 1.05rem; }
.palette-input { width: 100%; font-size: 1.1rem; padding: 10px 12px; }
.palette-list { max-height: 50vh; overflow: auto; margin-top: 8px; }
.palette-row { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.palette-row.on, .palette-row:hover { background: var(--primary-soft); }
.palette-row b { flex: 1; }
.palette-go { color: var(--muted); font-size: .8rem; }
kbd { display: inline-block; padding: 1px 7px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: #f7f8fa; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.check-field .check { display: inline-flex; align-items: center; gap: 6px; padding: 9px 0; white-space: nowrap; }
.ai-reader label.btn input { display: none; }

.ok-box { background: #e6f6ec; color: var(--success); border-color: #bfe7cc; }
.shift-list .badge-due { }

/* ---------- إعدادات الشعار والسندات ---------- */
.logo-row { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 10px; }
.logo-box { width: 160px; height: 90px; border: 1px dashed var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; background: #fff; }
.logo-box img { max-width: 150px; max-height: 80px; object-fit: contain; }
.check-grid { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.voucher { min-height: 150mm; }
.voucher-amount { margin: 16px 0; border: 2px solid var(--acc, #1f5fbf); border-radius: 8px; padding: 10px 14px; }
.va-num { display: flex; justify-content: space-between; font-size: 1.3em; font-weight: 700; }
.va-label { font-size: .75em; font-weight: 600; color: #555; }
.va-words { margin-top: 6px; font-weight: 600; }
.r-logo { max-width: 55mm; max-height: 22mm; object-fit: contain; }
.settings-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin: 8px 0 18px; }
.settings-links .card-link { display: flex; gap: 12px; align-items: center; padding: 12px 14px; }
.settings-links .ico { color: var(--primary); flex-shrink: 0; }
td.mono { white-space: nowrap; }
.biz-card { display: flex; align-items: center; gap: 10px; }
.biz-link { flex: 1; color: var(--text); }
.biz-card:hover { border-color: var(--primary); }
.danger-card { border-color: #e8b4ae; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
