/* ============================================================
   ESTILOS - Facturación Fontaneros Solcrisal
   Colores de empresa:
     Azul marino: #0a3d62
     Amarillo:    #f0c22a
   ============================================================ */

:root {
  --azul: #0a3d62;
  --azul-claro: #12507f;
  --amarillo: #f0c22a;
  --amarillo-oscuro: #d9ac16;
  --gris-fondo: #eef2f5;
  --gris-borde: #d4dbe0;
  --verde-ok: #27ae60;
  --rojo: #c0392b;
  --texto: #1c2b36;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  background: var(--gris-fondo);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

/* ===========================================================
   VISTA RÁPIDA (ventana pequeña)
   =========================================================== */

body.rapida {
  background: var(--azul);
}

.app {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  min-height: 100vh;
  max-width: 520px;
  margin: 0 auto;
}

.cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.cabecera h1 {
  color: #fff;
  font-size: 15px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.cabecera .enlaces {
  display: flex;
  gap: 6px;
}

.btn-mini {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.btn-mini:hover { background: rgba(255, 255, 255, 0.28); }

/* Rejilla de botones de fontaneros */
.fontaneros {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.btn-fontanero {
  background: #fff;
  color: var(--azul);
  font-size: 15px;
  font-weight: 700;
  padding: 12px 6px;
  border-radius: 10px;
  border: 3px solid transparent;
  min-height: 48px;
  transition: transform 0.05s ease;
}
.btn-fontanero:active { transform: scale(0.97); }

.btn-fontanero.seleccionado {
  background: var(--amarillo);
  color: var(--azul);
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--amarillo);
}

/* Campo de importe */
.importe-fila {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border-radius: 10px;
  padding: 4px 10px;
}
.importe-fila .euro {
  font-size: 22px;
  font-weight: 700;
  color: var(--azul);
}
#importe {
  flex: 1;
  border: none;
  outline: none;
  font-size: 30px;
  font-weight: 700;
  color: var(--azul);
  width: 100%;
  padding: 8px 0;
  text-align: right;
  background: transparent;
}

/* Botón Añadir */
.btn-anadir {
  background: var(--amarillo);
  color: var(--azul);
  font-size: 20px;
  font-weight: 800;
  padding: 16px;
  border-radius: 12px;
  min-height: 56px;
}
.btn-anadir:active { background: var(--amarillo-oscuro); }
.btn-anadir:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Fila inferior: deshacer */
.acciones {
  display: flex;
  gap: 6px;
}
.btn-deshacer {
  flex: 1;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 10px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}
.btn-deshacer:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Aviso del fontanero seleccionado */
.seleccion-info {
  color: #fff;
  font-size: 13px;
  text-align: center;
  min-height: 18px;
  opacity: 0.9;
}
.seleccion-info b { color: var(--amarillo); }

/* Mensaje de confirmación (toast) */
#toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%) translateY(120%);
  background: var(--verde-ok);
  color: #fff;
  padding: 12px 20px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s ease;
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}
#toast.visible {
  transform: translateX(-50%) translateY(0);
}
#toast.error { background: var(--rojo); }

/* ===========================================================
   VISTA PANEL (pantalla completa)
   =========================================================== */

body.panel {
  background: var(--gris-fondo);
}

.panel-cabecera {
  background: var(--azul);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.panel-cabecera h1 {
  margin: 0;
  font-size: 20px;
}
.panel-cabecera h1 span { color: var(--amarillo); }

.contenedor {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* Filtros */
.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.btn-filtro {
  background: #fff;
  color: var(--azul);
  border: 2px solid var(--gris-borde);
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
}
.btn-filtro.activo {
  background: var(--azul);
  color: #fff;
  border-color: var(--azul);
}
.rango-personalizado {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.rango-personalizado input[type="date"] {
  padding: 8px;
  border: 2px solid var(--gris-borde);
  border-radius: 8px;
  font-size: 14px;
}
.rango-personalizado button {
  background: var(--amarillo);
  color: var(--azul);
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
}

/* Tarjetas de totales */
.totales {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.tarjeta {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.tarjeta .etiqueta {
  font-size: 13px;
  color: #6b7a86;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tarjeta .valor {
  font-size: 28px;
  font-weight: 800;
  color: var(--azul);
  margin-top: 4px;
}

/* Secciones */
.seccion {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 20px;
}
.seccion h2 {
  margin: 0 0 14px;
  font-size: 17px;
  color: var(--azul);
}

/* Ranking */
.ranking-fila {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gris-borde);
}
.ranking-fila:last-child { border-bottom: none; }
.ranking-pos {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--azul);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.ranking-fila:first-child .ranking-pos { background: var(--amarillo); color: var(--azul); }
.ranking-nombre { flex: 1; font-weight: 600; }
.ranking-barra-fondo {
  flex: 2;
  height: 10px;
  background: var(--gris-fondo);
  border-radius: 5px;
  overflow: hidden;
}
.ranking-barra {
  height: 100%;
  background: var(--amarillo);
  border-radius: 5px;
}
.ranking-importe { font-weight: 800; color: var(--azul); min-width: 90px; text-align: right; }
.ranking-partes { font-size: 12px; color: #6b7a86; min-width: 70px; text-align: right; }

/* Gráficos */
.graficos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 720px) {
  .graficos { grid-template-columns: 1fr; }
}
.grafico-caja {
  position: relative;
  height: 280px;
}

/* Lista de registros */
table.registros {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.registros th,
table.registros td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--gris-borde);
}
table.registros th {
  color: #6b7a86;
  font-size: 12px;
  text-transform: uppercase;
}
table.registros td.importe-celda { font-weight: 700; color: var(--azul); }
.btn-tabla {
  background: none;
  border: 1px solid var(--gris-borde);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 13px;
  margin-right: 4px;
}
.btn-tabla.borrar { color: var(--rojo); border-color: #e6b3ad; }
.btn-tabla.editar { color: var(--azul); }

.cargando {
  text-align: center;
  color: #6b7a86;
  padding: 30px;
  font-style: italic;
}

/* Aviso de configuración pendiente */
.aviso-config {
  background: #fff3cd;
  border: 2px solid var(--amarillo);
  color: #7a5c00;
  padding: 14px;
  border-radius: 10px;
  margin: 10px 0;
  font-size: 14px;
  line-height: 1.5;
}
