 :root {
      --blue:    #1565C0;
      --blue-lt: #E3F0FF;
      --blue-md: #1976D2;
      --teal:    #00897B;
      --teal-lt: #E0F2F1;
      --amber:   #F57F17;
      --amber-lt:#FFF8E1;
      --red:     #C62828;
      --red-lt:  #FFEBEE;
      --green:   #2E7D32;
      --green-lt:#E8F5E9;
      --purple:  #6A1B9A;
      --purple-lt:#F3E5F5;
      --gray:    #546E7A;
      --gray-lt: #ECEFF1;
      --border:  #E0E6EF;
      --text:    #1a2236;
      --muted:   #6B7A99;
      --surface: #F6F9FF;
    }

    *, *::before, *::after { box-sizing: border-box; }
    body {
      font-family: 'Inter', sans-serif;
      background: var(--surface);
      color: var(--text);
      min-height: 100vh;
    }

    /* -- TOPBAR ----------------------------------- */
    .topbar {
      background: #fff;
      border-bottom: 1px solid var(--border);
      padding: 0 1.5rem;
      height: 64px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: sticky;
      top: 0;
      z-index: 100;
    }
    .topbar-brand {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .brand-dot {
      width: 36px; height: 36px;
      border-radius: 10px;
      background: var(--blue);
      display: flex; align-items: center; justify-content: center;
    }
    .brand-dot svg { width: 20px; height: 20px; }
    .brand-title {
      font-size: .95rem;
      font-weight: 600;
      color: var(--text);
      line-height: 1.1;
    }
    .brand-sub {
      font-size: .7rem;
      font-weight: 400;
      color: var(--muted);
    }
    .topbar-meta {
      display: flex;
      align-items: center;
      gap: 20px;
    }
    .meta-chip {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: .78rem;
      color: var(--muted);
    }
    .meta-chip svg { width: 14px; height: 14px; flex-shrink: 0; }
    .status-pill {
      display: flex;
      align-items: center;
      gap: 6px;
      background: var(--green-lt);
      color: var(--green);
      border-radius: 20px;
      font-size: .72rem;
      font-weight: 600;
      padding: .3em .8em;
    }
    .status-pill.offline { background: var(--red-lt); color: var(--red); }
    .status-dot {
      width: 6px; height: 6px;
      border-radius: 50%;
      background: currentColor;
      animation: blink 2s infinite;
    }
    .status-pill.offline .status-dot { animation: none; }
    @keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

    /* -- HERO BATTERY ----------------------------- */
    .hero-card {
      background: linear-gradient(135deg, var(--blue) 0%, #1976D2 60%, #1E88E5 100%);
      border-radius: 18px;
      padding: 1.5rem 2rem;
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: .25rem;
      margin-bottom: .25rem;
    }
    .hero-label {
      font-size: .7rem;
      font-weight: 600;
      letter-spacing: .1em;
      text-transform: uppercase;
      opacity: .75;
      margin-bottom: .25rem;
    }
    .hero-value {
      font-size: 2.6rem;
      font-weight: 700;
      line-height: 1;
    }
    .hero-value .unit { font-size: 1rem; font-weight: 400; margin-left: 4px; opacity: .8; }
    .hero-time {
      font-size: .78rem;
      opacity: .7;
      margin-top: .4rem;
    }
    .hero-icon {
      width: 64px; height: 64px;
      background: rgba(255,255,255,.15);
      border-radius: 16px;
      display: flex; align-items: center; justify-content: center;
    }
    .hero-icon svg { width: 36px; height: 36px; }

    /* -- SENSOR CARDS ----------------------------- */
    .sensor-card {
      background: #fff;
      border: 1px solid var(--border);
      border-radius: 16px;
      padding: 1.25rem 1.4rem;
      height: 100%;
      display: flex;
      flex-direction: column;
      gap: 10px;
      transition: box-shadow .18s ease, border-color .18s ease;
      position: relative;
      overflow: hidden;
    }
    .sensor-card::after {
      content: '';
      position: absolute;
      left: 0; top: 0; bottom: 0;
      width: 4px;
      border-radius: 16px 0 0 16px;
      background: var(--card-accent, var(--blue));
    }
    .sensor-card:hover {
      box-shadow: 0 4px 24px rgba(21,101,192,.1);
      border-color: #c5d8f5;
    }
    .sensor-card.alarma {
      border-color: #ffc5c5;
      --card-accent: var(--red);
    }
    .sensor-card.alarma:hover { box-shadow: 0 4px 24px rgba(198,40,40,.1); }

    .card-header-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .icon-wrap {
      width: 42px; height: 42px;
      border-radius: 12px;
      display: flex; align-items: center; justify-content: center;
      background: var(--icon-bg, var(--blue-lt));
      flex-shrink: 0;
    }
    .icon-wrap svg { width: 24px; height: 24px; }

    .alarma-chip {
      font-size: .65rem;
      font-weight: 700;
      letter-spacing: .06em;
      text-transform: uppercase;
      background: var(--red-lt);
      color: var(--red);
      border-radius: 20px;
      padding: .2em .7em;
    }

    .sensor-name {
      font-size: .7rem;
      font-weight: 600;
      letter-spacing: .06em;
      text-transform: uppercase;
      color: var(--muted);
    }
    .sensor-value {
      font-size: 2rem;
      font-weight: 700;
      color: var(--text);
      line-height: 1;
    }
    .sensor-value .unit {
      font-size: .85rem;
      font-weight: 400;
      color: var(--muted);
      margin-left: 3px;
    }
    .sensor-card.alarma .sensor-value { color: var(--red); }

    /* -- SECTION TITLE ---------------------------- */
    .section-label {
      font-size: .7rem;
      font-weight: 700;
      letter-spacing: .1em;
      text-transform: uppercase;
      color: var(--muted);
      padding: 1.25rem 0 .5rem;
    }

    /* -- SKELETON --------------------------------- */
    .sk {
      background: linear-gradient(90deg, #eef2f7 25%, #dde5f0 50%, #eef2f7 75%);
      background-size: 200% 100%;
      animation: shimmer 1.4s infinite;
      border-radius: 8px;
    }
    @keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

    /* -- FOOTER ----------------------------------- */
    .page-footer {
      padding: 1rem 1.5rem;
      text-align: center;
      font-size: .72rem;
      color: var(--muted);
      border-top: 1px solid var(--border);
      margin-top: 2rem;
      background: #fff;
    }
    #bat-info {
      font-size: .72rem;
      color: var(--muted);
    }
    #hero-valor {
      font-weight: 600;
      color: var(--text);
    }
    #hero-time2 {
      font-size: .68rem;
    }

    /* -- ERROR ------------------------------------ */
    .error-banner {
      background: var(--red-lt);
      border: 1px solid #ffc5c5;
      border-radius: 12px;
      color: var(--red);
      padding: 1rem 1.25rem;
      font-size: .85rem;
      display: none;
      margin-bottom: 1rem;
    }

    /* -- IEA --------------------------------------- */
    .iea-section {
      margin-top: 2rem;
    }
    .iea-card {
      background: #fff;
      border: 1px solid var(--border);
      border-radius: 16px;
      overflow: hidden;
      box-shadow: 0 2px 12px rgba(21,101,192,.07);
    }
    .iea-header {
      padding: 1.25rem 1.5rem 1rem;
      border-bottom: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: .65rem;
    }
    .iea-title {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .iea-icon {
      width: 42px; height: 42px;
      border-radius: 12px;
      background: #E8F5E9;
      color: #2E7D32;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0;
      transition: background .3s, color .3s;
    }
    .iea-icon svg { width: 22px; height: 22px; }
    .iea-label {
      font-size: .7rem;
      font-weight: 700;
      letter-spacing: .08em;
      text-transform: uppercase;
      color: var(--muted);
      margin-bottom: 1px;
    }
    .iea-sublabel {
      font-size: .68rem;
      color: var(--muted);
    }
    .iea-result {
      display: flex;
      align-items: baseline;
      gap: 12px;
      padding-left: 2px;
    }
    .iea-value {
      font-size: 2.8rem;
      font-weight: 700;
      line-height: 1;
      color: var(--text);
      transition: color .3s;
    }
    .iea-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      border-radius: 20px;
      font-size: .75rem;
      font-weight: 700;
      letter-spacing: .04em;
      padding: .35em 1em;
      transition: background .3s, color .3s;
    }
    
     .iea-badge_big {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      border-radius: 20px;
      font-size: 1.2rem;
      font-weight: 800;
      letter-spacing: .04em;
      padding: .35em 1em;
      transition: background .3s, color .3s;
    }

    
    
    /* estados por clase */
    .iea-inestable  { background: #E8F5E9; color: #1B5E20; }
    .iea-neutra     { background: #F9FBE7; color: #558B2F; }
    .iea-estable    { background: #FFFDE7; color: #F57F17; }
    .iea-muyestable { background: #FFEBEE; color: #B71C1C; }
    .iea-nodisponible { background: var(--gray-lt); color: var(--gray); }
    
    
    
   
    .iea-body {
      padding: 1rem 1.5rem 1.25rem;
    }
    .iea-formula {
      font-size: .72rem;
      color: var(--muted);
      margin-bottom: 1rem;
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
    }
    .iea-formula code {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: .15em .5em;
      font-size: .72rem;
      color: var(--blue);
    }

    /* tabla de rangos */
    .iea-table {
      width: 100%;
      border-collapse: collapse;
      font-size: .78rem;
    }
    .iea-table th {
      font-size: .62rem;
      font-weight: 700;
      letter-spacing: .08em;
      text-transform: uppercase;
      color: var(--muted);
      padding: .4rem .75rem;
      border-bottom: 1px solid var(--border);
      text-align: left;
    }
    .iea-table td {
      padding: .5rem .75rem;
      border-bottom: 1px solid #f0f4fa;
      vertical-align: middle;
    }
    .iea-table tr:last-child td { border-bottom: none; }
    .iea-table tr.active-row td { background: #F6F9FF; font-weight: 600; }
    .range-dot {
      display: inline-block;
      width: 10px; height: 10px;
      border-radius: 50%;
      margin-right: 6px;
      vertical-align: middle;
    }
    .dot-green     { background: #43A047; }
    .dot-lime      { background: #9CCC65; }
    .dot-yellow    { background: #FDD835; }
    .dot-red       { background: #E53935; }