/* Colours follow the Tolkie brand palette (docs/TOLKIE-BRAND.md in the website repo). */
:root {
  --blue: #123686;
  --blue-light: #e9f0ff;
  --blue-dark: #222f4b;
  --green: #26734f;
  --red: #a6271a;
  --red-light: #ffcdc8;
  --green-light: #ddf5ea;
  --warning-light: #fff4d6;
  --warning: #b69732;
  --text: #1c2233;
  --muted: #5b6375;
  --border: #d5dae5;
  --surface: #ffffff;
  --background: #f6f7fb;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
a { color: var(--blue); }
code { font-size: 0.9em; }

.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px;
  padding: 12px 24px; background: var(--blue-dark); color: #fff;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar nav { display: flex; gap: 16px; flex-wrap: wrap; }
.topbar .brand { font-weight: 700; }
.topbar .logout { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.topbar .muted { color: #c8d2ea; }
.topbar .link { color: #fff; }

main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { margin: 0 0 16px; font-size: 1.6rem; }
.narrow { max-width: 640px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.muted { color: var(--muted); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.tile-number { font-size: 2rem; font-weight: 700; color: var(--blue); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--blue-light); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.field label { font-weight: 600; }
input[type="text"], input[type="url"], input[type="password"], input[type="number"], input[type="file"], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; width: 100%;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, .table-wrap:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 2px;
}
.topbar a:focus-visible, .topbar button:focus-visible { outline-color: #93b5ff; }

button, .button {
  font: inherit; cursor: pointer; display: inline-block; padding: 8px 16px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
}
button.primary, .button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.danger { background: var(--red); border-color: var(--red); color: #fff; }
button.small { padding: 2px 10px; font-size: 0.9em; }
button.link { background: none; border: 0; padding: 0; text-decoration: underline; }
form button + a { margin-left: 12px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.helptext { color: var(--muted); font-size: 0.9em; }
.errorlist { list-style: none; margin: 0; padding: 0; color: var(--red); font-size: 0.9em; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.messages:empty { margin: 0; }
button, .button, td a { min-height: 24px; }
.error { color: var(--red); }
.ok { color: var(--green); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.message { padding: 10px 14px; border-radius: 6px; background: var(--blue-light); margin-bottom: 8px; }
.message.success { background: var(--green-light); }
.message.error { background: var(--red-light); color: var(--text); }

main.wide { max-width: none; }
h2 { font-size: 1.2rem; margin: 24px 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
form.inline { display: inline; }
.narrow-left { max-width: 640px; margin-top: 24px; }
fieldset.group { border: 1px solid var(--border); border-radius: 6px; padding: 12px 16px 4px; margin: 0 0 16px; }
fieldset.group legend { font-weight: 600; padding: 0 4px; }
fieldset.group .helptext { display: block; margin: 0 0 12px; }
progress { width: 100%; height: 12px; accent-color: var(--blue); }
.status { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--blue-light); font-size: 0.9em; }
.status-completed { background: var(--green-light); }
.status-failed, .status-cancelled { background: var(--red-light); }
.steps dt { font-weight: 600; margin-top: 8px; }
.steps dd { margin: 0; }
.steps pre { white-space: pre-wrap; word-break: break-word; font-size: 0.85em; background: var(--background); padding: 8px; border-radius: 6px; max-height: 240px; overflow: auto; }
details summary { cursor: pointer; color: var(--blue); }
.error-detail { margin-top: 4px; font-size: 0.85em; color: var(--muted); }
.error-detail code { display: block; white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
table.compare td.differs { background: var(--warning-light); box-shadow: inset 3px 0 0 var(--warning); }
.differs-mark { display: inline-block; font-size: 0.85em; font-weight: 600; color: var(--blue-dark); }

@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .topbar .logout { margin-left: 0; }
}
