/* analytics.css · Estilos para métricas de obreros */

#section-obreros.is-loading > :not(.obreros-loading-overlay) {
  pointer-events: none;
  opacity: 0.4;
  filter: blur(1.6px);
}

.obreros-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.obreros-loading-overlay[hidden] {
  display: none !important;
}

.obreros-loading-card {
  width: min(460px, 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.obreros-loading-spinner {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 3px solid rgba(59, 130, 246, 0.18);
  border-top-color: var(--primary);
  animation: obrerosSpin 0.8s linear infinite;
}

@keyframes obrerosSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.obreros-loading-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.obreros-loading-status {
  font-size: 12px;
  color: var(--muted);
}

.obreros-loading-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  overflow: hidden;
}

.obreros-loading-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--chart-blue));
  transition: width 0.18s ease;
}

.obreros-loading-progress-text {
  align-self: flex-end;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

body.theme-dark .obreros-loading-overlay {
  background: rgba(0, 0, 0, 0.5);
}

body.theme-dark .obreros-loading-card {
  box-shadow: none;
  background: var(--surface);
}

/* ===== KPIs Obreros (estilo mini-KPI con porcentajes) ===== */
.obreros-kpis-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 1200px) {
  .obreros-kpis-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .obreros-kpis-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .obreros-kpis-grid .obreros-kpi-card:nth-child(1),
  .obreros-kpis-grid .obreros-kpi-card:nth-child(2){
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .obreros-kpis-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .obreros-kpis-grid .obreros-kpi-card:nth-child(1),
  .obreros-kpis-grid .obreros-kpi-card:nth-child(2){
    grid-column: 1 / -1;
  }
}

.obreros-kpi-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  animation: fadeInUp 0.5s ease forwards;
  will-change: transform, opacity;
  transform: translateZ(0);
}

/* Colores de fondo para cada KPI */
.obreros-kpi-blue { background: #3B82F6; }
.obreros-kpi-indigo { background: #6366F1; }
.obreros-kpi-green { background: #10B981; }
.obreros-kpi-cyan { background: #06B6D4; }
.obreros-kpi-orange { background: #F59E0B; }
.obreros-kpi-red { background: #EF4444; }

/* Textos en blanco para cards con fondo de color */
.obreros-kpi-blue .obreros-kpi-label,
.obreros-kpi-blue .obreros-kpi-value,
.obreros-kpi-blue .obreros-kpi-percentage,
.obreros-kpi-blue .obreros-kpi-subtitle,
.obreros-kpi-indigo .obreros-kpi-label,
.obreros-kpi-indigo .obreros-kpi-value,
.obreros-kpi-indigo .obreros-kpi-percentage,
.obreros-kpi-indigo .obreros-kpi-subtitle,
.obreros-kpi-green .obreros-kpi-label,
.obreros-kpi-green .obreros-kpi-value,
.obreros-kpi-green .obreros-kpi-percentage,
.obreros-kpi-green .obreros-kpi-subtitle,
.obreros-kpi-cyan .obreros-kpi-label,
.obreros-kpi-cyan .obreros-kpi-value,
.obreros-kpi-cyan .obreros-kpi-percentage,
.obreros-kpi-cyan .obreros-kpi-subtitle,
.obreros-kpi-orange .obreros-kpi-label,
.obreros-kpi-orange .obreros-kpi-value,
.obreros-kpi-orange .obreros-kpi-percentage,
.obreros-kpi-orange .obreros-kpi-subtitle,
.obreros-kpi-red .obreros-kpi-label,
.obreros-kpi-red .obreros-kpi-value,
.obreros-kpi-red .obreros-kpi-percentage,
.obreros-kpi-red .obreros-kpi-subtitle {
  color: #FFFFFF;
}

.obreros-kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.obreros-kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.obreros-kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.obreros-kpi-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.obreros-kpi-percentage {
  font-size: 16px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

.obreros-kpi-subtitle {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
}

/* === Sistema de Tabs para Vistas === */
.table-view-tabs {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface-muted);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn i {
  font-size: 14px;
}

.tab-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.table-view {
  display: none;
}

.table-view.active {
  display: block;
}

@media (max-width: 768px) {
  .table-view-tabs {
    width: 100%;
    justify-content: stretch;
    margin-top:12px;
  }
  
  .tab-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
    font-size: 12px;
  }
  
  .tab-btn span {
    display: none;
  }
  
  .tab-btn i {
    margin: 0;
  }
}

/* ===== Gráficos ===== */
.analytics-charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 16px;
  margin-bottom: var(--space-2);
}

@media (max-width: 1024px) {
  .analytics-charts {
    grid-template-columns: 1fr;
  }

  .analytics-chart-card .chart[style*="width: 220px"]{
    width:180px !important;
    height:180px !important;
  }

  .analytics-chart-card [style*="gap: 32px"]{
    gap:8px !important;
  }
}

.analytics-chart-full {
  width: 100%;
  margin-bottom: var(--space-2);
}

.analytics-chart-full .analytics-chart {
  min-height: 380px;
}

/* Selector de fecha dentro del gráfico de tráfico */
.traffic-date-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
  justify-content: flex-end;
}

.traffic-date-selector .range-preset-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.traffic-date-selector .form-control {
  font-size: 13px;
  height: 36px;
  padding: 0 10px;
}

.preset-pill {
  padding: 6px 12px;
  border-radius: var(--radius-lg);
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-pill:hover {
  background: rgba(59,130,246,0.04);
  color: var(--primary);
}

.preset-pill.active {
  background: rgba(59,130,246,0.08);
  color: var(--primary);
}

.analytics-chart {
  width: 100%;
  height: 280px;
}

.analytics-chart-card {
  width: 100%;
  background: var(--panel);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 18px rgba(16,24,40,.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.analytics-chart-card .chart-head {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .02em;
  color: var(--text);
  flex-shrink: 0;
}

.analytics-chart-card .chart {
  width: 100%;
  height: 100%;
  min-height: 220px;
  flex-grow: 1;
  display: flex;
  align-items: flex-end;
  position: relative;
  padding: 12px;
}

/* KPI cards mantienen animación (no afecta gráficos) */
.obreros-kpi-card {
  animation-fill-mode: forwards;
}

@media (prefers-reduced-motion: reduce) {
  .obreros-kpi-card,
  .analytics-table-card {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* Escalonado de animaciones para KPIs de obreros */
.obreros-kpis-grid .obreros-kpi-card:nth-child(1) { animation-delay: 0.05s; }
.obreros-kpis-grid .obreros-kpi-card:nth-child(2) { animation-delay: 0.1s; }
.obreros-kpis-grid .obreros-kpi-card:nth-child(3) { animation-delay: 0.15s; }
.obreros-kpis-grid .obreros-kpi-card:nth-child(4) { animation-delay: 0.2s; }
.obreros-kpis-grid .obreros-kpi-card:nth-child(5) { animation-delay: 0.25s; }
.obreros-kpis-grid .obreros-kpi-card:nth-child(6) { animation-delay: 0.3s; }

/* Animación sutil */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Tabla de obreros ===== */
.analytics-table-wrapper {
  overflow: auto;
  border-radius: var(--radius);
  border: none;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: var(--surface-muted);
}

.analytics-table th,
.analytics-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}

.analytics-table th {
  background: var(--primary-soft);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.6px;
  color: var(--primary);
}

.analytics-table tbody tr:hover {
  background: var(--surface-muted);
}

.analytics-empty {
  text-align: center;
  padding: 32px 16px;
  font-size: 14px;
  color: var(--muted);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .obreros-kpis-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .analytics-charts {
    grid-template-columns: 1fr;
  }

  .traffic-date-selector {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-left: 0;
    width: 100%;
  }

  .analytics-chart-full .analytics-chart-card header {
    flex-direction: column !important;
    align-items: flex-start !important;
    flex-wrap: wrap !important;
    gap: 12px;
  }

  .analytics-chart-full .analytics-chart-card header .traffic-date-selector {
    width: 100%;
  }

  .traffic-date-selector .range-preset-pills {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
  }

  .traffic-date-selector .form-control {
    width: 100%;
  }

  .analytics-chart {
    height: 240px;
  }

  .analytics-table {
    min-width: 100%;
  }
}

@media (max-width: 480px) {
  .obreros-kpis-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .obreros-loading-overlay {
    padding: 12px;
  }
}

/* Ajustes responsive específicos para la sección Métricas de obreros */
#section-obreros .control-group,
#section-obreros .table-view-tabs,
#section-obreros .chart-head,
#section-obreros .obreros-status-chart-layout {
  min-width: 0;
}

#section-obreros .obreros-status-chart-layout {
  width: 100%;
}

#section-obreros #obreros-filter-selected-range-text {
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

@media (max-width: 900px) {
  #section-obreros .obreros-detail-card .card-header {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
  }

  #section-obreros .obreros-detail-heading,
  #section-obreros .table-view-tabs {
    width: 100%;
  }

  #section-obreros .obreros-status-chart-layout {
    flex-direction: column;
    align-items: stretch;
    gap: 12px !important;
  }

  #section-obreros #obrerosStatusLegend {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
  }

  #section-obreros #obreros-analytics-status-chart {
    width: min(220px, 100%) !important;
    height: 220px !important;
    margin: 0 auto;
  }
}

@media (max-width: 768px) {
  #section-obreros .analytics-control-bar {
    padding: 12px;
  }

  #section-obreros .control-row {
    gap: 10px;
  }

  #section-obreros .date-range-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 4px;
  }

  #section-obreros .date-range-group .date-btn {
    justify-content: center;
    min-width: 0;
    padding: 8px 10px;
    font-size: 12px;
  }

  #section-obreros #obreros-filter-calendar-btn {
    grid-column: 1 / -1;
  }

  #section-obreros .obreros-kpis-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #section-obreros .obreros-kpi-card {
    padding: 14px;
  }

  #section-obreros .obreros-kpi-header {
    align-items: flex-start;
    gap: 8px;
  }

  #section-obreros .obreros-kpi-label,
  #section-obreros .obreros-kpi-subtitle {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.2;
  }

  #section-obreros .obreros-kpi-value {
    font-size: 24px;
    line-height: 1;
  }

  #section-obreros .obreros-kpi-footer {
    flex-wrap: wrap;
    gap: 4px 10px;
  }

  #section-obreros .obreros-traffic-head {
    display: flex !important;
    flex-wrap: wrap;
    align-items: flex-start !important;
    gap: 8px;
  }

  #section-obreros .obreros-traffic-head > span:first-child {
    flex-basis: 100%;
  }

  #section-obreros #obrerosChartLegendInline {
    width: 100%;
    margin: 0;
    gap: 6px 10px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  #section-obreros #obrerosChartLegendInline .legend-item {
    padding: 3px 6px;
  }

  #section-obreros #obrerosChartLegendInline .legend-label {
    font-size: 11px;
  }

  #section-obreros .table-view-tabs .tab-btn {
    min-width: 0;
    white-space: nowrap;
  }

  #section-obreros .chart {
    min-height: 210px;
  }
}

@media (max-width: 560px) {
  #section-obreros #obreros-filter-selected-range-text {
    max-width: 120px;
  }

  #section-obreros #obrerosStatusLegend {
    max-width: 100%;
  }

  #section-obreros #obrerosStatusLegend > div {
    font-size: 12px;
  }

  #section-obreros #obreros-analytics-status-chart {
    width: min(190px, 100%) !important;
    height: 190px !important;
  }
}

@media (max-width: 768px) {
  #section-obreros .control-label {
    white-space: normal;
    line-height: 1.2;
  }

  #section-obreros .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #section-obreros .table-wrapper > .table {
    width: max-content;
    min-width: 920px;
    table-layout: auto;
  }

  #section-obreros #obreros-activity-table {
    min-width: 860px;
  }

  #section-obreros .table th,
  #section-obreros .table td {
    font-size: 12px;
    line-height: 1.25;
    white-space: nowrap;
  }

  #section-obreros .table th {
    padding: 10px 8px;
  }

  #section-obreros .table td {
    padding: 10px 8px;
  }

  #section-obreros .table-view-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #section-obreros .table-view-tabs .tab-btn {
    min-width: 0;
    justify-content: center;
    gap: 4px;
    padding: 9px 8px;
    white-space: nowrap;
  }

  #section-obreros .table-view-tabs .tab-btn span {
    display: inline;
    font-size: 11px;
    line-height: 1.1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #section-obreros .table-view-tabs .tab-btn i {
    font-size: 12px;
    margin: 0;
  }

  #section-obreros .pagination-container {
    padding: 10px 8px;
    gap: 8px;
  }

  #section-obreros .pagination-controls {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  #section-obreros .pagination-page-btn,
  #section-obreros .pagination-btn {
    min-width: 34px;
    height: 34px;
    flex: 0 0 auto;
  }
}

@media (max-width: 420px) {
  #section-obreros .date-range-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #section-obreros #obreros-filter-calendar-btn {
    grid-column: 1 / -1;
  }

  #section-obreros .table-wrapper > .table {
    min-width: 980px;
  }

  #section-obreros #obreros-activity-table {
    min-width: 900px;
  }
}

/* Mobile-first hardening para Métricas de obreros */
@media (max-width: 768px) {
  #section-obreros .analytics-control-bar {
    padding: 12px !important;
  }

  #section-obreros .control-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    align-items: stretch !important;
  }

  #section-obreros .control-group {
    min-width: 0 !important;
  }

  #section-obreros .control-group .form-select,
  #section-obreros .control-group .form-control {
    width: 100%;
    min-height: 40px;
    font-size: 14px;
  }

  #section-obreros .date-range-group {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
  }

  #section-obreros .date-range-group .date-btn {
    min-width: 0 !important;
    justify-content: center !important;
    padding: 8px 10px !important;
    font-size: 12px !important;
    border: 1px solid var(--border);
    background: var(--surface-muted);
  }

  #section-obreros #obreros-filter-calendar-btn {
    grid-column: 1 / -1;
  }

  #section-obreros .obreros-kpis-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  #section-obreros .obreros-kpi-card {
    min-height: 0;
    padding: 14px !important;
  }

  #section-obreros .analytics-charts {
    grid-template-columns: 1fr !important;
  }

  #section-obreros .table-wrapper {
    overflow: visible !important;
  }

  #section-obreros .table-wrapper > .table,
  #section-obreros #obreros-activity-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
    border-collapse: separate;
    border-spacing: 0;
  }

  #section-obreros .table thead {
    display: none;
  }

  #section-obreros .table tbody {
    display: block;
    width: 100%;
  }

  #section-obreros .table tbody tr {
    display: block;
    width: calc(100% - 12px);
    margin: 8px 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
  }

  #section-obreros .table tbody td {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 12px !important;
    white-space: normal !important;
    line-height: 1.3;
    font-size: 13px !important;
    border-bottom: 1px dashed var(--border);
  }

  #section-obreros .table tbody td:last-child {
    border-bottom: none;
  }

  #section-obreros .table tbody td::before {
    content: '';
    flex: 0 0 86px;
    max-width: 86px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
  }

  #section-obreros #obreros-view-tabla .table tbody td:nth-child(1)::before { content: 'DNI'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(2)::before { content: 'Nombre'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(3)::before { content: 'Country'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(4)::before { content: 'Lote'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(5)::before { content: 'Patente'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(6)::before { content: 'Cédula'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(7)::before { content: 'Seguro'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(8)::before { content: 'VTV'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(9)::before { content: 'Estado'; }

  #section-obreros #obreros-view-actividad .table tbody td:nth-child(1)::before { content: 'Hora'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(2)::before { content: 'DNI'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(3)::before { content: 'Nombre'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(4)::before { content: 'Lote'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(5)::before { content: 'Country'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(6)::before { content: 'Estado'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(7)::before { content: 'Egreso'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(8)::before { content: 'Duración'; }

  #section-obreros .table tbody tr td[colspan] {
    display: block;
    text-align: center;
    padding: 16px 10px !important;
    border-bottom: none;
  }

  #section-obreros .table tbody tr td[colspan]::before {
    display: none !important;
    content: none !important;
  }

  #section-obreros .table-view-tabs {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  #section-obreros .table-view-tabs .tab-btn {
    min-width: 0 !important;
    width: 100%;
    justify-content: center !important;
    gap: 4px;
    padding: 9px 8px !important;
  }

  #section-obreros .table-view-tabs .tab-btn span {
    display: inline !important;
    font-size: 11px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #section-obreros .pagination-container {
    padding: 10px 8px !important;
  }

  #section-obreros .pagination-info {
    width: 100%;
    font-size: 12px;
  }

  #section-obreros .pagination-controls {
    width: 100%;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
  }

  #section-obreros .pagination-btn,
  #section-obreros .pagination-page-btn {
    flex: 0 0 auto;
    min-width: 34px;
    height: 34px;
  }
}

@media (max-width: 420px) {
  #section-obreros .table tbody td {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  #section-obreros .table tbody td::before {
    flex-basis: 76px;
    max-width: 76px;
    font-size: 10px;
  }
}

/* Restaurar tablas en formato lista (sin cards) para Base de datos y Actividad */
@media (max-width: 1024px) {
  #section-obreros .table-wrapper {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
  }

  #section-obreros .table-wrapper > .table,
  #section-obreros #obreros-activity-table {
    width: max-content !important;
    min-width: 920px !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
  }

  #section-obreros #obreros-activity-table {
    min-width: 860px !important;
  }

  #section-obreros .table thead {
    display: table-header-group !important;
  }

  #section-obreros .table tbody {
    display: table-row-group !important;
    width: auto !important;
  }

  #section-obreros .table tbody tr {
    display: table-row !important;
    width: auto !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    overflow: visible !important;
    box-shadow: none !important;
    position: static !important;
    cursor: default !important;
  }

  #section-obreros .table tbody td {
    display: table-cell !important;
    width: auto !important;
    padding: 10px 8px !important;
    white-space: nowrap !important;
    word-break: normal !important;
    line-height: 1.25 !important;
    font-size: 12px !important;
    border-bottom: 1px solid var(--border) !important;
  }

  #section-obreros .table tbody td::before {
    display: none !important;
    content: none !important;
  }

  #section-obreros .table tbody tr td[colspan] {
    display: table-cell !important;
    text-align: center;
    padding: 16px 10px !important;
  }
}

/* Acordeón en mobile para Base de datos de obreros */
@media (max-width: 1024px) {
  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible {
    position: relative;
    cursor: pointer;
  }

  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 20px;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    pointer-events: none;
  }

  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible.is-expanded::after {
    transform: rotate(-135deg);
  }

  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible td {
    display: none !important;
  }

  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible td:nth-child(2) {
    display: flex !important;
    padding-right: 36px !important;
    border-bottom: none;
    font-weight: 600;
  }

  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible td:nth-child(2)::before {
    display: none !important;
  }

  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible.is-expanded td {
    display: flex !important;
  }

  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible.is-expanded td:nth-child(2) {
    border-bottom: 1px dashed var(--border);
    font-weight: 500;
  }

  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible.is-expanded td:nth-child(2)::before {
    display: block !important;
  }
}

/* Mobile-first final para Métricas de obreros (evita layout roto entre 320-1024px) */
@media (max-width: 1024px) {
  #section-obreros .analytics-control-bar {
    padding: 12px !important;
  }

  #section-obreros .control-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    align-items: stretch !important;
  }

  #section-obreros .control-group {
    width: 100% !important;
    min-width: 0 !important;
  }

  #section-obreros .control-label {
    white-space: normal !important;
    line-height: 1.2;
  }

  #section-obreros .search-field-container {
    width: 100% !important;
  }

  #section-obreros .date-range-group {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    width: 100% !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
  }

  #section-obreros .date-range-group .date-btn {
    min-width: 0 !important;
    width: 100%;
    justify-content: center !important;
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  #section-obreros #obreros-filter-calendar-btn {
    grid-column: 1 / -1;
  }

  #section-obreros .obreros-kpis-grid,
  #section-obreros .analytics-charts {
    grid-template-columns: 1fr !important;
  }

  #section-obreros .chart {
    min-height: 220px;
  }

  #section-obreros .obreros-status-chart-layout {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  #section-obreros #obrerosStatusLegend {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
  }

  #section-obreros #obreros-analytics-status-chart {
    width: min(220px, 100%) !important;
    height: 220px !important;
    margin: 0 auto;
  }

  #section-obreros .obreros-detail-card .card-header {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
  }

  #section-obreros .obreros-detail-heading,
  #section-obreros .table-view-tabs {
    width: 100%;
    min-width: 0;
  }

  #section-obreros .table-view-tabs {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #section-obreros .table-view-tabs .tab-btn {
    width: 100%;
    min-width: 0 !important;
    justify-content: center !important;
    gap: 4px;
    padding: 9px 8px !important;
  }

  #section-obreros .table-view-tabs .tab-btn span {
    display: inline !important;
    font-size: 11px !important;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #section-obreros .table-wrapper {
    overflow: visible !important;
  }

  #section-obreros .table-wrapper > .table,
  #section-obreros #obreros-activity-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
    border-collapse: separate;
    border-spacing: 0;
  }

  #section-obreros .table thead {
    display: none !important;
  }

  #section-obreros .table tbody {
    display: block;
    width: 100%;
  }

  #section-obreros .table tbody tr {
    display: block;
    width: 100%;
    margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
  }

  #section-obreros .table tbody td {
    display: flex !important;
    width: 100%;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 12px !important;
    white-space: normal !important;
    word-break: break-word;
    line-height: 1.3;
    font-size: 13px !important;
    border-bottom: 1px dashed var(--border);
  }

  #section-obreros .table tbody td:last-child {
    border-bottom: none;
  }

  #section-obreros .table tbody td::before {
    content: '';
    flex: 0 0 90px;
    max-width: 90px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
  }

  #section-obreros #obreros-view-tabla .table tbody td:nth-child(1)::before { content: 'DNI'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(2)::before { content: 'Nombre'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(3)::before { content: 'Country'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(4)::before { content: 'Lote'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(5)::before { content: 'Patente'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(6)::before { content: 'Cédula'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(7)::before { content: 'Seguro'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(8)::before { content: 'VTV'; }
  #section-obreros #obreros-view-tabla .table tbody td:nth-child(9)::before { content: 'Estado'; }

  #section-obreros #obreros-view-actividad .table tbody td:nth-child(1)::before { content: 'Hora'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(2)::before { content: 'DNI'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(3)::before { content: 'Nombre'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(4)::before { content: 'Lote'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(5)::before { content: 'Country'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(6)::before { content: 'Estado'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(7)::before { content: 'Egreso'; }
  #section-obreros #obreros-view-actividad .table tbody td:nth-child(8)::before { content: 'Duración'; }

  #section-obreros .table tbody tr td[colspan] {
    display: block !important;
    text-align: center;
    padding: 16px 10px !important;
    border-bottom: none;
  }

  #section-obreros .table tbody tr td[colspan]::before {
    display: none !important;
    content: none !important;
  }

  #section-obreros .pagination-container {
    padding: 10px 8px !important;
  }

  #section-obreros .pagination-info {
    width: 100%;
    font-size: 12px;
  }

  #section-obreros .pagination-controls {
    width: 100%;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
  }

  #section-obreros .pagination-btn,
  #section-obreros .pagination-page-btn {
    flex: 0 0 auto;
    min-width: 34px;
    height: 34px;
  }
}

@media (max-width: 420px) {
  #section-obreros .table tbody td {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  #section-obreros .table tbody td::before {
    flex-basis: 76px;
    max-width: 76px;
    font-size: 10px;
  }
}

/* FORZAR LISTA EN TABLAS DE OBREROS (Base de datos + Actividad) */
@media (max-width: 1024px) {
  #section-obreros .table-wrapper {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
  }

  #section-obreros .table-wrapper > .table,
  #section-obreros #obreros-activity-table {
    width: max-content !important;
    min-width: 920px !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
  }

  #section-obreros #obreros-activity-table {
    min-width: 860px !important;
  }

  #section-obreros .table thead {
    display: table-header-group !important;
  }

  #section-obreros .table tbody {
    display: table-row-group !important;
    width: auto !important;
  }

  #section-obreros .table tbody tr {
    display: table-row !important;
    width: auto !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    overflow: visible !important;
    box-shadow: none !important;
    position: static !important;
    cursor: default !important;
  }

  #section-obreros .table tbody td,
  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible td,
  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible.is-expanded td {
    display: table-cell !important;
    width: auto !important;
    padding: 10px 8px !important;
    white-space: nowrap !important;
    word-break: normal !important;
    line-height: 1.25 !important;
    font-size: 12px !important;
    border-bottom: 1px solid var(--border) !important;
    font-weight: inherit !important;
  }

  #section-obreros .table tbody td::before,
  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible td::before,
  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible.is-expanded td::before {
    display: none !important;
    content: none !important;
  }

  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible::after,
  #section-obreros #obreros-view-tabla .table tbody tr.obreros-row-collapsible.is-expanded::after {
    display: none !important;
    content: none !important;
  }

  #section-obreros .table tbody tr td[colspan] {
    display: table-cell !important;
    text-align: center;
    padding: 16px 10px !important;
  }
}
