/* Capa visual de operación. Las reglas de datos y almacenamiento viven en app.js. */
:root {
  --bg:#f3f5f7;
  --surface:#fff;
  --surface-2:#f5f7f9;
  --ink:#182533;
  --muted:#536476;
  --line:#d9e0e7;
  --nav:#142536;
  --nav-2:#20384e;
  --blue:#175f88;
  --blue-soft:#e9f3f8;
  --green:#216d50;
  --green-soft:#e7f4ed;
  --amber:#8a5b08;
  --amber-soft:#fff4df;
  --red:#ad3c36;
  --red-soft:#fcecea;
  --radius:6px;
  --shadow:none;
}
body { font-size:14px; line-height:1.5; }
.app-shell { grid-template-columns:250px minmax(0,1fr); }
.sidebar { padding:18px 12px 12px; }
.brand { padding:0 7px 17px; }
.brand-mark { flex:0 0 42px; }
.side-nav { gap:2px; margin-top:14px; }
.side-nav button { min-height:44px; padding:10px 11px; border-left:3px solid transparent; border-radius:4px; font-size:.88rem; }
.side-nav button[aria-current="page"] { border-left-color:#58a8cf; background:#e9f3f8; color:#123753; }
.topbar { min-height:84px; padding:13px 25px; }
.topbar-title p { color:var(--muted); letter-spacing:.045em; }
.topbar-title h1 { font-size:1.44rem; }
.topbar-title span { font-size:.8rem; }
main { padding:19px 25px 32px; }
.view-section { gap:14px; }
.source-band { padding:9px 13px; border-left:3px solid var(--blue); background:var(--surface); }
.button { min-height:42px; padding:9px 13px; font-size:.84rem; }
.button-primary { background:var(--blue); }
.button-primary:hover { background:#104d70; }
.button-secondary:hover { border-color:#90b5c9; }
.filter-band { gap:10px; padding:13px; }
.field { gap:5px; color:var(--ink); font-size:.78rem; }
.field input,.field select,.field textarea { min-height:42px; border-color:#cdd6df; }
.field input::placeholder { color:#8190a0; }
.toggle-field { min-height:42px; }
.metrics { gap:8px; }
.metric { padding:11px 13px; border:1px solid var(--line); border-top:2px solid var(--blue); box-shadow:none; }
.metric strong { margin-top:2px; font-size:1.27rem; }
.metric span { font-size:.76rem; }
.data-panel { padding:14px; box-shadow:none; }
.panel-heading { margin-bottom:11px; }
.panel-heading h2 { font-size:1rem; }
.table-frame { box-shadow:none; }
table { font-size:.79rem; }
th,td { padding:8px 10px; }
th { color:#445668; font-size:.69rem; letter-spacing:.035em; }
tbody tr:nth-child(even) { background:#fafbfc; }
tbody tr:hover,tbody tr:nth-child(even):hover { background:var(--blue-soft); }
.status { border-radius:4px; }
.row-actions { flex-wrap:nowrap; }
.row-actions .button { min-height:34px; padding:6px 8px; white-space:nowrap; }
.empty-state { min-height:130px; gap:3px; padding:20px; border:1px dashed var(--line); border-radius:var(--radius); }
.empty-state strong,.empty-state span { display:block; }
.shift-toolbar { align-items:end; }
.shift-toolbar h2 { font-size:1.1rem; }
.shift-toolbar p { font-size:.83rem; }
.metrics-three { gap:0; overflow:hidden; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
.metrics-three .metric { border:0; border-right:1px solid var(--line); border-radius:0; background:transparent; }
.metrics-three .metric:last-child { border-right:0; }
.wizard-dialog { width:min(1160px,calc(100% - 24px)); height:min(840px,calc(100dvh - 24px)); max-height:calc(100dvh - 24px); border-radius:8px; }
.dialog-header { padding:14px 18px; }
.dialog-header p { color:var(--muted); letter-spacing:.04em; }
.dialog-header h2 { font-size:1.2rem; }
.icon-button { width:42px; height:42px; }
.wizard-progress { gap:6px; padding:10px 18px; background:var(--surface); }
.wizard-step { gap:8px; font-size:.78rem; }
.wizard-step:not(:last-child)::after { right:8px; left:40px; top:17px; }
.wizard-step span { width:34px; height:34px; flex-basis:34px; }
.wizard-step strong { padding-right:6px; background:var(--surface); }
.wizard-step.current { color:#155b82; }
.wizard-body { padding:20px 22px; background:#fbfcfd; }
.wizard-form { max-width:850px; margin:0; padding:4px 0; gap:18px; }
.wizard-form .field { font-size:.84rem; }
.wizard-copy { max-width:none; margin:0 0 13px; }
.wizard-copy h3 { margin-bottom:2px; font-size:1.04rem; }
.wizard-copy p { font-size:.83rem; }
.transfer-grid { grid-template-columns:minmax(0,1fr) 146px minmax(0,1fr); align-items:stretch; gap:13px; max-width:none; }
.transfer-panel { gap:7px; padding:12px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
.transfer-panel>span { font-size:.9rem; font-weight:800; }
.transfer-panel>span strong { border-radius:4px; color:var(--ink); }
.transfer-panel select { height:360px; padding:4px; font-size:.83rem; }
.transfer-panel option { padding:8px 9px; line-height:1.35; }
.transfer-panel small { color:var(--muted); font-size:.75rem; }
.transfer-controls { align-content:center; gap:8px; }
.transfer-button { display:flex; justify-content:center; gap:5px; width:100%; min-height:43px; height:auto; padding:7px 8px; font-size:.75rem; line-height:1.15; }
.transfer-button span:first-child { font-size:1.17rem; line-height:1; }
.transfer-button span:last-child { text-align:left; }
.transfer-add { border-color:#b2cfde; background:var(--blue-soft); color:#134d6e; }
.pending-responsible { display:grid; grid-template-columns:minmax(0,1fr) minmax(250px,390px); align-items:end; gap:16px; margin:0 0 13px; padding:13px 15px; border:1px solid #afd1c1; border-left:4px solid var(--green); border-radius:var(--radius); background:var(--green-soft); }
.pending-responsible strong,.pending-responsible span { display:block; }
.pending-responsible strong { color:#18583e; font-size:.96rem; }
.pending-responsible span { margin-top:3px; color:#366a55; font-size:.8rem; }
.pending-responsible-field { max-width:none; margin:0; }
.pending-responsible-field input { background:#fff; }
.wizard-preview { min-width:0; }
.wizard-preview .print-document { border:1px solid var(--line); }
.wizard-actions { padding:12px 18px; }
.print-dialog { width:min(1100px,calc(100% - 20px)); max-height:calc(100dvh - 20px); }
#printDialogBody { padding:22px; }
.print-document { width:100%; max-width:210mm; min-width:0; padding:17mm; color:#172431; box-shadow:0 4px 24px rgba(26,42,64,.12); }
.print-document-title { border-bottom-color:#175f88; }
.print-document-title p { color:#175f88; }
.print-process { margin-top:20px; }
.print-section-title>span { border-radius:4px; background:#175f88; }
.print-process table { width:100%; table-layout:fixed; }
.print-process th,.print-process td { overflow-wrap:anywhere; }
.print-process th:first-child,.print-process td:first-child { width:6%; }
.print-process th:nth-child(2),.print-process td:nth-child(2) { width:16%; }
.print-process th:nth-child(3),.print-process td:nth-child(3) { width:40%; }
.print-process th:nth-child(4),.print-process td:nth-child(4) { width:23%; }
.print-process th:nth-child(5),.print-process td:nth-child(5) { width:15%; }
.print-handover { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:0 0 8px; padding:8px 10px; border:1px solid #b6ccbf; background:#eaf4ee; }
.print-handover span { color:#355f4a; font-size:.69rem; font-weight:800; text-transform:uppercase; }
.print-handover strong { color:#194c37; font-size:.83rem; overflow-wrap:anywhere; text-align:right; }
.print-signatures { gap:40px; margin-top:40px; }
@media (max-width:1180px) {
  .row-actions { flex-wrap:wrap; }
  .transfer-grid { grid-template-columns:minmax(0,1fr) 136px minmax(0,1fr); }
}
@media (max-width:900px) {
  .topbar { padding:12px 17px; }
  main { padding:17px; }
  .wizard-step strong { display:block; font-size:.72rem; white-space:normal; line-height:1.15; }
  .wizard-step:not(:last-child)::after { display:none; }
}
@media (max-width:720px) {
  .topbar { gap:10px; }
  main { padding:12px; }
  .view-section { gap:11px; }
  .metrics-three { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .metrics-three .metric { padding:9px; }
  .metrics-three .metric strong { font-size:1.08rem; }
  .metrics-three .metric span { line-height:1.2; }
  .data-panel { padding:11px; }
  .table-frame { overflow:visible; }
  tbody { gap:7px; }
  td { padding:6px 9px; font-size:.79rem; overflow-wrap:anywhere; }
  td::before { font-size:.68rem; }
  .row-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
  .row-actions .button { min-height:40px; }
  .activity-table tbody tr { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:0 8px; padding:8px 10px; }
  .activity-table td { display:block; width:auto; padding:2px 0; border:0; background:transparent!important; }
  .activity-table td::before { display:none; }
  .activity-table td:first-child { grid-column:1; color:var(--blue); font-size:.72rem; font-weight:800; }
  .activity-table td:nth-child(2) { grid-column:1; font-weight:600; }
  .activity-table td:nth-child(3) { grid-column:2; grid-row:1 / span 2; align-self:center; color:var(--muted); font-size:.72rem; }
  .wizard-dialog { width:calc(100% - 12px); height:calc(100dvh - 12px); max-height:calc(100dvh - 12px); }
  .wizard-progress { padding:8px 10px; gap:3px; }
  .wizard-step { display:grid; justify-items:center; align-content:start; gap:3px; text-align:center; }
  .wizard-step span { width:27px; height:27px; flex-basis:27px; font-size:.73rem; }
  .wizard-step strong { max-width:100%; padding:0; font-size:.64rem; }
  .wizard-body { padding:12px; }
  .wizard-form { gap:12px; }
  .transfer-grid { grid-template-columns:1fr; gap:8px; }
  .transfer-panel { padding:9px; }
  .transfer-panel select { height:160px; }
  .transfer-controls { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
  .transfer-button { min-height:44px; padding:6px; }
  .transfer-button span:last-child { font-size:.72rem; }
  .pending-responsible { grid-template-columns:1fr; gap:9px; padding:11px; }
  .wizard-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; padding:9px 12px; }
  .wizard-actions .button { width:100%; min-width:0; min-height:42px; font-size:.78rem; }
  .wizard-actions [data-wizard-action="save-print"] { grid-column:1 / -1; }
  .wizard-preview { min-width:0; }
  #printDialogBody { padding:8px; overflow:auto; }
  .print-document { max-width:none; padding:14px; box-shadow:none; }
  .print-document-title { gap:8px; }
  .print-document-title h1 { font-size:1.3rem; }
  .print-document-title>strong { white-space:nowrap; }
  .print-profile { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .print-profile div { border-right:1px solid #cad3de!important; border-bottom:1px solid #cad3de!important; }
  .print-profile div:nth-child(2n) { border-right:0!important; }
  .print-profile div:nth-last-child(-n+2) { border-bottom:0!important; }
  .print-process table { display:block!important; border:0; }
  .print-process thead { display:none!important; }
  .print-process tbody { display:grid!important; gap:7px; }
  .print-process tr { display:grid!important; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px 10px; padding:8px; border:1px solid #cad3de!important; border-radius:4px!important; background:#fff!important; }
  .print-process td,.print-process td:nth-child(n) { display:block!important; width:auto!important; min-width:0!important; padding:0!important; border:0!important; font-size:.76rem; overflow-wrap:anywhere; text-align:left!important; }
  .print-process td::before { display:block!important; margin-bottom:1px; color:#5a6878; content:attr(data-label); font-size:.61rem; font-weight:800; text-transform:uppercase; }
  .print-process td:first-child { grid-column:1; grid-row:2; }
  .print-process td:first-child { background:transparent!important; }
  .print-process td:nth-child(2) { grid-column:2; grid-row:2; }
  .print-process td:nth-child(3) { grid-column:1 / -1; grid-row:1; font-weight:700; }
  .print-process td:nth-child(4) { grid-column:1; grid-row:3; }
  .print-process td:nth-child(5) { grid-column:2; grid-row:3; }
  .print-process td[colspan] { grid-column:1 / -1; }
  .print-process td[colspan]::before { display:none!important; }
  .print-handover { display:grid; gap:2px; }
  .print-handover strong { text-align:left; }
  .print-signatures { gap:15px; margin-top:34px; }
}
@media (max-width:430px) {
  .metrics-three .metric span { font-size:.68rem; }
  .metrics-three .metric strong { font-size:1rem; }
  .wizard-step strong { font-size:.6rem; }
  .dialog-header { padding:11px 13px; }
  .dialog-header h2 { font-size:1.06rem; }
  .print-profile div { padding:7px; }
  .print-signatures { grid-template-columns:1fr 1fr; }
}
@media (prefers-color-scheme:dark) {
  :root { --bg:#101923; --surface:#182633; --surface-2:#223241; --ink:#edf3f8; --muted:#b9c8d5; --line:#34495b; --nav:#0c1721; --nav-2:#22394c; --blue:#80c2e5; --blue-soft:#193c51; --green:#86cda4; --green-soft:#1b3d2e; --amber:#e9c276; --amber-soft:#46391c; --red:#efa19b; --red-soft:#462a2b; }
  .wizard-body { background:#12202b; }
  tbody tr:nth-child(even) { background:#1b2b39; }
  .side-nav button[aria-current="page"] { background:#d9effa; color:#123753; }
  .pending-responsible { border-color:#568b70; }
  .pending-responsible strong,.pending-responsible span { color:#d5eee0; }
  .pending-responsible-field input { background:var(--surface); }
  .transfer-add { border-color:#446e83; color:#d6f0fc; }
  .wizard-step.current { color:#a4dbf6; }
  .wizard-step.current span { color:#123753; }
}
@media print {
  @page { size:A4 portrait; margin:12mm; }
  .print-document { width:100%!important; max-width:none!important; min-width:0!important; padding:0!important; box-shadow:none!important; color:#172431!important; font-size:9pt; }
  .print-document-title { margin:0 0 3mm; padding-bottom:3mm; }
  .print-profile { display:grid!important; grid-template-columns:repeat(3,minmax(0,1fr))!important; }
  .print-profile div { padding:2mm 2.5mm; }
  .print-process { margin-top:5mm; }
  .print-process table { display:table!important; width:100%!important; table-layout:fixed!important; }
  .print-process thead { display:table-header-group!important; }
  .print-process tbody { display:table-row-group!important; }
  .print-process tr { display:table-row!important; break-inside:avoid; }
  .print-process th,.print-process td { display:table-cell!important; width:auto!important; padding:1.7mm 2mm!important; border:1px solid #cad3de!important; font-size:8pt!important; overflow-wrap:anywhere; }
  .print-process th:first-child,.print-process td:first-child { width:6%!important; }
  .print-process th:nth-child(2),.print-process td:nth-child(2) { width:16%!important; }
  .print-process th:nth-child(3),.print-process td:nth-child(3) { width:40%!important; }
  .print-process th:nth-child(4),.print-process td:nth-child(4) { width:23%!important; }
  .print-process th:nth-child(5),.print-process td:nth-child(5) { width:15%!important; }
  .print-process td::before { display:none!important; }
  .print-handover { break-inside:avoid; margin-bottom:2mm; padding:2mm 3mm; }
  .print-signatures { break-inside:avoid; margin-top:12mm; }
}

/* Filtros y resultados del informe de pedidos. */
.filter-orders { grid-template-columns:repeat(5,minmax(0,1fr)); }
.filter-orders .field-grow { grid-column:span 3; min-width:0; }
.orders-table { min-width:2200px; }
.orders-table td[data-label="FECHA"],.orders-table td[data-label="F.PROMETIDA"] { white-space:nowrap; }
.order-days small { display:block; color:var(--muted); font-size:.68rem; font-weight:600; white-space:normal; }
@media (max-width:1180px) {
  .filter-orders { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .filter-orders .field-grow { grid-column:auto; }
}
@media (max-width:720px) {
  .filter-orders { grid-template-columns:minmax(0,1fr); }
  .orders-table { min-width:0; }
  .order-days small { grid-column:2; }
}

.order-report-toolbar { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:16px; border:1px solid #a8cddd; border-left:4px solid var(--blue); border-radius:var(--radius); background:var(--blue-soft); }
.order-report-toolbar strong { display:block; font-size:1rem; }
.order-report-toolbar p { margin:3px 0 0; color:var(--muted); }
.order-report-toolbar .button { flex:none; }
.filter-orders .field-grow { grid-column:auto; }
.report-dialog { width:min(800px,calc(100% - 24px)); max-height:calc(100dvh - 24px); padding:0; overflow:auto; border:1px solid var(--line); border-radius:8px; background:var(--surface); color:var(--ink); box-shadow:0 20px 60px rgba(0,0,0,.3); }
.report-dialog::backdrop { background:rgba(10,20,32,.68); }
.report-dialog-body { padding:18px; }
.report-choice-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.report-choice-grid fieldset { min-width:0; margin:0; padding:11px 13px; border:1px solid var(--line); border-radius:var(--radius); }
.report-choice-grid legend { padding:0 4px; font-weight:800; }
.report-choice-grid label { display:flex; align-items:center; gap:8px; padding:5px 0; cursor:pointer; }
.report-choice-grid input,.report-buyers input,.column-option input { accent-color:var(--blue); }
.report-buyers-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:17px 0 8px; }
.report-buyers-heading p { margin:2px 0 0; color:var(--muted); font-size:.8rem; }
.report-buyers { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; max-height:230px; overflow:auto; }
.report-buyers label { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:0 8px; min-width:0; padding:8px 10px; border:1px solid var(--line); border-radius:var(--radius); cursor:pointer; }
.report-buyers label span,.report-buyers label small { min-width:0; overflow-wrap:anywhere; }
.report-buyers label small { grid-column:2; color:var(--muted); }
.report-summary { margin:13px 0 0; padding:9px 11px; border-radius:var(--radius); background:var(--blue-soft); }
.report-results { margin-top:12px; padding:12px; border:1px solid var(--line); border-radius:var(--radius); }
.report-results p { margin:3px 0 10px; color:var(--muted); }
.report-file-list { margin:8px 0 12px; padding-left:20px; overflow-wrap:anywhere; }
.report-file-list li { margin:3px 0; }
.report-results .button { max-width:100%; white-space:normal; }
.report-master-selector { max-width:390px; padding:12px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
.report-master-selector select { width:100%; }
.report-config { min-width:0; }
.report-config .panel-heading { display:flex; align-items:start; justify-content:space-between; gap:12px; }
.report-config .panel-heading p { color:var(--muted); }
.report-config .panel-heading .button { flex:none; }
.column-order-help { max-width:760px; margin:0 0 12px; padding:9px 11px; border-radius:var(--radius); background:var(--blue-soft); color:var(--ink); font-size:.8rem; }
.column-list { display:grid; grid-template-columns:minmax(0,1fr); gap:6px; max-width:760px; }
.column-option { position:relative; display:flex; align-items:center; gap:9px; min-width:0; padding:5px 9px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface-2); }
.column-option label { display:flex; align-items:center; gap:8px; min-width:0; min-height:44px; flex:1; cursor:pointer; }
.column-option label span { overflow-wrap:anywhere; }
.column-drag-handle { display:grid; place-items:center; width:44px; height:44px; flex:none; border:1px solid var(--line); border-radius:5px; background:var(--surface); color:var(--muted); cursor:grab; touch-action:none; }
.column-drag-handle:active { cursor:grabbing; }
.column-drag-handle svg { width:18px; height:18px; fill:currentColor; }
.column-drag-handle:focus-visible { outline:3px solid var(--blue); outline-offset:2px; }
.column-option.is-dragging { border:2px solid var(--blue); background:var(--blue-soft); opacity:.7; }
.column-option.drop-before::before,.column-option.drop-after::after { position:absolute; left:0; right:0; z-index:2; height:4px; border-radius:4px; background:var(--blue); content:""; }
.column-option.drop-before::before { top:-5px; }
.column-option.drop-after::after { bottom:-5px; }
.column-drag-preview { position:fixed; z-index:1000; pointer-events:none; border:2px solid var(--blue); background:var(--surface); box-shadow:0 10px 25px rgba(0,0,0,.25); opacity:.96; }
.source-panel td .button { white-space:normal; }
.missing-source-list { display:grid; gap:8px; margin-top:13px; padding-top:12px; border-top:1px solid var(--line); }
.missing-source-list>div { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.empty-source { max-width:700px; padding:28px; border:1px dashed var(--line); border-radius:var(--radius); background:var(--surface); }
.empty-source h2 { margin:0 0 6px; }
.empty-source p { margin:0 0 16px; color:var(--muted); }
.empty-source-actions { display:flex; flex-wrap:wrap; gap:8px; }
.activity-search { max-width:440px; margin-bottom:7px; }
.catalog-count { margin:0 0 8px; color:var(--muted); font-size:.78rem; }
.activity-row-actions { display:flex; gap:5px; }
.activity-icon-button { display:inline-grid; place-items:center; width:36px; height:36px; padding:7px; border:1px solid var(--line); border-radius:5px; background:var(--surface); color:var(--blue); cursor:pointer; }
.activity-icon-button:hover { background:var(--blue-soft); }
.activity-delete-button { color:var(--red); }
.activity-icon-button svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; }
@media (max-width:720px) {
  .order-report-toolbar { align-items:stretch; flex-direction:column; }
  .report-choice-grid,.report-buyers,.column-list { grid-template-columns:minmax(0,1fr); }
  .report-buyers-heading,.report-config .panel-heading { align-items:stretch; flex-direction:column; }
  .report-buyers-heading .button,.report-config .panel-heading .button { width:100%; }
  .missing-source-list>div { align-items:stretch; flex-direction:column; }
  .missing-source-list .button { width:100%; }
  .activity-table td:nth-child(3) { grid-column:1; grid-row:auto; }
  .activity-table td:nth-child(4) { grid-column:2; grid-row:1 / span 3; align-self:center; }
}
