:root {
  --ink: #102027;
  --ink-soft: #395058;
  --paper: #f7fbfd;
  --accent: #177e89;
  --accent-strong: #0f5f68;
  --alert: #b83b3b;
  --ok: #2f855a;
  --line: #d0e2e9;
  --card: rgba(255, 255, 255, 0.9);
  --shadow: 0 14px 36px rgba(7, 37, 56, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, #eff8ff, #f7fbfd 42%, #eef6f6 100%);
}

body {
  position: relative;
  padding: 1.2rem;
}

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

.bg-shape-a {
  width: 40vw;
  height: 40vw;
  background: linear-gradient(135deg, #8ed1dc, #f4f9e9);
  top: -8vw;
  left: -8vw;
}

.bg-shape-b {
  width: 32vw;
  height: 32vw;
  background: linear-gradient(135deg, #f8d5a3, #f9efe1);
  bottom: -10vw;
  right: -6vw;
}

h1,
h2,
h3 {
  margin: 0;
}

p {
  margin: 0;
}

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

.topbar h1 {
  font-size: clamp(1.35rem, 2.4vw, 2.05rem);
  letter-spacing: 0.02em;
}

.subtitle {
  color: var(--ink-soft);
  margin-top: 0.2rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.auth-status {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.view-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.nav-button {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 0.55rem 0.9rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.nav-button:hover {
  transform: translateY(-1px);
  border-color: #98c3cf;
}

.nav-button.active {
  background: linear-gradient(135deg, #ddf0f4, #ffffff);
  border-color: #87b9c8;
}

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

.view {
  display: none;
  animation: reveal 220ms ease;
}

.view.active {
  display: block;
}

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

.card {
  background: var(--card);
  border: 1px solid #dcecf2;
  border-radius: 1.1rem;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
  margin-bottom: 0.9rem;
}

.editor-column {
  display: grid;
  gap: 0.9rem;
  align-content: start;
}

.points-panel {
  gap: 0.5rem;
}

.panel-form {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.8rem;
  background: #fff;
  display: grid;
  gap: 0.6rem;
  align-content: start;
}

.panel-form h3 {
  font-size: 1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  align-content: start;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid #c6dbe3;
  border-radius: 0.62rem;
  padding: 0.5rem 0.6rem;
  color: var(--ink);
  background: #fdfefe;
  min-height: 2.35rem;
  align-self: start;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #bddce6;
  border-color: #8db8c4;
}

textarea {
  font-family: "IBM Plex Mono", monospace;
  resize: vertical;
}

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

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

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
}

.primary-button,
.ghost-button,
.mini-button {
  border-radius: 0.62rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  padding: 0.52rem 0.86rem;
  font-weight: 650;
}

.primary-button.accent {
  background: linear-gradient(135deg, #ca6a2c, #a94d13);
}

.ghost-button {
  background: #fff;
  border-color: #c5d8e1;
  color: var(--ink);
  padding: 0.5rem 0.82rem;
}

.mini-button {
  background: #fff;
  border-color: #c5d8e1;
  color: var(--ink);
  padding: 0.34rem 0.54rem;
  font-size: 0.84rem;
}

.mini-button.accent {
  background: #eff8f9;
  border-color: #a3cfd8;
}

.primary-button:hover,
.ghost-button:hover,
.mini-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.table-wrap {
  overflow-x: auto;
}

.points-grid {
  border: 1px solid #cde1e8;
  border-radius: 0.85rem;
  overflow: hidden;
  margin-bottom: 0.45rem;
}

.points-hint {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin: 0;
}

.points-chart-wrap {
  border: 1px solid #d9e8ee;
  border-radius: 0.72rem;
  background: #fdfefe;
  padding: 0.5rem;
  height: 440px;
}

.points-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.row-action-menu {
  position: fixed;
  z-index: 80;
  min-width: 150px;
  background: #fff;
  border: 1px solid #cde1e8;
  border-radius: 0.62rem;
  box-shadow: 0 10px 24px rgba(7, 37, 56, 0.18);
  padding: 0.3rem;
  display: grid;
  gap: 0.2rem;
}

.row-action-menu button {
  border: 1px solid transparent;
  background: #fff;
  color: var(--ink);
  text-align: left;
  padding: 0.38rem 0.52rem;
  border-radius: 0.44rem;
  cursor: pointer;
}

.row-action-menu button:hover {
  background: #eef6f9;
  border-color: #d4e6ec;
}

.row-handle-button {
  border: 1px solid #c8dce4;
  border-radius: 0.5rem;
  background: #fff;
  color: var(--ink-soft);
  line-height: 1;
  width: 2rem;
  height: 1.65rem;
  cursor: pointer;
}

.row-handle-button:hover {
  background: #eef7fa;
  border-color: #adcdd8;
}

.points-grid .tabulator {
  border: none;
  font-size: 0.88rem;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background: #fff;
}

.points-grid .tabulator-header {
  border-bottom: 1px solid #d5e7ed;
  background: #f7fcfe;
}

.points-grid .tabulator-col {
  background: #f7fcfe;
}

.points-grid .tabulator-row {
  min-height: 2.25rem;
}

.points-grid .tabulator-row .tabulator-cell {
  border-right: 1px solid #eef5f8;
}

.points-grid .tabulator-cell:last-child {
  border-right: none;
}

.points-grid .tabulator-editing input {
  min-height: 1.8rem;
  padding: 0.25rem 0.45rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid #dfedf1;
  text-align: left;
  padding: 0.55rem;
  font-size: 0.88rem;
}

.data-table th {
  color: var(--ink-soft);
  font-weight: 600;
}

.meta-strip {
  border: 1px dashed #bfdae2;
  border-radius: 0.7rem;
  background: #f8fcfd;
  padding: 0.56rem 0.72rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.81rem;
  margin-bottom: 0.9rem;
}

.validation-panel {
  border-radius: 0.8rem;
  padding: 0.65rem 0.78rem;
  font-size: 0.88rem;
  border: 1px solid transparent;
  background: #f7fafb;
  margin-bottom: 0.9rem;
}

.validation-panel.neutral {
  border-color: #d7e8ee;
}

.validation-panel.valid {
  border-color: #b7e3cc;
  background: #f2fbf6;
  color: #1f5138;
}

.validation-panel.invalid {
  border-color: #f1c1c1;
  background: #fff5f5;
  color: #7a2222;
  display: grid;
  gap: 0.3rem;
}

.validation-hint {
  color: #7f4b1f;
  font-size: 0.8rem;
  margin-top: 0.18rem;
}

.version-compare-summary {
  border: 1px solid #d7e8ee;
  border-radius: 0.7rem;
  background: #f8fcfd;
  padding: 0.55rem 0.65rem;
  font-size: 0.84rem;
  color: var(--ink-soft);
  display: grid;
  gap: 0.3rem;
}

.status-badge {
  display: inline-block;
  width: fit-content;
  border-radius: 999px;
  padding: 0.36rem 0.72rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-badge.neutral {
  background: #edf3f6;
  color: #44606b;
}

.status-badge.progress {
  background: #e0f3f7;
  color: #155463;
}

.status-badge.ok {
  background: #e4f5ec;
  color: #1e5c3d;
}

.status-badge.error {
  background: #fce9e9;
  color: #8e2a2a;
}

.run-progress-wrap {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.35rem;
}

.rmse-callout {
  border: 1px solid #d8e7ec;
  border-radius: 0.72rem;
  background: #f6fbfd;
  padding: 0.55rem 0.65rem;
  display: grid;
  gap: 0.22rem;
}

.rmse-callout.ready {
  border-color: #98c4d0;
  background: #eef8fc;
}

.rmse-callout-label {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.rmse-callout-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  letter-spacing: 0.01em;
  color: #0e415f;
}

.run-progress-bar {
  width: 100%;
  height: 0.9rem;
  appearance: none;
}

.run-progress-bar::-webkit-progress-bar {
  background-color: #e4f0f4;
  border-radius: 999px;
}

.run-progress-bar::-webkit-progress-value {
  background: linear-gradient(90deg, #177e89, #0f5f68);
  border-radius: 999px;
}

.run-progress-bar::-moz-progress-bar {
  background: linear-gradient(90deg, #177e89, #0f5f68);
  border-radius: 999px;
}

.run-progress-text {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-family: "IBM Plex Mono", monospace;
}

.hidden {
  display: none !important;
}

.error-box {
  margin-top: 0.7rem;
  white-space: pre-wrap;
  background: #fff4f4;
  border: 1px solid #e7baba;
  color: #842c2c;
  border-radius: 0.62rem;
  padding: 0.55rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.79rem;
}

.summary-grid {
  display: grid;
  gap: 0.45rem;
}

.summary-item {
  border: 1px solid #d9eaef;
  border-radius: 0.65rem;
  padding: 0.45rem 0.6rem;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}

.summary-item span {
  color: var(--ink-soft);
}

.summary-empty {
  color: var(--ink-soft);
}

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

.artifacts-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.artifacts-toggle-chevron {
  font-size: 0.92rem;
}

.artifact-list li {
  border: 1px solid #d8e7ec;
  border-radius: 0.7rem;
  padding: 0.52rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.artifact-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.run-plots-panel {
  margin-top: 0.3rem;
}

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

.plot-box {
  border: 1px solid #d8e7ec;
  border-radius: 0.7rem;
  background: #fff;
  min-height: 320px;
  padding: 0.2rem;
}

.plot-box-wide {
  grid-column: 1 / -1;
  min-height: 440px;
}

.plot-empty {
  min-height: 300px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-size: 0.86rem;
  text-align: center;
  padding: 0.8rem;
}

.auth-gate {
  position: fixed;
  inset: 0;
  background: rgba(10, 34, 42, 0.44);
  display: grid;
  place-items: center;
  padding: 1rem;
  backdrop-filter: blur(3px);
}

.auth-card {
  width: min(920px, 96vw);
  background: #fff;
  border: 1px solid #d3e4ea;
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 1rem;
  display: grid;
  gap: 0.9rem;
}

.auth-helper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-start;
}

.auth-helper-modal-card {
  width: min(720px, 96vw);
}

.auth-helper-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.validation-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 34, 42, 0.44);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 70;
}

.validation-modal-card {
  width: min(760px, 96vw);
  background: #fff;
  border: 1px solid #d3e4ea;
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.validation-modal-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.35rem;
  color: #7a2222;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  max-width: 460px;
  border-radius: 0.75rem;
  padding: 0.62rem 0.78rem;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}

.toast.success {
  background: #1f8154;
}

.toast.error {
  background: #a83a3a;
}

.toast.neutral {
  background: #33606b;
}

@media (max-width: 980px) {
  body {
    padding: 0.8rem;
  }

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

  .inline-fields,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .run-plots-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-card {
    width: min(640px, 96vw);
  }
}
