*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #060c18;
  --surface: rgba(10, 20, 42, 0.86);
  --surface-2: rgba(0, 0, 0, 0.24);
  --border: rgba(0, 200, 255, 0.12);
  --border-strong: rgba(0, 200, 255, 0.24);
  --text: #c8d8f0;
  --heading: #e8f0ff;
  --muted: #7b8aaa;
  --muted-dark: #465778;
  --cyan: #00c8ff;
  --green: #00e5a0;
  --red: #ff3d5a;
  --gold: #ffd060;
  --purple: #a78bfa;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(0, 200, 255, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse at 88% 100%, rgba(124, 58, 237, 0.06) 0%, transparent 50%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(0, 200, 255, 0.024) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 200, 255, 0.024) 1px, transparent 1px);
  background-size: 48px 48px;
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }

nav {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 28px;
  background: rgba(6, 12, 24, 0.94);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
}

nav .brand {
  margin-right: 22px;
  color: var(--cyan);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
}

nav a {
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: color 0.15s, background 0.15s;
}

nav a:hover {
  color: var(--cyan);
  background: rgba(0, 200, 255, 0.08);
}

nav a.logout {
  margin-left: auto;
  color: var(--red);
  border: 1px solid rgba(255, 61, 90, 0.28);
}

nav a.logout:hover {
  color: #ff9aae;
  background: rgba(255, 61, 90, 0.1);
}

main {
  position: relative;
  z-index: 1;
  max-width: 1360px;
  margin: 0 auto;
  padding: 30px 22px 60px;
}

h2 {
  margin: 0;
  color: var(--heading);
  font-size: 30px;
  line-height: 1.1;
  font-weight: 800;
}

h3 {
  margin: 0 0 14px;
  color: var(--heading);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.engineTopStatus {
  align-self: center;
  margin-left: auto;
  margin-right: auto;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
  backdrop-filter: blur(20px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

input,
select {
  height: 38px;
  border: 1px solid rgba(0, 200, 255, 0.22);
  border-radius: 8px;
  padding: 0 11px;
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  color-scheme: dark;
  font: inherit;
  outline: none;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--cyan) 50%),
    linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 16px,
    calc(100% - 11px) 16px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

select option {
  background: #0a142a;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 200, 255, 0.08);
}

input::placeholder { color: var(--muted-dark); }

button {
  height: 38px;
  border: 1px solid rgba(0, 200, 255, 0.22);
  border-radius: 9px;
  padding: 0 14px;
  background: rgba(0, 200, 255, 0.08);
  color: var(--cyan);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.3px;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}

button:hover {
  transform: translateY(-1px);
  background: rgba(0, 200, 255, 0.14);
  box-shadow: 0 6px 24px rgba(0, 200, 255, 0.14);
}

button.primary {
  border-color: transparent;
  color: #06101f;
  background: linear-gradient(135deg, #00c8ff, #00e5a0);
  box-shadow: 0 5px 24px rgba(0, 200, 255, 0.26);
}

button.primary:hover {
  box-shadow: 0 7px 30px rgba(0, 229, 160, 0.32);
}

button.danger {
  color: var(--red);
  border-color: rgba(255, 61, 90, 0.34);
  background: rgba(255, 61, 90, 0.08);
}

button.danger:hover {
  background: rgba(255, 61, 90, 0.14);
  box-shadow: 0 6px 24px rgba(255, 61, 90, 0.14);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  overflow: hidden;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid rgba(0, 200, 255, 0.07);
  padding: 10px 9px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: rgba(0, 200, 255, 0.045);
}

tr:hover td { background: rgba(0, 200, 255, 0.025); }

.account-book {
  margin-top: 18px;
}

.account-book:first-child {
  margin-top: 12px;
}

.account-book .bar {
  align-items: center;
  margin-bottom: 8px;
}

.account-book h3 {
  margin-bottom: 0;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.errorText {
  color: var(--red);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(0, 200, 255, 0.11);
  border: 1px solid rgba(0, 200, 255, 0.18);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
}

.pill.statusConnected {
  background: rgba(0, 229, 160, 0.18);
  border-color: rgba(0, 229, 160, 0.55);
  color: var(--green) !important;
}

.pill.statusPending {
  background: rgba(255, 208, 96, 0.18);
  border-color: rgba(255, 208, 96, 0.55);
  color: var(--gold) !important;
}

.pill.statusFailed {
  background: rgba(255, 61, 90, 0.18);
  border-color: rgba(255, 61, 90, 0.55);
  color: var(--red) !important;
}

.engineStatus {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

.engineRunning {
  color: var(--green);
}

.engineStopped {
  color: var(--gold);
}

.mismatchAlert {
  border-color: rgba(255, 61, 90, 0.5);
  background: rgba(62, 10, 22, 0.86);
  box-shadow: 0 12px 42px rgba(255, 61, 90, 0.16);
}

.mismatchAlert .bar {
  align-items: center;
  margin-bottom: 10px;
}

.mismatchAlert h3 {
  margin-bottom: 0;
  color: #ff9aae;
}

code {
  display: inline-block;
  max-width: 320px;
  overflow-wrap: anywhere;
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.redirectTable {
  table-layout: auto;
}

.redirectTable th:nth-child(2),
.redirectTable td:nth-child(2) {
  width: 100%;
  min-width: 540px;
}

.redirectTable code.redirectCode {
  display: block;
  max-width: none;
  white-space: nowrap !important;
  overflow-x: auto;
  overflow-wrap: normal !important;
  word-break: normal;
}

.rowMsg {
  margin-top: 6px;
  max-width: 260px;
}

.ok { color: var(--green); }
.bad { color: var(--red); }
.warn { color: var(--gold); }

.matrix td {
  background: rgba(0, 0, 0, 0.16);
  min-width: 150px;
}

.matrix label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  margin-right: 8px;
}

.matrix input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--cyan);
}

.matrix input[type="number"] {
  width: 80px;
  height: 32px;
}

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login .panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  padding: 40px 36px;
}

.login h2 {
  color: var(--cyan);
  font-size: 15px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.login label {
  color: var(--muted);
}

.login button {
  width: 100%;
  margin-top: 8px;
}

#activity div {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 9px;
  margin-bottom: 8px;
  background: var(--surface-2);
}

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

@media (max-width: 720px) {
  nav {
    height: auto;
    padding: 12px 14px;
    flex-wrap: wrap;
  }

  nav .brand { width: 100%; margin-right: 0; }

  main { padding: 18px 14px 46px; }
  h2 { font-size: 24px; }
  .grid { grid-template-columns: 1fr; }
  .bar { align-items: flex-start; }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
