/* WADAN LOGISTIQUE — Mobile-first, RTL */

@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url("../fonts/plex-arabic-arabic-400.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: "Plex Arabic"; font-weight: 500; font-display: swap; src: url("../fonts/plex-arabic-arabic-500.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: "Plex Arabic"; font-weight: 600; font-display: swap; src: url("../fonts/plex-arabic-arabic-600.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: "Plex Arabic"; font-weight: 700; font-display: swap; src: url("../fonts/plex-arabic-arabic-700.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: "Plex Arabic"; font-weight: 400; font-display: swap; src: url("../fonts/plex-arabic-latin-400.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url("../fonts/plex-arabic-latin-500.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url("../fonts/plex-arabic-latin-600.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url("../fonts/plex-arabic-latin-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  /* هوية WADAN: أزرق سماوي #00BFFF مع الأسود والأبيض */
  --brand: #00BFFF;
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --text: #0a0a0a;
  --muted: #5b6670;
  --border: #dde4ea;
  --primary: #00BFFF;          /* تعبئة الأزرار والعناصر المميزة */
  --primary-ink: #000000;      /* النص فوق الأزرق */
  --primary-soft: #e0f7ff;
  --link: #0077a3;             /* نص أزرق مقروء فوق الأبيض */
  --topbar: #000000;
  --topbar-ink: #ffffff;
  --danger: #d32f2f;
  --danger-soft: #fdecec;
  --warning: #c25e00;
  --warning-soft: #fff1e0;
  --success: #1e7d3a;
  --success-soft: #e5f5ea;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 1px 3px rgb(0 0 0 / .08);
  --radius: 14px;
  --topbar-h: 56px;
  --bottomnav-h: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Plex Arabic", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 16px; line-height: 1.6;
}
a { color: var(--link); text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h4 { font-size: .9rem; color: var(--muted); }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: .8rem; background: var(--surface-2); padding: .6rem; border-radius: 8px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.inline { display: inline; margin: 0; }

/* ---------- Topbar & navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: 0 1rem; padding-top: env(safe-area-inset-top);
  background: var(--topbar); color: var(--topbar-ink); border-bottom: 2px solid var(--brand);
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--topbar-ink); font-weight: 700; letter-spacing: .04em; }
.brand img { border-radius: 8px; }
.brand small { font-weight: 500; color: var(--brand); font-size: .7rem; }
.topbar-actions { display: flex; align-items: center; gap: .25rem; }
.user-chip { display: none; font-size: .9rem; padding: 0 .5rem; }
.user-chip small { color: var(--brand); }
.topbar .icon-btn { color: var(--topbar-ink); }
.topbar .icon-btn:hover { background: #1c1f21; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg, .nav-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.main { padding: 1rem; max-width: 1100px; margin: 0 auto; }
body.has-nav .main { padding-bottom: calc(var(--bottomnav-h) + 1.5rem + env(safe-area-inset-bottom)); }

.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .72rem; min-width: 0;
}
.bottomnav a.active { color: var(--link); font-weight: 600; }
.sidenav { display: none; }

@media (min-width: 900px) {
  .user-chip { display: inline; }
  .bottomnav { display: none; }
  body.has-nav .main { padding-bottom: 2rem; margin-inline-start: 240px; margin-inline-end: auto; }
  .sidenav {
    display: flex; flex-direction: column; gap: .25rem; position: fixed; top: var(--topbar-h); bottom: 0; inset-inline-start: 0;
    width: 230px; padding: 1rem .75rem; background: var(--surface); border-inline-end: 1px solid var(--border);
  }
  .sidenav a { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border-radius: 10px; color: var(--text); }
  .sidenav a:hover { background: var(--surface-2); }
  .sidenav a.active { background: var(--primary-soft); color: var(--link); font-weight: 600; }
}

/* ---------- Cards, stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.page-head { margin-bottom: 1rem; }
.page-head p { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; border-inline-start: 4px solid var(--success); }
.stat strong { display: block; font-size: clamp(1.05rem, 4.6vw, 1.6rem); line-height: 1.25; overflow-wrap: break-word; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-warn { border-inline-start-color: var(--warning); }
.stat-danger { border-inline-start-color: var(--danger); }

/* حالة السجلات: أحمر / برتقالي / أخضر */
.state-red    { border-inline-start: 4px solid var(--danger); }
.state-orange { border-inline-start: 4px solid var(--warning); }
.state-green  { border-inline-start: 4px solid var(--success); }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .78rem; }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-orange { background: var(--warning-soft); color: var(--warning); }
.badge-green { background: var(--success-soft); color: var(--success); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .95rem; }
.field > span { font-weight: 500; }
.field small { color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  min-height: 48px; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--link); }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-inline-end: 4.5rem; }
.password-wrap .link-btn { position: absolute; inset-inline-end: .5rem; top: 50%; transform: translateY(-50%); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: .6rem 1.1rem; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--primary); border-color: var(--link); color: var(--primary-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn:active { transform: translateY(1px); }
.link-btn { background: none; border: 0; color: var(--link); font: inherit; cursor: pointer; padding: .25rem; }
.hint { margin: 0; text-align: center; color: var(--muted); font-size: .9rem; }

.filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; align-items: end; }
.filters .btn { grid-column: 1 / -1; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(5, minmax(0, 1fr)) auto; } .filters .btn { grid-column: auto; } }

/* ---------- Alerts ---------- */
.alert { padding: .75rem 1rem; border-radius: 12px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.form .alert { margin-bottom: 0; }

/* ---------- Auth pages ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand h1 { font-size: 1.5rem; letter-spacing: .04em; margin: .5rem 0 0; }
.auth-brand h1 span { color: var(--muted); font-weight: 500; font-size: 1rem; }
.auth-brand p { margin: 0; color: var(--muted); }
.ref { font-family: ui-monospace, Consolas, monospace; font-size: 1.3rem; letter-spacing: .1em; font-weight: 700; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.audit-row header { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.audit-row .meta { margin: .25rem 0 0; color: var(--muted); font-size: .85rem; }
.audit-row details { margin-top: .5rem; }
.audit-row summary { cursor: pointer; color: var(--link); }
.diff { display: grid; gap: .5rem; margin-top: .5rem; }
@media (min-width: 700px) { .diff { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.empty { text-align: center; color: var(--muted); padding: 2rem 0; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 1rem 0; }

/* ---------- Idle warning ---------- */
.idle-warning {
  position: fixed; inset-inline: 1rem; bottom: calc(var(--bottomnav-h) + 1rem); z-index: 50;
  background: var(--surface); border: 1px solid var(--warning); border-radius: var(--radius);
  padding: 1rem; box-shadow: 0 8px 24px rgb(0 0 0 / .2); display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.idle-warning p { margin: 0; }
@media (min-width: 900px) { .idle-warning { inset-inline: auto 1.5rem; bottom: 1.5rem; max-width: 420px; } }

/* ---------- Phase 2: lists, details, actions ---------- */
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.narrow { max-width: 560px; margin-inline: auto; }
.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; letter-spacing: .02em; }
.small { font-size: .9rem; }
.list-item { display: block; color: inherit; margin-bottom: .6rem; }
.list-item:hover { border-color: var(--link); }
.list-item .meta { margin: .2rem 0 0; color: var(--muted); font-size: .88rem; }
.is-muted { opacity: .6; }
.search-bar { display: flex; gap: .5rem; }
.search-bar input { flex: 1; }
.field-error { color: var(--danger) !important; font-weight: 500; }
.record-meta { color: var(--muted); font-size: .85rem; margin: .75rem 0 0; }
.notes { white-space: normal; margin-top: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.plain li:last-child { border-bottom: 0; }
.actions { display: flex; flex-direction: column; gap: .6rem; }
.actions form { margin: 0; }
.actions-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; align-items: flex-start; }
.actions-row .alert { margin: 0; width: 100%; }
.danger-zone summary { list-style: none; }
.danger-zone summary::-webkit-details-marker { display: none; }
.danger-zone[open] { width: 100%; }
.danger-zone[open] > form { margin-top: .75rem; padding: .75rem; border: 1px solid var(--danger); border-radius: 12px; }
.secret-box { display: grid; gap: .75rem; margin: 1rem 0; padding: 1rem; background: var(--surface-2); border-radius: 12px; }
.secret-box div { display: flex; flex-direction: column; }
.secret-box strong { font-size: 1.3rem; user-select: all; }

/* ---------- Phase 3: containers, items, scanner ---------- */
.bottomnav a.primary { color: var(--primary-ink); }
.bottomnav a.primary .nav-icon { background: var(--primary); color: var(--primary-ink); width: 44px; height: 44px; padding: 10px; border-radius: 50%; margin-top: -18px; box-shadow: 0 4px 12px rgb(11 92 173 / .35); }
.bottomnav a.primary span { color: var(--link); font-weight: 600; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .5rem; scrollbar-width: none; }
.chip { flex: none; padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .88rem; white-space: nowrap; }
.chip.active { background: var(--primary); border-color: var(--link); color: var(--primary-ink); }
.chip-red { border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.chip-red.active { background: var(--danger); border-color: var(--danger); color: #fff; }
.fieldset { border: 1px solid var(--border); border-radius: 12px; padding: .75rem; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.fieldset legend { padding: 0 .4rem; font-weight: 600; }
.segmented { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; }
.segmented label { display: flex; align-items: center; gap: .5rem; min-height: 48px; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.segmented label:has(input:checked) { border-color: var(--link); background: var(--primary-soft); color: var(--link); font-weight: 600; }
.segmented input { width: auto; min-height: 0; accent-color: var(--link); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; }
.currency-note { color: var(--muted); font-size: .82rem; margin: 0; }
.freight-preview { margin: 0; padding: .6rem .8rem; border-radius: 10px; background: var(--warning-soft); color: var(--warning); font-weight: 600; }
.inline-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.sub { font-size: 1rem; margin-top: .75rem; }
.link-btn.danger { color: var(--danger); }
.btn-sm { min-height: 36px; padding: .3rem .7rem; font-size: .85rem; border-radius: 9px; }
.history { margin-top: 1rem; }
.history summary { cursor: pointer; color: var(--link); }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.stepper li { position: relative; padding: .4rem 2rem .4rem 0; color: var(--muted); }
.stepper li::before { content: ""; position: absolute; inset-inline-start: .35rem; top: .75rem; width: .8rem; height: .8rem; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); }
.stepper li.done { color: var(--text); }
.stepper li.done::before { background: var(--success); border-color: var(--success); }
.stepper li.current { color: var(--text); font-weight: 600; }
.stepper li.current::before { background: var(--primary); border-color: var(--link); box-shadow: 0 0 0 4px var(--primary-soft); }
.stepper small { display: block; font-weight: 400; color: var(--muted); }
@media (min-width: 700px) { .stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.item-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.item-main { display: flex; flex-direction: column; color: inherit; min-width: 0; }
.item-main span { overflow-wrap: anywhere; }
.item-side { display: flex; align-items: center; gap: .5rem; flex: none; }
.qr-card { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.qr-card img { background: #fff; border-radius: 8px; padding: 4px; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
@media (min-width: 700px) { .menu-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.menu-tile { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 1.25rem .5rem; color: var(--text); text-align: center; margin: 0; }
.menu-tile .nav-icon { width: 28px; height: 28px; color: var(--link); }
.scanner-view { position: relative; aspect-ratio: 1; max-width: 420px; margin: 0 auto .75rem; border-radius: 14px; overflow: hidden; background: #000; }
.scanner-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-frame { position: absolute; inset: 15%; border: 3px solid rgb(255 255 255 / .85); border-radius: 16px; box-shadow: 0 0 0 999px rgb(0 0 0 / .35); }
.scanner { display: flex; flex-direction: column; gap: .5rem; }
[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.photo-scan { cursor: pointer; }
[data-photo-preview] { max-width: 220px; max-height: 220px; margin: .25rem auto 0; border-radius: 10px; object-fit: contain; }

/* ---------- Phase 4: fines ---------- */
.fine-running { color: var(--danger); font-weight: 600; }
.fine-warning { color: var(--warning); font-weight: 600; }
.fine-exempt { color: var(--success); }
.fine-free { color: var(--muted); }
.text-danger { color: var(--danger); }
a.stat { color: inherit; }
.segmented.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.add-exemption { margin-top: .75rem; }
.add-exemption summary { list-style: none; }
.add-exemption summary::-webkit-details-marker { display: none; }
.add-exemption[open] > form { margin-top: .75rem; }
.plain li.state-red, .plain li.state-orange, .plain li.state-green { padding-inline-start: .6rem; }

/* ---------- Phase 5: delivery & payment ---------- */
.delivery-line { border: 1px solid var(--border); border-radius: 12px; padding: .75rem; margin-bottom: .75rem; display: flex; flex-direction: column; gap: .6rem; }
.delivery-line p { margin: 0; }
.amounts { background: var(--surface-2); border-radius: 10px; padding: .6rem .75rem; }
.grid-span { grid-column: 1 / -1; }
.totals-card .total-due { font-size: 1.35rem; color: var(--link); }
.btn-lg { min-height: 56px; font-size: 1.1rem; }
.check { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; }
.check input { width: auto; min-height: 0; margin-top: .35rem; accent-color: var(--link); }
.debt-check { margin-top: .75rem; padding: .6rem; border: 1px dashed var(--danger); border-radius: 10px; }
.add-items { margin: .5rem 0 1rem; }
.pay-block { border: 1px solid var(--border); border-radius: 12px; padding: .75rem; margin-bottom: .75rem; display: flex; flex-direction: column; gap: .6rem; }
.pay-bank { display: flex; flex-direction: column; gap: .6rem; }
.pay-preview { max-width: 200px; max-height: 260px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border); }
.pay-note { padding: .5rem .75rem; border-radius: 10px; background: var(--surface-2); font-size: .9rem; }
.pay-note p { margin: 0; }
.pay-note.ok { background: var(--success-soft); color: var(--success); }
.pay-note.warn { background: var(--warning-soft); color: var(--warning); }
.pay-note.danger { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.pay-mismatch { margin: 0; color: var(--danger); font-weight: 600; font-size: .88rem; }
.pay-summary { font-weight: 600; margin: .5rem 0 0; }
.pay-summary.ok { color: var(--success); } .pay-summary.warn { color: var(--warning); } .pay-summary.danger { color: var(--danger); }
.input-danger { border-color: var(--danger) !important; outline-color: var(--danger) !important; }
.signature-pad { position: relative; border: 2px dashed var(--border); border-radius: 12px; background: #fff; }
.signature-pad canvas { display: block; width: 100%; height: 180px; touch-action: none; border-radius: 10px; }
.signature-pad .link-btn { position: absolute; inset-inline-start: .5rem; bottom: .25rem; }
.signature-view img { max-width: 280px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.signature-view { margin: .75rem 0 0; }
.pay-thumb { max-width: 120px; max-height: 160px; border-radius: 6px; border: 1px solid var(--border); margin-top: .4rem; }
.dialog { border: 0; border-radius: var(--radius); padding: 1rem; width: min(520px, calc(100vw - 2rem)); background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgb(0 0 0 / .3); }
.dialog::backdrop { background: rgb(0 0 0 / .45); }
.decision { display: grid; gap: .75rem; margin-top: .5rem; }
@media (min-width: 700px) { .decision { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.bell { position: relative; }
.bell-count { position: absolute; top: 4px; inset-inline-end: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; }
.notif { padding: 0; }
.notif-btn { all: unset; display: flex; flex-direction: column; gap: .2rem; padding: 1rem; cursor: pointer; width: 100%; box-sizing: border-box; }
.inline-input { flex: 1; min-width: 140px; }

/* ---------- الهوية والعملة ---------- */
.cur-toggle { min-height: 34px; padding: 0 .6rem; border-radius: 999px; border: 1px solid var(--brand); background: transparent;
  color: var(--brand); font: inherit; font-weight: 700; font-size: .8rem; cursor: pointer; letter-spacing: .05em; }
.cur-toggle:hover { background: var(--brand); color: #000; }
.auth-brand img { border-radius: 14px; box-shadow: 0 6px 24px rgb(0 191 255 / .25); }
.auth-brand h1 span { color: var(--link); }
.stat { border-inline-start-color: var(--brand); }

/* ---------- Phase 6: invoices ---------- */
.invoice-search { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; align-items: end; }
.invoice-search .btn { grid-column: 1 / -1; }
@media (min-width: 900px) { .invoice-search { grid-template-columns: repeat(5, minmax(0, 1fr)); } .invoice-search .btn { grid-column: auto; } }
.invoice-row a { color: inherit; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.invoice-row .mono { color: var(--link); }

/* ---------- Phase 7: accounts & treasury ---------- */
.bal-pos { color: var(--success); }
.bal-neg { color: var(--danger); }
.bal-zero { color: var(--text); }
.stat.bal-pos { border-inline-start-color: var(--success); }
.stat.bal-neg { border-inline-start-color: var(--danger); }
.stat.bal-zero { border-inline-start-color: var(--border); }
.text-success { color: var(--success); }
.section-title { font-size: 1rem; color: var(--muted); margin: 1.25rem 0 .5rem; }
.period-filter { display: flex; flex-direction: column; gap: .5rem; }
.period-filter .chips { margin: 0; padding: 0; }
.period-filter .range { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; align-items: end; }
.accounts-grid { display: grid; gap: .75rem; }
@media (min-width: 700px) { .accounts-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.account-card { display: flex; flex-direction: column; gap: .2rem; color: var(--text); margin: 0; border-inline-start: 5px solid var(--border); }
.account-card.bal-pos { border-inline-start-color: var(--success); }
.account-card.bal-neg { border-inline-start-color: var(--danger); background: var(--danger-soft); }
.account-card.bal-zero { border-inline-start-color: var(--border); background: var(--surface); }
.account-card .balance { font-size: 1.45rem; font-weight: 700; }
.account-card.bal-pos .balance { color: var(--success); }
.account-card.bal-neg .balance { color: var(--danger); }
.account-card.bal-zero .balance { color: var(--text); }
.account-card .link { color: var(--link); margin-top: .3rem; }
.balance-total { display: flex; justify-content: space-between; align-items: center; }
.balance-total strong { font-size: 1.5rem; }
.balance-total.bal-pos strong { color: var(--success); } .balance-total.bal-neg strong { color: var(--danger); }
.table-wrap { overflow-x: auto; padding: 0; }
table.ledger { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 640px; }
table.ledger th { background: #000; color: #fff; padding: .6rem .5rem; text-align: start; font-weight: 600; }
table.ledger td { padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.ledger td.in { color: var(--success); white-space: nowrap; }
table.ledger td.out { color: var(--danger); white-space: nowrap; }
table.ledger tr.total td { font-weight: 700; border-top: 2px solid var(--text); }
.nowrap { white-space: nowrap; }
.src-row { padding: .5rem; border: 1px dashed var(--border); border-radius: 10px; }
.segmented.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .segmented.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.customer-balance { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; border-inline-start: 6px solid; }
.customer-balance strong { font-size: 1.35rem; }
.customer-balance.owes { border-inline-start-color: var(--danger); background: var(--danger-soft); }
.customer-balance.owes strong, .customer-balance.owes .stat-label { color: var(--danger); }
.customer-balance.paid { border-inline-start-color: var(--success); background: var(--success-soft); }
.customer-balance.paid strong, .customer-balance.paid .stat-label { color: var(--success); }

/* ---------- Phase 8 ---------- */
.details-body { margin-top: .75rem; }
.request-edit { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin: 0; width: 100%; }
.checklist { list-style: none; margin: 0 0 1rem; padding: .75rem 1rem; background: var(--surface-2); border-radius: 12px; display: grid; gap: .25rem; font-size: .9rem; }

/* ---------- تحسين الشكل: نفس الهوية (سماوي، أسود، أبيض) بلمسات أنعم ---------- */
:root {
  --bg: #f1f5f8;
  --border: #e1e8ee;
  --primary-soft: #e3f7ff;
  --shadow: 0 1px 2px rgb(10 30 45 / .04), 0 10px 26px -18px rgb(0 60 90 / .35);
  --radius: 16px;
}
body { background: radial-gradient(1200px 380px at 50% -160px, rgb(0 191 255 / .10), transparent 70%) no-repeat, var(--bg); }
.topbar { background: linear-gradient(90deg, #000 0%, #071319 100%); border-bottom: 0; box-shadow: 0 2px 0 var(--brand), 0 8px 24px -14px rgb(0 0 0 / .6); }
.brand span { font-size: 1.02rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; }
.card { border-color: var(--border); }
a.card.list-item, .list-item { transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
a.card.list-item:hover, a.list-item:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -18px rgb(0 90 130 / .55); border-color: var(--brand); }
.stat { background: linear-gradient(180deg, #fff 0%, #f7fbfd 100%); box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
a.stat:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -18px rgb(0 90 130 / .6); }
.stat-label { font-weight: 500; }
.btn { transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, filter .15s ease; }
.btn:hover { border-color: var(--brand); }
.btn-primary { background: linear-gradient(180deg, #2acbff 0%, #00acea 100%); border-color: transparent; color: #000;
  box-shadow: 0 8px 18px -10px rgb(0 150 210 / .9); }
.btn-primary:hover { filter: brightness(1.05); border-color: transparent; }
.btn-danger:hover { filter: brightness(1.08); border-color: var(--danger); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(0 191 255 / .22); }
.chip { transition: border-color .15s ease, background .15s ease; }
.chip:hover { border-color: var(--brand); }
.chip.active { background: linear-gradient(180deg, #2acbff, #00acea); border-color: transparent; font-weight: 600; }
.bottomnav { background: rgb(255 255 255 / .94); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  box-shadow: 0 -6px 20px -14px rgb(0 0 0 / .35); }
.bottomnav a.primary .nav-icon { background: linear-gradient(180deg, #2acbff, #00acea); box-shadow: 0 6px 16px rgb(0 150 210 / .45); }
@media (min-width: 900px) {
  .sidenav { background: #fff; }
  .sidenav a { transition: background .15s ease; }
  .sidenav a.active { background: var(--primary-soft); color: #00597a; box-shadow: inset -3px 0 0 var(--brand); }
}
table.ledger th { background: #0a1014; }
.auth-body { background: radial-gradient(900px 520px at 50% -120px, rgb(0 191 255 / .18), transparent 70%) no-repeat, var(--bg); }
.auth-wrap .card { box-shadow: 0 24px 60px -30px rgb(0 70 100 / .45); }

/* ---------- التذييل: توقيع BSM Solutions · قسم التحول الرقمي ---------- */
.credit-foot { display: flex; flex-direction: column; align-items: center; gap: .6rem; margin: 2rem 0 .5rem; padding-top: 1.25rem;
  border-top: 1px solid var(--border); text-align: center; }
.credit { display: flex; align-items: center; gap: .75rem; direction: ltr; }
.credit-logo { display: grid; place-items: center; padding: 4px 8px; border-radius: 10px; background: #fff; box-shadow: 0 6px 16px -10px rgb(0 0 0 / .5); }
.credit-logo img { display: block; height: 30px; width: auto; }
.credit-txt { display: flex; flex-direction: column; line-height: 1.2; text-align: start; }
.credit-txt small { font-size: .68rem; color: var(--muted); }
.credit-txt strong { font-size: .95rem; letter-spacing: .1em; color: var(--text); }
.credit-txt em { font-style: normal; font-size: .66rem; letter-spacing: .04em; color: var(--link); }
.credit-wa { display: inline-flex; align-items: center; height: 32px; padding: 0 .9rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  color: #fff; background: #1fa855; box-shadow: 0 8px 18px -10px rgb(31 168 85 / .8); }
.credit-wa:hover { background: #25d366; color: #fff; }
.credit-copy { font-size: .72rem; color: var(--muted); }
@media (min-width: 900px) { .credit-foot { flex-direction: row; justify-content: space-between; flex-wrap: wrap; } }
@media print { .credit-foot { display: none; } }
