:root {
  color-scheme: light;
  --fondo: #f4f4f1;
  --superficie: #fcfcfb;
  --texto: #0b0b0b;
  --texto-2: #52514e;
  --texto-3: #85847f;
  --rejilla: #e6e5e0;
  --borde: #dddcd6;
  --acento: #2a78d6;
  --auto: #1baf7a;      /* autoconsumo */
  --red: #eb6834;       /* comprado a la red */
  --vertido: #2a78d6;   /* vertido a la red */
  --bien: #008300;
  --mal: #c4332f;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --fondo: #121211;
    --superficie: #1a1a19;
    --texto: #f0efec;
    --texto-2: #c3c2b7;
    --texto-3: #8f8e86;
    --rejilla: #2c2c2a;
    --borde: #33332f;
    --acento: #3987e5;
    --auto: #199e70;
    --red: #d95926;
    --vertido: #3987e5;
    --bien: #0ca30c;
    --mal: #e66767;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); color: var(--texto);
       font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
         padding: .75rem 1.25rem; background: var(--superficie); border-bottom: 1px solid var(--borde);
         position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.marca { font-weight: 700; }
nav { display: flex; gap: .25rem; flex-wrap: wrap; }
nav a { padding: .35rem .75rem; border-radius: 6px; color: var(--texto-2); text-decoration: none; }
nav a.activo { background: var(--fondo); color: var(--texto); font-weight: 600; }
nav a.salir { color: var(--texto-3); }
main { max-width: 1180px; margin: 0 auto; padding: 1.25rem; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
a { color: var(--acento); }
.cabecera { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
            margin-bottom: 1rem; flex-wrap: wrap; }
.mesnav { display: flex; align-items: center; gap: .5rem; }
.mesnav a, .boton, button { display: inline-block; padding: .4rem .8rem; border-radius: 6px;
  border: 1px solid var(--borde); background: var(--superficie); color: var(--texto);
  text-decoration: none; font: inherit; cursor: pointer; }
.boton.principal, button.principal { background: var(--acento); border-color: var(--acento); color: #fff; }
button.peligro { color: var(--mal); }
.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem;
            margin-bottom: 1rem; }
.tarjeta { background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px; padding: .85rem 1rem; }
.tarjeta .etq { font-size: .8rem; color: var(--texto-2); display: flex; align-items: center; gap: .4rem; }
.tarjeta .valor { font-size: 1.55rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tarjeta .valor small { font-size: .85rem; font-weight: 500; color: var(--texto-2); }
.tarjeta .sub { font-size: .8rem; color: var(--texto-3); }
.punto { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.panel { background: var(--superficie); border: 1px solid var(--borde); border-radius: 10px;
         padding: 1rem 1.1rem; margin-bottom: 1rem; }
.rejilla2 { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
@media (max-width: 820px) { .rejilla2 { grid-template-columns: 1fr; } }
.grafico { position: relative; height: 300px; }
.nota { font-size: .82rem; color: var(--texto-3); margin: .5rem 0 0; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .4rem .5rem; border-bottom: 1px solid var(--rejilla); text-align: right; }
th:first-child, td:first-child { text-align: left; }
th { font-size: .8rem; color: var(--texto-2); font-weight: 600; }
tr.total td { font-weight: 650; border-top: 2px solid var(--borde); }
.tabla-scroll { overflow-x: auto; }
.ok { color: var(--bien); font-weight: 600; }
.revisar { color: var(--mal); font-weight: 600; }
.aviso { background: var(--superficie); border-left: 4px solid var(--acento); padding: .6rem .9rem;
         border-radius: 6px; margin-bottom: .75rem; }
.consejo { border-left: 4px solid var(--auto); }
details summary { cursor: pointer; color: var(--texto-2); }
form.campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
label { font-size: .85rem; color: var(--texto-2); display: flex; flex-direction: column; gap: .25rem; }
input, select, textarea { font: inherit; padding: .45rem .55rem; border-radius: 6px;
  border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); }
.login { max-width: 340px; margin: 12vh auto; }
.login form { display: flex; flex-direction: column; gap: .75rem; }
pre { white-space: pre-wrap; font-size: .75rem; max-height: 340px; overflow: auto;
      background: var(--fondo); padding: .75rem; border-radius: 6px; }
