:root {
  --bg: #f7f4ef;
  --card: #ffffff;
  --ink: #1a1814;
  --accent: #8a7349;
  --accent-2: #b89a63;
  --accent-3: #0b74de;
  --danger: #b63e2a;
  --ok: #1f8a55;
  --warn: #c47a12;
  --border: #ddd2c0;
  --muted: #6b655c;
  --brand-beige: #c4a574;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Tajawal", "Cairo", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background:
    radial-gradient(circle at 18% 18%, rgba(196, 165, 116, 0.18), transparent 40%),
    radial-gradient(circle at 84% 10%, rgba(138, 115, 73, 0.1), transparent 36%),
    linear-gradient(180deg, #fbfaf7 0%, #f0ebe3 100%);
  color: var(--ink);
  /* الاتجاه يأتي من html[dir] (ar=rtl / en=ltr) — لا تفرض rtl هنا */
}

.app-watermark {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
}
.app-watermark img {
  width: min(70vw, 720px);
  opacity: 0.08;
  object-fit: contain;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 22px;
  background: #f7f4ef;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 2;
}
.brand-logo-rekaz {
  background: #fff;
  padding: 8px 12px;
}
.topbar-main {
  position: relative;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-logo {
  width: min(28vw, 280px);
  height: 84px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  padding: 3px 6px;
  box-shadow: 0 4px 12px rgba(57, 43, 97, 0.12);
}
.edge-logo { position: absolute; top: 50%; transform: translateY(-50%); }
.edge-left { left: 0; }
.edge-right { right: 0; }
.brand {
  text-align: center;
  font-weight: 800;
  font-size: clamp(18px, 1.8vw, 28px);
  color: var(--accent);
  max-width: calc(100% - 600px);
  line-height: 1.2;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.brand small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}
.topbar-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.92rem;
}
.lang-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.lang-switch a {
  color: var(--accent-2);
  text-decoration: none;
}
.lang-switch a.active { color: var(--accent); text-decoration: underline; }

.tabs {
  display: flex;
  gap: 10px;
  padding: 10px 22px 0;
  background: #f7f4ef;
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 2;
  font-family: "Tajawal", "Cairo", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 20.3px;
  color: #201c2e;
  unicode-bidi: isolate;
  box-sizing: border-box;
}
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  line-height: 20.3px;
  color: var(--ink);
  background: #fff;
  white-space: nowrap;
  flex: 0 0 auto;
}
.tab:hover {
  border-color: #b7d5ef;
  color: var(--accent);
  background: #f1f8ff;
}
.tab:active,
.tab.active {
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 8px 16px rgba(138, 115, 73, 0.28);
}
.tab.active:hover {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(180deg, #c4a574 0%, var(--accent) 100%);
}

.container,
.container.container-wide {
  /* App-wide ultra-wide: full viewport, light side padding only (no 960/1100/1280 traps) */
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: 18px clamp(12px, 1.4vw, 40px) 40px;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
}
/* Every content surface stretches with the container (ops, warehouses, finance, HR, workshop, contracts, quality, custom tabs, forms, hubs, lists) */
main.container > .card,
main.container > .page,
main.container .table-wrap,
main.container .stats-grid,
main.container .form-grid,
main.container .meta-grid,
main.container .toolbar,
.quality-hub,
.quality-hub .table-wrap,
.quality-hub .quality-table,
.tickets-page,
.tickets-page .tickets-table-wrap,
.tickets-page .tickets-filters {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}
.tickets-page .tickets-table-wrap {
  -webkit-overflow-scrolling: touch;
}
.tickets-page .tickets-table {
  width: 100%;
  min-width: 640px;
}
.tickets-page .stats-grid {
  margin-bottom: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(11, 94, 215, 0.08);
  padding: 16px;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-title {
  margin: 0;
  color: #123f69;
  font-size: 1.25rem;
}
.meta, .ui-hint { color: var(--muted); font-size: 0.9rem; }

/* إخفاء التلميحات / النصوص الإرشادية من الواجهة (بدون لمس رسائل الخطأ) */
.login-hint,
.ui-hint,
.qflow__hint,
.photo-storage-hint,
.quality-empty-hint,
.stat-card > .meta,
.toolbar > div > .meta {
  display: none !important;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
  border: 1px solid #8a7349;
  background: #fff;
  color: #5a4a2e;
  padding: 8px 13px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.92rem;
}
.btn:hover { filter: brightness(0.98); }
.btn.primary {
  background: linear-gradient(135deg, #c4a574 0%, #8a7349 100%);
  color: #fff;
  border-color: #8a7349;
}
.btn.ghost { background: #fff; }
.actions[data-tab-strip] .btn.primary {
  background: linear-gradient(135deg, #c4a574 0%, #8a7349 100%);
  color: #fff;
  border-color: #8a7349;
}
.btn.danger {
  background: #fff5f3;
  border-color: #e2aaa0;
  color: var(--danger);
}
.btn:disabled,
.btn[disabled] {
  opacity: 0.62;
  cursor: not-allowed;
  filter: none;
  display: inline-flex !important;
  visibility: visible !important;
}
.programmer-otp-actions .programmer-otp-btn {
  display: inline-flex !important;
  visibility: visible !important;
  min-height: 40px;
}
.programmer-otp-box {
  display: block !important;
  visibility: visible !important;
}
.wh-tx-options {
  appearance: auto;
  -webkit-appearance: menulist;
  min-width: 118px;
  max-width: 168px;
  padding-inline-end: 10px;
  cursor: pointer;
}
.wh-tx-options:focus {
  outline: 2px solid rgba(138, 115, 73, 0.35);
  outline-offset: 1px;
}
.delete-pw-backdrop {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  inset: 0 !important;
  z-index: 2147483646 !important;
  background: rgba(12, 22, 34, 0.62);
  display: flex !important;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px 24px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  isolation: isolate;
  pointer-events: auto !important;
  touch-action: manipulation;
}
.delete-pw-backdrop[hidden] { display: none !important; }
body.delete-pw-open {
  overflow: hidden !important;
  touch-action: none;
}
.delete-pw-dialog {
  position: relative;
  z-index: 2147483647 !important;
  width: min(440px, 100%);
  margin: 0 auto;
  background: #fff;
  border: 2px solid #8a7349;
  border-radius: 14px;
  padding: 20px 18px 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  pointer-events: auto !important;
  transform: translateZ(0);
  -webkit-user-select: text;
  user-select: text;
}
.delete-pw-dialog .btn,
.delete-pw-dialog input,
.delete-pw-dialog label,
.delete-pw-dialog * {
  pointer-events: auto !important;
}
.delete-pw-dialog input {
  position: relative;
  z-index: 2;
  background: #fff !important;
  color: #122030 !important;
  -webkit-user-select: text !important;
  user-select: text !important;
  caret-color: #122030;
}
.delete-pw-dialog .btn {
  position: relative;
  z-index: 2;
  min-height: 42px;
  cursor: pointer !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  background: linear-gradient(180deg, #f7fbff, #fff);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.stat-card div { color: var(--muted); font-size: 0.9rem; }
.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.45rem;
  color: #123f69;
}
.stat-card .meta {
  margin-top: 6px;
  font-size: 0.82rem;
  line-height: 1.35;
}
.warehouse-qty-summary {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 12px;
  /* Override fixed 4-col grid so N cards (incl. بدون مبلغ) share one row */
  grid-template-columns: none;
}
.warehouse-qty-summary .stat-card {
  flex: 1 1 0;
  min-width: 0;
  background: #fff;
  box-sizing: border-box;
}
a.stat-card {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
a.stat-card:hover {
  border-color: #7eb0d6;
  box-shadow: 0 2px 10px rgba(18, 63, 105, 0.08);
}
.stat-card.is-active {
  border-color: #c45c26;
  background: linear-gradient(180deg, #fff8f3, #fff);
  box-shadow: 0 0 0 1px rgba(196, 92, 38, 0.25);
}
.stat-card.is-active strong {
  color: #9a3d12;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.col-item-name {
  max-width: 9.5rem;
  width: 9.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
th.col-item-name {
  white-space: nowrap;
}
td.col-item-name[title]:hover {
  cursor: help;
}
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}
.table th, .table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e5edf6;
  text-align: right;
  white-space: nowrap;
}
.table th {
  background: #f3f8ff;
  color: #3d5f82;
  font-weight: 800;
}
.table tr:hover td { background: #f9fcff; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.badge.ok { background: #e3f6df; color: #1f6b3d; border-color: #b7e0b0; }
.badge.warn { background: #fff4c6; color: #8a5b00; border-color: #f0d98a; }
.badge.danger { background: #ffe2e2; color: #8f2b1d; border-color: #f0b4b4; }
.badge.info { background: #e3efff; color: #174f93; border-color: #b7cff0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.field { display: grid; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-weight: 700; font-size: 0.88rem; }
.field input, .field select, .field textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11,116,222,0.12);
}

.flash-list { display: grid; gap: 8px; margin-bottom: 12px; }
.flash {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.flash.ok { background: #e3f6df; border-color: #b7e0b0; }
.flash.danger { background: #ffe2e2; border-color: #f0b4b4; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.meta-item {
  background: #f7fbff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.meta-item .k { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.meta-item .v { margin-top: 4px; font-weight: 800; color: #123f69; word-break: break-word; }

.app-footer {
  text-align: center;
  color: var(--muted);
  padding: 18px;
  position: relative;
  z-index: 1;
  font-size: 0.88rem;
}

.jump-fab {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 40;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 1px solid #8a7349;
  background: linear-gradient(135deg, #c4a574, #8a7349);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(138, 115, 73, 0.35);
}
.jump-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 50, 0.45);
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 16px;
}
.jump-backdrop[hidden] { display: none !important; }
.jump-modal {
  width: min(640px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(16, 61, 103, 0.25);
  overflow: hidden;
}
.jump-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: #f3f8ff;
  border-bottom: 1px solid var(--border);
}
.jump-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  font: inherit;
  font-size: 1.05rem;
  outline: none;
}
.jump-list {
  max-height: 420px;
  overflow: auto;
  padding: 8px;
}
.jump-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
}
.jump-item:hover, .jump-item.active {
  background: linear-gradient(90deg, rgba(11,116,222,0.12), rgba(11,116,222,0.04));
}
.jump-title { font-weight: 800; color: #123f69; }
.jump-group { color: var(--muted); font-size: 0.85rem; font-weight: 700; }
.jump-empty { padding: 20px; text-align: center; color: var(--muted); }

.progress-bar {
  height: 10px;
  background: #e8f1fb;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}
.check-list { display: grid; gap: 8px; margin-top: 12px; }
.check-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f9fcff;
}
.check-item.ok { background: #eefaf3; border-color: #b7e0b0; }
.check-item.miss { background: #fff8f0; border-color: #f0d98a; }
.check-item .mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: #fff;
  border: 1px solid var(--border);
}
.check-item.ok .mark { color: var(--ok); border-color: #b7e0b0; }
.check-item.miss .mark { color: var(--warn); border-color: #f0d98a; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #3d5f82;
}
.flash.warn { background: #fff4c6; border-color: #f0d98a; }

/* سجل الصور — خانات الرفع قبل / أثناء / بعد */
.photo-slot {
  display: grid;
  gap: 8px;
}
.photo-slot .photo-preview {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f3f7fb;
}
.photo-slot .photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 220px;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  border: 1px dashed #c5d5e6;
  background: #f7fafc;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}
.photo-slot input[type="file"] {
  font-size: 0.85rem;
  padding: 6px;
}
.photo-slot .photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 0.85rem;
  color: #3d5f82;
}
.photo-thumb {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  vertical-align: middle;
  background: #f3f7fb;
}
.photo-pdf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 220px;
  min-height: 88px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #e2d3b8;
  background: linear-gradient(180deg, #fffdf8, #f7f1e6);
  color: #5c4a2d;
  font-weight: 800;
  text-decoration: none;
  text-align: center;
}
.photo-pdf:hover {
  border-color: var(--accent);
  color: #3f3424;
}
.photo-pdf-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 42px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #e2d3b8;
  background: #fff7ea;
  color: #5c4a2d;
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
  vertical-align: middle;
}
.photo-pdf-chip:hover {
  border-color: var(--accent);
}
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.attachment-list.is-compact {
  gap: 6px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  max-width: 180px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 0.82rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip:hover {
  border-color: var(--accent);
}
.photo-thumbs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.photo-cell-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 4px;
}
.photo-storage-hint {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.login-wrap {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card { width: min(420px, 100%); }

.ticket-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ticket-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: #5a4a2e;
  background: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}
.ticket-step-num {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f3ebe0;
  font-size: 0.8rem;
}
.ticket-step.is-active {
  border-color: #8a7349;
  background: linear-gradient(135deg, #f8f1e6 0%, #efe4d2 100%);
  box-shadow: 0 0 0 2px rgba(138, 115, 73, 0.18);
}
.ticket-step-panel.is-active {
  border-color: #8a7349;
  box-shadow: 0 0 0 2px rgba(138, 115, 73, 0.2), 0 14px 34px rgba(11, 94, 215, 0.08);
}

/* ---- مركز التنسيقات والجودة — تنقّل احترافي ---- */
.quality-subnav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.qnav-main {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 8px;
  align-items: stretch;
  padding: 10px;
  background: linear-gradient(180deg, #fffdf8, #f7f1e6);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 8px 22px rgba(138, 115, 73, 0.08);
}
.qnav-main__item {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.qnav-main__item:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: #e2d3b8;
  transform: translateY(-1px);
}
.qnav-main__item.is-active {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(138, 115, 73, 0.14);
}
.qnav-main__num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: #efe4d2;
  color: #5c4a2d;
  flex: 0 0 auto;
}
.qnav-main__item.is-active .qnav-main__num {
  background: var(--accent);
  color: #fff;
}
.qnav-main__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.qnav-main__text strong {
  font-size: 0.98rem;
  line-height: 1.25;
}
.qnav-main__text small {
  color: var(--muted);
  font-size: 0.78rem;
}
.qnav-main__arrow {
  width: 18px;
  align-self: center;
  height: 2px;
  background: linear-gradient(90deg, #d7c4a4, #b89a63);
  position: relative;
}
html[dir="rtl"] .qnav-main__arrow::after {
  content: "";
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: #b89a63;
}
html[dir="ltr"] .qnav-main__arrow::after {
  content: "";
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: #b89a63;
}
.qnav-subs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.qnav-sub {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #e5d9c5;
  background: #fff;
  font-size: 0.86rem;
  font-weight: 700;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.qnav-sub em {
  font-style: normal;
  min-width: 1.5em;
  padding: 1px 7px;
  border-radius: 999px;
  background: #f1e8d8;
  color: #5c4a2d;
  font-size: 0.78rem;
}
.qnav-sub:hover {
  border-color: var(--accent);
}
.qnav-sub.is-active {
  background: linear-gradient(180deg, #fff8ea, #f4e7cf);
  border-color: var(--accent);
  color: #4a3a20;
}
.qnav-sub.is-active em {
  background: var(--accent);
  color: #fff;
}

.qflow-card {
  margin: 0 0 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #fffdf9, #f8f2e8);
  box-shadow: 0 8px 20px rgba(138, 115, 73, 0.07);
}
.qflow-card.card {
  /* يمنع تراكب ظل/خلفية بطاقة عامة فوق مسار الجودة */
  box-shadow: 0 8px 20px rgba(138, 115, 73, 0.07);
}
.qflow__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.qflow__eyebrow {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.qflow__title {
  font-weight: 800;
  font-size: 1.05rem;
  color: #3f3424;
}
.qflow__badge {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: #efe4d2;
  color: #5c4a2d;
  font-size: 0.8rem;
  font-weight: 800;
}
.qflow__steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 18px 1fr 18px 1fr;
  gap: 8px;
  align-items: stretch;
}
.qflow__step {
  margin: 0;
}
.qflow__link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-height: 78px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid #e4d6bf;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.qflow__link:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(138, 115, 73, 0.12);
}
.qflow__index {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: #efe4d2;
  color: #5c4a2d;
  flex: 0 0 auto;
}
.qflow__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.qflow__label {
  font-weight: 800;
  font-size: 0.95rem;
}
.qflow__hint {
  color: var(--muted);
  font-size: 0.78rem;
}
.qflow__connector {
  height: 2px;
  align-self: center;
  background: #d8c7a8;
  border-radius: 99px;
}
.qflow__step.is-done .qflow__index {
  background: var(--ok);
  color: #fff;
}
.qflow__step.is-current .qflow__link {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fffaf0, #fff);
  box-shadow: 0 10px 22px rgba(138, 115, 73, 0.14);
}
.qflow__step.is-current .qflow__index {
  background: var(--accent);
  color: #fff;
}
.qflow__connector.is-done {
  background: linear-gradient(90deg, #1f8a55, #b89a63);
}
.qflow-mini {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid #e2d3b8;
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
  vertical-align: middle;
}
.qflow-mini a {
  text-decoration: none;
  color: #4a3a20;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 10px;
  border-inline-start: 1px solid #eee3d2;
  white-space: nowrap;
}
.qflow-mini a:first-child {
  border-inline-start: 0;
}
.qflow-mini a:hover {
  background: #fff7ea;
  color: #2f2618;
}
.quality-hub .quality-breadcrumb {
  margin-bottom: 4px;
  font-size: 0.88rem;
}
@media (max-width: 980px) {
  .qnav-main,
  .qflow__steps {
    grid-template-columns: 1fr;
  }
  .qnav-main__arrow,
  .qflow__connector {
    display: none;
  }
}
.quality-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
  margin: 12px 0 14px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #f3f7fc, #eef4fb);
  border: 1px solid #d5e2f0;
  border-radius: 14px;
}
.quality-filter label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 700;
}
.quality-filter select,
.quality-filter input[type="text"] {
  min-width: 140px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-family: inherit;
}
.quality-filter-search {
  flex: 1 1 240px;
}
.quality-filter-search input {
  width: 100%;
  min-width: 220px;
}
.quality-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.quality-summary-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(57, 43, 97, 0.05);
}
.quality-summary-card strong {
  display: block;
  margin: 6px 0 4px;
  color: #3d2f6b;
  font-size: 1.05rem;
}
.quality-metric-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.quality-metric-row.compact {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.quality-count-cards {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 0 0 14px;
}
.quality-count-cards-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.quality-count-cards .quality-metric {
  min-height: 96px;
  text-align: center;
}
.quality-count-cards .quality-metric strong {
  font-size: 1.85rem;
}
.quality-metric {
  display: block;
  text-decoration: none;
  color: inherit;
  background: linear-gradient(180deg, #faf8ff, #fff);
  border: 1px solid #ddd5ef;
  border-radius: 14px;
  padding: 14px 12px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
a.quality-metric:hover {
  border-color: #8a7349;
  transform: translateY(-1px);
}
a.quality-metric.active {
  border-color: #8a7349;
  background: linear-gradient(180deg, #fff8e8, #fff);
  box-shadow: 0 6px 16px rgba(138, 115, 73, 0.14);
}
.quality-metric div {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}
.quality-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
  color: #3d2f6b;
}
.quality-empty-hint {
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  background: #fbfaf7;
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.quality-evac-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.quality-evac-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}
.quality-evac-card strong {
  font-size: 2rem;
  color: #3d2f6b;
  line-height: 1;
}
.quality-table {
  min-width: 1100px;
}

@media (max-width: 1100px) {
  .stats-grid, .form-grid, .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Summary cards: keep one even row on tablet+ (override 2-col stats-grid) */
  .warehouse-qty-summary {
    display: flex;
    flex-wrap: nowrap;
    grid-template-columns: none;
  }
  .warehouse-qty-summary .stat-card {
    flex: 1 1 0;
    min-width: 0;
  }
  .brand-logo { width: 120px; height: 48px; }
  .quality-summary,
  .quality-evac-cards,
  .quality-metric-row,
  .quality-metric-row.compact,
  .quality-count-cards,
  .quality-count-cards-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 720px) {
  .stats-grid, .form-grid, .meta-grid { grid-template-columns: 1fr; }
  /* Very small phones: compact 2-up wrap; still prefer equal cards */
  .warehouse-qty-summary {
    display: flex;
    flex-wrap: wrap;
    grid-template-columns: none;
  }
  .warehouse-qty-summary .stat-card {
    flex: 1 1 calc(50% - 6px);
    min-width: min(100%, 140px);
  }
  .quality-count-cards,
  .quality-count-cards-3 {
    grid-template-columns: 1fr;
  }
  .edge-logo { display: none; }
  .tabs {
    padding: 10px 14px 0;
  }
  .tab {
    padding: 7px 10px;
    font-size: 12px;
  }
  .quality-summary,
  .quality-evac-cards,
  .quality-metric-row,
  .quality-metric-row.compact {
    grid-template-columns: 1fr;
  }
  .container,
  .container.container-wide {
    padding-inline: 10px;
  }
  .tickets-page .tickets-table {
    min-width: 560px;
  }
  .tickets-page .tickets-table .actions {
    flex-wrap: nowrap;
  }
  .tickets-page .tickets-table .btn {
    padding: 6px 8px;
    font-size: 12px;
  }
}
