/* حسّوب: التطبيق. فاتح وهادي، أخضر واحد، حدود 1px، أرقام جدولية */
@font-face { font-family: 'GE SS Two'; src: url(/assets/fonts/ge-ss-two-light.woff2) format('woff2'); font-weight: 300; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'GE SS Two'; src: url(/assets/fonts/ge-ss-two-medium.woff2) format('woff2'); font-weight: 400 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'GE SS Two'; src: url(/assets/fonts/ge-ss-two-bold.woff2) format('woff2'); font-weight: 600 800; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'Inter'; src: url(/assets/fonts/inter-var.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #fbfaf6; --surface: #fff; --surface-2: #f3f1ea; --border: #e3e0d6; --border-input: #8a8f88;
  --text: #16201b; --muted: #58625c; --accent: #0b6e4a; --accent-ink: #0b3b2a; --on-accent: #fff; --accent-soft: #e4f2ea;
  --marker: #f5d565; --danger: #b42318; --danger-soft: #fdecea; --warning: #9a5b00; --warning-soft: #fdf3dc;
  --r-sm: 4px; --r-md: 6px; --r-lg: 10px; --shadow: 0 1px 2px rgba(20,30,25,.06); --pop: 0 12px 32px rgba(20,30,25,.16);
  --font: 'GE SS Two', 'Inter', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --side: 248px; --head: 56px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1412; --surface: #151d1a; --surface-2: #1b2521; --border: #2a3530; --border-input: #77837d;
  --text: #e9efeb; --muted: #a1aea7; --accent: #3ccf91; --accent-ink: #0b3b2a; --on-accent: #05140d; --accent-soft: #163327;
  --danger: #ff8a80; --danger-soft: #3a1714; --warning: #f0b44c; --warning-soft: #33270f; --shadow: none; --pop: 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.7 var(--font); }
a { color: var(--accent); text-decoration: none; }
@media (hover:hover) { a:hover { text-decoration: underline; } }
h1, h2, h3 { margin: 0; line-height: 1.35; font-weight: 700; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); }
.num, td.n, th.n, input.num, .tab { font-family: 'Inter', var(--font); font-variant-numeric: tabular-nums; }
.num small { font-family: var(--font); font-size: .82em; }
.neg { color: var(--danger); }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ===== الهيكل ===== */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-inline-end: 1px solid var(--border); padding: 14px 12px 24px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; font-size: 19px; color: var(--text); }
.brand svg { width: 28px; height: 28px; flex: none; }
.co-switch { margin: 0 4px 12px; }
.co-switch select { width: 100%; }
.nav-h { font-size: 12px; color: var(--muted); padding: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md); color: var(--text); font-size: 14.5px; }
.nav a svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a[aria-current="page"] svg { color: var(--accent); }
@media (hover:hover) { .nav a:hover { background: var(--surface-2); text-decoration: none; } }
.nav a .count { margin-inline-start: auto; font-size: 12px; background: var(--marker); color: #16201b; border-radius: 99px; padding: 0 7px; font-family: 'Inter'; }
.side-foot { margin-top: auto; padding: 14px 10px 0; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); }
.main { min-width: 0; }
.top { height: var(--head); display: flex; align-items: center; gap: 12px; padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 17px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .actions { display: flex; gap: 8px; align-items: center; }
.content { padding: 24px; max-width: 1180px; }
.banner { padding: 10px 24px; font-size: 14px; background: var(--warning-soft); color: var(--text); border-bottom: 1px solid var(--border); }
.banner a { font-weight: 600; }
.mobile-nav, .m-only { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .top { padding: 0 16px; }
  .content { padding: 16px 16px 96px; }
  .banner { padding: 10px 16px; }
  .m-only { display: initial; }
  .d-only { display: none !important; }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset-inline: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; font-size: 11.5px; color: var(--muted); }
  .mobile-nav a svg { width: 22px; height: 22px; }
  .mobile-nav a[aria-current="page"] { color: var(--accent); }
  .mobile-nav a.scan-btn svg { width: 26px; height: 26px; }
  .mobile-nav a.scan-btn span.ic { background: var(--accent); color: var(--on-accent); border-radius: 99px; width: 44px; height: 44px; display: grid; place-items: center; margin-top: -18px; box-shadow: var(--pop); }
}

/* ===== المكوّنات ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 14px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 16px; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
@media (hover:hover) { .btn:hover { border-color: var(--border-input); } .btn.primary:hover { filter: brightness(1.08); } }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 5px; }
label.f > small { display: block; margin-top: 4px; font-size: 12.5px; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--border-input); border-radius: var(--r-md); background: var(--surface); color: var(--text); font: 400 15px var(--font); }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); vertical-align: middle; }
input.num, input[inputmode=decimal] { text-align: end; direction: ltr; }
input[type=date], input[type=month] { direction: ltr; text-align: end; font-family: 'Inter', var(--font); }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.err { background: var(--danger-soft); color: var(--danger); padding: 10px 14px; border-radius: var(--r-md); margin-bottom: 14px; font-size: 14px; }
.ok-msg { background: var(--accent-soft); color: var(--accent); padding: 10px 14px; border-radius: var(--r-md); margin-bottom: 14px; font-size: 14px; }

.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; margin-bottom: 16px; }
.box > h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.box > h2 .more { margin-inline-start: auto; font-size: 13px; font-weight: 500; }
.box.flush { padding: 0; overflow: hidden; }
.box.flush > h2 { padding: 16px 18px 0; }

/* أرقام اللوحة */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); margin-bottom: 16px; }
.stat { padding: 16px 18px; border-inline-start: 1px solid var(--border); min-width: 0; }
.stat:first-child { border-inline-start: 0; }
.stat .l { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v small { font-size: 13px; font-weight: 400; }
.stat .d { font-size: 12.5px; color: var(--muted); }
@media (max-width: 860px) { .stats { grid-template-columns: 1fr 1fr; } .stat:nth-child(3) { border-inline-start: 0; } .stat:nth-child(n+3) { border-top: 1px solid var(--border); } .stat { padding: 14px 12px; } .stat .v { font-size: 18px; white-space: normal; overflow: visible; } .stat .v small { font-size: 12px; } }

/* الجداول */
.tbl-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: start; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t td.n, table.t th.n { text-align: end; white-space: nowrap; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.total td { font-weight: 700; background: var(--surface-2); }
table.t tr.sub td { font-weight: 600; }
table.t a.row-link { color: var(--text); font-weight: 600; }
@media (hover:hover) { table.t tbody tr:hover td { background: var(--surface-2); } }
@media (max-width: 640px) {
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
  table.t.cards td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: start !important; }
  table.t.cards td::before { content: attr(data-l); color: var(--muted); font-size: 12.5px; font-family: var(--font); }
  table.t.cards td.main-cell { font-weight: 600; }
  table.t.cards td.main-cell::before { display: none; }
}

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.posted { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.review { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge.void, .badge.rejected, .badge.reversed { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.soon { background: var(--surface-2); color: var(--muted); }

.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty p { margin-bottom: 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 14px; }
.tabs a[aria-current="page"] { color: var(--accent); border-color: var(--accent); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.filters label { font-size: 12.5px; color: var(--muted); }
.filters input, .filters select { width: auto; min-width: 140px; }

/* الشريط البياني */
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; height: 170px; padding-top: 10px; }
.chart .col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.chart .bars { display: flex; gap: 3px; align-items: flex-end; height: 130px; width: 100%; justify-content: center; }
.chart .bar { width: 40%; max-width: 22px; border-radius: 2px 2px 0 0; background: var(--accent); min-height: 2px; }
.chart .bar.e { background: var(--border-input); opacity: .55; }
.chart .lab { font-size: 12px; color: var(--muted); font-family: 'Inter', var(--font); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--accent); margin-inline-end: 6px; vertical-align: -1px; }
.legend i.e { background: var(--border-input); opacity: .55; }

/* المراجعة */
.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
.docview { position: sticky; top: calc(var(--head) + 16px); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px; text-align: center; max-height: calc(100vh - 100px); overflow: auto; }
.docview img { max-width: 100%; height: auto; border-radius: var(--r-sm); background: #fff; }
.docview iframe { width: 100%; height: 70vh; border: 0; background: #fff; }
.flags { list-style: none; padding: 0; margin: 0 0 14px; }
.flags li { padding: 8px 12px; border-inline-start: 3px solid var(--warning); background: var(--warning-soft); margin-bottom: 6px; font-size: 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.conf { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.conf .meter { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; max-width: 160px; }
.conf .meter span { display: block; height: 100%; background: var(--accent); }
@media (max-width: 860px) { .review { grid-template-columns: 1fr; } .docview { position: static; max-height: 46vh; } }

/* سطور الفاتورة/القيد */
.lines { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.lines th { font-size: 12.5px; color: var(--muted); font-weight: 600; text-align: start; padding: 6px 4px; }
.lines td { padding: 4px; vertical-align: top; }
.lines td.x { width: 36px; }
.lines .rm { width: 32px; height: 40px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; }
.lines-total { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 4px 24px; font-size: 14px; margin: 8px 0 16px; }
.lines-total b { font-size: 16px; }
.unbal { color: var(--danger); font-weight: 600; }
@media (max-width: 640px) {
  .lines thead { display: none; }
  .lines, .lines tbody, .lines tr, .lines td { display: block; width: 100%; }
  .lines tr { border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px; margin-bottom: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .lines td { padding: 0; }
  .lines td.wide { grid-column: 1 / -1; }
  .lines td.x { width: auto; grid-column: 1 / -1; text-align: end; }
}

/* الماسح */
.drop { border: 2px dashed var(--border-input); border-radius: var(--r-lg); padding: 36px 18px; text-align: center; background: var(--surface); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; font-size: 17px; margin-bottom: 6px; }
.drop .btn-row { justify-content: center; margin-top: 14px; }
.queue-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--text); }
.queue-item:last-child { border-bottom: 0; }
.queue-item .thumb { width: 52px; height: 52px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface-2) center/cover; }
.queue-item .t1 { font-weight: 600; }
.queue-item .t2 { font-size: 13px; color: var(--muted); }
@media (hover:hover) { a.queue-item:hover { background: var(--surface-2); text-decoration: none; } }

/* المحاسب */
.chat { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 12px; font-size: 15px; white-space: pre-line; }
.msg.user { align-self: flex-start; background: var(--accent); color: var(--on-accent); border-end-start-radius: 4px; }
.msg.bot { align-self: flex-end; background: var(--surface); border: 1px solid var(--border); border-end-end-radius: 4px; }
.msg .cards { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.msg .cards div { border: 1px solid var(--border); border-radius: var(--r-md); padding: 6px 10px; font-size: 13px; background: var(--surface-2); }
.msg .cards b { display: block; font-size: 15px; }
.msg .links { margin-top: 8px; font-size: 13.5px; display: flex; gap: 12px; flex-wrap: wrap; }
.msg .note { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.ask-bar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; display: flex; gap: 8px; }
.ask-bar input { flex: 1; height: 48px; font-size: 16px; }
.ask-bar .btn { height: 48px; width: 48px; padding: 0; }
.ask-bar .btn.rec { background: var(--danger); border-color: var(--danger); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 6px 14px; font: 400 14px var(--font); color: var(--text); cursor: pointer; }
@media (max-width: 860px) { .ask-bar { bottom: 62px; } }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 960px) { .split { grid-template-columns: 1fr; } }
.list-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.list-row:last-child { border-bottom: 0; }

.toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: var(--r-md); z-index: 50; font-size: 14px; }
dialog { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; background: var(--surface); color: var(--text); max-width: min(520px, 92vw); box-shadow: var(--pop); }
dialog::backdrop { background: rgba(10,20,15,.45); }
.theme-btn { width: 36px; height: 36px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center; }
.theme-btn svg { width: 18px; height: 18px; }

/* الدخول */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 28px; }
.auth .brand { justify-content: center; padding-bottom: 6px; }
.auth h1 { text-align: center; font-size: 20px; margin-bottom: 18px; }
.auth .alt { text-align: center; font-size: 14px; margin-top: 16px; color: var(--muted); }
.country-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.country-pick label { border: 1px solid var(--border-input); border-radius: var(--r-md); padding: 10px; text-align: center; cursor: pointer; font-size: 14px; }
.country-pick input { display: none; }
.country-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mod-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.mod-pick label { border: 1px solid var(--border-input); border-radius: var(--r-md); padding: 10px 12px; cursor: pointer; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.mod-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* الطباعة: فاتورة */
.invoice-doc { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 36px; border: 1px solid var(--border); }
.invoice-doc h1 { font-size: 22px; }
.invoice-doc table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 14px; }
.invoice-doc th, .invoice-doc td { border: 1px solid #ddd; padding: 8px; text-align: start; }
.invoice-doc td.n, .invoice-doc th.n { text-align: end; }
.invoice-doc .head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.invoice-doc .qr { width: 132px; height: 132px; }
@media print { .no-print, .side, .top, .mobile-nav, .banner { display: none !important; } .shell { display: block; } .content { padding: 0; } .invoice-doc { border: 0; padding: 0; } body { background: #fff; } }
