* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, Arial, sans-serif; background: #f4f5f7; color: #1a1a1a; }
a { color: #2563eb; }

.topbar { display: flex; align-items: center; gap: 1.5rem; background: #111827; color: #fff; padding: 0.6rem 1.2rem; flex-wrap: wrap; }
.topbar .marca { font-weight: 700; }
.topbar nav { display: flex; gap: 0.9rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: #d1d5db; text-decoration: none; font-size: 0.92rem; padding: 0.2rem 0.4rem; border-radius: 4px; }
.topbar nav a:hover, .topbar nav a.activo { color: #fff; background: #1f2937; }
.topbar .usuario { font-size: 0.85rem; color: #9ca3af; }

.contenido { max-width: 1200px; margin: 1.2rem auto; padding: 0 1rem; }

.flash { padding: 0.6rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash-ok { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

table { width: 100%; border-collapse: collapse; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
th, td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid #e5e7eb; font-size: 0.9rem; }
th { background: #f9fafb; font-weight: 600; }
tr:hover td { background: #f9fafb; }

.barra-acciones { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; gap: 0.6rem; flex-wrap: wrap; }
.btn { display: inline-block; padding: 0.4rem 0.9rem; border-radius: 6px; background: #2563eb; color: #fff; text-decoration: none; border: none; cursor: pointer; font-size: 0.88rem; }
.btn:hover { background: #1d4ed8; }
.btn-secundario { background: #6b7280; }
.btn-secundario:hover { background: #4b5563; }
.btn-peligro { background: #dc2626; }
.btn-peligro:hover { background: #b91c1c; }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.76rem; background: #e5e7eb; color: #374151; }
.badge-local { background: #e5e7eb; color: #374151; }
.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-sincronizado { background: #dcfce7; color: #166534; }
.badge-conflicto { background: #fee2e2; color: #991b1b; }
.badge-error { background: #fee2e2; color: #991b1b; }

form.form-vertical { display: flex; flex-direction: column; gap: 0.7rem; max-width: 640px; background: #fff; padding: 1rem 1.2rem; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
form.form-vertical label { font-size: 0.85rem; font-weight: 600; display: flex; flex-direction: column; gap: 0.25rem; }
form.form-vertical input, form.form-vertical select, form.form-vertical textarea {
    padding: 0.4rem 0.5rem; border: 1px solid #d1d5db; border-radius: 5px; font-size: 0.9rem; font-family: inherit;
}
fieldset { border: 1px solid #e5e7eb; border-radius: 6px; }
legend { font-weight: 600; font-size: 0.85rem; padding: 0 0.4rem; }

.grid-dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1rem; }
.tarjeta { background: #fff; border-radius: 8px; padding: 1rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.tarjeta h2 { margin-top: 0; font-size: 1rem; }

.kpis { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.kpi { background: #fff; border-radius: 8px; padding: 0.8rem 1.2rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); min-width: 160px; }
.kpi .valor { font-size: 1.5rem; font-weight: 700; }
.kpi .etiqueta { font-size: 0.8rem; color: #6b7280; }

.login-box { max-width: 360px; margin: 4rem auto; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tabs a { padding: 0.35rem 0.8rem; border-radius: 6px; text-decoration: none; color: #374151; background: #e5e7eb; font-size: 0.86rem; }
.tabs a.activo { background: #2563eb; color: #fff; }

.barra-carga { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 3px; background: #e5e7eb; z-index: 9999; overflow: hidden; }
body.cargando .barra-carga { display: block; }
.barra-carga::after {
    content: ''; position: absolute; top: 0; left: -40%; height: 100%; width: 40%;
    background: #2563eb; animation: barra-carga-mov 1s ease-in-out infinite;
}
@keyframes barra-carga-mov {
    0% { left: -40%; }
    100% { left: 100%; }
}

/* Configurador de reparaciones: layout tipo carrito (editor a la izquierda, resumen fijo a la derecha) */
.config-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; align-items: start; }
@media (max-width: 900px) {
    .config-layout { grid-template-columns: 1fr; }
}

.resumen-precio { position: sticky; top: 1rem; background: #fff; border-radius: 8px; padding: 1.2rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.resumen-precio h2 { margin-top: 0; font-size: 1rem; }
.resumen-precio .linea { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.88rem; padding: 0.4rem 0; border-bottom: 1px solid #f3f4f6; }
.resumen-precio .linea.subtotal { border-top: 1px solid #e5e7eb; border-bottom: none; margin-top: 0.2rem; padding-top: 0.6rem; font-weight: 600; }
.resumen-precio .precio-final { text-align: center; margin: 1rem 0 0.6rem; padding: 1rem; background: #eff6ff; border-radius: 8px; }
.resumen-precio .precio-final .etiqueta { font-size: 0.74rem; color: #6b7280; text-transform: uppercase; letter-spacing: .05em; }
.resumen-precio .precio-final .valor { font-size: 2.1rem; font-weight: 800; color: #1d4ed8; line-height: 1.15; }
.resumen-precio form.form-vertical { box-shadow: none; padding: 0; max-width: none; margin-top: 0.8rem; }

.tabla-editable td { vertical-align: middle; }
.tabla-editable input { border: 1px solid transparent; background: transparent; padding: 0.3rem 0.4rem; border-radius: 4px; font-size: 0.88rem; width: 100%; font-family: inherit; }
.tabla-editable input:hover { border-color: #e5e7eb; }
.tabla-editable input:focus { border-color: #2563eb; background: #fff; outline: none; }
.tabla-editable tr.fila-subtotal td { font-weight: 600; background: #f9fafb; border-top: 1px solid #e5e7eb; }
.btn-icono { background: none; border: none; color: #9ca3af; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0.2rem 0.5rem; }
.btn-icono:hover { color: #dc2626; }
