:root {
  --bg: #0f172a;
  --card: rgba(30, 41, 59, 0.95);
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.2);
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #6366f1;
  --cream: #f8fafc;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

a {
  color: inherit;
}

.shell {
  width: min(1680px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 6, 23, 0.95);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.24);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
}

.brand-dot {
  color: var(--green);
  font-size: 1.8rem;
  line-height: 1;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

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

.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.hero {
  position: relative;
  display: grid;
  min-height: min(640px, calc(100vh - 118px));
  place-content: center;
  gap: 28px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 50%, #1e3a5f 100%);
  color: var(--card);
  padding: clamp(24px, 5vw, 56px);
  box-shadow: var(--shadow);
  text-align: center;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--rust);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.hero .eyebrow {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  width: fit-content;
  margin-inline: auto;
  border-radius: 999px;
  border: 1px solid rgba(147, 51, 234, 0.5);
  background: rgba(88, 28, 135, 0.2);
  color: #d8b4fe;
  padding: 8px 12px;
  text-transform: none;
}

.hero .eyebrow span {
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  padding: 4px 10px;
}

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

h1 {
  max-width: 900px;
  margin-bottom: 18px;
  font-size: clamp(2.7rem, 7vw, 6.9rem);
  line-height: 1;
  letter-spacing: 0;
}

.hero h1 {
  margin-inline: auto;
  background: linear-gradient(135deg, #ffffff 0%, #60a5fa 50%, #3b82f6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

.hero h2 {
  max-width: 900px;
  margin-inline: auto;
  margin-bottom: 20px;
  font-size: clamp(2.5rem, 7vw, 6.6rem);
  font-weight: 300;
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 2.8vw, 2.4rem);
  line-height: 1.05;
}

.hero div > p:not(.eyebrow),
.hero p:last-child {
  max-width: 760px;
  margin-inline: auto;
  color: rgba(229, 231, 235, 0.84);
  font-size: 1.1rem;
  line-height: 1.6;
}

.hero-panel {
  display: grid;
  width: min(820px, 100%);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-inline: auto;
}

.metric {
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.07);
}

.metric strong {
  display: block;
  font-size: 2.4rem;
}

.metric span {
  color: rgba(229, 231, 235, 0.72);
  font-size: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.button,
button,
.link-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.9);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
  padding: 0 14px;
}

.button.primary,
button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button.primary:hover,
button.primary:hover {
  background: var(--primary-dark);
}

.button.dark {
  border-color: rgba(255, 253, 248, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.aurora-button {
  border-color: #3b82f6;
  background: rgba(255, 255, 255, 0.98);
  color: #fff;
  color: #000;
  box-shadow: 0 4px 24px rgba(59, 130, 246, 0.58);
}

.marquee-wrap {
  position: relative;
  width: min(720px, 100%);
  margin: 58px auto 0;
}

.marquee-track {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  color: #9ca3af;
  font-size: 1.12rem;
}

.marquee-track span {
  margin: 4px 14px;
}

.grid {
  display: grid;
  gap: 14px;
}

.cards-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cards-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-layout {
  grid-template-columns: minmax(0, 1fr) 390px;
  align-items: start;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.card.pad {
  padding: 18px;
}

.card-header {
  padding: 18px 18px 0;
}

.card-body {
  padding: 18px;
}

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

.small {
  font-size: 0.86rem;
  line-height: 1.45;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0 10px;
}

.pill.strong {
  border-color: rgba(19, 255, 170, 0.34);
  background: rgba(19, 255, 170, 0.12);
  color: var(--mint);
}

.domain-card,
.tool-card,
.history-card {
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.domain-card:hover,
.tool-card:hover,
.history-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px auto auto;
  gap: 10px;
  margin: 20px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.input,
input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 6, 23, 0.74);
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 112px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 7px;
  font-size: 0.9rem;
  font-weight: 800;
}

.tool-card {
  display: flex;
  min-height: 300px;
  flex-direction: column;
}

.tool-card h3 {
  margin-bottom: 8px;
  line-height: 1.15;
}

.tool-card .card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.tool-card .source {
  margin-top: auto;
  padding-top: 16px;
  overflow-wrap: anywhere;
}

.runner {
  display: grid;
  grid-template-columns: minmax(320px, 0.86fr) minmax(0, 1.14fr);
  gap: 16px;
  align-items: start;
}

.runner-form,
.output-panel {
  position: sticky;
  top: 86px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.source-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 6, 23, 0.48);
}

.output-empty,
.loading,
.error {
  display: grid;
  min-height: 280px;
  place-items: center;
  padding: 30px;
  text-align: center;
}

.output-section {
  margin-bottom: 22px;
}

.load-row {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.output-section h3 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.output-section li {
  margin-bottom: 8px;
}

pre {
  max-height: 540px;
  overflow: auto;
  white-space: pre-wrap;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #020617;
  color: #dbeafe;
  padding: 16px;
  font-size: 0.82rem;
  line-height: 1.55;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  border-radius: 999px;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #020617;
  color: #fff;
  padding: 12px 14px;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.section {
  margin-top: 26px;
}

@media (max-width: 1120px) {
  .hero,
  .dashboard-layout,
  .runner {
    grid-template-columns: 1fr;
  }

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

  .runner-form,
  .output-panel {
    position: static;
  }

  .cards-3,
  .cards-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 10px;
  }

  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .cards-3,
  .cards-2,
  .toolbar {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(2.45rem, 14vw, 4rem);
  }
}

/* Professional status indicators */
.status-active {
  color: var(--success);
}

.status-inactive {
  color: var(--danger);
}

.status-pending {
  color: var(--warning);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--danger); animation: none; }
.status-dot.pending { background: var(--warning); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* API Key management styles */
.api-keys-link {
  position: relative;
}

.api-keys-link::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 101;
  transform: translate(-50%, -50%) scale(0.95);
  width: min(580px, 90vw);
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  padding: 28px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: transform 200ms ease, opacity 200ms ease;
}

.modal.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.modal h2 {
  font-size: 1.3rem;
  margin-bottom: 6px;
}

.modal .actions {
  margin-top: 20px;
  justify-content: flex-end;
}

/* API key row */
.api-key-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 6, 23, 0.48);
  margin-bottom: 10px;
}

.api-key-row .provider-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 900;
  font-size: 0.9rem;
}

.api-key-row .provider-icon.anthropic { background: #d97706; color: #fff; }
.api-key-row .provider-icon.openai { background: #10a37f; color: #fff; }
.api-key-row .provider-icon.google { background: #4285f4; color: #fff; }
.api-key-row .provider-icon.local { background: var(--info); color: #fff; }

.api-key-info h4 {
  margin: 0 0 3px;
  font-size: 0.92rem;
}

.api-key-info p {
  margin: 0;
  font-size: 0.78rem;
}

.api-key-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 800;
}

.key-masked {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Score card styles */
.score-card {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 6, 23, 0.48);
}

.score-card .score-value {
  font-size: 2.2rem;
  font-weight: 700;
}

.score-card .score-value.excellent { color: var(--success); }
.score-card .score-value.good { color: var(--primary); }
.score-card .score-value.warning { color: var(--warning); }
.score-card .score-value.poor { color: var(--danger); }

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric.compact {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
}

.metric.compact strong {
  font-size: 1.1rem;
}

.metric.compact span {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Timeline grid */
.timeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

/* Result card */
.result-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 12px;
}

.result-card h4 {
  margin: 8px 0 6px;
  font-size: 1rem;
}

/* Table styles */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
}

table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* Lazy note */
.lazy-note {
  border-left: 3px solid var(--warning);
}

/* API settings page */
.api-settings-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.provider-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.provider-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 150ms ease;
}

.provider-item:hover,
.provider-item.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--primary);
}

.provider-item .provider-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 900;
  font-size: 0.8rem;
}

.provider-config {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 6, 23, 0.48);
}

.provider-config h3 {
  margin-bottom: 4px;
}

.provider-config .form-grid {
  margin-top: 16px;
}

/* Active tools indicator */
.tools-active-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius);
  background: rgba(16, 185, 129, 0.08);
  margin-bottom: 20px;
}

.tools-active-bar .count {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--success);
}

.tools-active-bar .label {
  color: var(--muted);
  font-size: 0.88rem;
}

.tools-active-bar .spacer {
  flex: 1;
}

/* Notification badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0 5px;
}
