:root {
    --rojo:    #bf3020;
    --rojo-hover: #a82819;
    --verde:   #1e7e34;
    --gris:    #6b7280;
    --fondo:   #faf7f5;
    --borde:   #e8e2dc;
    --sombra:  0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --radio:   12px;
    --fs-base: 17px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    min-height: 100vh;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    font-size: var(--fs-base);
    background: var(--fondo);
    color: #1a1a1a;
}

/* ── Login ── */
.contenedor-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.contenedor-login .tarjeta { width: 380px; }
.contenedor-login h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.contenedor-login .subtitulo { color: var(--gris); margin-bottom: 8px; }

/* ── Layout principal ── */
.contenedor {
    width: 100%;
    padding: 20px 32px 60px;
}

.cabecera {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--borde);
}

.cabecera-acciones { display: flex; gap: 10px; align-items: center; }
.cabecera-acciones a { text-decoration: none; }

.cabecera-seccion {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

/* ── Tipografía ── */
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
h2 { font-size: 19px; font-weight: 700; margin-bottom: 10px; letter-spacing: -0.2px; }
.subtitulo { color: var(--gris); margin-top: -4px; font-size: 15px; }

/* ── Tarjetas ── */
.tarjeta {
    background: white;
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 18px 24px;
    margin-bottom: 16px;
    border: 1px solid rgba(0,0,0,.04);
}

/* ── Formularios ── */
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 14px 0 5px;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="text"], input[type="password"], input[type="file"] {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--borde);
    border-radius: 8px;
    font-size: 15px;
    background: white;
    transition: border-color .15s;
}
input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--rojo);
}

select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--borde);
    border-radius: 8px;
    font-size: 15px;
    background: white;
    transition: border-color .15s;
}
select:focus { outline: none; border-color: var(--rojo); }

/* Botón principal — pill rojo */
button {
    background: var(--rojo);
    color: white;
    border: none;
    padding: 11px 24px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    margin-top: 16px;
    letter-spacing: 0.01em;
    transition: background .15s, transform .1s;
}
button:hover { background: var(--rojo-hover); }
button:active { transform: scale(.98); }
button:disabled { background: #c4bab5; cursor: not-allowed; }

.boton-secundario {
    background: white;
    color: #374151;
    border: 1.5px solid var(--borde);
    margin-top: 0;
    font-weight: 500;
}
.boton-secundario:hover { background: var(--fondo); border-color: #c8c0ba; }

.boton-peligro {
    background: #fff1f0;
    color: var(--rojo);
    border: 1.5px solid #fac5bf;
    margin-top: 0;
    padding: 7px 16px;
    font-size: 14px;
}
.boton-peligro:hover { background: #ffe4e1; }

.formulario-linea {
    display: flex;
    gap: 12px;
    align-items: center;
}
.formulario-linea button { margin-top: 0; }

.formulario-subida { display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; }
.formulario-subida label { margin: 0; display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.formulario-subida select { width: 240px; }
.formulario-subida button { margin-top: 0; }

.formulario-vertical { display: flex; flex-direction: column; gap: 4px; max-width: 420px; }
.formulario-vertical button { align-self: flex-start; }

/* ── Textos de ayuda ── */
.ayuda { color: var(--gris); font-size: 14px; line-height: 1.65; margin-bottom: 16px; }
.ayuda code {
    background: #f3ede9;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--rojo);
}

/* ── Alertas ── */
.alerta {
    padding: 13px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 15px;
    font-weight: 500;
    border-left: 4px solid;
}
.alerta-info  { background: #fff8f0; color: #92400e; border-color: var(--rojo); }
.alerta-error { background: #fff1f0; color: var(--rojo);  border-color: var(--rojo); }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    text-transform: capitalize;
    background: #f0ebe7;
    color: #4b5563;
}
.badge-pendiente  { background: #fff3cd; color: #7c4a03; }
.badge-enviado    { background: #e0eeff; color: #1e40af; }
.badge-confirmada { background: #dcfce7; color: #166534; }
.badge-cancelada  { background: #fff1f0; color: var(--rojo); }
.badge-error      { background: #fff1f0; color: var(--rojo); }

/* ── Tabla de pacientes ── */
.tabla-wrapper { overflow-x: auto; }

.tabla-pacientes {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}
.tabla-pacientes th {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 2px solid var(--borde);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--gris);
    font-weight: 700;
}
.tabla-pacientes td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid #f0ebe7;
}
.tabla-pacientes tbody tr:hover { background: #fdf9f7; }
.tabla-pacientes .vacio { text-align: center; color: var(--gris); padding: 32px; }

/* ── Secciones por lote ── */
.lote-seccion { padding: 0; overflow: hidden; }

.lote-cabecera {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    flex-wrap: wrap;
}

details.lote-colapsable > summary { cursor: pointer; list-style: none; }
details.lote-colapsable > summary::-webkit-details-marker { display: none; }
details.lote-colapsable > summary::before {
    content: "▶ ";
    font-size: 11px;
    color: var(--gris);
    margin-right: 4px;
}
details.lote-colapsable[open] > summary::before { content: "▼ "; }

.lote-info { flex: 1; min-width: 200px; }
.lote-doctor { font-weight: 800; font-size: 18px; display: block; color: #1a1a1a; letter-spacing: -0.2px; }
.lote-meta { font-size: 13px; color: var(--gris); margin-top: 3px; }

.lote-contadores { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lote-seccion .tabla-wrapper {
    padding: 0 24px 20px;
    border-top: 1px solid var(--borde);
}
.lote-seccion form button { margin-top: 0; white-space: nowrap; }

/* ── Misc ── */
.vacio { text-align: center; color: var(--gris); padding: 32px; font-size: 15px; }

/* ── Barra de color superior (acento de marca) ── */
body::before {
    content: "";
    display: block;
    height: 4px;
    background: var(--rojo);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}
