:root {
  --bg: #f1f3ee;
  --fg: #15202b;
  --muted: #4b5a66;
  --panel: #fffffb;
  --line: #d4d9cc;
  --accent: #006d5b;
  --accent-soft: #e1f1ec;
  --hero-1: #dce9ff;
  --hero-2: #f9f6d7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 5%, #ffffff, transparent 35%),
    radial-gradient(circle at 95% 0%, #ebefe2, transparent 30%),
    linear-gradient(180deg, #f7f8f3 0%, var(--bg) 100%);
  color: var(--fg);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}
.container {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.2rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 8px 24px rgba(18, 35, 32, 0.04);
}
.muted {
  color: var(--muted);
}
.hero {
  background:
    linear-gradient(145deg, var(--hero-1), var(--hero-2));
}
.status-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
}
.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.22rem 0.62rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-queued {
  background: #fff3cc;
  color: #7b5f12;
}
.status-running {
  background: #d9f0ff;
  color: #0d4d7a;
}
.status-interrupted {
  background: #fde6d3;
  color: #8a4418;
}
.status-completed {
  background: #dff5e4;
  color: #206033;
}
.status-failed {
  background: #ffe0e0;
  color: #8a1f1f;
}
.hero h1 {
  margin: 0.2rem 0 0.5rem 0;
  font-size: clamp(1.9rem, 3vw, 2.5rem);
}
.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
}
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  font-weight: 700;
  color: #2d4b63;
}
.grid {
  display: grid;
  gap: 1rem;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
label {
  display: grid;
  gap: 0.45rem;
  font-weight: 600;
  color: #223039;
}
textarea, input[type='file'] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  font-family: inherit;
}
input[type='password'],
input[type='text'] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  font-family: inherit;
  background: #fff;
}
button {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}
button:hover {
  filter: brightness(1.03);
  box-shadow: 0 6px 18px rgba(0, 109, 91, 0.26);
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.ghost-button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: none;
}
.ghost-button:hover {
  background: var(--accent-soft);
  box-shadow: none;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.topbar p {
  margin: 0;
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-card {
  width: min(100%, 520px);
}
table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-y: scroll;
}
th, td {
  border: 1px solid var(--line);
  padding: 0.55rem;
  text-align: left;
  font-size: 0.92rem;
}
th {
  background: #f4f8f5;
}
.log {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.84rem;
  background: #fcfdf8;
}
.event-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 0.6rem;
  padding: 0.35rem 0.25rem;
  border-bottom: 1px dashed #dfe6d7;
}
.event-type {
  font-weight: 700;
  color: #2d4b63;
}
.event-msg {
  color: #17232f;
}
.event-llm {
  background: #e8f3ff;
  border-radius: 8px;
}
.event-warning {
  background: #fff4dd;
  border-radius: 8px;
}
.event-error {
  background: #ffe8e8;
  border-radius: 8px;
}
.workflow-steps {
  display: grid;
  gap: 0.6rem;
}
.workflow-empty {
  margin: 0;
  padding: 0.35rem 0;
}
.workflow-step {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdf9;
  overflow: hidden;
}
.workflow-step summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  font-weight: 700;
}
.workflow-step summary::-webkit-details-marker {
  display: none;
}
.spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #b8d0c5;
  border-top-color: #18775d;
  animation: spin 0.9s linear infinite;
}
.step-status {
  margin-left: auto;
  font-size: 0.78rem;
  color: #1d5a47;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.step-body {
  padding: 0 0.9rem 0.75rem 1.6rem;
}
.step-summary {
  margin: 0.2rem 0 0.35rem 0;
  color: #27414e;
  font-size: 0.9rem;
}
.step-substeps {
  margin: 0;
  padding-left: 1rem;
  color: #324550;
  font-size: 0.86rem;
  max-height: 180px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #a5b8ae transparent;
}
.step-substeps::-webkit-scrollbar {
  width: 6px;
}
.step-substeps::-webkit-scrollbar-track {
  background: transparent;
}
.step-substeps::-webkit-scrollbar-thumb {
  background: #a5b8ae;
  border-radius: 999px;
}
.workflow-step.completed .spinner {
  animation: none;
  border-color: #2f8a53;
  background: #2f8a53;
}
.markdown-view {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem;
  background: #fbfcf7;
  max-height: 380px;
  overflow: auto;
}
.markdown-view h1, .markdown-view h2, .markdown-view h3 {
  margin: 0.7rem 0 0.4rem 0;
}
.hidden {
  display: none;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.tooltip-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 0.25rem;
  border-radius: 50%;
  background: #e7ecf2;
  color: #2a4055;
  font-size: 0.75rem;
  font-weight: 700;
  position: relative;
  cursor: help;
}
.tooltip {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 125%;
  width: min(420px, 80vw);
  background: #17232f;
  color: #f3f8ff;
  font-size: 0.77rem;
  line-height: 1.35;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  opacity: 0;
  visibility: hidden;
  transition: all 120ms ease;
  z-index: 20;
}
.tooltip-wrap:hover .tooltip {
  opacity: 1;
  visibility: visible;
}

.drop-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}
.dropzone {
  position: relative;
  border: 2px dashed #9db8ac;
  border-radius: 12px;
  background: linear-gradient(160deg, #fbfef9, #f0f7f4);
  padding: 0.95rem;
  min-height: 148px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.dropzone:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.dropzone.drag-active {
  border-color: var(--accent);
  background: linear-gradient(160deg, #f1fbf7, #e6f4ef);
}
.dropzone.has-file {
  border-color: #2a8758;
  background: linear-gradient(160deg, #eefcf4, #e5f8ed);
}
.dropzone input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.drop-title {
  font-size: 0.97rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.drop-hint {
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.35;
}
.file-name {
  margin-top: 0.55rem;
  font-size: 0.82rem;
  color: #1e5d4b;
  word-break: break-word;
}
.upload-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  background: #f7faf6;
}
.upload-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}
.upload-bar-shell {
  width: 100%;
  height: 11px;
  border-radius: 999px;
  background: #e5ebe1;
  overflow: hidden;
}
.upload-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #2a7e68, #68b49e);
  transition: width 120ms ease;
}
.upload-error {
  color: #8a1f1f;
  margin: 0.45rem 0 0 0;
  font-size: 0.84rem;
}
@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
  .drop-grid { grid-template-columns: 1fr; }
  .event-row { grid-template-columns: 1fr; }
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
}
