:root {
  --fondo: #eef2f7;
  --tarjeta: #ffffff;
  --texto: #14213d;
  --tenue: #5d6b85;
  --linea: #dbe2ed;
  --fv: #f2a516;
  --carga: #e4573d;
  --soc: #1aa38b;
  --activo: #0b6bcb;
  --nav-fondo: rgba(255, 255, 255, 0.94);
  --cielo-a: #0c1733;
  --cielo-b: #1c2d57;
  --radio: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0b1120;
    --tarjeta: #151d33;
    --texto: #e8edf7;
    --tenue: #93a1bf;
    --linea: #26324f;
    --fv: #f6b73c;
    --carga: #ff7a62;
    --soc: #34cdb2;
    --activo: #29b6ff;
    --nav-fondo: rgba(8, 12, 17, 0.94);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px calc(59px + 24px + env(safe-area-inset-bottom));
}

.plana { padding-top: calc(16px + env(safe-area-inset-top)); }
.cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cab h1 { margin: 0; font-size: 1.3rem; font-weight: 600; }
.cab .estado { color: var(--tenue); }
.cab .tarjeta:first-child { margin-top: 0; }

.entrada { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: var(--fondo); }
.entrada[hidden] { display: none; }
.entrada-caja { width: 100%; max-width: 340px; background: var(--tarjeta); border-radius: var(--radio); padding: 24px; }
.entrada-caja h2 { margin: 0 0 6px; font-size: 1.4rem; }
.entrada-caja input {
  width: 100%; margin-top: 16px; padding: 12px 14px;
  font: inherit; color: var(--texto); background: var(--fondo);
  border: 1px solid var(--linea); border-radius: 12px;
}
.entrada-caja .error { min-height: 1.4em; margin-top: 8px; font-size: 0.85rem; color: var(--carga); }
.entrada-caja button {
  width: 100%; margin-top: 4px; padding: 12px; font: inherit; font-weight: 600;
  color: #fff; background: var(--activo); border: 0; border-radius: 12px;
}
.entrada-caja button:disabled { opacity: 0.6; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--nav-fondo);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--linea);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs-fila { display: flex; height: 58px; max-width: 560px; margin: 0 auto; }
.tabs a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--tenue);
  text-decoration: none;
  font-size: 0.7rem; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.tabs a[aria-current] { color: var(--activo); }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

p { margin: 0; }

.etiqueta { font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }
.sub { font-size: 0.85rem; opacity: 0.85; min-height: 1.2em; }
small { font-size: 0.5em; font-weight: 500; margin-left: 0.25em; opacity: 0.85; }

.cielo {
  position: relative;
  margin: 0 -16px;
  padding: calc(18px + env(safe-area-inset-top)) 24px 28px;
  color: #fff;
  background: linear-gradient(180deg, var(--cielo-a), var(--cielo-b));
  border-radius: 0 0 32px 32px;
  transition: background 1.2s;
  overflow: hidden;
}

.estado { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; opacity: 0.9; }
.punto { width: 9px; height: 9px; border-radius: 50%; background: #8793ab; }
.punto.ok { background: #46d17a; }
.punto.tarde { background: #f2c14e; }
.punto.mal { background: #ff6b5e; }

.astro { position: absolute; right: 18px; top: 40px; width: 96px; height: 96px; transform-origin: center; transition: transform 1.4s ease-out; }
.grande { margin-top: 6px; font-size: 4.2rem; font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; }
.cielo .etiqueta { margin-top: 44px; }

.fichas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: -18px; position: relative; }
.ficha {
  background: var(--tarjeta);
  border-radius: 16px;
  padding: 12px 10px 10px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(10, 20, 50, 0.12);
}
.ficha .etiqueta { font-size: 0.66rem; color: var(--tenue); }
.ficha .valor { margin: 6px 0 2px; font-size: 1.45rem; font-weight: 600; }
.ficha .sub { color: var(--tenue); font-size: 0.75rem; }

.anillo { position: relative; width: 58px; height: 58px; margin: 4px auto 2px; }
.anillo svg { width: 100%; height: 100%; }
.anillo circle { fill: none; stroke-width: 4.5; }
.anillo .pista { stroke: var(--linea); }
.anillo .barra { stroke: var(--soc); stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: 113.1; transition: stroke-dashoffset 0.8s; }
.anillo span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 600; font-size: 0.95rem; }

.tarjeta {
  background: var(--tarjeta);
  border-radius: var(--radio);
  padding: 16px;
  margin-top: 14px;
}
.tarjeta h2 { margin: 0 0 6px; font-size: 1rem; font-weight: 600; }
.energia { font-size: 2.4rem; font-weight: 600; line-height: 1.1; color: var(--soc); }
.energia small { font-size: 0.9rem; font-weight: 500; margin-left: 0.4em; color: var(--tenue); }
.energia + .tenue { margin: 2px 0 10px; }
.texto { font-size: 0.95rem; }
.tenue { color: var(--tenue); font-size: 0.85rem; margin-top: 4px; }
.tarjeta .texto + .texto { margin-top: 8px; }

.cabecera { display: flex; align-items: center; justify-content: space-between; }
.cabecera h2 { margin: 0; }
.nav {
  width: 40px; height: 40px;
  border: 0; border-radius: 12px;
  background: var(--fondo); color: var(--texto);
  font-size: 1.5rem; line-height: 1;
}
.nav:disabled { opacity: 0.3; }

.lectura { min-height: 1.3em; margin-top: 6px; font-size: 0.82rem; color: var(--tenue); }
.grafica { width: 100%; height: auto; display: block; touch-action: pan-y; }
.grafica text { fill: var(--tenue); font-size: 9px; }
.grafica .rejilla { stroke: var(--linea); stroke-width: 0.6; }
.grafica .area-fv { fill: var(--fv); fill-opacity: 0.28; }
.grafica .l-fv { fill: none; stroke: var(--fv); stroke-width: 1.6; }
.grafica .l-carga { fill: none; stroke: var(--carga); stroke-width: 1.4; }
.grafica .l-soc { fill: none; stroke: var(--soc); stroke-width: 1.2; stroke-dasharray: 3 2; }
.grafica .cursor { stroke: var(--tenue); stroke-width: 0.8; }

.leyenda { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--tenue); }
.leyenda i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; }
.c-fv { background: var(--fv); }
.c-carga { background: var(--carga); }
.c-soc { background: var(--soc); }

.semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 150px; margin-top: 8px; }
.dia { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 0.7rem; color: var(--tenue); }
.dia .barras { display: flex; align-items: flex-end; gap: 3px; flex: 1; width: 100%; justify-content: center; }
.dia .barras b { display: block; width: 38%; border-radius: 4px 4px 0 0; min-height: 2px; }
.dia .barras b:first-child { background: var(--fv); }
.dia .barras b:last-child { background: var(--carga); }
.dia .kwh { color: var(--texto); font-weight: 600; margin-bottom: 3px; }
.dia .nombre { margin-top: 4px; }
.dia.hoy .nombre { color: var(--texto); font-weight: 700; }

.pie { margin-top: 18px; text-align: center; font-size: 0.75rem; color: var(--tenue); }
