/* ----------------- entity cards ------------------ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
/* `display: grid` outranks the user-agent `[hidden] { display: none }` rule, so a
   section hidden for a system that has no such device would still take up space.
   Same trap as .node in flow.css. */
.cards[hidden] { display: none; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.card.inv { border-top: 3px solid var(--accent); }
.card .c-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card .c-name { font-size: 16px; font-weight: 600; }
.card .c-badge { font-size: 11px; color: var(--muted); }
.card .c-badge.live { color: var(--ok); }
.card .c-badge.off  { color: var(--err); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 10px; }
.metric { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.metric .m-l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric .m-v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.metric .m-v .u { font-size: 11px; color: var(--muted); font-weight: 400; }
.metric.solar .m-v { color: var(--solar); }
.metric.charge .m-v { color: var(--battery); }
.metric.discharge .m-v { color: var(--discharge); }
/* battery current/power coloured by |current|: <40A green, <70A yellow, ≥70A red */
.metric.amp-ok   .m-v { color: var(--battery); }
.metric.amp-warn .m-v { color: var(--warn); }
.metric.amp-over .m-v { color: var(--err); }
/* AC / DC section labels inside the inverter card */
.sec-title { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; margin: 12px 0 6px; }
.sec-title:first-of-type { margin-top: 4px; }

/* load bar */
.load-bar { height: 8px; border-radius: 5px; background: var(--panel-3); overflow: hidden; }
.load-bar > div { height: 100%; background: var(--battery); width: 0; transition: width 0.5s, background 0.4s; }
.load-bar > div.ok   { background: var(--battery); }
.load-bar > div.warn { background: var(--warn); }
.load-bar > div.over { background: var(--err); }

.flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flag {
  font-size: 10px; padding: 3px 8px; border-radius: 999px;
  background: var(--panel-3); color: var(--muted); border: 1px solid transparent;
}
.flag.on { color: var(--battery); border-color: color-mix(in srgb, var(--battery) 40%, transparent); }

/* operating-mode banner — where the load is being fed from */
.mode {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; margin: 2px 0 2px;
  font-weight: 600; letter-spacing: 0.02em;
  --m: var(--idle);
  color: var(--m);
  background: color-mix(in srgb, var(--m) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--m) 45%, var(--border));
}
.mode .m-ico { font-size: 18px; line-height: 1; }
.mode .m-txt { display: flex; flex-direction: column; gap: 1px; }
.mode .m-sub { font-size: 10px; font-weight: 500; color: var(--muted); letter-spacing: 0.03em; }
.mode.mode-battery   { --m: var(--discharge); }
.mode.mode-grid      { --m: var(--grid); }
.mode.mode-no_output { --m: var(--err); }
/* Only reachable before the first decided sample: afterwards the server holds
   the last known mode (solar/entities.py `_display_mode`). */
.mode.mode-undetermined { --m: var(--muted); }
.mode .m-warn { margin-left: auto; font-size: 16px; line-height: 1; color: var(--warn); }

/* consumers under an inverter */
.consumers { display: flex; flex-direction: column; gap: 8px; }
.consumers .c-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.consumer {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border-radius: 8px; padding: 8px 10px;
}
.consumer .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; }
.consumer.on .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.consumer.offline .dot { background: var(--err); }
.consumer .ico { font-size: 16px; }
.consumer .c-n { font-size: 13px; font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.consumer .c-w { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.consumer .c-w .u { font-size: 11px; color: var(--muted); font-weight: 400; }
.consumer .c-meta { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* battery cells */
/* One tile per series cell. 8 columns suits both pack sizes on the market here:
   an 8s pack is a single row, a 16s pack two tidy rows of 8. */
.cells { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.cell { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 2px; text-align: center; }
.cell .n { font-size: 9px; color: var(--muted); }
.cell .v { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cell.high { border-color: var(--battery); }
.cell.low  { border-color: var(--discharge); }
@media (max-width: 520px) { .cells { grid-template-columns: repeat(4, 1fr); } }

.soc-bar { height: 10px; border-radius: 6px; background: var(--panel-3); overflow: hidden; }
.soc-bar > div { height: 100%; background: linear-gradient(90deg, var(--discharge), var(--battery)); width: 0; transition: width 0.6s; }
