:root {
  --background: #f8faf9;
  --foreground: #17201b;
  --muted: #66736d;
  --line: #d8dfda;
  --panel: #ffffff;
  --primary: #1f5eff;
  --primary-hover: #194ed4;
  --secondary: #1f2a44;
  --secondary-hover: #31405f;
  --accent: #0f8b6f;
  --warning: #9a5b00;
  --warning-bg: #fff7e6;
  --error: #a32727;
  --error-bg: #fff0f0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-width: 320px;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: Arial, Helvetica, sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.58; }
a { color: inherit; text-decoration: none; }

.home-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.home-stack {
  display: grid;
  width: min(760px, 100%);
  gap: 28px;
  justify-items: center;
}
.home-stack h1 {
  margin: 0;
  font-size: clamp(48px, 12vw, 86px);
  font-weight: 650;
  letter-spacing: 0;
}
.search-shell { display: grid; width: 100%; gap: 16px; }
.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  width: 100%;
}
.target-input, input, textarea, select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--foreground);
  outline: none;
  padding: 10px 12px;
}
.target-input { height: 52px; font-size: 16px; padding: 0 16px; }
textarea { min-height: 96px; resize: vertical; }
.target-input:focus, input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(31 94 255 / 14%);
}
.field-error { color: var(--error); font-size: 14px; margin: -6px 0 0; }
.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 650;
  line-height: 1;
  padding: 0 18px;
  white-space: nowrap;
}
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary { background: var(--secondary); color: #fff; }
.button-secondary:hover { background: var(--secondary-hover); }
.button-danger { background: #c92a2a; color: #fff; }
.button-danger:hover { background: #a61e1e; }
.button-ghost { border-color: var(--line); background: #fff; }
.search-meta { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.region-picker { display: flex; min-width: 0; flex-wrap: wrap; gap: 6px; border: 0; margin: 0; padding: 0; }
.region {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
}
.region input { position: absolute; opacity: 0; pointer-events: none; }
.region.active { border-color: color-mix(in srgb, var(--accent) 42%, #fff); color: var(--foreground); }
.link-button, .snapshot-link {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 650;
  padding: 0;
  white-space: nowrap;
}
.link-button-danger { color: #b42318; }
.page-shell { width: min(1120px, 100%); margin: 0 auto; padding: 34px 16px 56px; }
.result-page, .snapshot-page { display: grid; gap: 18px; }
.result-page {
  align-content: start;
  gap: 20px;
}
.snapshot-static-page { background: #000; color: #f2fff6; min-height: 100vh; max-width: none; width: 100%; }
.snapshot-terminal {
  border: 0;
  border-radius: 0;
  background: #000;
  color: #f2fff6;
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 0 0 8px;
}
.snapshot-terminal p { margin: 0 0 12px; }
.snapshot-terminal .snapshot-meta-line { color: #8a8f8d; margin-bottom: 7px; }
.snapshot-static-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  color: #8a8f8d;
  font-family: Menlo, Consolas, monospace;
  font-size: 12px;
  margin: 0;
}
.result-header, .admin-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.brand-link { color: var(--primary); font-size: 18px; font-weight: 750; }
.result-header h1, .admin-header h1 {
  margin: 8px 0 0;
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 700;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.result-header h1 span:last-child { color: var(--muted); font-weight: 520; }
.settings-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}
.settings-bar > div { display: grid; gap: 5px; min-width: 0; background: var(--panel); padding: 12px; }
.setting-label, .settings-bar label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}
.settings-bar strong { min-width: 0; overflow-wrap: anywhere; }
.settings-bar input { width: 100%; padding: 6px 8px; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.notice { border-radius: 8px; margin: 0; padding: 12px 14px; }
.notice-error { background: var(--error-bg); color: var(--error); }
.notice-warning { background: var(--warning-bg); color: var(--warning); }
.muted { color: var(--muted); }
.result-grid { display: grid; gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 16px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel h2 { margin: 0; font-size: 16px; }
.live-results-panel { background: #050806; color: #f2fff6; }
.terminal-query {
  margin: 0 0 12px;
  color: #f2fff6;
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
}
.live-table-wrap, .table-wrap { overflow-x: auto; }
.live-results-table {
  min-width: 940px;
  color: #f2fff6;
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
}
.live-results-table th { border-bottom: 0; background: #04920b; color: #001b04; font-size: 12px; text-transform: none; }
.live-results-table td { border-bottom: 0; padding: 4px 8px; }
.live-row-running td, .live-row-complete td { background: #061306; }
.live-row-error td { background: #210808; }
.mtr-toggle { border: 0; background: transparent; color: #00ff66; cursor: pointer; font: inherit; padding: 0; text-transform: lowercase; }
.mtr-toggle:hover, .mtr-toggle:focus-visible { text-decoration: underline; }
.mtr-detail-row td { background: #001f06; padding: 0 8px 8px; }
.mtr-output { min-height: 0; border-radius: 0; background: #001f06; color: #00ff66; padding: 12px 0; overflow-x: auto; white-space: pre; }
.mtr-output-table-wrap { overflow-x: auto; padding: 10px 0 12px; }
.mtr-output-table {
  width: 100%;
  min-width: 1040px;
  table-layout: fixed;
  border-collapse: collapse;
  color: #00ff66;
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
}
.mtr-output-table th, .mtr-output-table td {
  border: 0;
  padding: 2px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
.mtr-output-table th { color: #00ff66; background: #001f06; font-weight: 700; }
.mtr-output-table th:nth-child(1), .mtr-output-table td:nth-child(1) { width: 44px; }
.mtr-output-table th:nth-child(2), .mtr-output-table td:nth-child(2) { width: 210px; text-align: left; }
.mtr-output-table th:nth-child(3), .mtr-output-table td:nth-child(3) { width: 64px; }
.mtr-output-table th:nth-child(4), .mtr-output-table td:nth-child(4) { width: 56px; }
.mtr-output-table th:nth-child(n+5):nth-child(-n+8),
.mtr-output-table td:nth-child(n+5):nth-child(-n+8) { width: 72px; }
.mtr-output-table th:nth-child(9), .mtr-output-table td:nth-child(9) { width: 240px; text-align: left; }
.mtr-output-table th:nth-child(10), .mtr-output-table td:nth-child(10) { width: 240px; text-align: left; }
.spark-bar { display: block; width: 0; min-width: 4px; height: 12px; background: #03a814; }
pre {
  min-height: 220px;
  overflow: auto;
  border-radius: 8px;
  background: #10151f;
  color: #edf5ff;
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
  padding: 16px;
  white-space: pre-wrap;
}
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.admin-page {
  display: grid;
  gap: 18px;
}
.admin-dashboard {
  display: grid;
  gap: 16px;
}
.admin-login {
  width: min(460px, 100%);
}
.admin-form,
.admin-grid-form,
.admin-node-form,
.admin-node-edit-form {
  display: grid;
  gap: 12px;
}
.admin-form {
  width: min(420px, 100%);
}
.admin-grid-form,
.admin-node-form,
.admin-node-edit-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}
.admin-node-edit-form {
  border-radius: 8px;
  background: #f6f8f7;
  padding: 12px;
}
.admin-page label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.admin-page input,
.admin-page select,
.admin-page textarea {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--foreground);
  padding: 0 12px;
}
.admin-page input:focus,
.admin-page select:focus,
.admin-page textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(31 94 255 / 14%);
  outline: none;
}
.admin-page textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}
.admin-node-secret { grid-column: span 2; }
.admin-checkbox {
  display: flex !important;
  min-height: 42px;
  align-items: center;
  flex-direction: row;
  gap: 8px;
}
.admin-checkbox input {
  width: 18px;
  height: 18px;
}
.node-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.node-progress {
  position: relative;
  width: 104px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e7ec;
  margin-top: 8px;
}
.node-progress span {
  position: absolute;
  inset: 0;
  width: 44%;
  border-radius: inherit;
  background: var(--primary);
  animation: node-progress-slide 1s ease-in-out infinite;
}
.edit-row td {
  background: #f8faf9;
  padding: 12px 8px;
}

@keyframes node-progress-slide {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(240%);
  }
}

@media (max-width: 760px) {
  .search-form,
  .settings-bar,
  .admin-grid-form,
  .admin-node-form,
  .admin-node-edit-form {
    grid-template-columns: 1fr;
  }
  .search-meta, .result-header, .admin-header { align-items: stretch; flex-direction: column; }
  .admin-node-secret { grid-column: auto; }
}

/* Datacenter-inspired looking glass */
.looking-glass-page {
  width: 100%;
  max-width: none;
  color: #d8edf2;
}
.home-page.looking-glass-page,
.result-page.looking-glass-page {
  min-height: 100vh;
  background:
    linear-gradient(rgba(0, 255, 102, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 102, 0.05) 1px, transparent 1px),
    #000;
  background-size: 42px 42px;
}
.home-page.looking-glass-page { align-items: stretch; padding: 24px; }
.looking-glass-page.page-shell { padding: 24px; }
.result-page.looking-glass-page.page-shell { padding: 0 24px 24px; }
.lg-card {
  align-content: start;
  align-self: center;
  width: min(980px, 100%);
  border: 1px solid #064d1f;
  border-radius: 12px;
  background: rgba(0, 20, 8, 0.94);
  box-shadow: 0 24px 80px rgb(0 0 0 / 24%);
  gap: 0;
  overflow: hidden;
  padding: 0;
}
.lg-card-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  width: 100%;
  gap: 18px;
}
.lg-card-heading p { margin: 0; color: #74a883; font-family: Menlo, Consolas, monospace; font-size: 13px; }
.looking-glass-page .brand-link { color: #00ff66; }
.looking-glass-page .search-shell { gap: 14px; }
.looking-glass-page .search-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}
.looking-glass-page .home-search-form { padding: 16px; }
.looking-glass-page .home-search-form .source-picker { grid-column: 1 / -1; }
.home-term-head {
  width: 100%;
  border-bottom-color: #052f14;
  background: #000f05;
}
.source-picker {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  border: 1px solid #0a5b27;
  border-radius: 8px;
  background: #001807;
  padding: 6px 8px;
}
.source-picker legend {
  float: left;
  color: #dceaf2;
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 4px 6px 4px 0;
}
.source-picker legend::after { content: "  ·"; color: #4c8f61; }
.looking-glass-page .region {
  min-height: 28px;
  border-color: transparent;
  border-radius: 7px;
  background: transparent;
  color: #74a883;
  font-family: Menlo, Consolas, monospace;
  padding: 0 8px;
}
.looking-glass-page .region.active {
  border-color: #00ff66;
  background: #063f18;
  color: #caffd7;
}
.looking-glass-page .target-input,
.looking-glass-page input,
.looking-glass-page select {
  border-color: #0a5b27;
  background: #001807;
  color: #e8ffee;
}
.looking-glass-page .target-input::placeholder,
.looking-glass-page input::placeholder { color: #4f875f; }
.looking-glass-page .button-primary {
  border-color: #00ff66;
  background: #00ff66;
  color: #001204;
}
.looking-glass-page .button-primary:hover { background: #6aff9b; }
.looking-glass-page .button-secondary,
.looking-glass-page .button-ghost {
  border-color: #0a5b27;
  background: #001807;
  color: #b8dec1;
}
.looking-glass-page .button-secondary:hover,
.looking-glass-page .button-ghost:hover {
  border-color: #00ff66;
  color: #caffd7;
}
.looking-glass-page .button-danger {
  border-color: #ff4d4d;
  background: #d92d2d;
  color: #fff;
}
.looking-glass-page .button-danger:hover {
  border-color: #ff7676;
  background: #b42323;
  color: #fff;
}
.lg-terminal-preview {
  width: 100%;
  min-height: 210px;
  overflow: hidden;
  border: 1px solid #064d1f;
  border-radius: 12px;
  background: #000f05;
}
.lg-term-head {
  display: flex;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid #052f14;
  padding: 10px 14px;
  color: #68a878;
  font-family: Menlo, Consolas, monospace;
  font-size: 12px;
}
.lg-term-head span,
.term-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
}
.lg-term-head span:nth-child(1), .term-dot.red { background: #fb7185; }
.lg-term-head span:nth-child(2), .term-dot.yellow { background: #fbbf24; }
.lg-terminal-preview pre {
  min-height: 0;
  border-radius: 0;
  background: transparent;
  color: #b8dec1;
  padding: 18px;
  white-space: pre;
}
.looking-glass-page .result-header {
  width: min(1120px, 100%);
  margin: 0 auto;
  color: #d8edf2;
}
.looking-glass-page .result-header h1 span:last-child { color: #74a883; }
.looking-glass-page .settings-bar {
  width: min(1120px, 100%);
  margin: 0 auto;
  grid-template-columns: minmax(180px, 1.3fr) minmax(90px, 0.6fr) repeat(2, minmax(92px, 0.45fr)) minmax(180px, 1fr);
  border-color: #064d1f;
  background: #064d1f;
}
.looking-glass-page .settings-bar > div {
  background: #001807;
  color: #e8ffee;
}
.looking-glass-page .setting-label,
.looking-glass-page .settings-bar label { color: #74a883; }
.result-control-card {
  position: relative;
  z-index: 20;
  width: min(1120px, 100%);
  height: auto;
  min-height: 0;
  align-self: start;
  overflow: visible;
  border: 1px solid #064d1f;
  border-radius: 12px;
  background: rgba(0, 20, 8, 0.94);
  margin: 0 auto;
}
.result-term-head { background: #000f05; }
.result-control-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
}
.result-summary-row {
  flex: 1 1 520px;
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) minmax(180px, 1fr);
  gap: 8px;
}
.result-summary-row > label,
.advanced-settings label {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid #064d1f;
  border-radius: 8px;
  background: #001807;
  color: #e8ffee;
  padding: 8px 12px;
}
.result-summary-row > label { height: 64px; }
.result-summary-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}
.result-summary-row input,
.result-summary-row select {
  height: 32px;
  width: 100%;
  border-radius: 7px;
  font-weight: 650;
  padding: 0 10px;
}
.result-summary-row input:disabled,
.result-summary-row select:disabled {
  opacity: 1;
  -webkit-text-fill-color: #e8ffee;
}
.result-actions {
  display: grid;
  flex: 0 0 auto;
  gap: 8px;
  justify-items: end;
  position: relative;
}
.result-actions .button {
  min-height: 64px;
  height: 64px;
}
.advanced-settings {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 8px;
  justify-self: start;
  border: 1px solid #064d1f;
  border-radius: 10px;
  background: #000f05;
  box-shadow: 0 18px 48px rgb(0 0 0 / 42%);
  padding: 8px;
}
.advanced-settings[hidden] { display: none; }
.advanced-settings label {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  white-space: nowrap;
}
.advanced-settings input {
  width: 88px;
  min-width: 88px;
  padding: 6px 8px;
}
.result-control-card .action-row {
  flex-wrap: nowrap;
  margin: 0;
}
.looking-glass-page .action-row,
.looking-glass-page .notice,
.looking-glass-page .result-grid {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  margin-left: auto;
  margin-right: auto;
}
.looking-glass-page .result-control-card .action-row {
  width: auto;
  margin: 0;
}
.looking-glass-page .live-results-panel {
  border-color: #064d1f;
  border-radius: 12px;
  background: #000f05;
  color: #d8edf2;
  padding: 0;
  overflow: hidden;
}
.looking-glass-page .panel-heading {
  border-bottom: 1px solid #052f14;
  margin: 0;
  padding: 10px 14px;
}
.looking-glass-page .panel-heading h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #68a878;
  font-family: Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
}
.looking-glass-page .terminal-query { color: #b8dec1; margin: 14px 16px 0; }
.looking-glass-page .live-table-wrap { padding: 14px 16px 18px; }
.looking-glass-page .live-results-table {
  min-width: 880px;
  color: #d8edf2;
}
.looking-glass-page .live-results-table th {
  background: #052d10;
  color: #49f38b;
}
.looking-glass-page .live-row-running td,
.looking-glass-page .live-row-complete td { background: #061306; }
.looking-glass-page .mtr-detail-row td { background: #001f06; }
.looking-glass-page .mtr-output-table th { background: #001f06; color: #49f38b; }

@media (max-width: 820px) {
  .home-page.looking-glass-page,
  .looking-glass-page.page-shell { padding: 14px; }
  .result-page.looking-glass-page.page-shell { padding: 0 14px 14px; }
  .lg-card { padding: 16px; }
  .lg-card-heading { align-items: start; flex-direction: column; }
  .looking-glass-page .search-form { grid-template-columns: 1fr; }
  .source-picker { align-items: flex-start; }
  .source-picker legend { width: 100%; padding-bottom: 2px; }
  .looking-glass-page .settings-bar { grid-template-columns: 1fr; }
  .result-control-body { align-items: stretch; }
  .result-actions { width: 100%; justify-items: stretch; }
  .result-summary-row { grid-template-columns: 1fr; }
  .advanced-settings {
    left: 0;
    right: auto;
    grid-template-columns: 1fr;
  }
  .advanced-settings label { justify-content: space-between; }
  .looking-glass-page .result-header { align-items: flex-start; flex-direction: column; }
  .looking-glass-page .action-row { align-items: stretch; flex-direction: column; }
  .looking-glass-page .action-row .button,
  .looking-glass-page .snapshot-link { width: 100%; }
}
