body { font-family: sans-serif; background-color: #f4f4f4; margin: 0; }

/* Breadcrumb */
.breadcrumb {
    padding: 12px 24px;
    background: #fff;
    color: #999;
    font-size: 0.9em;
    border-bottom: 1px solid #eee;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.breadcrumb a { color: #dc3545; text-decoration: none; font-weight: 500; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb strong { color: #333; }
.sesion-info { float: right; color: #999; }
.sesion-info a { color: #dc3545; text-decoration: none; font-weight: 500; }
.sesion-info a:hover { text-decoration: underline; }

/* Encabezado de página (ícono + título), reutilizado en todas las páginas internas */
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.etapas-header .page-header { margin-bottom: 0; }
.page-header-icono {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    background: #fff3ec;
    color: #dc3545;
    display: flex;
    align-items: center;
    justify-content: center;
}
.page-header h2 { margin: 0; }

.botonera-header { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Logo / header de inicio */
.logo-container { background-color: #dc3545; color: white; padding: 40px 20px; }
.logo-header-contenido { display: flex; align-items: center; justify-content: center; gap: 20px; max-width: 900px; margin: auto; }
.logo-container h1 { margin: 0; font-size: 2.4em; letter-spacing: 4px; }
.subtitulo-home { margin: 4px 0 0; opacity: 0.85; letter-spacing: 1px; font-size: 0.95em; }
.logo-container img { max-height: 64px; }

.logo-fallback-grande {
    width: 64px;
    height: 64px;
    min-width: 64px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Accesos de la portada */
.home-container { max-width: 900px; margin: auto; padding: 30px 40px 60px; }

.grupo-accesos { margin-bottom: 30px; }
.titulo-grupo {
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #888;
    margin: 0 0 12px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 6px;
}

.tarjetas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.tarjeta-acceso {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    font-size: 1em;
    text-align: left;
    border-radius: 8px;
    background: white;
    color: #333;
    border: 2px solid #eee;
    cursor: pointer;
    transition: 0.2s;
}
.tarjeta-acceso:hover { border-color: #dc3545; box-shadow: 0 2px 8px rgba(220, 53, 69, 0.15); }

.tarjeta-icono {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #fff3ec;
    color: #dc3545;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tarjeta-texto { display: flex; flex-direction: column; gap: 3px; }
.tarjeta-texto strong { color: #222; font-size: 1.02em; }
.tarjeta-texto small { color: #888; font-size: 0.85em; }

/* Contenedor general de páginas internas */
.container { max-width: 900px; margin: auto; padding: 20px 40px 60px; }

.panel {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #eee;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

#datosGenerales { display: flex; gap: 30px; flex-wrap: wrap; }
#datosGenerales label { display: flex; flex-direction: column; font-size: 0.9em; color: #555; gap: 4px; }
#datosGenerales input { padding: 8px; border: 1px solid #ccc; border-radius: 4px; }

/* Categorías / procesos */
.categoria-bloque { margin-bottom: 10px; }

.btn-categoria {
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    background: white;
    border: 2px solid #dc3545;
    color: #dc3545;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: 0.2s;
}
.btn-categoria:hover { background: #dc3545; color: white; }

.lista-procesos {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 4px 4px 16px;
}

.btn-proceso {
    padding: 8px 14px;
    border: 1px solid #dc3545;
    background: #fff5f5;
    color: #333;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
}
.btn-proceso:hover { background: #dc3545; color: white; }

.btn-terciarizado {
    padding: 8px 14px;
    border: 1px solid #dc3545;
    background: #fff5f5;
    color: #333;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
}
.btn-terciarizado:hover { background: #dc3545; color: white; }

.oculto { display: none !important; }

/* Etapas */
.etapas-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 15px; }
.etapas-header .btn-secundario { background: #eee; color: #333; }

.etapas-header button, #btnNuevaEtapa {
    padding: 10px 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.etapas-header button:hover { background: #218838; }

.etapa-bloque { border: 1px solid #eee; border-radius: 6px; padding: 15px; margin-bottom: 15px; }
.etapa-header { display: flex; justify-content: space-between; align-items: center; }
.etapa-header h4 { margin: 0; color: #333; }

.tabla-etapa { width: 100%; border-collapse: collapse; margin-top: 10px; }
.tabla-etapa th, .tabla-etapa td { border: 1px solid #ddd; padding: 8px; text-align: left; font-size: 0.9em; }
.tabla-etapa th { background: #f8f8f8; }

.etapa-subtotal { text-align: right; margin-top: 8px; font-weight: bold; color: #dc3545; }

.etapa-notas {
    width: 100%;
    box-sizing: border-box;
    margin-top: 10px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    resize: vertical;
    min-height: 50px;
}
.etapa-notas-texto { margin-top: 10px; color: #555; font-style: italic; }

.btn-eliminar {
    background: transparent;
    border: 1px solid #dc3545;
    color: #dc3545;
    border-radius: 4px;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.85em;
}
.btn-eliminar:hover { background: #dc3545; color: white; }

.btn-editar {
    background: transparent;
    border: 1px solid #0d6efd;
    color: #0d6efd;
    border-radius: 4px;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.85em;
    margin-right: 4px;
}
.btn-editar:hover { background: #0d6efd; color: white; }

.total-panel { text-align: right; font-size: 1.2em; }

/* Resumen final (estilo Excel "Calculo Materiales") */
.resumen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.resumen-caja { border: 1px solid #ddd; border-radius: 6px; overflow: hidden; }
.resumen-caja h4 {
    margin: 0;
    padding: 10px;
    background: #dc3545;
    text-align: center;
    color: white;
}

.tabla-resumen { width: 100%; border-collapse: collapse; }
.tabla-resumen td { padding: 8px 12px; border: 1px solid #eee; }
.tabla-resumen td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.tabla-resumen .fila-total td { font-weight: bold; background: #f4f7f6; }

/* Materiales */
.form-nuevo { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-nuevo input { flex: 1; min-width: 150px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.form-nuevo select { flex: 1; min-width: 150px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; background: white; font-size: 1em; color: #333; }
.checkbox-superusuario { display: flex; align-items: center; gap: 6px; font-size: 0.9em; color: #555; white-space: nowrap; }
.form-nuevo button {
    padding: 8px 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.form-nuevo button:hover { background: #218838; }

#tablaMateriales { width: 100%; border-collapse: collapse; margin-top: 15px; }
#tablaMateriales th, #tablaMateriales td { border: 1px solid #ddd; padding: 10px; text-align: left; }
#tablaMateriales th { background: #dc3545; color: white; }
#tablaMateriales input[type="number"] { width: 120px; padding: 5px; }

#tablaTercerizados { width: 100%; border-collapse: collapse; margin-top: 15px; }
#tablaTercerizados th, #tablaTercerizados td { border: 1px solid #ddd; padding: 10px; text-align: left; }
#tablaTercerizados th { background: #dc3545; color: white; }
#tablaTercerizados input[type="number"] { width: 100px; padding: 5px; }
#tablaTercerizados input[type="date"] { padding: 5px; }

#tablaConfig { width: 100%; border-collapse: collapse; margin-top: 10px; }
#tablaConfig th, #tablaConfig td { border: 1px solid #ddd; padding: 10px; text-align: left; }
#tablaConfig th { background: #dc3545; color: white; }
#tablaConfig input[type="text"] { width: 150px; padding: 6px; border: 1px solid #ccc; border-radius: 4px; }

.preview-logo { display: block; max-height: 100px; margin-bottom: 15px; }

/* Vista imprimible para el cliente */
.hoja-imprimir {
    max-width: 800px;
    margin: 30px auto;
    padding: 30px;
    background: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #222;
}

.membrete {
    display: flex;
    align-items: center;
    gap: 20px;
    border: 2px solid #dc3545;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 15px;
}
.membrete img { max-height: 70px; }
.datos-empresa h1 { margin: 0; font-size: 1.6em; color: #dc3545; letter-spacing: 1px; }
.subtitulo-empresa { margin: 0 0 6px; color: #999; font-size: 0.75em; letter-spacing: 2px; text-transform: uppercase; }

.logo-fallback {
    width: 56px;
    height: 56px;
    min-width: 56px;
    border-radius: 10px;
    background: #dc3545;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contacto-empresa { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.item-contacto {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #555;
    font-size: 0.85em;
}
.item-contacto svg { color: #dc3545; flex-shrink: 0; }

.caja-titulo {
    border: 1px solid #999;
    border-radius: 4px;
    padding: 10px;
    text-align: center;
    margin-bottom: 15px;
}
.caja-titulo h2 { margin: 0; font-size: 1.1em; }

.caja-intro {
    border: 1px solid #999;
    border-radius: 4px;
    padding: 10px 14px;
    margin-bottom: 15px;
}
.texto-intro { font-size: 0.9em; margin: 0; text-align: center; }

.tabla-especificaciones { width: 100%; border-collapse: collapse; margin-bottom: 15px; }
.tabla-especificaciones th {
    background: #dc3545;
    color: white;
    padding: 8px;
    text-align: left;
    text-transform: lowercase;
}
.tabla-especificaciones td { border: 1px solid #ddd; padding: 8px; font-size: 0.9em; }
.tabla-especificaciones th:last-child { width: 140px; }
.celda-total-especificaciones {
    text-align: center;
    vertical-align: middle;
    font-weight: bold;
    font-size: 1.15em;
    background: #fff3ec;
    color: #dc3545;
}

.tabla-totales-imprimir { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.tabla-totales-imprimir td { border: 1px solid #ddd; padding: 8px 12px; }
.tabla-totales-imprimir td:last-child { text-align: right; width: 140px; }
.fila-total-final td { background: #ffe0c2; font-weight: bold; }

.texto-footer { font-size: 0.75em; color: #666; margin-bottom: 15px; }
.texto-fecha { text-align: right; font-size: 0.85em; }

.botonera-imprimir { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 20px; }
.botonera-imprimir button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
#btnDescargar { background: #28a745; color: white; }
#btnDescargar:hover { background: #218838; }

@media print {
    .no-imprimir { display: none !important; }
    .hoja-imprimir { margin: 0; max-width: 100%; }
}

.btn-guardar {
    margin-top: 15px;
    padding: 12px 25px;
    background: #28a745;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1em;
    border-radius: 4px;
}
.btn-guardar:hover { background: #218838; }

/* Panel flotante (overlay) */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.panel-flotante {
    background: white;
    border-radius: 10px;
    padding: 25px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.panel-flotante h3 { margin-top: 0; color: #dc3545; }
.unidad-texto { color: #888; font-size: 0.9em; margin-top: -8px; }
.fecha-actualizacion { color: #888; font-size: 0.9em; white-space: nowrap; }

/* Manual de uso */
.manual-intro { color: #666; margin: -8px 0 20px; }

.manual-toc { display: flex; flex-direction: column; gap: 6px; padding: 16px 20px; }
.manual-toc a {
    color: #dc3545;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95em;
    padding: 4px 0;
}
.manual-toc a:hover { text-decoration: underline; }

.manual-seccion h3 { display: flex; align-items: center; gap: 12px; margin-top: 0; color: #222; }
.manual-numero {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    font-weight: bold;
}

.manual-pasos { margin: 12px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.manual-pasos li { line-height: 1.5; color: #444; }

.manual-tip {
    margin: 16px 0 0;
    padding: 10px 14px;
    background: #fff3ec;
    border-left: 3px solid #dc3545;
    border-radius: 4px;
    color: #555;
    font-size: 0.9em;
}
.manual-tip a { color: #dc3545; }

.panel-flotante label { display: block; margin-bottom: 15px; font-size: 0.9em; color: #555; }
.panel-flotante input, .panel-flotante select {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.preview { background: #f8f8f8; border-radius: 6px; padding: 12px; margin-bottom: 15px; }
.preview p { margin: 4px 0; }

.panel-acciones { display: flex; gap: 10px; justify-content: flex-end; }
.panel-acciones button {
    padding: 10px 18px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #28a745;
    color: white;
}
.panel-acciones button:disabled { background: #ccc; cursor: not-allowed; }
.panel-acciones .btn-secundario { background: #eee; color: #333; }

.btn-secundario {
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #eee;
    color: #333;
    cursor: pointer;
}
.btn-secundario:hover { background: #ddd; }

/* Historial de presupuestos */
#tablaPresupuestos { width: 100%; border-collapse: collapse; }
#tablaPresupuestos th, #tablaPresupuestos td { border: 1px solid #ddd; padding: 10px; text-align: left; }
#tablaPresupuestos th { background: #dc3545; color: white; }

.btn-accion {
    padding: 8px 14px;
    border: 1px solid #dc3545;
    border-radius: 4px;
    background: white;
    color: #dc3545;
    cursor: pointer;
    font-size: 0.9em;
}
.btn-accion:hover { background: #dc3545; color: white; }

.badge-estado { padding: 4px 10px; border-radius: 12px; font-size: 0.85em; font-weight: bold; }
.badge-borrador { background: #fff3cd; color: #856404; }
.badge-terminado { background: #d4edda; color: #155724; }

/* Login */
.pagina-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-caja {
    background: white;
    border-radius: 10px;
    padding: 40px;
    width: 90%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.login-logo img { max-height: 64px; }
.login-caja h2 { margin: 0 0 4px; }
.login-subtitulo { color: #888; font-size: 0.9em; margin: 0 0 24px; }
.login-form { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.login-form label { font-size: 0.9em; color: #555; display: flex; flex-direction: column; gap: 6px; }
.login-form input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
}
.login-form button {
    padding: 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    cursor: pointer;
    margin-top: 8px;
}
.login-form button:hover { background: #c82333; }
.login-error { color: #dc3545; font-size: 0.9em; margin: 0; }
.login-caja-ancha { max-width: 440px; }
.login-pie { margin: 20px 0 0; }
.login-pie a { color: #dc3545; text-decoration: none; font-weight: 500; }
.login-pie a:hover { text-decoration: underline; }
.campo-ayuda { font-weight: normal; color: #999; font-size: 0.85em; }
.direccion-input { display: flex; align-items: center; border: 1px solid #ccc; border-radius: 4px; overflow: hidden; }
.direccion-input .direccion-prefijo { padding: 10px 0 10px 10px; color: #999; font-size: 0.95em; white-space: nowrap; }
.direccion-input input { border: none; border-radius: 0; flex: 1; min-width: 0; }
.direccion-input input:focus { outline: none; }
/* notificaciones.js — toasts no bloqueantes, no le sacan el foco a nada */
#notificaciones-contenedor {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.notificacion {
    pointer-events: auto;
    cursor: pointer;
    padding: 12px 16px;
    border-radius: 6px;
    color: white;
    font-size: 0.9em;
    max-width: 320px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.notificacion-salir { opacity: 0; transform: translateX(16px); }
.notificacion-error { background: #dc3545; }
.notificacion-exito { background: #198754; }
.notificacion-info { background: #0d6efd; }

/* auth-guard.js — flechitas atrás/adelante, reemplazan la barra de menú */
#nav-atras-adelante {
    display: inline-flex;
    gap: 4px;
    margin-right: 12px;
    vertical-align: middle;
}
#nav-atras-adelante button {
    width: 22px;
    height: 22px;
    border: 1px solid #ddd;
    background: #fafafa;
    border-radius: 4px;
    font-size: 1em;
    line-height: 1;
    color: #555;
    cursor: pointer;
    vertical-align: middle;
}
#nav-atras-adelante button:hover { background: #eee; }

/* notificaciones.js — confirmarAccion(), reemplaza al confirm() nativo */
.confirmacion-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.confirmacion-caja {
    background: white;
    border-radius: 8px;
    padding: 24px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.confirmacion-caja p { margin: 0 0 20px; color: #333; }
.confirmacion-botones { display: flex; justify-content: flex-end; gap: 8px; }
.confirmacion-botones button {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    font-size: 0.9em;
    cursor: pointer;
}
.confirmacion-cancelar { background: #e9ecef; color: #333; }
.confirmacion-cancelar:hover { background: #dde1e4; }
.confirmacion-aceptar { background: #dc3545; color: white; }
.confirmacion-aceptar:hover { background: #c82333; }

.confirmacion-caja .prompt-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    margin: -8px 0 20px;
}
