:root {
  --fondo: #f4f2ee; --papel: #fffefb; --tinta: #1d2420; --tenue: #5f6b64; --linea: #d9d5cc;
  --verde: #1f6b45; --verde-suave: #e3f0e8; --rojo: #a8321f; --rojo-suave: #fbe9e5; --ambar: #fff3cf;
  --radio: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fondo); color: var(--tinta); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--verde); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 .6rem; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.num, .monto, .real, td, .tarjeta strong, [data-total-dia] { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid #2f8f5f; outline-offset: 1px; }

.barra { display: flex; align-items: center; gap: 20px; padding: 10px 16px; background: var(--tinta); color: #fff; flex-wrap: wrap; }
.barra .marca { color: #fff; font-weight: 700; text-decoration: none; }
.barra nav { display: flex; gap: 4px; flex: 1; }
.barra nav a { color: #d7ded9; text-decoration: none; padding: 6px 12px; border-radius: 6px; }
.barra nav a.activo, .barra nav a:hover { background: #36413b; color: #fff; }
.salir { display: flex; align-items: center; gap: 10px; margin: 0; color: #d7ded9; font-size: .9rem; }
.salir button { background: none; border: 1px solid #6c7a72; color: #fff; border-radius: 6px; padding: 5px 10px; cursor: pointer; font: inherit; }

.entrar { max-width: 340px; margin: 12vh auto 0; background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 28px; display: grid; gap: 14px; }
.entrar h1 { margin: 0; } .entrar .bajada { margin: -10px 0 0; }
.entrar label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
input { font: inherit; color: inherit; border: 1px solid #b9b4a8; border-radius: 6px; padding: 8px 10px; background: #fff; min-width: 0; }
input:disabled { background: #f1efe9; color: var(--tinta); opacity: 1; -webkit-text-fill-color: var(--tinta); }
button, .boton { font: inherit; cursor: pointer; border-radius: 6px; padding: 8px 14px; border: 1px solid #b9b4a8; background: #fff; color: var(--tinta); text-decoration: none; display: inline-block; }
button.primario { background: var(--verde); border-color: var(--verde); color: #fff; font-weight: 600; padding: 10px; }
.aviso { background: var(--rojo-suave); color: var(--rojo); border-radius: 6px; padding: 8px 12px; margin: 0; }
.aviso.suave { background: var(--ambar); color: #5c4700; margin-bottom: 12px; }
.bajada, .tenue { color: var(--tenue); }
.vacio { text-align: center; padding: 48px 16px; color: var(--tenue); }
.vacio h1 { color: var(--tinta); font-size: 1.2rem; }

.encabezado { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.fecha-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fecha-nav form { margin: 0; }
.flecha { text-decoration: none; border: 1px solid #b9b4a8; background: #fff; border-radius: 6px; padding: 7px 12px; color: var(--tinta); }
.fecha-texto { font-size: 1.1rem; }
.total-dia { margin-left: auto; color: var(--tenue); }
.total-dia strong { color: var(--tinta); font-size: 1.35rem; margin-left: 6px; }

.grilla { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.suc { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px; }
.suc-cabeza { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.suc h2 { margin: 0; font-size: 1.15rem; }
.no-trabajo { font-size: .9rem; color: var(--tenue); display: flex; align-items: center; gap: 6px; }
.suc.cerrada { background: #ebe8e1; }
.suc.cerrada .suc-cuerpo { opacity: .35; pointer-events: none; }
.medios { width: 100%; border-collapse: collapse; table-layout: fixed; }
.medios th:nth-child(1) { width: 21%; } .medios th:nth-child(2) { width: 23%; } .medios th:nth-child(3) { width: 20%; }
.medios th:nth-child(4) { width: 20%; } .medios th:nth-child(5) { width: 16%; }
.medios th, .medios td { padding: 3px 4px; text-align: right; }
.medios thead th { font-size: .75rem; font-weight: 600; color: var(--tenue); text-transform: uppercase; letter-spacing: .03em; }
.medios tbody th, .medios tfoot th { text-align: left; font-weight: 600; padding-right: 6px; line-height: 1.15; }
.medios input { width: 100%; text-align: right; padding-left: 6px; padding-right: 6px; }
.medios input.nota { text-align: left; }
.medios td.real { font-weight: 600; white-space: nowrap; }
.medios td.real.aparte { color: var(--tenue); font-weight: 400; }
.medios th small { display: block; font-weight: 400; font-size: .7rem; color: var(--tenue); }
.medios tfoot th small { display: inline; font-size: .75rem; }
.medios tfoot td, .medios tfoot th { border-top: 2px solid var(--tinta); padding-top: 8px; font-size: 1.1rem; }
input.dif:not(:placeholder-shown) { background: var(--ambar); }
input.error { border-color: var(--rojo); background: var(--rojo-suave); }
input.guardado { border-color: var(--verde); }

.gastos { margin-top: 12px; border-top: 1px solid var(--linea); padding-top: 8px; }
.gastos h3 { margin: 0 0 6px; font-size: .9rem; display: flex; justify-content: space-between; }
.gastos ul { list-style: none; margin: 0 0 6px; padding: 0; }
.gastos li { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px dotted var(--linea); }
.gastos li .concepto { flex: 1; overflow-wrap: anywhere; }
.gastos .quitar { border: none; background: none; color: var(--rojo); font-size: 1.2rem; line-height: 1; padding: 2px 8px; }
.nuevo-gasto { display: grid; grid-template-columns: 1fr 8em auto; gap: 6px; margin: 0; }
.nuevo-gasto .monto { text-align: right; }
.pie { display: grid; grid-template-columns: 1fr 9em; gap: 10px; margin-top: 12px; }
.pie label { display: grid; gap: 3px; font-size: .8rem; font-weight: 600; color: var(--tenue); }
.pie .monto { text-align: right; }
.estado { min-height: 1.3em; margin: 6px 0 0; font-size: .85rem; color: var(--verde); }
.estado.mal { color: var(--rojo); font-weight: 600; }

.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.tarjeta { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 12px 14px; display: grid; gap: 2px; }
.tarjeta span { color: var(--tenue); font-size: .85rem; }
.tarjeta strong { font-size: 1.3rem; }
.tarjeta em { font-style: normal; color: var(--tenue); font-size: .8rem; }
.tarjetas.principal .tarjeta:first-child { background: var(--verde); border-color: var(--verde); color: #fff; }
.tarjetas.principal .tarjeta:first-child span, .tarjetas.principal .tarjeta:first-child em { color: #d6ebdf; }
.tarjetas.principal .tarjeta:first-child strong { font-size: 1.7rem; }
.tabla-ancha { overflow-x: auto; background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); }
table.dias { width: 100%; border-collapse: collapse; white-space: nowrap; }
table.dias th, table.dias td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--linea); }
table.dias thead th { font-size: .8rem; color: var(--tenue); background: #f1efe9; }
table.dias th:first-child, table.dias.cambios td, table.dias.cambios th { text-align: left; }
table.dias td.total, table.dias tfoot { font-weight: 700; }
table.dias tfoot td, table.dias tfoot th { border-top: 2px solid var(--tinta); border-bottom: none; }
table.dias.cambios td { white-space: normal; overflow-wrap: anywhere; }
table.dias.cambios tr.alerta td { background: var(--ambar); }

@media (max-width: 1100px) { .grilla { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .total-dia { margin-left: 0; } }
@media (max-width: 520px) {
  main { padding: 8px; }
  .suc { padding: 10px; }
  .barra { gap: 8px 14px; padding: 8px 10px; }
  .medios thead th:nth-child(5), .medios td:nth-child(5) { display: none; }
  .medios th:nth-child(1) { width: 22%; } .medios th:nth-child(2) { width: 27%; } .medios th:nth-child(3) { width: 25%; } .medios th:nth-child(4) { width: 26%; }
  .medios th, .medios td { padding: 3px 2px; }
  .medios tbody th, .medios tfoot th { font-size: .85rem; }
  .medios input { padding: 7px 2px; font-size: 13px; letter-spacing: -.03em; }
  .medios td.real { font-size: .9rem; letter-spacing: -.02em; }
  .medios tfoot td, .medios tfoot th { font-size: 1rem; }
  .nuevo-gasto { grid-template-columns: 1fr 6.5em; }
  .nuevo-gasto button { grid-column: 1 / -1; }
  .pie { grid-template-columns: 1fr 7.5em; }
}

/* ---- La hoja para imprimir: A4 apaisada, como la de papel ----
   El margen lo pone la propia hoja (12 mm) y no la impresora: así sale igual en cualquier
   impresora y con cualquier ajuste de márgenes, y nunca se corta la fecha de arriba. */
@page { size: A4 landscape; margin: 0; }
body.hoja { background: #fff; font: 10pt/1.15 Arial, Helvetica, sans-serif; margin: 0 auto; padding: 12mm; width: 297mm; }
.hoja-cabeza { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 8mm; margin-bottom: 3mm; }
.hoja-cabeza .fecha { border: 1.5px solid #000; padding: 1mm 3mm; display: flex; gap: 4mm; align-items: baseline; }
.hoja-cabeza .fecha strong { font-size: 13pt; }
.hoja-grilla { display: grid; grid-template-columns: 1fr 1fr; gap: 4mm 6mm; --alto: 5.6mm; --letra: 10pt; }
.filas-5 { --alto: 5.60mm; --letra: 10.0pt; }
.filas-6 { --alto: 5.25mm; --letra: 9.5pt; }
.filas-7 { --alto: 4.94mm; --letra: 8.9pt; }
.filas-8 { --alto: 4.67mm; --letra: 8.4pt; }
.filas-9 { --alto: 4.42mm; --letra: 8.0pt; }
.filas-10 { --alto: 4.20mm; --letra: 7.6pt; }
.filas-11 { --alto: 4.00mm; --letra: 7.2pt; }
.filas-12 { --alto: 3.82mm; --letra: 6.9pt; }
.filas-13 { --alto: 3.65mm; --letra: 6.6pt; }
.filas-14 { --alto: 3.50mm; --letra: 6.5pt; }
body.hoja .suc { border: none; border-radius: 0; padding: 0; background: none; position: relative; break-inside: avoid; }
body.hoja .suc h2 { margin: 0; font-size: var(--letra); line-height: 1; height: var(--alto); display: flex; align-items: center; justify-content: center; background: #dcdcdc; border: 1.5px solid #000; border-bottom: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
body.hoja table { width: 100%; border-collapse: collapse; table-layout: fixed; }
body.hoja th, body.hoja td { border: 1.5px solid #000; padding: 0 1.5mm; height: var(--alto); line-height: 1; text-align: left; font-size: var(--letra); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
body.hoja thead th { text-align: center; font-size: calc(var(--letra) * .95); }
body.hoja tbody th { font-weight: normal; width: 27%; }
body.hoja tr.tot th, body.hoja tr.tot td { font-weight: bold; }
body.hoja tr.tot th { width: auto; } body.hoja tr.tot small { font-weight: normal; font-size: .8em; }
body.hoja td.concepto { width: 50%; }
body.hoja .suc.tachada::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top right, transparent calc(50% - 1px), #000 calc(50% - 1px), #000 calc(50% + 1px), transparent calc(50% + 1px)); pointer-events: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
@media screen { body.hoja { box-shadow: 0 0 0 1px #ccc; margin-top: 12px; } }
@media print { .no-imprimir { display: none; } }
