/* =========================================================
 🌄 SISTEMA CHAKANA ECUADOR – estilos.css (versión organizada)
==========================================================*/

/* =========================================================
1️⃣ VARIABLES DE COLOR (PALETA SEMÁNTICA)
==========================================================*/
:root {
  --brand: #2c2c2c;
  --primary: #2c2c2c;
  --primary-hover: #000000;

  --success: #2e7d32;
  --success-hover: #1b5e20;

  --danger: #c62828;
  --danger-hover: #8e0000;

  --warning: #f9a825;
  --warning-hover: #f57f17;
  --warning-text: #1f1f1f;

  --info: #1565c0;
  --info-hover: #0d47a1;

  --muted: #666;
  --bg: #f5f5f5;
}

/* =========================================================
2️⃣ BASE Y ESTRUCTURA GENERAL
==========================================================*/
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
  padding: 12px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  border: 1px solid #e0e0e0;
}

/* ======= Encabezado ======= */
.header {
  background: #2c2c2c;
  color: white;
  padding: 20px 24px;
  text-align: center;
  border-bottom: 3px solid #000;
}

.header h1 {
  font-size: 2em;
  margin-bottom: 6px;
  font-weight: 600;
}

.header p {
  font-size: 1em;
  opacity: 0.9;
  font-weight: 300;
}

/* =========================================================
3️⃣ NAVEGACIÓN POR TABS
==========================================================*/
.tabs {
  display: flex;
  gap: 0;
  background: #fafafa;
  border-bottom: 2px solid #e0e0e0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.tabs::-webkit-scrollbar {
  height: 6px;
}

.tabs::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 6px;
}

.tab {
  flex: 0 0 auto;
  min-width: 140px;
  padding: 12px 14px;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  font-weight: 600;
  border: none;
  background: transparent;
  font-size: 14px;
  color: #666;
  white-space: nowrap;
}

.tab:hover {
  background: #f0f0f0;
  color: #2c2c2c;
}

.tab.active {
  background: #fff;
  color: #000;
  border-bottom: 3px solid var(--brand);
}

.content {
  padding: 20px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* =========================================================
4️⃣ FORMULARIOS Y CAMPOS
==========================================================*/
.form-group {
  margin-bottom: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #2c2c2c;
  font-size: 13px;
}

/* Campo de cédula destacado */
#cedula {
  border: 2px solid #007bff;
  background-color: #f8f9ff;
}

#cedula:focus {
  background-color: #eef3ff;
  outline: none;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #d0d0d0;
  border-radius: 5px;
  font-size: 13px;
  transition: all 0.3s;
  background: white;
}

/* Visual en mayúsculas (solo texto) - Aplicar solo a formularios de datos */
.container input[type="text"]:not(.login-input):not(.registro-input),
.container textarea:not(.login-input):not(.registro-input),
.formulario-datos input[type="text"],
.formulario-datos textarea {
  text-transform: uppercase;
}

/* Excepciones en formularios de datos (campos específicos que no deben estar en mayúsculas) */
input#email:not(.login-input):not(.registro-input),
input#whatsapp,
input#telefono,
input#cedula {
  text-transform: none;
}

/* Excepciones para formularios de autenticación (login y registro) */
#loginForm input,
#registroForm input,
.login-container input,
.login-container textarea,
.login-input,
.registro-input {
  text-transform: none !important;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #2c2c2c;
  box-shadow: 0 0 0 3px rgba(44, 44, 44, 0.1);
}

textarea {
  resize: vertical;
  min-height: 70px;
}

.section-title {
  background: #2c2c2c;
  color: white;
  padding: 12px 20px;
  margin: 20px -20px 16px -20px;
  font-size: 1.15em;
  font-weight: 600;
}

/* =========================================================
5️⃣ BOTONES (SEMÁNTICOS Y COMPACTOS)
==========================================================*/
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
  margin-right: 6px;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn:focus-visible {
  outline: 3px solid rgba(0, 0, 0, 0.15);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: var(--success-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-warning {
  background: var(--warning);
  color: var(--warning-text);
}

.btn-warning:hover {
  background: var(--warning-hover);
}

.btn-info {
  background: var(--info);
  color: #fff;
}

.btn-info:hover {
  background: var(--info-hover);
}

.btn-secondary {
  background-color: #e5e5e5;
}

.btn-secondary:hover {
  background-color: #c9c9c9;
}

/* Botón mini más compacto */
.btn-mini {
  font-size: 11px !important;
  padding: 5px 8px !important;
  border-radius: 4px !important;
  line-height: 1.2 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-mini svg {
  width: 13px !important;
  height: 13px !important;
  vertical-align: middle;
}

.btn-del-row {
  background: #c62828;
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-del-row svg {
  width: 14px;
  height: 14px;
}

/* Botones compactos para listas de contratos */
.contract-card .btn,
.contract-list .btn {
  padding: 6px 12px;
  font-size: 12px;
  margin-right: 4px;
  margin-top: 4px;
}

.contract-card .btn svg,
.contract-list .btn svg {
  width: 14px;
  height: 14px;
}

/* =========================================================
6️⃣ TABLAS, LISTAS Y TARJETAS
==========================================================*/
.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.search-box input {
  flex: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
}

table th,
table td {
  padding: 9px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
  font-size: 13px;
}

table th {
  background: #fafafa;
  font-weight: 600;
  color: #2c2c2c;
}

table tr:hover {
  background: #f9f9f9;
}

.item-row {
  display: grid;
  grid-template-columns: 80px 2fr 120px 120px auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

/* Responsive para item-row */
@media (max-width: 768px) {
  .item-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .item-row > div {
    width: 100%;
  }
  
  .item-row label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
  }
}

/* Totales */
.total-section {
  background: #fafafa;
  padding: 14px 16px;
  border-radius: 6px;
  margin-top: 16px;
  border: 1px solid #e0e0e0;
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 1em;
  color: #2c2c2c;
}

.total-row.final {
  font-weight: 700;
  font-size: 1.2em;
  color: #000;
  border-top: 2px solid #2c2c2c;
  margin-top: 8px;
  padding-top: 12px;
}

/* Contratos - Más compacto */
.contract-list {
  max-height: 600px;
  overflow-y: auto;
}

.contract-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 10px;
  transition: all 0.3s;
}

.contract-card:hover {
  border-color: #2c2c2c;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.contract-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.contract-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.info-item {
  padding: 6px 8px;
  background: #fafafa;
  border-radius: 4px;
  border: 1px solid #f0f0f0;
}

.info-label {
  font-size: 0.8em;
  color: #666;
  font-weight: 600;
}

.info-value {
  font-size: 0.95em;
  color: #2c2c2c;
  margin-top: 2px;
}

/* =========================================================
7️⃣ CALENDARIO Y GARANTÍAS
==========================================================*/
.calendar-layout {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 16px;
  align-items: flex-start;
}

#calendar {
  background: #fff;
}

.day-details {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px;
  max-height: 600px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #bbb #f0f0f0;
}

.day-details h3 {
  margin-bottom: 8px;
  font-size: 1.1em;
}

.day-details h4 {
  font-weight: 700;
  color: #1f1f1f;
  font-size: 0.95em;
}

.day-contract {
  border: 1px solid #f0f0f0;
  border-left: 4px solid #2c2c2c;
  border-radius: 5px;
  padding: 8px;
  margin-bottom: 8px;
  background: #fafafa;
}

.day-contract small {
  display: block;
  color: #666;
  margin-bottom: 3px;
  font-size: 0.85em;
}

.fc-daygrid-day.selected-day {
  background: rgba(44, 44, 44, 0.1) !important;
  border: 2px solid #2c2c2c !important;
  transition: all 0.2s ease;
}

/* Fechas (pares fecha+hora) */
.dates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

@media (max-width: 768px) {
  .dates-grid {
    grid-template-columns: 1fr;
  }
}

.datetime-pair {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.pair-title {
  font-weight: 700;
  color: #2c2c2c;
  margin-bottom: 8px;
  font-size: 0.9em;
}

.pair-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pair-field label {
  font-size: 11px;
  color: #666;
  margin-bottom: 5px;
}

/* Garantía (chips) */
.guaranty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 10px;
  margin-bottom: 8px;
  align-items: start;
}

.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.2s, border-color 0.2s, background-color 0.2s;
}

.chip-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--success);
}

.chip-check span {
  font-weight: 600;
  color: #333;
  font-size: 13px;
}

.chip-check:hover {
  border-color: #cfcfcf;
  background: #fafafa;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
}

.guaranty-other {
  grid-column: 1 / -1;
  margin-top: 3px;
}

.guaranty-other input {
  margin-top: 5px;
}

/* Sugerencias de hora */
.time-suggestions {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.time-chip {
  padding: 5px 9px;
  border: 1px solid #e0e0e0;
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.time-chip:hover {
  background: #fafafa;
}

.time-chip.occupied {
  background: #fdecea;
  border-color: #f5c2c0;
  color: #6a1b1a;
  cursor: not-allowed;
}

.time-chip.suggested {
  background: #e8f5e9;
  border-color: #c8e6c9;
  color: #1b5e20;
}

.occupied-info {
  margin-top: 5px;
  font-size: 11px;
  color: #666;
}

@media (max-width: 900px) {
  .calendar-layout {
    grid-template-columns: 1fr;
  }

  #calendar {
    margin-bottom: 14px;
  }
}

/* =========================================================
8️⃣ POPUPS, TOASTS Y MODALES
==========================================================*/
.popup-notificacion {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  z-index: 10000;
  pointer-events: none;
  padding: 20px;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .popup-notificacion {
    padding: 15px;
    align-items: flex-start;
    justify-content: center;
  }
}

.popup-contenido {
  background: #fff;
  padding: 14px 18px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-size: 0.95em;
  font-weight: normal;
  color: #2c2c2c;
  text-align: left;
  animation: slideInToast 0.3s ease-out;
  min-width: 280px;
  max-width: 450px;
  position: relative;
  word-wrap: break-word;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .popup-contenido {
    max-width: calc(100% - 30px);
    min-width: auto;
    width: 100%;
    font-size: 0.9em;
    padding: 12px 16px;
  }
}

.popup-contenido.success {
  border-top: 5px solid #2e7d32;
}

.popup-contenido.error {
  border-top: 5px solid #c62828;
}

.popup-contenido.info {
  border-top: 5px solid #1565c0;
}

/* Modal personalizado */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.modal-overlay.cerrando {
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  width: 360px;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.25);
  animation: fadeIn 0.25s ease-out;
}

.modal-box h3 {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 8px;
}

.modal-box p {
  color: #555;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.modal-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.modal-inputs input {
  padding: 7px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.95rem;
}

.modal-buttons {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.modal-buttons .btn {
  flex: 1;
  padding: 7px 9px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

/* =========================================================
9️⃣ TABLAS DE PIEZAS
==========================================================*/
.piezas-grid {
  align-items: flex-start;
}

.tabla-piezas {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  overflow: hidden;
}

.tabla-piezas thead {
  background: #f5f5f5;
}

.tabla-piezas th,
.tabla-piezas td {
  padding: 7px 5px;
  font-size: 12px;
  vertical-align: top;
  border-bottom: 1px solid #eee;
}

.tabla-piezas tbody tr:last-child td {
  border-bottom: none;
}

.tabla-piezas input[type="text"],
.tabla-piezas textarea {
  width: 100%;
  font-size: 12px;
  padding: 5px 7px;
}

.tabla-piezas textarea {
  min-height: 36px;
  resize: vertical;
}

/* =========================================================
🔟 ALERTA DESTACADA (automática por estado)
==========================================================*/
.alert-highlight {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-weight: 700;
  font-size: 0.98em;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
  animation: fadeInAlert 0.35s ease-out;
}

/* === Estado: hay pendientes (amarillo, emoji animado) === */
.alert-warning {
  background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
  border: 2px solid #f1c232;
  color: #3a3a3a;
  position: relative;
}

.alert-warning::before {
  content: "🚨";
  font-size: 1.4em;
  flex-shrink: 0;
  animation: pulseAlert 1.2s infinite;
}

/* === Estado: sin pendientes (verde, emoji estático) === */
.alert-ok {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border: 2px solid #66bb6a;
  color: #1b5e20;
}

.alert-ok::before {
  content: "✅";
  font-size: 1.3em;
  flex-shrink: 0;
}

/* =========================================================
1️⃣1️⃣ HISTORIAL DE ABONOS
==========================================================*/
.historial-abonos {
  margin-top: 8px;
  max-height: 130px;
  overflow-y: auto;
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  padding: 6px 0;
}

.abono-item {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 0.85rem;
  border-bottom: 1px dashed #eee;
}

.abono-item:last-child {
  border-bottom: none;
}

.abono-fecha {
  color: #666;
  width: 85px;
  font-size: 0.8rem;
}

.abono-metodo {
  color: #007bff;
  text-transform: capitalize;
  font-size: 0.8rem;
}

.abono-monto {
  font-weight: bold;
  color: #28a745;
  font-size: 0.85rem;
}

.sin-abonos {
  color: #999;
  font-style: italic;
  text-align: center;
  margin-top: 8px;
  font-size: 0.85rem;
}

/* =========================================================
1️⃣2️⃣ CLASES UTILITARIAS
==========================================================*/
.text-danger {
  color: #d9534f;
  font-weight: bold;
}

.text-success {
  color: #28a745;
  font-weight: bold;
}

/* =========================================================
1️⃣3️⃣ ANIMACIONES
==========================================================*/
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeInBg {
  from {
    background: rgba(0, 0, 0, 0);
  }
  to {
    background: rgba(0, 0, 0, 0.4);
  }
}

@keyframes fadeInAlert {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseAlert {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.25);
  }
}

@keyframes popIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* =========================================================
1️⃣4️⃣ MEDIA QUERIES Y RESPONSIVE
==========================================================*/

/* Animación de spinner */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (min-width: 900px) {
  .tab {
    min-width: unset;
    flex: 1 1 0;
    padding: 14px 18px;
    font-size: 15px;
  }
}

@media (max-width: 900px) {
  .calendar-layout {
    grid-template-columns: 1fr;
  }

  #calendar {
    margin-bottom: 14px;
  }
  
  .form-row {
    flex-direction: column;
    gap: 12px;
  }
  
  .form-group {
    width: 100% !important;
  }
  
  .dates-grid {
    grid-template-columns: 1fr;
  }
  
  .pair-row {
    grid-template-columns: 1fr;
  }
  
  .item-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .item-row > div {
    width: 100%;
  }
  
  .item-row label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
  }
  
  .guaranty-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  
  .contract-info {
    grid-template-columns: 1fr;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .card-grid {
    grid-template-columns: 1fr;
  }
  
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab {
    min-width: 120px;
    font-size: 12px;
    padding: 10px 12px;
  }
  
  .section-title {
    font-size: 1em;
    padding: 10px 15px;
  }
  
  .btn {
    width: 100%;
    margin-right: 0;
    margin-bottom: 8px;
    justify-content: center;
  }
  
  table {
    font-size: 11px;
  }
  
  table th,
  table td {
    padding: 6px;
  }
  
  .modal-box {
    width: 95% !important;
    max-width: 95% !important;
    margin: 10px;
    padding: 15px;
  }
  
  #sugerenciasTrajes {
    max-height: 150px;
    font-size: 12px;
  }
  
  .time-chip {
    font-size: 11px;
    padding: 6px 10px;
  }
}

/* Responsive: Móvil */
@media (max-width: 700px) {
  .container {
    margin: 0;
    border-radius: 0;
    padding: 0;
  }
  
  body {
    padding: 0;
  }
  
  .content {
    padding: 12px;
  }
  
  .form-row {
    flex-direction: column;
  }
  
  .form-group {
    width: 100% !important;
  }
  
  .dates-grid {
    grid-template-columns: 1fr;
  }
  
  .pair-row {
    grid-template-columns: 1fr;
  }
  
  .item-row {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }
  
  .item-row > div {
    width: 100%;
  }
  
  .item-row label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
  }
  
  .guaranty-grid {
    grid-template-columns: 1fr;
  }
  
  .calendar-layout {
    grid-template-columns: 1fr;
  }
  
  .contract-info {
    grid-template-columns: 1fr;
  }
  
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab {
    min-width: 120px;
    font-size: 12px;
    padding: 10px 12px;
  }
  
  .section-title {
    font-size: 1em;
    padding: 10px 15px;
  }
  
  .btn {
    width: 100%;
    margin-right: 0;
    margin-bottom: 8px;
    justify-content: center;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .card-grid {
    grid-template-columns: 1fr;
  }
  
  table {
    font-size: 11px;
  }
  
  table th,
  table td {
    padding: 6px;
  }
  
  .modal-box {
    width: 95% !important;
    max-width: 95% !important;
    margin: 10px;
    padding: 15px;
  }
  
  #sugerenciasTrajes {
    max-height: 150px;
    font-size: 12px;
  }
  
  .time-chip {
    font-size: 11px;
    padding: 6px 10px;
  }
  
  .time-suggestions {
    flex-wrap: wrap;
  }
}

/* Duplicado removido - ya está arriba */

/* =========================================================
1️⃣5️⃣ ESTILOS DE IMPRESIÓN
==========================================================*/
@media print {
  body * {
    visibility: hidden;
  }

  .print-area,
  .print-area * {
    visibility: visible;
  }

  .print-area {
    position: absolute;
    left: 0;
    top: 0;
  }
}

/* 📊 ESTADÍSTICAS - Chakana Ecuador */
.stats-container {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  padding: 15px;
}

/* --- Resumen superior --- */
.card-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-bottom: 25px;
}
.card-grid .card {
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 14px 20px;
  min-width: 160px;
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Filtros de rango en línea */
.stats-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.stats-controls input[type="date"] {
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.stats-controls label {
  font-size: 0.9em;
  color: #333;
  margin: 0 4px;
}


/* Contenedor de ambos gráficos */
.stats-charts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 20px;
  margin-top: 30px;
}

.stats-charts canvas {
  flex: 1 1 420px;         /* ambos del mismo tamaño y responsivos */
  max-width: 600px;
  height: 340px !important;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  padding: 8px;
}


/* --- Gráficos --- */
.chart-canvas {
  flex: 1 1 45%;
  max-width: 560px;
  min-height: 260px;
  height: 260px !important;
  display: block;
  margin: 0 auto;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
  padding: 8px;
}

/* --- Tabla resumen --- */
.tabla-simple {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}
.tabla-simple th, .tabla-simple td {
  border: 1px solid #ddd;
  padding: 8px 10px;
  text-align: center;
}
.tabla-simple th {
  background: #f5f5f5;
}

/* --- Título --- */
.stats-container h2 {
  color: #333;
  font-size: 1.8em;
  margin-bottom: 10px;
}

/* --- Responsivo --- */
@media (max-width: 850px) {
  .chart-canvas {
    flex: 1 1 100%;
    max-width: 100%;
    height: 300px !important;
  }
  .stats-controls {
    flex-direction: column;
    gap: 8px;
  }
}

/* 🎨 Diseño centrado y limpio de la barra de controles de estadísticas */
.stats-controls {
  display: flex;
  flex-direction: column;
  align-items: center;      /* ✅ Centra horizontalmente */
  justify-content: center;
  gap: 12px;
  margin-bottom: 25px;
  text-align: center;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;  /* ✅ Centra los elementos dentro */
  align-items: center;
  gap: 10px;
}

.stats-row.fechas label {
  font-weight: 500;
  margin-right: 4px;
}

.stats-row.fechas input[type="date"] {
  width: 130px;             /* 🔹 Compacto */
  padding: 5px 6px;
  font-size: 0.9em;
  border: 1px solid #ccc;
  border-radius: 5px;
}

.stats-row.fechas button {
  font-size: 0.9em;
  padding: 6px 10px;
}

.stats-btn {
  min-width: 130px;
  text-align: center;
}

.stats-btn.btn-primary {
  background-color: #2196F3;
  color: #fff;
  border: 1px solid #1976D2;
}

.stats-btn.btn-secondary {
  background-color: #e0e0e0;
  color: #333;
  border: 1px solid #bdbdbd;
}

.stats-btn:hover {
  transform: scale(1.05);
  transition: all 0.15s ease-in-out;
}

.selector-genero {
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 8px;
  margin-top: 4px;
  animation: fadeIn 0.2s ease-in;
}
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInToast {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutToast {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@media (max-width: 768px) {
  @keyframes slideInToast {
    from {
      transform: translateY(-20px);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
  
  @keyframes slideOutToast {
    from {
      transform: translateY(0);
      opacity: 1;
    }
    to {
      transform: translateY(-20px);
      opacity: 0;
    }
  }
}

/* =========================================================
🔹 ESTILOS PARA AUTOCOMPLETADO (SUGERENCIAS)
==========================================================*/
.autocomplete-suggestions {
  background: white;
  border: 1px solid #ccc;
  border-radius: 8px;
  max-height: 250px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  margin-top: 4px;
}

.autocomplete-suggestions::-webkit-scrollbar {
  width: 6px;
}

.autocomplete-suggestions::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.autocomplete-suggestions::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.autocomplete-suggestions::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.autocomplete-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  transition: background 0.2s;
  font-size: 13px;
}

.autocomplete-item:hover {
  background: #f0f0f0;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item strong {
  color: #2c2c2c;
  font-weight: 600;
}

.autocomplete-item small {
  color: #666;
  display: block;
  margin-top: 4px;
  font-size: 11px;
}

/* =========================================================
🔹 MEJORAS RESPONSIVAS TIPO APP MÓVIL
==========================================================*/
@media (max-width: 768px) {
  .header {
    padding: 12px 15px;
    flex-direction: column;
    gap: 10px;
  }
  
  .header h1 {
    font-size: clamp(1.2em, 5vw, 1.6em);
    margin-bottom: 4px;
  }
  
  .header p {
    font-size: clamp(0.85em, 3vw, 0.95em);
  }
  
  .nav-header {
    flex-direction: column;
    gap: 10px;
    padding: 12px 15px;
  }
  
  .nav-header h1 {
    font-size: clamp(1.1em, 4vw, 1.4em);
  }
  
  .nav-header a {
    font-size: clamp(0.85em, 2.5vw, 0.95em);
    padding: 6px 12px;
  }
  
  .content {
    padding: 15px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .form-group {
    margin-bottom: 12px;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 14px;
    width: 100%;
    margin: 4px 0;
    min-height: 44px; /* Mejor área táctil */
  }
  
  .section-title {
    padding: 10px 15px;
    font-size: 1em;
    margin: 15px -15px 12px -15px;
  }
  
  input, select, textarea {
    padding: 12px;
    font-size: 16px; /* Evita zoom en iOS */
    min-height: 44px;
  }
  
  .dates-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
  }
  
  .datetime-pair {
    width: 100%;
  }
  
  .pair-row {
    flex-direction: column;
    gap: 10px;
  }
  
  .pair-field {
    width: 100%;
  }
  
  .tabla-piezas {
    font-size: 12px;
  }
  
  .tabla-piezas th,
  .tabla-piezas td {
    padding: 8px 4px;
  }
  
  .item-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 6px;
    margin-bottom: 10px;
  }
  
  .item-row > div {
    width: 100%;
  }
  
  .total-section {
    padding: 12px;
    margin-top: 15px;
  }
  
  .total-row {
    font-size: 0.95em;
    padding: 8px 0;
  }
  
  .total-row.final {
    font-size: 1.1em;
    padding-top: 10px;
  }
  
  .autocomplete-suggestions {
    max-height: 200px;
    font-size: 14px;
  }
  
  .autocomplete-item {
    padding: 12px;
    min-height: 48px;
  }
  
  .modal-box {
    width: 95vw !important;
    max-width: 95vw !important;
    padding: 15px !important;
    max-height: 90vh !important;
  }
  
  .contract-card {
    padding: 12px;
  }
  
  .contract-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .contract-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .contract-actions .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 3px);
  }
}

@media (max-width: 480px) {
  body {
    padding: 8px;
  }
  
  .container {
    border-radius: 0;
  }
  
  .header {
    padding: 10px 12px;
  }
  
  .content {
    padding: 12px;
  }
  
  .btn {
    font-size: 13px;
    padding: 10px 14px;
  }
  
  .section-title {
    font-size: 0.95em;
    padding: 8px 12px;
    margin: 12px -12px 10px -12px;
  }
  
  /* Fix para campos de inventario en móviles */
  #inv_nombreTraje,
  #inv_piezas_hombre,
  #inv_piezas_mujer,
  #inv_tallas_ropa_h,
  #inv_tallas_calzado_h,
  #inv_tallas_ropa_m,
  #inv_tallas_calzado_m,
  #inv_total_h,
  #inv_total_m,
  #inv_precio_h,
  #inv_precio_m {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    font-size: 16px !important; /* Evita zoom en iOS */
    padding: 10px 12px !important;
  }
  
  /* Asegurar que los contenedores de formulario no reduzcan los inputs */
  #formularioTraje,
  #formularioTraje form,
  .form-group,
  .form-row {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

/* Media query adicional para tablets y móviles grandes */
@media (max-width: 768px) {
  /* Asegurar que los inputs del inventario sean visibles */
  #inv_nombreTraje,
  #inv_piezas_hombre,
  #inv_piezas_mujer,
  #inv_tallas_ropa_h,
  #inv_tallas_calzado_h,
  #inv_tallas_ropa_m,
  #inv_tallas_calzado_m,
  #inv_total_h,
  #inv_total_m,
  #inv_precio_h,
  #inv_precio_m {
    width: 100% !important;
    min-width: 200px !important;
    box-sizing: border-box !important;
  }
  
  .form-row {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
  }
}