/* Joule read-only dashboard — minimal hand-written dark theme, no framework. */

:root {
  --bg: #0a0e1a;
  --panel: #111827;
  --panel-edge: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --muted: #b0b8c8;
  --dim: #6b7a90;
  --accent: #00d4ff;
  --accent-green: #00ff88;
  --accent-gold: #c9a84c;
  --ok: #00ff88;
  --warn: #ffb800;
  --crit: #ff4466;
  --glow-blue: 0 0 20px rgba(0, 212, 255, 0.3);
  --glow-green: 0 0 20px rgba(0, 255, 136, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 16px 20px 40px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
header h1 { font-size: 20px; font-weight: 600; }
header .sub { color: var(--muted); font-size: 12px; }
header .spacer { flex: 1; }
.nav {
  align-items: center;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.nav a {
  color: var(--text);
  font-size: 12px;
}
.nav button {
  background: transparent;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  padding: 3px 8px;
}
.user-badge {
  color: var(--muted);
  font-size: 12px;
}

.key-control { display: flex; gap: 6px; align-items: center; }
.key-control input,
.inline-form input,
.form-grid input,
.form-grid select,
.toolbar select,
td input,
td select {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  color: var(--text);
  padding: 4px 8px;
}
.key-control input {
  width: 180px;
}
.key-control button,
.banner button,
.inline-form button,
.form-grid button,
.toolbar button,
td button,
.tab-btn {
  background: var(--accent);
  border: none;
  border-radius: 4px;
  color: #06222e;
  cursor: pointer;
  font-weight: 600;
  padding: 4px 10px;
}
button.danger { background: var(--crit); color: #2e0606; }

.banner {
  display: none;
  background: #3a1f1f;
  border: 1px solid var(--crit);
  border-radius: 6px;
  color: #ffd2d2;
  margin-bottom: 14px;
  padding: 10px 14px;
}
.banner.visible { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 0 8px;
}

.admin-band {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 10px 12px;
}
.auth-status { color: var(--muted); min-width: 220px; }
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.inline-form input { min-width: 180px; }

.tabs {
  border-bottom: 1px solid var(--panel-edge);
  display: flex;
  gap: 6px;
  margin: 12px 0 16px;
}
.tab-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom: none;
  padding: 8px 12px;
}
.tab-btn.active {
  background: var(--panel);
  border-color: var(--panel-edge);
  color: var(--text);
}
.tabpanel { display: none; }
.tabpanel.active { display: block; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}
.toolbar select { min-width: 260px; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.editor-label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
textarea {
  background: #0b1015;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  color: var(--text);
  display: block;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  min-height: 360px;
  padding: 10px;
  resize: vertical;
  text-transform: none;
  width: 100%;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label,
.login-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.field textarea {
  min-height: 120px;
}
.field-error {
  color: #ffd2d2;
  font-size: 12px;
  min-height: 16px;
}
.raw-toggle {
  align-self: end;
}
.checkline {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 6px;
}
td input,
td select {
  max-width: 180px;
  width: 100%;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 10px 14px;
}
.card .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.card .value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.card .value.ok { color: var(--ok); }
.card .value.warn { color: var(--warn); }
.card .value.crit { color: var(--crit); }
.card .detail { color: var(--muted); font-size: 12px; }
.copy-row {
  align-items: center;
  display: flex;
  gap: 8px;
}
.copy-row code {
  background: #0b1015;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  display: block;
  overflow-x: auto;
  padding: 4px 6px;
}
.copy-row button {
  background: var(--accent);
  border: none;
  border-radius: 4px;
  color: #06222e;
  cursor: pointer;
  padding: 4px 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 7px 12px;
  border-bottom: 1px solid var(--panel-edge);
  white-space: nowrap;
}
td.wrap { white-space: normal; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }
td.empty { color: var(--muted); text-align: center; padding: 14px; }

.badge {
  border-radius: 10px;
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 9px;
  text-transform: uppercase;
}
.badge.ok { background: rgba(61, 220, 132, 0.15); color: var(--ok); }
.badge.warn { background: rgba(255, 179, 71, 0.15); color: var(--warn); }
.badge.crit { background: rgba(255, 92, 92, 0.15); color: var(--crit); }
.badge.muted { background: rgba(130, 148, 165, 0.15); color: var(--muted); }

.bar {
  background: var(--panel-edge);
  border-radius: 4px;
  display: inline-block;
  height: 8px;
  overflow: hidden;
  vertical-align: middle;
  width: 70px;
}
.bar span { background: var(--ok); display: block; height: 100%; }
.bar.warn span { background: var(--warn); }
.bar.crit span { background: var(--crit); }

footer { color: var(--muted); font-size: 11px; margin-top: 24px; }

.login-page {
  background:
    linear-gradient(180deg, rgba(13, 18, 32, 0.96) 0%, rgba(10, 14, 26, 1) 100%),
    var(--bg);
  display: grid;
  min-height: 100vh;
  overflow-x: hidden;
  padding: 0;
  place-items: center;
  position: relative;
}
.login-energy-flow {
  height: 500px;
  opacity: 0.15;
  pointer-events: none;
  position: fixed;
  right: -80px;
  top: calc(50% - 250px);
  width: 500px;
  z-index: 0;
}
.login-energy-flow span {
  animation: login-ring-pulse 4s ease-in-out infinite;
  border: 2px solid var(--accent);
  border-radius: 50%;
  position: absolute;
}
.login-energy-flow span:nth-child(1) {
  animation-delay: 0s;
  height: 200px;
  left: 150px;
  top: 150px;
  width: 200px;
}
.login-energy-flow span:nth-child(2) {
  animation-delay: 0.5s;
  height: 300px;
  left: 100px;
  top: 100px;
  width: 300px;
}
.login-energy-flow span:nth-child(3) {
  animation-delay: 1s;
  height: 400px;
  left: 50px;
  top: 50px;
  width: 400px;
}
.login-energy-flow span:nth-child(4) {
  animation-delay: 1.5s;
  height: 500px;
  left: 0;
  top: 0;
  width: 500px;
}
@keyframes login-ring-pulse {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.05); }
}
.login-shell {
  align-items: stretch;
  display: grid;
  gap: 48px;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  max-width: 1200px;
  padding: 72px 24px;
  position: relative;
  width: 100%;
  z-index: 1;
}
.login-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 560px;
}
.login-brand {
  display: inline-flex;
  margin-bottom: 40px;
}
.login-brand img {
  height: 64px;
  object-fit: contain;
  width: 64px;
}
.login-label {
  color: var(--accent);
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.login-copy h1 {
  color: var(--text);
  font-size: 56px;
  font-weight: 800;
  line-height: 1.08;
  margin-bottom: 20px;
  max-width: 820px;
}
.login-copy h1 span {
  color: var(--accent);
}
.login-copy p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
  max-width: 680px;
}
.login-stats {
  border-top: 1px solid var(--panel-edge);
  display: grid;
  gap: 22px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 56px;
  padding-top: 30px;
}
.login-stats div {
  min-width: 0;
}
.login-stats strong {
  color: var(--accent);
  display: block;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 24px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.login-stats span {
  color: var(--dim);
  display: block;
  font-size: 13px;
  margin-top: 4px;
}
.login-form-panel {
  align-self: center;
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  padding: 40px 36px 36px;
  position: relative;
}
.login-product-badge {
  background: rgba(0, 255, 136, 0.12);
  border-radius: 4px;
  color: var(--accent-green);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  position: absolute;
  right: 24px;
  text-transform: uppercase;
  top: 24px;
}
.login-form-heading {
  margin-bottom: 24px;
  padding-right: 72px;
}
.login-form-heading h2 {
  color: var(--text);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
  text-transform: none;
}
.login-form-heading p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 8px;
}
.login-form {
  display: grid;
  gap: 14px;
}
.login-form input {
  background: #0a0e1a;
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  color: var(--text);
  display: block;
  font: inherit;
  margin-top: 6px;
  padding: 12px 13px;
  width: 100%;
}
.login-form input:focus {
  border-color: rgba(0, 212, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.14);
  outline: none;
}
.login-form button {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  box-shadow: var(--glow-blue);
  color: #0a0e1a;
  cursor: pointer;
  font-weight: 700;
  margin-top: 2px;
  padding: 13px 16px;
}
.login-form button:hover {
  background: var(--accent-green);
  box-shadow: var(--glow-green);
}

.stepper {
  border-bottom: 1px solid var(--panel-edge);
  display: flex;
  gap: 6px;
  margin: 12px 0 16px;
}
.step {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 12px;
}
.step.active {
  background: var(--panel);
  border-color: var(--panel-edge);
  color: var(--text);
}
.wizard-step {
  display: none;
}
.wizard-step.active {
  display: block;
}
.hint-list {
  display: grid;
  gap: 8px;
}
.hint {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
}

@media (max-width: 760px) {
  body { padding: 12px; }
  .login-page {
    align-items: start;
    padding: 18px;
  }
  .login-energy-flow { display: none; }
  .login-shell {
    gap: 22px;
    grid-template-columns: 1fr;
    padding: 0;
  }
  .login-brand-panel { min-height: 0; }
  .login-brand { margin-bottom: 12px; }
  .login-brand img { height: 44px; width: 44px; }
  .login-label { margin-bottom: 8px; }
  .login-copy h1 {
    font-size: 34px;
    margin-bottom: 12px;
  }
  .login-copy p {
    font-size: 14px;
    line-height: 1.55;
  }
  .login-stats {
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
    padding-top: 14px;
  }
  .login-stats strong {
    font-size: 16px;
  }
  .login-stats span {
    font-size: 10px;
  }
  .login-form-panel {
    border-radius: 8px;
    padding: 20px;
  }
  .login-product-badge {
    position: static;
    width: max-content;
    margin-bottom: 12px;
  }
  .login-form-heading { margin-bottom: 18px; }
  .login-form-heading h2 { font-size: 28px; }
  .login-form input { padding: 10px 12px; }
  .login-form button { padding: 12px 14px; }
  .login-form-heading { padding-right: 0; }
  .admin-band { align-items: stretch; flex-direction: column; }
  .split { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
  .toolbar select { min-width: 0; width: 100%; }
}

/* ===== Pilot Replay ===== */
.panel { background: var(--panel, #161b22); border: 1px solid var(--panel-edge, #30363d);
  border-radius: 8px; padding: 16px 20px; margin: 16px 0; }
.panel h2 { margin-top: 0; }
button.primary { background: var(--ok, #2ea043); color: #fff; border: none;
  padding: 8px 18px; border-radius: 6px; font-weight: 600; cursor: pointer; }
button.primary:disabled { opacity: .5; cursor: default; }
#validation-box { font-size: 1.05em; }
.replay-hero { display: flex; gap: 24px; flex-wrap: wrap; align-items: stretch; margin-bottom: 12px; }
.replay-savings, .replay-clock { flex: 1 1 280px; background: var(--panel-edge, #21262d);
  border-radius: 8px; padding: 14px 18px; }
.replay-savings .value { font-size: 2.4em; font-weight: 700; line-height: 1.1; }
.replay-clock .value { font-size: 1.4em; font-variant-numeric: tabular-nums; }
.replay-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.replay-controls button { padding: 6px 14px; border-radius: 6px; cursor: pointer; }
.event-log { max-height: 280px; overflow-y: auto; border: 1px solid var(--panel-edge, #30363d);
  border-radius: 6px; padding: 8px; font-size: .9em; background: rgba(0,0,0,.15); }
.event-row { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.event-row .time { color: var(--muted, #8b949e); font-variant-numeric: tabular-nums; margin-right: 6px; white-space: nowrap; }
