:root {
  --bg: #0f141f;
  --surface: #182031;
  --surface-soft: #202b40;
  --text: #e9edf5;
  --muted: #9fa9bc;
  --accent: #5de4c7;
  --accent-2: #ffd166;
  --error: #ff6b6b;
  --ok: #7ee081;
  --border: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 5% 5%, #1d3159, transparent 40%),
    radial-gradient(circle at 80% 0%, #3c1f63, transparent 45%),
    linear-gradient(135deg, #070b12, #101827 60%, #0f141f);
  padding: 32px 20px;
}

[hidden] {
  display: none !important;
}

.bg-orb {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
  pointer-events: none;
}

.bg-orb-a {
  width: 320px;
  height: 320px;
  background: #1be7ff;
  top: -80px;
  left: -80px;
}

.bg-orb-b {
  width: 300px;
  height: 300px;
  background: #ff9f1c;
  right: -90px;
  bottom: -100px;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
}

.auth-shell {
  position: relative;
  z-index: 1;
  max-width: 460px;
  margin: 14vh auto 0;
}

.auth-card {
  display: grid;
  gap: 20px;
  padding: 30px 30px 26px;
  background: linear-gradient(180deg, rgba(25, 34, 54, 0.96), rgba(17, 24, 39, 0.98));
}

.auth-footer {
  display: grid;
  gap: 6px;
  min-height: 24px;
}

.auth-actions {
  display: block;
}

.auth-lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 1rem;
}

.auth-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.auth-status {
  margin: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.auth-status.loading {
  color: var(--accent-2);
}

.auth-status.ok {
  color: var(--ok);
}

.auth-status.error {
  color: var(--error);
}

.auth-card .button-row {
  width: 100%;
}

.auth-card .button-row button {
  width: 100%;
  justify-content: center;
}

.auth-primary {
  border: 1px solid rgba(93, 228, 199, 0.32);
  background:
    linear-gradient(135deg, rgba(93, 228, 199, 0.22), rgba(255, 209, 102, 0.16)),
    linear-gradient(180deg, rgba(30, 41, 65, 0.98), rgba(22, 31, 50, 0.98));
  color: #f7fbff;
  font-weight: 700;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.auth-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(93, 228, 199, 0.5);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
}

.auth-primary:focus-visible {
  outline: 2px solid rgba(93, 228, 199, 0.7);
  outline-offset: 2px;
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.6rem);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.02em;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
}

.header-actions {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.session-summary {
  margin: 0;
  max-width: 320px;
  color: var(--muted);
  text-align: right;
  font-size: 0.92rem;
  line-height: 1.4;
}

.tab-nav {
  display: inline-flex;
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(24, 32, 49, 0.8);
}

.tab-btn {
  border: 0;
  padding: 10px 18px;
  font: inherit;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: all 160ms ease;
}

.tab-btn.active {
  color: #111;
  background: var(--accent);
  font-weight: 700;
}

.tab-panel {
  display: none;
  margin-top: 20px;
  gap: 18px;
}

.tab-panel.active {
  display: grid;
}

.panel-card {
  background: linear-gradient(160deg, rgba(33, 44, 66, 0.95), rgba(18, 26, 41, 0.95));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.25);
}

.panel-card h2,
.panel-card h3 {
  margin: 0;
}

.result-card {
  min-height: 280px;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

input,
select,
textarea,
button {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(93, 228, 199, 0.6);
  border-color: transparent;
}

button[type='submit'] {
  cursor: pointer;
  font-weight: 700;
  border: 0;
  color: #101827;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.button-row {
  display: flex;
  gap: 10px;
}

button.secondary {
  cursor: pointer;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface-soft);
  font-weight: 600;
}

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

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.status-pill.loading {
  color: #111;
  background: var(--accent-2);
}

.status-pill.ok {
  color: #06240f;
  background: var(--ok);
}

.status-pill.error {
  color: #2f0d0d;
  background: var(--error);
}

.report-output {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.result-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.metrics-panel {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(140deg, rgba(18, 26, 41, 0.95), rgba(21, 33, 51, 0.95));
}

.metrics-panel.hidden {
  display: none;
}

.metrics-panel h4 {
  margin: 0 0 10px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.metric-card {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.metric-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  margin: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1rem;
  color: #f7fbff;
}

.report-output.empty,
.themes-grid.empty {
  color: var(--muted);
  font-style: italic;
}

.report-section {
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
}

.report-section h4 {
  margin: 0 0 6px;
}

.report-section p {
  margin: 0;
  color: #dfe6f5;
  line-height: 1.5;
  text-align: left;
  hyphens: auto;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.md p {
  margin: 0 0 8px;
  color: #dfe6f5;
  text-align: left;
  hyphens: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.md,
.md * {
  max-width: 100%;
  box-sizing: border-box;
}

.md ul {
  margin: 0 0 8px 18px;
  padding: 0;
}

.md li {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.md a {
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.md code {
  font-family: 'IBM Plex Mono', monospace;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 1px 5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  table-layout: fixed;
  display: block;
  overflow-x: auto;
}

.md th,
.md td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.md blockquote {
  margin: 0 0 8px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
  color: #c9d4e9;
}

.themes-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.themes-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  min-width: 0;
}

.keywords-review {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.keywords-review.hidden {
  display: none;
}

.progress-wrap {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.progress-wrap.hidden {
  display: none;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 180ms ease;
}

textarea {
  resize: vertical;
  min-height: 88px;
}

.company-card {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  height: 100%;
}

.card-actions {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.company-card h4 {
  margin: 0;
  font-size: 1.02rem;
}

.company-card p {
  margin: 0;
  color: #d8e0f1;
  font-size: 0.92rem;
}

.card-links {
  display: flex;
  gap: 10px;
  font-size: 0.87rem;
}

.card-links a {
  color: var(--accent);
  text-decoration: none;
}

.keywords {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 760px) {
  .app-header {
    grid-template-columns: 1fr;
    display: grid;
  }

  .header-actions {
    justify-items: stretch;
  }

  .session-summary {
    max-width: none;
    text-align: left;
  }

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