:root {
  color-scheme: dark;
  --bg: #07120f;
  --surface: rgba(15, 31, 27, .86);
  --line: rgba(174, 209, 198, .13);
  --text: #edf8f4;
  --muted: #8ea7a0;
  --green: #64d6b0;
  --yellow: #f6c85f;
  --red: #f2766b;
  --blue: #83a7ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    radial-gradient(circle at 15% 0%, #153a2e, transparent 34%),
    var(--bg);
  background-size: 42px 42px, 42px 42px, auto, auto;
  color: var(--text);
}
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(7, 18, 15, .8);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(100, 214, 176, .35);
  border-radius: 12px;
  background: rgba(100, 214, 176, .1);
}
.brand-mark svg { width: 20px; fill: var(--green); }
.brand strong { display: block; font-size: .84rem; letter-spacing: .18em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: .7rem; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.back-link { color: var(--green); font-size: .75rem; font-weight: 700; }
.back-link:hover { color: var(--text); }
.connection { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .78rem; font-weight: 650; }
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 5px rgba(246, 200, 95, .1);
}
.connection[data-state="online"] .status-dot { background: var(--green); box-shadow: 0 0 0 5px rgba(100,214,176,.1); }
.connection[data-state="offline"] .status-dot { background: var(--red); box-shadow: 0 0 0 5px rgba(242,118,107,.1); }

main, body > footer { width: min(1280px, calc(100% - 48px)); margin-inline: auto; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; padding: 54px 0 30px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: .67rem; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 4vw, 3.5rem); line-height: .98; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 1.12rem; letter-spacing: -.02em; }
.muted { margin-bottom: 0; color: var(--muted); }
.last-update { text-align: right; }
.last-update span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .72rem; }
.last-update strong { font-size: .86rem; }

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 25px 70px rgba(0, 0, 0, .16);
  backdrop-filter: blur(14px);
}
.filters { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)) auto auto; gap: 12px; padding: 16px; }
label span { display: block; margin: 0 0 7px 4px; color: var(--muted); font-size: .69rem; font-weight: 650; }
input, select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: rgba(2, 10, 8, .46);
  color: var(--text);
}
input:focus, select:focus { border-color: rgba(100,214,176,.65); box-shadow: 0 0 0 3px rgba(100,214,176,.08); }
.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  align-self: end;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-size: .76rem;
  font-weight: 750;
  transition: transform .15s ease;
}
.button:hover { transform: translateY(-1px); }
.primary { background: var(--green); color: #071510; }
.ghost { border-color: var(--line); background: rgba(255,255,255,.025); color: var(--text); }
.notice { margin-top: 16px; padding: 13px 16px; border: 1px solid rgba(242,118,107,.35); border-radius: 12px; background: rgba(242,118,107,.08); color: #ffb4ad; font-size: .8rem; }

.entity-hero { padding-bottom: 24px; }
.entity-nav {
  display: flex;
  gap: 5px;
  margin-bottom: 14px;
  padding-bottom: 5px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.entity-nav a {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}
.entity-nav a:hover { color: var(--text); }
.entity-nav a[aria-current="page"] {
  border-color: rgba(100,214,176,.25);
  background: rgba(100,214,176,.09);
  color: var(--green);
}
.entity-filters { grid-template-columns: repeat(3, minmax(150px, 1fr)) repeat(3, auto); }

.metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin: 18px 0; }
.metric {
  position: relative;
  min-width: 0;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(18,41,34,.9), rgba(9,24,20,.86));
}
.metric::after {
  position: absolute;
  right: -22px;
  bottom: -35px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
  filter: blur(42px);
  opacity: .15;
}
.solar { --accent: var(--yellow); }
.load { --accent: var(--red); }
.battery { --accent: var(--green); }
.grid { --accent: var(--blue); }
.metric-label { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; color: var(--muted); font-size: .72rem; font-weight: 650; }
.metric-label i {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent);
  font-size: .65rem;
  font-style: normal;
  font-weight: 850;
}
.metric strong { display: block; overflow: hidden; font-size: clamp(1.45rem, 2.3vw, 2rem); letter-spacing: -.04em; text-overflow: ellipsis; }
.metric strong small { color: var(--muted); font-size: .72rem; letter-spacing: 0; }
.metric p { margin: 7px 0 0; color: var(--muted); font-size: .68rem; }
.charge { height: 4px; margin-top: 13px; overflow: hidden; border-radius: 3px; background: rgba(255,255,255,.07); }
.charge span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width .4s ease; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .75fr); gap: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.badge { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: .66rem; }
.chart-wrap { position: relative; height: 360px; padding: 20px; }
.details { margin: 0; padding: 8px 24px 18px; }
.details div { display: flex; justify-content: space-between; gap: 20px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.details div:last-child { border-bottom: 0; }
.details dt { color: var(--muted); font-size: .72rem; }
.details dd { max-width: 60%; margin: 0; overflow: hidden; font-size: .75rem; font-weight: 650; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.records { margin-top: 18px; }
.records .button { align-self: center; }
.entity-table-panel { margin-top: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .76rem; }
th, td { padding: 15px 24px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(100,214,176,.025); }
.entity-table td {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entity-table .numeric { font-variant-numeric: tabular-nums; }
.entity-table td[data-status="ok"] { color: var(--green); font-weight: 750; }
.entity-table td[data-status="warning"] { color: var(--yellow); font-weight: 750; }
.empty { padding: 38px; color: var(--muted); text-align: center; }
.pagination {
  display: flex;
  width: auto;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .72rem;
}
.pagination > div { display: flex; gap: 8px; }
.pagination .button { min-height: 36px; padding-inline: 13px; }
.button:disabled { cursor: not-allowed; opacity: .38; transform: none; }
body > footer { display: flex; justify-content: space-between; padding: 30px 0 40px; color: var(--muted); font-size: .68rem; }
.not-found { min-height: 100vh; display: grid; align-content: center; justify-items: start; }
.not-found h1 { margin-bottom: 12px; }
.not-found .button { margin-top: 24px; }
.not-found code { color: var(--green); }

@media (max-width: 1100px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) {
  .site-header { padding-inline: 18px; }
  main, body > footer { width: min(100% - 28px, 1280px); }
  .hero { align-items: flex-start; padding-top: 38px; flex-direction: column; }
  .last-update { text-align: left; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters label:nth-child(3) { grid-column: 1 / -1; }
  .entity-filters { grid-template-columns: 1fr 1fr; }
  .entity-filters label:nth-child(3) { grid-column: 1 / -1; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .chart-wrap { height: 310px; padding: 12px; }
}
@media (max-width: 460px) {
  .brand small { display: none; }
  .header-actions { gap: 12px; }
  .connection { display: none; }
  .filters { grid-template-columns: 1fr; }
  .filters label:nth-child(3) { grid-column: auto; }
  .entity-filters { grid-template-columns: 1fr; }
  .entity-filters label:nth-child(3) { grid-column: auto; }
  .metrics { grid-template-columns: 1fr; }
  body > footer { flex-direction: column; gap: 7px; }
  .pagination { align-items: flex-start; flex-direction: column; gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
