/* RUA Bench collection console.
   Palette from the restaurant's pass-through window: porcelain, cobalt glaze, stainless steel. */
:root {
  --porcelain: #f4f6f9;
  --surface: #ffffff;
  --ink: #151b26;
  --steel: #5c6675;
  --line: #d6dce5;
  --cobalt: #1b3fa0;
  --cobalt-deep: #142e78;
  --frame: #1a2130;
  --ok: #17794b;
  --warn: #8f5b00;
  --bad: #b42318;
  --step: 0.5rem;
  font-family: "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--porcelain); }
h1, h2 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.2rem; white-space: nowrap; }
h2 { font-size: 1.05rem; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1.5rem; background: var(--cobalt-deep); color: #fff;
}
.top-nav { display: flex; gap: 0.25rem; margin-right: auto; }
.top-nav a { color: #fff; text-decoration: none; padding: 0.3rem 0.8rem; border-radius: 4px; opacity: 0.8; }
.top-nav a:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }
.top-nav a[aria-current="page"] { opacity: 1; background: rgba(255, 255, 255, 0.2); font-weight: 600; }
.top-meta { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.revision { font-size: 0.87rem; opacity: 0.85; }
.note { padding: 0.5rem 1.5rem; background: #e7ecf8; color: var(--cobalt-deep); font-size: 0.9rem; white-space: pre-wrap; }
.alerts { display: grid; }
.alerts p { padding: 0.5rem 1.5rem; background: #fdf0d5; color: #5c3a00; border-bottom: 1px solid #edd9a8; font-size: 0.93rem; }

button {
  border: 1px solid var(--line); border-radius: 4px; background: var(--surface);
  padding: 0.4rem 0.9rem; cursor: pointer; line-height: 1.4;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--cobalt-deep); }
button.quiet:hover:not(:disabled) { border-color: var(--steel); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.top button.quiet { background: transparent; border-color: rgba(255, 255, 255, 0.45); color: #fff; }
.top button.primary { background: #fff; border-color: #fff; color: var(--cobalt-deep); }

.layout { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 1.5rem; padding: 1.5rem; max-width: 92rem; margin: 0 auto; }
.work { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; min-width: 0; }

/* task list */
.tasks h2 { margin-bottom: 0.75rem; }
.tasks ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.tasks button {
  display: grid; grid-template-columns: 5.2rem 1fr; gap: 0.75rem; align-items: center; width: 100%;
  padding: 0.5rem; text-align: left; border: 0; border-left: 3px solid transparent; border-radius: 0; background: transparent;
}
.tasks button:hover { background: #e9edf3; }
.tasks button[aria-current="true"] { background: var(--surface); border-left-color: var(--cobalt); }
.tasks img { width: 5.2rem; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 2px; background: var(--line); display: block; }
.tasks .name { display: block; font-weight: 600; }
.tasks .engine { display: block; font-size: 0.82rem; color: var(--steel); }

/* the pass-through window: live view of the running task */
.pass { background: var(--frame); border-radius: 3px; color: #fff; overflow: hidden; }
.pass-frame { position: relative; aspect-ratio: 16 / 9; max-height: 62vh; width: 100%; background: #0f141d; display: grid; place-items: center; }
.pass-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pass.idle .pass-frame { aspect-ratio: 16 / 6; }
.pass-frame img.still { object-fit: cover; opacity: 0.55; }
.view-hint { position: absolute; left: 1rem; bottom: 0.75rem; right: 1rem; font-size: 0.93rem; text-shadow: 0 1px 2px #000; }
.pass-bar { display: flex; align-items: center; gap: 1.25rem; padding: 0.7rem 1rem; flex-wrap: wrap; border-top: 3px solid var(--cobalt); }
.pass-state { display: grid; min-width: 9rem; }
.pass-state strong { font-size: 1.1rem; }
.pass-state span { font-size: 0.87rem; opacity: 0.8; }
.checks { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0; padding: 0; flex: 1; font-size: 0.9rem; }
.checks li::before { content: "○ "; opacity: 0.6; }
.checks li.met::before { content: "● "; color: #6fd3a2; opacity: 1; }
.session-note { padding: 0.6rem 1rem; background: #263042; font-size: 0.93rem; }
.session-note.bad { background: #5b1a14; }

/* launch form */
.launch, .records, .log, .devices { background: var(--surface); border: 1px solid var(--line); border-radius: 3px; padding: 1.25rem 1.5rem; }
.prompt { margin-top: 0.4rem; max-width: 44rem; }
.steps { margin: 0.6rem 0 0; padding-left: 1.4rem; color: var(--steel); max-width: 44rem; }
.facts { margin-top: 0.6rem; font-size: 0.87rem; color: var(--steel); }
form { margin-top: 1.1rem; display: grid; gap: 1rem; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { padding: 0; font-weight: 600; margin-bottom: 0.3rem; }
.choices { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choices label { border: 1px solid var(--line); border-radius: 4px; padding: 0.35rem 0.8rem; cursor: pointer; }
.choices input { position: absolute; opacity: 0; }
.choices label:has(input:checked) { border-color: var(--cobalt); background: #e7ecf8; color: var(--cobalt-deep); font-weight: 600; }
.choices label:has(input:focus-visible) { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.choices small { display: block; font-weight: 400; color: var(--steel); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(13rem, 100%), 1fr)); gap: 0.75rem 1rem; }
.fields label { display: grid; gap: 0.2rem; font-size: 0.9rem; color: var(--steel); }
.fields label.wide { grid-column: span 2; }
.fields label.check { display: flex; align-items: center; gap: 0.5rem; grid-column: 1 / -1; color: var(--ink); }
.fields input:not([type="checkbox"]), .fields select { border: 1px solid var(--line); border-radius: 4px; padding: 0.4rem 0.6rem; background: #fff; color: var(--ink); width: 100%; }
details summary { cursor: pointer; color: var(--cobalt); width: fit-content; }
details[open] summary { margin-bottom: 0.75rem; }
.actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.error { color: var(--bad); }

/* teleoperation devices */
.devices-head { display: flex; align-items: center; gap: 0.75rem 1.25rem; flex-wrap: wrap; }
.devices-head .actions { margin-left: auto; }
.device-state { font-size: 0.93rem; color: var(--steel); }
.device-state.on { color: var(--ok); font-weight: 600; }
.device-state.busy { color: var(--warn); font-weight: 600; }
.device-parts { list-style: none; display: flex; flex-wrap: wrap; gap: 0.3rem 1.5rem; margin: 0.75rem 0 0; padding: 0; font-size: 0.93rem; }
.device-parts li::before { content: "○ "; color: var(--steel); }
.device-parts li.on::before { content: "● "; color: var(--ok); }
.device-parts small { color: var(--steel); }
.calibrations { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr)); gap: 1rem 2rem; margin: 1rem 0; }
.calibrations h3 { margin: 0; font-size: 0.97rem; font-weight: 600; }
.calibrations .actions { margin-top: 0.5rem; }
.devices pre { margin: 0; max-height: 18rem; overflow: auto; font-size: 0.82rem; line-height: 1.45; white-space: pre-wrap; word-break: break-all; color: #2a3342; }

.log pre { margin: 0; max-height: 18rem; overflow: auto; font-size: 0.82rem; line-height: 1.45; white-space: pre-wrap; word-break: break-all; color: #2a3342; }

/* records */
.records-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.filters button { padding: 0.25rem 0.7rem; font-size: 0.9rem; }
.filters button[aria-selected="true"] { border-color: var(--cobalt); color: var(--cobalt-deep); background: #e7ecf8; font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th { text-align: left; font-weight: 600; color: var(--steel); border-bottom: 1px solid var(--line); padding: 0.4rem 0.6rem 0.4rem 0; white-space: nowrap; }
td { border-bottom: 1px solid #e8ecf2; padding: 0.5rem 0.6rem 0.5rem 0; vertical-align: top; }
td .sub { display: block; font-size: 0.82rem; color: var(--steel); }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
td button { padding: 0.15rem 0.55rem; font-size: 0.87rem; margin: 0 0.3rem 0.3rem 0; }
.empty { color: var(--steel); padding: 1rem 0 0.25rem; }

dialog { border: 0; border-radius: 3px; padding: 0; width: min(64rem, 94vw); background: var(--frame); color: #fff; }
dialog::backdrop { background: rgba(10, 14, 22, 0.7); }
.player-head { display: flex; justify-content: space-between; align-items: center; margin: 0; padding: 0.6rem 0.9rem; }
dialog video { width: 100%; display: block; background: #000; max-height: 70vh; }
dialog .filters { padding: 0.6rem 0.9rem; }
dialog button.quiet, dialog .filters button { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.4); }
dialog .filters button[aria-selected="true"] { background: #fff; color: var(--cobalt-deep); border-color: #fff; }

@media (max-width: 60rem) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 1rem; }
  .top { flex-wrap: wrap; padding: 0.75rem 1rem; }
  .launch, .records, .log, .devices { padding: 1rem; }
  .devices-head .actions { margin-left: 0; }
  .tasks ul { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
  .fields label.wide { grid-column: auto; }
  table { display: block; overflow-x: auto; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color 0.12s, border-color 0.12s; }
}
