:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffaf1;
  --ink: #171511;
  --muted: #716b60;
  --line: rgba(23, 21, 17, 0.12);
  --accent: #2457ff;
  --danger: #b42318;
  --ok: #157f48;
  --warn: #b76a00;
  --shadow: 0 22px 60px rgba(37, 31, 20, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(36, 87, 255, 0.10), transparent 34rem),
    linear-gradient(135deg, #f4f1ea, #efe7da);
  color: var(--ink);
}
button, input, textarea { font: inherit; }
button, .button {
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  background: var(--ink);
  color: white;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}
button:hover, .button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.inline { display: inline-flex; width: fit-content; }
.muted { color: var(--muted); }
.compact { margin: 0.25rem 0 0; font-size: 0.88rem; }
.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-body { display: grid; place-items: center; padding: 1.5rem; }
.login-shell { width: min(100%, 460px); }
.login-panel, .panel {
  background: rgba(255, 250, 241, 0.88);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.login-panel {
  border-radius: 2rem;
  padding: 2rem;
}
.login-panel h1 { margin: 0; font-size: clamp(2rem, 6vw, 3.4rem); letter-spacing: -0.06em; }
.login-form, .stack-form, .dialog-form { display: grid; gap: 1rem; }
label { display: grid; gap: 0.45rem; color: var(--muted); font-size: 0.9rem; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  outline: none;
}
textarea {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  resize: vertical;
}
input:focus, textarea:focus { border-color: rgba(36, 87, 255, 0.55); box-shadow: 0 0 0 4px rgba(36, 87, 255, 0.10); }
.alert {
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  margin: 1rem 0;
}
.danger { color: var(--danger); background: rgba(180, 35, 24, 0.08); }

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
  background: rgba(244, 241, 234, 0.72);
  backdrop-filter: blur(18px);
}
.sidebar h1 {
  margin: 0;
  font-size: 2.4rem;
  letter-spacing: -0.07em;
}
.tabs { display: grid; gap: 0.45rem; margin-top: 2rem; }
.tab {
  justify-content: flex-start;
  text-align: left;
  border-radius: 1rem;
  background: transparent;
  color: var(--muted);
}
.tab.active {
  background: var(--ink);
  color: white;
}
.logout { color: var(--muted); text-decoration: none; }
.workspace { padding: 2rem; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.topbar h2 { margin: 0; font-size: clamp(2rem, 4vw, 4rem); letter-spacing: -0.07em; }
.actions { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; }
.view { display: none; animation: enter 0.24s ease both; }
.view.active { display: grid; gap: 1rem; }
@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.status-strip > div { padding: 1.25rem 1rem; border-right: 1px solid var(--line); }
.status-strip > div:last-child { border-right: 0; }
.label { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 0.4rem; }
.status-strip strong { font-size: clamp(1.2rem, 2vw, 1.8rem); letter-spacing: -0.04em; }
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr); gap: 1rem; }
.panel { border-radius: 1.5rem; padding: 1.25rem; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
h3 { margin: 0 0 0.35rem; font-size: 1.25rem; letter-spacing: -0.03em; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 0.85rem 1rem; align-items: center; }
.kv span { color: var(--muted); }
.metric-list, .runs-list { display: grid; gap: 0.65rem; }
.metric-row, .run-row {
  display: grid;
  gap: 0.35rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.metric-row:last-child, .run-row:last-child { border-bottom: 0; }
.row-main { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  background: rgba(23, 21, 17, 0.08);
}
.pill.ok { color: var(--ok); background: rgba(21, 127, 72, 0.10); }
.pill.fail { color: var(--danger); background: rgba(180, 35, 24, 0.10); }
.pill.warn { color: var(--warn); background: rgba(183, 106, 0, 0.10); }
.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td {
  padding: 1rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
td .actions { justify-content: flex-end; }
.toast {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 20;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}
dialog {
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  width: min(92vw, 480px);
}
dialog::backdrop { background: rgba(23, 21, 17, 0.28); backdrop-filter: blur(4px); }
.dialog-form { padding: 1.25rem; }
.dialog-form.wide { width: min(92vw, 760px); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.7rem; }
.run-details {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 1.1rem;
    gap: 1rem;
  }
  .tabs { display: flex; overflow-x: auto; margin-top: 1rem; }
  .tab { white-space: nowrap; }
  .workspace { padding: 1rem; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .status-strip { grid-template-columns: 1fr 1fr; }
  .status-strip > div:nth-child(2n) { border-right: 0; }
  .split { grid-template-columns: 1fr; }
}

