:root {
  --ink: #0e1b2b;
  --muted: #6f7c8f;
  --line: #e3e7ee;
  --card: #ffffff;
  --accent: #0b2a6f;
  --accent-soft: #d7e4ff;
  --accent-strong: #081f57;
  --shadow: 0 24px 60px rgba(10, 22, 50, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Avenir", "Helvetica Neue", "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f4f6fb;
  min-height: 100vh;
}

.page-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(207, 222, 255, 0.9), transparent 55%),
    radial-gradient(circle at 90% 0%, rgba(252, 237, 217, 0.7), transparent 40%),
    linear-gradient(180deg, #f7f8fb 0%, #eff3f9 100%);
  z-index: -1;
}

h1, h2, h3 {
  font-family: "Iowan Old Style", "Palatino", "Georgia", serif;
  margin: 0 0 0.4rem;
}

h1 {
  font-size: 2.4rem;
}

h2 {
  font-size: 1.4rem;
}

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

.main {
  padding: 2rem 4vw 4rem;
  max-width: 1240px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 4vw;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

.topnav {
  display: flex;
  gap: 1.4rem;
  font-weight: 600;
}

.nav-link {
  color: var(--ink);
  padding: 0.4rem 0.2rem;
  border-bottom: 2px solid transparent;
}

.nav-link:hover {
  border-bottom: 2px solid var(--accent);
}

.account {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.account-email {
  font-size: 0.9rem;
  color: var(--muted);
}

.account-email:hover {
  color: var(--accent);
  text-decoration: underline;
}

.flash-wrap {
  max-width: 1240px;
  margin: 1rem auto 0;
  padding: 0 4vw;
}

.flash {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  margin-bottom: 0.6rem;
  background: #fff;
  border: 1px solid var(--line);
}

.flash.success {
  border-color: #b1d6b1;
  background: #eef7ee;
}

.flash.error {
  border-color: #f2b7b7;
  background: #fcecec;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.6rem;
}

.warning-banner {
  margin-bottom: 1.2rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid #e3a5aa;
  background: #fde8ea;
  color: #6a1118;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.back-link {
  font-size: 0.9rem;
  color: var(--muted);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.status-pill {
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 30, 60, 0.06);
}

.inner-card {
  background: #f6f8fc;
  border-radius: 14px;
  padding: 1.2rem;
  margin-top: 1rem;
  border: 1px dashed #d6ddea;
}

.table-card {
  padding: 0.6rem;
}

.table {
  display: grid;
  gap: 0.4rem;
}

.table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 0.6fr;
  gap: 1rem;
  align-items: center;
  padding: 0.8rem 1rem;
  border-radius: 12px;
}

.runs-table .table-row {
  grid-template-columns: 2fr 1fr 1.1fr 0.8fr 1fr 0.6fr;
}

.table-row.table-header {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
}

.table-row:not(.table-header) {
  background: #f9fafc;
  border: 1px solid #eef1f6;
}

.table-row.run-row {
  cursor: pointer;
}

.table-row.run-row:not(.table-header):hover {
  background: #f3f6fb;
  border-color: #dbe4f2;
}

.table-row.run-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.table-row.empty {
  justify-content: center;
  color: var(--muted);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}

.dataset-card-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

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

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

.unseen-badge {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0b2a6f;
  background: #d7e4ff;
  border: 1px solid #b8cbf5;
  vertical-align: middle;
}

.strong {
  font-weight: 700;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.button.compact {
  padding: 0.38rem 0.75rem;
  font-size: 0.78rem;
}

.button.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(11, 42, 111, 0.2);
}

.button.ghost {
  background: #f2f4f9;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.ghost.danger {
  background: #fff2f3;
  color: #8d1b25;
  border-color: #e3a5aa;
}

.button.danger {
  background: #8d1b25;
  color: #fff;
  box-shadow: 0 10px 20px rgba(141, 27, 37, 0.2);
}

.button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.icon-button.danger {
  border-color: #e3a5aa;
  color: #8d1b25;
}

.inline-form {
  margin: 0;
}

.search input {
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  min-width: 220px;
}

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

.form-card {
  display: grid;
  gap: 1.4rem;
}

.field {
  display: grid;
  gap: 0.5rem;
  font-weight: 600;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.field input,
.field select,
.field textarea,
select,
textarea {
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  font: inherit;
  background: #fff;
}

textarea {
  resize: vertical;
}

.toggle-row {
  display: flex;
  gap: 1rem;
  margin: 0.8rem 0;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: #f4f6fb;
  border: 1px solid var(--line);
  font-weight: 600;
}

.toggle input {
  accent-color: var(--accent);
}

.upload-zone {
  border: 2px dashed #9db2d9;
  background: #f0f4ff;
  border-radius: 18px;
  padding: 2rem;
  text-align: center;
  position: relative;
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-title {
  font-weight: 700;
}

.selected-files {
  margin-top: 0.8rem;
  font-size: 0.9rem;
}

.selected-files ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

.prompt-row select,
.prompt-box {
  width: 100%;
}

.prompt-box {
  display: block;
  font-family: "Iowan Old Style", "Palatino", "Georgia", serif;
  font-size: 0.95rem;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
  gap: 1rem;
}

.stack {
  display: grid;
  gap: 1.6rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.4rem;
  margin-bottom: 1.4rem;
}

.run-context {
  margin-bottom: 1.4rem;
}

.multiline-text {
  white-space: pre-wrap;
}

.markdown-report {
  line-height: 1.5;
}

.markdown-report > :first-child {
  margin-top: 0;
}

.markdown-report > :last-child {
  margin-bottom: 0;
}

.markdown-report h1,
.markdown-report h2,
.markdown-report h3,
.markdown-report h4 {
  margin: 1rem 0 0.5rem;
  font-size: 1.05rem;
}

.markdown-report p,
.markdown-report ul,
.markdown-report ol,
.markdown-report blockquote,
.markdown-report pre,
.markdown-report table {
  margin: 0.6rem 0;
}

.markdown-report pre,
.markdown-report code {
  font-family: "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
}

.markdown-report pre {
  background: #f7f9fd;
  border: 1px solid #e2e8f4;
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  overflow-x: auto;
}

.markdown-report table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-report th,
.markdown-report td {
  border: 1px solid #e5ebf5;
  padding: 0.35rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

.markdown-report blockquote {
  border-left: 3px solid #d4dced;
  margin-left: 0;
  padding: 0.1rem 0 0.1rem 0.8rem;
  color: var(--muted);
}

.stat-title {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-weight: 700;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0.2rem 0 0.4rem;
}

.stat-value.fit-text {
  font-size: clamp(0.9rem, 1.1vw, 1.2rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: #edf2ff;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 0.6rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.4rem;
}

.file-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.6rem;
  list-style: none;
  padding-left: 0;
}

.file-item {
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  background: #f4f6fb;
}

.preview-file-row {
  cursor: pointer;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.preview-file-row:hover {
  background: #eef3ff;
  box-shadow: inset 0 0 0 1px #d9e5ff;
}

.preview-file-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.file-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.file-item-head > div {
  overflow-wrap: anywhere;
}

.xlsx-preview-modal {
  width: min(96vw, 1200px);
  border: none;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 18px 45px rgba(12, 20, 40, 0.3);
}

.xlsx-preview-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.xlsx-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.preview-search-field {
  flex: 1 1 340px;
  margin: 0;
}

.preview-search-summary {
  min-height: 1.2rem;
  text-align: right;
}

.xlsx-preview-table {
  min-width: 700px;
}

.preview-search-match {
  background: #fff3bf;
}

.case-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.6rem;
}

.case-sidebar {
  position: sticky;
  top: 90px;
  height: fit-content;
}

.section-title {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 1.2rem 0;
}

.tab-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tab {
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  background: #f4f6fb;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: transparent;
}

.output-panel {
  display: none;
}

.output-panel.active {
  display: block;
}

.output-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.2rem;
}

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

.section {
  margin: 1.2rem 0;
}

.variant-table-wrap {
  overflow-x: auto;
  border: 1px solid #e5e9f1;
  border-radius: 12px;
  background: #fff;
}

.log-excerpt {
  margin: 0.8rem 0 0;
  padding: 1rem;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: 0.82rem/1.45 "SFMono-Regular", "Menlo", "Consolas", monospace;
}

.variant-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.variant-table th {
  position: sticky;
  top: 0;
  background: #f3f6fd;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: left;
  border-bottom: 1px solid #dfe5f1;
  padding: 0.45rem 0.42rem;
  white-space: nowrap;
}

.variant-table td {
  padding: 0.42rem 0.42rem;
  border-bottom: 1px solid #edf1f7;
  vertical-align: top;
  white-space: nowrap;
}

.variant-table tbody tr:nth-child(even) {
  background: #fafcff;
}

.variant-table .cell-wrap {
  white-space: normal;
  min-width: 140px;
}

.accordion {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  background: #f7f8fc;
  border-radius: 12px;
  border: 1px solid #eef1f6;
}

.accordion summary {
  cursor: pointer;
  font-weight: 600;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--line);
  background: #f4f6fb;
  cursor: pointer;
}

.pill input {
  accent-color: var(--accent);
}

.feedback-form {
  display: grid;
  gap: 0.8rem;
}

.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
}

.auth-card {
  width: min(420px, 90vw);
  background: var(--card);
  padding: 2.2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-footer {
  margin-top: 1rem;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.hidden {
  display: none;
}

.footer {
  text-align: center;
  padding: 2rem 4vw 3rem;
  color: var(--muted);
}

@media (max-width: 980px) {
  .case-grid {
    grid-template-columns: 1fr;
  }
  .case-sidebar {
    position: static;
  }
  .table-row {
    grid-template-columns: 1fr;
  }
  .runs-table .table-row {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .topnav {
    flex-wrap: wrap;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .preview-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .preview-search-summary {
    text-align: left;
  }
}
