:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #dbe3ee;
  --line-strong: #c5d2e3;
  --text: #122033;
  --muted: #637083;
  --navy: #0d2b4f;
  --navy-2: #123a67;
  --blue: #1769e0;
  --blue-dark: #0f55bd;
  --green: #0f8a5f;
  --green-bg: #e8f7f0;
  --red: #c0392b;
  --red-bg: #fdecea;
  --amber: #9a6700;
  --amber-bg: #fff7e6;
  --shadow: 0 14px 40px rgba(15, 39, 66, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, rgba(23, 105, 224, 0.12), transparent 32rem),
    radial-gradient(circle at 100% 0%, rgba(15, 138, 95, 0.08), transparent 28rem),
    var(--bg);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.12rem;
  letter-spacing: -0.015em;
}

h3 {
  font-size: 1rem;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 24px 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, var(--navy), var(--blue));
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow: 0 8px 20px rgba(13, 43, 79, 0.24);
}

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

.eyebrow {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

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

.small {
  color: var(--muted);
  font-size: 0.78rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(154, 103, 0, 0.12);
}

.status-pill.is-online {
  color: var(--green);
  border-color: #b8e6d2;
  background: var(--green-bg);
}

.status-pill.is-online .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(15, 138, 95, 0.13);
}

.status-pill.is-offline {
  color: var(--red);
  border-color: #f3c6c1;
  background: var(--red-bg);
}

.status-pill.is-offline .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.12);
}

.status-pill.is-checking .status-dot {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.8);
  }
}

.card {
  border: 1px solid rgba(197, 210, 227, 0.75);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.token-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 20px 24px;
  border-left: 4px solid var(--amber);
}

.token-copy {
  max-width: 560px;
}

.token-copy h2 {
  margin: 3px 0 4px;
}

.token-row {
  display: flex;
  flex: 1;
  max-width: 470px;
  gap: 10px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 22px;
  padding: 4px 2px;
}

.hero h2 {
  margin: 4px 0 8px;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
}

.hero-copy {
  max-width: 660px;
}

.flow {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow li {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.flow li + li::before {
  content: "";
  width: 18px;
  height: 1px;
  margin-right: 2px;
  background: var(--line-strong);
}

.flow span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--navy);
  background: var(--surface);
  font-size: 0.7rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.step-card,
.generate-card {
  padding: 22px;
}

.generate-card {
  margin-top: 20px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.step-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-title h2 {
  margin-bottom: 2px;
}

.step-title .muted {
  font-size: 0.8rem;
}

.step-number {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(145deg, var(--navy), var(--navy-2));
  font-size: 0.8rem;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge.is-success {
  color: var(--green);
  border-color: #b8e6d2;
  background: var(--green-bg);
}

.badge.is-error {
  color: var(--red);
  border-color: #f3c6c1;
  background: var(--red-bg);
}

.badge.is-warning {
  color: var(--amber);
  border-color: #f0d9a6;
  background: var(--amber-bg);
}

.badge.is-info {
  color: var(--blue-dark);
  border-color: #c7dcfb;
  background: #edf4ff;
}

.badge.is-running {
  color: var(--blue-dark);
  border-color: #c7dcfb;
  background: #edf4ff;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 168px;
  padding: 20px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfdff, var(--surface-2));
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.is-dragover {
  border-color: var(--blue);
  background: #f3f8ff;
  outline: none;
}

.dropzone.is-dragover {
  transform: translateY(-1px);
}

.dropzone svg {
  width: 34px;
  height: 34px;
  margin-bottom: 9px;
  fill: var(--blue);
}

.dropzone p {
  font-size: 0.9rem;
}

.dropzone .small {
  margin-top: 4px;
  max-width: 390px;
}

.link {
  color: var(--blue);
  font-weight: 700;
}

.file-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.82rem;
}

.file-list .file-info {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.file-list .file-info svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  fill: var(--blue);
}

.file-list .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list .file-size {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.74rem;
}

.remove-file {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.remove-file:hover {
  color: var(--red);
  border-color: #f3c6c1;
  background: var(--red-bg);
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.download-row {
  padding-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 3px solid rgba(23, 105, 224, 0.25);
  outline-offset: 2px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(145deg, var(--blue), var(--blue-dark));
  box-shadow: 0 7px 16px rgba(23, 105, 224, 0.22);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(145deg, var(--blue-dark), #0b47a2);
}

.btn-secondary {
  color: var(--navy);
  border-color: var(--line-strong);
  background: var(--surface);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--blue);
  background: #f3f8ff;
}

.btn-ghost {
  color: var(--navy);
  background: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(13, 43, 79, 0.06);
}

.btn-success {
  color: #fff;
  background: linear-gradient(145deg, #12996a, var(--green));
  box-shadow: 0 7px 16px rgba(15, 138, 95, 0.22);
}

.btn-success:hover:not(:disabled) {
  background: linear-gradient(145deg, #0f8a5f, #0a6d4b);
}

.btn-small {
  min-height: 34px;
  padding: 6px 11px;
  font-size: 0.78rem;
}

.btn-large {
  min-height: 46px;
  padding: 11px 22px;
  font-size: 0.94rem;
}

input[type="password"],
input[type="text"],
select {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-size: 0.86rem;
}

input:focus,
select:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(23, 105, 224, 0.14);
}

select:disabled {
  color: var(--muted);
  background: var(--surface-2);
}

.file-picker {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 88px;
  padding: 15px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfdff, var(--surface-2));
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.file-picker:hover,
.file-picker:focus-within {
  border-color: var(--blue);
  background: #f3f8ff;
}

.file-picker svg {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  fill: var(--blue);
}

.file-picker-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.file-picker-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field {
  margin-top: 15px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.progress {
  position: relative;
  overflow: hidden;
  height: 7px;
  margin-top: 13px;
  border-radius: 999px;
  background: #e8eef7;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #3b9cff);
  transition: width 0.18s ease;
}

.progress-bar.is-indeterminate {
  width: 38%;
  animation: slide 1.25s ease-in-out infinite;
}

@keyframes slide {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(290%);
  }
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
}

.summary-item {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 0 6px;
}

.summary-item + .summary-item {
  border-left: 1px solid var(--line);
}

.summary-item span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.summary-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
}

.job-panel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
}

.job-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.job-head strong {
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.82rem;
}

.job-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.76rem;
}

.job-meta span:last-child {
  text-align: right;
}

.verification {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.verification-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.verification-head h3 {
  margin-top: 2px;
}

.issue-list {
  display: grid;
  gap: 7px;
}

.issue {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 0.8rem;
}

.issue.is-error {
  color: #8d2419;
  background: var(--red-bg);
}

.issue.is-warning {
  color: #765000;
  background: var(--amber-bg);
}

.issue.is-ok {
  color: var(--green);
  background: var(--green-bg);
}

.issue::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  background: currentColor;
}

.details {
  margin-top: 13px;
  border-top: 1px solid var(--line);
  padding-top: 11px;
}

.details summary {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.details summary:hover {
  color: var(--blue);
}

pre {
  overflow: auto;
  max-height: 330px;
  margin: 10px 0 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: #253349;
  font-family: "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
  font-size: 0.74rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

pre.console {
  border-color: #1d3554;
  background: #0d1b2c;
  color: #cfe1f7;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 26px;
  padding: 16px 4px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.74rem;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(390px, calc(100vw - 44px));
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(13, 43, 79, 0.18);
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 600;
  animation: toast-in 0.18s ease-out;
}

.toast.is-error {
  color: #8d2419;
  border-color: #f3c6c1;
  background: var(--red-bg);
}

.toast.is-success {
  color: #0a6d4b;
  border-color: #b8e6d2;
  background: var(--green-bg);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (max-width: 900px) {
  .hero {
    display: block;
  }

  .flow {
    margin-top: 16px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .token-card {
    display: block;
  }

  .token-row {
    max-width: none;
    margin-top: 14px;
  }
}

@media (max-width: 620px) {
  .page {
    padding: 20px 15px 36px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .topbar-right {
    flex-direction: column;
    align-items: flex-end;
  }

  .hero h2 {
    font-size: 1.45rem;
  }

  .flow {
    flex-wrap: wrap;
  }

  .flow li + li::before {
    display: none;
  }

  .step-card,
  .generate-card {
    padding: 17px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-item + .summary-item {
    border-top: 1px solid var(--line);
    border-left: 0;
    padding-top: 8px;
  }

  .job-meta {
    display: grid;
    gap: 3px;
  }

  .job-meta span:last-child {
    text-align: left;
  }

  footer {
    display: grid;
  }
}

/* Login page */
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid rgba(197, 210, 227, 0.75);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.login-brand h1 {
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.login-card .field {
  margin-top: 0;
  margin-bottom: 14px;
}

.login-card .btn {
  width: 100%;
}

.login-card #login-error {
  margin-top: 12px;
  color: var(--red);
  text-align: center;
}

.login-card .details {
  margin-top: 18px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.login-card .details p {
  margin-top: 8px;
}

.btn-logout {
  color: var(--red);
  border-color: #f3c6c1;
  background: var(--red-bg);
}

.btn-logout:hover:not(:disabled) {
  background: #fbd9d5;
}
