/* Elements, controls and tables. Lifted from the prototype so the built app
   matches it rather than resembling it. */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 21px;
  color: var(--n-primary);
  background: var(--n-lighter);
  -webkit-font-smoothing: antialiased;
}

/* The hidden attribute, made to mean it.
 *
 * A browser hides [hidden] with display:none at the lowest precedence, so any
 * class rule that sets display beats it and the element stays on screen. That
 * has now cost two bugs: an error bar that rendered as an empty coloured block
 * and could never show its message, and a picker whose search box filtered
 * nothing because .pickrow is display:flex. Important, because the whole point
 * is to outrank whatever display a class happens to set. */
[hidden] {
  display: none !important;
}


body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 21px;
  color: var(--n-primary);
  background: var(--n-lighter);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

:focus-visible {
  outline: 2px solid var(--n-dark);
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

svg {
  display: block;
}


/* The heading typed under a ticked duty in a template. Indented, so it reads
   as belonging to the duty above it rather than as a duty of its own. */
.heading-above {
  flex-basis: 100%;
  margin: 6px 0 0 26px;
  width: calc(100% - 26px);
  font-size: 13px;
}

/* A duty's row wraps so its heading sits underneath, and the heading only
   shows once the duty is ticked: it has no meaning for a duty not included. */
.chk:has(.heading-above) {
  flex-wrap: wrap;
}

.chk:has(input[type="checkbox"]:not(:checked)) .heading-above {
  display: none;
}

/* A picker you can type into ------------------------------------------------ */
/* A plain select cannot be searched, and a branch with two hundred members is
   a dropdown nobody can find anybody in. Typing filters these rows. */

.picklist {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--n-light);
  border-radius: 2px;
  margin-bottom: 8px;
}

.pickrow {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--n-light);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.pickrow:last-child {
  border-bottom: none;
}

.pickrow:hover {
  background: var(--n-lighter, rgb(0 0 0 / 4%));
}

/* The one that is picked, which survives typing and scrolling. */
.pickrow.on {
  background: var(--err-bg);
  font-weight: 600;
}

.pickrow .m1 {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pickrow .m1 span {
  font-size: 12px;
  color: var(--n-secondary);
  font-weight: 400;
}

/* Headings ---------------------------------------------------------------- */

.ttl {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--n-dark);
}

.sub {
  font-size: 14px;
  color: var(--n-secondary);
  margin-top: 4px;
}

.head {
  margin-bottom: 20px;
}

/* Buttons ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--n-quaternary);
  background: var(--white);
  color: var(--n-primary);
  transition: background 120ms, border-color 120ms;
}

/* An icon in a button is a glyph beside the words, not an illustration. */
.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn:hover {
  background: var(--n-lighter);
  border-color: var(--n-tertiary);
}

.btn-pri {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(165 18 37 / 25%);
}

.btn-pri:hover {
  background: var(--brand-dk);
  border-color: var(--brand-dk);
}

.btn[disabled] {
  background: var(--n-lighter);
  border-color: var(--n-light);
  color: var(--n-tertiary);
  cursor: default;
}

.btn-sm {
  min-height: 28px;
  padding: 0 12px;
  font-size: 13px;
}

.linkbtn {
  color: var(--brand);
  font-size: 14px;
  padding: 4px 8px;
  border-radius: var(--radius);
}

.linkbtn:hover {
  background: var(--n-lighter);
  text-decoration: underline;
}

/* For an action that repeats on every row of a long list. Four brand-coloured
   links times seventeen rows is a wall of red, and the reordering arrows are
   the least important two of the four. */
.linkbtn.quiet {
  color: var(--n-secondary);
  padding: 4px 6px;
}

.linkbtn.quiet:hover {
  color: var(--n-primary);
  text-decoration: none;
}

.linkbtn[disabled] {
  color: var(--n-light);
  cursor: default;
}

.linkbtn[disabled]:hover {
  background: none;
  text-decoration: none;
}

/* Fields ------------------------------------------------------------------ */

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--n-quaternary);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color 120ms, box-shadow 120ms;
}

/* Without this a search box keeps the browser's own styling: a fixed narrow
   width that ignores the rule above, a different font, and on some browsers a
   pill shape and a cancel button of its own. It looked like a field from a
   different application sitting in the middle of ours. */
input[type="search"] {
  appearance: none;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  appearance: none;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--n-tertiary);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(165 18 37 / 14%);
}

input[disabled] {
  background: var(--n-lighter);
  color: var(--n-secondary);
  border-color: var(--n-light);
}

.fld {
  margin-bottom: 16px;
}

.fld label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--n-primary);
}

/* Say which fields are needed before the form is submitted, not after. The
   asterisk is decoration, so it is hidden from a screen reader, which gets
   aria-required on the input instead. */
.fld label.req::after {
  content: " *";
  color: var(--err);
  font-weight: 400;
}

.fld .hint {
  font-size: 12px;
  color: var(--n-secondary);
  margin-top: 4px;
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.chk {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 20px;
  margin-bottom: 10px;
}

/* Checkboxes only: a text box that shares the row, as a template's heading
   does, was being squashed to 16px and read as a toggle. */
.chk input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  flex: none;
  margin-top: 2px;
  accent-color: var(--brand);
}

/* Messages ---------------------------------------------------------------- */

.msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 20px;
  margin-bottom: 12px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--sh2);
}

.msg svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 2px;
  stroke: var(--n-secondary);
}

.msg.warn {
  background: var(--warn-bg);
  box-shadow: none;
}

.msg.warn svg {
  stroke: var(--warn-ink);
}

.msg.error {
  background: var(--err-bg);
  box-shadow: none;
}

.msg.error svg {
  stroke: var(--err);
}

.msg .act {
  margin-left: auto;
  flex: none;
  padding-left: 8px;
}

.msg a {
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.msg a:hover {
  text-decoration: underline;
}

/* Cards and tables -------------------------------------------------------- */

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--sh2);
}

.card-hd {
  padding: 18px 20px 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.card-hd h2 {
  font-size: 16px;
  font-weight: 650;
  color: var(--n-dark);
}

.card-hd .spacer,
.bar .spacer {
  margin-left: auto;
}

.card-bd {
  padding: 12px 20px 20px;
}

.grid {
  width: 100%;
  border-collapse: collapse;
}

.grid th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--n-tertiary);
  padding: 0 16px;
  height: 40px;
  border-bottom: 1px solid var(--n-light);
  white-space: nowrap;
}

.grid td {
  padding: 0 16px;
  height: var(--row-height);
  border-bottom: 1px solid var(--n-lighter);
  vertical-align: middle;
}

.grid tbody tr:hover {
  background: var(--n-lighter-alt);
}

.grid tbody tr:last-child td {
  border-bottom: none;
}

.g-strong {
  font-weight: 600;
}

.g-dim {
  color: var(--n-secondary);
  font-size: 12px;
}

.g-num {
  font-variant-numeric: tabular-nums;
}

.g-act {
  text-align: right;
  white-space: nowrap;
}

.tablewrap {
  overflow-x: auto;
}

/* Status is a coloured dot plus a word, never a pill. Section 10. */

.stt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.dot-ok {
  background: var(--ok);
}

.dot-off {
  background: var(--n-tertiary);
}

.dot-warn {
  background: var(--warn-dot);
}

/* Empty states and code blocks -------------------------------------------- */

.blank {
  padding: 48px 24px;
  text-align: center;
}

.blank h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.blank p {
  font-size: 14px;
  color: var(--n-secondary);
  margin-bottom: 16px;
}

.code {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 18px;
  background: var(--n-lighter);
  border: 1px solid var(--n-light);
  border-radius: var(--radius);
  padding: 8px 10px;
  white-space: pre-wrap;
  max-height: 140px;
  overflow: auto;
  word-break: break-all;
}
