/* NALQIVO ERP — Sales application surface.
 *
 * The application header (context bar) is the only navigation row: the page
 * body never repeats sections or tabs. This file owns the workspace chrome —
 * masthead, KPI ribbon, command panel, filter chips, recent rail and table
 * polish — for the Sales app only. */

.sales-app { min-width: 0; }

/* ---- Masthead ------------------------------------------------------------ */
.sales-masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 2px 2px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.sales-masthead-copy { min-width: 0; }
.sales-masthead .page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding: 3px 9px;
  border: 1px solid var(--brand-100);
  border-radius: 999px;
  background: var(--brand-50);
  color: var(--brand-2);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1px;
}
.sales-masthead h1 {
  margin: 0;
  font-size: clamp(24px, 2vw, 28px);
  line-height: 1.15;
  letter-spacing: -0.5px;
  color: var(--ink);
}
.sales-masthead .page-sub {
  margin-top: 5px;
  max-width: 780px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
}
.sales-masthead-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 2px;
}
.sales-new {
  height: 38px;
  padding-inline: 15px;
  border-radius: 10px;
  font-size: 12.5px;
  box-shadow: 0 8px 18px rgba(108, 76, 241, 0.2);
}

/* ---- KPI ribbon ---------------------------------------------------------- */
.sales-pulse {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}
.sales-pulse.pulse-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.sp-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 12px 13px 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(25, 29, 51, 0.04);
  color: inherit;
  text-decoration: none;
  transition: transform 0.16s var(--easing, ease), box-shadow 0.16s ease, border-color 0.16s ease;
}
a.sp-card:hover,
a.sp-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--brand-200);
  box-shadow: 0 10px 22px rgba(25, 29, 51, 0.07);
}
.sp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.sp-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.sp-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.7px;
  line-height: 1.1;
  color: #102641;
  font-variant-numeric: tabular-nums;
}
.sp-value bdi {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-value.is-money { font-size: 19px; }
.sp-value em {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--muted);
}
.sp-note {
  min-height: 13px;
  font-size: 9.5px;
  line-height: 1.35;
  color: var(--muted-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sp-card.tone-purple .sp-icon { background: var(--purple-soft); color: var(--purple); }
.sp-card.tone-blue .sp-icon { background: var(--brand-50); color: var(--brand); }
.sp-card.tone-red .sp-icon { background: var(--red-soft); color: var(--red); }
.sp-card.tone-green .sp-icon { background: var(--green-soft); color: var(--green); }
.sp-card.tone-orange .sp-icon { background: var(--amber-soft); color: var(--amber); }

/* ---- Command panel ------------------------------------------------------- */
.sales-command {
  margin-top: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(25, 29, 51, 0.04);
  overflow: hidden;
}
.sc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  flex-wrap: wrap;
}
.sc-top { border-bottom: 1px solid var(--line); }
.sc-filters { background: linear-gradient(180deg, #fcfcff, #f9fafd); }
.sc-search { flex: 1 1 300px; max-width: 520px; min-width: 210px; }
.sc-search .input { height: 36px; min-height: 36px; font-size: 12.5px; }
.sc-count {
  flex: 0 0 auto;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}
.sc-spacer { flex: 1 1 0; }
.sc-divider { width: 1px; height: 22px; background: var(--line); margin-inline: 2px; }
.sc-sort { min-width: 128px; }
.sc-saved-select { max-width: 170px; min-width: 130px; }
.sc-filters .filter-select,
.sc-filters .input { height: 33px; min-height: 33px; font-size: 11.5px; }
.sc-filters .filter-select { min-width: 0; }
.sc-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-inline-end: 2px;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--muted);
}
.sc-dates { display: flex; align-items: center; gap: 6px; }
.sc-date {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 33px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}
.sc-date span { font-size: 10px; font-weight: 800; color: var(--muted-2); white-space: nowrap; }
.sc-date .input {
  width: 118px;
  height: 31px;
  min-height: 31px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
}

/* ---- Active filter chips ------------------------------------------------- */
.fchip-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 12px 10px;
  margin-top: -1px;
}
.fchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--brand-100);
  border-radius: 999px;
  background: var(--brand-50);
  color: var(--brand-2);
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}
.fchip:hover,
.fchip:focus-visible { background: var(--brand-100); }
.fchip span { opacity: 0.65; font-size: 12px; line-height: 1; }
.fchip svg { vertical-align: -2px; }
.fchip-clear {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--muted);
}
.fchip-clear:hover,
.fchip-clear:focus-visible { background: var(--surface-2); color: var(--ink); }

/* ---- Recent rail --------------------------------------------------------- */
.sales-recent {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 7px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(25, 29, 51, 0.04);
  min-width: 0;
}
.sales-recent-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}
.sales-recent-label svg { color: var(--brand); }
.sales-recent-rail {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: thin;
}
/* Fade only the edge that hides more chips: left in RTL, right in LTR. */
.sales-recent-rail.is-overflowing {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 18px, #000 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 18px, #000 100%);
}
[dir="ltr"] .sales-recent-rail.is-overflowing {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 18px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 18px), transparent 100%);
}
.sales-app .recent-chip {
  flex: 0 0 auto;
  gap: 5px;
  padding: 3px 9px;
}
.sales-app .recent-chip .rc-sub { max-width: 118px; }

/* ---- Table --------------------------------------------------------------- */
.sales-app .sales-table-card .table th {
  padding: 10px 14px;
  background: #fbfcff;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}
.sales-app .sales-table-card .table td { padding: 12px 14px; }
.sales-app .sales-table-card tbody tr.clickable:hover td { background: #faf9ff; }
.sales-app .sales-table-card .row-go {
  width: 34px;
  text-align: center;
  color: var(--muted-2);
  opacity: 0.45;
}
[dir="ltr"] .sales-app .sales-table-card .row-go svg { transform: scaleX(-1); }

/* ---- Empty state --------------------------------------------------------- */
.sales-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 34px 16px;
  text-align: center;
}
.sales-empty-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 4px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--brand-50);
  color: var(--brand);
}
.sales-empty-title { font-size: 14px; font-weight: 800; color: var(--ink); }
.sales-empty-sub { max-width: 330px; font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.sales-empty .btn { margin-top: 8px; }

/* ---- Sales invoice register --------------------------------------------- */
.inv-app { display: flex; flex-direction: column; gap: 0; }
.inv-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcfe, #fff);
}
.inv-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.inv-tab:hover,
.inv-tab:focus-visible { border-color: var(--brand-200); color: var(--brand); }
.inv-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.18);
}
.inv-tab-count {
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.07);
  color: inherit;
  font-size: 9.5px;
  font-weight: 800;
  text-align: center;
}
.inv-tab.active .inv-tab-count { background: rgba(255, 255, 255, 0.22); }

.inv-overview { display: flex; flex-direction: column; gap: 12px; }
.inv-currency-block {
  padding: 12px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(25, 29, 51, 0.04);
}
.inv-currency-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.inv-currency-code {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--brand);
  background: var(--brand-50);
  border-radius: 8px;
  padding: 3px 8px;
}
.inv-currency-note { font-size: 10px; color: var(--muted-2); }
.inv-pulse { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.inv-split {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 10.5px;
  color: var(--muted);
}
.inv-split b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.inv-split-today { margin-inline-start: auto; color: var(--green, #0f9d58); }
.inv-overview-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.inv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inv-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fcfdff;
}
.inv-filters .sc-search { flex: 1 1 260px; max-width: 360px; }
.inv-table { width: 100%; }
.inv-row.inv-late td:first-child { box-shadow: inset 3px 0 0 var(--red); }
[dir="rtl"] .inv-row.inv-late td:first-child { box-shadow: inset -3px 0 0 var(--red); }

/* ---- Sales invoice detail ------------------------------------------------ */
.inv-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}
.inv-back:hover { color: var(--brand); }
.inv-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.inv-detail-head h1 { margin: 2px 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -0.4px; }
.inv-detail-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.inv-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.inv-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 11px;
  color: var(--muted);
}
.inv-facts b { color: var(--ink); font-weight: 800; }
.inv-panel { padding: 0; }
.inv-subhead {
  padding: 10px 14px 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.inv-pay-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.inv-pay-summary b { color: var(--ink); font-weight: 800; }
.inv-audit { display: flex; flex-direction: column; padding: 6px 0; }
.inv-audit-row {
  display: flex;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px dashed var(--line);
}
.inv-audit-row:last-child { border-bottom: 0; }
.inv-audit-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.7;
}
.inv-audit-summary { font-size: 12px; font-weight: 600; color: var(--ink); line-height: 1.5; }
.inv-audit-meta { font-size: 10px; color: var(--muted-2); margin-top: 2px; }
.inv-line-table td { vertical-align: middle; }
.inv-line-table .input { min-width: 90px; }

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 1320px) {
  .sales-pulse,
  .sales-pulse.pulse-6 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sales-masthead { align-items: flex-start; }
  .sales-masthead-actions { margin-inline-start: 0; }
  .sales-pulse,
  .sales-pulse.pulse-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sc-search { max-width: none; }
}
@media (max-width: 620px) {
  .sales-pulse { gap: 8px; }
  .sp-value { font-size: 18px; }
  .sp-value.is-money { font-size: 16px; }
  .sales-masthead h1 { font-size: 22px; }
  .sc-row { padding: 8px 10px; }
  .sc-dates { width: 100%; }
  .sc-date { flex: 1 1 0; }
  .sc-date .input { width: 100%; }
}

/* ERP-7: quotation lines without the «نوع البند» column; customised-item spec. */
.line-grid.no-type { grid-template-columns: minmax(260px, 1fr) 82px 124px 104px 112px 30px; min-width: 712px; }
.line-item textarea.line-spec { height: auto; min-height: 58px; padding-block: 6px; margin-top: 4px; white-space: pre-wrap; resize: vertical; line-height: 1.5; }
.line-spec-text { white-space: pre-line; }
