/* Roefja brand (brandbook v1.0): colours, fonts and shapes come from tokens.css. Orange is only the logo and the one
   primary action of a view; status colours always come with text. */
* { box-sizing: border-box; }
body { margin: 0; font: 400 16px/1.5 var(--font-body); background: var(--color-bg); color: var(--color-ink); }
h1, h2 { font-family: var(--font-heading); font-weight: 700; line-height: 1.2; }
h1 { font-size: 28px; margin: 8px 0 16px; }
h2 { font-size: 20px; margin: 32px 0 12px; }
a { color: var(--color-accent-text); }
:focus-visible { outline: 2px solid var(--color-ink); outline-offset: 2px; }

/* Layout: sidebar on the left, content (notice bar above main) on the right. Below 900px the sidebar stacks on top. */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.content { min-width: 0; }
#header { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 24px; padding: 24px 20px; background: var(--color-surface); border-right: 1px solid var(--color-border); }
#header .brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-decoration: none; color: var(--color-ink); }
#header .brand img { display: block; max-width: 100%; height: auto; }
#header .product { font: 600 15px var(--font-heading); color: var(--color-text-muted); }
.eyebrow { display: block; font: 500 11px/1.4 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 6px; }
#header .picker select { width: 100%; }
#header nav { display: flex; flex-direction: column; gap: 20px; }
#header .nav-group { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
#header nav a { color: var(--color-ink); text-decoration: none; font-size: 15px; font-weight: 500; padding: 2px 0; border-bottom: 2px solid transparent; }
#header nav a:hover { border-bottom-color: var(--color-border); }
#header nav a.active { border-bottom-color: var(--color-accent); font-weight: 600; }
#header .account { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--color-border); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
#header .account .who { overflow-wrap: anywhere; }
#header .account button { margin: 0; }
main { padding: 24px; max-width: 1200px; margin: 0 auto; }

[hidden] { display: none !important; }
.sub { color: var(--color-text-muted); font-size: 13px; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.empty { color: var(--color-text-muted); }
.error { color: var(--color-error-text); }

table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; font-size: 14px; margin-top: 12px; }
table.grid th { text-align: left; padding: 10px 14px; font: 500 12px var(--font-mono); color: var(--color-text-muted); background: var(--color-surface-muted); border-bottom: 1px solid var(--color-border); }
table.grid td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--color-border); vertical-align: top; overflow-wrap: anywhere; }
table.grid tr:last-child td { border-bottom: 0; }

/* Status: indicator dot plus text, text colours from the -text tokens. "muted" is the neutral info state. */
.pill { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-pill); font: 600 12px/1.5 var(--font-body); background: var(--color-surface-muted); color: #3A3936; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--color-text-muted); flex: none; }
.pill.good { background: var(--color-success-bg); color: var(--color-success-text); }
.pill.good::before { background: var(--color-success); }
.pill.warn { background: var(--color-warning-bg); color: var(--color-warning-text); }
.pill.warn::before { background: var(--color-warning); }
.pill.bad { background: var(--color-error-bg); color: var(--color-error-text); }
.pill.bad::before { background: var(--color-error); }

/* Buttons are pills. Default is the tertiary style; .primary is the primary button: orange with white bold text at
   16 px (Rick's call: the brand only allows white on orange from 19 px bold, where the contrast is 3.1:1, so this is a
   deliberate step below it). One primary action per view or dialog, never inside a table row: tight places use the
   default button. */
button { font: 600 13px/1.4 var(--font-body); padding: 5px 14px; border: 1.5px solid var(--color-ink); background: var(--color-surface); color: var(--color-ink); border-radius: var(--radius-pill); cursor: pointer; margin: 0 6px 6px 0; }
button:hover { background: var(--color-surface-muted); }
button.primary { font: 700 16px/1.4 var(--font-body); padding: 8px 18px; background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
button.primary:hover { filter: brightness(0.95); }
button.danger { color: var(--color-error-text); border-color: var(--color-error-text); }

#notice { position: sticky; top: 0; z-index: 1; margin: 0; padding: 10px 24px; background: var(--color-surface-muted); color: #3A3936; border-bottom: 1px solid var(--color-border); }
#notice[data-tone="bad"] { background: var(--color-error-bg); color: var(--color-error-text); }
#notice[data-tone="good"] { background: var(--color-success-bg); color: var(--color-success-text); }

dialog { border: 1px solid var(--color-border); border-radius: var(--radius-md); min-width: min(520px, 95vw); padding: 20px 24px; background: var(--color-surface); color: var(--color-ink); }
dialog::backdrop { background: rgb(22 22 22 / 0.45); }
dialog h2 { margin-top: 0; }
label.field { display: block; margin: 12px 0; }
label.field span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
/* Selects: no native arrow (it ignores the brand), a CSS caret instead (gradients, so no image and nothing for the CSP). */
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--color-ink) 50%), linear-gradient(135deg, var(--color-ink) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; cursor: pointer; }
/* In a table row a select looks like the default button: same pill, border and type. */
table.grid select { font: 600 13px/1.4 var(--font-body); padding: 5px 32px 5px 14px; border: 1.5px solid var(--color-ink); border-radius: var(--radius-pill); background-color: var(--color-surface); color: var(--color-ink); }
table.grid select:hover { background-color: var(--color-surface-muted); }
label.field input, label.field select, label.field textarea, #header select { width: 100%; padding: 8px 10px; font: inherit; color: var(--color-ink); background-color: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
label.field textarea { font-family: var(--font-mono); font-size: 13px; }
.buttons { margin-top: 16px; text-align: right; }

/* Searchable selects: Tom Select (vendored, see vendor/tom-select/README.md) dresses the native select, which stays in the
   form (visually hidden) and keeps the value. Same field look and caret as the selects above; the dropdown has a border,
   no shadow (the brand has none). */
.ts-wrapper { width: 100%; }
.ts-control { min-height: 41px; padding: 8px 32px 8px 10px; font: inherit; color: var(--color-ink); background-color: var(--color-surface); background-image: linear-gradient(45deg, transparent 50%, var(--color-ink) 50%), linear-gradient(135deg, var(--color-ink) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; border: 1px solid var(--color-border); border-radius: var(--radius-sm); box-shadow: none; cursor: pointer; }
.ts-wrapper.focus .ts-control { outline: 2px solid var(--color-ink); outline-offset: 2px; box-shadow: none; }
.ts-wrapper.single.input-active .ts-control { cursor: text; }
.ts-control > .item { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ts-control > input { font: inherit; color: var(--color-ink); }
.ts-wrapper.disabled .ts-control { opacity: 0.5; background-color: var(--color-surface-muted); cursor: not-allowed; }
.ts-wrapper.invalid .ts-control { border-color: var(--color-error); }
.ts-dropdown { margin: 4px 0 0; font: inherit; color: var(--color-ink); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); box-shadow: none; overflow: hidden; }
.ts-dropdown .ts-dropdown-content { max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
.ts-dropdown .option, .ts-dropdown .no-results { padding: 8px 10px; }
.ts-dropdown .no-results { color: var(--color-text-muted); }
.ts-dropdown .option.selected { font-weight: 600; }
.ts-dropdown .active, .ts-dropdown .option:hover { color: var(--color-ink); background-color: var(--color-surface-muted); }
.ts-dropdown [data-selectable] .highlight { background: none; font-weight: 700; }
.ts-dropdown .dropdown-input-wrap { padding: 8px; border-bottom: 1px solid var(--color-border); }
.ts-dropdown .dropdown-input:focus-visible { outline: none; border-color: var(--color-ink); }
.ts-dropdown .dropdown-input { width: 100%; padding: 6px 10px; font: inherit; color: var(--color-ink); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }

ul.cards { list-style: none; padding: 0; margin: 12px 0; }
ul.cards li { background: var(--color-surface); border: 1px solid var(--color-border); padding: 14px 16px; margin-bottom: 8px; border-radius: var(--radius-sm); }
/* A long URL shows as one line cut off with an ellipsis (the whole URL is in its title and still selectable and copyable). */
.url { display: block; max-width: 48ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Long slugs and references are cut off with an ellipsis like URLs (the whole text is in the title). */
.clip { display: block; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.page-head h1 { margin: 0.67em 0; min-width: 0; overflow-wrap: anywhere; }
.page-head button { margin: 0; }
.empty-state { margin-top: 12px; padding: 32px 16px; text-align: center; background: var(--color-surface); border: 1px dashed var(--color-border); border-radius: var(--radius-md); }
.empty-state p { margin: 4px 0; }
table.grid td.actions { text-align: right; white-space: nowrap; }
table.grid td.actions button { margin: 0; }
pre.details { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; font: 400 12px var(--font-mono); }

/* Releases, rollouts and updates. */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 20px; margin: 16px 0; }
.facts dt { font: 500 12px var(--font-mono); color: var(--color-text-muted); padding-top: 3px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.callout { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--color-warning-bg); color: var(--color-warning-text); }
.callout.bad { background: var(--color-error-bg); color: var(--color-error-text); }
.progress { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.progress .step { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 10px 14px; border-top-width: 4px; }
.progress .step strong { display: block; font: 700 24px var(--font-heading); }
.progress .step.healthy.has { border-top-color: var(--color-success); }
.progress .step.failed.has, .progress .step.rolled_back.has { border-top-color: var(--color-error); }
.progress .step.downloading.has, .progress .step.installing.has { border-top-color: var(--color-maintenance); }
fieldset.days { border: 0; padding: 0; margin: 12px 0; }
fieldset.days legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 4px; }
fieldset.days label, label.check { display: inline-flex; align-items: center; gap: 4px; margin-right: 12px; }
label.check { display: flex; margin: 12px 0; }
label.check.tight { margin-bottom: 4px; }
label.inline-filter { margin-left: 12px; }
.counts { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; }
.counts .failed, .counts .rolled_back { color: var(--color-error-text); }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0; }
label.inline-filter select { padding: 5px 10px; font: inherit; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background-color: var(--color-surface); }
ul.history { margin: 4px 0 0; padding-left: 18px; }
/* Site form: the editable list of extra URL parameters. */
div.field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
div.field { margin: 12px 0; }
.param-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.param-row input { width: 100%; padding: 8px 10px; font: inherit; color: var(--color-ink); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.param-row button { margin: 0; }
.note { margin: 12px 0; }
.note small { display: block; margin-bottom: 4px; overflow-wrap: anywhere; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 1100px) {
  /* Wide tables scroll sideways instead of squeezing their cells; cells keep a readable minimum width. */
  table.grid { display: block; overflow-x: auto; }
  table.grid td, table.grid th { overflow-wrap: anywhere; min-width: 80px; }
  table.grid .pill, table.grid button { white-space: nowrap; }
}
@media (max-width: 900px) {
  .shell { display: block; }
  #header { position: static; height: auto; overflow: visible; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 12px 24px; border-right: 0; border-bottom: 1px solid var(--color-border); }
  #header .brand { flex-direction: row; align-items: center; gap: 12px; }
  #header .picker { display: flex; align-items: center; gap: 8px; }
  #header .picker .eyebrow { margin: 0; }
  #header .picker select { width: auto; max-width: 220px; }
  #header .picker .ts-wrapper { width: 220px; max-width: 100%; }
  #header nav { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
  #header .nav-group { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
  #header .nav-group .eyebrow { margin: 0; }
  #header .account { margin-top: 0; margin-left: auto; padding-top: 0; border-top: 0; flex-direction: row; align-items: center; gap: 12px; }
  #notice { position: static; }
}
@media (max-width: 720px) {
  /* A table with .stack becomes one card per row on a phone: each cell names its column. */
  table.grid.stack { overflow: visible; background: none; border: 0; }
  table.grid.stack thead { display: none; }
  table.grid.stack tr { display: block; margin-bottom: 8px; padding: 6px 14px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
  table.grid.stack td { display: grid; grid-template-columns: 8.5em minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 0; min-width: 0; }
  table.grid.stack td[data-label]::before { content: attr(data-label); color: var(--color-text-muted); font-size: 13px; }
  table.grid.stack td .pill { justify-self: start; }
  table.grid.stack td.actions { display: block; text-align: left; }
  .clip { max-width: 100%; }
  .param-row { grid-template-columns: minmax(0, 1fr) auto; }
  .param-row input[name=paramName] { grid-column: 1 / -1; }
  #header, main, #notice { padding-left: 16px; padding-right: 16px; }
}

/* The caret needs room on the right in every select (the field and filter rules above reset the padding). */
label.field select, #header select, label.inline-filter select { padding-right: 32px; }
