/* Refinamientos de auditoría: legibilidad, densidad, responsive y accesibilidad. */
html { scroll-behavior: smooth; }
body { overflow-x: hidden; text-rendering: optimizeLegibility; }
::selection { background: #ccebf0; color: var(--brand); }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.app-shell, .main, .grid > * { min-width: 0; }
.main > * { max-width: 100%; }
h1 { letter-spacing: -.018em; }
h2 { letter-spacing: -.01em; }
button:disabled { cursor: not-allowed; opacity: .55; }
.data-table th:first-child, .data-table td:first-child { padding-left: 14px; }
.order-code { white-space: nowrap; }
.order-description { min-width: 145px; max-width: 220px; }
.order-table th:first-child { min-width: 104px; }
.order-table td:nth-child(2) { min-width: 150px; }
.order-table td:nth-child(4), .order-table td:nth-child(5) { min-width: 115px; }
.fact select, .page-head select {
  border: 1px solid #c9d6db; border-radius: 7px; padding: 8px 10px;
  background: #fff; color: var(--ink); min-width: 0;
}
.field input, .field select, .field textarea, .filters input, .filters select,
.global-search input, .fact select, .page-head select {
  transition: border-color .12s, box-shadow .12s;
}
.field input:hover, .field select:hover, .field textarea:hover,
.filters input:hover, .filters select:hover { border-color: #9db3bb; }
.field input:focus, .field select:focus, .field textarea:focus,
.filters input:focus, .filters select:focus, .global-search input:focus {
  border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(22,168,193,.12); outline: 0;
}
.filters { align-items: end; }
.filters input { min-width: 180px; }
.filter-count { margin-left: auto; color: var(--muted); font-size: 12px; padding: 8px 0; }
.filter-label { display: grid; gap: 3px; }
.filter-label > span {
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700;
}
.filter-label > input, .filter-label > select { width: 100%; }
.surface-note {
  display: flex; gap: 10px; align-items: flex-start; background: #f6fafb;
  border: 1px solid #d9e8eb; border-radius: 8px; padding: 11px 13px; color: #38535d;
}
.surface-note strong { display: block; }
.surface-note svg { width: 18px; flex: 0 0 auto; color: var(--brand-2); }
.mobile-scrim { display: none; }
.print-only { display: none; }
.map-panel { margin-bottom: 15px; overflow: hidden; }
.center-map-layout { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(235px,.65fr); gap: 16px; }
.center-map {
  position: relative; min-height: 330px; overflow: hidden; isolation: isolate;
  border: 1px solid #cfdee1; border-radius: 10px; background: #edf4f4;
}
.center-map-base { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.map-place { position: absolute; color: #81989f; font-size: 10px; font-weight: 700; letter-spacing: .03em; pointer-events: none; }
.map-place.north { left: 7%; top: 8%; }
.map-place.coast { right: 5%; bottom: 10%; }
.map-place.center { left: 42%; top: 50%; }
.map-marker {
  position: absolute; left: var(--x); top: var(--y); transform: translate(-50%,-50%);
  width: 30px; height: 30px; border: 3px solid #fff; border-radius: 50% 50% 50% 6px;
  rotate: -45deg; color: #fff; background: var(--green); box-shadow: 0 3px 10px rgba(15,52,63,.25); z-index: 2;
}
.map-marker span { display: grid; place-items: center; width: 100%; height: 100%; rotate: 45deg; font-size: 10px; font-weight: 800; }
.map-marker.active { background: var(--blue); }
.map-marker.critical { background: var(--red); }
.map-marker:hover, .map-marker:focus-visible { z-index: 3; scale: 1.12; }
.map-marker.selected { outline: 3px solid rgba(22,168,193,.25); outline-offset: 3px; scale: 1.15; }
.map-legend { position: absolute; left: 10px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 9px; padding: 6px 8px; border: 1px solid rgba(207,222,225,.9); border-radius: 6px; background: rgba(255,255,255,.92); font-size: 10px; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 4px; }
.map-legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.map-legend i.active { background: var(--blue); }
.map-legend i.critical { background: var(--red); }
.map-detail { display: flex; flex-direction: column; gap: 16px; border-left: 1px solid var(--line); padding: 8px 2px 4px 17px; }
.map-detail h3 { margin: 4px 0; font-size: 18px; }
.map-detail p { color: var(--muted); font-size: 12px; margin: 0; }
.eyebrow { color: var(--brand-2); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; }
.map-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.map-stats div { padding: 9px; border-radius: 7px; background: #f6f9fa; }
.map-stats dt { color: var(--muted); font-size: 10px; }
.map-stats dd { margin: 2px 0 0; font-size: 19px; font-weight: 800; }
.map-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }
.map-actions .btn { flex: 1; }
.live-state { display: inline-flex; align-items: center; gap: 6px; padding: 7px 9px; color: var(--green); font-size: 11px; font-weight: 750; }
.live-state i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px rgba(30,147,92,.1); }
.live-state.paused { color: var(--amber); }
.action-center { margin-bottom: 15px; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.action-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px; border: 1px solid #e1e9eb; border-radius: 8px; background: #fbfcfc; }
.action-item:hover { border-color: #b8d4d9; background: #f5fafb; }
.action-type { flex: 0 0 76px; text-align: center; padding: 4px 6px; border-radius: 5px; background: #edf2f4; color: #47606a; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.action-type.red { background: #f9e7e8; color: #a52c32; }.action-type.amber { background: #fbf0df; color: #8b5205; }.action-type.blue { background: #e6f0fa; color: #245e96; }.action-type.cyan { background: #e1f5f8; color: #08697a; }
.notice-section + .notice-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }.notice-section > strong { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.ops-band { display: grid; grid-template-columns: repeat(3,1fr); gap: 1px; margin: 10px 0 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r); background: var(--line); box-shadow: var(--shadow); }
.ops-band > button { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; text-align: left; border: 0; padding: 11px 13px; background: #fff; color: var(--ink); }
.ops-band > button:hover { background: #f7fbfb; }.ops-band span { color: var(--muted); font-size: 11px; }.ops-band strong { font-size: 13px; }.ops-band small { grid-column: 1/-1; color: var(--muted); }
.ops-band .status-bar { grid-column: 1/-1; }.ops-band .status-bar i { display: block; height: 100%; border-radius: inherit; background: var(--cyan); }
.ops-band.has-blocker > button:last-child { background: #fff7f7; }.ops-band.has-blocker > button:last-child strong { color: var(--red); }
.compact-control { grid-template-columns: 1fr 1fr !important; gap: 18px; }.control-checks h3 { margin-top: 0; }
.control-check { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #edf1f2; }
.control-check > span { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; background: #fff1e0; color: #9b5e08; font-weight: 900; }.control-check.done > span { background: #e3f3eb; color: var(--green); }.control-check small { color: var(--muted); }
.blocker-card { border: 1px solid #efc7c9; border-left: 4px solid var(--red); border-radius: 8px; background: #fff8f8; padding: 13px; }.blocker-card p { margin: 6px 0; }.blocker-card .btn { margin-top: 12px; }
.empty.compact { padding: 14px; }.planning-kpis { grid-template-columns: repeat(4,1fr) !important; }
.capacity-board { display: grid; grid-template-columns: repeat(5,minmax(160px,1fr)); gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.capacity-card { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }.capacity-card .status-bar { margin: 8px 0 5px; }.capacity-card.overload { border-color: #efc7c9; }.capacity-card.overload .status-bar span { background: var(--red); }
.kanban-card.blocked { border-left-color: var(--red); background: #fffafa; }
.planning-backlog-item { display: grid; gap: 4px; padding: 11px; border: 1px solid var(--line); border-radius: 8px; }.planning-backlog-item span { font-size: 12px; }.planning-backlog-item small { color: var(--muted); }
.table-actions { display: flex; gap: 5px; white-space: nowrap; }.template-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfcfc; }.template-card h3 { margin: 10px 0 5px; font-size: 13px; }.template-card p { color: var(--muted); font-size: 12px; }.compact-stack { gap: 6px; }.kit-form { margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--line); }
.trace-panel, .productivity-panel { margin-top: 15px; }.trace-layout { display: grid; grid-template-columns: 1.4fr .7fr; gap: 24px; }.trace-layout form { padding-left: 18px; border-left: 1px solid var(--line); }
.improvement-board { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }.improvement-card { display: grid; align-content: start; gap: 10px; padding: 14px; border: 1px solid var(--line); border-top: 3px solid var(--cyan); border-radius: 9px; background: #fff; box-shadow: var(--shadow); }.improvement-card h2 { font-size: 15px; margin: 0; }.improvement-card p { font-size: 12px; color: var(--muted); margin: 0; min-height: 34px; }.improvement-card .btn { justify-self: start; }.improvement-meta { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; }.improvement-meta span { padding: 6px; border-radius: 6px; background: #f5f8f9; color: var(--muted); font-size: 9px; text-transform: uppercase; }.improvement-meta strong { display: block; color: var(--ink); font-size: 11px; text-transform: none; }
.mini-trend { width: 100px; height: 7px; overflow: hidden; border-radius: 99px; background: #e5ecee; }.mini-trend i { display: block; height: 100%; background: var(--cyan); }.metric-bad { color: var(--red); font-weight: 750; }.metric-good { color: var(--green); font-weight: 750; }.blocker-metrics { margin-top: 15px; }.blocker-metrics > div { display: grid; gap: 3px; padding: 12px; border-radius: 8px; background: #f6f9fa; }.blocker-metrics span { color: var(--muted); font-size: 11px; }.blocker-metrics strong { font-size: 17px; }
@media (min-width: 821px) {
  .grid.two > .panel:first-child .order-table th:nth-child(5),
  .grid.two > .panel:first-child .order-table td:nth-child(5),
  .grid.two > .panel:first-child .order-table th:nth-child(7),
  .grid.two > .panel:first-child .order-table td:nth-child(7),
  .grid.two > .panel:first-child .order-table th:nth-child(9),
  .grid.two > .panel:first-child .order-table td:nth-child(9),
  .grid.two > .panel:first-child .order-table th:nth-child(10),
  .grid.two > .panel:first-child .order-table td:nth-child(10),
  .grid.two > .panel:first-child .order-table th:nth-child(11),
  .grid.two > .panel:first-child .order-table td:nth-child(11) { display: none; }
}

@media (max-width: 820px) {
  .sidebar { box-shadow: 18px 0 50px rgba(8,29,37,.22); }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .center-map-layout { grid-template-columns: 1fr; }
  .map-detail { border-left: 0; border-top: 1px solid var(--line); padding: 15px 0 0; }
  .action-grid, .trace-layout { grid-template-columns: 1fr; }.trace-layout form { padding: 15px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .improvement-board { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 620px) {
  .order-table-wrap { overflow: visible; }
  .order-table, .order-table tbody, .order-table tr, .order-table td { display: block; width: 100%; }
  .order-table thead { display: none; }
  .order-table tbody { display: grid; gap: 10px; padding: 10px; }
  .order-table tr {
    position: relative; background: #fff; border: 1px solid var(--line);
    border-radius: 9px; padding: 11px 12px; box-shadow: 0 1px 2px rgba(16,37,45,.04); overflow: hidden;
  }
  .order-table td {
    border: 0 !important; padding: 4px 0 !important; display: grid;
    grid-template-columns: 92px minmax(0,1fr); gap: 8px;
    min-width: 0 !important; max-width: none !important;
  }
  .order-table td::before {
    content: attr(data-label); font-size: 10px; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted); font-weight: 700;
  }
  .order-table td:first-child {
    display: block; padding-bottom: 8px !important;
    border-bottom: 1px solid #edf1f2 !important; margin-bottom: 4px;
  }
  .order-table td:first-child::before, .order-table td:last-child::before { display: none; }
  .order-table td[data-label="Descripción"] { font-weight: 650; }
  .order-table td > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  .order-table td:last-child { display: block; position: absolute; right: 10px; top: 8px; width: auto; }
  .order-table .empty-row, .order-table .empty-row td { display: block; }
  .order-table .empty-row td::before { display: none; }
  .filters > * { flex: 1 1 calc(50% - 8px); min-width: 0 !important; }
  .filters > input:first-child { flex-basis: 100%; }
  .filter-count { flex-basis: 100%; margin-left: 0; }
  .ops-band { grid-template-columns: 1fr; }.compact-control { grid-template-columns: 1fr !important; }.planning-kpis { grid-template-columns: repeat(2,1fr) !important; }.improvement-board { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .main { overflow-x: clip; }
  .page-head .actions { grid-template-columns: 1fr; }
  .page-head .actions .btn { width: 100%; }
  .filters > * { flex-basis: 100%; }
  .order-table td { grid-template-columns: 84px minmax(0,1fr); }
  .order-table .badge { white-space: normal; width: max-content; max-width: 100%; }
  .center-map { min-height: 290px; }
  .map-legend { right: 8px; justify-content: center; }
}

@media (max-width: 520px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .global-search input:focus { width: min(160px,42vw); }
  .page-head .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .page-head .actions select { grid-column: 1/-1; width: 100%; }
}

@media print {
  body > #app { display: none !important; }
  .print-sheet { display: block !important; color: #15242b; font: 12px/1.45 Arial,sans-serif; padding: 12mm; }
  .print-sheet header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #123b4a; padding-bottom: 12px; }
  .print-sheet header div { display: grid; gap: 3px; }
  .print-sheet header span, .print-sheet section span, .print-sheet footer span { color: #64747c; font-size: 10px; text-transform: uppercase; }
  .print-sheet h1 { font-size: 24px; }
  .print-sheet h2 { font-size: 13px; margin: 18px 0 5px; }
  .print-facts { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; padding: 16px 0; }
  .print-facts div { display: grid; gap: 2px; }
  .print-two { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
  .print-sheet table { width: 100%; border-collapse: collapse; }
  .print-sheet th, .print-sheet td { text-align: left; padding: 6px; border-bottom: 1px solid #cfdade; }
  .print-sheet footer { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 30px; }
  .print-sheet footer div { min-height: 60px; border-top: 1px solid #97a9b0; padding-top: 6px; display: grid; align-content: start; }
  .order-table thead { display: table-header-group; }
  .order-table, .order-table tbody, .order-table tr, .order-table td { display: revert; }
  .order-table td::before { display: none; }
}
