@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=Poppins:wght@400;500;600&display=swap');

/* ─── Design tokens ─────────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  --bg-base:      #0a0a0a;
  --bg-deep:      #050505;
  --bg-panel:     #111111;
  --bg-panel-alt: #161616;
  --bg-input:     #0e0e0e;

  --border:        rgba(255, 255, 255, 0.07);
  --border-hover:  rgba(255, 255, 255, 0.11);
  --border-focus:  rgba(220, 38, 38, 0.65);

  --red:           #dc2626;
  --red-hover:     #ef4444;
  --red-glow:      rgba(220, 38, 38, 0.15);
  --red-subtle:    rgba(220, 38, 38, 0.07);

  --text-primary:  #f0f0f0;
  --text-muted:    #7a7a7a;
  --text-faint:    #444444;
  --text-red:      #f87171;

  --radius:        8px;
  --radius-lg:     12px;

  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg-base);
  color: var(--text-primary);
}

/* ─── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
h1, h2, h3, h4 { font-family: 'Sora', system-ui, sans-serif; margin-top: 0; }
h1, h2, p { margin-top: 0; }

/* ─── Page ───────────────────────────────────────────────────────────── */
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top left, rgba(220, 38, 38, 0.06) 0%, transparent 45%),
    linear-gradient(180deg, #0a0a0a 0%, #050505 100%);
}

/* ─── Animations ─────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0   rgba(220, 38, 38, 0.55); }
  50%       { box-shadow: 0 0 0 5px rgba(220, 38, 38, 0); }
}

/* ─── Shell / layout ─────────────────────────────────────────────────── */
.shell {
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 64px;
}
.results-shell {
  width: min(1100px, calc(100% - 32px));
}

/* ─── Panel ──────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 12px;
  animation: fadeUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: border-color 0.2s ease;
}
.panel:hover          { border-color: var(--border-hover); }
.panel:nth-child(2)   { animation-delay: 0.05s; }
.panel:nth-child(3)   { animation-delay: 0.10s; }
.panel:nth-child(4)   { animation-delay: 0.14s; }
.panel:nth-child(5)   { animation-delay: 0.18s; }
.panel:nth-child(n+6) { animation-delay: 0.22s; }

.hero-panel {
  padding: 32px 28px;
  border-color: rgba(220, 38, 38, 0.1);
}

/* ─── Typography ─────────────────────────────────────────────────────── */
.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--red);
  font-family: 'Poppins', sans-serif;
}

h1 {
  font-size: clamp(1.3rem, 2.2vw, 1.8rem);
  line-height: 1.15;
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.lede {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.muted { color: var(--text-muted); font-size: 0.85rem; }

dd, td, li { color: #c0c0c0; }

/* ─── Form ───────────────────────────────────────────────────────────── */
.lookup-form {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.field-label {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: 'Poppins', sans-serif;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input[type="text"]:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--red-glow);
}
input[type="text"]::placeholder { color: var(--text-faint); }

/* ─── Buttons ────────────────────────────────────────────────────────── */
button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 120px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease,
              box-shadow 0.18s ease, transform 0.13s ease;
  letter-spacing: 0.02em;
}

button {
  background: var(--red);
  color: #fff;
}
button:hover {
  background: var(--red-hover);
  box-shadow: 0 4px 18px rgba(220, 38, 38, 0.3);
  transform: translateY(-1px);
}
button:active { transform: scale(0.98); box-shadow: none; }

.secondary-link {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.secondary-link:hover {
  background: var(--bg-panel-alt);
  border-color: var(--border-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}
.secondary-link:active { transform: scale(0.98); }

/* ─── Results header ─────────────────────────────────────────────────── */
.results-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ─── Meta grid (result summary cards) ──────────────────────────────── */
.meta-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin: 16px 0 0;
}

.meta-grid div {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel-alt);
  transition: border-color 0.2s ease;
}
.meta-grid div:hover { border-color: rgba(220, 38, 38, 0.18); }

dt {
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

dd {
  margin: 0;
  word-break: break-word;
  font-size: 0.82rem;
  color: #c8c8c8;
  line-height: 1.5;
}

/* ─── Results data sections ──────────────────────────────────────────── */

/* Section divider label */
.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 8px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* KV table (form data) */
.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.kv-table tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}
.kv-table tr:last-child { border-bottom: none; }
.kv-table tr:hover { background: rgba(255,255,255,0.02); }
.kv-table td {
  padding: 9px 12px;
  border: none;
  vertical-align: top;
}
.kv-table td:first-child {
  width: 34%;
  color: #999;
  font-size: 0.78rem;
  font-weight: 600;
}
.kv-table td:last-child { color: #e0e0e0; }

/* Data tables (scraped tables) */
.data-table-wrap { overflow-x: auto; border-radius: var(--radius); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.data-table thead tr { background: var(--bg-panel-alt); }
.data-table th {
  padding: 9px 11px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  color: #c0c0c0;
  min-width: 90px;
  vertical-align: top;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ─── Result summary row ─────────────────────────────────────────────── */
.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.summary-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel-alt);
  transition: border-color 0.2s ease;
}
.summary-card:hover { border-color: rgba(220, 38, 38, 0.18); }

.summary-card dt {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.dt-sep { font-weight: 400; color: var(--text-faint); text-transform: none; letter-spacing: 0; }

.summary-card dd {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: #e0e0e0;
  word-break: break-word;
}

.code-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.22);
  color: var(--text-red);
  font-weight: 700;
  font-size: 0.84rem;
  letter-spacing: 0.05em;
}

.fo-inline {
  font-family: 'SFMono-Regular', 'Consolas', monospace;
  font-size: 0.8rem;
  color: var(--text-red);
  word-break: break-all;
}

.val-faint { color: var(--text-faint); font-weight: 400; }

/* ─── Bag grid ───────────────────────────────────────────────────────── */
.bag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.bag-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.15s ease;
  animation: fadeUp 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.bag-card:hover     { border-color: var(--border-hover); transform: translateY(-1px); }
.bag-card.is-found  { border-color: rgba(34, 197, 94, 0.22); }

.bag-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 13px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
}

.bag-num {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.bag-body {
  padding: 12px 13px;
}
.bag-body dl {
  margin: 0;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 5px 10px;
  align-items: baseline;
}
.bag-body dt {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.bag-body dd {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: #e0e0e0;
}

.found-note {
  margin: 8px 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #86efac;
  letter-spacing: 0.02em;
}

/* ─── Status badges (bag) ────────────────────────────────────────────── */
.badge-found {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: #86efac;
  letter-spacing: 0.03em;
}
.badge-partial {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.2);
  color: #fde047;
  letter-spacing: 0.03em;
}
.badge-missing {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  background: rgba(60, 60, 60, 0.12);
  border: 1px solid rgba(80, 80, 80, 0.15);
  color: var(--text-faint);
  letter-spacing: 0.03em;
}

/* ─── FO list ────────────────────────────────────────────────────────── */
.fo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.fo-entry {
  padding: 7px 11px;
  background: var(--bg-panel-alt);
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: 'SFMono-Regular', 'Consolas', monospace;
  color: var(--text-red);
  letter-spacing: 0.02em;
  border: 1px solid rgba(220, 38, 38, 0.1);
}

/* ─── Collapsible details ────────────────────────────────────────────── */
details.collapse-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  background: var(--bg-panel);
  overflow: hidden;
  transition: border-color 0.2s ease;
}
details.collapse-panel:hover { border-color: var(--border-hover); }
details.collapse-panel[open]  { border-color: var(--border-hover); }

details.collapse-panel summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
  transition: color 0.15s ease;
}
details.collapse-panel summary::-webkit-details-marker { display: none; }
details.collapse-panel summary::before {
  content: '›';
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-faint);
  transition: transform 0.2s ease;
  line-height: 1;
}
details.collapse-panel[open] summary::before { transform: rotate(90deg); }
details.collapse-panel summary:hover { color: var(--text-primary); }

.collapse-body {
  padding: 0 20px 18px;
  animation: fadeIn 0.2s ease;
}

/* ─── Text list (visible text) ───────────────────────────────────────── */
.text-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}
.text-list li {
  font-size: 0.8rem;
  color: #888;
  padding: 5px 8px;
  border-radius: 4px;
  transition: background 0.15s ease;
}
.text-list li:hover { background: var(--bg-panel-alt); color: #aaa; }

/* ─── Pre / code ─────────────────────────────────────────────────────── */
pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  line-height: 1.65;
  color: #888;
  max-height: 400px;
  overflow-y: auto;
}

/* ─── Step timeline ──────────────────────────────────────────────────── */
.progress-steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.step-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  animation: fadeIn 0.25s ease both;
}

.step-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid var(--text-faint);
  background: transparent;
  margin-top: 6px;
  flex-shrink: 0;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.step-line {
  width: 2px;
  flex: 1;
  min-height: 28px;
  background: var(--border);
  margin-top: 4px;
  transition: background 0.3s ease;
}

.step-copy { padding-bottom: 16px; }

.step-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.step-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.83rem;
  color: var(--text-primary);
}

.step-detail {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

/* ─── Step / status badges ───────────────────────────────────────────── */
.step-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background 0.25s ease, color 0.25s ease;
}

.status-badge.is-queued,
.step-pill.is-pending {
  background: rgba(70,70,70,0.15);
  border-color: rgba(100,100,100,0.18);
  color: #555;
}

.status-badge.is-running,
.step-pill.is-running {
  background: rgba(220,38,38,0.1);
  border-color: rgba(220,38,38,0.22);
  color: var(--text-red);
}

.status-badge.is-success,
.step-pill.is-success {
  background: rgba(34,197,94,0.08);
  border-color: rgba(34,197,94,0.18);
  color: #86efac;
}

.status-badge.is-error,
.step-pill.is-error {
  background: rgba(220,38,38,0.1);
  border-color: rgba(220,38,38,0.22);
  color: #fca5a5;
}

/* ─── Step dot states ────────────────────────────────────────────────── */
.step-item.is-running .step-dot {
  border-color: var(--red);
  background: var(--red);
  animation: pulse-dot 1.5s ease-in-out infinite;
}
.step-item.is-success .step-dot { border-color: #22c55e; background: #22c55e; }
.step-item.is-error   .step-dot { border-color: var(--red); background: var(--red); }
.step-item.is-success .step-line { background: rgba(34,197,94,0.18); }
.step-item.is-running .step-line,
.step-item.is-error   .step-line { background: rgba(220,38,38,0.15); }

/* ─── State text ─────────────────────────────────────────────────────── */
.error-text   { color: #fca5a5; margin: 0; font-size: 0.85rem; }
.success-text { color: #86efac; margin: 0; font-size: 0.85rem; }

/* ─── Utility ────────────────────────────────────────────────────────── */
.is-hidden { display: none; }

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .shell { width: calc(100% - 24px); padding: 20px 0 48px; }
  .hero-panel, .panel { padding: 16px; }
  .results-header, .step-row { flex-direction: column; }
  button, .secondary-link, .status-badge { width: 100%; }
  .inline-actions { width: 100%; }
}
