/* Operaciones: obras/trabajos, gastos, partes, proveedores, informes y módulos por oficio. */

/* Campos que app.css no cubre */
input[type=number], input[type=date], input[type=month], input[type=week], input[type=time], input[type=datetime-local] {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  font: inherit; font-size: 16px; color: var(--gray-900); background: #fff;
}
@media (min-width: 768px) {
  input[type=number], input[type=date], input[type=month], input[type=week], input[type=time], input[type=datetime-local] { font-size: 14px; }
}
input[type=file] { font: inherit; max-width: 100%; }
.ops-input-auto { width: auto; max-width: 100%; }
.has-error textarea { border-color: var(--danger); }

/* Barras de avance */
.ops-progress { flex: 1; height: 8px; background: var(--gray-100); border-radius: var(--radius-full); overflow: hidden; min-width: 60px; }
.ops-progress span { display: block; height: 100%; background: var(--orange-500); border-radius: var(--radius-full); transition: width .25s ease; }
.ops-progress--lg { height: 12px; }
.ops-progress-row { display: flex; align-items: center; gap: 10px; }
.ops-progress-row .num { min-width: 40px; text-align: right; }

.ops-count { display: inline-flex; min-width: 20px; height: 18px; padding: 0 6px; margin-left: 4px; border-radius: var(--radius-full); background: rgba(16,24,40,.08); font-size: 11px; align-items: center; justify-content: center; }
.ops-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.ops-scroll::-webkit-scrollbar { display: none; }
.ops-scroll a { white-space: nowrap; }

/* Cabecera de la ficha y pestañas */
.ops-job-head { display: flex; gap: 24px; align-items: center; margin-bottom: 16px; }
.ops-job-head__main { flex: 1; min-width: 0; }
.ops-job-head__progress { width: min(320px, 40%); display: grid; gap: 6px; }
.ops-tabs { margin-bottom: 16px; }
.ops-tabs a { display: inline-flex; align-items: center; gap: 6px; }

/* Rango (avance) */
.ops-range { width: 100%; height: 40px; accent-color: var(--orange-500); }

/* Selector de equipo */
.ops-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ops-chip { cursor: pointer; }
.ops-chip input { position: absolute; opacity: 0; pointer-events: none; }
.ops-chip > span { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--gray-300); border-radius: var(--radius-full); font-weight: 500; }
.ops-chip input:checked + span { border-color: var(--orange-500); background: var(--orange-50); color: var(--orange-600); }
.ops-chip input:focus-visible + span { outline: 2px solid var(--orange-500); outline-offset: 2px; }

/* Selector de cliente */
.ops-picker { position: relative; }
.ops-picker > .icon { position: absolute; left: 12px; top: 20px; transform: translateY(-50%); color: var(--gray-500); pointer-events: none; }
.ops-picker input[type=search] { padding-left: 38px; }
.ops-picker__menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; background: #fff;
  border-radius: var(--radius-md); box-shadow: var(--shadow-elevated); border: 1px solid var(--gray-100);
  max-height: 280px; overflow-y: auto; padding: 4px;
}
.ops-picker__menu button {
  display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; cursor: pointer;
  padding: 8px 10px; border-radius: var(--radius-sm);
}
.ops-picker__menu button:hover, .ops-picker__menu button.is-active { background: var(--gray-50); }
.ops-picker__menu small { display: block; color: var(--gray-500); }
.ops-picker__empty { padding: 10px; color: var(--gray-500); }

/* Listas móviles sin enlace (con botón de borrar) */
.cards-list .ops-card-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--gray-100); }
.ops-card-item__main { flex: 1; min-width: 0; }
.ops-icon-btn { width: 36px; height: 36px; color: var(--gray-500); }
.ops-icon-btn:hover { color: var(--danger); border-color: var(--danger-50); }

/* Miniaturas de tickets */
.ops-thumb { width: 40px; height: 40px; border-radius: var(--radius-sm); overflow: hidden; display: inline-flex; align-items: center; justify-content: center; background: var(--gray-100); color: var(--gray-500); flex: none; }
.ops-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ops-thumb--none { color: var(--gray-300); }
.cards-list a.ops-thumb { padding: 0; border: 0; display: inline-flex; }

/* Zona de foto del ticket */
.ops-photo-drop { position: relative; display: flex; align-items: center; justify-content: center; min-height: 120px; border: 2px dashed var(--gray-300); border-radius: var(--radius-md); cursor: pointer; overflow: hidden; background: var(--gray-50); font-weight: 400 !important; }
.ops-photo-drop:hover { border-color: var(--orange-500); }
.ops-photo-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ops-photo-drop__empty { display: flex; align-items: center; gap: 12px; padding: 16px; color: var(--navy-900); }
.ops-photo-drop__empty .icon { color: var(--orange-500); }
.ops-photo-drop img { max-height: 220px; max-width: 100%; display: block; }
.ops-photo-drop.has-file .ops-photo-drop__empty { display: none; }

/* Fotos */
.ops-upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ops-upload > .muted { flex: 1; min-width: 200px; }
.ops-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.ops-gallery a { display: block; aspect-ratio: 1; border-radius: var(--radius-md); overflow: hidden; background: var(--gray-100); box-shadow: var(--shadow-card); }
.ops-gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease; }
.ops-gallery a:hover img { transform: scale(1.03); }
.ops-gallery__doc { display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; text-align: center; color: var(--navy-900); font-size: 12px; background: #fff !important; }

/* Visor de fotos */
.ops-lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(11,31,58,.92); display: flex; align-items: center; justify-content: center; }
.ops-lightbox img { max-width: calc(100vw - 32px); max-height: calc(100dvh - 120px); border-radius: var(--radius-md); box-shadow: var(--shadow-elevated); }
.ops-lightbox__caption { position: absolute; bottom: 20px; left: 16px; right: 16px; text-align: center; color: #fff; font-size: 13px; }
.ops-lightbox button { position: absolute; width: 48px; height: 48px; border-radius: var(--radius-full); border: 0; background: rgba(255,255,255,.14); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ops-lightbox button:hover { background: rgba(255,255,255,.28); }
.ops-lightbox [data-lb-close] { top: 16px; right: 16px; }
.ops-lightbox [data-lb-prev] { left: 16px; top: 50%; transform: translateY(-50%); }
.ops-lightbox [data-lb-next] { right: 16px; top: 50%; transform: translateY(-50%); }

/* Barras horizontales (rentabilidad) */
.ops-hbars { display: grid; gap: 14px; }
.ops-hbar { display: grid; grid-template-columns: 200px minmax(0, 1fr) 120px; gap: 12px; align-items: center; }
.ops-hbar__label { font-weight: 600; color: var(--navy-900); line-height: 1.3; }
.ops-hbar__label small { display: block; font-weight: 400; font-size: 12px; }
.ops-hbar__track { height: 14px; background: var(--gray-100); border-radius: 0 4px 4px 0; overflow: hidden; }
.ops-bar { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.ops-bar--budget { background: #2563EB; }
.ops-bar--plan { background: #93B4F5; }
.ops-bar--real { background: #FF6B1A; }
.ops-bar--over { background: var(--danger); }
.ops-bar--ok { background: #0F9D8A; }
.ops-hbar__value { text-align: right; }

/* Navegación por meses / semanas */
.ops-month-nav { display: inline-flex; align-items: center; gap: 8px; }
.ops-month-nav strong { color: var(--navy-900); min-width: 120px; text-align: center; }

/* Semana de partes */
.ops-table-scroll { overflow-x: auto; }
.ops-week th.is-today, .ops-week td.is-today { background: var(--orange-50); }

/* Tarjeta con acciones de estado */
.ops-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ops-actions form { display: contents; }

@media (max-width: 767px) {
  .ops-job-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .ops-job-head__progress { width: 100%; }
  .ops-hbar { grid-template-columns: minmax(0, 1fr) auto; }
  .ops-hbar__track { grid-column: 1 / -1; grid-row: 2; }
  .ops-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .ops-toolbar-grow { width: 100%; }
  .toolbar .ops-input-auto { flex: 1 1 140px; }
}

@media print {
  body:has(.ops-printable) .sidebar, body:has(.ops-printable) .topbar, body:has(.ops-printable) .bottom-nav,
  body:has(.ops-printable) .alert, .ops-no-print { display: none !important; }
  body:has(.ops-printable) .main { overflow: visible; padding: 0; }
  body:has(.ops-printable) .shell { height: auto; display: block; }
  body:has(.ops-printable) .card { box-shadow: none; border: 1px solid var(--gray-300); break-inside: avoid; }
  body:has(.ops-printable) { background: #fff; }
  body:has(.ops-printable) > :not(.shell) { display: none !important; }
}

/* Líneas de pedido */
.ops-lines { display: grid; gap: 8px; }
.ops-line { display: grid; grid-template-columns: minmax(0, 1fr) 90px 90px 110px 100px 36px; gap: 8px; align-items: center; }
.ops-line__sub { text-align: right; }
.ops-status-form--row { display: inline-flex !important; align-items: center; gap: 10px; }
.ops-check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
@media (max-width: 767px) {
  .ops-line { grid-template-columns: 1fr 1fr 1fr 36px; padding-bottom: 8px; border-bottom: 1px solid var(--gray-100); }
  .ops-line__desc { grid-column: 1 / -1; }
  .ops-line__sub { display: none; }
}

/* Informes */
.ops-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--gray-500); }
.ops-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ops-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ops-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.ops-chart__grid { stroke: var(--gray-100); stroke-width: 1; }
.ops-chart__grid.is-base { stroke: var(--gray-300); }
.ops-chart__axis { font-size: 12px; fill: var(--gray-500); font-variant-numeric: tabular-nums; }
.ops-chart__hit { fill: transparent; }
.ops-chart__group:hover .ops-chart__hit { fill: var(--gray-50); }
.ops-total-row td { font-weight: 700; color: var(--navy-900); background: var(--gray-50); }
.ops-funnel { display: grid; gap: 10px; }
.ops-funnel__row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 40px 56px; gap: 10px; align-items: center; }
.ops-funnel__label { font-weight: 500; }
.ops-funnel__track { height: 12px; background: var(--gray-100); border-radius: 0 4px 4px 0; overflow: hidden; }
.ops-funnel__track span { display: block; height: 100%; background: #2563EB; border-radius: 0 4px 4px 0; min-width: 2px; }
.ops-funnel__row .num { text-align: right; }
.ops-mini-kpis { gap: 16px; }
.ops-export { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.ops-export .field { min-width: 180px; }
@media (max-width: 767px) {
  .ops-funnel__row { grid-template-columns: minmax(0, 1fr) 40px 56px; }
  .ops-funnel__track { grid-column: 1 / -1; grid-row: 2; }
  .ops-chart { overflow-x: auto; }
  .ops-chart svg { min-width: 560px; }
}

/* Carpintería */
.ops-carp { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.ops-carp__dims { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ops-cut-boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 20px; }
.ops-cut { margin: 0; }
.ops-cut figcaption { margin-bottom: 8px; }
.ops-cut svg { width: 100%; height: auto; display: block; font-family: Inter, system-ui, sans-serif; }
.ops-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--navy-700); margin-right: 8px; vertical-align: -1px; flex: none; }
.table tr.is-selected td { background: var(--orange-50); }
@media (max-width: 1023px) {
  .ops-carp { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .ops-carp__dims { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ops-cut-boards { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .ops-cut-boards { grid-template-columns: 1fr 1fr; }
  .ops-cut { break-inside: avoid; }
}

/* Mantenimientos y documentación */
.ops-btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.table tr.ops-row-due td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.table tr.ops-row-due td { background: #FFFBF3; }
.ops-next-visit { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; max-width: 960px; }
a.card.kpi:hover { box-shadow: var(--shadow-elevated); }
.ops-form-stack { grid-template-columns: minmax(0, 1fr); }
.ops-form-stack .span-2 { grid-column: auto; }

/* Importar */
.ops-cols { display: flex; flex-wrap: wrap; gap: 6px; }
.ops-pre { background: var(--gray-50); border-radius: var(--radius-sm); padding: 12px; font-size: 12px; overflow-x: auto; margin: 8px 0 0; }
.ops-err { color: var(--danger); }
.table tr.ops-row-error td { background: #FFF8F8; }
.table td.num { white-space: nowrap; }
