:root {
  --bg: #f3efe8;
  --paper: #fffdf9;
  --ink: #1b1b1d;
  --muted: #5f646f;
  --accent: #e4572e;
  --accent-2: #0b7a75;
  --line: #d7d2c8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 20%, #f8f4ed 0%, var(--bg) 45%, #e5dfd5 100%);
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(2px);
  z-index: -1;
  opacity: 0.45;
}

.bg-shape-a {
  top: -120px;
  right: -50px;
  width: 320px;
  height: 320px;
  background: #ffd9b8;
}

.bg-shape-b {
  bottom: -90px;
  left: -40px;
  width: 280px;
  height: 280px;
  background: #cbe7d9;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.3rem;
}

.logo {
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.2rem;
}

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

.user-label {
  color: var(--muted);
  font-size: 0.95rem;
}

.link-btn {
  background: linear-gradient(120deg, var(--accent-2), #189e96);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  font-weight: 600;
}

.content-shell {
  width: min(1360px, calc(100% - 2rem));
  margin: 0 auto 2rem;
  animation: rise 0.45s ease-out;
}

.content-shell > .card + .card {
  margin-top: 0.9rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem;
  box-shadow: 0 8px 28px rgba(43, 33, 24, 0.08);
}

.login-card {
  max-width: 420px;
  margin: 10vh auto 0;
}

.stacked-form {
  display: grid;
  gap: 0.55rem;
}

input,
button {
  font: inherit;
}

input {
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

button {
  margin-top: 0.3rem;
  background: linear-gradient(120deg, var(--accent), #f18d3a);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 0.68rem 1rem;
  cursor: pointer;
  font-weight: 600;
}

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

.error-box {
  background: #ffe6e0;
  color: #8d2312;
  border: 1px solid #ffb6a7;
  border-radius: 10px;
  padding: 0.6rem;
}

.project-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.project-list a {
  color: var(--accent-2);
  font-weight: 700;
  text-decoration: none;
}

.project-list li {
  display: grid;
  gap: 0.55rem;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.55rem;
}

.row-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.project-label-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.access-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #f6f3ec;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.inline-delete-form {
  margin: 0;
}

.inline-form input {
  min-width: 150px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  padding: 0;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  color: #fff;
}

.editable-row {
  align-items: start;
}

.row-editor {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.row-editor input {
  min-width: 220px;
}

.row-editor input,
.row-editor .btn-secondary,
.row-editor .btn-cancel {
  height: 42px;
  margin-top: 0;
}

.row-editor .btn-secondary,
.row-editor .btn-cancel {
  padding-top: 0;
  padding-bottom: 0;
}

.hidden {
  display: none;
}

.btn-cancel {
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 0.5rem 0.75rem;
}

.btn-secondary {
  background: linear-gradient(120deg, var(--accent-2), #189e96);
}

.btn-danger {
  background: linear-gradient(120deg, #b42318, #d92d20);
}

.btn-download {
  background: linear-gradient(120deg, #1d6dbf, #2e86de);
}

.btn-secondary:not(.icon-btn),
.btn-download:not(.icon-btn) {
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 0.68rem 1rem;
  margin-top: 0.3rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.run-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.import-form input[type="file"] {
  padding: 0.55rem 0.65rem;
  cursor: pointer;
}

.title-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
}

.token-chip {
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: #fff;
}

.copy-token-btn {
  margin-top: 0;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  line-height: 1;
}

.collapsible-info {
  margin-top: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0.5rem 0.75rem;
}

.collapsible-info summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}

.collapsible-info[open] summary {
  margin-bottom: 0.55rem;
}

.collapsible-info p {
  margin: 0.35rem 0;
}

/* ── Compare page ─────────────────────────────────────────── */
.section-toolbar {
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.section-toolbar a {
  text-decoration: none;
  display: inline-flex;
}
.compare-run-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1rem;
}

.compare-run-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.compare-run-item:has(input:checked) {
  border-color: var(--accent);
  background: rgba(52, 152, 219, 0.1);
}

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

.token-line {
  overflow-wrap: anywhere;
}

.run-meta-card {
  padding-left: 1.4rem;
  padding-right: 1.4rem;
}

.run-meta-card h2 {
  text-align: left;
}

.meta-table-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.meta-table-grid-desktop {
  display: none;
}

.meta-table-single {
  display: table;
}

.meta-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.meta-table th,
.meta-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0.65rem 0.75rem;
  vertical-align: top;
}

.meta-table th:last-child,
.meta-table td:last-child {
  border-right: 0;
}

.meta-table tbody tr:last-child td {
  border-bottom: 0;
}

.meta-table th {
  font-size: 0.9rem;
  color: var(--muted);
  background: #faf8f3;
}

.meta-table td {
  overflow-wrap: anywhere;
}

.meta-empty {
  color: transparent;
}

@media (min-width: 1120px) {
  .meta-table-grid-desktop {
    display: grid;
  }

  .meta-table-single {
    display: none;
  }
}

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

.chart-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem;
  background: #fff;
  min-height: 340px;
}

.chart-card h3 {
  margin: 0 0 0.8rem;
}

.chart-card canvas {
  width: 100% !important;
  height: 280px !important;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.scale-select {
  min-width: 140px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0 0.65rem;
  font: inherit;
}

@media (max-width: 600px) {
  .topbar {
    padding: 0.8rem;
  }

  .content-shell {
    width: calc(100% - 1rem);
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .project-list li {
    flex-direction: column;
    align-items: flex-start;
  }

  .row-main {
    width: 100%;
  }

  .row-editor {
    width: 100%;
    flex-wrap: wrap;
  }

  .row-editor input {
    width: 100%;
    min-width: 0;
  }
}
