/* Facturación STICON · hoja de estilos */

:root {
  --azul: #1e3a5f;
  --azul-claro: #2563eb;
  --texto: #1f2937;
  --gris: #6b7280;
  --fondo: #f5f7fa;
  --borde: #e2e8f0;
  --verde: #16a34a;
  --rojo: #dc2626;
  --naranja: #d97706;
  --amarillo: #fef3c7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  font-size: 15px;
  line-height: 1.45;
}

.contenedor { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* --- Cabecera --- */
.cabecera { background: var(--azul); color: #fff; padding: 10px 0; }
.cabecera-fila { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.marca { color: #fff; text-decoration: none; display: flex; align-items: baseline; gap: 8px; }
.marca strong { font-size: 20px; letter-spacing: 1px; }
.marca span { font-size: 12px; color: #cbd5e1; }
.menu { display: flex; gap: 4px; flex-wrap: wrap; }
.menu a {
  color: #e2e8f0; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: 14px;
}
.menu a:hover { background: rgba(255, 255, 255, 0.12); }
.menu a.salir { color: #fca5a5; }

.pie { margin-top: 40px; padding: 16px 0; color: var(--gris); font-size: 12px; border-top: 1px solid var(--borde); }

/* --- Estructura --- */
main.contenedor { padding-top: 24px; padding-bottom: 40px; }

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; color: var(--azul); }

.fila-titulo { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.fila-titulo h1 { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.acciones { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acciones form { display: inline; margin: 0; }

.tarjeta {
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.apagado { color: var(--gris); font-size: 13.5px; }
.oculto { display: none !important; }
.der { text-align: right; }
.centro { text-align: center; }

code { background: #eef2f7; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* --- Botones --- */
.boton {
  display: inline-block;
  background: var(--azul-claro);
  color: #fff;
  border: 1px solid var(--azul-claro);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}
.boton:hover { background: #1d4ed8; }
.boton.secundario { background: #fff; color: var(--azul); border-color: var(--borde); }
.boton.secundario:hover { background: #f1f5f9; }
.boton.peligro { background: #fff; color: var(--rojo); border-color: #fecaca; }
.boton.peligro:hover { background: #fef2f2; }
.boton-icono {
  border: none; background: none; color: var(--rojo); cursor: pointer; font-size: 14px; padding: 4px 6px;
}
.enlace { color: var(--azul-claro); text-decoration: none; font-size: 14px; }
.enlace:hover { text-decoration: underline; }

/* --- Formularios --- */
.formulario label { display: block; font-size: 13.5px; color: var(--texto); }
.formulario input[type="text"],
.formulario input[type="password"],
.formulario input[type="date"],
.formulario input[type="email"],
.formulario select,
.formulario textarea {
  width: 100%;
  padding: 7px 9px;
  margin-top: 3px;
  border: 1px solid var(--borde);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--texto);
}
.formulario input:focus, .formulario select:focus, .formulario textarea:focus {
  outline: 2px solid #bfdbfe; border-color: var(--azul-claro);
}
.rejilla-dos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin-bottom: 10px; }
.rejilla-tres { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px; margin-bottom: 10px; }
.ancho-completo { grid-column: 1 / -1; }
.ancho-doble { grid-column: span 2; }
.casillas { display: flex; gap: 18px; flex-wrap: wrap; margin: 10px 0; }
.casilla { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.casilla input { width: auto; }

.buscador { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.buscador input[type="text"] {
  flex: 1; min-width: 220px; padding: 8px 10px; border: 1px solid var(--borde); border-radius: 8px; font-size: 14px;
}
.buscador select { padding: 8px 10px; border: 1px solid var(--borde); border-radius: 8px; font-size: 14px; }

/* --- Tablas --- */
.tabla { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; }
.tabla th, .tabla td { padding: 8px 10px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.tabla th { background: #f1f5f9; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--gris); }
.tabla tr:last-child td { border-bottom: none; }
.tabla tr.inactivo td { opacity: 0.55; }
.tabla a { color: var(--azul-claro); text-decoration: none; }
.tabla a:hover { text-decoration: underline; }
.acciones-fila { white-space: nowrap; display: flex; gap: 10px; }

.tabla-scroll { overflow-x: auto; }

/* --- Etiquetas y estados --- */
.etiqueta {
  display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
  background: #eef2f7; color: var(--gris); vertical-align: middle;
}
.etiqueta.azul { background: #dbeafe; color: #1d4ed8; }
.etiqueta.verde { background: #dcfce7; color: #15803d; }
.etiqueta.gris { background: #e5e7eb; color: #4b5563; }
.etiqueta.tipo-presupuesto { background: #fef9c3; color: #a16207; }
.etiqueta.tipo-pedido { background: #dbeafe; color: #1d4ed8; }
.etiqueta.tipo-factura { background: #dcfce7; color: #15803d; }

.estado { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.estado-borrador { background: #e5e7eb; color: #4b5563; }
.estado-enviado { background: #dbeafe; color: #1d4ed8; }
.estado-aprobado { background: #dcfce7; color: #15803d; }
.estado-rechazado { background: #fee2e2; color: #b91c1c; }
.estado-en-curso { background: #ffedd5; color: #c2410c; }
.estado-terminado { background: #dcfce7; color: #15803d; }
.estado-emitida { background: #dbeafe; color: #1d4ed8; }
.estado-cobrada { background: #dcfce7; color: #15803d; }

/* --- Avisos --- */
.aviso { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.aviso-ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.aviso-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.aviso-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.aviso a { color: inherit; font-weight: 600; }

/* --- Acceso --- */
.tarjeta-acceso { max-width: 380px; margin: 60px auto; }
.tarjeta-acceso h1 { text-align: center; }
.tarjeta-acceso label { margin-bottom: 12px; }
.tarjeta-acceso .boton { width: 100%; margin-top: 8px; }

/* --- Inicio --- */
.rejilla-cifras { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.tarjeta.cifra { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--texto); margin: 0; }
.tarjeta.cifra .numero { font-size: 22px; font-weight: 700; color: var(--azul); }
.tarjeta.cifra .rotulo { font-size: 12.5px; color: var(--gris); }
a.tarjeta.cifra:hover { border-color: var(--azul-claro); }

/* --- Pestañas --- */
.pestanas { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 2px solid var(--borde); }
.pestanas a {
  padding: 8px 14px; text-decoration: none; color: var(--gris); font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.pestanas a.activa { color: var(--azul); border-bottom-color: var(--azul); font-weight: 600; }
.pestanas-boton button {
  padding: 8px 14px; text-decoration: none; color: var(--gris); font-size: 14px;
  border: none; background: none; cursor: pointer; font-family: inherit;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.pestanas-boton button.activa { color: var(--azul); border-bottom-color: var(--azul); font-weight: 600; }

/* --- Editor de documento --- */
.tabla-lineas { border-radius: 8px; }
.tabla-lineas th, .tabla-lineas td { padding: 4px 5px; font-size: 13px; }
.tabla-lineas input, .tabla-lineas select {
  width: 100%; padding: 5px 6px; border: 1px solid var(--borde); border-radius: 6px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--texto);
}
.tabla-lineas input:focus, .tabla-lineas select:focus { outline: 2px solid #bfdbfe; border-color: var(--azul-claro); }
.tabla-lineas .num-fila { color: var(--gris); text-align: center; }
.w-num { width: 34px; } .w-producto { width: 300px; } .w-cant { width: 58px; } .w-ud { width: 104px; }
.w-importe { width: 88px; } .importe-linea { font-size: 13px; white-space: nowrap; }
.w-precio { width: 82px; } .w-dto { width: 58px; } .w-tipo { width: 52px; } .w-iva { width: 58px; }
.w-coste { width: 72px; } .w-part { width: 68px; } .w-sub { width: 68px; } .w-x { width: 36px; }

/* Cada línea es un bloque de dos filas: datos arriba y descripción/marcadores abajo */
.tabla-lineas .fila-principal td { border-bottom: none; }
.tabla-lineas .celda-quitar { vertical-align: middle; }
.detalle-linea { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.detalle-linea .descripcion { flex: 1 1 320px; min-width: 200px; }
.marca-linea {
  display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--gris); white-space: nowrap;
}
.marca-linea select { width: auto; }

/* Partida y subpartida destacadas, y separador visual entre grupos de partidas */
.tabla-lineas .partida, .tabla-lineas .subpartida { background: #eef4ff; font-weight: 600; }
.tabla-lineas .linea.inicio-grupo tr.fila-principal td { border-top: 3px solid var(--azul); }

/* Líneas marcadas como opcionales: fondo amarillo suave */
.tabla-lineas .linea.fila-opcional td { background: #fef9e7; }
.tabla-lineas .linea.fila-opcional input, .tabla-lineas .linea.fila-opcional select { background: #fef9e7; }

/* Líneas con FACT = No (apuntes internos de gastos): fondo gris */
.tabla-lineas .linea.fila-sin-facturar td { background: #f3f4f6; }
.tabla-lineas .linea.fila-sin-facturar input, .tabla-lineas .linea.fila-sin-facturar select { background: #f3f4f6; }

/* Selector en línea (formato del PDF) */
.fila-inline { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.fila-inline select { width: auto; }

/* Menú desplegable (facturas del pedido) */
.menu-desplegable { position: relative; display: inline-block; }
.menu-contenido {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
  background: #fff; border: 1px solid var(--borde); border-radius: 8px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12); min-width: 240px; padding: 6px;
}
.menu-contenido a {
  display: block; padding: 6px 10px; border-radius: 6px;
  color: var(--texto); text-decoration: none; font-size: 13.5px;
}
.menu-contenido a:hover { background: #f1f5f9; }
.menu-contenido a.pdf { color: var(--azul-claro); font-size: 12.5px; }

/* Estado «rectificada» */
.estado-rectificada { background: #e5e7eb; color: #374151; text-decoration: line-through; }

/* Factura emitida con registro VeriFactu: datos bloqueados (solo estado y campos internos) */
.bloqueado .tarjeta input, .bloqueado .tarjeta select, .bloqueado .tarjeta textarea {
  pointer-events: none; background: #f1f5f9; color: #475569;
}
.bloqueado .tarjeta .permitido input, .bloqueado .tarjeta .permitido select,
.bloqueado .tarjeta .permitido textarea {
  pointer-events: auto; background: #fff; color: inherit;
}
.bloqueado .tabla-lineas input, .bloqueado .tabla-lineas select,
.bloqueado .tabla-lineas button {
  pointer-events: none;
}

/* Huella VeriFactu (columna de la pantalla de registros) */
.huella { font-family: Consolas, 'Courier New', monospace; font-size: 12px; }

/* Ventana de productos (subventana para elegir y añadir un producto) */
.modal-fondo {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-caja {
  background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(15, 23, 42, 0.25);
  width: 560px; max-width: 100%; max-height: 80vh; display: flex; flex-direction: column;
  padding: 16px 18px;
}
.modal-cabecera { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-cabecera h3 { margin: 0; }
.modal-caja input[type="text"] {
  padding: 8px 10px; border: 1px solid var(--borde); border-radius: 8px; font-size: 14px; margin-bottom: 10px;
}
.modal-lista { overflow-y: auto; flex: 1; }
.producto-fila {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 1px solid var(--borde); border-radius: 8px; margin-bottom: 6px;
  background: #fff; cursor: pointer; font-size: 14px; text-align: left;
}
.producto-fila:hover { background: #f1f5f9; border-color: var(--azul-claro); }
.pf-nombre { font-weight: 600; }
.pf-precio { color: var(--gris); font-size: 12.5px; }

/* Aviso de cambios sin guardar */
.aviso-cambios { color: #b45309; font-size: 13.5px; margin-right: 12px; font-weight: 600; }

/* Logo en la pantalla de configuración */
.logo-fila { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.logo-preview { max-height: 70px; max-width: 220px; border: 1px solid var(--borde); border-radius: 6px; padding: 6px; background: #fff; }
.formulario input[type="file"] { margin-top: 3px; font-size: 14px; }

/* Contactos en la ficha de empresa */
.tabla-contactos th, .tabla-contactos td { padding: 4px 5px; }
.tabla-contactos input { width: 100%; padding: 5px 6px; border: 1px solid var(--borde); border-radius: 6px; font-size: 13px; font-family: inherit; }
.tabla-contactos input:focus { outline: 2px solid #bfdbfe; border-color: var(--azul-claro); }

/* Bloque desplegable (datos FACe) */
.bloque-detalle { border: 1px solid var(--borde); border-radius: 8px; padding: 10px 14px; margin: 12px 0; background: #fbfdff; }
.bloque-detalle summary { cursor: pointer; font-weight: 600; color: var(--azul); }

/* Separadores por tipo de documento en el listado «Todos» */
.tabla tr.separador-tipo td {
  background: #f3f4f6;
  color: var(--azul);
  font-weight: 700;
  font-size: 13.5px;
}
.tabla tr.separador-tipo .contador { color: var(--gris); font-weight: 600; }

/* Separadores por mes en los listados de un tipo de documento */
.tabla tr.separador-mes td {
  background: #eef2f7;
  color: var(--azul);
  font-weight: 600;
  font-size: 13px;
  border-top: 1px solid var(--borde);
}
.tabla tr.separador-mes .contador { color: var(--gris); font-weight: 600; }

/* Importes que requieren atención (pendiente distinto de 0, beneficio negativo) */
.aviso-rojo { color: #b91c1c; font-weight: 600; }

/* Identidad por tipo de documento (franja superior del editor) */
.franja-tipo { height: 6px; border-radius: 3px; margin: 0 0 14px 0; }
.franja-presupuesto { background: #facc15; }
.franja-proforma { background: #8b5cf6; }
.franja-pedido { background: #2563eb; }
.franja-factura { background: #16a34a; }
.etiqueta.tipo-proforma { background: #ede9fe; color: #6d28d9; }

/* Barra de progreso de facturación de un pedido */
.barra-progreso { height: 8px; background: #e5e7eb; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.barra-progreso .relleno { height: 100%; background: var(--verde); border-radius: 4px; }

/* Pie del editor: campos secundarios a la izquierda y totales a la derecha */
.pie-editor { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.campos-pie { flex: 1 1 340px; min-width: 0; }
.campos-pie label { margin-bottom: 12px; }

/* Nota interna: se remarca cuando tiene contenido (editor y listado) */
.nota-con-contenido { color: #b45309; font-weight: 600; }
.nota-con-contenido textarea { background: #fffbeb; border-color: #f59e0b; }
.nota-interna-marca { color: #b45309; font-size: 12px; font-weight: 600; }

/* Presupuesto ya convertido en pedido (listado) */
.pedido-convertido { font-size: 12px; font-weight: 600; }
.pedido-convertido a { color: #15803d; text-decoration: none; }

/* Desplegable propio (partida/subpartida): al abrirse muestra todas las opciones */
.combo { position: relative; }
.combo-flecha {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; color: var(--gris); cursor: pointer;
  font-size: 13px; padding: 2px 6px; line-height: 1;
}
.combo-lista {
  position: absolute; left: 0; right: 0; top: calc(100% + 3px); z-index: 60;
  background: #fff; border: 1px solid var(--borde); border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14); max-height: 220px; overflow-y: auto;
}
.combo-opcion {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  border: none; background: none; cursor: pointer; font-size: 14px; color: var(--texto);
}
.combo-opcion:hover { background: #f1f5f9; }
.combo-vacio { padding: 7px 10px; color: var(--gris); font-size: 13px; }

.resumen-cuadro { max-width: 480px; margin-left: auto; }
.resumen-fila { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.resumen-fila input { width: 90px; padding: 6px 8px; border: 1px solid var(--borde); border-radius: 6px; text-align: right; font-size: 14px; }
.resumen-fila select { padding: 6px 8px; border: 1px solid var(--borde); border-radius: 6px; font-size: 14px; }

.tabla-totales { width: 100%; border-collapse: collapse; }
.tabla-totales td { padding: 4px 2px; font-size: 14px; border: none; }
.tabla-totales .total td { border-top: 2px solid var(--azul); font-size: 17px; font-weight: 700; color: var(--azul); padding-top: 8px; }
.tabla-totales .der { text-align: right; }

.opcionales { margin-top: 8px; font-size: 13.5px; background: var(--amarillo); border: 1px solid #fde68a; padding: 8px 10px; border-radius: 8px; }
.interno {
  margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--borde);
  font-size: 13px; color: var(--gris); display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end;
}

/* --- Adaptación a pantallas pequeñas --- */
@media (max-width: 900px) {
  .rejilla-cifras { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rejilla-dos, .rejilla-tres { grid-template-columns: 1fr; }
  .ancho-doble { grid-column: auto; }
}
