/* Operaciones rediseñado (Fabricación, Compras, Materiales y repuestos, Bienes y permutas, Entregas, Garantías).
   Todo con ámbito: body[data-section="operaciones"] (lo fija app.js al navegar). No toca otras secciones, la barra lateral ni la cabecera. */

/* ---------- base común: pestañas, indicadores, tablas, barras, detalles y formularios ---------- */
body[data-section="operaciones"] .tabs { margin-bottom: 14px; }
body[data-section="operaciones"] .tabs button[aria-selected="true"] { box-shadow: var(--shadow-1); }
body[data-section="operaciones"] .kpis { gap: 10px; }
body[data-section="operaciones"] .kpi { padding: 12px 16px; }
body[data-section="operaciones"] .kpi .label { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
body[data-section="operaciones"] .kpi .value { font-size: 1.45rem; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
body[data-section="operaciones"] .kpi .sub { font-size: var(--fs-xs); }
body[data-section="operaciones"] .toolbar { gap: 8px 10px; margin-bottom: 10px; }
body[data-section="operaciones"] .table-wrap .tbl thead th { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
body[data-section="operaciones"] .table-wrap .tbl td { padding-top: 11px; padding-bottom: 11px; vertical-align: middle; }
body[data-section="operaciones"] .table-wrap .tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
body[data-section="operaciones"] .table-wrap .tbl tbody tr:hover { background: var(--accent-soft); }
body[data-section="operaciones"] .table-wrap .tbl td > strong:first-child { font-weight: 600; }
body[data-section="operaciones"] .table-wrap .tbl small.muted { font-size: var(--fs-xs); margin-top: 2px; }
body[data-section="operaciones"] .table-wrap .tbl .actions { justify-content: flex-end; }
body[data-section="operaciones"] .card { border-radius: var(--r-lg); }

/* detalles y formularios (paneles): cabecera y pie siempre visibles, secciones ordenadas */
body[data-section="operaciones"] .overlay .panel-head, body[data-section="operaciones"] .overlay .panel-foot { flex: none; }
body[data-section="operaciones"] .overlay .panel-head h2 { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }
body[data-section="operaciones"] .overlay .panel-body { padding: 16px 22px; display: grid; gap: 12px; align-content: start; }
body[data-section="operaciones"] .overlay .panel-body > h3, body[data-section="operaciones"] .overlay .panel-body > div > h3 { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--accent-ink); margin: 6px 0 0; }
body[data-section="operaciones"] .overlay .panel-body .toolbar { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); margin: 0; }
body[data-section="operaciones"] .overlay .panel-body .toolbar h3 { font-size: 1.05rem !important; }
body[data-section="operaciones"] .overlay .panel-body .list.compact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 2px 14px; }
body[data-section="operaciones"] .overlay .panel-body .list.compact li { padding: 8px 0; }
body[data-section="operaciones"] .overlay .panel-body .card-sub { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; }
body[data-section="operaciones"] .overlay .panel-body .card-sub h3 { margin: 0 0 6px; font-size: var(--fs-md); }
body[data-section="operaciones"] .overlay .panel-body .field label { font-weight: 600; font-size: var(--fs-sm); }
body[data-section="operaciones"] .overlay .panel-body .row2, body[data-section="operaciones"] .overlay .panel-body .row3 { gap: 10px 14px; }
body[data-section="operaciones"] .overlay .panel-foot { align-items: center; flex-wrap: wrap; }

/* ---------- Fabricación: tablero por estados ---------- */
.mf-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; align-items: start; }
.mf-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.mf-col > header { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; }
.mf-col h3 { margin: 0; font-size: var(--fs-sm); font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--text-2); }
.mf-n { min-width: 24px; height: 22px; padding: 0 7px; display: inline-grid; place-items: center; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: var(--fs-xs); font-weight: 700; }
.mf-col.mf-en_proceso { border-top: 3px solid var(--warn-ink); }
.mf-col.mf-planificada { border-top: 3px solid var(--info-ink); }
.mf-col.mf-terminada { border-top: 3px solid var(--ok-ink); }
.mf-col.mf-borrador { border-top: 3px solid var(--line-strong); }
.mf-empty { text-align: center; padding: 14px 0; margin: 0; font-size: var(--fs-sm); }
.mf-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 11px 12px; display: grid; gap: 5px; box-shadow: var(--shadow-1); }
.mf-card.blocked { border-color: color-mix(in srgb, var(--err) 45%, var(--line)); box-shadow: inset 3px 0 0 var(--err); }
.mf-card.late:not(.blocked) { box-shadow: inset 3px 0 0 var(--warn-ink); }
.mf-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mf-name { font-weight: 600; line-height: 1.3; }
.mf-meta { display: flex; align-items: center; gap: 5px; font-size: var(--fs-xs); flex-wrap: wrap; }
.mf-meta svg { width: 13px; height: 13px; }
.mf-mat { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: var(--r-sm, 8px); font-size: var(--fs-xs); font-weight: 600; margin-top: 2px; }
.mf-mat svg { width: 14px; height: 14px; flex: none; }
.mf-mat.ok { background: var(--ok-soft); color: var(--ok-ink); }
.mf-mat.warn { background: var(--warn-soft); color: var(--warn-ink); }
.mf-mat.bad { background: var(--err-soft); color: var(--err-ink); }
.mf-act { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }

/* ---------- Compras: recorrido solicitud → orden → recepción → factura y pago ---------- */
.pc-journey { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.pc-journey li { position: relative; border-right: 1px solid var(--line); min-width: 0; }
.pc-journey li:last-child { border-right: 0; }
.pc-step { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 14px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; color: var(--text-2); }
.pc-step:hover:not(:disabled) { background: var(--surface-2); }
.pc-step:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.pc-step:disabled { cursor: not-allowed; opacity: .55; }
.pc-n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-weight: 700; font-size: var(--fs-sm); }
.pc-t { display: grid; min-width: 0; }
.pc-t strong { font-size: var(--fs-sm); color: var(--text); }
.pc-t small { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-journey li.on { background: var(--accent-soft); }
.pc-journey li.on .pc-n { background: var(--primary); color: #fff; }
.pc-journey li.done .pc-n { background: var(--ok-soft); color: var(--ok-ink); }

/* ---------- Materiales y repuestos: reposición ---------- */
.tbl-stock tr.stk-low > td { background: color-mix(in srgb, var(--err-soft) 55%, transparent); }
.tbl-stock tr.stk-low > td:first-child { box-shadow: inset 3px 0 0 var(--err); }

/* ---------- Bienes y permutas: intercambio gráfico ---------- */
.trade-swap { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: stretch; }
.trade-swap .swap-mid { display: grid; align-content: center; justify-items: center; gap: 8px; min-width: 120px; padding: 0 4px; }
.swap-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 1.35rem; line-height: 1; }
.swap-diff { display: grid; gap: 4px; justify-items: center; font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.swap-diff .diff-cobrar { color: var(--ok-ink); } .swap-diff .diff-devolver { color: var(--err-ink); } .swap-diff .diff-cero { color: var(--muted); }
.trade-swap .card-sub:first-child { border-left: 3px solid var(--line-strong); } .trade-swap .card-sub:last-child { border-left: 3px solid var(--accent); }

/* ---------- Entregas: agenda, preparación y acta ---------- */
.ag { display: grid; gap: 10px; }
.ag-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 12px; display: grid; gap: 8px; }
.ag-day.today { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
.ag-day.late { border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.ag-day.closed { background: var(--surface-2); }
.ag-day h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 700; text-transform: capitalize; }
.ag-n { min-width: 22px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 99px; background: var(--surface-3); font-size: var(--fs-xs); font-weight: 700; }
.ag-empty { margin: 0; }
.ag-item { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.ag-item.late { box-shadow: inset 3px 0 0 var(--err); }
.ag-when { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }
.ag-main { display: grid; gap: 1px; min-width: 0; }
.ag-main .muted svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.ag-side { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dl-prep { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r-lg); background: var(--warn-soft); color: var(--warn-ink); border: 1px solid color-mix(in srgb, var(--warn-ink) 22%, var(--line)); }
.dl-prep.ok { background: var(--ok-soft); color: var(--ok-ink); border-color: color-mix(in srgb, var(--ok-ink) 22%, var(--line)); }
.dl-prep small { display: block; font-size: var(--fs-xs); opacity: .9; }

/* ---------- Garantías: vigencia y diferencias ---------- */
.vig { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 5px 0 2px; min-width: 120px; }
.vig span { display: block; height: 100%; border-radius: 99px; }
.vig-ok span { background: var(--ok-ink); } .vig-warn span { background: var(--warn-ink); } .vig-off span { background: var(--line-strong); }
.wr-legend { margin: 0 0 10px; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }

@media (max-width: 900px) {
  .pc-journey { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pc-journey li:nth-child(2) { border-right: 0; }
  .pc-journey li:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .trade-swap { grid-template-columns: minmax(0, 1fr); }
  .trade-swap .swap-mid { grid-auto-flow: column; min-width: 0; padding: 4px 0; }
  .ag-item { grid-template-columns: minmax(0, 1fr); }
  .ag-side { justify-content: flex-start; }
}
