@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text: #101828;
  --text-muted: #667085;
  --border: #e4e7ec;
  --navy: #0b1f3a;
  --navy-light: #142c52;
  --accent: #0f9d8c;
  --accent-hover: #0c8677;
  --gold: #d4a03c;
  --success: #12805c;
  --error-bg: #fdecea;
  --error-text: #9c2b1f;
  --chip-completed-bg: #e6f6ef;
  --chip-running-bg: #eaf2ff;
  --chip-cancelled-bg: #f2f2f2;
  --chip-cancelled-text: #757575;
  --shadow-ambient: 0 16px 40px rgba(16, 24, 40, 0.09), 0 4px 10px rgba(16, 24, 40, 0.05);
  --shadow-ambient-hover: 0 22px 50px rgba(16, 24, 40, 0.13), 0 6px 14px rgba(16, 24, 40, 0.07);
  --shadow-inset: inset 0 1px 3px rgba(16, 24, 40, 0.06), inset 0 0 0 1px rgba(16, 24, 40, 0.02);
  --card-top-highlight: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] {
  --bg: #0e1320;
  --card-bg: #171e2e;
  --text: #e7eaf1;
  --text-muted: #97a1b6;
  --border: #2b3448;
  --accent: #17b8a3;
  --accent-hover: #1ccdb6;
  --gold: #e0ae4a;
  --success: #35c98a;
  --error-bg: #3a1f1e;
  --error-text: #f0968c;
  --chip-completed-bg: #133226;
  --chip-running-bg: #17263f;
  --chip-cancelled-bg: #262c3a;
  --chip-cancelled-text: #9aa3b5;
  --shadow-ambient: 0 18px 44px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-ambient-hover: 0 24px 56px rgba(0, 0, 0, 0.55), 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-inset: inset 0 1px 3px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  --card-top-highlight: rgba(255, 255, 255, 0.06);
}

* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
}

[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(700px circle at 8% 0%, rgba(15, 157, 140, 0.07), transparent 55%),
    radial-gradient(600px circle at 100% 30%, rgba(212, 160, 60, 0.05), transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background-color 0.2s ease, color 0.2s ease;
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(700px circle at 8% 0%, rgba(23, 184, 163, 0.1), transparent 55%),
    radial-gradient(600px circle at 100% 30%, rgba(224, 174, 74, 0.06), transparent 50%);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  flex-shrink: 0;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

.theme-toggle-fixed {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 10;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ---------------------------------------------------------------- hero */

.hero {
  position: relative;
  margin: 0 -24px 32px;
  padding: 40px 24px 56px;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-light) 60%, #103b52 100%);
  color: #fff;
  overflow: hidden;
  border-radius: 0 0 28px 28px;
}

.hero-network {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
  pointer-events: none;
}

.hero-network .node {
  fill: var(--gold);
}

.hero-network .node.india {
  fill: #ffffff;
}

.hero-network .link {
  fill: none;
  stroke: rgba(255, 255, 255, 0.45);
  stroke-width: 1.2;
  stroke-dasharray: 4 5;
  animation: dash-flow 18s linear infinite;
}

@keyframes dash-flow {
  to { stroke-dashoffset: -400; }
}

.hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  max-width: 712px;
  margin: 0 auto;
}

.hero-content h1 {
  font-size: 2.1rem;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

.hero-content .subtitle {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0;
  max-width: 480px;
}

.hero-stat-strip {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.hero-stat-strip span {
  display: inline-flex;
  align-items: baseline;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 13px;
  border-radius: 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.15);
}

.hero-stat-strip strong {
  color: var(--gold);
  font-weight: 800;
  margin-right: 5px;
  text-shadow: 0 1px 8px rgba(212, 160, 60, 0.4);
}

.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

#user-name {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.88rem;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

/* login page (no topbar) uses a simpler centered header */
.header:not(.topbar) {
  text-align: center;
}
.header:not(.topbar) h1 { color: var(--text); }
.header:not(.topbar) .subtitle { color: var(--text-muted); max-width: none; }

/* ---------------------------------------------------------- auth pages */

.auth-layout {
  display: flex;
  min-height: 100vh;
}

.auth-visual {
  flex: 1 1 46%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-light) 55%, #103b52 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 56px 48px;
}

.auth-visual .hero-network {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}

.auth-visual-content {
  position: relative;
  z-index: 1;
  max-width: 380px;
}

.auth-visual-content h1 {
  font-size: 2.3rem;
  font-weight: 800;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}

.auth-visual-content .subtitle {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
  line-height: 1.6;
}

.auth-stats {
  list-style: none;
  padding: 0;
  margin: 32px 0 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-stats li {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.auth-stats strong {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gold);
  min-width: 52px;
}

.auth-stats span {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.88rem;
}

.auth-form-panel {
  flex: 1 1 54%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  padding: 40px 24px;
}

.auth-form-inner {
  width: 100%;
  max-width: 380px;
}

.auth-form-inner h2 {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.auth-form-inner .lede {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 0.92rem;
}

.auth-switch {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 20px;
}

.input-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon svg {
  position: absolute;
  left: 13px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.auth-form-inner .input-icon input {
  width: 100%;
  padding-left: 42px;
}

@media (max-width: 860px) {
  .auth-layout {
    flex-direction: column;
  }
  .auth-visual {
    flex: 0 0 auto;
    padding: 40px 24px;
  }
  .auth-form-panel {
    padding: 32px 24px 56px;
  }
}

/* ---------------------------------------------------------------- cards */

.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 27px 26px 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-ambient), inset 0 1px 0 var(--card-top-highlight);
  transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22px;
  right: 22px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  opacity: 0.75;
}

.card:hover {
  box-shadow: var(--shadow-ambient-hover), inset 0 1px 0 var(--card-top-highlight);
  border-color: rgba(15, 157, 140, 0.3);
  transform: translateY(-2px);
}

.field-label-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}

.field-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(145deg, rgba(15, 157, 140, 0.16), rgba(15, 157, 140, 0.06));
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5), 0 1px 2px rgba(16, 24, 40, 0.06);
  flex-shrink: 0;
}

[data-theme="dark"] .field-icon-badge {
  background: linear-gradient(145deg, rgba(23, 184, 163, 0.22), rgba(23, 184, 163, 0.08));
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.3);
}

.field-icon {
  width: 13px;
  height: 13px;
  color: var(--accent);
  flex-shrink: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.search-type-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  width: fit-content;
  background: var(--bg);
}

.search-type-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.search-type-btn svg {
  width: 15px;
  height: 15px;
}

.search-type-btn + .search-type-btn {
  border-left: 1px solid var(--border);
}

.search-type-btn:hover:not(.active) {
  background: var(--card-bg);
  color: var(--text);
}

.search-type-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
}

.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 6px 0 0;
}

select,
input[type="number"],
input[type="text"],
input[type="email"],
input[type="password"] {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow-inset);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-inset), 0 0 0 3px rgba(15, 157, 140, 0.15);
}

.btn-primary {
  display: inline-block;
  background: linear-gradient(160deg, var(--accent-hover) 0%, var(--accent) 45%, var(--accent) 100%);
  color: #fff;
  border: none;
  border-bottom: 3px solid rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  padding: 13px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  width: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 12px rgba(15, 157, 140, 0.3);
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, border-bottom-width 0.12s ease;
}

.btn-primary:hover {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 8px 20px rgba(15, 157, 140, 0.4);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 6px rgba(15, 157, 140, 0.3);
}

.btn-primary-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary-content svg {
  width: 17px;
  height: 17px;
  transition: transform 0.15s ease;
}

.btn-primary:hover .btn-primary-content svg {
  transform: translateX(3px);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ------------------------------------------------------------ progress */

.progress-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

.progress-step {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--border);
  position: relative;
}

.progress-step .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--border);
  margin: 0 auto 6px;
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.15);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.progress-step.active .dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 157, 140, 0.18);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 4px rgba(15, 157, 140, 0.18); }
  50% { box-shadow: 0 0 0 7px rgba(15, 157, 140, 0.1); }
}

.progress-step.active {
  color: var(--accent);
}

.progress-step.done .dot {
  background: var(--success);
}

.progress-step.done {
  color: var(--success);
}

.progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  width: 0%;
  transition: width 0.4s ease;
}

.progress-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

#result-summary {
  font-weight: 700;
  color: var(--success);
  margin: 0 0 16px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

thead tr:first-child th:first-child {
  border-top-left-radius: 11px;
}

thead tr:first-child th:last-child {
  border-top-right-radius: 11px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg);
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: var(--bg);
}

tbody tr:last-child td {
  border-bottom: none;
}

.error-card {
  background: var(--error-bg);
  border-color: #f3c6c0;
}

#error-text {
  color: var(--error-text);
  margin: 0;
}

.runs-header h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.runs-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 18px;
}

.run-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

.run-type {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
}

.run-type.buyer { background: var(--chip-running-bg); color: var(--accent); }
.run-type.node { background: var(--chip-cancelled-bg); color: var(--gold); }

.run-status.completed { background: var(--chip-completed-bg); color: var(--success); }
.run-status.running, .run-status.queued { background: var(--chip-running-bg); color: var(--accent); }
.run-status.failed { background: var(--error-bg); color: var(--error-text); }
.run-status.cancelled { background: var(--chip-cancelled-bg); color: var(--chip-cancelled-text); }

#cancel-btn {
  margin-top: 10px;
}

.run-download {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.85rem;
}

.run-download:hover { text-decoration: underline; }

a {
  color: var(--accent);
}

/* ------------------------------------------------------------- mobile */

@media (max-width: 640px) {
  .page {
    padding: 0 16px 56px;
  }

  .hero {
    margin: 0 -16px 24px;
    padding: 24px 16px 32px;
    border-radius: 0 0 20px 20px;
  }

  .hero-content {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .hero-content h1 {
    font-size: 1.6rem;
  }

  .hero-content .subtitle {
    font-size: 0.88rem;
    max-width: none;
  }

  .user-info {
    justify-content: flex-end;
  }

  .hero-stat-strip {
    gap: 14px 20px;
  }

  .card {
    padding: 18px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .progress-step {
    font-size: 0.68rem;
  }

  th, td {
    padding: 8px;
    font-size: 0.8rem;
  }
}
