/* Energy Maxx AI — shared styles for the website, the node console and the owner console.
   Brand: Inter (UI) · Roboto Mono (numbers, labels, data) · Georgia (display serif, matches website)
   Palette: Terminal Black #231f20 · Deep Navy #13245c · Blue Ocean #0c68f0 · Teal Shores #00c0f3 · white · black */

:root {
  --black: #000;
  --terminal: #231f20;
  --navy: #13245c;
  --ocean: #0c68f0;
  --teal: #00c0f3;
  --white: #fff;

  --sans: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: Georgia, "Times New Roman", serif;

  --tap: 44px;
  --radius: 12px;
  --gutter: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

/* Each surface commits to one theme, set as a class on <html>. Every color below resolves from these tokens. */
.dark {
  color-scheme: dark;
  --bg: #000;
  --surface: color-mix(in srgb, var(--terminal) 55%, #000);
  --surface-2: var(--terminal);
  --surface-3: color-mix(in srgb, var(--terminal) 80%, #fff);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.58);
  --faint: rgba(255, 255, 255, 0.34);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.22);
  --accent: var(--ocean);
  --accent-ink: #fff;
  --signal: var(--ocean);
  --tint: color-mix(in srgb, var(--navy) 55%, transparent);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.light {
  color-scheme: light;
  --bg: #fff;
  --surface: #fff;
  --surface-2: rgba(35, 31, 32, 0.045);
  --surface-3: rgba(35, 31, 32, 0.09);
  --text: var(--terminal);
  --muted: rgba(35, 31, 32, 0.6);
  --faint: rgba(35, 31, 32, 0.38);
  --line: rgba(35, 31, 32, 0.13);
  --line-strong: rgba(35, 31, 32, 0.28);
  --accent: var(--ocean);
  --accent-ink: #fff;
  --signal: var(--ocean);
  --tint: color-mix(in srgb, var(--ocean) 8%, transparent);
  --shadow: 0 18px 50px rgba(35, 31, 32, 0.16);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
h2, h3 { text-wrap: balance; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
::placeholder { color: var(--faint); }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { letter-spacing: -0.01em; }
.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: grid; gap: 12px; }
.wrap { flex-wrap: wrap; }
.right { text-align: right; }
.hide-m { display: none; }
@media (min-width: 1024px) {
  .hide-m { display: initial; }
  .hide-d { display: none !important; }
}

/* Mark and wordmark */
.mark { width: 28px; height: 28px; flex: none; color: var(--text); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; }
.wordmark { font-family: var(--serif); font-size: 22px; letter-spacing: -0.01em; line-height: 1; }
.wordmark b { font-weight: 600; }

/* Buttons — every one is at least 44px tall */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.12s, transform 0.08s;
}
.btn:active { transform: translateY(1px); filter: brightness(0.94); }
.btn.lg { min-height: 52px; padding: 0 22px; font-size: 16px; }
.btn.sm { min-height: 44px; padding: 0 14px; font-size: 13.5px; }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn.quiet { background: var(--surface-2); color: var(--text); }
.btn.invert { background: var(--text); color: var(--bg); }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: var(--tap); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.added { background: var(--ok-bg, #e6f4ea); color: var(--ok-text, #1a7f37); border-color: var(--ok-line, #b7e0c3); cursor: default; }
.btn.danger { color: var(--danger, #d92d20); }
.btn.danger:active { background: var(--danger-bg, #fee4e2); }
.btn svg { width: 18px; height: 18px; flex: none; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.section { padding-block: 22px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.section-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.rule { height: 1px; background: var(--line); margin-block: 14px; }

/* Rows — the list unit both consoles are built from */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  width: 100%;
  background: none;
  border-left: 0; border-right: 0; border-bottom: 0;
  text-align: left;
}
.rows > .row:first-child { border-top: 0; }
.row .ico {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text);
}
.row .ico svg { width: 18px; height: 18px; }
.row .body { flex: 1; min-width: 0; }
.row .t { display: block; font-weight: 500; }
.row .s { display: block; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row .chev { color: var(--faint); flex: none; width: 18px; height: 18px; }
.row .end { flex: none; display: flex; align-items: center; gap: 8px; }
.row.empty { color: var(--faint); font-size: 13px; min-height: 40px; }

/* Tables that become stacked cards on a phone */
.tablewrap { width: 100%; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 8px 0; border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}
.table td { padding: 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table .num { white-space: nowrap; }
@media (max-width: 767px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: left; }
  .table td.r { text-align: right; }
  .table td::before {
    content: attr(data-l);
    color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
    padding-top: 3px; flex: none;
  }
  .table td.lead { display: block; font-weight: 600; padding-bottom: 6px; }
  .table td.lead::before { display: none; }
}

/* Forms */
.field { display: grid; gap: 6px; }
.field > label { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.field .req { color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); appearance: none;
}
select.input {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px;
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.grid2 { display: grid; gap: 14px; }
@media (min-width: 768px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.prefix { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.prefix > span { padding: 0 12px; font-family: var(--mono); color: var(--muted); border-right: 1px solid var(--line); align-self: stretch; display: flex; align-items: center; }
.prefix > input { border: 0; background: transparent; flex: 1; min-width: 0; min-height: var(--tap); padding: 10px 12px; }
.prefix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.prefix input:focus { outline: none; }

/* Toggle — a 44px hit area around a 30px pill */
.switch { position: relative; width: 58px; height: 44px; flex: none; background: transparent; border: 0; padding: 0; }
.switch::before { content: ""; position: absolute; left: 4px; top: 7px; width: 50px; height: 30px; border-radius: 999px; background: var(--surface-3); transition: background 0.15s; }
.switch::after {
  content: ""; position: absolute; top: 10px; left: 7px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.35); transition: transform 0.15s;
}
.switch[aria-checked="true"]::before { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* Badges and status */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap;
}
.badge.live { color: var(--signal); border-color: color-mix(in srgb, var(--signal) 45%, transparent); }
.badge.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.badge.solid { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.dot.pulse { animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); } 60% { box-shadow: 0 0 0 6px transparent; } }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 768px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: grid; gap: 4px; align-content: start; }
.tile .v { font-family: var(--mono); font-size: 24px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 12px; color: var(--muted); }

/* Collapsible */
details.fold { border-top: 1px solid var(--line); }
details.fold > summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 10px 0; cursor: pointer; font-weight: 500;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .chev { transition: transform 0.15s; color: var(--faint); width: 18px; height: 18px; }
details.fold[open] > summary .chev { transform: rotate(180deg); }
details.fold > .fold-body { padding: 4px 0 18px; }

/* Sheet — bottom sheet on phones, centered panel on wider screens */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--surface-2); color: var(--text);
  border-radius: 20px 20px 0 0; padding: 16px var(--gutter) calc(20px + var(--safe-b));
  max-height: 88dvh; overflow: auto; box-shadow: var(--shadow);
}
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 14px; }
@media (min-width: 768px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 32px)); border-radius: 18px; padding: 22px; }
  .sheet .grab { display: none; }
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  z-index: 60; box-shadow: var(--shadow); white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}
@media (min-width: 1024px) { .toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
