:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1c2330;
  --muted: #5d6878;
  --line: #dfe3ea;
  --accent: #1f6feb;
  --ok: #1f7a3d;
  --warn: #9a6700;
  --bad: #b4232c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, "Segoe UI", Roboto, sans-serif;
}

.shell { display: flex; min-height: 100vh; }

/* --- sidebar --- */

.sidebar {
  width: 290px;
  flex: 0 0 290px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  overflow-y: auto;
}

.brand {
  display: block;
  font-weight: 650;
  font-size: 16px;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 18px;
}

.basis {
  background: #eef4ff;
  border: 1px solid #d3e0fb;
  border-radius: 8px;
  padding: 9px 11px;
  margin-bottom: 14px;
}

.basis .value {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.label {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 11px;
  color: var(--muted);
  margin: 14px 0 6px;
}

.new-run {
  display: block;
  text-align: center;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 550;
}

.runs { list-style: none; margin: 0; padding: 0; }

.runs a {
  display: block;
  padding: 9px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid transparent;
}

.runs a:hover { background: #f2f5fa; border-color: var(--line); }
.runs a.is-head { border-color: #b9d2ff; background: #f4f8ff; }
.run-time { font-weight: 600; margin-right: 6px; }
.run-id {
  display: block;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: 1px;
}

.badge-proposed { background: #fff4d6; color: var(--warn); }
.badge-accepted { background: #e2f5e8; color: var(--ok); }
.badge-rejected { background: #f2f3f5; color: var(--muted); }
.badge-current  { background: #e5efff; color: var(--accent); }

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

/* --- content --- */

.content { flex: 1; padding: 30px 36px 60px; max-width: 1100px; }

h1 { font-size: 23px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 30px 0 10px; }
.lede { color: var(--muted); margin: 0 0 22px; max-width: 62ch; }

.field { margin-bottom: 18px; max-width: 420px; }
.field label { display: block; font-weight: 550; margin-bottom: 4px; }
.field small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.field small.warn { color: var(--warn); }

input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: var(--panel);
}

button, .downloads a {
  font: inherit;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.secondary { background: var(--panel); color: var(--ink); border-color: var(--line); }

.advanced { margin: 18px 0; max-width: 620px; }
.advanced summary { cursor: pointer; color: var(--muted); }
.advanced dl { font-size: 12.5px; }
.advanced dt { font-weight: 600; margin-top: 8px; }
.advanced dd {
  margin: 0;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--muted);
  word-break: break-all;
}

.errors {
  background: #fdecec;
  border: 1px solid #f5c2c2;
  color: var(--bad);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 20px;
}
.errors p { margin: 4px 0; }

/* --- tables --- */

table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.states { max-width: 720px; border: 1px solid var(--line); border-radius: 8px; }
.states th small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.states .unit { color: var(--muted); font-weight: 400; }
.states .predicted { color: var(--muted); font-family: ui-monospace, Consolas, monospace; }

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.schedule { font-size: 13px; white-space: nowrap; }
.schedule th { background: #f2f5fa; position: sticky; top: 0; }

/* --- status --- */

.status {
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.status.running  { background: #eef4ff; border: 1px solid #d3e0fb; }
.status.failed   { background: #fdecec; border: 1px solid #f5c2c2; display: block; }
.status.proposed { background: #fff9e8; border: 1px solid #f2e0b0; }
.status.accepted { background: #e9f7ee; border: 1px solid #bfe3cd; }
.status.rejected { background: #f2f3f5; border: 1px solid var(--line); color: var(--muted); }
.status pre { white-space: pre-wrap; font-size: 12.5px; }

.actions { display: flex; gap: 8px; }
.actions form { margin: 0; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid #c7d7f5;
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.objective { color: var(--muted); max-width: 66ch; }
.downloads { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; }

.plot {
  width: 100%;
  height: 1100px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

/* --- presentation window --- */

.window {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.window label { font-weight: 550; }
.window input { width: 110px; }
.window small { flex-basis: 100%; color: var(--muted); font-size: 12.5px; }

.chip {
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
}

.chip:hover { background: #f2f5fa; }
.chip-on { background: var(--accent); color: #fff; border-color: var(--accent); }

button[disabled] {
  opacity: .45;
  cursor: not-allowed;
}

.new-run.disabled {
  color: var(--muted);
  border-style: solid;
  background: #f2f3f5;
  cursor: not-allowed;
}

.running-link {
  display: block;
  text-align: center;
  margin-top: 8px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}

.plot-short { height: 460px; }

/* The run currently on screen, distinct from the accepted basis. */
.runs a.is-selected {
  background: #e8f0fe;
  border-color: var(--accent);
  border-left: 4px solid var(--accent);
  font-weight: 600;
}

.runs a.is-selected .run-id { color: var(--ink); }

/* --- sidebar: two independent meanings, two different colours ---------------
   GREEN  = the accepted basis the next re-plan builds on ("current").
   BLUE   = the run you are looking at right now.
   They are independent, so a run can be both: green fill, blue bar.          */

.runs a.is-head {
  background: #eef8f1;
  border-color: #bfe3cd;
  border-left: 4px solid var(--ok);
}

.runs a.is-selected {
  background: #e8f0fe;
  border-color: var(--accent);
  border-left: 4px solid var(--accent);
  font-weight: 600;
}

.runs a.is-head.is-selected {
  background: #eef8f1;
  border-color: #bfe3cd;
  border-left: 4px solid var(--accent);
  font-weight: 600;
}

.badge-current { background: #d7f0e0; color: var(--ok); }

.basis {
  background: #eef8f1;
  border-color: #bfe3cd;
}
