/* نظام إدارة الكارتات — مأخوذ من تصميم Claude Design */
:root {
  --navy: #06375f;
  --navy-hover: #0a4a7d;
  --gold: #b9a884;
  --gold-ink: #8a7650;
  --bg: #f5f3ee;
  --ink: #14273b;
  --muted: #6b6a63;
  --muted-2: #8a877d;
  --text-2: #4a4a44;
  --line: #e8e3d8;
  --line-2: #efebe2;
  --line-3: #f1ede4;
  --input: #dcd6c8;
  --thead: #faf8f3;
  --total: #f3efe6;
  --danger: #a33a2c;
  --danger-bg: #f8e6e2;
  --danger-line: #efcbc3;
  --ok: #2f6b43;
  --ok-bg: #e4f1e8;
  --green: #38834e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); font-family: 'Tajawal', sans-serif; color: var(--ink); }
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold-ink); }
input, select, textarea, button { font-family: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted-2); }
.ltr { direction: ltr; display: inline-block; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 264px; flex: none; background: var(--navy); color: #cfd8e2; position: sticky; top: 0; right: 0; height: 100vh; z-index: 50; transition: transform .25s ease; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar .brand { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 22px 20px 18px; border-bottom: 1px solid rgba(185,168,132,.18); }
.sidebar .brand .logos { display: flex; align-items: center; gap: 14px; }
.sidebar .brand img { height: 30px; width: auto; }
.sidebar .brand img.partner { height: 22px; }
.sidebar .brand .sep { width: 1px; height: 26px; background: rgba(233,225,207,.3); }
.sidebar .brand .t1 { font-size: 16px; font-weight: 700; color: var(--gold); }
.sidebar .brand .t2 { font-size: 11.5px; color: #9fb0c2; }
.sidebar nav { padding: 12px 12px 24px; display: flex; flex-direction: column; gap: 16px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11.5px; color: #8ea2b7; padding: 4px 12px 6px; font-weight: 500; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border-radius: 10px; color: #cfd8e2; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(185,168,132,.16); color: #fff; font-weight: 700; box-shadow: inset -3px 0 0 var(--gold); }
.nav-item i { width: 18px; font-size: 16px; text-align: center; }
.nav-item .dot-wrap { width: 18px; display: grid; place-items: center; }
.nav-item .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255,255,255,.08); }
.nav-item .label { flex: 1; }
.nav-item .count { font-size: 11.5px; color: #9fb0c2; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(6,30,52,.45); z-index: 40; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); height: 66px; display: flex; align-items: center; gap: 14px; padding: 0 clamp(14px,2.5vw,28px); }
.topbar .menu-btn { display: none; width: 40px; height: 40px; border: 1px solid var(--input); border-radius: 10px; background: #fff; cursor: pointer; font-size: 20px; color: var(--navy); place-items: center; }
.topbar .titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.topbar .title { font-size: 18px; font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #efe9dc; color: var(--gold-ink); display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.user-meta { display: flex; flex-direction: column; gap: 1px; }
.user-meta .n { font-size: 14px; font-weight: 500; }
.user-meta .r { font-size: 11.5px; color: var(--muted-2); }
.content { padding: clamp(14px,2.5vw,28px); display: flex; flex-direction: column; gap: 20px; max-width: 2400px; width: 100%; margin-inline: auto; }
/* الشاشات العريضة جداً (34 بوصة / ‎3440px) */
@media (min-width: 2200px) {
  .content { gap: 24px; }
  .grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 991px) {
  .sidebar { position: fixed; transform: translateX(100%); }
  body.sb-open .sidebar { transform: none; }
  body.sb-open .overlay { display: block; }
  .topbar .menu-btn { display: grid; }
  .user-meta { display: none; }
}

/* ---------- cards / sections ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.card.clip { overflow: hidden; }
.card-pad { padding: 18px 20px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.card-head .hsub { font-size: 12px; color: var(--muted-2); }
.card-head .stack { display: flex; flex-direction: column; gap: 2px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(0,1fr); gap: 20px; }
.grid-2r { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.9fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,560px),1fr)); gap: 20px; }
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit,minmax(210px,1fr)); gap: 16px; }
.grid-stage-tables { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.15fr); gap: 20px; }
.grid-stage-tables.single { grid-template-columns: minmax(0,1fr); }
@media (max-width: 991px) { .grid-2, .grid-2r, .grid-stage-tables { grid-template-columns: minmax(0,1fr); } }

/* ---------- buttons ---------- */
.btn { height: 40px; padding: 0 16px; border: 1px solid var(--input); border-radius: 10px; background: #fff; color: var(--ink); font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { color: var(--ink); background: var(--thead); }
.btn-primary { border: none; background: var(--navy); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--navy-hover); color: #fff; }
.btn-outline { border-color: var(--navy); color: var(--navy); font-weight: 500; }
.btn-danger-o { border-color: var(--danger-line); color: var(--danger); }
.btn-danger-o:hover { background: #fbf1ef; color: var(--danger); }
.btn-sm { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; gap: 5px; }
.btn-sm.navy { color: var(--navy); font-weight: 500; }
.btn-sm.navy:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-icon { width: 32px; padding: 0; }
.btn-lg { height: 44px; padding: 0 24px; font-size: 15px; }
.btn-link { border: none; background: none; color: var(--navy); font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 0; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field label .req { color: var(--danger); }
.field.sm label { font-size: 12px; color: var(--muted); font-weight: 400; }
.input, .select, .textarea { height: 42px; padding: 0 12px; border: 1px solid var(--input); border-radius: 10px; font-size: 14px; background: #fff; color: var(--ink); outline: none; width: 100%; }
.textarea { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(6,55,95,.12); }
.input.sm, .select.sm { height: 40px; font-size: 13.5px; padding: 0 10px; }
.input.xs, .select.xs { height: 38px; font-size: 13.5px; padding: 0 10px; border-radius: 9px; }
.is-invalid { border-color: #d4513e !important; }
.form-grid { padding: 20px; display: grid; grid-template-columns: repeat(auto-fit,minmax(230px,1fr)); gap: 16px; }
.full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; color: var(--ink); }
.tbl th { padding: 10px 16px; font-weight: 500; font-size: 12.5px; color: var(--muted); background: var(--thead); border-bottom: 1px solid #ece7dc; text-align: right; white-space: nowrap; }
.tbl td { padding: 11px 16px; border-bottom: 1px solid var(--line-3); }
.tbl .l { text-align: left; }
.tbl .c { text-align: center; }
.tbl .b { font-weight: 700; }
.tbl .m { font-weight: 500; }
.tbl tr.total td { background: var(--total); font-weight: 700; padding: 12px 16px; border-bottom: none; }
.tbl tbody tr.hover:hover { background: var(--thead); }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.canceled { opacity: .62; }
.tbl tr.canceled td.strike { text-decoration: line-through; }
.tbl td.dim { color: #c4bfb2; }
.tbl td.soft { color: var(--muted); }

/* ---------- badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill .d { width: 7px; height: 7px; border-radius: 50%; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.off { background: #f5f3ee; color: var(--muted); }
.code { font-family: monospace; font-size: 12.5px; background: var(--bg); padding: 3px 8px; border-radius: 6px; }

/* ---------- alerts / empty ---------- */
.alert-err { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--danger-bg); border: 1px solid var(--danger-line); color: var(--danger); font-size: 13.5px; }
.alert-err ul { margin: 0; padding-inline-start: 18px; }
.empty { padding: 40px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted-2); text-align: center; }
.empty .ic { width: 52px; height: 52px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 22px; color: var(--gold); }
.empty .t { font-size: 14px; font-weight: 500; color: var(--text-2); }
.empty .s { font-size: 12.5px; }

/* ---------- toast ---------- */
.toast { position: fixed; top: 80px; left: 24px; z-index: 100; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; border: 1px solid; box-shadow: 0 12px 30px -12px rgba(6,55,95,.35); font-size: 14px; font-weight: 500; max-width: 380px; animation: toastIn .25s ease; }
.toast.success { background: #edf6ef; color: #24603a; border-color: #c7e1cf; }
.toast.error { background: #fbefec; color: #8e2f23; border-color: var(--danger-line); }
.toast i { font-size: 18px; }
.toast button { border: none; background: none; color: inherit; cursor: pointer; opacity: .7; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(6,30,52,.5); z-index: 80; display: none; place-items: center; padding: 16px; }
.modal.open { display: grid; }
.modal-box { width: 100%; max-width: 520px; background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 30px 60px -20px rgba(0,0,0,.35); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-x { width: 34px; height: 34px; border: none; border-radius: 9px; background: var(--bg); cursor: pointer; font-size: 14px; color: var(--text-2); }
.modal-body { padding: 20px 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; background: var(--thead); }
.warn { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: #fbf1ef; color: #7d2a1f; font-size: 13.5px; }

/* ---------- dashboard ---------- */
.pipeline { display: flex; align-items: stretch; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.pipe-step { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 172px; }
.pipe-card { flex: 1; text-align: right; border: 1px solid #ece7dc; border-top: 4px solid var(--c); border-radius: 12px; background: #fff; padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 10px; color: var(--ink); }
.pipe-card:hover { box-shadow: 0 8px 20px -10px rgba(6,55,95,.3); border-color: #ddd5c4; border-top-color: var(--c); color: var(--ink); }
.ic-box { border-radius: 10px; display: grid; place-items: center; flex: none; }
.bars { position: relative; display: flex; align-items: flex-end; border-bottom: 1px solid #e3ddcf; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.bar-labels { display: flex; }
.bar-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap; }
.legend-sq { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.progress { height: 12px; background: var(--line-3); border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 6px; }

/* ---------- stage pills ---------- */
.stage-pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.stage-pill { flex: 1; min-width: 140px; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.stage-pill .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; background: var(--bg); color: var(--muted); flex: none; }
.stage-pill .lbl { flex: 1; text-align: right; }
.stage-pill .v { opacity: .85; font-size: 12px; }

.tabs { display: flex; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; align-self: flex-start; }
.tabs a { height: 36px; padding: 0 16px; border-radius: 9px; color: var(--text-2); font-size: 13.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.tabs a.active { background: var(--navy); color: #fff; }

.pager { padding: 14px 20px; display: flex; align-items: center; justify-content: center; gap: 6px; border-top: 1px solid var(--line-2); }
.pager a, .pager span { min-width: 36px; height: 36px; border: 1px solid var(--input); border-radius: 9px; background: #fff; color: var(--ink); display: grid; place-items: center; font-weight: 500; padding: 0 8px; }
.pager .active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pager .disabled { opacity: .45; }

@media print {
  html, body { background: #fff; }
  [data-noprint] { display: none !important; }
  [data-printwrap] { padding: 0 !important; background: #fff !important; }
  [data-sheet] { box-shadow: none !important; zoom: 1 !important; }
}

/* نسخة العرض للمدير (VPS): شريط آخر تحديث، وأزرار التعديل مخفية (المنع الحقيقي من السيرفر) */
.mirror-banner { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-radius: 12px; background: var(--navy-bg, #eef1fb); border: 1px solid var(--line, #d9deea); color: var(--text-2, #334); font-size: 13.5px; margin-bottom: 14px; }
.mirror-banner--stale { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.is-mirror form[method="POST"]:not(.keep-mirror),
.is-mirror form[method="post"]:not(.keep-mirror),
.is-mirror a[href*="/transfers/create"],
.is-mirror a[href*="/uploads/create"],
.is-mirror a[href*="/outlet-sale"],
.is-mirror a[href$="/sell"],
.is-mirror a[href*="/sell?"],
.is-mirror [data-open],
.is-mirror [data-mirror-hide] { display: none !important; }

