/* Materials Hub (Watchtower Phase 1). Everything shared - buttons, inputs, tables, modals -
   is reused from competitors.css / shell.css; only the receiving-specific pieces live here.
   All colors come from the shell tokens, no literals. */

.mat-head { display:flex; align-items:baseline; gap:12px; flex-wrap:wrap; margin-bottom:16px; }
.mat-head .page-title { margin:0; }
.mat-head-sub { font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); }
.mat-head-actions { margin-left:auto; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

.mat-kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:12px; margin-bottom:20px; }

.mat-seg { display:inline-flex; border:1px solid var(--line); border-radius:var(--radius-8); overflow:hidden; }
.mat-seg-btn { background:var(--surface-raised); border:none; color:var(--muted); font-family:inherit; font-size:12px; font-weight:600; padding:7px 14px; cursor:pointer; }
.mat-seg-btn + .mat-seg-btn { border-left:1px solid var(--line); }
.mat-seg-btn.active { background:var(--orange); color:var(--white); }

.mat-pill { display:inline-block; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; padding:2px 8px; border-radius:var(--radius-20); border:1px solid; white-space:nowrap; }
.mat-dim { color:var(--dim); font-size:12px; }

/* --- purchase card (Receiving) --- */
.mat-purchase-card { margin-bottom:16px; }
.mat-purchase-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.mat-purchase-title { display:flex; align-items:center; gap:8px; font-family:var(--font-display); font-size:15px; font-weight:600; color:var(--text); flex-wrap:wrap; }
.mat-purchase-title a { color:var(--text); text-decoration:none; }
.mat-purchase-title a:hover { color:var(--orange); }
.mat-purchase-meta { font-size:12px; color:var(--muted); margin-top:3px; }
.mat-purchase-actions { display:flex; gap:6px; flex-wrap:wrap; }

.mat-progress { height:6px; border-radius:var(--radius-6); background:var(--cream-a08); overflow:hidden; margin:10px 0; }
.mat-progress span { display:block; height:100%; background:var(--good); border-radius:var(--radius-6); }
.mat-progress-sm { width:60px; height:5px; margin:0 0 3px; display:inline-block; }

.mat-warn { font-size:12px; line-height:1.5; color:var(--warn); background:var(--surface-alt); border:1px solid var(--warn); border-radius:var(--radius-8); padding:8px 12px; margin-bottom:10px; }
.mat-empty { font-size:12.5px; color:var(--dim); margin:6px 0 0; }

/* --- parcel --- */
.mat-parcels { display:flex; flex-direction:column; gap:10px; }
.mat-parcel { background:var(--surface-raised); border:1px solid var(--line-soft); border-radius:var(--radius-10); padding:12px 14px; }
.mat-parcel-top { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.mat-parcel-id { display:flex; align-items:center; gap:8px; font-size:13px; font-weight:700; color:var(--text); flex-wrap:wrap; }
.mat-parcel-actions { display:flex; gap:6px; flex-wrap:wrap; }
.mat-parcel-meta { font-size:12px; color:var(--muted); margin-top:6px; }
.mat-method { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.04em; color:var(--text-secondary); background:var(--surface-input); border-radius:var(--radius-6); padding:2px 7px; }
.mat-track { color:var(--orange); font-weight:600; text-decoration:none; font-variant-numeric:tabular-nums; }
.mat-track:hover { text-decoration:underline; }
.mat-parcel-lines { display:flex; flex-wrap:wrap; gap:6px; margin-top:9px; }
.mat-line { font-size:12px; color:var(--text-secondary); background:var(--surface-input); border-radius:var(--radius-6); padding:3px 9px; }
.mat-line b { color:var(--text); font-weight:700; }
.mat-line em { color:var(--warn); font-style:normal; }

/* --- catalog --- */
.mat-price-input { width:88px; background:var(--surface-input); border:1px solid var(--line); color:var(--text); border-radius:var(--radius-6); padding:4px 7px; font-family:inherit; font-size:12px; text-align:right; }
.mat-price-input:focus { outline:none; border-color:var(--orange); }
.mat-supopts { display:flex; gap:5px; flex-wrap:wrap; max-width:280px; }
.mat-supopt { font-size:10.5px; font-weight:600; text-decoration:none; color:var(--muted); background:var(--surface-raised); border:1px solid var(--line); border-radius:var(--radius-6); padding:2px 7px; white-space:nowrap; }
.mat-supopt:hover { color:var(--orange); border-color:var(--orange); }
.mat-supopt.on { color:var(--text-secondary); border-color:var(--line-strong); }

/* --- costs (Phase 2: the cost-lever view) --- */
.mat-cost-share { min-width:150px; }
.mat-cost-bar { display:inline-block; vertical-align:middle; width:96px; height:6px; border-radius:var(--radius-6); background:var(--cream-a08); overflow:hidden; }
.mat-cost-bar i { display:block; height:100%; background:var(--orange); border-radius:var(--radius-6); }
.mat-cost-pct { display:inline-block; margin-left:8px; font-size:11.5px; color:var(--muted); font-variant-numeric:tabular-nums; }
.mat-cost-total td { border-top:1px solid var(--line); font-weight:700; color:var(--text); }

.mat-cost-strip { display:grid; grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:8px; }
.mat-cost-chip { display:flex; flex-direction:column; gap:5px; text-align:left; background:var(--surface-raised); border:1px solid var(--line-soft); border-radius:var(--radius-10); padding:10px 12px; cursor:pointer; font-family:inherit; }
.mat-cost-chip:hover { border-color:var(--line-strong); }
.mat-cost-chip.active { border-color:var(--orange); }
.mat-cost-chip-name { font-size:12px; font-weight:600; color:var(--text); }
.mat-cost-chip-val { font-size:14px; font-weight:700; color:var(--text); font-variant-numeric:tabular-nums; }
.mat-cost-chip-bar { display:block; height:4px; border-radius:var(--radius-6); background:var(--cream-a08); overflow:hidden; }
.mat-cost-chip-bar i { display:block; height:100%; background:var(--orange); border-radius:var(--radius-6); }

/* --- productions (Phase 3: the MLGR tab replacement) --- */
.mat-link-btn { background:none; border:none; padding:0; font-family:inherit; font-size:inherit; font-weight:600; color:var(--orange); cursor:pointer; text-align:left; }
.mat-link-btn:hover { text-decoration:underline; }
.mat-prod-title { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:10px; }
.mat-prod-title h3 { margin:0; font-family:var(--font-display); font-size:20px; font-weight:600; color:var(--text); }
.mat-prod-grid { display:grid; grid-template-columns:minmax(0,1fr) 280px; gap:20px; align-items:start; }
.mat-prod-side { background:var(--surface-raised); border:1px solid var(--line-soft); border-radius:var(--radius-10); padding:14px; position:sticky; top:16px; }
.mat-neg { color:var(--bad); }
.mat-ok { color:var(--good); }
.mat-row-short td { background:var(--surface-alt); }

.mat-qty-row { display:flex; align-items:center; gap:8px; padding:6px 0; border-bottom:1px solid var(--line-soft); }
.mat-qty-name { flex:1; font-size:12.5px; color:var(--text-secondary); }
.mat-qty-input { width:70px; text-align:right; }
.mat-qty-cost { font-size:11.5px; color:var(--muted); font-variant-numeric:tabular-nums; min-width:60px; text-align:right; }
.mat-qty-add { display:flex; gap:6px; margin-top:10px; }
.mat-qty-add .comp-input { min-width:0; }
.mat-qty-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:8px; }
.mat-qty-cell { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12.5px; color:var(--text-secondary); background:var(--surface-raised); border:1px solid var(--line-soft); border-radius:var(--radius-8); padding:6px 10px; }
.mat-qty-cell .comp-input { width:70px; text-align:right; }

.mat-buy-group { border:1px solid var(--line-soft); border-radius:var(--radius-10); padding:12px; margin-bottom:10px; background:var(--surface-raised); }
.mat-buy-head { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text); margin-bottom:8px; flex-wrap:wrap; }
.mat-buy-lines { display:flex; flex-direction:column; gap:6px; }
.mat-buy-lines label { display:flex; align-items:center; gap:8px; font-size:12.5px; color:var(--text-secondary); }
.mat-buy-label { flex:1; min-width:0; }

/* --- modal (own overlay so it can coexist with the competitors one) --- */
.mat-modal-overlay { position:fixed; inset:0; z-index:900; background:rgba(10,9,7,0.75); backdrop-filter:blur(2px); display:none; align-items:flex-start; justify-content:center; padding:40px 16px; overflow-y:auto; }
.mat-modal-overlay.open { display:flex; }
.mat-modal { width:100%; max-width:760px; background:var(--card); border:1px solid var(--line); border-radius:var(--radius-14); }
.mat-modal-head { display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid var(--line-soft); }
.mat-modal-head h3 { margin:0; font-family:var(--font-display); font-size:16px; font-weight:600; color:var(--text); }
.mat-modal-close { background:none; border:none; color:var(--muted); font-size:24px; line-height:1; cursor:pointer; }
.mat-modal-body { padding:18px 20px; }
.mat-modal-foot { display:flex; align-items:center; justify-content:flex-end; gap:8px; padding:14px 20px; border-top:1px solid var(--line-soft); flex-wrap:wrap; }
.mat-sub-h { font-family:var(--font-display); font-size:13px; font-weight:600; color:var(--text); margin:18px 0 8px; }

.mat-line-row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; padding:8px 0; border-bottom:1px solid var(--line-soft); }
.mat-line-row .mat-l-material { flex:1; min-width:180px; }
.mat-supchips { flex-basis:100%; display:flex; align-items:center; gap:6px; flex-wrap:wrap; font-size:11px; color:var(--muted); }
.mat-supchip { font-size:11px; font-weight:600; color:var(--text-secondary); background:var(--surface-raised); border:1px solid var(--line); border-radius:var(--radius-6); padding:3px 9px; cursor:pointer; font-family:inherit; }
.mat-supchip:hover { border-color:var(--orange); color:var(--orange); }

.mat-parcel-form { border:1px solid var(--line-soft); border-radius:var(--radius-10); padding:12px; margin-bottom:10px; background:var(--surface-raised); }
.mat-parcel-form-top { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; font-size:13px; color:var(--text); }
.mat-parcel-form-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:8px; }
.mat-parcel-form-lines { display:flex; flex-direction:column; gap:5px; margin-top:10px; font-size:12.5px; color:var(--text-secondary); }
.mat-parcel-form-lines label { display:flex; align-items:center; gap:7px; cursor:pointer; }

/* --- Stocktake (Phase 4): the migration-baseline checklist. Count inputs stay empty until
   a human types in them, so the column reads as a form, never as data. --- */
.mat-stock-table .mat-stock-input { width:110px; text-align:right; }
.mat-stock-table td { vertical-align:middle; }
.mat-stock-delta { white-space:nowrap; font-weight:600; }
.mat-warn-chip { font-size:11px; font-weight:600; color:var(--warn); border:1px solid var(--warn); border-radius:var(--radius-6); padding:2px 7px; white-space:nowrap; }

@media (max-width: 900px) {
  .mat-stock-table .mat-stock-input { width:88px; }
}

@media (max-width: 900px) {
  .mat-head-actions { margin-left:0; width:100%; }
  .mat-head-actions .comp-input { flex:1; min-width:0; }
  .mat-kpis { grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:8px; }
  .mat-purchase-head { flex-direction:column; align-items:stretch; }
  .mat-purchase-actions { justify-content:flex-start; }
  .mat-parcel-top { flex-direction:column; align-items:flex-start; }
  .mat-parcel-actions { width:100%; }
  .mat-parcel-actions .comp-btn { flex:1; text-align:center; }
  .mat-supopts { max-width:none; }
  .mat-modal-overlay { padding:16px 8px; }
  .mat-line-row { flex-direction:column; align-items:stretch; }
  .mat-line-row .comp-input { width:100% !important; }
}

/* --- landed cost (Phase 5: the freight / duty editor on a purchase) --- */
.mat-cost-rows { display:flex; flex-direction:column; gap:8px; margin:12px 0 18px; }
.mat-cost-row { display:grid; grid-template-columns:1.2fr .8fr .8fr 1.2fr 1.4fr auto auto; gap:6px; align-items:center; }
.mat-cost-row-head { font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); }
.mat-cost-row-new { border-top:1px solid var(--line-soft); padding-top:10px; }
.mat-cost-row .comp-input { width:100%; min-width:0; }
@media (max-width:760px) {
  .mat-cost-row { grid-template-columns:1fr 1fr; }
  .mat-cost-row-head { display:none; }
}

/* --- catalog thumbnails + material edit modal --- */
.mat-thumb { display:block; width:44px; height:44px; border-radius:var(--radius-6); border:1px solid var(--line); object-fit:cover; background:var(--surface-raised); cursor:pointer; }
.mat-thumb:hover { border-color:var(--orange); }
.mat-thumb-empty { display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; letter-spacing:.04em; color:var(--muted); }
.mat-edit-image { display:flex; gap:14px; align-items:center; margin-bottom:16px; }
.mat-edit-image > div:first-child { width:96px; height:96px; flex:0 0 96px; display:flex; align-items:center; justify-content:center; border:1px solid var(--line); border-radius:var(--radius-8); background:var(--surface-raised); overflow:hidden; font-size:11px; text-align:center; }
.mat-edit-image img { width:100%; height:100%; object-fit:cover; }
