@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --bg: #f7f2ea;
  --bg-alt: #f3e7d3;
  --panel: #fffdf7;
  --ink: #1f1d1a;
  --muted: #6c5f55;
  --accent: #d45d3d;
  --accent-2: #3f7c6b;
  --border: #e5d7c7;
  --shadow: 0 18px 45px rgba(31, 29, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(212, 93, 61, 0.12), transparent 55%),
    radial-gradient(circle at 90% 10%, rgba(63, 124, 107, 0.18), transparent 50%),
    linear-gradient(180deg, var(--bg), var(--bg-alt));
  min-height: 100vh;
}

.app {
  width: 100%;
  margin: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  display: flex;
  gap: 32px;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(212, 93, 61, 0.12), rgba(63, 124, 107, 0.08));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 32px;
  box-shadow: var(--shadow);
  animation: floatIn 0.6s ease-out;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-2);
  margin: 0 0 6px;
}

.hero h1 {
  font-size: 32px;
  margin: 0 0 8px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
}

.image-info {
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px dashed rgba(63, 124, 107, 0.3);
  color: var(--muted);
  min-width: 180px;
  text-align: right;
}

.image-info-text {
  font-size: 14px;
}

.hero-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(63, 124, 107, 0.12);
  color: var(--accent-2);
}

.status-pill.warn {
  background: rgba(212, 93, 61, 0.18);
  color: var(--accent);
}

.status-pill.error {
  background: rgba(220, 38, 38, 0.16);
  color: #b91c1c;
}

.status-pill.success {
  background: rgba(63, 124, 107, 0.2);
  color: var(--accent-2);
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  animation: floatIn 0.6s ease-out;
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 12px;
}

.section {
  margin-top: 20px;
}

.section h3 {
  margin: 0 0 10px;
}

.label-add {
  display: flex;
  gap: 8px;
  align-items: center;
}

.label-add input {
  flex: 1;
}

.label-add .btn {
  white-space: nowrap;
}

label,
input,
select,
button {
  font-family: inherit;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 14px;
}

input[type="checkbox"] {
  width: auto;
  padding: 0;
  border-radius: 4px;
}

select {
  margin-top: 8px;
}

.tag-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.7);
}

.tag-list-inline {
  flex-direction: row;
  flex-wrap: wrap;
  max-height: none;
  overflow-y: visible;
  border-style: solid;
}

.tag-list-inline .tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(63, 124, 107, 0.14);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.tag-remove {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  padding: 0 2px;
}

.tag-remove:hover {
  color: #d45d3d;
}

.stats-block {
  display: grid;
  gap: 12px;
}

.stats-group h4 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.7);
}

.config-list,
.detections-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.7);
  max-height: 240px;
  overflow-y: auto;
}

.config-row,
.detection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.config-value,
.detection-score {
  font-weight: 600;
  color: var(--ink);
  background: rgba(63, 124, 107, 0.12);
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.detection-score {
  background: rgba(212, 93, 61, 0.14);
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.stat-count {
  font-weight: 600;
  color: var(--ink);
  background: rgba(212, 93, 61, 0.14);
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.tag-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.tag-item input {
  margin: 0;
}

.tag-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.tag-item .btn.tiny {
  padding: 6px 10px;
  font-size: 12px;
  margin-left: auto;
}

.canvas-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.image-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.counter {
  font-weight: 600;
  color: var(--muted);
}

.canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.6), rgba(243, 231, 211, 0.8)),
    repeating-linear-gradient(
      45deg,
      rgba(31, 29, 26, 0.04) 0,
      rgba(31, 29, 26, 0.04) 10px,
      transparent 10px,
      transparent 20px
    );
  border-radius: 18px;
  border: 1px solid var(--border);
  min-height: 360px;
  padding: 16px;
  overflow: auto;
}

canvas {
  border-radius: 14px;
  box-shadow: 0 16px 30px rgba(31, 29, 26, 0.16);
}

.empty-state {
  position: absolute;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
}

.hidden {
  display: none;
}

.box-actions {
  display: flex;
  justify-content: flex-end;
}

.boxes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.box-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(63, 124, 107, 0.08);
  font-size: 13px;
  color: var(--muted);
}

.box-row span {
  flex: 1;
}

.box-row select {
  min-width: 140px;
}

.box-row .btn {
  padding: 6px 10px;
  font-size: 12px;
}

.save-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand {
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.topbar-user {
  font-size: 13px;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.dashboard-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.dashboard-tile h3 {
  margin: 0;
}

.save-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.split-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.train-config {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
}

.train-config h3 {
  margin-bottom: 12px;
}

.train-inputs {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.train-options {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  min-width: 220px;
}

.train-options .hint {
  margin-top: 0;
}

.split-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 12px;
  flex: 1;
}

.confidence-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.confidence-row input[type="range"] {
  flex: 1;
}

.confidence-row input[type="number"] {
  width: 90px;
}

.split-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.save-status {
  color: var(--muted);
  font-size: 14px;
}

.split-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.split-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.scenario-label {
  margin-bottom: 8px;
}

.scenario-grid .split-row {
  grid-template-columns: minmax(200px, 220px) minmax(320px, 1fr) 140px;
}

.scenario-create {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.scenario-create input {
  flex: 1;
  min-width: 200px;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top, rgba(79, 124, 90, 0.15), transparent 55%),
    linear-gradient(120deg, rgba(244, 234, 214, 0.8), rgba(252, 246, 235, 0.9));
}

.auth-card {
  width: min(420px, 92vw);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-error {
  color: #b91c1c;
  font-size: 13px;
}

.splits-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.models-section {
  margin-top: 32px;
}

.split-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 180px 120px 140px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
}

.split-row.header {
  background: transparent;
  border: none;
  padding: 0 14px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.split-cell {
  overflow-wrap: anywhere;
}

.split-action-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background: #0f172a;
  color: #f8fafc;
  padding: 24px;
  width: min(520px, 92vw);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-card h3 {
  margin: 0;
}

.modal-details {
  font-size: 14px;
  color: #cbd5f5;
  display: grid;
  gap: 6px;
}

.modal-metrics {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.modal-metrics .label {
  display: block;
  font-size: 12px;
  color: #94a3b8;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.split-status {
  font-size: 12px;
  color: var(--muted);
}

.split-status.running {
  color: var(--accent);
}

.split-status.completed {
  color: var(--accent-2);
}

.split-status.failed {
  color: #a33a2b;
}

.split-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.split-empty {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed var(--border);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  border: none;
  padding: 10px 16px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  background: var(--accent-2);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(63, 124, 107, 0.22);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.jump-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jump-controls input {
  width: 90px;
}

.btn.primary {
  background: var(--accent);
}

.btn.danger {
  background: #e11d48;
}

.btn.danger:hover {
  box-shadow: 0 8px 18px rgba(225, 29, 72, 0.25);
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 0.92em;
}

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

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

  .image-info {
    text-align: left;
    width: 100%;
  }
}

@media (max-width: 720px) {
  .train-inputs {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .split-row {
    grid-template-columns: 1fr;
  }
}
