/* ==========================================================================
   CraftX ERP — Application-level patterns
   Higher-level page patterns built on top of foundations in app.css /
   cx-shell.css / cx-widgets.css.
   Source: design-pkg/craftx-design-system/project/library/pages/*.jsx
   Token-only: every color references variables defined in app.css.
   Naming: prefer `.cx-*` prefixes / compound selectors; rename anything
   that would collide with Bootstrap or Syncfusion globals.
   ========================================================================== */

/* Local color aliases — the mockups reference named accents (--violet/
   --blue/--patina/--ochre/--brick) that don't yet live in app.css. Map
   them onto existing semantic tokens; promote into app.css if needed.   */
:root {
    --violet: var(--ai); --violet-50: var(--ai-50);
    --blue: var(--cx-info); --blue-50: var(--info-50);
    --patina: var(--cx-success); --patina-50: var(--success-50);
    --ochre: var(--cx-warning); --ochre-50: var(--warning-50);
    --brick: var(--cx-danger); --brick-50: var(--danger-50);
    --cx-hairline-strong: rgba(28, 25, 21, 0.14);
}

/* ── 1. Pipeline stepper (job lifecycle) ─────────────────────────────── */
/* Default surface = neutral; tone shows only as a 2px top stripe (semantic
   hint, not a flood-fill). is-active wins: ink-tinted bg + copper bottom bar.
   Compact mode is the default density for embedded pipelines. */

.cx-pipeline {
    display: flex; gap: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: hidden;
}
.cx-pipeline .step {
    flex: 1; padding: 8px 14px 10px;
    background: transparent;
    border-right: 1px solid var(--cx-hairline-soft);
    position: relative;
    transition: background 0.15s var(--ease);
    min-width: 0;
}
.cx-pipeline .step:last-child { border-right: none; }
.cx-pipeline .step .step-label {
    font-family: var(--font-mono); font-size: 9.5px;
    font-weight: var(--fw-semibold); letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--cx-text-muted);
    line-height: 1.2;
    margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cx-pipeline .step .step-value {
    font-family: var(--font-display); font-size: 17px;
    font-weight: var(--fw-bold); letter-spacing: -0.02em;
    color: var(--cx-text-primary); line-height: 1.1;
}
.cx-pipeline .step .step-foot {
    font-size: 10.5px; color: var(--cx-text-muted);
    line-height: 1.2;
    margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Tone hint as 2px top stripe — colors the label only, never floods. */
.cx-pipeline .step.copper::before,
.cx-pipeline .step.blue::before,
.cx-pipeline .step.ochre::before,
.cx-pipeline .step.patina::before,
.cx-pipeline .step.violet::before,
.cx-pipeline .step.ink::before {
    content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px;
}
.cx-pipeline .step.copper::before { background: var(--copper); }
.cx-pipeline .step.copper .step-label { color: var(--copper); }
.cx-pipeline .step.blue::before { background: var(--blue); }
.cx-pipeline .step.blue .step-label { color: var(--blue); }
.cx-pipeline .step.ochre::before { background: var(--ochre); }
.cx-pipeline .step.ochre .step-label { color: var(--ochre); }
.cx-pipeline .step.patina::before { background: var(--patina); }
.cx-pipeline .step.patina .step-label { color: var(--patina); }
.cx-pipeline .step.violet::before { background: var(--violet); }
.cx-pipeline .step.violet .step-label { color: var(--violet); }
.cx-pipeline .step.ink::before { background: var(--ink); }
.cx-pipeline .step.ink .step-label { color: var(--ink); }

.cx-pipeline.compact .step {
    padding: 5px 12px 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.cx-pipeline.compact .step .step-label { margin: 0; line-height: 1; height: 10px; }
.cx-pipeline.compact .step .step-value { font-size: 13px; line-height: 1; margin: 0; height: 13px; display: flex; align-items: center; }
.cx-pipeline.compact .step .step-value i { line-height: 1; vertical-align: middle; }
.cx-pipeline.compact .step .step-foot { margin: 0; line-height: 1; height: 11px; }

.cx-pipeline .step.is-clickable:hover { background: var(--cx-hairline-soft); }

.cx-pipeline .step.is-active {
    background: var(--copper-50);
    box-shadow: inset 0 -2px 0 var(--copper);
}
.cx-pipeline .step.is-active .step-label { color: var(--copper-dark); }
.cx-pipeline .step.is-active .step-value { color: var(--copper-dark); }

.cx-pipeline .step.is-done .step-label,
.cx-pipeline .step.is-done .step-value,
.cx-pipeline .step.is-done .step-foot { color: var(--cx-text-muted); opacity: 0.85; }
.cx-pipeline .step.is-done .step-value i { color: var(--patina); opacity: 1; }

.cx-pipeline .step.is-upcoming .step-value,
.cx-pipeline .step.is-upcoming .step-foot { color: var(--cx-text-muted); }

/* ── 2. Document header (invoice / quote) + line items ───────────────── */

.cx-doc-header {
    padding: 24px;
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-surface);
}
.cx-doc-header .doc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.cx-doc-header .doc-eyebrow {
    font-family: var(--font-mono); font-size: 11px;
    font-weight: var(--fw-semibold); letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--cx-text-muted);
    margin-bottom: 6px;
}
.cx-doc-header .doc-amount {
    font-family: var(--font-display); font-size: 30px;
    font-weight: var(--fw-xbold); letter-spacing: -0.03em;
    color: var(--cx-text-primary); margin: 0; line-height: 1.1;
}
.cx-doc-header .doc-sub { font-size: 13px; color: var(--cx-text-secondary); margin-top: 4px; }
.cx-doc-header .doc-meta-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
    padding-top: 16px; border-top: 1px solid var(--cx-hairline);
}
.cx-doc-header .doc-meta-grid .meta-label,
.cx-detail-meta .meta-cell .meta-label {
    font-family: var(--font-mono); font-size: 10px;
    font-weight: var(--fw-semibold); letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--cx-text-muted);
    margin-bottom: 3px;
}
.cx-doc-header .doc-meta-grid .meta-value {
    font-family: var(--font-display); font-size: 15px;
    font-weight: var(--fw-bold); color: var(--cx-text-primary);
}

.cx-line-items {
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-surface);
    overflow: hidden;
}
.cx-line-items table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cx-line-items thead tr { background: var(--paper-2); }
.cx-line-items thead th {
    padding: 10px 14px; text-align: left;
    font-family: var(--font-mono); font-size: 10.5px;
    font-weight: var(--fw-semibold); letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--cx-text-muted);
    border-bottom: 1px solid var(--cx-hairline); white-space: nowrap;
}
.cx-line-items thead th.num,
.cx-line-items td.num {
    text-align: right; font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.cx-line-items tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--cx-hairline-soft);
    color: var(--cx-text-primary); vertical-align: middle;
}
.cx-line-items tbody tr:last-child td { border-bottom: none; }
.cx-line-items tbody td.muted { color: var(--cx-text-muted); font-family: var(--font-mono); }
.cx-line-items .totals-block {
    padding: 14px 18px; background: var(--paper);
    border-top: 1px solid var(--cx-hairline);
}
.cx-line-items .totals-block .totals-inner {
    max-width: 280px; margin-left: auto;
    display: flex; flex-direction: column; gap: 6px;
}
.cx-line-items .totals-block .totals-row {
    display: flex; justify-content: space-between;
    font-size: 12.5px; color: var(--cx-text-secondary);
}
.cx-line-items .totals-block .totals-row .amount { font-family: var(--font-mono); }
.cx-line-items .totals-block .totals-row.is-grand {
    font-size: 14px; font-weight: var(--fw-bold);
    color: var(--cx-text-primary);
    padding-top: 8px; border-top: 1px solid var(--cx-hairline);
}

/* ── 3. Audit panel + activity timeline ──────────────────────────────── */

.cx-audit-panel {
    padding: 18px;
    background: linear-gradient(135deg, var(--blue-50) 0%, var(--paper) 70%);
    border: 1px solid rgba(31, 74, 130, 0.18);
    border-radius: var(--cx-radius-surface);
}
.cx-audit-panel .audit-header { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.cx-audit-panel .audit-icon {
    width: 36px; height: 36px;
    border-radius: var(--cx-radius-control);
    background: var(--blue); color: white;
    display: grid; place-items: center;
    font-size: 16px; flex-shrink: 0;
}
.cx-audit-panel .audit-title {
    font-family: var(--font-display); font-size: 15px;
    font-weight: var(--fw-bold); letter-spacing: -0.015em;
    color: var(--cx-text-primary); margin: 0;
}
.cx-audit-panel .audit-sub { font-size: 12px; color: var(--cx-text-secondary); font-family: var(--font-mono); }

.cx-audit-timeline {
    border-left: 2px solid var(--cx-hairline);
    padding-left: 14px;
    display: flex; flex-direction: column; gap: 10px;
}
.cx-audit-timeline .audit-step {
    display: flex; gap: 12px; align-items: baseline;
    position: relative; font-size: 13px;
}
.cx-audit-timeline .audit-step::before {
    content: ''; position: absolute;
    left: -19px; top: 6px;
    width: 8px; height: 8px; border-radius: var(--cx-radius-round);
    background: var(--blue); border: 2px solid var(--cx-card-bg);
}
.cx-audit-timeline .audit-step .audit-action {
    font-weight: var(--fw-semibold); min-width: 130px;
    color: var(--cx-text-primary);
}
.cx-audit-timeline .audit-step .audit-actor { font-size: 12.5px; color: var(--cx-text-secondary); flex: 1; }
.cx-audit-timeline .audit-step .audit-time { font-family: var(--font-mono); font-size: 11px; color: var(--cx-text-muted); }

.cx-activity-timeline { display: flex; flex-direction: column; }
.cx-activity-timeline .activity-step { display: flex; gap: 14px; padding-bottom: 14px; position: relative; }
.cx-activity-timeline .activity-step:last-child { padding-bottom: 0; }
.cx-activity-timeline .activity-rail { display: flex; flex-direction: column; align-items: center; }
.cx-activity-timeline .activity-rail .ico {
    width: 30px; height: 30px; border-radius: var(--cx-radius-round);
    display: grid; place-items: center; flex-shrink: 0;
    font-size: 13px;
    background: var(--copper-50); color: var(--copper);
}
.cx-activity-timeline .activity-rail .ico.blue   { background: var(--blue-50);   color: var(--blue); }
.cx-activity-timeline .activity-rail .ico.patina { background: var(--patina-50); color: var(--patina); }
.cx-activity-timeline .activity-rail .ico.violet { background: var(--violet-50); color: var(--violet); }
.cx-activity-timeline .activity-rail .ico.ochre  { background: var(--ochre-50);  color: var(--ochre); }
.cx-activity-timeline .activity-rail .connector { flex: 1; width: 2px; background: var(--cx-hairline); margin-top: 4px; }
.cx-activity-timeline .activity-step:last-child .connector { display: none; }
.cx-activity-timeline .activity-body { flex: 1; padding-top: 4px; }
.cx-activity-timeline .activity-body .activity-title { font-size: 13px; font-weight: var(--fw-semibold); color: var(--cx-text-primary); }
.cx-activity-timeline .activity-body .activity-meta { font-size: 11.5px; color: var(--cx-text-muted); }

/* ── 4. Ageing buckets (receivables aging strip) ─────────────────────── */

.cx-ageing-buckets {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-surface);
    overflow: hidden;
}
.cx-ageing-buckets .bucket { padding: 14px; border-right: 1px solid var(--cx-hairline); }
.cx-ageing-buckets .bucket:last-child { border-right: none; }
.cx-ageing-buckets .bucket .bucket-label {
    font-family: var(--font-mono); font-size: 10px;
    font-weight: var(--fw-semibold); letter-spacing: 0.1em;
    text-transform: uppercase;
}
.cx-ageing-buckets .bucket .bucket-value {
    font-family: var(--font-display); font-size: 18px;
    font-weight: var(--fw-bold); letter-spacing: -0.02em;
    color: var(--cx-text-primary); margin-top: 4px;
}
.cx-ageing-buckets .bucket.patina .bucket-label { color: var(--patina); }
.cx-ageing-buckets .bucket.blue   .bucket-label { color: var(--blue); }
.cx-ageing-buckets .bucket.ochre  .bucket-label { color: var(--ochre); }
.cx-ageing-buckets .bucket.copper .bucket-label { color: var(--copper); }
.cx-ageing-buckets .bucket.brick  .bucket-label { color: var(--brick); }

/* ── 5. Contact row + address card ───────────────────────────────────── */

.cx-contact-list { background: var(--cx-card-bg); border: 1px solid var(--cx-card-border); border-radius: var(--cx-radius-surface); overflow: hidden; }
.cx-contact-row {
    display: grid; grid-template-columns: 40px 1.4fr 1fr 1.2fr auto;
    gap: 14px; padding: 10px 16px;
    border-bottom: 1px solid var(--cx-hairline-soft);
    align-items: center; font-size: 13px;
    transition: background 0.12s var(--ease);
}
.cx-contact-row:last-child { border-bottom: none; }
.cx-contact-row:hover { background: var(--paper-2); }
.cx-contact-row .contact-name { font-weight: var(--fw-semibold); color: var(--cx-text-primary); }
.cx-contact-row .contact-role { font-size: 11.5px; color: var(--cx-text-muted); }
.cx-contact-row .contact-phone { font-family: var(--font-mono); font-size: 12px; color: var(--cx-text-secondary); }
.cx-contact-row .contact-geo { color: var(--cx-text-secondary); }
.cx-contact-row .contact-geo i { margin-right: 4px; color: var(--cx-text-muted); }
.cx-contact-row .contact-actions { display: inline-flex; align-items: center; gap: 6px; }
.cx-contact-row .contact-actions .icon-btn {
    width: 28px; height: 28px; border: none;
    background: transparent; color: var(--cx-text-muted);
    border-radius: var(--cx-radius-control); cursor: pointer;
    transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.cx-contact-row .contact-actions .icon-btn:hover { background: var(--paper-2); color: var(--cx-text-primary); }

.cx-address-card {
    display: flex; gap: 14px; padding: 14px;
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-surface); align-items: center;
}
.cx-address-card .address-ico {
    width: 36px; height: 36px;
    border-radius: var(--cx-radius-control);
    background: var(--copper-50); color: var(--copper);
    display: grid; place-items: center;
    font-size: 14px; flex-shrink: 0;
}
.cx-address-card .address-body { flex: 1; min-width: 0; }
.cx-address-card .address-label { display: flex; gap: 8px; align-items: center; margin-bottom: 2px; font-size: 13px; font-weight: var(--fw-semibold); color: var(--cx-text-primary); }
.cx-address-card .address-text { font-size: 12.5px; color: var(--cx-text-secondary); }

/* ── 6. Event card + event chip (scheduler) ──────────────────────────── */

.cx-event-card {
    padding: 14px;
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-left: 3px solid var(--copper);
    border-radius: var(--cx-radius-surface);
    transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
    cursor: grab;
}
.cx-event-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.cx-event-card:active { cursor: grabbing; }
.cx-event-card.copper { border-left-color: var(--copper); }
.cx-event-card.blue   { border-left-color: var(--blue); }
.cx-event-card.patina { border-left-color: var(--patina); }
.cx-event-card.violet { border-left-color: var(--violet); }
.cx-event-card.ochre  { border-left-color: var(--ochre); }
.cx-event-card.brick  { border-left-color: var(--brick); }
.cx-event-card .event-head { display: flex; align-items: center; gap: 10px; }
.cx-event-card .event-ico {
    width: 30px; height: 30px; border-radius: var(--cx-radius-control);
    display: grid; place-items: center; flex-shrink: 0;
    background: var(--copper-50); color: var(--copper);
}
.cx-event-card.blue   .event-ico { background: var(--blue-50);   color: var(--blue); }
.cx-event-card.patina .event-ico { background: var(--patina-50); color: var(--patina); }
.cx-event-card.violet .event-ico { background: var(--violet-50); color: var(--violet); }
.cx-event-card.ochre  .event-ico { background: var(--ochre-50);  color: var(--ochre); }
.cx-event-card.brick  .event-ico { background: var(--brick-50);  color: var(--brick); }
.cx-event-card .event-title { flex: 1; font-size: 13px; font-weight: var(--fw-semibold); color: var(--cx-text-primary); }
.cx-event-card .event-meta { font-size: 11px; color: var(--cx-text-muted); font-family: var(--font-mono); }
.cx-event-card .event-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--cx-hairline-soft); }

.cx-event-chip {
    padding: 6px 8px; border-radius: var(--cx-radius-control);
    color: white; font-size: 11.5px;
    font-weight: var(--fw-semibold);
    box-shadow: var(--shadow-sm);
    background: var(--copper);
}
.cx-event-chip.blue   { background: var(--blue); }
.cx-event-chip.patina { background: var(--patina); }
.cx-event-chip.violet { background: var(--violet); }
.cx-event-chip.ochre  { background: var(--ochre); }
.cx-event-chip.brick  { background: var(--brick); }
.cx-event-chip .event-chip-meta { font-size: 10px; opacity: 0.85; margin-top: 2px; font-family: var(--font-mono); }

/* ── 7. Settings nav (left rail + content area) ──────────────────────── */

.cx-settings-shell {
    display: grid; grid-template-columns: 220px 1fr;
    min-height: 380px;
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-surface);
    overflow: hidden;
}
.cx-settings-rail { padding: 14px; background: var(--paper-2); border-right: 1px solid var(--cx-hairline); }
.cx-settings-rail .group-title {
    font-family: var(--font-mono); font-size: 10px;
    font-weight: var(--fw-semibold); letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--cx-text-muted);
    padding: 0 12px 8px;
}
.cx-settings-rail .group-title + .group-title { padding-top: 14px; }
.cx-settings-rail .rail-link {
    display: block; padding: 7px 12px;
    border-radius: var(--cx-radius-control);
    font-size: 13px; color: var(--cx-text-secondary);
    font-weight: var(--fw-medium); text-decoration: none;
    transition: background 0.12s var(--ease), color 0.12s var(--ease);
    cursor: pointer;
}
.cx-settings-rail .rail-link:hover { background: rgba(28, 25, 21, 0.04); color: var(--cx-text-primary); }
.cx-settings-rail .rail-link.active { background: var(--copper-50); color: var(--copper-dark); font-weight: var(--fw-semibold); }
.cx-settings-content { padding: 24px; overflow-y: auto; }
.cx-settings-content h3 {
    margin: 0 0 16px;
    font-family: var(--font-display); font-size: 22px;
    font-weight: var(--fw-bold); letter-spacing: -0.02em;
    color: var(--cx-text-primary);
}

/* ── 8. Permission matrix (sticky header + sticky first col) ─────────── */

.cx-permission-matrix {
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-surface);
    overflow: auto; max-height: 70vh;
}
.cx-permission-matrix table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cx-permission-matrix thead tr { background: var(--paper-2); }
.cx-permission-matrix thead th {
    padding: 10px 14px;
    font-family: var(--font-mono); font-size: 10.5px;
    font-weight: var(--fw-semibold); letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--cx-text-muted);
    border-bottom: 1px solid var(--cx-hairline);
    background: var(--paper-2);
    position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
.cx-permission-matrix thead th:first-child { text-align: left; left: 0; z-index: 3; }
.cx-permission-matrix thead th:not(:first-child) { text-align: center; letter-spacing: 0.06em; }
.cx-permission-matrix tbody tr { border-bottom: 1px solid var(--cx-hairline-soft); }
.cx-permission-matrix tbody tr:last-child { border-bottom: none; }
.cx-permission-matrix tbody td { padding: 10px 14px; color: var(--cx-text-primary); vertical-align: middle; }
.cx-permission-matrix tbody td:first-child {
    font-weight: var(--fw-medium);
    background: var(--cx-card-bg);
    position: sticky; left: 0; z-index: 1;
}
.cx-permission-matrix tbody td:not(:first-child) { text-align: center; }
.cx-permission-matrix .perm-yes { color: var(--patina); font-size: 15px; }
.cx-permission-matrix .perm-no { color: var(--cx-text-muted); font-size: 15px; }

/* ── 9. Integration card (connected services) ────────────────────────── */

.cx-integration-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cx-integration-card {
    padding: 16px;
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-surface);
    transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.cx-integration-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.cx-integration-card .ic-head { display: flex; align-items: center; gap: 10px; }
.cx-integration-card .ic-ico {
    width: 36px; height: 36px;
    border-radius: var(--cx-radius-control);
    display: grid; place-items: center;
    font-size: 16px; flex-shrink: 0;
    background: var(--copper-50); color: var(--copper);
}
.cx-integration-card.blue   .ic-ico { background: var(--blue-50);   color: var(--blue); }
.cx-integration-card.patina .ic-ico { background: var(--patina-50); color: var(--patina); }
.cx-integration-card.violet .ic-ico { background: var(--violet-50); color: var(--violet); }
.cx-integration-card.ochre  .ic-ico { background: var(--ochre-50);  color: var(--ochre); }
.cx-integration-card .ic-title { flex: 1; min-width: 0; }
.cx-integration-card .ic-name { font-weight: var(--fw-semibold); font-size: 13.5px; color: var(--cx-text-primary); }
.cx-integration-card .ic-desc { font-size: 11.5px; color: var(--cx-text-muted); }
.cx-integration-card .ic-status-dot { width: 8px; height: 8px; border-radius: var(--cx-radius-round); background: var(--cx-text-muted); flex-shrink: 0; }
.cx-integration-card .ic-status-dot.connected { background: var(--patina); }
.cx-integration-card .ic-foot {
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--cx-hairline-soft);
    display: flex; justify-content: space-between; align-items: center;
}
.cx-integration-card .ic-since { font-size: 11.5px; color: var(--cx-text-secondary); }

/* ── 10. Stock row + adjust modal + low-stock banner ─────────────────── */

.cx-stock-table { width: 100%; }
.cx-stock-table .stock-sku { font-family: var(--font-mono); font-size: 11.5px; color: var(--cx-text-muted); }
.cx-stock-table .stock-qty { font-variant-numeric: tabular-nums; font-family: var(--font-mono); text-align: right; }
.cx-stock-table .stock-qty .unit { color: var(--cx-text-muted); font-size: 11px; margin-left: 2px; }
.cx-stock-table .stock-adjust-btn {
    height: 26px; padding: 0 10px;
    border-radius: var(--cx-radius-control);
    background: transparent;
    border: 1.5px solid var(--cx-hairline-strong);
    font-size: 11.5px; font-weight: var(--fw-semibold);
    cursor: pointer; color: var(--cx-text-primary);
    font-family: inherit; transition: all 0.12s var(--ease);
}
.cx-stock-table .stock-adjust-btn:hover { border-color: var(--copper); color: var(--copper); }

.cx-stock-adjust {
    max-width: 380px; padding: 18px;
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-control);
}
.cx-stock-adjust .adjust-title {
    font-family: var(--font-display); font-size: 17px;
    font-weight: var(--fw-bold); letter-spacing: -0.02em;
    margin: 0 0 12px; color: var(--cx-text-primary);
}
.cx-stock-adjust .adjust-current {
    padding: 10px; background: var(--paper-2);
    border-radius: var(--cx-radius-control); margin-bottom: 14px;
    font-size: 12px; color: var(--cx-text-secondary);
}
.cx-stock-adjust .adjust-current strong { color: var(--cx-text-primary); font-family: var(--font-mono); }
.cx-stock-adjust .adjust-mode { display: flex; gap: 8px; margin-bottom: 12px; }
.cx-stock-adjust .adjust-mode button {
    flex: 1; height: 34px;
    border-radius: var(--cx-radius-control);
    border: 1.5px solid var(--cx-hairline-strong);
    background: var(--cx-card-bg); color: var(--cx-text-secondary);
    font-weight: var(--fw-semibold); font-size: 13px;
    cursor: pointer; font-family: inherit;
    transition: all 0.12s var(--ease);
}
.cx-stock-adjust .adjust-mode button.is-active { border-color: var(--patina); background: var(--patina-50); color: var(--patina); }
.cx-stock-adjust .adjust-spinner {
    display: flex; height: 36px;
    border: 1px solid var(--cx-hairline);
    border-radius: var(--cx-radius-control);
    overflow: hidden;
}
.cx-stock-adjust .adjust-spinner button {
    width: 36px; border: none;
    background: var(--paper-2); cursor: pointer;
    color: var(--cx-text-primary); font-family: inherit;
    transition: background 0.12s var(--ease);
}
.cx-stock-adjust .adjust-spinner button:hover { background: var(--paper); }
.cx-stock-adjust .adjust-spinner input {
    flex: 1; border: none; outline: none; text-align: center;
    font-family: var(--font-mono); font-size: 14px;
    font-weight: var(--fw-semibold); color: var(--cx-text-primary);
    background: var(--cx-card-bg);
}
.cx-stock-adjust .adjust-spinner .unit {
    padding: 0 14px; display: grid; place-items: center;
    background: var(--paper-2); font-size: 12px; color: var(--cx-text-muted);
}
.cx-stock-adjust .adjust-result {
    padding: 10px; background: var(--patina-50);
    border-radius: var(--cx-radius-surface);
    font-size: 12px; color: var(--patina);
    display: flex; justify-content: space-between; align-items: center;
}
.cx-stock-adjust .adjust-result strong { font-family: var(--font-mono); color: var(--patina); }

.cx-low-stock-banner {
    padding: 18px;
    background: var(--brick-50);
    border: 1px solid rgba(154, 59, 51, 0.2);
    border-radius: var(--cx-radius-surface);
}
.cx-low-stock-banner .banner-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cx-low-stock-banner .banner-head i { color: var(--brick); font-size: 18px; }
.cx-low-stock-banner .banner-head strong { font-size: 14px; color: var(--cx-text-primary); }
.cx-low-stock-banner .low-stock-list { display: flex; flex-direction: column; gap: 8px; }
.cx-low-stock-banner .low-stock-row {
    display: grid; grid-template-columns: 1fr 80px 100px 100px;
    gap: 10px; padding: 8px 12px;
    background: var(--cx-card-bg);
    border-radius: var(--cx-radius-control);
    font-size: 12.5px; align-items: center;
}
.cx-low-stock-banner .low-stock-row .item-name { font-weight: var(--fw-semibold); color: var(--cx-text-primary); }
.cx-low-stock-banner .low-stock-row .item-qty { font-family: var(--font-mono); color: var(--brick); font-weight: var(--fw-semibold); }
.cx-low-stock-banner .low-stock-row .item-min { font-family: var(--font-mono); color: var(--cx-text-muted); font-size: 11px; }

/* ── 11. Comment thread (chat / position comments) ───────────────────── */

.cx-comment-thread {
    padding: 16px;
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-surface);
}
.cx-comment-thread .thread-title {
    font-size: 11.5px; font-weight: var(--fw-semibold);
    letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--cx-text-muted); margin-bottom: 12px;
}
.cx-comment {
    display: flex; gap: 10px;
    padding-bottom: 14px; margin-bottom: 14px;
    border-bottom: 1px solid var(--cx-hairline-soft);
}
.cx-comment:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: none; }
.cx-comment .comment-body { flex: 1; min-width: 0; }
.cx-comment .comment-head { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.cx-comment .comment-author { font-size: 12.5px; font-weight: var(--fw-semibold); color: var(--cx-text-primary); }
.cx-comment .comment-time { font-size: 11px; color: var(--cx-text-muted); }
.cx-comment .comment-text { font-size: 13px; line-height: 1.5; color: var(--cx-text-primary); }

/* ── 12. Chat message bubble + attachment + drop zone ────────────────── */

.cx-msg-bubble {
    padding: 10px 14px;
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-control) var(--cx-radius-surface) var(--cx-radius-surface) var(--cx-radius-surface);
    font-size: 13.5px; color: var(--cx-text-primary);
    max-width: 380px; line-height: 1.5;
}
.cx-msg-bubble.outgoing {
    background: var(--copper); border-color: var(--copper);
    color: white;
    border-radius: var(--cx-radius-surface) var(--cx-radius-control) var(--cx-radius-surface) var(--cx-radius-surface);
    margin-left: auto;
}
.cx-msg-meta { font-size: 11.5px; color: var(--cx-text-muted); margin-bottom: 4px; }
.cx-msg-attachment {
    padding: 10px 14px;
    background: var(--cx-card-bg);
    border: 1px solid var(--cx-card-border);
    border-radius: var(--cx-radius-surface) var(--cx-radius-surface) var(--cx-radius-surface) var(--cx-radius-control);
    font-size: 13.5px;
    display: inline-flex; gap: 10px; align-items: center;
}
.cx-msg-attachment .att-name { font-weight: var(--fw-semibold); font-size: 12.5px; color: var(--cx-text-primary); }
.cx-msg-attachment .att-size { font-size: 11px; color: var(--cx-text-muted); font-family: var(--font-mono); }

.cx-drop-zone {
    padding: 24px;
    border: 2px dashed var(--copper);
    border-radius: var(--cx-radius-surface);
    background: var(--copper-50);
    text-align: center; color: var(--cx-text-primary);
    transition: background 0.15s var(--ease);
}
.cx-drop-zone i { font-size: 32px; color: var(--copper); }
.cx-drop-zone .drop-title { font-size: 14px; font-weight: var(--fw-semibold); margin-top: 10px; }
.cx-drop-zone .drop-sub { font-size: 12px; color: var(--cx-text-secondary); margin-top: 2px; }

/* ── 13. Detail meta-grid (4-col key/value strip used by detail cards) ── */

.cx-detail-meta {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 12px; padding: 14px 0;
    border-top: 1px solid var(--cx-hairline);
    border-bottom: 1px solid var(--cx-hairline);
}
.cx-detail-meta .meta-cell .meta-label { display: flex; align-items: center; gap: 4px; }
.cx-detail-meta .meta-cell .meta-value {
    font-family: var(--font-display); font-size: 18px;
    font-weight: var(--fw-bold); letter-spacing: -0.02em;
    color: var(--cx-text-primary);
}
.cx-detail-meta .meta-cell .meta-value.sm {
    font-size: 13px; font-weight: var(--fw-medium);
    font-family: var(--font-sans); letter-spacing: 0;
}

/* ── 14. Mobile breakpoints ──────────────────────────────────────────── */

@media (max-width: 900px) {
    .cx-pipeline,
    .cx-ageing-buckets {
        grid-template-columns: repeat(2, 1fr);
        flex-wrap: wrap;
    }
    .cx-pipeline .step,
    .cx-ageing-buckets .bucket {
        border-right: none;
        border-bottom: 1px solid var(--cx-hairline);
    }
    .cx-doc-header .doc-meta-grid,
    .cx-detail-meta { grid-template-columns: repeat(2, 1fr); }
    .cx-integration-grid { grid-template-columns: 1fr; }
    .cx-settings-shell { grid-template-columns: 1fr; }
    .cx-settings-rail { border-right: none; border-bottom: 1px solid var(--cx-hairline); }
    .cx-contact-row { grid-template-columns: 40px 1fr auto; row-gap: 4px; }
    .cx-contact-row .contact-phone,
    .cx-contact-row .contact-geo { grid-column: 2 / span 2; }
    .cx-low-stock-banner .low-stock-row { grid-template-columns: 1fr auto; row-gap: 4px; }
}
