: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);
}

.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;
}

.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);
}

.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.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[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.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 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;
}

.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;
}

.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;
}

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

.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;
}

.variant-table {
  width: 100%;
  min-width: 1160px;
  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.55rem 0.55rem;
  white-space: nowrap;
}

.variant-table td {
  padding: 0.5rem 0.55rem;
  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: 170px;
}

.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;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .topnav {
    flex-wrap: wrap;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
