/* ════════════════════════════════════════════════════════════════════════
   ماشین حساب فروش و تنظیمات قیمت‌گذاری
   جدا از styles.css نگه داشته شده تا این بخش مستقل بماند.
   ════════════════════════════════════════════════════════════════════════ */

.pc-page { display: flex; flex-direction: column; gap: 16px; }

/* ── فرم ورودی ──────────────────────────────────────── */
.pc-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.pc-f { display: flex; flex-direction: column; gap: 6px; }
.pc-f > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.pc-f input, .pc-f select {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 14px; background: var(--surface); color: var(--text); width: 100%;
}
.pc-f input:focus, .pc-f select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.pc-f .pc-unit { font-size: 11px; color: var(--muted); font-weight: 400; }

/* ── کارت‌های نتیجه ─────────────────────────────────── */
.pc-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.pc-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.pc-card.hero { border-color: var(--primary); }
.pc-card .pc-lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.pc-card .pc-val { font-size: 24px; font-weight: 700; margin-top: 4px; line-height: 1.25; }
.pc-card.hero .pc-val { color: var(--primary); }
.pc-card .pc-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── نوار تفکیک قیمت ────────────────────────────────── */
.pc-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.pc-box > h3 { margin: 0 0 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.pc-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.pc-bar > div { min-width: 2px; transition: width 0.25s; }
.pc-seg-mat { background: #7f77dd; }
.pc-seg-oh  { background: #5dcaa5; }
.pc-seg-fin { background: #ef9f27; }
.pc-seg-pro { background: #378add; }
.pc-seg-hid { background: #e24b4a; }
.pc-legend { display: grid; gap: 6px 18px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-top: 12px; }
.pc-lrow { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pc-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pc-lrow .pc-nm { color: var(--muted); }
.pc-lrow .pc-amt { margin-inline-start: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.pc-lrow.credit .pc-amt { color: var(--success); }
.pc-lrow.total { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 2px; grid-column: 1 / -1; }
.pc-lrow.total .pc-nm { color: var(--text); font-weight: 700; }

.pc-line-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary);
  font-size: 13px; font-weight: 700;
}

/* ── هشدارها ────────────────────────────────────────── */
.pc-warn {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 8px;
  font-size: 13px; background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--warning); border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
}
.pc-warn.bad { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.pc-warn svg { flex: none; margin-top: 2px; }

/* ── تنظیمات قیمت فروش ─────────────────────────────── */
.ps-page { display: flex; flex-direction: column; gap: 16px; padding-bottom: 72px; }
.ps-note { font-size: 13px; color: var(--muted); margin: 0; }
.pc-avg-hd { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; }
.pc-avg-hd h4 { margin: 0; }
.ps-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.ps-f { display: flex; flex-direction: column; gap: 5px; }
.ps-f > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.ps-f > small { font-size: 11px; color: var(--muted); font-weight: 400; }
.ps-f input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 14px; background: var(--surface); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ps-f input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }

.ps-scroll { overflow-x: auto; }
.ps-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.ps-tbl th, .ps-tbl td { border-bottom: 1px solid var(--border); padding: 7px 8px; text-align: right; white-space: nowrap; }
.ps-tbl th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--surface-2); position: sticky; top: 0; }
.ps-tbl td input {
  width: 100%; min-width: 92px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 13px; background: var(--surface); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ps-tbl td input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.ps-tbl td.ps-name input { min-width: 130px; font-weight: 600; }
.ps-tbl td.ps-calc { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }
.ps-tbl tr.off { opacity: 0.45; }
.ps-tbl td.ps-act { width: 40px; }
.ps-del {
  border: none; background: transparent; color: var(--danger); cursor: pointer;
  padding: 3px 6px; border-radius: 6px; line-height: 0;
}
.ps-del:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.ps-add { margin-top: 10px; }

.ps-save {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 16px; margin-top: 4px;
}
.ps-save .ps-dirty { font-size: 12px; color: var(--warning); font-weight: 600; }
.ps-save .ps-spacer { margin-inline-start: auto; }

/* ── نشان کاغذ (حروف اختصاری + رنگ، از جدول کاغذهای تنظیمات) ────────── */
.pc-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.pc-chip.big { font-size: 14px; font-weight: 700; }
.pc-chip .pc-swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.pc-chip.big .pc-swatch { width: 14px; height: 14px; }
.pc-chip .pc-chip-nm { white-space: nowrap; }
.pc-chip.orphan { color: var(--muted); }
.pc-abbr {
  font: 700 11px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.4px;
  padding: 3px 6px; border-radius: 6px; border: 1px solid; flex: none;
}
.pc-prod { display: flex; flex-direction: column; gap: 6px; }
.pc-chipwrap { min-height: 18px; }
.pc-result-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pc-result-head .pc-spec {
  font-size: 12px; color: var(--muted); background: var(--surface-2);
  padding: 4px 10px; border-radius: 999px; font-weight: 600;
}
.ps-flag { font-size: 11px; color: var(--muted); font-weight: 600; }
.ps-flag.on { color: var(--success); }
.ps-tbl td.ps-name { font-weight: 600; }
.ps-tbl-narrow { max-width: 620px; }
.ps-line-block { margin-bottom: 18px; }
.ps-line-block h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }

/* ── پیش‌فاکتور ──────────────────────────────────────────────────── */
.pc-result-head .ps-spacer, .pc-box > h3 .ps-spacer { margin-inline-start: auto; }
.pc-add { flex: none; }
.pf-head { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 12px; }
.pf-f { display: flex; flex-direction: column; gap: 5px; }
.pf-f > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.pf-f input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 13px; background: var(--surface); color: var(--text);
}
.pf-f input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.pf-tot { margin-top: 12px; margin-inline-start: auto; max-width: 340px; display: flex; flex-direction: column; gap: 6px; }
.pf-trow { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.pf-trow b { margin-inline-start: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.pf-trow.grand { border-top: 1px solid var(--border); padding-top: 7px; font-size: 14px; }
.pf-trow.grand b { color: var(--primary); font-size: 17px; }

/* ── منبع سرعت (از جدول یا درون‌یابی) ──────────────────────────────── */
.pc-speed-src {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; padding: 9px 12px;
  border-radius: 8px; font-size: 12.5px; line-height: 1.7;
  background: var(--surface-2); color: var(--muted);
}
.pc-speed-src svg { flex: none; margin-top: 3px; }
.pc-speed-src b { color: var(--text); }
.pc-speed-src.est {
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  color: var(--warning); border: 1px solid color-mix(in srgb, var(--warning) 26%, transparent);
}
.pc-speed-src.est b { color: inherit; }

/* ── جدول قیمت بر حسب عرض ──────────────────────────────────────────── */
.pc-grid-cond {
  display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--surface-2); padding: 4px 11px; border-radius: 999px;
}
.pc-grid-cond .pc-sep { opacity: 0.55; }
.pc-grid-body { min-height: 76px; }
.pc-grid-body > .loading { display: flex; justify-content: center; padding: 22px 0; }

/* هفت عرض کنار هم — جدول عمودی برای هفت عدد، عرض صفحه را هدر می‌داد.
   روی نمایشگر باریک خودش به دو سطر می‌شکند. */
.pc-wgrid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); }
.pc-wcell {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 11px 8px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: inherit; font-family: inherit;
  cursor: pointer; text-align: center; transition: border-color 0.12s, background 0.12s;
}
.pc-wcell:hover { border-color: var(--primary); background: var(--surface); }
.pc-wcell:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pc-wcell.cur {
  cursor: default; border-color: var(--primary); border-width: 2px; padding: 10px 7px 11px;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.pc-wcell.off { cursor: default; opacity: 0.45; }
.pc-wtop { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.pc-wtop small { font-size: 10.5px; font-weight: 500; }
.pc-wcell.cur .pc-wtop { color: var(--primary); }
.pc-wval { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.2px; }
.pc-wcell.cur .pc-wval { color: var(--primary); }
.pc-wnote { margin: 10px 0 0; font-size: 12px; }

/* ── حالت خالیِ ماشین حساب (پیش از پر شدن فرم) ─────────────────────── */
.pc-empty {
  display: flex; align-items: flex-start; gap: 12px; padding: 20px 18px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--muted);
}
.pc-empty svg { flex: none; margin-top: 1px; opacity: 0.7; }
.pc-empty > div { display: flex; flex-direction: column; gap: 4px; }
.pc-empty b { font-size: 14px; color: var(--text); font-weight: 700; }
.pc-empty span { font-size: 12.5px; line-height: 1.8; }

/* ── نمودار حساسیت قیمت ────────────────────────────────────────────── */
.pcc-wrap { overflow-x: auto; }
.pc-chart { width: 100%; min-width: 560px; height: auto; display: block; }
.pcc-grid { stroke: var(--border); stroke-width: 1; }
.pcc-split { stroke: var(--danger); stroke-width: 1.2; stroke-dasharray: 5 4; opacity: 0.75; }
.pcc-splbl { fill: var(--danger); font-size: 11px; }
.pcc-ylbl, .pcc-xlbl { fill: var(--muted); font-size: 11px; font-family: inherit; }
.pcc-axis { fill: var(--muted); font-size: 11.5px; font-family: inherit; }
.pcc-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: 0.85; }
.pcc-line.cur { stroke-width: 3.4; opacity: 1; }
.pcc-dot { opacity: 0.9; }
.pcc-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.pcc-lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.pcc-lg.cur { color: var(--text); font-weight: 700; }
.pcc-sw { width: 14px; height: 3px; border-radius: 2px; }
.pcc-notes { margin: 12px 0 0; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 6px; }
.pcc-notes li { font-size: 13px; line-height: 1.85; }

@media (max-width: 720px) {
  .pc-card .pc-val { font-size: 20px; }
}

@media (prefers-color-scheme: dark) {
  .pc-seg-mat { background: #6a63c4; }
  .pc-seg-oh  { background: #47ab8a; }
  .pc-seg-fin { background: #cf8a1f; }
  .pc-seg-pro { background: #2f75bd; }
  .pc-seg-hid { background: #c33f3e; }
}

/* ── مبلغ با واحد ─────────────────────────────────────────────────────────
 * واحد در انتهای قاب می‌نشیند (سمت چپ در RTL) تا روی خودِ عدد نیفتد.
 * بدون جداکننده، «۱۰۵۰۰۰۰» و «۱٬۰۵۰٬۰۰۰» روی صفحه یکی به نظر می‌رسند. */
.ps-money { display: block; position: relative; }
/* ورودی داخل قاب دیگر فرزندِ مستقیم ستون نیست، پس خودش باید پهنا بگیرد */
.ps-money input { width: 100%; box-sizing: border-box; }
.ps-f .ps-money input,
.ps-tbl td .ps-money input { padding-inline-end: 50px; }
.ps-money > i {
  position: absolute; inset-inline-end: 1px; top: 1px; bottom: 1px;
  display: flex; align-items: center; padding: 0 10px;
  font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--muted);
  background: var(--surface-2); border-inline-start: 1px solid var(--border);
  border-radius: 7px 0 0 7px; pointer-events: none;
}
.ps-tbl td .ps-money > i { font-size: 11px; padding: 0 8px; }
.ps-tbl td .ps-money input { min-width: 140px; }
.ps-unit { font-style: normal; font-size: 11px; color: var(--muted); margin-inline-start: 5px; font-weight: 600; }

