body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    background-color: #eef2f3;
    margin: 0;
    padding: 0;
    color: #333;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 20px 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.logo-mini {
    height: 40px;
    margin-bottom: 5px;
}

h1 { margin: 5px 0; font-size: 1.5rem; }
.subtitulo { font-size: 0.9rem; opacity: 0.9; margin: 0; }

.control-panel {
    margin: 20px auto;
    background: white;
    padding: 15px;
    width: 90%;
    max-width: 400px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

select {
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 1rem;
    width: 100%;
    margin-top: 5px;
}

#reader-wrapper {
    position: relative;
    width: 90%;
    max-width: 400px;
    margin: 0 auto;
}

#reader {
    width: 100%;
    height: 220px;
    border-radius: 15px;
    overflow: hidden;
    border: 4px solid #2c3e50;
    background: #000;
    object-fit: cover;
    display: block;
}


.camera-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 55%;
    height: 12%;
    border: 3px solid #ffffff;
    border-radius: 6px;
    pointer-events: none;
    z-index: 10;
}

#resultado-cuadro {
    width: 85%;
    max-width: 380px;
    margin: 20px auto;
    padding: 20px;
    border-radius: 12px;
    background: white;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

#mensaje-estado {
    font-weight: bold;
    font-size: 1.1rem;
}

.nota-ayuda {
    font-size: 0.85rem;
    color: #666;
    margin-top: 10px;
}

.acciones {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    padding-bottom: 30px;
}

#boton-escanear {
    background-color: #27ae60;
    color: white;
    padding: 18px 40px;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    width: 80%;
    max-width: 300px;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

#boton-apagar {
    background-color: #e74c3c;
    color: white;
    padding: 18px 40px;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    width: 80%;
    max-width: 300px;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

#boton-escanear:disabled,
#boton-apagar:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

#boton-manual {
    background: none;
    border: 1px solid #7f8c8d;
    color: #7f8c8d;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
}

.switch-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 5px;
}
.switch-label {
    font-size: 1rem;
    font-weight: bold;
    color: #2c3e50;
}
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 32px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #bdc3c7;
    border-radius: 32px;
    transition: 0.3s;
}
.slider:before {
    content: '';
    position: absolute;
    height: 24px;
    width: 24px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}
input:checked + .slider { background-color: #27ae60; }
input:checked + .slider:before { transform: translateX(28px); }

#boton-capturar {
    background-color: #2980b9;
    color: white;
    padding: 18px 40px;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    width: 80%;
    max-width: 300px;
    box-shadow: 0 4px 15px rgba(41, 128, 185, 0.3);
}

#boton-linterna {
    background-color: #f39c12;
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    width: 80%;
    max-width: 300px;
}

#boton-capturar:disabled,
#boton-linterna:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

#procesando {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.75);
    color: white;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 0.9rem;
    z-index: 20;
}
.oculto { display: none !important; }

#contador {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 15px auto;
    width: 90%;
    max-width: 400px;
}
.cnt {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1rem;
}
.valido-cnt  { background: #d5f5e3; color: #1e8449; }
.peligro-cnt { background: #fadbd8; color: #c0392b; }

#historial-container {
    width: 90%;
    max-width: 400px;
    margin: 20px auto 30px;
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: left;
}
#historial-container h3 {
    margin: 0 0 10px;
    font-size: 1rem;
    color: #2c3e50;
    text-align: center;
}
#boton-limpiar {
    display: block;
    margin: 0 auto 10px;
    background: none;
    border: 1px solid #bdc3c7;
    color: #7f8c8d;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
}
#historial-lista {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}
#historial-lista li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 5px;
    font-size: 0.85rem;
    gap: 8px;
}
#historial-lista li small { color: #999; white-space: nowrap; }
.hist-valido  { background: #eafaf1; color: #1e8449; }
.hist-peligro { background: #fdedec; color: #c0392b; }

.peligro     { background-color: #e74c3c !important; color: white !important; }
.valido      { background-color: #2ecc71 !important; color: white !important; }
.advertencia { background-color: #f39c12 !important; color: white !important; }

footer {
    margin-top: 20px;
    padding: 20px;
    font-size: 0.8rem;
    color: #7f8c8d;
    background: #fff;
}

#boton-donar {
    margin: 10px auto;
    display: block;
    background: none;
    border: 1px solid #bdc3c7;
    color: #7f8c8d;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
}
#boton-donar:hover { background: #f4f4f4; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.modal-contenido {
    background: white;
    border-radius: 16px;
    padding: 30px 25px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.modal-contenido h3 { margin: 0 0 5px; font-size: 1.2rem; color: #2c3e50; }
.modal-contenido p  { margin: 0 0 15px; font-size: 0.9rem; color: #7f8c8d; }
.modal-contenido img {
    width: 100%;
    max-width: 240px;
    border-radius: 10px;
    border: 1px solid #eee;
}
.modal-cerrar {
    position: absolute;
    top: 10px; right: 14px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #999;
}