:root {
  --marfil: #F2EFE9; --borgona: #B74E58; --borgona-osc: #9C3F49; --rosa: #EDCCCC; --rosa-claro: #F6E4E4;
  --verde: #106864; --texto: #2B2627; --suave: #6B5F61; --rojo: #B3261E; --blanco: #FFFDFB; --linea: #E3D6D3;
  --serif: "DM Serif Display", Georgia, serif; --sans: Montserrat, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--marfil); color: var(--texto); font-family: var(--sans); font-size: 15px; }
body { overflow-x: hidden; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0 0 .5em; }
h2 { font-size: 1.9rem; } h3 { font-size: 1.35rem; color: var(--verde); }
a { color: var(--verde); }
.cargando { padding: 40px; text-align: center; }

/* Botones y campos */
button, .boton { font: 600 .9rem var(--sans); border: 0; border-radius: 999px; padding: .6em 1.2em; cursor: pointer; background: var(--borgona); color: var(--marfil); text-decoration: none; display: inline-flex; align-items: center; gap: .4em; }
button:hover, .boton:hover { background: var(--borgona-osc); }
button.sec { background: transparent; color: var(--borgona); box-shadow: inset 0 0 0 1.5px var(--borgona); }
button.sec:hover { background: var(--rosa-claro); }
button.verde { background: var(--verde); } button.verde:hover { background: #0b4f4c; }
button.mini { padding: .3em .7em; font-size: .78rem; }
button.icono { background: transparent; color: var(--suave); padding: .3em .5em; }
button.icono:hover { color: var(--rojo); background: var(--rosa-claro); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: 500 .9rem var(--sans); color: var(--texto); border: 1px solid var(--linea); border-radius: 8px; padding: .5em .6em; background: var(--blanco); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--verde); outline-offset: -1px; }
textarea { resize: vertical; min-height: 80px; }
label { font-weight: 600; font-size: .85rem; display: block; margin-bottom: .3em; }
.campo { margin-bottom: 14px; }
.fila-botones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Ingreso */
.ingreso { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--borgona); }
.ingreso .caja { background: var(--marfil); border-radius: 20px; padding: 32px 28px; width: 100%; max-width: 400px; text-align: center; }
.ingreso img { width: 120px; margin-bottom: 8px; }
.ingreso form { text-align: left; margin-top: 18px; }
.ingreso button { width: 100%; justify-content: center; margin-top: 6px; }
.error { color: var(--rojo); font-weight: 600; font-size: .9rem; }

/* Estructura */
header.barra { background: var(--borgona); color: var(--marfil); padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
header.barra img { height: 54px; }
header.barra .titulo { flex: 1; min-width: 160px; }
header.barra .titulo strong { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; display: block; line-height: 1.1; }
header.barra .titulo span { font-size: .85rem; opacity: .9; }
header.barra button { background: var(--marfil); color: var(--borgona); }
header.barra button:hover { background: var(--rosa); }
header.barra .usuario { font-size: .8rem; opacity: .9; }
nav.pestanas { background: var(--blanco); border-bottom: 1px solid var(--linea); display: flex; gap: 2px; overflow-x: auto; padding: 0 8px; position: sticky; top: 0; z-index: 5; scrollbar-width: thin; }
nav.pestanas button { background: transparent; color: var(--suave); border-radius: 0; padding: 14px 14px 12px; border-bottom: 3px solid transparent; white-space: nowrap; }
nav.pestanas button.activa { color: var(--borgona); border-bottom-color: var(--borgona); }
nav.pestanas button:hover { background: var(--rosa-claro); }
main { max-width: 1240px; margin: 0 auto; padding: 22px 16px 80px; }
.demo { background: #FFF4D6; color: #6B4E00; padding: 8px 16px; font-size: .85rem; text-align: center; }

.tarjeta { background: var(--blanco); border-radius: 16px; padding: 20px; margin-bottom: 18px; box-shadow: 0 1px 0 var(--linea); }
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.cifra { background: var(--blanco); border-radius: 14px; padding: 14px 16px; }
.cifra small { display: block; color: var(--suave); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.cifra b { font-family: var(--serif); font-weight: 400; font-size: 1.7rem; }
.cifra.total { background: var(--borgona); color: var(--marfil); } .cifra.total small { color: var(--rosa); }
.ok { color: var(--verde); font-weight: 600; } .mal { color: var(--rojo); font-weight: 600; }
.nota { color: var(--suave); font-size: .85rem; }
.duda { background: #FFF4D6; border-left: 4px solid #D9A400; padding: 8px 12px; border-radius: 6px; margin: 6px 0; font-size: .88rem; }

/* Tablas */
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--linea); background: var(--blanco); }
table { border-collapse: collapse; width: 100%; font-size: .87rem; }
th { background: var(--borgona); color: var(--marfil); text-align: left; padding: 10px 8px; font-weight: 700; font-size: .78rem; white-space: nowrap; position: sticky; top: 0; }
td { padding: 4px 6px; border-bottom: 1px solid var(--linea); vertical-align: middle; }
tbody tr:nth-child(even) td { background: #FBF6F4; }
td.num, th.num { text-align: right; white-space: nowrap; }
td input, td select { padding: .35em .45em; min-width: 70px; border-color: transparent; background: transparent; }
td input:hover, td select:hover { border-color: var(--linea); background: var(--blanco); }
td input[type=date] { min-width: 132px; } td input.hora { width: 92px; min-width: 92px; } td input.corto { width: 86px; min-width: 86px; }
td input.largo { min-width: 170px; }
tr.pendiente td { color: var(--rojo); }
tr.pendiente td input { color: var(--rojo); }
.etiqueta { display: inline-block; font-size: .72rem; font-weight: 700; padding: .2em .6em; border-radius: 999px; background: var(--rosa-claro); color: var(--borgona); white-space: nowrap; }
.etiqueta.roja { background: #FBE3E1; color: var(--rojo); } .etiqueta.verde { background: #DDEFEE; color: var(--verde); }
tfoot td { font-weight: 700; background: var(--rosa) !important; }

/* Comprobantes */
.comprobantes { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.comprobante img { width: 100%; border-radius: 10px; border: 1px solid var(--linea); cursor: zoom-in; display: block; background: var(--marfil); }
.comprobante h3 { margin-bottom: 4px; }
.correo { margin-top: 12px; border-top: 1px dashed var(--linea); padding-top: 12px; }
.correo .linea { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.correo .linea span { flex: 1; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.correo pre { white-space: pre-wrap; font: .82rem var(--sans); background: var(--marfil); padding: 10px; border-radius: 8px; max-height: 180px; overflow: auto; }

.visor { position: fixed; inset: 0; background: rgba(43,38,39,.85); z-index: 50; overflow: auto; padding: 16px; display: flex; justify-content: center; align-items: flex-start; }
.visor img { max-width: 900px; width: 100%; border-radius: 8px; }

.dialogo { position: fixed; inset: 0; background: rgba(43,38,39,.55); z-index: 40; display: grid; place-items: center; padding: 16px; }
.dialogo .caja { background: var(--marfil); border-radius: 18px; padding: 22px; max-width: 980px; width: 100%; max-height: 90vh; overflow: auto; }

#avisos { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100% - 32px)); }
.aviso { background: var(--texto); color: var(--marfil); padding: 12px 16px; border-radius: 12px; font-size: .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.aviso.error { background: var(--rojo); color: #fff; }

.propuesta { background: var(--rosa-claro); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.propuesta ul { margin: 6px 0 10px; padding-left: 20px; }
.historial li { margin-bottom: 8px; } .historial .deshecho { text-decoration: line-through; color: var(--suave); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.zona-archivo { border: 2px dashed var(--rosa); border-radius: 14px; padding: 22px; text-align: center; background: var(--blanco); }
.zona-archivo.encima { background: var(--rosa-claro); }
.hojas label { font-weight: 500; display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.hojas input { width: auto; }

@media (max-width: 640px) {
  h2 { font-size: 1.5rem; }
  header.barra img { height: 42px; }
  header.barra .usuario { display: none; }
  .tarjeta { padding: 14px; border-radius: 12px; }
  .comprobantes { grid-template-columns: 1fr; }
}
