:root {
  --brand: #1553b6;
  --brand-2: #2d8ee6;
  --navy: #16266b;
  --ink: #1c2230;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f5f7fb;
  --card: #fff;
  --ok: #0f8a5f;
  --ok-bg: #e7f6ef;
  --err: #c0362c;
  --err-bg: #fdecea;
  --warn: #b25e09;
  --warn-bg: #fff4e5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.6; font-size: 15px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4em; justify-content: center;
  padding: .6em 1.2em; border-radius: 10px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none !important; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--line); }
.btn.light { background: #fff; color: var(--brand); }
.btn.sm { padding: .35em .8em; font-size: 13px; }
.btn.danger { background: var(--err); }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: #344054; }
input, select, textarea {
  width: 100%; padding: .6em .75em; border: 1px solid #d0d5dd; border-radius: 10px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
input[type=checkbox] { width: auto; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- cards / tables ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: #fafbfd; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: .15em .65em; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef2f7; color: #344054; }
.badge.request, .badge.quoted { background: var(--warn-bg); color: var(--warn); }
.badge.confirmed, .badge.issued { background: #e8f0fd; color: var(--brand); }
.badge.completed { background: var(--ok-bg); color: var(--ok); }
.badge.cancelled { background: var(--err-bg); color: var(--err); }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- staff app layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: #0f1b3d; color: #cdd5e5; padding: 14px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #2b3b6b transparent; }
.side::-webkit-scrollbar { width: 6px; } .side::-webkit-scrollbar-thumb { background: #2b3b6b; border-radius: 6px; } .side::-webkit-scrollbar-track { background: transparent; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; color: #fff; font-weight: 700; font-size: 14px; line-height: 1.3; }
.side .brand img { width: 40px; height: 40px; background: #fff; border-radius: 10px; padding: 3px; }
.side nav a { display: flex; gap: 10px; align-items: center; padding: 7px 12px; border-radius: 9px; color: #cdd5e5; font-weight: 500; font-size: 14.5px; }
.side nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.side nav a.on { background: var(--brand); color: #fff; }
.side .sec { font-size: 11.5px; letter-spacing: .04em; color: #7f8aa6; margin: 12px 12px 4px; }
.side .soon { opacity: .45; pointer-events: none; }
.side .soon::after { content: "قريباً"; margin-inline-start: auto; font-size: 10.5px; border: 1px solid #56617f; border-radius: 6px; padding: 0 5px; }
.main { padding: 24px 28px 48px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 22px; }
.menu-toggle { display: none; }

.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 2px; }
.kpi .s { font-size: 12.5px; color: var(--muted); }
.kpi.alert .v { color: var(--warn); }

/* ---------- public site ---------- */
.site-nav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.site-nav .wrap { display: flex; align-items: center; gap: 18px; height: 72px; }
.site-nav img { height: 56px; }
.site-nav .links { display: flex; gap: 20px; margin-inline-start: 18px; }
.site-nav .links a { color: var(--ink); font-weight: 500; }
.hero { background: linear-gradient(135deg, var(--navy), var(--brand) 60%, var(--brand-2)); color: #fff; padding: 72px 0 84px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset-inline-start: -120px; top: -140px; width: 480px; height: 480px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .12); box-shadow: 0 0 0 60px rgba(255, 255, 255, .03), 0 0 0 130px rgba(255, 255, 255, .025); }
.hero .wrap { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; position: relative; z-index: 1; }
.hero h1 { font-size: 42px; margin-bottom: 14px; }
.hero p { font-size: 18px; opacity: .92; max-width: 34em; }
.hero .logo-card { background: #fff; border-radius: 22px; padding: 24px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.hero .logo-card img { width: 100%; display: block; }
.section { padding: 64px 0; }
.section h2 { font-size: 28px; text-align: center; }
.section .lead { text-align: center; color: var(--muted); max-width: 40em; margin: 0 auto 36px; }
.services { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.service { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.service .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: #e8f0fd; color: var(--brand); margin-bottom: 12px; }
.service h3 { font-size: 17px; margin-bottom: 4px; }
.service p { margin: 0; color: var(--muted); font-size: 14px; }
.cta { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cta .wrap { display: flex; gap: 20px; align-items: center; justify-content: space-between; padding: 36px 16px; flex-wrap: wrap; }
.footer { background: #0f1b3d; color: #aab4c8; padding: 28px 0; font-size: 14px; }
.footer .wrap { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.footer a { color: #fff; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth .panel { display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.auth .box { width: 100%; max-width: 400px; }
.auth .box img { height: 110px; display: block; margin: 0 auto 18px; }
.auth .art { background: linear-gradient(160deg, var(--navy), var(--brand) 70%, var(--brand-2)); color: #fff; display: flex; flex-direction: column; justify-content: flex-end; padding: 48px; }
.auth .art h2 { font-size: 30px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 260px; z-index: 50; transform: translateX(100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .main { padding: 16px; }
  .hero .wrap { grid-template-columns: 1fr; }
  .hero h1 { font-size: 30px; }
  .hero .logo-card { max-width: 320px; }
  .site-nav .links { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth .art { display: none; }
  .kv { grid-template-columns: 110px 1fr; }
}
.nav-brand { display: flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 700; font-size: 17px; text-decoration: none !important; }
.site-nav .nav-brand img { height: 50px; }
@media (max-width: 900px) { .nav-brand span { display: none; } }

/* ---------- إضافات ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 6px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: 13.5px; }
.tabs a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.badge.manual, .badge.queued { background: var(--warn-bg); color: var(--warn); }
.badge.sent { background: var(--ok-bg); color: var(--ok); }
.badge.failed, .badge.cancelled { background: var(--err-bg); color: var(--err); }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.doc { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; font-size: 13px; }
.doc .th { height: 100px; background: #f2f4f8 center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.doc .meta { padding: 8px 10px; }
.scan-box { border: 2px dashed #c9d6f0; border-radius: 14px; padding: 16px; background: #f7faff; margin-bottom: 16px; }
.scan-box .row { gap: 8px; }
.ai-out { white-space: pre-wrap; line-height: 1.9; min-height: 120px; }
.ai-out:empty::before { content: "سيظهر الرد هنا…"; color: var(--muted); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg) } }
.msg-body { white-space: pre-wrap; max-width: 420px; font-size: 13px; }
