/* Harbourline console — design/design-system.yaml (harbourline-console).
 *
 * A plain, dense operations console: a table you can read at arm's length, one accent
 * colour, no decoration. The tokens below are the design system's, verbatim, as custom
 * properties; the three primitives — Table, StatePill, ActionButton — are the classes of
 * the same name further down. dd-one-accent: blue for the primary action and links; state
 * colours only on the state word, and nowhere else on the page.
 */

:root {
  /* typography */
  --font-sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Menlo', 'Consolas', 'DejaVu Sans Mono', monospace; /* loan numbers and dates */
  --size-base: 15px;
  --size-small: 13px;
  --size-h1: 24px;
  --size-h2: 18px;
  --weight-normal: 400;
  --weight-semibold: 600;

  /* colours — light, the only mode */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #d9dde3;
  --text: #1b1f24;
  --muted: #5b6470;
  --accent: #1f5fbf;
  --ready: #1e7f4f;
  --held: #b0611a;

  /* spacing, px */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
}

/* ---- base ------------------------------------------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font: var(--weight-normal) var(--size-base) / 1.4 var(--font-sans);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
}

a {
  color: var(--accent);
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: var(--size-small);
}

h1,
h2,
h3 {
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  margin: 0 0 var(--space-sm);
}

h1 {
  font-size: var(--size-h1);
}

h2 {
  font-size: var(--size-h2);
}

h3 {
  font-size: var(--size-base);
}

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

.small {
  font-size: var(--size-small);
}

[hidden] {
  display: none !important;
}

/* ---- masthead -------------------------------------------------------------------------- */

.masthead {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-sm) var(--space-lg);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.masthead__brand {
  color: var(--text);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

.masthead__nav a {
  margin-right: var(--space-md);
}

.masthead__nav a[aria-current='page'] {
  color: var(--text);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

.masthead__session {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-left: auto;
  font-size: var(--size-small);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ---- page ------------------------------------------------------------------------------ */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.page__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-md);
}

.page__title {
  margin-bottom: var(--space-md);
}

.page__title .mono {
  font-size: inherit;
}

.crumbs {
  margin: 0 0 var(--space-sm);
  font-size: var(--size-small);
}

.panel {
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.panel--narrow {
  max-width: 420px;
  margin: var(--space-lg) auto;
}

.notice {
  margin: 0 0 var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}

.loading {
  position: fixed;
  right: var(--space-md);
  bottom: var(--space-md);
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--size-small);
}

.empty {
  margin: 0;
  padding: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
}

/* ---- summary — the counts per state across the top of the queue ------------------------ */

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.summary__item {
  min-width: 104px;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.summary__count {
  display: block;
  font-size: var(--size-h1);
  font-weight: var(--weight-semibold);
  line-height: 1.1;
}

/* ---- Table primitive — header row sticky, one row per case ----------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
}

.table th,
.table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
  color: var(--muted);
  font-size: var(--size-small);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: var(--bg);
}

/* ---- StatePill primitive — ready in green, held in amber, the rest in muted text -------- */

.state-pill {
  color: var(--muted);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.state-pill--ready {
  color: var(--ready);
}

.state-pill--held {
  color: var(--held);
}

/* ---- ActionButton primitive — one per Action; disabled with the reason when refused ---- */

.action-button {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
}

.action-button--primary {
  background: var(--accent);
  color: var(--surface);
}

.action-button:disabled,
.action-button[aria-disabled='true'] {
  border-color: var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: not-allowed;
}

.action-button:focus-visible,
.link-button:focus-visible,
.field input:focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.action__reason {
  margin: var(--space-xs) 0 0;
  color: var(--muted);
  font-size: var(--size-small);
}

.action__reason code {
  display: block;
  margin-top: var(--space-xs);
}

/* ---- forms ----------------------------------------------------------------------------- */

.form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-md);
}

.form--stack {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-sm);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-size: var(--size-small);
}

.field--wide {
  flex: 1 1 100%;
}

.field__label {
  color: var(--muted);
}

.field input,
.field select {
  min-width: 12em;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--size-base);
}

.field input:disabled,
.field select:disabled {
  background: var(--bg);
  color: var(--muted);
}

.field__error {
  color: var(--text);
  font-weight: var(--weight-semibold);
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--size-small);
}

/* ---- problems -------------------------------------------------------------------------- */
/* SHIPYARD-GAP: the design system has no error or danger colour, and dd-one-accent keeps
 * colour off everything but the state word — chose: a refusal is typeset, not coloured:
 * semibold text on the surface with a dark left rule. */

.problem {
  flex: 1 1 100%;
  margin: var(--space-sm) 0 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text);
}

.problem--load {
  padding: var(--space-lg);
}

.problem__message {
  margin: 0;
  font-weight: var(--weight-semibold);
}

.problem__criterion {
  margin: var(--space-xs) 0 0;
  color: var(--muted);
  font-size: var(--size-small);
}

/* ---- case ------------------------------------------------------------------------------ */

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-xs) var(--space-md);
  margin: 0;
}

.facts dt {
  color: var(--muted);
  font-size: var(--size-small);
  line-height: calc(var(--size-base) * 1.4);
}

.facts dd {
  margin: 0;
}

.required {
  margin: 0;
  padding-left: var(--space-lg);
}

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-md);
}

.action {
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.action--refused {
  background: var(--bg);
}

.action__title {
  margin-bottom: var(--space-xs);
}

@media (max-width: 720px) {
  .page {
    padding: var(--space-md);
  }

  .facts {
    grid-template-columns: 1fr;
    gap: 0 0;
  }

  .facts dd {
    margin-bottom: var(--space-sm);
  }
}
