/* The Wren app shell. All signed-in pages share it.
   The design language is "Ledger": a plain ground, hairline rules, Geist
   text, Geist Mono for IDs, times and labels, and a #FF4342 brand mark.
   It is layered over pico.red.min.css. The page follows the light or dark
   setting of the browser: the colour tokens below have one set of values for
   each mode. The fonts are served from /fonts, so the page makes no request
   to another origin. */

@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---- Colour tokens ---- */
/* Each colour token has a light value and a dark value. The light-dark()
   function selects the value from the colour scheme of the page. Each text
   colour has 4.5:1 contrast on --bg and on --panel. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#FFFFFF, #121619);
  --panel: light-dark(#F6F7F9, #191D21);
  --hover: light-dark(#F2F4F8, #1E2328);
  --stripe: light-dark(#F8F9FB, #171B1F); /* Every second row of a facts list. Fainter than --panel */
  --line: light-dark(#DDE1E6, #2F353B);
  --ink: light-dark(#121619, #F2F4F8);
  --muted: light-dark(#545B64, #A2A9B0);
  --placeholder: light-dark(#6F767E, #8D949B);
  --primary: light-dark(#121619, #F2F4F8);
  --primary-hover: light-dark(#000000, #FFFFFF);
  --on-primary: light-dark(#FFFFFF, #121619);
  --brand: #FF4342;
  --ok: light-dark(#197A3B, #42BE65);
  --run: light-dark(#0F62FE, #78A9FF);
  --warn: light-dark(#8E5B00, #F1C21B);
  --bad: light-dark(#C21F2D, #FF8389);
  --idle: light-dark(#545B64, #A2A9B0);
  --shadow: light-dark(rgba(18, 22, 25, 0.16), rgba(0, 0, 0, 0.5));
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* The page follows the setting of the browser. A page that sets data-theme
   uses that scheme. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* ---- Type scale ---- */
/* Use only these sizes for text. The root size is the browser default,
   usually 16px. Each comment gives the size at that default. */
:root {
  --fs-xs: 0.6875rem;  /* 11px. Uppercase labels and table headers. */
  --fs-sm: 0.8125rem;  /* 13px. Secondary text, notes and small controls. */
  --fs-base: 0.875rem; /* 14px. Main interface text, tables and buttons. */
  --fs-md: 1rem;       /* 16px. Card titles and the product name. */
  --fs-lg: 1.125rem;   /* 18px. Section headings. */
  --fs-xl: 1.375rem;   /* 22px. Page titles and large figures. */
  --fs-2xl: 1.75rem;   /* 28px. The login pitch only. */
}

/* ---- Controls ---- */
/* A control has one of two heights. Use --control-h in a form and for a
   button that stands alone. Use --control-h-sm in a table, a facts list or
   a card. Do not set a height or a text size on one control only. */
:root {
  --control-h: 2.25rem;   /* 36px */
  --control-h-sm: 2rem;   /* 32px */
}

/* Pico reads these variables. Pico sets its theme variables with selectors
   such as :root:not([data-theme]). This selector has the same specificity,
   and app.css loads after Pico, so these values win in both modes. Each
   value is a token, so it changes with the mode. */
:root:not([data-theme]),
:root[data-theme] {
  --pico-font-family: var(--sans);
  --pico-font-family-monospace: var(--mono);
  /* Keep the browser default size at all widths.
     Pico makes the root size larger on wide screens. */
  --pico-font-size: 100%;
  --pico-line-height: 1.5;
  --pico-border-radius: 3px;
  --pico-background-color: var(--bg);
  --pico-color: var(--ink);
  --pico-muted-color: var(--muted);
  --pico-muted-border-color: var(--line);
  --pico-h1-color: var(--ink);
  --pico-h2-color: var(--ink);
  --pico-h3-color: var(--ink);
  --pico-primary: var(--ink);
  --pico-primary-background: var(--primary);
  --pico-primary-border: var(--primary);
  --pico-primary-underline: var(--line);
  --pico-primary-hover: var(--ink);
  --pico-primary-hover-background: var(--primary-hover);
  --pico-primary-hover-border: var(--primary-hover);
  --pico-primary-focus: color-mix(in srgb, var(--brand) 30%, transparent);
  --pico-primary-inverse: var(--on-primary);
  --pico-secondary: var(--muted);
  --pico-secondary-background: transparent;
  --pico-secondary-border: var(--line);
  --pico-secondary-hover-background: var(--hover);
  --pico-secondary-hover-border: var(--ink);
  --pico-secondary-inverse: var(--ink);
  --pico-form-element-background-color: var(--bg);
  --pico-form-element-border-color: var(--line);
  --pico-form-element-color: var(--ink);
  --pico-form-element-placeholder-color: var(--placeholder);
  --pico-form-element-active-background-color: var(--bg);
  --pico-form-element-active-border-color: var(--ink);
  --pico-form-element-focus-color: color-mix(in srgb, var(--brand) 30%, transparent);
  --pico-form-element-spacing-vertical: 0.5rem;
  /* With the 1px border, the text in a box starts 0.8rem from its edge, the
     same as the text in a table cell. */
  --pico-form-element-spacing-horizontal: calc(0.8rem - 1px);
  --pico-card-background-color: var(--bg);
  --pico-table-border-color: var(--line);
  --pico-code-background-color: var(--panel);
  --pico-code-color: var(--ink);
  --pico-modal-overlay-background-color: rgba(0, 0, 0, 0.45);
}

/* Set the heading sizes to the type scale.
   The Pico sizes are too large for this dense layout. */
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3, h4, h5, h6 { font-size: var(--fs-md); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  /* The main text size of the interface. Pico sets 1rem on each control, so
     the Controls section sets the size of a control again. */
  font-size: var(--fs-base);
}

code,
kbd,
pre {
  font-family: var(--mono);
}

button,
[type="submit"],
[type="button"],
input:not([type="checkbox"], [type="radio"], [type="file"]),
select,
textarea {
  font-size: var(--fs-base);
}

input:not([type="checkbox"], [type="radio"], [type="file"]),
select {
  height: var(--control-h);
  padding-top: 0;
  padding-bottom: 0;
}

textarea {
  min-height: var(--control-h);
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

button,
[type="submit"],
[type="button"] {
  width: auto;
  min-height: var(--control-h);
  padding: 0 1.15rem;
}

/* Pico makes a submit button as wide as its form. This selector is as
   strong as the selector of Pico, so the button has the width of its
   label. */
button[type="submit"] {
  width: auto;
}

input[type="file"] {
  height: var(--control-h);
  padding: 0;
  font-size: var(--fs-base);
}

input[type="file"]::file-selector-button {
  height: var(--control-h);
  margin-top: 0;
  margin-bottom: 0;
  padding: 0 0.9rem;
  font-size: var(--fs-base);
}

/* The compact controls. A link that looks like a button has the same
   height. */
select.control-sm,
input.control-sm,
button.row-action,
#page a.attention-action,
#page a.download-link,
.col-menu input,
.col-menu select,
.col-menu button {
  height: var(--control-h-sm);
  min-height: var(--control-h-sm);
}

/* A small mono label in capitals. The sidebar groups, the panels, the aside
   blocks and the stat tiles use it. */
.eyebrow,
.nav-heading,
.panel .panel-title,
.aside-block h2,
.tile .label {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- Shell ---- */
/* On a small screen, the sidebar is above the page. On a wide screen, it is
   a fixed column on the left. */
.shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.sidebar {
  box-sizing: border-box;
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

@media (min-width: 56rem) {
  .shell {
    grid-template-columns: 14.5rem minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
}

/* The brand row has a fixed height, so that it does not change when the
   collapsed sidebar hides the name. */
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 1.75rem;
  padding: 0 0.75rem;
  color: var(--ink);
  text-decoration: none;
}

/* The logo does not shrink, so that it has the same size in the collapsed
   sidebar. Pico sets max-width: 100% on images, and the collapsed brand link
   has only 16px of width, so this rule removes that limit. */
.brand img {
  flex: none;
  max-width: none;
  width: 20px;
  height: 20px;
}

.brand span {
  font-size: var(--fs-md);
  font-weight: 600;
}

/* The version of the build, at the right of the name. Only platform admins
   see it. It is inline text in the name span, so it sits on the baseline of
   the name, and the collapsed sidebar hides it with the name. This selector
   is stronger than the .brand span rule. */
.brand .brand-version {
  margin-left: 0.25rem;
  font-family: var(--pico-font-family-monospace);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--muted);
}

.brand:hover {
  color: var(--ink);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* A group heading is in ink and heavier than the shared label, so that it is
   darker than the muted nav entries below it. */
.nav-heading {
  position: relative;
  margin: 0;
  padding: 0 0.75rem 0.4rem;
  font-weight: 600;
  color: var(--ink);
}

/* A nav entry: a line icon and a label. The icon is red on the active
   entry. */
.nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.15rem;
  padding: 0 0.75rem;
  border-radius: 3px;
  font-size: var(--fs-base);
  color: var(--muted);
  text-decoration: none;
}

/* The line icons of the sidebar: the nav entries, the toggle and the
   log out link. */
.sidebar svg {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav a:hover {
  color: var(--ink);
  background: var(--hover);
}

.nav a.active {
  color: var(--ink);
  font-weight: 500;
}

.nav a.active svg {
  color: var(--brand);
}

/* The bottom of the sidebar: the collapse toggle, then the log out link. */
.sidebar-user {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: var(--fs-sm);
}

/* The toggle button and the log out button look like nav entries. They have
   no Pico button style. A line separates the toggle from the log out button. */
.nav-toggle,
.logout-button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.15rem;
  padding: 0 0.75rem;
  border-radius: 3px;
  text-decoration: none;
}

.nav-toggle {
  display: none;
  position: relative;
  width: 100%;
  margin: 0 0 0.5rem;
  border: 0;
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: var(--fs-base);
  text-align: left;
  color: var(--muted);
  cursor: pointer;
}

.nav-toggle::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.45rem;
  border-top: 1px solid var(--line);
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  color: var(--ink);
  background: var(--hover);
}

.logout-form {
  margin: 0;
}

/* The button selector makes this rule stronger than the width rule of a
   submit button. */
button.logout-button {
  width: 100%;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font: inherit;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.logout-button:hover,
.logout-button:focus-visible {
  color: var(--ink);
  background: var(--hover);
}

/* ---- Collapsed sidebar ---- */
/* On a wide screen, the toggle button collapses the sidebar to a column of
   icons. The collapsed width keeps each icon at the same x position, and
   each row keeps its height, so only the labels go. The labels stay in the
   page for screen readers, and the title attribute of each link shows the
   label on hover. On a small screen,
   the sidebar is above the page, so the collapsed state has no effect. */
@media (min-width: 56rem) {
  .nav-toggle {
    display: flex;
  }

  .nav-collapsed .shell {
    grid-template-columns: 4rem minmax(0, 1fr);
  }

  .nav-collapsed .nav-label,
  .nav-collapsed .brand span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* A heading keeps its height but its text is transparent, so the entries
     stay at the same y position. The text stays for screen readers. */
  .nav-collapsed .nav-heading {
    overflow: hidden;
    white-space: nowrap;
    color: transparent;
  }

  /* A line in the place of the heading text separates the groups. */
  .nav-collapsed .nav-group + .nav-group .nav-heading::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: calc((100% - 0.4rem) / 2);
    border-top: 1px solid var(--line);
  }
}

/* The tooltip of an entry in the collapsed sidebar. app.js sets its text
   and its position. */
.nav-tip {
  position: fixed;
  z-index: 50;
  padding: 0.25rem 0.55rem;
  border-radius: 3px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px var(--shadow);
}

.nav-tip[hidden] {
  display: none;
}

/* On a small screen, the nav groups go in a row and wrap. */
@media (max-width: 55.99rem) {
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
  }

  .sidebar-user {
    margin-top: 0;
  }
}

/* ---- Page column ---- */
/* The page column has a maximum width. On a wide screen, the automatic
   margins put it in the centre of the space at the right of the sidebar. */
#page {
  min-width: 0;
  width: 100%;
  max-width: 90rem;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 1.85rem 2.65rem 4rem;
}

#page h1,
#page h2,
#page h3 {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem 2rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.35rem;
  margin-bottom: 1.6rem;
}

.page-header h1 {
  margin: 0;
  font-size: var(--fs-xl);
  line-height: 1.2;
}

.page-header .intro {
  margin: 0.4rem 0 0;
  max-width: 44rem;
  color: var(--muted);
  font-size: var(--fs-base);
  line-height: 1.5;
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.page-header-actions button {
  margin: 0;
}

/* The small link above a page title, back to the list */
.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: var(--fs-sm);
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--ink);
}

.eyebrow {
  margin: 0 0 0.35rem;
}

/* The tabs below a page header, for example the job scope. They are a segmented control: the active tab is filled. */
.subnav {
  display: inline-flex;
  flex-wrap: wrap;
  margin: 0 0 1.6rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.subnav a {
  display: inline-flex;
  align-items: center;
  height: var(--control-h-sm);
  padding: 0 0.95rem;
  font-size: var(--fs-sm);
  color: var(--muted);
  text-decoration: none;
}

.subnav a + a {
  border-left: 1px solid var(--line);
}

#page .subnav a:hover {
  color: var(--ink);
  background: var(--hover);
}

#page .subnav a.active {
  color: var(--on-primary);
  background: var(--primary);
}

/* ---- Two-column detail pages ---- */
.split {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem 3rem;
  align-items: flex-start;
}

.split-main {
  flex: 999 1 560px;
  min-width: 0;
}

.split-aside {
  flex: 1 1 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* The page header rule is above the aside, so the first block has no rule */
.aside-block + .aside-block {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

#page .aside-block h2 {
  margin: 0 0 0.75rem;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
}

/* Numbered sections of a detail page */
.section {
  margin-bottom: 2.5rem;
}

/* The gap below a section heading is the same in all places. A heading in a
   row with a link or a switch has no margin: the row has the gap. */
.section-heading {
  margin: 0 0 0.5rem;
  font-size: var(--fs-lg);
}

/* A section heading with a control at the right, for example the auto
   refresh switch of a list. */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin: 0 0 0.5rem;
}

.section-head .section-heading,
.dash-heading .section-heading,
.dash-heading .dash-subheading {
  margin: 0;
}

.section-heading .num {
  margin-right: 0.4rem;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--muted);
}

.section-intro {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: var(--fs-base);
}

/* Facts as a definition list. Every second row has a faint band, so the
   eye can follow a label to its value. The cells have padding instead of
   a grid gap, so the band of a row has no gaps. Each dt has one dd, so
   nth-of-type counts the rows. */
.facts {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 0;
  margin: 0;
  font-size: var(--fs-base);
}

.facts dt,
.facts dd {
  padding: 0.45rem 0.75rem;
}

.facts dt {
  color: var(--muted);
  font-weight: 400;
}

.facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.facts dt:nth-of-type(even),
.facts dt:nth-of-type(even) + dd {
  background: var(--stripe);
}

.facts dt:nth-of-type(even) {
  border-radius: 3px 0 0 3px;
}

.facts dt:nth-of-type(even) + dd {
  border-radius: 0 3px 3px 0;
}

/* In an aside, the facts list goes 0.75rem outside the block on each side.
   Thus its text starts below the heading of the block. */
.aside-block .facts {
  margin: 0 -0.75rem;
}

/* A control in a fact, for example the priority of a job. The cells
   stretch to the height of the control, so the band has one height.
   The label of a compact control is level with the text in the control.
   The selector of the inputs is stronger than the input selector of Pico,
   so margin 0 removes the bottom margin of Pico. */
.facts dt:has(+ dd :is(select, input, button)) {
  padding-top: calc(0.45rem + (var(--control-h-sm) - 1.5em) / 2);
}

.facts dd form input,
.facts dd form select {
  margin: 0;
}

/* Cards, for example the control hardware of a QPU */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1rem 1.1rem;
}

.card .card-title {
  margin: 0.35rem 0 0;
  font-size: var(--fs-md);
  font-weight: 500;
}

.card .card-line {
  margin: 0.25rem 0 0;
  font-size: var(--fs-sm);
}

.card .card-note {
  margin: 0.5rem 0 0;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.card select {
  margin: 0.75rem 0 0;
}

/* Stat tiles of the dashboard */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.tile {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1rem 1.15rem;
}

.tile .label {
  margin: 0;
}

.tile .value {
  margin: 0.4rem 0 0;
  font-size: var(--fs-xl);
  font-weight: 600;
}

.tile .tile-note {
  margin: 0.3rem 0 0;
  font-size: var(--fs-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---- Dashboard ---- */
.dash-section {
  margin-bottom: 2.25rem;
  min-width: 0;
}

.dash-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.dash-heading > a {
  line-height: 1.2;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.dash-subheading {
  margin: 0 0 0.5rem;
  font-size: var(--fs-base);
  font-weight: 600;
}

/* Two columns that stack on a narrow screen */
.dash-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 0 2rem;
}

.dash-col {
  min-width: 0;
}

@media (max-width: 48rem) {
  .dash-cols {
    grid-template-columns: minmax(0, 1fr);
  }
}

#page td.num,
#page th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The attention list. The left stripe shows how serious the problem is */
.attention {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
}

.attention li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--idle);
}

.attention li:last-child {
  border-bottom: 0;
}

.attention li > div {
  flex: 1;
  min-width: 0;
}

.attention strong {
  display: block;
  font-weight: 500;
}

.attention span {
  display: block;
  margin-top: 0.1rem;
  font-size: var(--fs-sm);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.attention .attention-bad {
  border-left-color: var(--bad);
}

.attention .attention-warn {
  border-left-color: var(--warn);
}

.attention .attention-info {
  border-left-color: var(--run);
}

#page a.attention-action,
#page a.download-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: var(--fs-sm);
  text-decoration: none;
}

#page a.attention-action:hover,
#page a.download-link:hover {
  background: var(--hover);
}

#page a.download-link {
  gap: 0.5rem;
  white-space: nowrap;
}

.download-size {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* The range switch of the throughput section. It is higher than the
   heading. The negative margin keeps the heading row at the height of the
   heading, so the gap below the row stays the same. */
.range-switch {
  margin: -0.4rem 0;
  align-self: center;
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}

#page .range-switch a {
  display: inline-flex;
  align-items: center;
  height: var(--control-h-sm);
  padding: 0 0.75rem;
  font-size: var(--fs-sm);
  color: var(--muted);
  text-decoration: none;
}

#page .range-switch a + a {
  border-left: 1px solid var(--line);
}

#page .range-switch a.active {
  background: var(--hover);
  color: var(--ink);
  font-weight: 500;
}

/* The jobs finished chart. The server lays out the SVG */
.chart-scroll {
  overflow-x: auto;
  margin-bottom: 1.75rem;
}

/* The chart scales with its width. At the usual desktop width the scale is
   1, so the text has the size of --fs-xs. A narrow page scrolls the chart. */
.chart {
  display: block;
  width: 100%;
  min-width: 56rem;
  height: auto;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-text {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 11px; /* fs-exception: SVG text uses the units of the viewBox. */
}

.chart-hit {
  fill: transparent;
}

.chart g:hover .chart-hit {
  fill: var(--hover);
}

rect.chart-completed {
  fill: var(--ok);
}

rect.chart-failed {
  fill: var(--bad);
}

rect.chart-cancelled {
  fill: var(--idle);
}

.chart-legend {
  align-self: center;
  line-height: 1.2;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.chart-key::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 0.4rem;
  background: var(--idle);
}

.chart-key.chart-completed::before {
  background: var(--ok);
}

.chart-key.chart-failed::before {
  background: var(--bad);
}

/* Horizontal bars: a name, a bar and a value */
.bars {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1.5rem;
}

.bar {
  display: grid;
  grid-template-columns: minmax(0, 10rem) minmax(0, 1fr) 4rem;
  gap: 0.75rem;
  align-items: center;
  font-size: var(--fs-base);
}

.bar-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bar-name .cell-note {
  font-size: var(--fs-sm);
}

.bar-track {
  height: 8px;
  background: var(--hover);
}

.bar-fill {
  display: block;
  height: 100%;
}

.bar-tenant {
  background: var(--muted);
}

.bar-busy {
  background: var(--run);
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ---- Panels and forms ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1.1rem 1.25rem 1.25rem;
  margin-bottom: 2rem;
}

.panel .panel-title {
  margin: 0 0 0.8rem;
}

.panel p {
  margin-bottom: 0.6rem;
}

.create-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.create-form input,
.create-form select,
.create-form textarea {
  flex: 1 1 12rem;
  width: auto;
  margin: 0;
}

/* A control in a create form has the standard height, also a select with
   the compact class. */
.create-form select.control-sm,
.create-form input.control-sm {
  height: var(--control-h);
  min-height: var(--control-h);
}

.create-form button {
  margin: 0;
}

/* The form below the workers of an overseer. The select keeps a fixed
   width, so the button stays next to it. */
.add-worker-form {
  margin: 1rem 0 0.5rem;
}

.add-worker-form select {
  flex: 0 1 16rem;
}

/* A create section at the top of a list page. The title and the help text
   are in a column on the left, and the form is on the right. A line below
   separates the section from the table. */
.create-section {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2.5rem;
  padding: 0 0 1.5rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--line);
}

.create-label {
  flex: 0 1 13.75rem;
}

#page .create-label h2 {
  margin: 0;
  font-size: var(--fs-base);
}

.create-label p {
  margin: 0.4rem 0 0;
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--muted);
}

.create-section .create-form {
  flex: 1 1 26rem;
  align-items: flex-start;
  align-content: flex-start;
}

/* A field that takes a full line of the form, for example a description */
.create-form .wide {
  flex-basis: 100%;
}

/* The submit button is at the right end of the fields */
.create-section .create-form button[type="submit"] {
  margin-left: auto;
}

/* A form that edits one entity. Each field is a label above its input, and
   the fields are in one column. The button is below the last field. */
.edit-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 32rem;
}

.edit-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 500;
}

.edit-form input,
.edit-form select,
.edit-form textarea {
  margin: 0;
}

.edit-form button {
  align-self: flex-start;
  margin: 0.25rem 0 0;
}

/* A short note after a field label, for example "optional" */
.field-hint {
  font-weight: 400;
  color: var(--muted);
}

/* The content of a config on its detail page. A long config scrolls inside
   the panel. */
.config-content {
  max-height: 32rem;
  overflow: auto;
  margin: 0;
  font-size: var(--fs-sm);
  background: var(--panel);
}

/* A compact control, used in tables, facts lists and cards */
.control-sm {
  width: auto;
  min-width: 9rem;
  margin: 0;
}

/* An inline-editable cell. The border shows on hover and focus.
   The input selector of Pico is stronger than one class, so the selector
   starts with "input". Then margin 0 removes the bottom margin of Pico, and
   the text is level with the text of the other cells.
   The negative left margin is equal to the padding and the border. Thus the
   text starts at the same position as the column heading. */
input.cell-input {
  margin: 0 0 0 calc(-0.5rem - 1px);
  width: calc(100% + 0.5rem + 1px);
  height: var(--control-h-sm);
  padding: 0 0.5rem;
  background: transparent;
  border-color: transparent;
  font-size: inherit;
  line-height: inherit;
}

input.cell-input:hover,
input.cell-input:focus {
  background: var(--bg);
  border-color: var(--line);
}

/* Radio choices, for example the availability of a QPU */
.choices {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.choices label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2rem;
  margin: 0;
}

.choices input {
  margin: 0;
}

/* ---- Tables ---- */
.ledger {
  margin-bottom: 2.25rem;
}

.ledger-title {
  margin: 0 0 0.5rem;
  font-size: var(--fs-lg);
}

/* The scroll box is the containing block of the text for screen readers in
   a heading cell. Without position: relative, that text is outside the box
   and makes the page scroll to the side on a narrow screen. */
.table-scroll {
  position: relative;
  overflow-x: auto;
}

/* The title of a list, and the number of filters with a Reset link */
.ledger-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 0 0 0.5rem;
}

#page .ledger-head .ledger-title {
  margin: 0;
}

.ledger-state {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* The auto refresh switch of a list. It is at the right of the head of the
   table. */
#page .auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0 auto;
  font-size: var(--fs-sm);
  color: var(--muted);
  cursor: pointer;
}

#page .auto-refresh input {
  margin: 0;
}

/* A column without a menu. Its heading is dimmer than the heading of a
   column with a menu, so a user can see which columns sort and filter. */
#page th.col-plain {
  color: var(--placeholder);
}

/* The heading of a column with a menu is a button. It looks like the
   heading text until the pointer is on it. A column that sorts or filters
   the list now has its heading in the text colour, with a mark. */
#page .col-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 0;
  margin: -0.2rem -0.35rem;
  padding: 0.2rem 0.35rem;
  background: transparent;
  border: 0;
  border-radius: 3px;
  box-shadow: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

#page .col-button:hover,
#page .col-button:focus-visible,
#page .col-button:has(+ .col-menu:popover-open) {
  background: var(--hover);
  color: var(--ink);
}

#page .col-button.active {
  color: var(--ink);
}

.col-mark {
  color: var(--brand);
  font-family: var(--sans);
}

svg.col-mark {
  width: 0.6rem;
  height: 0.6rem;
}

/* The menu of a column. It is a popover in the top layer. app.js puts it
   below the heading button. The menu is inside the heading cell, so it sets
   the font again. */
.col-menu {
  position: absolute;
  inset: auto;
  width: 16rem;
  margin: 0;
  padding: 0.9rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  white-space: normal;
}

.col-menu:popover-open {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.col-menu-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.col-menu-sort {
  display: flex;
  margin-top: -0.4rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}

#page .col-sort {
  flex: 1;
  padding: 0.4rem 0.5rem;
  text-align: center;
  text-decoration: none;
  font-size: var(--fs-sm);
  color: var(--ink);
}

#page .col-sort + .col-sort {
  border-left: 1px solid var(--line);
}

#page .col-sort:hover,
#page .col-sort.active {
  background: var(--hover);
}

#page .col-sort.active {
  font-weight: 500;
}

.col-menu-filter {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
}

.col-menu-filter input,
.col-menu-filter select {
  margin: 0;
}

.col-menu-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

#page .col-menu-clear {
  margin-right: auto;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.col-menu-actions button {
  margin: 0;
  padding: 0 0.9rem;
}

#page table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: var(--fs-base);
  --pico-background-color: transparent;
}

/* A column heading is a small mono label above a strong rule. */
#page th {
  padding: 0.65rem 0.8rem;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--ink);
  background: transparent;
  text-align: left;
  white-space: nowrap;
}

#page td {
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid var(--line);
  background: transparent;
  vertical-align: middle;
}

#page tbody tr:hover td {
  background: var(--hover);
}

/* The first column keeps the full 0.8rem padding. An inline-editable cell
   moves its box 0.5rem plus 1px to the left (see input.cell-input), and its
   focus ring is 2px wide. The table-scroll box cuts off anything that goes
   outside the table, so less padding cuts off the left border of the box. */

#page th:last-child,
#page td:last-child {
  padding-right: 0.4rem;
}

/* A table cell that stays on one line, for example a date or a size */
.nowrap {
  white-space: nowrap;
}

.cell-note {
  display: block;
  margin-top: 0.15rem;
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* The heading row of a group in a table, for example a datacentre. It is a
   filled band across the table. */
#page tr.group-row th {
  padding: 0.55rem 0.8rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

/* An empty state. In a table it is a padded cell. Inline it is a muted dash */
td.empty,
p.empty {
  padding: 2rem 0;
  text-align: center;
  color: var(--muted);
}

span.empty {
  color: var(--muted);
}

/* ---- Links ---- */
#page a {
  color: var(--ink);
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

#page a:hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

/* A clickable entity name that links to a detail page. A faint underline
   always shows, so that the link is visible without hover. On hover, the
   underline changes to the text colour. */
#page a.row-link {
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line);
  transition: text-decoration-color 0.15s ease;
}

#page a.row-link:hover {
  text-decoration-color: var(--ink);
}

/* A table value that filters the list by itself. It looks like the other
   text of the table. On hover, a dotted line shows that it is a link. */
#page a.cell-filter {
  color: inherit;
  text-decoration: none;
}

#page a.cell-filter:hover {
  text-decoration: underline dotted;
  text-decoration-color: var(--muted);
  text-underline-offset: 3px;
}

/* Text for screen readers only */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Inline code has a fixed size from the type scale, so it has the same size
   in all text. */
code {
  padding: 0.1rem 0.3rem;
  font-size: var(--fs-sm);
  border-radius: 3px;
}

/* ---- Pager ---- */
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.5rem;
  margin: -1.25rem 0 2rem;
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

.pager-status {
  color: var(--muted);
}

#page .pager-link {
  text-decoration: none;
}

.pager-link.disabled {
  color: var(--placeholder);
}

/* ---- Buttons ---- */
.row-actions {
  text-align: right;
  white-space: nowrap;
}

button.row-action {
  margin: 0 0 0 0.35rem;
  padding: 0 0.75rem;
  font-size: var(--fs-sm);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

button.row-action:hover {
  background: var(--hover);
  border-color: var(--ink);
}

button.row-action.danger,
button.danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  background: transparent;
}

button.row-action.danger:hover,
button.danger:hover {
  background: color-mix(in srgb, var(--bad) 8%, transparent);
  border-color: var(--bad);
}

/* ---- Status labels ---- */
/* A status is coloured text after a small square of the same colour. The
   default is the neutral colour. */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-sm);
  white-space: nowrap;
  color: var(--idle);
}

.status::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: currentColor;
}

.status-active,
.status-online,
.status-idle,
.status-completed {
  color: var(--ok);
}

.status-invited,
.status-processing,
.status-calibrating,
.status-running {
  color: var(--run);
}

.status-suspended,
.status-maintenance,
.status-paused,
.status-offered {
  color: var(--warn);
}

.status-system,
.status-error,
.status-offline,
.status-retired,
.status-failed {
  color: var(--bad);
}

/* The system tag comes after a group name in the same cell. templ removes
   the space between the name and the tag, so the margin makes the gap. */
.status-system {
  margin-left: 0.6rem;
}

.text-ok {
  color: var(--ok);
}

.text-warn {
  color: var(--warn);
}

/* ---- Audit log ---- */
.log {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  font-size: var(--fs-base);
  line-height: 1.4;
}

.log li {
  margin: 0;
  padding: 0;
}

.log strong {
  font-weight: 500;
}

.log time {
  display: block;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--muted);
}

.log .log-actor {
  color: var(--muted);
}

.log-empty {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-base);
}

.log-more {
  display: inline-block;
  margin-top: 0.8rem;
  font-size: var(--fs-sm);
}

/* ---- Confirm dialog ---- */
.confirm article {
  max-width: 28rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 12px 40px var(--shadow);
}

.confirm p {
  margin: 0 0 1rem;
  line-height: 1.5;
}

.confirm footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
}

.confirm footer button {
  margin: 0;
}

/* ---- Toasts ---- */
/* A toast uses the inverse colours, so it stands out in both modes. */
.toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(26rem, calc(100vw - 2.5rem));
}

.toast {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.75rem 1rem;
  background: var(--primary);
  color: var(--on-primary);
  border-left: 3px solid var(--brand);
  border-radius: 3px;
  box-shadow: 0 8px 24px var(--shadow);
  font-size: var(--fs-base);
  cursor: pointer;
  animation: toast-in 0.2s ease-out;
}

.toast-success {
  border-left-color: var(--ok);
}

.toast-code {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  opacity: 0.75;
}

.toast-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast-leaving {
    animation: none;
    transition: none;
  }
}

/* ---- Small screens ---- */
@media (max-width: 40rem) {
  #page {
    padding: 1.25rem 1rem 3rem;
  }

  /* The label is above its value. The band covers both, as one block */
  .facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .facts dt {
    padding-bottom: 0.1rem;
  }

  .facts dd {
    padding-top: 0;
  }

  .facts dt:nth-of-type(even) {
    border-radius: 3px 3px 0 0;
  }

  .facts dt:nth-of-type(even) + dd {
    border-radius: 0 0 3px 3px;
  }
}

/* ---- Config history and inline upload ---- */
/* One item of a list in a table cell, for example a config position */
.cell-line {
  display: block;
}

.config-save {
  display: flex;
  justify-content: flex-end;
  margin: 0.75rem 0 0;
}

.config-save button {
  width: auto;
  margin: 0;
}

.upload-inline,
.config-history {
  margin: 0.35rem 0 0;
}

/* The arrow of Pico is at the right end of the cell. Here it is directly
   after the label. */
.upload-inline summary,
.config-history summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.upload-inline summary::after,
.config-history summary::after {
  float: none;
  margin: 0;
}

.upload-inline .create-form {
  margin-top: 0.5rem;
}

.config-history ul {
  margin: 0.4rem 0 0;
  padding-left: 0;
  list-style: none;
}

.config-history li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.6rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--line);
}

.config-history .cell-note {
  display: inline;
  margin: 0;
}

.config-history .row-action {
  margin-left: auto;
}

/* The history row belongs to the position row above it */
tr.history-row td {
  padding-top: 0;
}

/* The reason why a change is not available now, next to the disabled
   controls. It stands out from the other intro text. */
.locked-note {
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--warn);
  background: var(--panel);
  color: var(--ink);
}

#worker-qpu-locked {
  margin-top: 0.35rem;
}
