@font-face {
  font-family: "Cairo";
  src: url("../vendor/fonts/cairo-arabic.cdfdf6997ccf.woff2") format("woff2");
  font-weight: 200 1000;
  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-display: swap;
}
@font-face {
  font-family: "Cairo";
  src: url("../vendor/fonts/cairo-latin.ead8e97c01f0.woff2") format("woff2");
  font-weight: 200 1000;
  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-display: swap;
}

:root {
  --brand: #1f4e79;
  --brand-dark: #163a5c;
  --sidebar-w: 250px;
  --bs-body-font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  --bs-body-font-size: 1rem;
  --bs-primary: #1f4e79;
  --bs-primary-rgb: 31, 78, 121;
}
body { background: #f3f5f8; min-height: 100vh; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }
.text-primary { color: var(--brand) !important; }
a { color: var(--brand); }

/* ---------- layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--brand-dark); color: #fff;
  position: fixed; top: 0; bottom: 0; right: 0; overflow-y: auto; z-index: 1030;
}
.sidebar .brand, .sidebar-mobile .brand {
  display: block; padding: 1rem 1.25rem; font-weight: 800; font-size: 1.2rem; color: #fff; text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-mobile { background: var(--brand-dark); color: #fff; }
.navmenu { padding: .5rem 0 2rem; }
.navmenu .nav-link { color: rgba(255,255,255,.85); padding: .55rem 1.25rem; border-radius: 0; display: flex; gap: .6rem; align-items: center; }
.navmenu .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.navmenu .nav-link.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 700; border-right: 4px solid #ffc107; }
.nav-section { font-size: .75rem; color: rgba(255,255,255,.5); padding: .9rem 1.25rem .25rem; }

.main { flex: 1; min-width: 0; }
html, body { overflow-x: clip; }
@media (min-width: 992px) { .main { margin-right: var(--sidebar-w); } }
.topbar {
  background: var(--brand); color: #fff; display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; position: sticky; top: 0; z-index: 1020;
}
.brand-sm { color: #fff; font-weight: 800; text-decoration: none; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topsearch { position: relative; max-width: 480px; }
.topsearch i { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); color: #888; }
.topsearch input { padding-right: 2.2rem; border: 0; }
.content { padding: 1.25rem; max-width: 1400px; }
@media (max-width: 991.98px) {
  .content { padding: .75rem .75rem 5.5rem; }
}

/* bottom nav للموبايل */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid #ddd;
  display: flex; z-index: 1030; padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 8px rgba(0,0,0,.05);
}
.bottomnav a {
  flex: 1; text-align: center; padding: .45rem 0 .35rem; color: #555; text-decoration: none; font-size: .75rem;
  display: flex; flex-direction: column; align-items: center;
}
.bottomnav a i { font-size: 1.35rem; }
.bottomnav a.active { color: var(--brand); font-weight: 700; }

/* ---------- عناصر */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.4rem; font-weight: 800; margin: 0; flex: 1; min-width: 200px; }
.card { border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); border-radius: .75rem; }
.card-header { background: #fff; font-weight: 700; border-bottom: 1px solid #eee; border-radius: .75rem .75rem 0 0 !important; }
.stat { padding: 1rem; border-radius: .75rem; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06); height: 100%; }
.stat .label { color: #666; font-size: .9rem; }
.stat .value { font-size: 1.5rem; font-weight: 800; }
.stat .icon { font-size: 1.8rem; opacity: .25; float: left; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.quick a {
  background: #fff; border-radius: .75rem; padding: 1rem .5rem; text-align: center; text-decoration: none; color: #222;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); font-weight: 700; transition: transform .1s;
}
.quick a:hover { transform: translateY(-2px); }
.quick a i { display: block; font-size: 2rem; margin-bottom: .25rem; }
.table { --bs-table-bg: transparent; }
.table thead th { background: #f7f8fa; font-weight: 700; white-space: nowrap; font-size: .9rem; }
.table td { vertical-align: middle; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.form-label { font-weight: 600; margin-bottom: .25rem; }
.form-control, .form-select { min-height: 44px; }
.btn { min-height: 40px; }
.btn-lg { min-height: 52px; }
.errorlist { color: #dc3545; list-style: none; padding: 0; margin: .25rem 0 0; font-size: .9rem; }
.badge-in { background: #d1f2df; color: #0f6b3a; }
.badge-out { background: #fde2e1; color: #9b1c1c; }
.text-in { color: #0f6b3a; }
.text-out { color: #b42318; }
.empty { text-align: center; color: #888; padding: 2.5rem 1rem; }
.empty i { font-size: 2.5rem; display: block; margin-bottom: .5rem; }

/* جدول بيتحول كروت على الموبايل */
@media (max-width: 767.98px) {
  .table-cards thead { display: none; }
  .table-cards tr { display: block; background: #fff; border-radius: .6rem; margin-bottom: .6rem; padding: .5rem .75rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
  .table-cards td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .2rem 0; text-align: left; }
  .table-cards td::before { content: attr(data-label); font-weight: 600; color: #666; text-align: right; }
  .table-cards td[data-label=""]::before, .table-cards td:not([data-label])::before { content: none; }
  .table-cards td.title-cell { font-weight: 800; font-size: 1.05rem; justify-content: flex-start; text-align: right; }
}

/* فاتورة */
.inv-lines td { padding: .35rem; }
.inv-lines input { min-width: 80px; }
.inv-total { font-size: 1.6rem; font-weight: 800; }
@media (max-width: 767.98px) {
  .inv-lines thead { display: none; }
  .inv-lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: .4rem; padding: .6rem .75rem; border-bottom: 1px solid #eee; align-items: end; }
  .inv-lines td { border: 0; padding: 0 !important; }
  .inv-lines td:first-child { grid-column: 1 / -1; }
  .inv-lines td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; color: #777; }
  .inv-lines input { min-width: 0; }
  .inv-lines .ltotal { padding-bottom: .6rem !important; }
}
.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0; }
.ts-control { min-height: 44px; }
.ts-dropdown .option small { color: #777; }

/* طباعة */
@media print {
  .sidebar, .topbar, .bottomnav, .no-print, .alert { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); padding: 1rem; }
.login-card { width: 100%; max-width: 400px; }

/* ---------------- المساعدة ---------------- */
.mark-n {
  display: inline-flex; align-items: center; justify-content: center; width: 1.6em; height: 1.6em;
  border-radius: 50%; background: #e53935; color: #fff; font-weight: 700; font-size: .85em;
  vertical-align: middle; flex-shrink: 0;
}
.kbd-ar {
  display: inline-block; padding: 0 .45em; border: 1px solid #cfd6df; border-bottom-width: 2px;
  border-radius: 6px; background: #fff; font-weight: 700; white-space: nowrap; line-height: 1.6;
}
.help-search { position: relative; max-width: 720px; }
.help-search i { position: absolute; top: 50%; right: 1rem; transform: translateY(-50%); color: #888; }
.help-search input { padding-right: 2.75rem; }
.help-start {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-radius: 14px;
  background: var(--brand); color: #fff; text-decoration: none; max-width: 720px;
}
.help-start:hover { color: #fff; filter: brightness(1.1); }
.help-start > .bi:first-child { font-size: 2rem; }
.help-legend {
  display: flex; gap: .6rem; align-items: center; max-width: 720px; padding: .75rem 1rem;
  background: #fff7e6; border: 1px solid #ffe2a8; border-radius: 12px; font-size: .95rem;
}
.help-card {
  display: flex; align-items: center; gap: .75rem; height: 100%; padding: .85rem 1rem; border-radius: 12px;
  background: #fff; border: 1px solid #e3e7ec; color: inherit; text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.help-card:hover { border-color: var(--brand); box-shadow: 0 2px 8px rgba(31,78,121,.12); color: inherit; }
.help-card > .bi { font-size: 1.6rem; color: var(--brand); flex-shrink: 0; }
.help-guide { max-width: 980px; }
.help-intro { font-size: 1.1rem; line-height: 1.9; }
.help-steps { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.help-steps > li {
  display: flex; gap: 1rem; padding: 1.1rem 1.1rem 1.1rem 1.25rem; margin-bottom: .9rem;
  background: #fff; border: 1px solid #e3e7ec; border-radius: 14px;
}
.step-n {
  flex-shrink: 0; width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.2rem;
}
.step-body { flex: 1; min-width: 0; }
.step-text { font-size: 1.05rem; line-height: 2; }
.step-text ul { margin: .25rem 0; padding-right: 1.2rem; }
.step-text li { margin-bottom: .2rem; }
.step-img { margin: .75rem 0 0; }
.step-img img {
  max-width: 100%; border-radius: 10px; border: 1px solid #d5dbe2; box-shadow: 0 2px 10px rgba(0,0,0,.08);
  cursor: zoom-in;
}
.step-img.phone img { max-width: 300px; }
.step-img figcaption { font-size: .85rem; color: #6c757d; margin-top: .35rem; }
.help-callout { display: flex; gap: .75rem; padding: 1rem 1.1rem; border-radius: 12px; line-height: 1.9; }
.help-callout > .bi { font-size: 1.4rem; flex-shrink: 0; }
.help-callout.warn { background: #fff4f2; border: 1px solid #f5c2bc; }
.help-callout.warn > .bi { color: #d9480f; }
.help-callout.tip { background: #f0f7ff; border: 1px solid #c5dcf5; }
.help-callout.tip > .bi { color: #f2b400; }
.help-callout ul { padding-right: 1.2rem; }
.help-nav { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 575.98px) {
  .help-steps > li { flex-direction: column; gap: .5rem; padding: .9rem; }
  .step-n { width: 2rem; height: 2rem; font-size: 1rem; }
  .help-nav { grid-template-columns: 1fr; }
  .help-intro { font-size: 1rem; }
}
@media print {
  .help-steps > li { break-inside: avoid; border-color: #bbb; }
  .step-img img { max-height: 420px; box-shadow: none; }
  .help-guide { max-width: none; }
}

/* ---------------- شاشة البداية ---------------- */
.welcome { max-width: 900px; }
.welcome-hero { background: linear-gradient(135deg, var(--brand), #2d6da3); color: #fff; border-radius: 16px; padding: 1.5rem 1.75rem; }
.welcome-tile { display: flex; gap: .75rem; height: 100%; padding: 1rem; background: #fff; border: 1px solid #e3e7ec; border-radius: 12px; }
.welcome-tile > .bi { font-size: 1.8rem; color: var(--brand); }
.welcome-steps { list-style: none; padding: 0; margin: 0; }
.welcome-steps li { display: flex; gap: 1rem; padding: 1rem 1.1rem; margin-bottom: .6rem; background: #fff; border: 1px solid #e3e7ec; border-radius: 14px; }
.welcome-steps li:not(.done) { border: 2px solid var(--brand); box-shadow: 0 3px 12px rgba(31,78,121,.12); }
.welcome-steps li:not(.done) ~ li:not(.done) { border: 1px solid #e3e7ec; box-shadow: none; }
.welcome-steps li.done { background: #f6fbf7; }
.welcome-steps li.done .fs-6 { color: #6c757d; }
.ws-check { flex-shrink: 0; width: 2.2rem; height: 2.2rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; background: #eef2f6; color: #555; }
.welcome-steps li.done .ws-check { background: #198754; color: #fff; font-size: 1.2rem; }
.welcome-done { text-align: center; padding: 1.5rem; background: #f0faf3; border: 1px solid #b7e1c5; border-radius: 14px; }
.min-w-0 { min-width: 0; }
.onboard-card { display: flex; align-items: center; gap: 1rem; padding: .9rem 1.1rem; border-radius: 14px; background: #fff8e6; border: 1px solid #ffd977; color: inherit; text-decoration: none; }
.onboard-card:hover { color: inherit; border-color: #f2b400; }
.onboard-card > .bi:first-child { font-size: 1.6rem; color: #d99a00; }
