/* ─────────────────────────────────────────────────────────────────────────
   Namu SOV Ingestion — light theme (Namu brand palette)
   Palette: #4CC9F0 (brand sky) + #0A192F (deep navy) on slate-50 surfaces.
   Typography: DM Sans (loaded from Google Fonts in _base.html).
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --bg:            #f8fafc;  /* slate-50 */
  --bg-elev:       #ffffff;
  --bg-tint:       #f1f5f9;  /* slate-100 */

  --border:        #f1f5f9;  /* slate-100 */
  --border-strong: #e2e8f0;  /* slate-200 */

  --text:          #0f172a;  /* slate-900 */
  --text-2:        #334155;  /* slate-700 */
  --text-muted:    #64748b;  /* slate-500 */
  --text-dim:      #94a3b8;  /* slate-400 */

  --brand:         #4CC9F0;
  --brand-strong:  #0A192F;
  --brand-hover:   #38bdf8;
  --brand-soft:    rgba(76, 201, 240, 0.10);
  --brand-soft-2:  rgba(76, 201, 240, 0.18);

  --ok:            #10b981;
  --ok-soft:       #ecfdf5;
  --warn:          #f59e0b;
  --warn-soft:     #fffbeb;
  --bad:           #f43f5e;
  --bad-soft:      #fff1f2;

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 24px;

  --shadow-sm:
    0 1px 2px 0 rgb(15 23 42 / 0.04);
  --shadow:
    0 12px 24px -10px rgb(15 23 42 / 0.10),
    0 6px 12px -6px rgb(15 23 42 / 0.05);
  --shadow-lg:
    0 30px 60px -20px rgb(15 23 42 / 0.18),
    0 12px 24px -8px rgb(15 23 42 / 0.08);

  --font:
    'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica,
    Arial, 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
}

* { box-sizing: border-box; }

/* Beat author-stylesheet display rules so the `hidden` attribute works. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }
a.link {
  color: var(--brand-hover);
  text-decoration: none;
  font-weight: 500;
}
a.link:hover { text-decoration: underline; }

code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--bg-tint);
  padding: 0.05em 0.4em;
  border-radius: 4px;
}

/* ─── topbar ────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.6rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.topbar .brand { display: inline-flex; line-height: 0; }
.topbar .brand img { display: block; max-width: 200px; height: auto; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0;
}
.user-badge {
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
}
.link-button {
  background: none;
  border: none;
  font: inherit;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  font-size: 0.85rem;
}
.link-button:hover { color: var(--brand-hover); }

/* ─── layout ────────────────────────────────────────────────────────── */

.page {
  flex: 1 0 auto;
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.footer {
  flex: 0 0 auto;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 1.5rem 1rem 2rem;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
.empty { color: var(--text-muted); font-style: italic; margin: 0.5rem 0 0; }

/* Off-screen-but-accessible. Unlike the `hidden` HTML attribute, this
   leaves the element in the layout tree so the file input still accepts
   programmatic .click() and drag-drop .files assignment in every browser. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ─── cards ─────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.8rem 1.8rem;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.9rem;
}
.card-head h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

/* ─── hero ──────────────────────────────────────────────────────────── */

.hero {
  text-align: center;
  margin: 0.5rem auto 0.6rem;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.hero-title {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--brand-strong);
}
.hero-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.55;
}
.hero-subtitle code {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

/* ─── AI disclaimer ─────────────────────────────────────────────────── */

.ai-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0 auto;
  max-width: 640px;
  width: 100%;
  padding: 0.9rem 1.1rem;
  background: var(--warn-soft);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.55;
  color: #92400e;
}
.ai-disclaimer strong { color: #78350f; }

/* ─── upload card / dropzone ────────────────────────────────────────── */

.upload-card { padding: 1.4rem; }
.upload {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.8rem 1.5rem;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background   160ms ease,
    transform    120ms ease,
    padding      260ms cubic-bezier(0.4, 0, 0.2, 1),
    min-height   260ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow   200ms ease;
}
.dropzone:hover,
.dropzone.dragging {
  border-color: var(--brand);
  background: var(--brand-soft);
}

/* Shrink to a compact "file ready" strip once a file is picked — gives
   the end user clear, immediate confirmation the upload registered. */
.dropzone.has-file {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: start;
  column-gap: 0.9rem;
  row-gap: 0.1rem;
  min-height: 0;
  padding: 0.9rem 1.1rem;
  text-align: left;
  border-style: solid;
  border-color: var(--ok);
  background: var(--ok-soft);
  box-shadow: 0 2px 14px -6px rgba(16, 185, 129, 0.35);
}
.dropzone.has-file:hover { background: var(--ok-soft); }
.dropzone.has-file .feature-pills { display: none; }

.dropzone-icon {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: var(--bg-tint);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  transition: transform 160ms ease, color 160ms ease, background 160ms ease,
    width 220ms ease, height 220ms ease, margin 220ms ease;
}
.dropzone:hover .dropzone-icon,
.dropzone.dragging .dropzone-icon {
  transform: scale(1.06);
  color: var(--brand-strong);
  background: var(--brand-soft-2);
}
.dropzone.has-file .dropzone-icon {
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 38px;
  height: 38px;
  margin-bottom: 0;
  color: var(--ok);
  background: rgba(16, 185, 129, 0.14);
}
.dropzone-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}
.dropzone-hint {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}
.dropzone.has-file .dropzone-title {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ok);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dropzone.has-file .dropzone-hint {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
}

.feature-pills {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 0.6rem;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.feature-pills li {
  padding: 0.22rem 0.6rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
}

.upload-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.upload-actions .muted { margin: 0; }

.upload-status {
  flex: 1 1 100%;
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.45;
}
.upload-status[hidden] { display: none !important; }
.upload-status.is-error {
  background: #fff5f5;
  border: 1px solid #fc8181;
  color: #742a2a;
}
.upload-status.is-pending {
  background: #f0fafe;
  border: 1px solid var(--brand);
  color: var(--text);
}

/* ─── buttons ───────────────────────────────────────────────────────── */

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0;
  transition:
    background 140ms ease,
    color      140ms ease,
    transform  100ms ease,
    box-shadow 140ms ease;
}

.btn-primary {
  background: var(--brand-strong);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: #112746;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn-primary:disabled {
  background: var(--text-dim);
  cursor: progress;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-elev);
  color: var(--brand-strong);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

/* ─── badges ────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-pending   { background: var(--bg-tint);  color: var(--text-muted); border-color: var(--border-strong); }
.badge-running   { background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand); animation: pulse 1.8s ease-in-out infinite; }
.badge-completed { background: var(--ok-soft);  color: var(--ok); border-color: rgba(16,185,129,0.4); }
.badge-failed    { background: var(--bad-soft); color: var(--bad); border-color: rgba(244,63,94,0.4); }
.badge-awaiting_catalog_approval {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: rgba(245,158,11,0.45);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76, 201, 240, 0.45); }
  70%      { box-shadow: 0 0 0 8px rgba(76, 201, 240, 0); }
}

/* ─── job page ──────────────────────────────────────────────────────── */

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

.job-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.job-meta {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.2rem;
}
.job-id { font-size: 0.95rem; }
.job-filename {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--brand-strong);
  line-height: 1.25;
  max-width: 540px;
}

.summary {
  display: flex;
  gap: 1.5rem;
  margin: 1.2rem 0 1rem;
  padding: 1rem 1.2rem;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.metric-label {
  display: block;
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.15rem;
}
.metric-value {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--brand-strong);
  font-variant-numeric: tabular-nums;
}

/* ─── downloads ─────────────────────────────────────────────────────── */

.downloads {
  display: flex;
  gap: 0.9rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.download-option {
  flex: 1 1 240px;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  text-decoration: none;
  color: inherit;
  transition:
    border-color 140ms ease,
    box-shadow   140ms ease,
    transform    100ms ease,
    background   140ms ease;
}
.download-option:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.download-option.is-primary {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.download-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.download-icon-xlsx { background: rgba(16, 185, 129, 0.16); color: #0f9d58; }
.download-icon-csv  { background: var(--brand-soft-2); color: var(--brand-strong); }

.download-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.download-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}
.download-title code {
  font-size: 0.8em;
  background: transparent;
  padding: 0;
}
.download-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.alert {
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  font-size: 0.9rem;
  margin-top: 1rem;
}
.alert-error {
  background: var(--bad-soft);
  color: #be123c;
  border: 1px solid rgba(244, 63, 94, 0.30);
  white-space: pre-wrap;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

/* ─── progress stepper ──────────────────────────────────────────────── */
/* Plain-language milestones for the end user — deliberately abstracted
   away from the pipeline's internal stage/LLM/model details. */

.progress-card { padding: 1.5rem; }

.steps {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.6rem 0;
}
.step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 34px;
  bottom: -0.6rem;
  width: 2px;
  background: var(--border-strong);
  transition: background 200ms ease;
}
.step.done:not(:last-child)::before { background: var(--ok); }

.step-marker {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid var(--border-strong);
  background: var(--bg-elev);
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 200ms ease, background 200ms ease, color 200ms ease;
}

.step-title {
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: color 200ms ease, font-weight 200ms ease;
}

.step.active .step-marker {
  border-color: var(--brand);
  background: var(--brand-soft);
  animation: pulse 1.8s ease-in-out infinite;
}
.step.active .step-title { color: var(--text); font-weight: 600; }

.step.waiting .step-marker {
  border-color: var(--warn);
  background: var(--warn-soft);
  animation: pulse-warn 1.8s ease-in-out infinite;
}
.step.waiting .step-title { color: var(--warn); font-weight: 600; }

.step.done .step-marker {
  border-color: var(--ok);
  background: var(--ok);
  color: #ffffff;
}
.step.done .step-title { color: var(--text-2); }

.step.error .step-marker {
  border-color: var(--bad);
  background: var(--bad-soft);
}
.step.error .step-title { color: var(--bad); font-weight: 600; }

@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.45); }
  70%      { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
}

/* ─── login page ────────────────────────────────────────────────────── */

body.auth-page {
  background:
    radial-gradient(1100px 600px at 50% -15%, rgba(76, 201, 240, 0.18) 0%, var(--bg) 60%);
  align-items: center;
  justify-content: center;
}

body.auth-page .page {
  max-width: 420px;
  padding: 3rem 1.5rem 2rem;
  flex: 1 0 auto;
  display: flex;
  align-items: center;
}

.auth-card {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.4rem 2rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 0.4rem;
}
.auth-logo img { display: block; max-width: 220px; height: auto; }

.auth-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--brand-strong);
}
.auth-subtitle {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.6rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-align: left;
}
.field-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  font: inherit;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.field input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.auth-submit {
  margin-top: 0.4rem;
  padding-block: 0.75rem;
  font-size: 0.95rem;
}

.auth-foot {
  margin: 1.2rem 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* ─── catalog review modal ─────────────────────────────────────────── */

body.modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(10, 25, 47, 0.45);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(100%, 26rem);
  max-height: calc(100vh - 3rem);
  overflow: auto;
  padding: 1.5rem 1.6rem;
  border-top: 4px solid var(--brand);
  background: linear-gradient(180deg, var(--brand-soft) 0%, var(--bg-elev) 170px);
  box-shadow: var(--shadow-lg);
}

.modal-head {
  margin-bottom: 1rem;
}

.modal-head h2 {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
}

.review-readonly {
  margin: 0 0 1.1rem;
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.review-readonly dt {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.review-readonly dd {
  margin: 0.2rem 0 0;
  color: var(--text-2);
  line-height: 1.45;
  white-space: pre-wrap;
}

.review-readonly dd.italic {
  font-style: italic;
}

.review-form {
  display: grid;
  gap: 1rem;
}

.review-form select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

/* ─── responsive ────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .topbar { padding: 0.9rem 1rem; }
  .topbar .brand img { max-width: 150px; }
  .page { padding: 1.5rem 1rem; gap: 1.1rem; }
  .card { padding: 1.4rem 1.2rem; border-radius: var(--radius); }
  .hero-title { font-size: 1.6rem; }
  .job-filename { font-size: 1.15rem; }
  .dropzone { padding: 2rem 1rem; }
}
