/* لوحة الحجوزات — فاتحة، هادئة، بدون ظلال أو تدرجات */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e2e6eb;
  --line-strong: #cfd5dc;
  --text: #1d2630;
  --text-2: #5f6b78;
  --text-3: #8a95a1;
  --band: #34557a;
  --band-2: #2c4968;
  --band-text: #ffffff;
  --band-muted: #c9d6e4;
  --accent: #2f6db5;
  --accent-soft: #e8f0fa;
  --chart: #257de0;
  --ok: #1f7a4d;      --ok-soft: #e6f4ec;
  --warn: #9a6400;    --warn-soft: #fdf3df;
  --bad: #b3342f;     --bad-soft: #fbeceb;
  --info: #2f6db5;    --info-soft: #e8f0fa;
  --muted: #6b7580;   --muted-soft: #eef0f2;
  --r: 8px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.6 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 13px; direction: ltr; unicode-bidi: embed; }
.num { font-variant-numeric: tabular-nums; }

.wrap { max-width: 1320px; margin: 20px auto 40px; padding: 0 16px; }

/* ---------- الصندوق الموحّد: شريط + تبويبات + عنوان ---------- */
.shell { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.band { background: var(--band); color: var(--band-text); padding: 14px 20px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.band .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.band .brand i { font-size: 18px; opacity: .9; }
.band .hstats { display: flex; gap: 22px; margin-inline-start: 12px; }
.band .hstat { display: flex; flex-direction: column; line-height: 1.25; }
.band .hstat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.band .hstat span { font-size: 12px; color: var(--band-muted); }
.band .hstat.hs-alert b { color: #ffd7d4; }
.band .actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.band .btn-band { background: var(--band-2); color: #fff; border: 1px solid rgba(255,255,255,.18); border-radius: 6px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.band .btn-band:hover { background: #253f5a; text-decoration: none; }
.band .who { font-size: 13px; color: var(--band-muted); }

.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
.tabs a { padding: 11px 14px; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; display: flex; gap: 7px; align-items: center; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--band); border-bottom-color: var(--band); font-weight: 700; }
.tabs .badge { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 0 7px; font-size: 11px; }

.page-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.page-head h1 { font-size: 17px; margin: 0; font-weight: 700; }
.page-head .sub { color: var(--text-3); font-size: 13px; }
.page-head .tools { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-body { padding: 18px 20px 22px; }

/* ---------- عناصر عامة ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.card > .card-h { padding: 11px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; font-weight: 700; }
.card > .card-h .tools { margin-inline-start: auto; font-weight: 400; display: flex; gap: 6px; }
.card > .card-b { padding: 14px; }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1000px) { .g2, .g3, .g-main { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: 6px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #285f9e; }
.btn.danger { color: var(--bad); border-color: #e6c3c1; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ok { color: var(--ok); border-color: #bcdcc9; }
.btn.ok:hover { background: var(--ok-soft); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--muted-soft); }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; font-size: 13px; color: var(--text); background: #fff; border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 6px 9px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d1ee; outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; direction: ltr; text-align: left; min-height: 340px; }
label.f { display: block; }
label.f > span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; font-size: 13px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- الحالات ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.st-pending   { background: var(--warn-soft); color: var(--warn); border-color: #f1ddb0; }
.st-shipped   { background: var(--info-soft); color: var(--info); border-color: #c9dbf1; }
.st-delivered { background: var(--ok-soft);   color: var(--ok);   border-color: #c3e2d0; }
.st-returned  { background: var(--bad-soft);  color: var(--bad);  border-color: #f0cdcb; }
.st-deleted   { background: var(--muted-soft);color: var(--muted);border-color: #dde1e5; }
.tag { display: inline-block; padding: 0 7px; border-radius: 4px; background: var(--muted-soft); color: var(--text-2); font-size: 12px; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- الأرقام (KPI) ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.kpi { padding: 13px 15px; border-inline-start: 1px solid var(--line); }
.kpi:first-child { border-inline-start: 0; }
.kpi .k-l { font-size: 12px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.kpi .k-v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; line-height: 1.3; }
.kpi .k-v small { font-size: 12px; font-weight: 500; color: var(--text-3); }
.kpi .k-d { font-size: 12px; color: var(--text-3); }
.kpi .up { color: var(--ok); } .kpi .down { color: var(--bad); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpi:nth-child(4) { border-inline-start: 0; } .kpi:nth-child(n+4) { border-top: 1px solid var(--line); } }
@media (max-width: 620px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

.statusbar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; gap: 2px; background: var(--surface); }
.statusbar > div { min-width: 2px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 5px; vertical-align: -1px; }

.chart-box { position: relative; height: 260px; }
.chart-box.short { height: 190px; }

/* أشرطة أفقية بسيطة (HTML) */
.hbars { display: flex; flex-direction: column; gap: 7px; }
.hbar { display: grid; grid-template-columns: 120px minmax(0, 1fr) 54px; gap: 10px; align-items: center; font-size: 13px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.hbar .trk { height: 12px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; }
[dir=rtl] .hbar .fill { border-radius: 4px 0 0 4px; margin-inline-start: 0; }
.hbar .val { text-align: left; font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: right; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 12px; }
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover { background: #fafbfc; }
table.t tr.sel { background: var(--accent-soft) !important; }
table.t td.addr { max-width: 320px; }
table.t td.addr .a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.t .w1 { width: 1%; white-space: nowrap; }
.card table.t th:first-child, .card table.t td:first-child { padding-inline-start: 14px; }

.filters { display: grid; grid-template-columns: 2fr repeat(6, minmax(0, 1fr)) auto; gap: 8px; margin-bottom: 12px; align-items: end; }
@media (max-width: 1200px) { .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg a { padding: 5px 11px; font-size: 13px; color: var(--text-2); border-inline-start: 1px solid var(--line); }
.seg a:first-child { border-inline-start: 0; }
.seg a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg a:hover { text-decoration: none; background: var(--surface-2); }

.bulkbar { position: sticky; top: 0; z-index: 5; display: none; gap: 8px; align-items: center; padding: 8px 12px; margin-bottom: 10px; background: var(--accent-soft); border: 1px solid #c9dbf1; border-radius: var(--r); flex-wrap: wrap; }
.bulkbar.on { display: flex; }
.bulkbar select { width: auto; }

.pager { display: flex; gap: 6px; align-items: center; justify-content: space-between; margin-top: 12px; color: var(--text-2); font-size: 13px; flex-wrap: wrap; }

/* ---------- الخط الزمني ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .ic { color: var(--text-3); text-align: center; padding-top: 2px; }
.timeline .meta { color: var(--text-3); font-size: 12px; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }

.alert { padding: 9px 12px; border-radius: 6px; font-size: 13px; border: 1px solid; display: flex; gap: 8px; align-items: flex-start; }
.alert.bad { background: var(--bad-soft); color: var(--bad); border-color: #f0cdcb; }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: #f1ddb0; }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: #c3e2d0; }
.alert.info { background: var(--info-soft); color: var(--info); border-color: #c9dbf1; }
.alert ul { margin: 0; padding-inline-start: 18px; }

/* ---------- إشعارات ---------- */
#toasts { position: fixed; bottom: 18px; left: 18px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast { background: var(--text); color: #fff; padding: 10px 14px; border-radius: 6px; font-size: 13px; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---------- الدخول ---------- */
.login { max-width: 380px; margin: 9vh auto; }
.login .band { justify-content: center; }
.login form { padding: 22px; display: flex; flex-direction: column; gap: 14px; }

dialog { border: 1px solid var(--line); border-radius: var(--r); padding: 0; width: min(560px, 94vw); }
dialog::backdrop { background: rgba(20, 30, 40, .35); }
dialog .card-h { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; }
dialog .card-b { padding: 16px; }
dialog .card-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
