:root {
  --graphite: #14181c;
  --panel: #1d242b;
  --panel-edge: #2b343d;
  --phosphor: #ffb454;
  --steel: #7aa2c4;
  --ink: #d9e1e8;
  --ink-dim: #8a949d;
  --ok: #4ade80;
  --warn: #f2c14e;
  --fault: #e5636b;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --display: "Chakra Petch", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--graphite);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  background-image: repeating-linear-gradient(
    0deg, transparent, transparent 3px, rgba(255,255,255,0.008) 3px, rgba(255,255,255,0.008) 4px
  );
}

/* ---------------------------------------------------------- nameplate */
.nameplate {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 2px solid var(--phosphor);
  background: linear-gradient(180deg, #1a2026, var(--graphite));
}
.nameplate-id { display: flex; align-items: center; gap: 14px; }
.nameplate-mark { color: var(--phosphor); font-size: 26px; }
.nameplate h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.22em;
  margin: 0;
}
.nameplate-sub {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
}
.nameplate-nav { display: flex; align-items: center; gap: 18px; }
.nav-link {
  color: var(--steel);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-link:hover { color: var(--phosphor); }
.nav-dim { color: var(--ink-dim); }
.nav-user { font-size: 12px; color: var(--ink); }

main { padding: 24px; max-width: 1280px; margin: 0 auto; }

/* -------------------------------------------------------------- login */
.login-panel { display: grid; place-items: center; min-height: 60vh; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-top: 3px solid var(--phosphor);
  padding: 36px 44px;
  text-align: center;
  max-width: 420px;
}
.login-card h2 { font-family: var(--display); letter-spacing: 0.06em; margin: 14px 0 8px; }
.login-card p { color: var(--ink-dim); font-size: 13px; }
.login-led {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
  animation: breathe 2.4s ease-in-out infinite;
}

/* ------------------------------------------------------------ buttons */
.btn {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  color: var(--steel);
  border: 1px solid var(--steel);
  padding: 8px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { color: var(--phosphor); border-color: var(--phosphor); }
.btn-primary { color: var(--graphite); background: var(--phosphor); border-color: var(--phosphor); font-weight: 600; }
.btn-primary:hover { color: var(--graphite); filter: brightness(1.08); }
.btn:focus-visible, .tab:focus-visible, a:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 2px;
}

/* ----------------------------------------------------------- console */
.console-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.stat-row { display: flex; gap: 28px; }
.stat { display: flex; flex-direction: column; }
.stat-num {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 700;
  color: var(--phosphor);
  line-height: 1;
}
.stat-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.console-actions { display: flex; gap: 12px; align-items: center; }
#filterBox {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 12px;
  min-width: 260px;
}
#filterBox:focus { outline: none; border-color: var(--phosphor); }

/* --- the rail: nodes as DIN-mounted modules --- */
.rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2px;
  background: var(--panel-edge);
  border: 1px solid var(--panel-edge);
  border-top: 6px solid var(--panel-edge);
}
.module {
  background: var(--panel);
  padding: 14px 16px 12px;
  position: relative;
  border-top: 1px solid #333d47;
}
.module::before {
  content: "";
  position: absolute;
  top: 0; left: 12px; right: 12px;
  height: 3px;
  background: repeating-linear-gradient(90deg, #39434d 0 6px, transparent 6px 12px);
}
.module-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.led {
  width: 10px; height: 10px; border-radius: 50%;
  background: #3a444e;
  flex: none;
}
.led.on {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: breathe 2.4s ease-in-out infinite;
}
.led.expired { background: var(--fault); box-shadow: 0 0 6px var(--fault); }
.module-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.module-user { margin-left: auto; font-size: 11px; color: var(--steel); }
.module-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; min-height: 20px; }
.tag {
  font-size: 10px;
  letter-spacing: 0.04em;
  border: 1px solid var(--panel-edge);
  color: var(--ink-dim);
  padding: 1px 7px;
}
.tag.scada { border-color: var(--fault); color: var(--fault); }
.tag.robotics { border-color: var(--steel); color: var(--steel); }
.tag.gateway, .tag.gateway-res { border-color: var(--phosphor); color: var(--phosphor); }
.module-meta { font-size: 11px; color: var(--ink-dim); }
.module-meta span { display: inline-block; margin-right: 14px; }

.gauges { display: flex; gap: 10px; margin-top: 8px; }
.gauge { flex: 1; }
.gauge-label {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  display: flex;
  justify-content: space-between;
}
.gauge-track { height: 4px; background: #2a333c; margin-top: 3px; }
.gauge-fill { height: 100%; background: var(--steel); transition: width 0.6s ease; }
.gauge-fill.hot { background: var(--warn); }
.gauge-fill.crit { background: var(--fault); }

.module-actions { display: flex; gap: 8px; margin-top: 10px; }
.mini {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: none;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  padding: 2px 0;
}
.mini:hover { color: var(--phosphor); }
.mini.danger:hover { color: var(--fault); }

/* ------------------------------------------------------------- drawer */
.drawer[hidden] { display: none; }
.drawer {
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 16, 0.7);
  display: grid;
  place-items: center;
  z-index: 50;
}
.drawer-body {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-top: 3px solid var(--phosphor);
  padding: 26px 30px;
  width: min(460px, 92vw);
}
.drawer-body h3 { font-family: var(--display); margin: 0 0 4px; letter-spacing: 0.05em; }
.drawer-hint { font-size: 12px; color: var(--ink-dim); margin-top: 0; }
.drawer-body label { display: block; font-size: 11px; color: var(--ink-dim); margin: 14px 0 4px; letter-spacing: 0.06em; }
.drawer-body select, .drawer-body input[type="text"] {
  width: 100%;
  background: var(--graphite);
  border: 1px solid var(--panel-edge);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  margin-top: 4px;
}
.drawer-body .check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink); }
.drawer-actions { display: flex; gap: 10px; margin-top: 20px; }
.key-result { margin-top: 18px; border-top: 1px dashed var(--panel-edge); padding-top: 14px; }
.key-result-label { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--phosphor); }
.key-result pre {
  background: var(--graphite);
  border: 1px solid var(--panel-edge);
  padding: 10px 12px;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* -------------------------------------------------------------- enroll */
.enroll { max-width: 780px; }
.enroll-title { font-family: var(--display); letter-spacing: 0.06em; }
.enroll-lead { color: var(--ink-dim); }
.tabs { display: flex; gap: 2px; margin: 22px 0 0; flex-wrap: wrap; }
.tab {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  background: var(--panel);
  color: var(--ink-dim);
  border: 1px solid var(--panel-edge);
  border-bottom: none;
  padding: 10px 16px;
  cursor: pointer;
}
.tab.active { color: var(--phosphor); border-top: 2px solid var(--phosphor); background: #222a32; }
.tabpane {
  display: none;
  background: #222a32;
  border: 1px solid var(--panel-edge);
  padding: 20px 26px;
}
.tabpane.active { display: block; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 14px; }
.steps a { color: var(--steel); }
.cmd {
  background: var(--graphite);
  border: 1px solid var(--panel-edge);
  border-left: 3px solid var(--phosphor);
  padding: 10px 14px;
  font-size: 12.5px;
  overflow-x: auto;
  margin: 8px 0 0;
}
.enroll-note {
  margin-top: 22px;
  font-size: 12px;
  color: var(--ink-dim);
  border-left: 2px solid var(--panel-edge);
  padding-left: 12px;
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@media (prefers-reduced-motion: reduce) {
  .led.on, .login-led { animation: none; }
  .gauge-fill { transition: none; }
}
@media (max-width: 640px) {
  .nameplate { flex-direction: column; gap: 10px; align-items: flex-start; }
  .console-head { flex-direction: column; align-items: stretch; }
  #filterBox { min-width: 0; width: 100%; }
}
