:root {
  --lateral: #111827;
  --lateral-texto: #d1d5db;
  --lateral-suave: #9ca3af;
  --fondo: #f3f4f6;
  --superficie: #ffffff;
  --texto: #111827;
  --texto-2: #4b5563;
  --borde: #e5e7eb;
  --acento: #1d4ed8;
  --serie-actual: #1d4ed8;
  --serie-previa: #6b7280;
  --bien: #166534;
  --mal: #b91c1c;
  --aviso: #92400e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fondo); color: var(--texto); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }

/* Menú lateral */
.lateral {
  position: fixed; inset: 0 auto 0 0; width: 248px; overflow-y: auto; z-index: 30;
  display: flex; flex-direction: column; padding: 18px 12px 12px;
  background: var(--lateral); color: var(--lateral-texto);
}
.logo { font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; color: #fff; text-decoration: none; padding: 0 10px 12px; display: block; }
.logo.oscuro { color: var(--texto); padding: 0 0 12px; }
.seccion { margin: 14px 10px 4px; font-size: .75rem; color: var(--lateral-suave); }
.lateral ul { list-style: none; margin: 0; padding: 0; }
.lateral li > a, .futuro { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 6px 10px; border-radius: 8px; font-size: .94rem; text-decoration: none; }
.lateral li > a:hover { background: #1f2937; color: #fff; }
.lateral li > a.activo { background: var(--acento); color: #fff; font-weight: 600; }
.futuro { color: var(--lateral-suave); cursor: default; }
.futuro small { margin-left: auto; font-size: .7rem; border: 1px solid #4b5563; border-radius: 999px; padding: 0 7px; }
.icono { flex-shrink: 0; }
.salir { margin-top: auto; padding-top: 16px; }
.salir button { width: 100%; min-height: 38px; background: none; border: 1px solid #374151; border-radius: 8px; color: var(--lateral-texto); font: inherit; font-size: .9rem; cursor: pointer; }
.salir button:hover { background: #1f2937; color: #fff; }
.abrir-menu { position: absolute; opacity: 0; pointer-events: none; }
.barra-movil, .velo { display: none; }

/* Contenido */
.contenido { margin-left: 248px; padding: 28px; max-width: 1248px; }
.cabecera { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
h1 { font-size: 1.9rem; line-height: 1.2; letter-spacing: -.02em; }
.sub { color: var(--texto-2); font-size: .94rem; }
.filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.selector { display: inline-flex; background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px; padding: 3px; }
.selector a { min-height: 36px; display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 7px; font-size: .9rem; text-decoration: none; color: var(--texto-2); white-space: nowrap; }
.selector a:hover { color: var(--texto); }
.selector a.activo { background: var(--texto); color: #fff; font-weight: 600; }

.canales { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.canal { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; background: var(--superficie); border: 1px solid var(--borde); font-size: .9rem; font-weight: 600; }
.canal i { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; }
.canal.conectado i { background: #16a34a; }
.canal small { font-weight: 400; color: var(--texto-2); font-size: .8rem; }

.tarjeta { background: var(--superficie); border: 1px solid var(--borde); border-radius: 12px; padding: 20px; margin-bottom: 18px; }
.tarjeta-cabecera { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
.sincronizado { color: var(--texto-2); font-size: .85rem; }
.aviso { color: var(--aviso); }
.vacio { color: var(--texto-2); padding: 24px 0; text-align: center; }

.cifras { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.cifra { border: 1px solid var(--borde); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.cifra span:first-child { display: block; color: var(--texto-2); font-size: .85rem; }
.cifra strong { display: block; font-size: 1.65rem; line-height: 1.3; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.cambio { font-size: .85rem; font-weight: 600; }
.cambio.bien { color: var(--bien); }
.cambio.mal { color: var(--mal); }
.cambio.neutro { color: var(--texto-2); font-weight: 400; }

.grafica-titulo { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.leyenda { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 14px; font-size: .85rem; color: var(--texto-2); }
.leyenda li { display: inline-flex; align-items: center; gap: 6px; }
.muestra { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--serie-actual); }
.muestra.previo { border-top: 2px dashed var(--serie-previa); }
.grafica { position: relative; height: 240px; }
.grafica svg { display: block; touch-action: pan-y; }
.rejilla { stroke: #eef0f3; }
.eje { stroke: #d1d5db; }
.marca-eje { fill: var(--texto-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.linea { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.linea.actual { stroke: var(--serie-actual); }
.linea.previo { stroke: var(--serie-previa); stroke-dasharray: 5 4; }
.guia { stroke: #9ca3af; stroke-width: 1; }
.punto { stroke: #fff; stroke-width: 2; }
.punto.actual { fill: var(--serie-actual); }
.punto.previo { fill: var(--serie-previa); }
.ficha { position: absolute; top: 8px; background: #111827; color: #fff; border-radius: 8px; padding: 8px 10px; font-size: .82rem; pointer-events: none; white-space: nowrap; }
.ficha div { display: flex; align-items: center; gap: 8px; }
.ficha b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.ficha .muestra.actual { border-top-color: #93c5fd; }
.ficha .muestra.previo { border-top-color: #d1d5db; }

.tabla-datos { margin-top: 8px; font-size: .9rem; }
.tabla-datos summary { cursor: pointer; color: var(--acento); min-height: 32px; display: inline-flex; align-items: center; }
.tabla-scroll { max-height: 280px; overflow: auto; border: 1px solid var(--borde); border-radius: 8px; margin-top: 6px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 12px; text-align: right; border-bottom: 1px solid var(--borde); white-space: nowrap; }
th { position: sticky; top: 0; background: #f9fafb; font-weight: 600; }
th:nth-child(odd), td:nth-child(odd) { text-align: left; }

.fuentes { margin-top: 20px; }
.fuentes ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.fuentes li { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 12px; font-size: .92rem; }
.fuente-barra { height: 8px; background: #eef0f3; border-radius: 4px; overflow: hidden; }
.fuente-barra i { display: block; height: 100%; background: var(--serie-actual); border-radius: 0 4px 4px 0; }
.fuente-dato { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fuente-dato small { color: var(--texto-2); }

.titulo-pendientes { margin: 26px 0 10px; }
.pendientes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pendiente { margin: 0; padding: 16px; }
.pendiente p { color: var(--texto-2); font-size: .9rem; margin-top: 4px; }

/* Entrada */
.pagina-entrar { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.entrar { width: 100%; max-width: 360px; margin: 0; }
.entrar h1 { font-size: 1.4rem; margin-bottom: 14px; }
.entrar label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.entrar input { width: 100%; min-height: 44px; padding: 8px 12px; font-size: 16px; border: 1px solid #9ca3af; border-radius: 8px; }
.boton { width: 100%; min-height: 44px; margin-top: 12px; background: var(--acento); color: #fff; border: 0; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.error { color: var(--mal); margin-bottom: 12px; font-size: .92rem; }

a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
.lateral a:focus-visible, .lateral button:focus-visible { outline-color: #93c5fd; }

@media (max-width: 900px) {
  .barra-movil { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; height: 56px; padding: 0 16px; background: var(--lateral); }
  .barra-movil .logo { padding: 0; }
  .boton-menu { display: grid; gap: 4px; padding: 10px; margin-left: -10px; cursor: pointer; }
  .boton-menu span { display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; }
  .lateral { transform: translateX(-100%); transition: transform .2s ease; }
  .abrir-menu:checked ~ .lateral { transform: none; }
  .abrir-menu:checked ~ .velo { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .45); }
  .contenido { margin-left: 0; padding: 16px; }
  .cifras { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cifra strong { font-size: 1.35rem; }
  .tarjeta { padding: 16px; }
  .filtros, .selector { width: 100%; }
  .selector a { flex: 1; justify-content: center; padding: 4px 6px; }
  .fuentes li { grid-template-columns: 1fr auto; }
  .fuente-barra { grid-column: 1 / -1; grid-row: 2; }
}

/* Herramientas incrustadas */
.contenido.ancho { max-width: none; height: 100vh; display: flex; flex-direction: column; padding: 14px; }
.ancho .cabecera { margin-bottom: 10px; align-items: baseline; }
.ancho h1 { font-size: 1.35rem; }
.pantallas { flex: 1; min-height: 0; display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.pantallas.una { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.pantalla { display: flex; flex-direction: column; min-height: 0; background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; }
.pantalla-barra { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 8px 5px 12px; border-bottom: 1px solid var(--borde); }
.pantalla-barra h2 { font-size: .92rem; }
.pantalla-barra h2 small { font-weight: 400; color: var(--texto-2); margin-left: 6px; }
.pantalla-acciones { display: flex; gap: 4px; flex-shrink: 0; }
.pantalla-acciones a, .pantalla-acciones button { min-height: 30px; padding: 2px 9px; display: inline-flex; align-items: center; background: none; border: 1px solid var(--borde); border-radius: 6px; font: inherit; font-size: .8rem; color: var(--texto-2); text-decoration: none; cursor: pointer; }
.pantalla-acciones a:hover, .pantalla-acciones button:hover { color: var(--texto); background: var(--fondo); }
.pantalla iframe { flex: 1; min-height: 0; width: 100%; border: 0; background: #fff; }
.correos { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(150px, 38%) minmax(0, 1fr); }
.correos-lista { list-style: none; margin: 0; padding: 0; overflow-y: auto; border-right: 1px solid var(--borde); }
.correos-lista button { display: block; width: 100%; padding: 8px 10px; background: none; border: 0; border-bottom: 1px solid var(--borde); font: inherit; font-size: .84rem; text-align: left; color: var(--texto); cursor: pointer; }
.correos-lista button:hover { background: var(--fondo); }
.correos-lista button[aria-current="true"] { background: #eff6ff; box-shadow: inset 3px 0 0 var(--acento); }
.correos-lista small { display: block; color: var(--texto-2); font-size: .76rem; overflow-wrap: anywhere; }
.correos-aviso { padding: 12px; color: var(--texto-2); font-size: .86rem; }
.correos iframe { height: 100%; }

@media (max-width: 900px) {
  .contenido.ancho { height: auto; display: block; padding: 12px; }
  .pantallas, .pantallas.una { display: block; }
  .pantalla { height: 82vh; margin-bottom: 12px; }
  .correos { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 35%) minmax(0, 1fr); }
  .correos-lista { border-right: 0; border-bottom: 1px solid var(--borde); }
}

@media (prefers-reduced-motion: reduce) {
  .lateral { transition: none; }
}

/* Creador de webs */
.nota-creador { margin-bottom: 16px; border-left: 4px solid var(--bien); }
.nota-creador p { margin: 6px 0 0; }
.nota-creador code { font-size: 1.05rem; font-weight: 700; user-select: all; }
.webs-creadas { list-style: none; margin: 8px 0 0; padding: 0; }
.webs-creadas li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--borde); }
.webs-creadas small { display: block; color: var(--texto-2); }
.web-acciones { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.web-acciones a, .web-acciones summary { color: var(--acento); cursor: pointer; min-height: 32px; display: inline-flex; align-items: center; }
.web-acciones form { margin-top: 6px; }
.peligro { min-height: 38px; padding: 0 12px; border: 1px solid var(--mal); border-radius: 8px; background: #fff; color: var(--mal); cursor: pointer; }
.formulario-web { margin-top: 16px; }
.formulario-web fieldset { border: 0; border-top: 1px solid var(--borde); margin: 18px 0 0; padding: 14px 0 0; }
.formulario-web legend { font-weight: 700; padding-right: 10px; }
.formulario-web label { display: block; margin: 10px 0; font-size: .92rem; font-weight: 600; }
.formulario-web input:not([type=checkbox]):not([type=color]):not([type=file]), .formulario-web select, .formulario-web textarea { display: block; width: 100%; min-height: 40px; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--borde); border-radius: 8px; font: inherit; font-weight: 400; background: #fff; color: var(--texto); }
.formulario-web input[type=file] { display: block; margin-top: 6px; max-width: 100%; font-weight: 400; }
.formulario-web .casilla { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.colores { display: flex; flex-wrap: wrap; gap: 16px; }
.colores label { margin: 0; }
.colores input { display: block; width: 64px; height: 36px; margin-top: 4px; padding: 2px; border: 1px solid var(--borde); border-radius: 8px; background: #fff; }
.servicio, .dos { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; }
.servicio { grid-template-columns: 1fr 2fr; }
.error-form { color: var(--mal); font-weight: 600; }
.acciones-form { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 18px; }
.principal { min-height: 44px; padding: 0 22px; border: 0; border-radius: 8px; background: var(--acento); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
@media (max-width: 640px) { .servicio, .dos { grid-template-columns: 1fr; } }
