/* ============================================================
   Grupo SI · Cotizaciones — Estilos de la aplicación
   Paleta corporativa 2026-2027
   ============================================================ */
:root {
  --marino: #16284A;
  --marino-2: #1F3560;
  --lima: #8CC63F;
  --verde: #5C9A28;
  --azul-medio: #4A6285;
  --gris: #AAB6C4;
  --fondo: #F1F5F8;
  --texto: #2E3E56;
  --suave: #6E7C8C;
  --linea: #E2E8EF;
  --rojo: #B23A3A;
  --ambar: #C98A12;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(22,40,74,.06), 0 6px 20px rgba(22,40,74,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: 14px; color: var(--texto); background: var(--fondo); line-height: 1.5;
}
a { color: var(--azul-medio); text-decoration: none; }
a:hover { color: var(--marino); }
h1, h2, h3 { color: var(--marino); margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.mini { font-size: 12px; color: var(--suave); }
.derecha { text-align: right; }
.centro { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- Menú lateral ---------- */
body.con-menu { padding-left: 250px; }
.lateral {
  position: fixed; top: 0; left: 0; bottom: 0; width: 250px; z-index: 30;
  background: var(--marino); color: #fff; display: flex; flex-direction: column;
  overflow-y: auto;
}
.lateral-marca { display: block; margin: 18px 16px 8px; background: #fff; border-radius: 12px; padding: 12px 14px; }
.lateral-marca img { display: block; width: 100%; height: auto; max-height: 56px; object-fit: contain; }
.lateral-app { margin: 0 18px 10px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--lima); font-weight: 600; }
.lateral-usuario { display: flex; align-items: center; gap: 10px; margin: 6px 16px 14px; padding: 10px 12px; background: rgba(255,255,255,.06); border-radius: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--lima); color: var(--marino); display: grid; place-items: center; font-weight: 700; flex: none; }
.lateral-usuario .nombre { font-weight: 600; font-size: 13px; line-height: 1.2; }
.lateral-usuario .rol { font-size: 11px; color: var(--gris); }
.lateral-nav { flex: 1; padding: 0 10px; }
.lateral-nav .grupo { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--gris); margin: 16px 10px 6px; }
.lateral a.item { display: flex; align-items: center; gap: 10px; color: #DCE4EE; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 2px; }
.lateral a.item:hover { background: rgba(255,255,255,.07); color: #fff; }
.lateral a.item.activo { background: var(--lima); color: var(--marino); font-weight: 600; }
.lateral a.item svg { width: 18px; height: 18px; flex: none; }
.lateral-pie { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.barra-movil { display: none; }
.velo { display: none; }

/* ---------- Contenido ---------- */
.contenido { padding: 28px 32px 60px; max-width: 1280px; }
body.sin-menu .contenido { max-width: none; padding: 0; }
.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.encabezado h1 { margin: 0; }
.encabezado .bajada { color: var(--suave); margin-top: 2px; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tarjeta { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); padding: 22px; margin-bottom: 18px; }
.tarjeta-titulo { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.tarjeta-titulo h2 { margin: 0; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); padding: 18px 20px; border-top: 4px solid var(--lima); }
.kpi .etq { font-size: 12px; color: var(--suave); }
.kpi .val { font-size: 26px; font-weight: 700; color: var(--marino); line-height: 1.2; margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--azul-medio); }
.kpi.azul { border-top-color: var(--azul-medio); }
.kpi.verde { border-top-color: var(--verde); }
.kpi.marino { border-top-color: var(--marino); }

/* ---------- Botones ---------- */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--marino); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 18px; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: transform .05s, background .15s; white-space: nowrap;
}
.boton:hover { background: var(--marino-2); color: #fff; }
.boton:active { transform: translateY(1px); }
.boton-lima { background: var(--lima); color: var(--marino); }
.boton-lima:hover { background: #7DB534; color: var(--marino); }
.boton-sec { background: #fff; color: var(--marino); box-shadow: inset 0 0 0 1.5px var(--linea); }
.boton-sec:hover { background: var(--fondo); color: var(--marino); }
.boton-peligro { background: #fff; color: var(--rojo); box-shadow: inset 0 0 0 1.5px #EBC9C9; }
.boton-peligro:hover { background: #FBEFEF; color: var(--rojo); }
.boton-chico { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.boton-grande { width: 100%; padding: 13px; font-size: 15px; }
.boton svg { width: 16px; height: 16px; }

/* ---------- Formularios ---------- */
.grilla { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; }
.c5 { grid-column: span 5; } .c6 { grid-column: span 6; } .c8 { grid-column: span 8; }
.c7 { grid-column: span 7; } .c9 { grid-column: span 9; } .c10 { grid-column: span 10; } .c12 { grid-column: span 12; }
.campo label { display: block; font-size: 12px; font-weight: 600; color: var(--azul-medio); margin-bottom: 5px; }
.campo .ayuda { font-size: 11.5px; color: var(--suave); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=url], select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--texto);
  background: #fff; border: 1.5px solid var(--linea); border-radius: 10px; padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--lima); box-shadow: 0 0 0 3px rgba(140,198,63,.2); }
input[type=color] { width: 54px; height: 40px; padding: 2px; border: 1.5px solid var(--linea); border-radius: 10px; background: #fff; cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--verde); }
.separador { grid-column: span 12; border-top: 1px solid var(--linea); margin: 6px 0 2px; padding-top: 14px; font-weight: 600; color: var(--marino); }
.pie-form { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Tablas ---------- */
.tabla-envoltura { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; }
.tabla th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--suave); font-weight: 600; padding: 10px 12px; border-bottom: 1.5px solid var(--linea); white-space: nowrap; }
.tabla td { padding: 12px; border-bottom: 1px solid var(--linea); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover td { background: #FAFCFD; }
.tabla .fuerte { font-weight: 600; color: var(--marino); }
.vacio { text-align: center; color: var(--suave); padding: 36px 12px !important; }

/* ---------- Chips de estado ---------- */
.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.chip-borrador { background: #EEF1F5; color: var(--azul-medio); }
.chip-enviada { background: #E4EEFB; color: #2A5BA8; }
.chip-aceptada { background: #E9F5DC; color: var(--verde); }
.chip-rechazada { background: #FBEAEA; color: var(--rojo); }
.chip-anulada { background: #F3F3F3; color: #8A8A8A; text-decoration: line-through; }
.chip-activo { background: #E9F5DC; color: var(--verde); }
.chip-inactivo { background: #F3F3F3; color: #8A8A8A; }
.chip-admin { background: var(--marino); color: #fff; }
.chip-vendedor { background: #EEF1F5; color: var(--azul-medio); }

/* ---------- Mensajes ---------- */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 13.5px; border-left: 4px solid; }
.flash-ok { background: #EEF7E3; border-color: var(--lima); color: #3E6B17; }
.flash-error { background: #FBEDED; border-color: var(--rojo); color: var(--rojo); }
.flash-aviso { background: #FDF6E6; border-color: var(--ambar); color: #8A5D07; }

/* ---------- Filtros ---------- */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filtros .campo { min-width: 150px; }
.filtros .campo.ancho { flex: 1; min-width: 220px; }

/* ---------- Logo de empresa en listas ---------- */
.logo-mini { height: 26px; width: 90px; object-fit: contain; object-position: left center; display: block; }
.empresa-card { display: flex; gap: 16px; align-items: center; }
.empresa-card .logo-caja { width: 150px; height: 64px; background: #fff; border: 1px solid var(--linea); border-radius: 12px; display: grid; place-items: center; padding: 8px; flex: none; }
.empresa-card .logo-caja img { max-width: 100%; max-height: 100%; object-fit: contain; }
.muestra-color { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }

/* ---------- Selector de empresa (tarjetas) ---------- */
.selector-empresas { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.selector-empresas label { cursor: pointer; }
.selector-empresas input { position: absolute; opacity: 0; pointer-events: none; }
.selector-empresas .opcion { display: grid; place-items: center; height: 76px; padding: 10px 14px; background: #fff; border: 2px solid var(--linea); border-radius: 12px; transition: border-color .15s, box-shadow .15s; }
.selector-empresas .opcion img { max-width: 100%; max-height: 48px; object-fit: contain; }
.selector-empresas input:checked + .opcion { border-color: var(--lima); box-shadow: 0 0 0 3px rgba(140,198,63,.22); }
.selector-empresas input:focus-visible + .opcion { outline: 2px solid var(--marino); }

/* ---------- Editor de ítems ---------- */
.items-editor { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.items-editor th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--suave); text-align: left; padding: 0 6px; font-weight: 600; }
.items-editor td { padding: 0 6px; vertical-align: top; }
.items-editor tr.fila-item td { background: var(--fondo); padding-top: 10px; padding-bottom: 10px; }
.items-editor tr.fila-item td:first-child { border-radius: 12px 0 0 12px; padding-left: 12px; }
.items-editor tr.fila-item td:last-child { border-radius: 0 12px 12px 0; padding-right: 10px; }
.items-editor textarea { min-height: 38px; height: 38px; margin-top: 6px; font-size: 12.5px; }
.items-editor .num { text-align: right; }
.items-editor .total-fila { font-weight: 600; color: var(--marino); padding-top: 9px; display: block; text-align: right; white-space: nowrap; }
.items-editor .mover { display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
.btn-icono { background: none; border: 0; cursor: pointer; color: var(--suave); padding: 3px; border-radius: 6px; line-height: 0; }
.btn-icono:hover { background: #fff; color: var(--marino); }
.btn-icono.borrar:hover { color: var(--rojo); }
.btn-icono svg { width: 16px; height: 16px; }
.resumen-totales { margin-left: auto; width: 340px; max-width: 100%; }
.resumen-totales .linea { display: flex; justify-content: space-between; padding: 6px 0; color: var(--azul-medio); }
.resumen-totales .linea b { color: var(--marino); }
.resumen-totales .linea.total { border-top: 2px solid var(--marino); margin-top: 6px; padding-top: 10px; font-size: 18px; }
.resumen-totales .linea.total b { color: var(--marino); }

/* ---------- Fotos ---------- */
.fotos-grilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; min-width: 0; }
.fotos-grilla:empty { display: none; }
.foto-card { background: var(--fondo); border-radius: 12px; overflow: hidden; position: relative; border: 1px solid var(--linea); }
.foto-card img { width: 100%; aspect-ratio: 4 / 3; height: auto; object-fit: cover; display: block; }
.foto-card .pie-foto { padding: 6px; }
.foto-card .pie-foto input { font-size: 12px; padding: 5px 8px; border-radius: 8px; }
.foto-card .quitar { position: absolute; top: 6px; right: 6px; background: rgba(255,255,255,.95); border-radius: 7px; padding: 3px 8px; font-size: 11px; font-weight: 600; color: var(--rojo); cursor: pointer; border: 0; font-family: inherit; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.foto-card .quitar input { width: 12px; height: 12px; margin: 0 3px 0 0; }
.zona-subida { display: flex; align-items: center; gap: 14px; border: 2px dashed var(--gris); border-radius: 12px; padding: 12px 16px; color: var(--azul-medio); background: #FAFCFD; cursor: pointer; transition: border-color .15s, background .15s; }
.zona-subida:hover, .zona-subida.arrastrando { border-color: var(--lima); background: #F4FAEC; }
.zona-subida input { display: none; }
.zona-ico { width: 40px; height: 40px; flex: none; border-radius: 10px; background: #EEF3E6; color: var(--verde); display: grid; place-items: center; }
.zona-ico svg { width: 22px; height: 22px; }
.zona-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.zona-txt strong { color: var(--marino); font-size: 13.5px; font-weight: 600; }
.zona-btn { flex: none; pointer-events: none; }
@media (max-width: 600px) { .zona-btn { display: none; } }
.previas { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 12px; }
.previas img { width: 100%; height: 80px; object-fit: cover; border-radius: 10px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-marca {
  background: radial-gradient(circle at 15% 20%, rgba(140,198,63,.22), transparent 45%), linear-gradient(150deg, var(--marino) 0%, #0E1B33 100%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.login-marca::after { content: ''; position: absolute; right: -120px; bottom: -40px; width: 520px; height: 120px; background: var(--lima); transform: rotate(-8deg); opacity: .9; clip-path: polygon(0 60%, 100% 0, 70% 100%); }
.login-marca .logo-blanco { background: #fff; border-radius: 16px; padding: 18px 22px; display: inline-block; }
.login-marca .logo-blanco img { height: 70px; display: block; }
.login-marca h2 { color: #fff; font-size: 34px; font-weight: 700; margin: 0 0 10px; max-width: 460px; }
.login-marca h2 span { color: var(--lima); }
.login-marca p { color: #C9D3E0; max-width: 440px; font-size: 15px; }
.login-marcas { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.login-marcas span { background: rgba(255,255,255,.95); border-radius: 10px; padding: 8px 12px; height: 46px; display: grid; place-items: center; }
.login-marcas img { height: 28px; max-width: 110px; object-fit: contain; }
.login-form { display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.login-form .caja { width: 100%; max-width: 380px; }
.login-form h1 { font-size: 26px; }
.login-form .campo { margin-bottom: 14px; }

/* ---------- Vista de documento (dentro de la app) ---------- */
.marco-documento { background: #DDE4EC; border-radius: var(--radio); padding: 28px; overflow-x: auto; }
.linea-tiempo { list-style: none; margin: 0; padding: 0; }
.linea-tiempo li { padding: 0 0 12px 18px; border-left: 2px solid var(--linea); position: relative; font-size: 13px; }
.linea-tiempo li::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--lima); }
.linea-tiempo .cuando { font-size: 11.5px; color: var(--suave); }
.lado-a-lado { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lado-a-lado { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  body.con-menu { padding-left: 0; padding-top: 58px; }
  .barra-movil { display: flex; align-items: center; gap: 12px; position: fixed; top: 0; left: 0; right: 0; height: 58px; background: var(--marino); color: #fff; padding: 0 14px; z-index: 25; }
  .barra-movil img { height: 30px; background: #fff; border-radius: 8px; padding: 4px 8px; }
  .hamburguesa { background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }
  .lateral { transform: translateX(-100%); transition: transform .2s; }
  .lateral.abierto { transform: none; }
  .velo.visible { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 29; }
  .contenido { padding: 18px 16px 50px; }
  .grilla > * { grid-column: span 12 !important; }
  .login { grid-template-columns: 1fr; }
  .login-marca { padding: 32px 24px; min-height: auto; gap: 24px; }
  .login-marca h2 { font-size: 26px; }
  .marco-documento { padding: 10px; }
  .items-editor thead { display: none; }
  .items-editor, .items-editor tbody, .items-editor tr, .items-editor td { display: block; width: 100%; }
  .items-editor tr.fila-item { background: var(--fondo); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
  .items-editor tr.fila-item td { background: none; padding: 4px 0 !important; border-radius: 0 !important; }
  .items-editor .mover { flex-direction: row; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
}

/* ---------- Buscador predictivo (combobox) ---------- */
.combo { position: relative; }
.combo input.invalido { border-color: var(--rojo); box-shadow: 0 0 0 3px rgba(178,58,58,.12); }
.combo-lista { display: none; position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border-radius: 12px; box-shadow: 0 12px 34px rgba(22,40,74,.18), 0 0 0 1px var(--linea); max-height: 360px; overflow-y: auto; padding: 6px; }
.combo-lista.visible { display: block; }
.combo-op { padding: 9px 12px; border-radius: 9px; cursor: pointer; }
.combo-op.activo { background: #F1F7E8; }
.combo-nom { font-weight: 600; color: var(--marino); font-size: 13.5px; }
.combo-sub { font-size: 11.5px; color: var(--suave); }
.combo-op mark { background: rgba(140,198,63,.35); color: inherit; border-radius: 3px; padding: 0 1px; }
.combo-vacio { padding: 12px; color: var(--suave); font-size: 13px; }
.combo-nuevo { display: block; margin-top: 4px; padding: 10px 12px; border-top: 1px solid var(--linea); color: var(--verde); font-weight: 600; font-size: 13px; }
.combo-nuevo:hover { background: var(--fondo); color: var(--verde); border-radius: 0 0 9px 9px; }

/* ---------- Ventanas emergentes (creación rápida) ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 16px; width: min(640px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(22,40,74,.3); }
dialog.modal::backdrop { background: rgba(14,27,51,.45); }
.modal-caja { padding: 24px; }
.modal-caja .cerrar.btn-icono { font-size: 16px; line-height: 1; padding: 6px 8px; }
.modal-caja .errores { margin-bottom: 14px; }
button.combo-nuevo { width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--linea); font: inherit; font-weight: 600; font-size: 13px; color: var(--verde); cursor: pointer; }

/* ---------- Vista rápida de cotización (ventana emergente) ---------- */
dialog.previa { border: 0; padding: 0; background: transparent; width: min(1000px, calc(100vw - 32px)); height: calc(100vh - 40px); max-height: none; max-width: none; }
dialog.previa::backdrop { background: rgba(14,27,51,.55); backdrop-filter: blur(2px); }
.previa-caja { display: flex; flex-direction: column; height: 100%; background: #DDE4EC; border-radius: 16px; overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.previa-barra { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--linea); }
.previa-titulo { font-weight: 700; color: var(--marino); font-size: 16px; line-height: 1.2; }
.previa-sub { font-size: 12px; color: var(--suave); }
.previa-cerrar { background: var(--fondo); border: 0; border-radius: 8px; width: 34px; height: 32px; font-size: 15px; color: var(--marino); cursor: pointer; }
.previa-cerrar:hover { background: #E2E8EF; }
.previa-cuerpo { position: relative; flex: 1; }
.previa-cuerpo iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.previa-cargando { position: absolute; inset: 0; display: none; place-items: center; color: var(--azul-medio); font-weight: 500; }
dialog.previa.cargando .previa-cargando { display: grid; }
dialog.previa.cargando iframe { visibility: hidden; }
a[data-previa] { cursor: zoom-in; }
@media (max-width: 700px) {
  dialog.previa { width: 100vw; height: 100vh; }
  .previa-caja { border-radius: 0; }
  .previa-barra .boton { padding: 6px 9px; font-size: 11.5px; }
}
.boton[hidden] { display: none; }
.texto-error { color: var(--rojo) !important; font-weight: 600; }
