:root {
  --navy-950: #071b3e;
  --navy-800: #13325c;
  --navy-650: #355278;
  --teal-700: #087f86;
  --teal-600: #07939a;
  --teal-100: #e4f5f5;
  --blue-100: #eef5ff;
  --blue-300: #b7d4ff;
  --green-700: #168256;
  --green-100: #e9f7f0;
  --amber-700: #b86600;
  --amber-100: #fff5df;
  --red-700: #c53c4b;
  --red-100: #fff0f2;
  --gray-25: #fcfdff;
  --gray-50: #f7f9fc;
  --gray-100: #eef1f5;
  --gray-200: #dce2e9;
  --gray-400: #8a98aa;
  --gray-600: #556579;
  --white: #ffffff;
  --shadow: 0 12px 30px rgba(17, 42, 78, 0.08);
  --radius: 10px;
  --topbar-height: 64px;
  --sidebar-width: 248px;
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--navy-950);
  background: var(--white);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--white);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.94)),
    repeating-linear-gradient(
      90deg,
      var(--blue-100) 0,
      var(--blue-100) 1px,
      transparent 1px,
      transparent 84px
    );
}

.login-panel {
  width: min(100%, 440px);
  padding: 44px;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  border-radius: 10px;
  background: var(--teal-700);
  color: var(--white);
  font-size: 22px;
  font-weight: 800;
}

.login-panel h1,
.section-heading h1,
.form-region h1 {
  margin: 0;
  color: var(--navy-950);
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.login-panel > p,
.section-heading p,
.form-region .section-heading p,
.pipeline-heading p {
  margin: 8px 0 0;
  color: var(--gray-600);
  font-size: 14px;
  line-height: 1.5;
}

.form-stack,
.report-form,
.settings-form {
  display: grid;
  gap: 18px;
  margin-top: 30px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--navy-800);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #bfc9d5;
  border-radius: 8px;
  background: var(--white);
  color: var(--navy-950);
  padding: 11px 12px;
  font-size: 14px;
  line-height: 1.35;
  outline: none;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #357ef4;
  box-shadow: 0 0 0 3px rgba(53, 126, 244, 0.13);
}

.field-help {
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 450;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-field input {
  width: auto;
  margin: 0;
}

.form-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.button-primary {
  background: var(--teal-700);
  color: var(--white);
}

.button-primary:hover:not(:disabled) {
  background: #056c72;
}

.button-secondary {
  border-color: #b8c6d8;
  background: var(--white);
  color: var(--navy-800);
}

.button-quiet {
  background: transparent;
  color: #0b5bd3;
  padding-inline: 10px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--gray-600);
  font-size: 13px;
  font-weight: 550;
}

.form-message.is-error {
  color: var(--red-700);
}

.form-message.is-success {
  color: var(--green-700);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template:
    "header header" var(--topbar-height)
    "sidebar main" calc(100vh - var(--topbar-height))
    / var(--sidebar-width) minmax(0, 1fr);
}

.topbar {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--gray-200);
  background: rgba(255, 255, 255, 0.96);
}

.brand {
  color: var(--navy-950);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}

.current-user {
  font-weight: 650;
}

.connection-state {
  color: var(--gray-600);
}

.connection-state.is-online {
  color: var(--green-700);
}

.connection-state.is-offline {
  color: var(--red-700);
}

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
  padding: 20px 14px;
  border-right: 1px solid var(--gray-200);
  background: var(--gray-25);
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: var(--navy-800);
  padding: 13px 14px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  font-weight: 620;
}

.nav-item:hover,
.nav-item.is-active {
  background: #edf5f7;
  color: var(--teal-700);
}

.nav-item.is-active {
  border-left-color: var(--teal-600);
}

.swagger-link {
  color: var(--navy-650);
  padding: 12px 15px;
  font-size: 12px;
  text-decoration: none;
}

.main-content {
  grid-area: main;
  overflow-y: auto;
  background: var(--white);
}

.view {
  display: none;
  min-height: 100%;
  padding: 32px;
}

.view.is-active {
  display: block;
}

.generate-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.35fr) minmax(340px, 0.9fr);
  margin: -32px -32px 0;
  border-bottom: 1px solid var(--gray-200);
}

.form-region,
.pipeline-region {
  padding: 34px 46px;
}

.form-region {
  border-right: 1px solid var(--gray-200);
}

.report-form {
  max-width: 660px;
}

.pipeline-region {
  background: var(--gray-25);
}

.pipeline-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.pipeline-heading h2,
.table-section h2,
.section-heading h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.015em;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--white);
  color: var(--navy-650);
  cursor: pointer;
}

.pipeline-list {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
}

.pipeline-step {
  position: relative;
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 12px;
  align-items: start;
  min-height: 68px;
}

.pipeline-step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 34px;
  bottom: -4px;
  border-left: 1px dashed #b6c3d3;
}

.step-number {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid #bdc8d5;
  border-radius: 50%;
  background: var(--gray-50);
  color: var(--navy-650);
  font-size: 13px;
  font-weight: 750;
}

.pipeline-step.is-current .step-number,
.pipeline-step.is-complete .step-number {
  border-color: var(--teal-700);
  background: var(--teal-700);
  color: var(--white);
}

.pipeline-step.is-failed .step-number {
  border-color: var(--red-700);
  background: var(--red-700);
  color: var(--white);
}

.step-copy strong {
  display: block;
  margin-top: 2px;
  color: var(--navy-800);
  font-size: 13px;
}

.step-copy span {
  display: block;
  margin-top: 4px;
  color: var(--gray-600);
  font-size: 12px;
  line-height: 1.4;
}

.status-label {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-queued,
.status-pending {
  background: var(--teal-100);
  color: var(--teal-700);
}

.status-processing {
  background: var(--amber-100);
  color: var(--amber-700);
}

.status-completed {
  background: var(--green-100);
  color: var(--green-700);
}

.status-failed {
  background: var(--red-100);
  color: var(--red-700);
}

.status-requested,
.status-unknown {
  background: var(--gray-100);
  color: var(--gray-600);
}

.system-message {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0 0;
  border: 1px solid var(--blue-300);
  border-radius: 8px;
  background: var(--blue-100);
  color: #164b9c;
  padding: 12px 16px;
  font-size: 12px;
}

.table-section {
  padding-top: 24px;
}

.table-heading {
  align-items: center;
  margin-bottom: 14px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--gray-200);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--gray-50);
  color: var(--navy-800);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfdff;
}

.table-link {
  border: 0;
  background: transparent;
  color: #0961d7;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
}

.empty-row {
  color: var(--gray-600);
  padding: 30px;
  text-align: center;
}

.toolbar {
  max-width: 360px;
  margin: 22px 0 14px;
}

.settings-form {
  width: min(100%, 720px);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 26px;
  background: var(--gray-25);
}

.settings-form.compact {
  margin: 0;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.8fr) minmax(520px, 1.2fr);
  gap: 22px;
  align-items: start;
  margin-top: 24px;
}

.view > .section-heading + .settings-form {
  margin-top: 24px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: min(390px, calc(100vw - 48px));
  transform: translateY(20px);
  border-radius: 8px;
  background: var(--navy-950);
  color: var(--white);
  padding: 13px 16px;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.mobile-only {
  display: none;
}

@media (max-width: 1100px) {
  .generate-grid,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .form-region {
    border-right: 0;
    border-bottom: 1px solid var(--gray-200);
  }

  .settings-layout .settings-form {
    width: 100%;
  }
}

@media (max-width: 820px) {
  :root {
    --sidebar-width: 0px;
  }

  .app-shell {
    grid-template:
      "header" var(--topbar-height)
      "main" calc(100vh - var(--topbar-height))
      / 1fr;
  }

  .mobile-only {
    display: inline-grid;
  }

  .topbar {
    padding: 0 14px;
  }

  .brand {
    font-size: 16px;
  }

  .connection-state,
  .current-user {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    z-index: 30;
    width: 250px;
    height: calc(100vh - var(--topbar-height));
    transform: translateX(-105%);
    box-shadow: var(--shadow);
    transition: transform 180ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .view {
    padding: 20px;
  }

  .generate-grid {
    margin: -20px -20px 0;
  }

  .form-region,
  .pipeline-region {
    padding: 26px 20px;
  }
}

@media (max-width: 580px) {
  .login-panel {
    padding: 30px 22px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .pipeline-heading,
  .system-message {
    align-items: flex-start;
    flex-direction: column;
  }

  .button-row .button,
  .settings-form > .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
