@import url("https://fonts.googleapis.com/css2?family=Funnel+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600&display=swap");

:root {
  color-scheme: dark;
  --bg: #090d12;
  --topbar: #0e141b;
  --sidebar: #0b1016;
  --panel: #0e141b;
  --panel-raised: #111920;
  --panel-selected: #182318;
  --inset: #070b0f;
  --field: #0a0f14;
  --line: #28343f;
  --line-strong: #40505c;
  --text: #eff4f1;
  --muted: #7e8b96;
  --quiet: #60707e;
  --lime: #b6ff4a;
  --cyan: #55d6ff;
  --violet: #a78bfa;
  --amber: #ffcf5c;
  --coral: #ff7653;
  --sans: "Inter", system-ui, sans-serif;
  --display: "Funnel Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(85, 214, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(85, 214, 255, 0.022) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  transform: translateY(-160%);
  background: var(--lime);
  color: #0a0e11;
  font: 600 11px var(--mono);
}

.skip-link:focus {
  transform: translateY(0);
}

.mono,
.eyebrow,
.status-badge,
.brand,
.tenant,
.nav-section,
.field-label,
.button,
.tab-kicker,
.tab-events,
.metric-label,
.metric-value,
.console,
.timeline,
.filter,
.toast,
.environment,
.mobile-select-label,
.safety-note {
  font-family: var(--mono);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 64px;
  border-bottom: 1px solid #26313d;
  background: rgba(14, 20, 27, 0.96);
  backdrop-filter: blur(16px);
}

.topbar-inner {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #f0f4f2;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.mark {
  position: relative;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  border: 1.5px solid var(--lime);
  transform: rotate(45deg);
}

.mark::after {
  position: absolute;
  inset: 5px;
  background: var(--lime);
  content: "";
}

.status-badge {
  position: absolute;
  left: 50%;
  min-height: 32px;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #385332;
  background: var(--panel-selected);
  color: var(--amber);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.055em;
  transform: translateX(-50%);
  white-space: nowrap;
}

.status-badge.violet {
  color: var(--violet);
}

.dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(182, 255, 74, 0.08);
}

.tenant {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #8d9ba8;
  font-size: 10px;
  white-space: nowrap;
}

.avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: #26313d;
  color: #d7dfdc;
  font: 600 9px var(--mono);
}

.menu-button {
  display: none;
  min-width: 68px;
  min-height: 40px;
  border: 1px solid #385332;
  background: transparent;
  color: var(--lime);
  font: 600 9px var(--mono);
  letter-spacing: 0.06em;
}

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

.sidebar {
  min-height: calc(100vh - 64px);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid #26313d;
  background: var(--sidebar);
}

.nav-section {
  margin: 0 10px 8px;
  color: #566472;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.11em;
}

.side-nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #9ba7b2;
  text-align: left;
  font-size: 13px;
}

.nav-item:hover {
  border-color: #2c3a46;
  color: var(--text);
}

.nav-item[aria-current="page"] {
  border-color: #2d4529;
  background: #1d2a1c;
  color: #ecf4e8;
  font-weight: 600;
}

.nav-icon {
  width: 17px;
  color: #697887;
  font: 400 12px var(--mono);
  text-align: center;
}

.nav-item[aria-current="page"] .nav-icon {
  color: var(--lime);
}

.sidebar-rule {
  width: 100%;
  height: 1px;
  margin: 10px 0 13px;
  border: 0;
  background: #26313d;
}

.sidebar-spacer {
  flex: 1;
  min-height: 10px;
}

.environment {
  padding: 12px;
  display: grid;
  gap: 8px;
  border: 1px solid #2c3a46;
}

.environment strong {
  color: #d8e0dd;
  font-size: 10px;
  line-height: 1.45;
}

.environment span {
  color: #73818d;
  font-size: 8px;
  line-height: 1.6;
}

.main {
  min-width: 0;
  padding: 24px;
}

.page-header {
  min-height: 70px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.page-title {
  margin: 0;
  color: var(--text);
  font: 600 28px/1.08 var(--display);
  letter-spacing: -0.025em;
}

.page-subtitle {
  max-width: 750px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.button {
  min-height: 40px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #40505c;
  background: transparent;
  color: #aab5be;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.button:hover {
  border-color: #7b8b97;
  color: var(--text);
}

.button-primary {
  min-height: 48px;
  border-color: var(--lime);
  background: var(--lime);
  color: #0a0e11;
}

.button-primary:hover {
  border-color: #d1ff8f;
  background: #c4ff6b;
  color: #0a0e11;
}

.button-danger:hover {
  border-color: var(--coral);
  color: #ff9b83;
}

.button-cyan-icon {
  color: var(--cyan);
  font-size: 11px;
}

.mobile-status {
  min-height: 36px;
  margin-bottom: 18px;
  padding: 0 10px;
  display: none;
  align-items: center;
  gap: 8px;
  border: 1px solid #385332;
  background: var(--panel-selected);
  color: var(--amber);
  font: 600 8px var(--mono);
  letter-spacing: 0.05em;
}

.mobile-status.violet {
  color: var(--violet);
}

.selector-grid {
  margin: 0 0 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.selector-card {
  position: relative;
  min-width: 0;
  min-height: 132px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  overflow: hidden;
  border: 1px solid #2a3540;
  background: #10161d;
  color: inherit;
  text-align: left;
}

.selector-card::after {
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  height: 3px;
  background: #26313d;
  content: "";
}

.selector-card:hover {
  border-color: #4b5b68;
}

.selector-card[aria-selected="true"] {
  border-color: #639b4c;
  background: var(--panel-selected);
}

.selector-card[aria-selected="true"]::after {
  background: var(--lime);
}

.tab-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.tab-kicker,
.tab-events {
  font-size: 8px;
  line-height: 1.35;
}

.tab-kicker {
  color: #596774;
  font-weight: 600;
}

.selector-card[aria-selected="true"] .tab-kicker {
  color: var(--lime);
}

.tab-events {
  color: #687784;
}

.tab-title {
  overflow: hidden;
  color: #afbac3;
  font: 600 10px/1.35 var(--mono);
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selector-card[aria-selected="true"] .tab-title {
  color: #eaf2e6;
}

.tab-description {
  color: #71808c;
  font-size: 11px;
  line-height: 1.45;
}

.mobile-selector {
  margin-bottom: 18px;
  padding: 12px;
  display: none;
  border: 1px solid #639b4c;
  background: var(--panel-selected);
}

.mobile-select-label {
  display: block;
  margin-bottom: 7px;
  color: var(--lime);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.mobile-selector select {
  width: 100%;
  min-height: 42px;
  padding: 0 38px 0 10px;
  border: 1px solid #385332;
  border-radius: 0;
  background: #101a17;
  color: #eaf2e6;
  font: 600 10px var(--mono);
}

.mobile-select-copy {
  margin: 8px 0 0;
  color: #71808c;
  font-size: 11px;
}

.workbench-grid {
  min-height: 610px;
  display: grid;
  grid-template-columns: 330px minmax(360px, 1fr) 270px;
  gap: 12px;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.config-panel,
.result-panel,
.events-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.eyebrow {
  margin: 0;
  color: #667684;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.panel-title {
  margin: 0;
  color: #edf3f0;
  font: 600 21px/1.15 var(--display);
  letter-spacing: -0.015em;
}

.field-stack {
  display: grid;
  gap: 12px;
}

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

.field-label {
  color: var(--quiet);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.075em;
}

.field-value {
  min-height: 40px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #303c47;
  background: var(--field);
  color: #b8c2c9;
  font: 400 10px var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-stack {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.action-stack .button {
  width: 100%;
}

.safety-note {
  margin: 0;
  color: #63717d;
  font-size: 8px;
  line-height: 1.55;
}

.result-panel {
  background: #0c1218;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.heading-stack {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.heading-value {
  overflow: hidden;
  color: #dce4e1;
  font: 600 11px/1.4 var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-badge {
  min-height: 30px;
  padding: 6px 9px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  background: var(--panel-selected);
  color: var(--lime);
  font: 600 8px var(--mono);
  letter-spacing: 0.045em;
  text-align: center;
}

.mini-badge.warning {
  color: var(--amber);
}

.mini-badge.rejected {
  background: #291713;
  color: #ff9277;
}

.metric-grid {
  min-height: 82px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-width: 0;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 8px;
  background: var(--panel-raised);
}

.metric-label {
  color: #63717d;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.055em;
}

.metric-value {
  overflow: hidden;
  color: #f0f4f2;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-value.lime {
  color: var(--lime);
}

.metric-value.cyan {
  color: var(--cyan);
}

.console {
  min-height: 230px;
  flex: 1;
  padding: 14px;
  overflow: auto;
  border: 1px solid #111820;
  background:
    linear-gradient(rgba(85, 214, 255, 0.025) 1px, transparent 1px),
    var(--inset);
  background-size: 100% 28px;
  color: #9eabb4;
  font-size: 10px;
  line-height: 1.8;
  scrollbar-color: #33414d var(--inset);
}

.console-label {
  margin-bottom: 8px;
  color: var(--cyan);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.07em;
}

.console pre {
  margin: 0;
  color: inherit;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.console .accent {
  color: var(--lime);
}

.console-actions {
  display: flex;
  gap: 8px;
}

.console-actions .button {
  flex: 1;
}

.events-panel {
  background: var(--panel);
}

.timeline-list {
  margin: 0;
  padding: 0;
  display: grid;
  list-style: none;
}

.timeline-item {
  position: relative;
  min-height: 70px;
  padding-left: 30px;
}

.timeline-item::before {
  position: absolute;
  top: 5px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  content: "";
}

.timeline-item::after {
  position: absolute;
  top: 18px;
  bottom: 4px;
  left: 6px;
  width: 1px;
  background: #33414d;
  content: "";
}

.timeline-item:last-child::before {
  background: var(--lime);
}

.timeline-item:last-child::after {
  display: none;
}

.event-name {
  display: block;
  color: #c6d0d6;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.5;
}

.event-time {
  display: block;
  margin-top: 5px;
  color: #5f6e7b;
  font-size: 8px;
}

.events-panel > .button {
  width: 100%;
  margin-top: auto;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid #303c47;
  background: transparent;
  color: #778692;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.filter[aria-pressed="true"] {
  border-color: #639b4c;
  background: var(--panel-selected);
  color: var(--lime);
}

.run-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  background: #27313a;
  list-style: none;
}

.run-row {
  width: 100%;
  min-height: 47px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(90px, 1fr) 70px;
  align-items: center;
  gap: 10px;
  border: 0;
  background: var(--inset);
  color: #9eabb4;
  text-align: left;
  font: 400 9px/1.35 var(--mono);
}

.run-row:hover,
.run-row[aria-current="true"] {
  background: #111920;
  color: #dce4e1;
}

.run-id {
  overflow: hidden;
  color: #dce4e1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-status {
  color: var(--lime);
}

.run-status.blocked {
  color: var(--coral);
}

.mobile-fixture {
  min-height: 82px;
  margin-top: 12px;
  padding: 14px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #34414d;
  background: #121820;
}

.mobile-fixture strong,
.mobile-fixture span {
  display: block;
  font-family: var(--mono);
}

.mobile-fixture strong {
  color: #d0d8d5;
  font-size: 9px;
}

.mobile-fixture span {
  margin-top: 5px;
  color: #687783;
  font-size: 7px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: min(380px, calc(100vw - 32px));
  padding: 13px 16px;
  border: 1px solid #639b4c;
  background: #182318;
  color: #dfffc9;
  font-size: 9px;
  line-height: 1.5;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.3);
  transform: translateY(0);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast[hidden] {
  display: block;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.drawer {
  width: min(520px, 100%);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid #40505c;
  background: var(--topbar);
  color: var(--text);
}

.drawer::backdrop {
  background: rgba(2, 6, 10, 0.72);
  backdrop-filter: blur(3px);
}

.drawer-inner {
  min-height: 100%;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.drawer-header {
  padding-bottom: 18px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-title {
  margin: 5px 0 0;
  font: 600 26px var(--display);
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid #40505c;
  background: transparent;
  color: #aab5be;
  font: 500 17px var(--mono);
}

.drawer-copy {
  margin: 0;
  color: #9eabb4;
  font-size: 13px;
  line-height: 1.65;
}

.definition-list {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(100px, 0.7fr) minmax(0, 1.3fr);
  border-top: 1px solid var(--line);
}

.definition-list dt,
.definition-list dd {
  min-width: 0;
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font: 9px/1.5 var(--mono);
  overflow-wrap: anywhere;
}

.definition-list dt {
  color: var(--quiet);
}

.definition-list dd {
  color: #dce4e1;
}

.drawer-actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
}

.drawer-actions .button {
  flex: 1;
}

.no-scroll {
  overflow: hidden;
}

@media (max-width: 1180px) {
  .status-badge {
    position: static;
    margin-left: auto;
    transform: none;
  }

  .tenant > span:first-child {
    display: none;
  }

  .workbench-grid {
    grid-template-columns: 310px minmax(0, 1fr);
  }

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

  .timeline-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }

  .timeline-item {
    min-height: 54px;
    padding: 23px 0 0;
  }

  .timeline-item::before {
    top: 3px;
    left: 0;
  }

  .timeline-item::after {
    top: 7px;
    right: -12px;
    bottom: auto;
    left: 14px;
    width: auto;
    height: 1px;
  }
}

@media (max-width: 1023px) {
  .menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .tenant {
    display: none;
  }

  .status-badge {
    margin-left: 0;
  }

  .shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 64px;
    bottom: 0;
    left: 0;
    z-index: 35;
    width: min(300px, calc(100vw - 48px));
    min-height: 0;
    overflow-y: auto;
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.46);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .nav-open .sidebar {
    transform: translateX(0);
  }

  .nav-open::after {
    position: fixed;
    inset: 64px 0 0;
    z-index: 30;
    background: rgba(2, 5, 8, 0.7);
    content: "";
  }

  .selector-card {
    min-height: 126px;
  }
}

@media (max-width: 800px) {
  .topbar-inner {
    padding: 0 16px;
  }

  .status-badge {
    display: none;
  }

  .main {
    padding: 22px 16px 40px;
  }

  .mobile-status {
    display: flex;
  }

  .page-header {
    min-height: 0;
    margin-bottom: 18px;
  }

  .page-header > .button {
    display: none;
  }

  .page-title {
    font-size: 26px;
  }

  .page-subtitle {
    max-width: 560px;
  }

  .selector-grid {
    display: none;
  }

  .mobile-selector {
    display: block;
  }

  .workbench-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .events-panel {
    grid-column: auto;
  }

  .config-panel,
  .result-panel,
  .events-panel {
    min-height: auto;
  }

  .timeline-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .timeline-item {
    min-height: 72px;
    padding: 0 0 0 30px;
  }

  .timeline-item::before {
    top: 5px;
    left: 3px;
  }

  .timeline-item::after {
    top: 18px;
    right: auto;
    bottom: 4px;
    left: 6px;
    width: 1px;
    height: auto;
  }

  .mobile-fixture {
    display: flex;
  }
}

@media (max-width: 480px) {
  .brand {
    gap: 9px;
    font-size: 11px;
  }

  .mark {
    width: 15px;
    height: 15px;
  }

  .mark::after {
    inset: 4px;
  }

  .menu-button {
    min-width: 64px;
  }

  .panel {
    padding: 14px;
  }

  .metric-grid {
    min-height: 88px;
    gap: 7px;
  }

  .metric {
    padding: 9px;
  }

  .metric-label {
    font-size: 8px;
  }

  .metric-value {
    font-size: 13px;
  }

  .panel-header {
    display: grid;
  }

  .mini-badge {
    width: fit-content;
  }

  .heading-value {
    white-space: normal;
  }

  .console {
    min-height: 280px;
  }

  .run-row {
    grid-template-columns: minmax(0, 1fr) 76px;
  }

  .run-row > :nth-child(2) {
    display: none;
  }

  .mobile-fixture {
    align-items: flex-start;
  }

  .mobile-fixture span,
  .event-time,
  .safety-note {
    font-size: 9px;
  }

  .drawer {
    width: 100%;
  }

  .drawer-inner {
    padding: 18px 16px;
  }

  .toast {
    right: 16px;
    bottom: 16px;
    left: 16px;
  }
}

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