@font-face { font-family: "DM Sans"; src: url(fonts/DMSans-Regular.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url(fonts/DMSans-Medium.ttf); font-weight: 500; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url(fonts/DMSans-SemiBold.ttf); font-weight: 600; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url(fonts/DMSans-Bold.ttf); font-weight: 700; font-display: swap; }

:root {
  --primario: #0F172A;
  --acento: #6366F1;
  --acento-suave: #EEF2FF;
  --fondo: #F6F5F2;
  --superficie: #FFFFFF;
  --tinta: #0B0B0B;
  --tinta-2: #52514E;
  --tenue: #8A8984;
  --linea: #E7E6E2;
  --pos: #1C5CAB;
  --pos-suave: #E7F0FC;
  --neg: #B8322F;
  --neg-suave: #FDF1F0;
  --ok: #0A8A0A;
  --warn: #B87800;
  --warn-suave: #FFF7E6;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "DM Sans", system-ui, -apple-system, sans-serif; background: var(--fondo); color: var(--tinta);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 .8em; }
small, .tenue { color: var(--tenue); }
.muted { color: var(--tinta-2); }

/* ---------------- layout */
.app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.lateral { background: var(--primario); color: #CBD5E1; padding: 22px 16px; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.marca { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 14px; letter-spacing: .04em;
  line-height: 1.15; padding: 0 8px 18px; }
.marca img { width: 38px; height: 38px; object-fit: contain; flex: none; }
.marca span small { display: block; color: #94A3B8; font-weight: 500; letter-spacing: .08em; font-size: 10px; }
.nav a { display: flex; align-items: center; gap: 10px; color: #CBD5E1; padding: 9px 12px; border-radius: 10px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.activo { background: rgba(99,102,241,.22); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-titulo { font-size: 11px; letter-spacing: .1em; color: #64748B; padding: 16px 12px 6px; font-weight: 600; }
.nav .cliente-link { font-size: 14px; padding: 7px 12px 7px 40px; }
.lateral .pie { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.lateral .pie a { color: #94A3B8; }
.principal { padding: 28px 36px 60px; max-width: 1280px; width: 100%; min-width: 0; }
.barra-movil { display: none; }

.cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.cabecera .sub { color: var(--tinta-2); margin: 0; }
.migas { font-size: 13px; color: var(--tenue); margin-bottom: 6px; }
.migas a { color: var(--tenue); }

/* ---------------- componentes */
.tarjeta { background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--radio); padding: 22px; box-shadow: var(--sombra); }
.tarjeta + .tarjeta, .bloque + .bloque { margin-top: 18px; }
.grid > .tarjeta, .clientes > .tarjeta, .grid > * { margin-top: 0 !important; }
.tarjeta h2 { margin-bottom: 4px; }
.tarjeta .sub { color: var(--tinta-2); margin-bottom: 16px; font-size: 14px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fila.entre { justify-content: space-between; }
.espacio { height: 18px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 18px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; background: var(--acento); color: #fff;
  transition: filter .15s, transform .05s; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.sec { background: var(--superficie); color: var(--tinta); border-color: var(--linea); }
.btn.sec:hover { background: #FAFAF8; }
.btn.peligro { background: var(--superficie); color: var(--neg); border-color: #F1C9C7; }
.btn.grande { padding: 14px 24px; font-size: 15px; }
.btn.chico { padding: 6px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

.aviso { border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; border: 1px solid; font-size: 14px; }
.aviso.ok { background: #EEFBEE; border-color: #BFE7BF; color: #125C12; }
.aviso.error { background: var(--neg-suave); border-color: #F1C9C7; color: #8E2320; }
.aviso.info { background: var(--acento-suave); border-color: #D5DBFF; color: #2E3190; }
.aviso.warn { background: var(--warn-suave); border-color: #F3DFB0; color: #6E4B00; }

.etiqueta { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
  background: #F0EFEC; color: var(--tinta-2); }
.etiqueta.ok { background: #E6F6E6; color: #0B6B0B; }
.etiqueta.error { background: var(--neg-suave); color: var(--neg); }
.etiqueta.warn { background: var(--warn-suave); color: var(--warn); }
.etiqueta.acento { background: var(--acento-suave); color: #3730A3; }
.punto { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.tono-pos { color: var(--pos); }
.tono-neg { color: var(--neg); }
.tono-neu { color: var(--tinta-2); }
.tono-nd { color: var(--tenue); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.kpi { background: #FAFAF8; border: 1px solid var(--linea); border-radius: 12px; padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi .l { font-size: 13px; color: var(--tinta-2); margin-top: 2px; }
.kpi .d { font-size: 12px; margin-top: 6px; color: var(--tenue); }
.kpi .d b { font-weight: 600; }

/* Termómetro */
.termometro { position: relative; height: 14px; border-radius: 99px; background: linear-gradient(90deg, #B8322F, #EE8A87 25%, #D6D5D0 50%, #86B6EF 75%, #1C5CAB); margin: 28px 0 8px; }
.termometro .aguja { position: absolute; top: -10px; width: 4px; height: 34px; background: var(--tinta); border-radius: 3px; transform: translateX(-2px); }
.termometro .aguja span { position: absolute; top: -26px; left: 50%; transform: translateX(-50%); font-weight: 700; font-size: 15px; white-space: nowrap; }
.escala { display: flex; justify-content: space-between; font-size: 12px; color: var(--tenue); }

/* Tarjetas de cliente */
.clientes { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 18px; }
.cliente-card { display: flex; flex-direction: column; gap: 12px; color: inherit; transition: border-color .15s, transform .15s; }
.cliente-card:hover { border-color: #C7CBF5; transform: translateY(-2px); text-decoration: none; }
.cliente-card .cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cliente-card h3 { font-size: 18px; margin: 0; }
.cliente-card .mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cliente-card .mini div { background: #FAFAF8; border-radius: 10px; padding: 8px 10px; }
.cliente-card .mini b { display: block; font-size: 18px; }
.cliente-card .mini span { font-size: 11px; color: var(--tenue); }
.cliente-card .titular { font-size: 14px; color: var(--tinta-2); }
.cliente-card .pie { display: flex; justify-content: space-between; font-size: 12px; color: var(--tenue); border-top: 1px solid var(--linea); padding-top: 10px; margin-top: auto; }
.nueva { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 2px dashed #CFCDC6;
  background: transparent; box-shadow: none; min-height: 220px; color: var(--tinta-2); font-weight: 600; }
.nueva:hover { border-color: var(--acento); color: var(--acento); text-decoration: none; }
.nueva .mas { font-size: 34px; line-height: 1; }

/* Pestañas */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--linea); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 16px; color: var(--tinta-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; font-size: 14px; }
.tabs a:hover { color: var(--tinta); text-decoration: none; }
.tabs a.activo { color: var(--acento); border-color: var(--acento); }

/* Tablas */
.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--tinta-2); padding: 10px 12px; border-bottom: 1px solid var(--tinta-2); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--linea); vertical-align: middle; }
tr:nth-child(even) td { background: #FBFBF9; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.destacado td { background: var(--acento-suave) !important; font-weight: 600; }

/* Formularios */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.campo { margin-bottom: 18px; }
.ayuda { font-size: 13px; color: var(--tenue); margin-top: 5px; font-weight: 400; }
.req { color: var(--neg); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], input[type=url], select, textarea {
  width: 100%; font: inherit; font-size: 15px; padding: 11px 13px; border: 1px solid #D8D6D0; border-radius: 10px; background: #fff; color: var(--tinta); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px rgba(99,102,241,.18); }
textarea { resize: vertical; min-height: 90px; }
input[type=color] { width: 56px; height: 42px; border: 1px solid #D8D6D0; border-radius: 10px; padding: 3px; background: #fff; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; margin-bottom: 10px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--acento); flex: none; }
.check small { display: block; color: var(--tenue); font-weight: 400; }
.opciones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.opcion { position: relative; }
.opcion input { position: absolute; opacity: 0; }
.opcion span { display: block; border: 1.5px solid #D8D6D0; border-radius: 12px; padding: 14px; text-align: center; font-weight: 600; cursor: pointer; background: #fff; }
.opcion span small { display: block; font-weight: 400; color: var(--tenue); font-size: 12px; margin-top: 2px; }
.opcion input:checked + span { border-color: var(--acento); background: var(--acento-suave); color: #3730A3; }
.opcion input:focus-visible + span { box-shadow: 0 0 0 3px rgba(99,102,241,.25); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px; border: 1px solid #D8D6D0; border-radius: 10px; background: #fff; min-height: 46px; cursor: text; }
.chips:focus-within { border-color: var(--acento); box-shadow: 0 0 0 3px rgba(99,102,241,.18); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--acento-suave); color: #3730A3; border-radius: 8px; padding: 4px 6px 4px 10px; font-size: 14px; font-weight: 500; }
.chip button { border: 0; background: transparent; color: #6366F1; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.chips input { border: 0 !important; box-shadow: none !important; flex: 1; min-width: 160px; padding: 5px !important; }

/* Asistente por pasos */
.pasos { display: flex; gap: 6px; margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.pasos button { flex: 1; min-width: 118px; border: 0; background: transparent; text-align: left; padding: 10px 4px 0; border-top: 3px solid var(--linea);
  font: inherit; font-size: 13px; color: var(--tenue); cursor: pointer; }
.pasos button b { display: block; font-size: 11px; letter-spacing: .08em; }
.pasos button.hecho { border-color: #A5B4FC; color: var(--tinta-2); }
.pasos button.activo { border-color: var(--acento); color: var(--tinta); font-weight: 600; }
.paso { display: none; }
.paso.activo { display: block; animation: aparecer .2s ease; }
@keyframes aparecer { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.acciones-form { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--linea); }
.competidor { border: 1px solid var(--linea); border-radius: 12px; padding: 16px; margin-bottom: 12px; background: #FCFCFA; }

/* Progreso */
.progreso { background: var(--acento-suave); border: 1px solid #D5DBFF; border-radius: var(--radio); padding: 18px 20px; margin-bottom: 18px; }
.progreso .barra { height: 8px; background: #fff; border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progreso .barra div { height: 100%; background: var(--acento); border-radius: 99px; transition: width .6s ease; }
.progreso .msg { font-size: 14px; color: #2E3190; }
.girando { width: 16px; height: 16px; border: 2.5px solid #C7CBF5; border-top-color: var(--acento); border-radius: 50%; animation: girar .8s linear infinite; display: inline-block; }
@keyframes girar { to { transform: rotate(360deg); } }

/* Vacío */
.vacio { text-align: center; padding: 48px 20px; }
.vacio .icono { font-size: 42px; margin-bottom: 8px; }
.vacio p { color: var(--tinta-2); max-width: 460px; margin: 0 auto 18px; }

/* Listas */
.lista { list-style: none; padding: 0; margin: 0; }
.lista li { padding: 12px 0; border-bottom: 1px solid var(--linea); }
.lista li:last-child { border-bottom: 0; }
.reco { border-left: 4px solid var(--linea); padding: 12px 16px; background: #FAFAF8; border-radius: 0 12px 12px 0; margin-bottom: 10px; }
.reco.alta { border-color: #D03B3B; } .reco.media { border-color: #C98500; } .reco.baja { border-color: #0CA30C; }
.reco .meta { font-size: 11px; letter-spacing: .06em; font-weight: 700; color: var(--tenue); text-transform: uppercase; }
.hallazgo { display: flex; gap: 10px; align-items: flex-start; }

/* Anuncios */
.anuncios { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.anuncio { background: #fff; border: 1px solid var(--linea); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.anuncio img { width: 100%; aspect-ratio: 1.3; object-fit: cover; background: #F0EFEC; }
.anuncio .cuerpo { padding: 12px 14px; font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.anuncio .texto { color: var(--tinta-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.anuncio .pie { font-size: 12px; color: var(--tenue); display: flex; justify-content: space-between; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--linea); }

.grafica { position: relative; height: 260px; }
.grafica.baja { height: 200px; }

/* Acceso */
.acceso { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(99,102,241,.35), transparent), var(--primario); }
.acceso .tarjeta { width: 100%; max-width: 420px; padding: 32px; }
.acceso .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.acceso .logo img { width: 46px; }
.acceso .logo b { font-size: 16px; letter-spacing: .04em; line-height: 1.15; }
.acceso .logo small { display: block; color: var(--tenue); font-size: 11px; letter-spacing: .1em; font-weight: 500; }

.historial a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--tinta-2); font-size: 14px; }
.historial a.activo, .historial a:hover { background: var(--acento-suave); color: #3730A3; text-decoration: none; }

details.ayuda-box { background: #FAFAF8; border: 1px solid var(--linea); border-radius: 12px; padding: 12px 16px; font-size: 14px; }
details.ayuda-box summary { cursor: pointer; font-weight: 600; }

.con-lateral { grid-template-columns: minmax(0, 1fr) 260px; align-items: start; }

/* ---------------- móvil */
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .cabecera > .fila, .cabecera form { width: 100%; }
  .lateral { position: fixed; inset: 0 30% 0 0; max-width: 300px; z-index: 50; transform: translateX(-105%); transition: transform .25s; height: 100%; }
  body.menu-abierto .lateral { transform: none; box-shadow: 0 0 0 100vmax rgba(15,23,42,.45); }
  .barra-movil { display: flex; align-items: center; gap: 12px; background: var(--primario); color: #fff; padding: 12px 16px; position: sticky; top: 0; z-index: 40; font-weight: 700; font-size: 13px; letter-spacing: .04em; }
  .barra-movil button { background: transparent; border: 0; color: #fff; font-size: 24px; cursor: pointer; padding: 0 4px; }
  .barra-movil img { width: 28px; }
  .principal { padding: 20px 16px 50px; }
  .g2, .g3, .g4, .con-lateral { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .opciones { grid-template-columns: 1fr; }
  h1 { font-size: 23px; }
  .cabecera .btn { width: 100%; }
}
