/* PSK Business ERP — CRM and Sales module styles */

/* ---------- CRM ---------- */
.credit-meter { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.credit-meter .progress { height: 8px; }
.fu-list { list-style: none; margin: 0; padding: 0; }
.fu-list li { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.fu-list li:first-child { padding-top: 2px; }
.fu-list li:last-child { border-bottom: 0; padding-bottom: 2px; }
.fu-ic { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--blue-50); color: var(--secondary); }
.fu-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13.5px; }
.fu-top .muted { font-size: 12.5px; }
.fu-list p { margin-top: 4px; color: var(--text-2); font-size: 13.5px; line-height: 1.55; }

/* ---------- order / quotation editor ---------- */
.de-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 20px 0 6px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.doc-editor .lines td { vertical-align: top; }
.doc-editor .lines .icon-btn { width: 34px; height: 34px; color: var(--muted); }
.doc-editor .lines .icon-btn:hover { background: var(--red-50); color: var(--danger); }
.doc-editor .line-hint { display: flex; align-items: center; gap: 4px; }
.doc-editor .doc-foot { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-2); }
.doc-editor .totals { padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line-2); max-width: none; }
.qty-table .input-group .input { text-align: right; }
.qty-table td { vertical-align: middle; }

/* ---------- order detail ---------- */
.order-pill { width: 52px; height: 52px; border-radius: 14px; background: var(--navy-50); color: var(--primary); }
.track { list-style: none; margin: 0; padding: 4px 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.track li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; padding: 0 6px; }
.track li::before { content: ''; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--line); }
.track li:first-child::before { display: none; }
.track li.done::before, .track li.partial::before, .track li.current::before { background: var(--success); }
.track-dot { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid #CBD3E1; color: #fff; margin-bottom: 5px; }
.track li.done .track-dot { background: var(--success); border-color: var(--success); }
.track li.partial .track-dot { background: var(--accent); border-color: var(--accent); }
.track li.current .track-dot { border-color: var(--secondary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .14); }
.track b { font-size: 13px; font-weight: 600; }
.track small { font-size: 11.5px; color: var(--muted); }
.track li:not(.done):not(.partial):not(.current) b { color: var(--muted); font-weight: 500; }
.track.cancelled { opacity: .55; }
.order-totals { display: flex; justify-content: flex-end; padding: 14px 18px 16px; border-top: 1px solid var(--line-2); }
.deliv-cell { display: flex; align-items: center; gap: 8px; min-width: 96px; }
.deliv-cell .progress { flex: 1; }
.deliv-cell small { color: var(--muted); font-size: 11.5px; width: 32px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- printable documents ---------- */
.doc-preview { background: var(--bg); margin: -20px -22px; padding: 20px; }
.doc-preview .doc { box-shadow: var(--shadow-sm); }
.doc-tax { width: 100%; border-collapse: collapse; font-size: 11px; }
.doc-tax td { padding: 4px 8px; border: 1px solid #E4E9F2; text-align: right; }
.doc-tax td:first-child { text-align: left; }
.doc-tax thead td { background: #F3F6FA; }
.doc-tax small { color: #8592A8; }
.doc-sum .doc-tax td:last-child { text-align: right; }
.doc-pay { margin-top: 10px; padding: 8px 10px; border: 1px solid #E4E9F2; border-radius: 8px; font-size: 11.5px; color: #475069; line-height: 1.6; }
.doc-sig { display: block; max-height: 70px; margin-top: 6px; }
.doc-table { table-layout: auto; }

@media (max-width: 760px) {
  .track { grid-template-columns: 1fr; gap: 12px; }
  .track li { flex-direction: row; align-items: center; text-align: left; gap: 10px; padding: 0; flex-wrap: wrap; }
  .track li::before { display: none; }
  .track-dot { margin-bottom: 0; }
  .track small { margin-left: auto; }
  .doc-preview { margin: -16px; padding: 10px; overflow-x: auto; }
  .doc-preview .doc { min-width: 640px; }
  .order-totals { padding: 12px; }
  .order-totals .totals { max-width: none; }
}

/* ---------- shared tweaks ---------- */
.lines th.ta-right { text-align: right; }
.cell-main.clip { max-width: 180px; }
.cell-main.clip > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 760px) {
  /* detail headers: title block on its own row, actions full width below */
  [data-module="crm"] .profile-head .grow, [data-module="sales"] .profile-head .grow { flex: 1 1 60%; min-width: 190px; }
  [data-module="crm"] .profile-head .actions, [data-module="sales"] .profile-head .actions { width: 100%; }
  [data-module="crm"] .profile-head .actions .btn, [data-module="sales"] .profile-head .actions .btn { flex: 1 1 auto; }
  /* line-item editor becomes one card per item */
  .doc-editor .lines, .doc-editor .lines tbody { display: block; width: 100%; }
  .doc-editor .lines thead { display: none; }
  .doc-editor .lines tr { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
  .doc-editor .lines td { display: block; padding: 0; border: 0; width: auto; }
  .doc-editor .lines td.w-prod { grid-column: 1 / -1; min-width: 0; padding-right: 42px; }
  .doc-editor .lines td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em; }
  .doc-editor .lines td.line-total { text-align: left; padding-top: 0; font-size: 14px; }
  .doc-editor .lines td.line-total::before { margin-bottom: 9px; }
  .doc-editor .lines td.line-rm { position: absolute; top: 12px; right: 8px; }
  .doc-editor .lines-wrap { overflow: visible; }
}
