:root {
  color-scheme: dark;
  --bg: #16171c;
  --elevated: #191a1f;
  --surface: #1f2027;
  --input: #15161b;
  --border: #2e3038;
  --border-subtle: #2a2c33;
  --border-strong: #363943;
  --text: #c9cbd1;
  --text-bright: #e3e4e8;
  --secondary: #a6aab3;
  --muted: #8a8f98;
  --accent: #4a9eff;
  --accent-fill: #1e6fd9;
  --success: #98c379;
  --warning: #f57c00;
  --error: #e12d39;
  --panel-head: #191a1f;
  --hover: rgba(255, 255, 255, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "IBM Plex Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  overflow-wrap: break-word;
}

button,
input {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  padding: 10px 16px;
  color: #ffffff;
  background: var(--accent-fill);
  font-weight: 700;
}

.skip-link:focus {
  left: 0;
}

h1:focus {
  outline: none;
}

/* ---------- shell ---------- */

.nexus-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: var(--elevated);
  border-right: 1px solid var(--border);
  user-select: none;
}

.rail-logo,
.rail-item,
.rail-user {
  min-height: 44px;
  display: grid;
  place-items: center;
  border-left: 2px solid transparent;
  color: var(--secondary);
  font-family: "IBM Plex Mono", Consolas, ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
}

.rail-logo {
  border-bottom: 1px solid var(--border-subtle);
}

.rail-logo img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.rail-item {
  border-bottom: 1px solid var(--border-subtle);
}

.rail-item.active {
  border-left-color: var(--accent);
  color: var(--accent);
  background: rgba(74, 158, 255, 0.1);
}

.rail-user {
  width: 32px;
  min-height: 32px;
  margin: auto auto 14px;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.app-frame {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- topbar ---------- */

.topbar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 18px;
  background: var(--elevated);
  border-bottom: 1px solid var(--border);
}

.crumb {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.search {
  width: min(360px, 32vw);
  padding: 9px 14px;
  color: var(--muted);
  background: var(--input);
  border: 1px solid var(--border-strong);
  user-select: none;
}

.preview-flag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.preview-flag span,
.status {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: currentColor;
}

/* ---------- hero ---------- */

.hero-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 32px;
  padding: 28px 28px 22px;
  border-bottom: 1px solid var(--border);
  background: #14151a;
}

.hero-copy {
  min-width: 0;
}

.section-label,
.readout-grid span,
.panel-title span,
.field-grid dt {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 860px;
  margin-bottom: 14px;
  color: var(--text-bright);
  font-size: clamp(36px, 5vw, 64px);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-lede {
  max-width: 900px;
  margin-bottom: 14px;
  color: var(--secondary);
  font-size: 15px;
  line-height: 1.55;
}

.mock-note {
  max-width: 780px;
  margin-bottom: 0;
  padding-left: 12px;
  color: var(--muted);
  border-left: 2px solid var(--border-strong);
  line-height: 1.5;
}

/* ---------- notify form ---------- */

.notify-form {
  align-self: end;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.notify-heading {
  margin: 0;
  background: var(--panel-head);
  border-bottom: 1px solid var(--border-strong);
}

.notify-heading label {
  display: block;
  padding: 10px 12px;
  color: var(--secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.notify-body {
  padding: 12px;
}

/* Honeypot: off-screen for people, still fillable by bots. */
.trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.notify-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
}

input {
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  color: var(--text-bright);
  background: var(--input);
  border: 1px solid var(--border-strong);
  outline: none;
}

input:focus-visible {
  border-color: var(--accent);
  outline-offset: -1px;
}

.button,
.notify-row button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: #ffffff;
  background: var(--accent-fill);
  border: 1px solid var(--accent-fill);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
.notify-row button:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.notify-row button[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.notify-status {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.notify-status:not(:empty) {
  margin-top: 10px;
}

.notify-status.is-ok {
  color: var(--success);
}

.notify-status.is-error {
  color: var(--warning);
}

.notify-status a {
  color: inherit;
}

/* ---------- readouts ---------- */

.readout-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
  background: var(--border);
  gap: 1px;
}

.readout-grid article {
  min-height: 92px;
  padding: 16px;
  background: var(--elevated);
}

.readout-grid strong {
  display: block;
  margin: 10px 0 4px;
  color: var(--text-bright);
  font-family: "IBM Plex Mono", Consolas, ui-monospace, monospace;
  font-size: 20px;
  line-height: 1.1;
  white-space: nowrap;
}

.readout-grid small {
  color: var(--muted);
  font-size: 12px;
}

.warn {
  color: var(--warning) !important;
}

/* ---------- console grid ---------- */

.console-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr) minmax(0, 0.8fr);
  gap: 24px;
  padding: 24px 28px 34px;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.panel-title {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px;
  background: var(--panel-head);
  border-bottom: 1px solid var(--border-strong);
}

.panel-title h2,
.detail-head h2 {
  margin: 0;
  color: var(--text-bright);
  font-size: 18px;
  line-height: 1.2;
}

/* ---------- device table ---------- */

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  /* Scroll the roster rather than wrapping every cell to three lines. */
  min-width: 420px;
  border-collapse: collapse;
}

th {
  padding: 9px 10px;
  color: var(--secondary);
  background: var(--panel-head);
  border-bottom: 1px solid var(--border-strong);
  border-right: 1px solid var(--border-strong);
  font-size: 11px;
  letter-spacing: 0.11em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 11px 10px;
  color: var(--secondary);
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  vertical-align: middle;
}

th:last-child,
td:last-child {
  border-right: 0;
}

tbody tr:hover {
  background: var(--hover);
}

tr.selected {
  background: rgba(74, 158, 255, 0.1);
  box-shadow: inset 2px 0 0 var(--accent);
}

.status {
  margin-right: 8px;
}

.status.ok,
.severity.ok {
  color: var(--success);
}

.status.warn,
.severity.warn {
  color: var(--warning);
}

.status.muted {
  color: var(--muted);
}

/* ---------- detail panel ---------- */

.detail-panel {
  grid-row: span 2;
  display: flex;
  flex-direction: column;
}

.detail-head {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
  background: #17181d;
  border-bottom: 1px solid var(--border-strong);
}

.detail-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", Consolas, ui-monospace, monospace;
}

.pill,
.severity {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 0;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill.warning {
  color: var(--warning);
  background: rgba(245, 124, 0, 0.14);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-strong);
}

.tab {
  min-width: 132px;
  padding: 13px 18px;
  color: var(--muted);
  background: none;
  border: 0;
  border-right: 1px solid var(--border-strong);
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.tab:hover {
  color: var(--secondary);
  background: var(--hover);
}

.tab[aria-selected="true"] {
  color: var(--text-bright);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.tab-panel {
  flex: 1;
}

.tab-panel:focus-visible {
  outline-offset: -2px;
}

.callout {
  margin: 18px;
  padding: 14px 16px;
  color: var(--secondary);
  background: rgba(245, 124, 0, 0.1);
  border-left: 2px solid var(--warning);
  font-weight: 700;
  line-height: 1.5;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0 18px 18px;
}

.field {
  display: grid;
  gap: 9px;
}

.field-grid dd {
  min-height: 46px;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 12px;
  color: var(--text-bright);
  background: var(--input);
  border: 1px solid var(--border-strong);
  font-family: "IBM Plex Mono", Consolas, ui-monospace, monospace;
  font-size: 14px;
  font-weight: 600;
}

.sticky-bar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  color: var(--warning);
  background: var(--elevated);
  border-top: 1px solid var(--border-strong);
  font-weight: 700;
}

.sticky-bar p {
  margin: 0;
  line-height: 1.4;
}

/* ---------- events ---------- */

.events {
  list-style: none;
  margin: 0;
  padding: 0;
}

.events li {
  display: grid;
  grid-template-columns: 62px 52px minmax(0, 1fr);
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.events li:last-child {
  border-bottom: 0;
}

time {
  color: var(--muted);
  font-family: "IBM Plex Mono", Consolas, ui-monospace, monospace;
  font-size: 11px;
}

.severity {
  justify-content: center;
  background: rgba(152, 195, 121, 0.12);
}

.severity.warn {
  background: rgba(245, 124, 0, 0.14);
}

.events p {
  margin: 0;
  color: var(--secondary);
  line-height: 1.45;
}

/* ---------- modules ---------- */

.module-panel {
  grid-column: 1 / 2;
}

.module-list article {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.module-list article:last-child {
  border-bottom: 0;
}

.module-list strong {
  color: var(--text-bright);
}

.module-list span {
  color: var(--secondary);
  line-height: 1.45;
}

/* ---------- 404 ---------- */

.notfound {
  min-height: 100vh;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 auto;
  padding: 24px;
}

.notfound-code {
  margin: 10px 0 12px;
  color: var(--accent);
  font-family: "IBM Plex Mono", Consolas, ui-monospace, monospace;
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
}

.notfound h1 {
  font-size: clamp(28px, 4vw, 40px);
}

.notfound-lede {
  margin-bottom: 24px;
  color: var(--secondary);
  font-size: 15px;
  line-height: 1.55;
}

.notfound .button {
  align-self: start;
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  color: var(--muted);
  background: var(--elevated);
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--accent);
}

/* ---------- responsive ---------- */

/* Three columns only where they genuinely fit. The track minimums are 0 so the
   grid can never force a horizontal scrollbar the way fixed minimums did. */
@media (max-width: 1599px) {
  .console-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-panel {
    grid-row: auto;
    grid-column: 1 / -1;
    order: -1;
  }

  .module-panel {
    grid-column: 1 / -1;
  }

  .module-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-list article:nth-last-child(2) {
    border-bottom: 0;
  }
}

@media (max-width: 1080px) {
  .readout-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .nexus-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: static;
    height: auto;
    min-height: 44px;
    flex-direction: row;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .rail-logo,
  .rail-item,
  .rail-user {
    width: 44px;
    min-height: 44px;
    margin: 0;
  }

  .rail-user {
    margin-left: auto;
  }

  .hero-strip {
    grid-template-columns: minmax(0, 1fr);
    padding: 22px 16px;
  }

  .console-grid {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }

  .detail-panel,
  .module-panel {
    grid-column: auto;
    order: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .search {
    width: min(100%, 360px);
  }

  .site-footer {
    padding: 16px;
  }
}

@media (max-width: 640px) {
  .rail-item:nth-of-type(n + 5) {
    display: none;
  }

  h1 {
    font-size: 38px;
  }

  .readout-grid,
  .module-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .readout-grid article {
    min-height: 84px;
  }

  .notify-row,
  .field-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .notify-row button {
    margin-top: 10px;
  }

  .tab {
    min-width: 0;
    flex: 1;
  }

  .events li {
    grid-template-columns: 62px 52px;
  }

  .events li p {
    grid-column: 1 / -1;
  }

  .module-list article {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .module-list article:nth-last-child(2) {
    border-bottom: 1px solid var(--border-subtle);
  }

  .sticky-bar {
    align-items: flex-start;
    flex-direction: column;
  }
}

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