*, *::before, *::after { box-sizing: border-box; }
body { font-family: Roboto;
	   margin:0;
	   padding:0;
	   background:#f5f5f5;
	   display: none;
	 }
.header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0px 12px;
    background: #ffffff;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
}

h1 {
    margin-bottom: 0;
}

.title-block{
    display: flex;
    flex-direction: column;
    padding-left: 30px;
}

.title-block h1{
    margin: 0;
    line-height: 1.2;
}

.subtitle{
    margin-top: 2px;
    font-size: 13px;
    color: #777;
    letter-spacing: 0.3px;
}

.logo {
    height: 62px;
    width: auto;
    object-fit: contain;
    display: block;
    border: none;
    outline: none;
    box-shadow: none;
    background: transparent;
}

.user-panel{
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info{
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9em;
  color: #333;
  white-space: nowrap;
}

.user-icon{
  width: 18px;
  height: 18px;
  fill: #555;
  opacity: 0.85;
}

#logoutBtn{
  padding: 4px 10px;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 6px;
  background: #f5f5f5;
  font-size: 0.85em;
}

#logoutBtn:hover{
  background: #e0e0e0;
}

main { padding: 5px; }

.tab-buttons { display:flex; gap:10px; margin-bottom:5px; }
.tab-buttons button {
    padding: 8px 16px;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 6px;
    background: #f5f5f5;
    color: #333;
    font-weight: 500;
    transition: background-color .15s, border-color .15s;
}

.tab-buttons button:hover {
    background: #e0e0e0;
}

.tab-buttons button.active {
    background: #e3e3e3;
    border-color: rgba(0,0,0,.3);
    font-weight: 600;
}

.tab-content { display:none; }

main .panel { display: block; background:white; padding:5px; border-radius:6px; box-shadow:0 2px 6px rgba(0,0,0,0.1); margin-bottom:20px; }
main .panel h2, main .panel h3 { margin-top:0; }

input[type="text"], input[type="number"], button, input[type="file"] { padding:6px 10px; margin:5px 0; font-size:14px; }
input[type="number"] { width:60px; }

#resultados, #resumen { border:1px solid #ccc; padding:10px; max-height:200px; overflow-y:auto; }
.item, .resumen-item, .pedido-item { display:flex; justify-content:space-between; align-items:center; margin-bottom:5px; padding:5px; border-bottom:1px solid #eee; }
.item div.precio, .item div.subtotal, .resumen-item span:last-child, .pedido-item span:last-child { min-width:80px; text-align:right; }
.resumen-item button, .pedido-item button { margin-left:10px; cursor:pointer; background:#e74c3c; color:white; border:none; border-radius:4px; padding:2px 6px; }
.total { margin-top:10px; font-weight:bold; display:flex; justify-content:space-between; border-top:1px solid #ccc; padding-top:5px; }

.resumen-item {
    display: grid;
    grid-template-columns: 1fr 110px 30px;
    align-items: center;
    gap: 5px;
}

.resumen-item span:nth-child(2) {
    text-align: right;
    font-weight: bold;
}

.resumen-cantidad {
    background: #3498db;
    color: white;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 12px;
    margin-right: 4px;
    font-size: 0.85em;
}


/* MODAL */
.modal { display:none; position:fixed; z-index:999; left:0; top:0; width:100%; height:100%; overflow:auto; background-color: rgba(0,0,0,0.5); }
.modal-content { background-color:#fefefe; margin:10% auto; padding:20px; border-radius:6px; width:90%; max-width:600px; }
.modal-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.close { cursor:pointer; font-size:24px; }
#pedido-resumen { max-height:300px; overflow-y:auto; margin-bottom:10px; }

.btn-increase,
.btn-decrease {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 4px;
    background-color: #f5f5f5;
    color: #333;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s, border-color .15s;
}

.btn-increase:hover,
.btn-decrease:hover {
    background-color: #e0e0e0;
    border-color: rgba(0,0,0,.25);
}

.btn-increase:active,
.btn-decrease:active {
    background-color: #d6d6d6;
}

/* Span de cantidad */
.cantidad-span {
    min-width: 24px;
    text-align: center;
    display: inline-block;
    font-weight: bold;
    margin: 0 4px;
}

.proveedor {
  display: flex;
  align-items: center;
  gap: 6px;
}

.proveedor img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

mark {
    padding: 2px 0px;
    border-radius: 4px;
	background-color: transparent;
  }

mark.resaltado-1  { background-color: #e6e6e6; } /* gris visible */
mark.resaltado-2  { background-color: #d4d4d4; } /* gris medio */

/* Medios */
mark.resaltado-3  { background-color: #fff3cd; } /* amarillo suave */
mark.resaltado-4  { background-color: #ffe0b2; } /* ámbar */
mark.resaltado-5  { background-color: #dcedc8; } /* verde pastel */

/* Altos */
mark.resaltado-6  { background-color: #c8e6c9; } /* verde */
mark.resaltado-7  { background-color: #bbdefb; } /* azul */
mark.resaltado-8  { background-color: #cfd8dc; } /* azul gris */
mark.resaltado-9  { background-color: #ffcdd2; } /* rojo suave */
mark.resaltado-10 { background-color: #e0cfc2; } /* marrón claro */

/* Búsqueda sin relevancia */
mark.busqueda-simple {
    background-color: #fff59d; /* amarillo más visible */
}

.filtro{
  display:flex;
  align-items:center;
  gap:6px;
  padding:4px 8px;
  border:1px solid #ddd;
  background:#fff;
  border-radius:20px;
  cursor:pointer;
  white-space:nowrap;
  font-size:0.8em;
}

.filtro img{
  width:20px;
  height:20px;
  object-fit:contain;
}

.filtro.active{
  background:#333;
  color:#fff;
  border-color:#333;
}

.filtro.active img{
  filter: none;
}

.filtros-scroll{
  display:flex;
  gap:8px;
  overflow-x:auto;
  padding:6px 4px;
  margin-bottom:6px;
  scrollbar-width:thin; /* Firefox */
}
.filtros-scroll::-webkit-scrollbar{
  height:6px;
}
.filtros-scroll::-webkit-scrollbar-thumb{
  background:#ccc;
  border-radius:4px;
}

.badge{
  background:#e0e0e0;
  color:#333;
  border-radius:10px;
  padding:2px 6px;
  font-size:0.75em;
  margin-left:4px;
  font-weight:600;
}

.filtro.active .badge{
  background:#fff;
  color:#333;
}

/* MOBILE */
@media (max-width: 768px){

  /* Oculta el nombre del proveedor */
  #filtros-proveedor .filtro img + span{
      display: none;
  }

  /* Ajuste visual del botón */
  #filtros-proveedor .filtro{
      min-width: 60px;
      padding: 6px;
      gap: 4px;
  }

  #filtros-proveedor img{
      width: 32px;
      height: 32px;
  }

  /* Badge más compacto */
  .badge{
      font-size: 0.7em;
      padding: 2px 5px;
  }
}

#filtros-resaltado{
  display:flex;
  gap:6px;
  margin-bottom:6px;
}

#filtros-resaltado button{
  min-width:32px;
  height:28px;
  border-radius:6px;
  color: #222;
  border: 1px solid rgba(0,0,0,.08);
  font-size:0.75em;
  cursor:pointer;
}

#filtros-resaltado button.active{
  box-shadow: 0 0 0 2px #333;
  font-weight: 600;
}

#filtros-resaltado button:hover {
  filter: brightness(0.95);
}

/* mismos colores que los <mark> */
#filtros-resaltado .c1  { background:#e6e6e6; } /* gris visible */
#filtros-resaltado .c2  { background:#d4d4d4; } /* gris medio */

#filtros-resaltado .c3  { background:#fff3cd; } /* amarillo suave */
#filtros-resaltado .c4  { background:#ffe0b2; } /* ámbar suave */
#filtros-resaltado .c5  { background:#dcedc8; } /* verde pastel */

#filtros-resaltado .c6  { background:#c8e6c9; } /* verde suave */
#filtros-resaltado .c7  { background:#bbdefb; } /* azul claro */
#filtros-resaltado .c8  { background:#cfd8dc; } /* azul grisáceo */

#filtros-resaltado .c9  { background:#ffcdd2; } /* rojo suave */
#filtros-resaltado .c10 { background:#e0cfc2; } /* marrón claro */


#tablaImportaciones {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
	table-layout: fixed;
}

#tablaImportaciones thead {
    background: #f0f0f0;
}

#tablaImportaciones th,
#tablaImportaciones td {
    padding: 8px 10px;
    border-bottom: 1px solid #ddd;
    text-align: center;
    vertical-align: middle;
}

#tablaImportaciones th {
    font-weight: bold;
    white-space: nowrap;
}

#tablaImportaciones td.num {
    text-align: right;
    white-space: nowrap;
}

#tablaImportaciones td.archivo {
    max-width: 420px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* zebra */
#tablaImportaciones tbody tr:nth-child(even) {
    background: #fafafa;
}

/* hover */
#tablaImportaciones tbody tr:hover {
    background: #eef6ff;
}

#tablaImportaciones th:nth-child(1),
#tablaImportaciones td:nth-child(1) {
    width: 140px; /* Fecha */
}

#tablaImportaciones th:nth-child(2),
#tablaImportaciones td:nth-child(2) {
    width: auto;  /* Archivo */
}

#tablaImportaciones th:nth-child(3),
#tablaImportaciones td:nth-child(3) {
    width: 90px;  /* Filas */
    text-align: right;
}

#tablaImportaciones th:nth-child(4),
#tablaImportaciones td:nth-child(4) {
    width: 120px; /* Proveedores */
    text-align: right;
}

.item{
  align-items:flex-start !important;
}

.bloque-cantidad{
  display:flex;
  flex-direction:column;
  align-items: center;
  gap:4px;
  min-width:120px;
}

.cantidad{
  display:flex;
  align-items:center;
  gap:6px;
}

.precio{
  font-size:.85em;
  color:#555;
  white-space:nowrap;
}

.subtotal{
  width:90px;
  text-align:right;
}


/* contenedor de sugerencias */
.suggestions-list {
    position: absolute; /* flota debajo del input */
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px; /* alto máximo con scroll */
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 9999;
    list-style: none;
    margin: 0;
    padding: 0;
    font-family: Roboto, sans-serif;
}

/* cada sugerencia */
.suggestion-item {
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

/* hover/focus */
.suggestion-item:hover,
.suggestion-item:focus {
    background: #f0f8ff;
}

/* precio en la sugerencia */
.suggestion-item span.precio {
    margin-left: 10px;
    white-space: nowrap;
}

/* responsive: móviles */
@media (max-width: 600px) {
    .suggestions-list {
        max-height: 200px;
        font-size: 0.9em;
    }
    .suggestion-item {
        padding: 8px 10px;
        flex-direction: column;
        align-items: flex-start;
    }
    .suggestion-item span.precio {
        margin-left: 0;
        margin-top: 2px;
    }
}

/* --- TABLET (max 768px) --- */
@media (max-width: 768px) {

    .header {
        flex-wrap: wrap;
        padding: 8px 10px;
        gap: 8px;
    }

    .title-block {
        padding-left: 10px;
    }

    .title-block h1 {
        font-size: 1.2em;
    }

    .subtitle {
        font-size: 11px;
    }

    .logo {
        height: 50px;
    }

    .user-panel {
        gap: 8px;
    }

    .tab-buttons {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .tab-buttons button {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 13px;
        padding: 6px 12px;
    }

    #tablaImportaciones {
        font-size: 12px;
    }

    #tablaImportaciones th,
    #tablaImportaciones td {
        padding: 6px 4px;
    }

    #tablaImportaciones td.archivo {
        max-width: 180px;
    }

    .item {
        flex-direction: column !important;
        gap: 6px;
        padding: 8px 5px !important;
    }

    .item > div:first-child {
        min-width: unset !important;
        width: 100%;
    }

    .bloque-cantidad {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        min-width: unset;
    }

    .subtotal {
        width: auto;
        text-align: right;
        font-weight: bold;
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 15px;
    }
}

/* --- MOBILE (max 480px) --- */
@media (max-width: 480px) {

    .header {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px;
        gap: 6px;
        position: relative;
    }

    .header > .logo {
        align-self: center;
    }

    .title-block {
        padding-left: 0;
        text-align: center;
        width: 100%;
    }

    .title-block h1 {
        font-size: 1.1em;
    }

    .subtitle {
        font-size: 10px;
    }

    .menu-toggle {
        display: block;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        margin-left: auto;
    }

    .menu-toggle span {
        display: block;
        width: 24px;
        height: 3px;
        background: #333;
        margin: 5px 0;
        transition: 0.3s;
    }

    .user-panel {
        display: none;
        width: 100%;
        flex-direction: column;
        margin-left: 0;
        padding: 10px;
        background: #f5f5f5;
        border-radius: 6px;
        gap: 8px;
    }

    .user-panel.active {
        display: flex;
    }

    .user-info {
        font-size: 0.85em;
        width: 100%;
        justify-content: center;
    }

    #logoutBtn {
        font-size: 0.85em;
        padding: 8px 16px;
        width: 100%;
    }

    main {
        padding: 4px;
    }

    main .panel {
        padding: 8px;
    }

    .tab-buttons {
        gap: 6px;
    }

    .tab-buttons button {
        font-size: 12px;
        padding: 6px 10px;
    }

    /* Tabla importaciones: scroll horizontal */
    #tab-importar .panel {
        overflow-x: auto;
    }

    #tablaImportaciones {
        font-size: 11px;
        min-width: 400px;
    }

    /* Items de producto */
    .item {
        flex-direction: column !important;
        gap: 4px;
        padding: 8px 4px !important;
    }

    .bloque-cantidad {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        min-width: unset;
    }

    .cantidad {
        gap: 4px;
    }

    .btn-increase, .btn-decrease {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .cantidad-span {
        font-size: 1em;
        min-width: 28px;
    }

    .subtotal {
        width: auto;
        font-size: 0.95em;
    }

    .precio {
        font-size: 0.8em;
    }

    /* Resumen */
    .resumen-item {
        grid-template-columns: 1fr 80px 28px;
        font-size: 0.9em;
    }

    /* Modal */
    .modal-content {
        width: 96%;
        margin: 3% auto;
        padding: 12px;
        max-height: 90vh;
        overflow-y: auto;
    }

    #pedido-resumen {
        max-height: 50vh;
    }

    .pedido-item {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 4px;
    }

    /* Filtros */
    .filtros-scroll {
        gap: 6px;
        padding: 4px 2px;
    }

    .filtro {
        font-size: 0.75em;
        padding: 4px 6px;
    }

    #filtros-resaltado button {
        min-width: 28px;
        height: 26px;
        font-size: 0.7em;
    }

    /* Input de busqueda */
    #buscar {
        font-size: 16px !important; /* evita zoom en iOS */
    }

    #resultados {
        max-height: none;
    }
}

/* WhatsApp link */
a[href*="wa.me"] {
    display: block;
    text-align: center;
    padding: 10px;
    color: #25d366;
    font-weight: bold;
    text-decoration: none;
}

a[href*="wa.me"]:hover {
    text-decoration: underline;
}

footer {
    padding: 10px;
    font-size: 0.85em;
    color: #666;
}