/* ============================================================
   mijnECactus — energy command center theme
   Dark default, light via html[data-theme="light"].
   ============================================================ */

:root,
html[data-theme="dark"] {
  --bg: #0b1120;               /* deep slate */
  --bg-soft: #111a2e;
  --surface: #16213a;
  --surface-2: #1d2a47;
  --border: #26345e;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #2dd4bf;           /* energy cyan/teal */
  --accent-2: #f59e0b;         /* amber (discharge) */
  --charge: #34d399;           /* green (charge) */
  --discharge: #fbbf24;        /* amber (discharge) */
  --danger: #f87171;
  --glow: 0 0 24px rgba(45, 212, 191, .18);
  --radius: 14px;
  --shadow: 0 8px 30px rgba(2, 6, 23, .45);
}

html[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-soft: #e8eef5;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #d7e0ec;
  --text: #0f172a;
  --text-dim: #64748b;
  --accent: #0d9488;
  --accent-2: #d97706;
  --charge: #059669;
  --discharge: #d97706;
  --danger: #dc2626;
  --glow: none;
  --shadow: 0 6px 20px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(45, 212, 191, .07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(245, 158, 11, .05), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

html[data-theme="light"] body {
  background: var(--bg);
}

code, .key {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: .9em;
  background: var(--bg-soft);
  padding: .1em .4em;
  border-radius: 6px;
  word-break: break-all;
}

a { color: var(--accent); }
.link { color: var(--accent); }
.muted { color: var(--text-dim); }

/* ---- Topbar ------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 1.05rem;
  letter-spacing: .01em;
}
.brand strong { color: var(--accent); }
.brand__bolt {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #07121f;
  font-size: 1rem;
  box-shadow: var(--glow);
}

.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav__link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 10px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: .92rem;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav__link:hover { color: var(--text); background: var(--surface); }
.nav__link--active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.nav__icon { font-size: .95rem; }

.topbar__actions { display: flex; align-items: center; gap: 8px; }
.theme-form { display: inline; }

.iconbtn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  list-style: none;
}
summary.iconbtn::-webkit-details-marker { display: none; }

.navdd { position: relative; }
.navdd__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.navdd__user {
  padding: 8px 10px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.navdd__panel a,
.navdd__panel button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  text-decoration: none;
  font-size: .92rem;
  cursor: pointer;
}
.navdd__panel a:hover,
.navdd__panel button:hover { background: var(--surface-2); }

/* ---- Layout ------------------------------------------------ */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.page__head { margin-bottom: 22px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .72rem;
  color: var(--accent);
  margin: 0 0 2px;
}
.page__title { margin: 0; font-size: 1.7rem; font-weight: 650; }
.page__lead { margin: 4px 0 0; color: var(--text-dim); }
.page--center { text-align: center; padding-top: 12vh; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---- Cards ------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card--highlight { border-color: var(--accent); box-shadow: var(--glow); }
.card__title { margin: 0 0 8px; font-size: 1.05rem; font-weight: 650; }
.card__hint { color: var(--text-dim); font-size: .88rem; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
}
.stat__value { font-size: 1.9rem; font-weight: 700; color: var(--accent); }
.stat__hint { font-size: .82rem; color: var(--text-dim); }

/* ---- Forms ------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: .85rem; color: var(--text-dim); }
.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: .95rem;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.input--code { letter-spacing: .35em; font-size: 1.2rem; text-align: center; }
select.input { appearance: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s, background .15s;
}
.btn--primary {
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #06121f;
  box-shadow: var(--glow);
}
.btn--primary:hover { filter: brightness(1.1); }
.btn--outline {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
.btn--outline:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.btn--ghost { background: transparent; color: var(--text-dim); }
.btn--ghost:hover { color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 12px; font-size: .85rem; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.inline-form { display: inline-block; margin-left: 10px; }

/* ---- Auth -------------------------------------------------- */
.auth {
  min-height: calc(100vh - 60px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth__card { width: 100%; max-width: 400px; }
.auth__head { text-align: center; margin-bottom: 18px; }
.auth__bolt {
  display: inline-grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #07121f;
  font-size: 1.6rem;
  box-shadow: var(--glow);
  margin-bottom: 10px;
}
.auth__title { margin: 0; font-size: 1.5rem; font-weight: 500; }
.auth__title strong { color: var(--accent); }
.auth__sub { color: var(--text-dim); font-size: .9rem; margin: 6px 0 0; }
.auth__divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: .8rem;
  margin: 16px 0;
}
.auth__divider::before,
.auth__divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth__hint { font-size: .85rem; color: var(--text-dim); text-align: center; min-height: 1.2em; }

/* ---- Notices / flash --------------------------------------- */
.notice {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: .9rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 14px;
}
.notice--accent { border-color: var(--accent); }
.notice--warn { border-color: var(--discharge); }

.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: .92rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.flash--success { border-left-color: var(--charge); }
.flash--error { border-left-color: var(--danger); }
.flash--info { border-left-color: var(--accent); }

/* ---- Lists / misc ------------------------------------------ */
.list { list-style: none; margin: 0 0 12px; padding: 0; }
.list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.list__row:last-child { border-bottom: 0; }

.codes {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  font-family: Consolas, monospace;
  font-size: 1.05rem;
}
.codes li {
  background: var(--bg-soft);
  padding: 8px 10px;
  border-radius: 8px;
  text-align: center;
}

.status { font-weight: 700; margin: 4px 0; }
.status--on { color: var(--charge); }
.status--off { color: var(--text-dim); }

.badge {
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.badge--muted { color: var(--text-dim); }
.badge--charge { color: var(--charge); border-color: var(--charge); }
.badge--discharge { color: var(--discharge); border-color: var(--discharge); }

.reveal summary { cursor: pointer; color: var(--text-dim); font-size: .88rem; }

@media (max-width: 720px) {
  .nav__label { display: none; }
  .nav__link { padding: 8px 11px; }
  .container { padding: 16px 12px 50px; }
}

/* ---- Energy flow diagram ----------------------------------- */
.flowcard { margin: 16px 0; }
.flow { width: 100%; max-width: 720px; display: block; margin: 0 auto; }
.flow__node circle {
  fill: var(--surface-2);
  stroke: var(--border);
  stroke-width: 2;
}
.flow__node text { fill: var(--text); font-size: 20px; }
.flow__node .flow__val { font-size: 11px; fill: var(--text-dim); }
.flow__node--solar circle { stroke: var(--discharge); }
.flow__node--battery circle { stroke: var(--charge); }
.flow__node--grid circle { stroke: var(--accent); }
.flow__node--home circle { stroke: var(--danger); }
.flow__hub { fill: var(--accent); }
.flow__link {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
  stroke-linecap: round;
}
.flow__link--active {
  stroke: var(--accent);
  stroke-dasharray: 6 10;
  animation: flowdash 1.2s linear infinite;
  filter: drop-shadow(0 0 4px var(--accent));
}
.flow__link--active.flow__link--reverse { animation-direction: reverse; }
@keyframes flowdash { to { stroke-dashoffset: -16; } }

/* ---- SoC bar ------------------------------------------------ */
.socbar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
  margin: 6px 0 2px;
}
.socbar__fill { height: 100%; width: 0; border-radius: 999px; transition: width .6s; }

/* ---- Plan strip --------------------------------------------- */
.planstrip { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; }
.planstrip__slot {
  min-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: .78rem;
}
.planstrip__hour { color: var(--text-dim); }
.planstrip__icon { font-size: 1rem; }
.planstrip__bat { color: var(--text-dim); font-size: .72rem; }
.planstrip__bat::after { content: " kWh"; font-size: .6rem; }
.planstrip__slot--charge { border-color: var(--charge); }
.planstrip__slot--charge .planstrip__icon { color: var(--charge); }
.planstrip__slot--discharge { border-color: var(--discharge); }
.planstrip__slot--discharge .planstrip__icon { color: var(--discharge); }
.planstrip__slot--self-powered .planstrip__icon { color: var(--accent); }

/* ---- Tables -------------------------------------------------- */
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.pos { color: var(--charge); }
.neg { color: var(--danger); }
.action--charge { color: var(--charge); font-weight: 600; }
.action--discharge { color: var(--discharge); font-weight: 600; }
.action--self-powered { color: var(--accent); }
.action--backup, .action--hold { color: var(--text-dim); }
