*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

:root {
  --base: #1a1a1d;
  --mantle: #1f1f22;
  --surface0: #252528;
  --surface1: #323236;
  --surface2: #3f3f45;
  --text: #e8e8ea;
  --subtext0: #a6a6ac;
  --subtext1: #76767c;
  --blue: #8aa6cf;
  --teal: #94e2d5;
  --green: #a6e3a1;
  --mauve: #cba6f7;
  --peach: #fab387;
  --danger: #f38ba8;
  --radius: 6px;
  --mono: "JetBrains Mono", monospace;
  --sans: "Space Grotesk", sans-serif;
}

html, body {
  background: var(--base);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: color-mix(in srgb, var(--blue) 35%, transparent); }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 64px 40px 96px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 24px;
  margin-bottom: 44px;
}

.title {
  color: var(--text);
  font-family: var(--sans);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0;
}

.title span { color: var(--blue); }

.subtitle {
  color: var(--subtext1);
  font-size: 13px;
  margin-top: 4px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 40px;
  align-items: start;
}

@media (max-width: 860px) {
  .wrap { padding: 40px 22px 72px; }
  .top { align-items: stretch; flex-direction: column; }
  .grid { grid-template-columns: 1fr; }
  .results { position: static !important; }
}

.group { margin-bottom: 28px; }

.group.last { margin-bottom: 0; }

.group-head {
  color: var(--subtext1);
  font-size: 11px;
  letter-spacing: 0.12em;
  margin-bottom: 14px;
  text-transform: uppercase;
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field.narrow { max-width: 150px; }

.field label {
  color: var(--subtext0);
  font-size: 12px;
}

.field input,
.field select {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
  padding: 11px 13px;
  transition: border-color 0.12s, background 0.12s;
  width: 100%;
}

.field input::placeholder { color: var(--subtext1); }
.field input:hover, .field select:hover { border-color: var(--surface2); }
.field input:focus, .field select:focus { border-color: var(--blue); background: var(--mantle); }

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2376767c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
  cursor: pointer;
  padding-right: 34px;
}

.seg {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: var(--radius);
  display: inline-flex;
  gap: 3px;
  margin-bottom: 16px;
  padding: 3px;
}

.seg button {
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--subtext0);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 18px;
  transition: background 0.12s, color 0.12s;
}

.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface2); color: var(--text); }

details.advanced {
  border-top: 1px solid var(--surface1);
  margin-top: 4px;
  padding-top: 22px;
}

details.advanced > summary,
details.breakdown > summary {
  align-items: center;
  color: var(--subtext0);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  gap: 8px;
  list-style: none;
  transition: color 0.12s;
  user-select: none;
}

details.advanced > summary:hover,
details.breakdown > summary:hover { color: var(--text); }

details.advanced > summary::-webkit-details-marker,
details.breakdown > summary::-webkit-details-marker { display: none; }

details.advanced > summary svg { transition: transform 0.18s ease; }
details.advanced[open] > summary svg { transform: rotate(90deg); }
details.advanced .group { margin-top: 24px; margin-bottom: 24px; }
details.advanced .group:last-of-type { margin-bottom: 0; }

.opts {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.opt {
  align-items: center;
  color: var(--subtext0);
  cursor: pointer;
  display: flex;
  font-size: 13px;
  gap: 10px;
  width: fit-content;
}

.opt input {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.check {
  background: var(--surface0);
  border: 1px solid var(--surface2);
  border-radius: 4px;
  display: grid;
  flex-shrink: 0;
  height: 16px;
  place-items: center;
  transition: background 0.12s, border-color 0.12s;
  width: 16px;
}

.check svg { opacity: 0; transition: opacity 0.1s; }
.opt input:checked + .check { background: var(--blue); border-color: var(--blue); }
.opt input:checked + .check svg { opacity: 1; }
.opt:hover .check { border-color: var(--blue); }
.opt:hover { color: var(--text); }

.run,
.ghost {
  align-items: center;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--mono);
  justify-content: center;
  transition: opacity 0.12s, transform 0.08s, border-color 0.12s, color 0.12s;
}

.run {
  background: var(--blue);
  border: none;
  color: #0d0d14;
  font-size: 14px;
  font-weight: 600;
  gap: 9px;
  margin-top: 32px;
  padding: 13px;
  width: 100%;
}

.run:hover { opacity: 0.88; }
.run:active { transform: scale(0.985); }
.run:disabled { cursor: wait; opacity: 0.55; }

.ghost {
  background: transparent;
  border: 1px solid var(--surface1);
  color: var(--subtext0);
  font-size: 12px;
  padding: 9px 12px;
  white-space: nowrap;
}

.ghost:hover { border-color: var(--surface2); color: var(--text); }

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 40px;
}

.metric {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 10px;
  padding: 18px 20px;
}

.metric.muted { opacity: 0.45; }

.box-label {
  color: var(--subtext1);
  font-size: 11px;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.box-value {
  color: var(--text);
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.1;
  overflow-wrap: anywhere;
  transition: color 0.2s;
}

.box-value .unit,
.box-value small {
  color: var(--subtext0);
  font-size: 15px;
  font-weight: 400;
}

.stamp {
  color: var(--subtext1);
  font-size: 11px;
  margin-top: 2px;
  min-height: 16px;
  text-align: center;
}

.running .box-value { color: var(--subtext1); }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request .last-run { display: none; }

.alert {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface0));
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--surface1));
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 13px 14px;
}

details.breakdown {
  border-top: 1px solid var(--surface1);
  margin-top: 8px;
  padding-top: 14px;
}

details.breakdown pre {
  background: var(--mantle);
  border: 1px solid var(--surface1);
  border-radius: var(--radius);
  color: var(--subtext0);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  margin-top: 12px;
  max-height: 460px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  padding: 40px 20px;
  place-items: center;
}

.auth-card {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 10px;
  max-width: 380px;
  padding: 28px;
  width: 100%;
}

.auth-card .subtitle { margin-bottom: 28px; }
.auth-card .alert { margin-bottom: 18px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .run { margin-top: 4px; }
