:root {
  --azul: #1f4e8c; --azul-osc: #163a69; --azul-claro: #e8f0fb;
  --verde: #2e7d32; --rojo: #c62828; --naranja: #ef6c00;
  --gris: #6b7280; --borde: #d6dce5; --fondo: #f4f6f9; --blanco: #fff;
  --radio: 12px; --sombra: 0 2px 8px rgba(20,40,80,.08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, "Segoe UI", Roboto, sans-serif; font-size: 18px;
       background: var(--fondo); color: #1c2430; }
header { background: var(--azul); color: #fff; display: flex; align-items: center; gap: 16px;
         padding: 10px 16px; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.logo { font-weight: 800; font-size: 22px; letter-spacing: 1px; }
nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav button { background: transparent; color: #fff; border: 0; font-size: 17px; padding: 10px 14px;
             border-radius: 10px; cursor: pointer; }
nav button.activo, nav button:hover { background: rgba(255,255,255,.18); }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 80px; }
h1 { font-size: 26px; margin: 4px 0 16px; color: var(--azul-osc); }
h2 { font-size: 20px; margin: 0 0 12px; color: var(--azul-osc); }
.tarjeta { background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra);
           padding: 18px; margin-bottom: 16px; }
.fila { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
label { display: flex; flex-direction: column; font-size: 14px; color: var(--gris); gap: 4px; }
input, select, textarea { font-size: 18px; padding: 12px; border: 1px solid var(--borde);
                          border-radius: 10px; background: #fff; font-family: inherit; }
textarea { min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--azul-claro); border-color: var(--azul); }
.btn { font-size: 18px; font-weight: 600; padding: 14px 22px; border: 0; border-radius: 12px;
       background: var(--azul); color: #fff; cursor: pointer; min-height: 52px; }
.btn:hover { background: var(--azul-osc); }
.btn.sec { background: #fff; color: var(--azul); border: 2px solid var(--azul); }
.btn.verde { background: var(--verde); } .btn.rojo { background: var(--rojo); }
.btn.peq { font-size: 15px; padding: 8px 14px; min-height: 40px; }
.buscador { display: flex; gap: 10px; }
.buscador input.matricula { min-width: 0; width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
html, body { overflow-x: hidden; }
.buscador input.matricula { flex: 1; font-size: 40px; text-align: center; font-weight: 800;
   letter-spacing: 6px; text-transform: uppercase; padding: 18px; border: 3px solid var(--azul);
   border-radius: 14px; font-family: "DIN Alternate", "Arial Narrow", sans-serif; }
.grandes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 16px; }
.grande { background: #fff; border: 0; border-radius: var(--radio); box-shadow: var(--sombra);
          padding: 26px 16px; font-size: 20px; font-weight: 700; color: var(--azul-osc); cursor: pointer; }
.grande span { display: block; font-size: 40px; margin-bottom: 8px; }
.grande small { display:block; font-weight:500; color: var(--gris); font-size:15px; margin-top:6px; }
.grande:hover { background: var(--azul-claro); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 14px; color: var(--gris); font-weight: 600; padding: 8px; border-bottom: 2px solid var(--borde); }
td { padding: 10px 8px; border-bottom: 1px solid var(--borde); }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover { background: var(--azul-claro); }
.chip { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 14px; font-weight: 700; }
.chip.abierta { background: #fff3e0; color: var(--naranja); }
.chip.terminada { background: #e8f5e9; color: var(--verde); }
.chip.facturada { background: var(--azul-claro); color: var(--azul); }
.chip.anulada { background: #fde8e8; color: var(--rojo); }
.placa { display:inline-block; background:#fff; border:3px solid #1c2430; border-radius:8px; padding:2px 12px 2px 6px;
         font-weight:800; letter-spacing:3px; font-size:24px; }
.placa::before { content:"E"; background:#1f4fa8; color:#fff; font-size:13px; padding:8px 5px; margin-right:8px; border-radius:3px; vertical-align: middle; }
.totales { margin-left: auto; min-width: 260px; }
.totales div { display: flex; justify-content: space-between; padding: 4px 0; }
.totales .total { font-size: 26px; font-weight: 800; color: var(--azul-osc); border-top: 2px solid var(--borde); margin-top: 6px; padding-top: 8px; }
.vacio { color: var(--gris); text-align: center; padding: 24px; }
.bajo { color: var(--rojo); font-weight: 700; }
#aviso { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c2430; color:#fff;
         padding: 14px 22px; border-radius: 12px; font-size: 17px; opacity: 0; transition: opacity .3s; pointer-events:none; z-index: 20; }
#aviso.ver { opacity: 1; } #aviso.error { background: var(--rojo); }
dialog { border: 0; border-radius: 16px; padding: 0; width: min(640px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,30,50,.45); }
#modal-cuerpo { padding: 22px; }
.acciones { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.resultados { max-height: 300px; overflow: auto; margin-top: 10px; }
@media (max-width: 640px) {
  body { font-size: 16px; } .buscador { flex-direction: column; } .buscador input.matricula { font-size: 30px; letter-spacing: 3px; }
  table { font-size: 15px; } .tarjeta { padding: 14px; }
  nav button { font-size: 15px; padding: 8px 10px; } .hide-m { display: none; }
}

.kpi { font-size: 24px; font-weight: 800; color: var(--azul-osc); }
.lbl-k { font-size: 14px; color: var(--gris); }

#b-apagar { position: fixed; left: 0; bottom: 90px; z-index: 6; border: 0; cursor: pointer;
            background: #5f6b7a; color: #fff; font-size: 13px; padding: 8px 10px 8px 8px;
            border-radius: 0 10px 10px 0; opacity: .6; }
#b-apagar:hover { opacity: 1; background: var(--rojo); }

/* Albaranes */
.globo { background: var(--rojo); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 13px; font-weight: 700; margin-left: 4px; }
.alb-cuerpo { display: flex; gap: 16px; align-items: flex-start; }
.alb-foto { flex: 0 0 30%; position: sticky; top: 10px; margin: 0; max-height: 92vh; overflow: auto; }
#a-lineas input { font-size: 16px; padding: 6px 8px; } #a-lineas input.n { text-align: right; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.grid2 label { display: flex; flex-direction: column; font-weight: 600; gap: 4px; }
.cargando { height: 6px; background: linear-gradient(90deg, var(--azul) 30%, var(--azul-claro) 30%); background-size: 200% 100%; animation: carga 1s linear infinite; border-radius: 3px; }
@keyframes carga { to { background-position: -200% 0; } }
@media (max-width: 800px) { .alb-cuerpo { flex-direction: column; } .alb-foto { position: static; flex: none; width: 100%; max-height: 50vh; } }

/* Importes ocultos hasta pulsar «Ver importes» */
.kpi.privado { filter: blur(12px); user-select: none; transition: filter .2s; }
body.ver-importes .kpi.privado { filter: none; user-select: auto; }
