/* Qsynapse Platform: the page layer on top of the Qsynapse design kit.

   base.html loads kit/fonts.css, kit/tokens.css and kit/components.css first. They are copied
   unchanged from qsynapse-site/design-kit (refresh with `make design-kit`; never edit them
   here). This file only adds what the kit leaves to each product: header, footer and page
   layout, forms, tables, notices and a few variants of kit components. Colours, fonts, radii
   and shadows are the kit's tokens.

   Where a kit colour pair measures below WCAG AA, the same hue is darkened just enough to pass,
   and tests/test_design_kit.py checks every ratio:
   - primary buttons: navy text on teal (5.3:1) instead of white (3.1:1);
   - status pills and notices: green #1c7d45 (4.6:1) and amber #9d5e00 (4.7:1) on the kit's
     tints, instead of --ok (3.9:1) and --warn (3.1:1);
   - input borders: #8a8a8a (3.4:1) instead of #ddd (1.4:1), so fields stay visible.

   Served from 'self' only (CSP): no inline styles, no external fonts. Logical properties
   throughout (margin-inline, padding-block ...), so an Arabic dir="rtl" version needs no second
   stylesheet. */

:root {
  --ok-text: #1c7d45;
  --warn-text: #9d5e00;
  --field-line: #8a8a8a;
  --on-navy: #b7c4d4;
  --on-navy-2: #8fa0b4;
}

/* ---------- 1. Base ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  min-block-size: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--grey);
}
.container {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--pad-x);
}
main a:not(.btn) {
  color: var(--teal-text);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
main a:not(.btn):hover {
  text-decoration-thickness: 2px;
}
strong {
  font-weight: 500;
  color: var(--ink);
}
code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
  color: var(--ink);
  background: var(--grey);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
}
.muted {
  color: var(--ink-3);
}
.note {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-3);
}
.visually-hidden {
  position: absolute !important;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  inset-inline-start: 16px;
  top: -100px;
  z-index: 100;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-float);
}
.skip-link:focus {
  top: 12px;
}

/* ---------- 2. Header and footer (the website's, adapted) ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-block-end: 1px solid var(--line);
}
.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
  min-height: var(--header-h);
  padding-block: 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand img {
  width: 36px;
  height: 36px;
}
.brand span {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.brand small {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-text);
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-inline-start: auto;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  padding-block: 10px 8px;
  border-block-end: 2px solid transparent;
}
.site-nav a:hover {
  color: var(--ink);
}
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-block-end-color: var(--teal);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.site-nav .site-nav__signout {
  display: none;
}
.site-footer {
  background: var(--navy);
  color: var(--on-navy-2);
  font-family: var(--font-ui);
  font-size: 13px;
  padding-block: 26px;
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 24px;
}
.site-footer p {
  color: var(--on-navy-2);
}
.site-footer .brand span {
  color: #fff;
  font-size: 16px;
}
.site-footer .brand img {
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 50%;
  padding: 3px;
}

/* ---------- 3. Page layout ---------- */
.page {
  flex: 1 0 auto;
  padding-block: 40px 72px;
}
.page > .container > * + * {
  margin-block-start: 20px;
}
.page-head .eyebrow {
  margin-block-end: 8px;
}
.page-head .row-title {
  margin-block-end: 6px;
}
.page-lead {
  max-width: 720px;
}
.card > * + * {
  margin-block-start: 12px;
}
.card h2 {
  font-size: 24px; /* the kit's card title (.card h3) */
  margin-block-end: 6px;
}
.card--narrow {
  max-width: 480px;
  margin-inline: auto;
}
.card--cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 32px;
}
.card--cta > * + * {
  margin-block-start: 0;
}
.card--cta p {
  max-width: 560px;
}
.card--cta .eyebrow {
  margin-block-end: 6px;
}
.auth-mark {
  width: 48px;
  height: 48px;
}

/* A navy band of kit .stat figures, like the website's stat band. */
.stat-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 28px 36px;
  background: var(--navy);
  border-radius: var(--radius-card);
  padding: 30px 32px;
}
.stat-band .label {
  color: var(--on-navy);
  margin-block-end: 12px;
}
.stat-band .stat {
  overflow-wrap: anywhere;
}
/* Units used of the monthly allowance, under the "Units used" figure. A <meter> draws the
   share without an inline width, which the CSP would refuse. */
.units-meter {
  display: block;
  inline-size: 100%;
  block-size: 8px;
  margin-block-start: 16px;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}
.units-meter::-webkit-meter-bar {
  block-size: 8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.16);
}
.units-meter::-webkit-meter-optimum-value,
.units-meter::-webkit-meter-suboptimum-value,
.units-meter::-webkit-meter-even-less-good-value {
  border-radius: var(--radius-pill);
  background: var(--teal);
}
.units-meter::-moz-meter-bar {
  border-radius: var(--radius-pill);
  background: var(--teal);
}

/* Cards side by side where there is room (dashboard, organization); a card alone fills the row. */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 20px;
  align-items: start;
}
.seat-count {
  font-family: var(--font-ui);
  font-size: 15px;
}

/* Rows of label and value, like the kit's report card lines. */
.summary-list {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
}
.summary-list > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-block: 12px;
  border-block-end: 1px solid var(--line);
}
.summary-list > div:last-child {
  border-block-end: 0;
  padding-block-end: 0;
}
.summary-list dt {
  color: var(--ink-3);
}
.summary-list dd {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
  text-align: end;
  font-variant-numeric: tabular-nums;
}
.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.link-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 24px;
  padding-block: 14px;
  border-block-end: 1px solid var(--line);
}
.link-list li:last-child {
  border-block-end: 0;
  padding-block-end: 0;
}
.link-list a {
  min-inline-size: 150px;
  font-family: var(--font-ui);
}
.link-list span {
  font-size: 14px;
  color: var(--ink-2);
}
.month-nav,
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.month-nav__current {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
}
.empty {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-3);
}

/* ---------- 4. Tables ---------- */
.table-wrap {
  position: relative; /* contains the absolutely positioned .visually-hidden labels in rows */
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
}
.table th {
  text-align: start;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  padding: 0 12px 10px;
  border-block-end: 1px solid var(--line);
}
.table td {
  padding: 12px;
  vertical-align: middle;
  border-block-end: 1px solid var(--line);
}
.table tbody tr:last-child td {
  border-block-end: 0;
}
.table th:first-child,
.table td:first-child {
  padding-inline-start: 0;
}
.table th:last-child,
.table td:last-child {
  padding-inline-end: 0;
}
.table .num {
  text-align: end;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- 5. Status pills and notices ---------- */
.status {
  white-space: nowrap;
}
.status--ok {
  color: var(--ok-text);
}
.status--warn {
  color: var(--warn-text);
}
.notice {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 16px;
  border: 1px solid;
  border-radius: 12px;
}
.notice--ok {
  background: var(--ok-soft);
  border-color: #bfe3cf;
  color: var(--ok-text);
}
.notice--risk {
  background: #fff7f7; /* the kit's finding card */
  border-color: #f3c6c6;
  color: var(--risk);
}
.notice--warn {
  background: #fffaf2; /* the kit's needs-review row */
  border-color: #f3d9a8;
  color: var(--warn-text);
}
.notice--info {
  background: var(--teal-soft);
  border-color: var(--teal-line);
  color: var(--teal-text);
}

/* ---------- 6. Forms ---------- */
.form {
  display: grid;
  gap: 18px;
}
.form-field {
  display: grid;
  gap: 8px;
}
.form-field > label {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.form-field .input {
  width: 100%;
}
.form-hint {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-3);
}
.input {
  border-color: var(--field-line);
}
.input[readonly] {
  background: var(--grey);
}
.input--code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235c5c5c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
}
[dir="rtl"] select.input {
  background-position: left 16px center;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
}
.form-row .form-field {
  flex: 1 1 240px;
}
.form-row .form-field--role {
  flex: 0 1 190px;
}
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.inline-form .input {
  font-size: 13px;
  padding-block: 8px;
  padding-inline-start: 14px;
}

/* ---------- 7. Buttons: kit .btn with platform variants ---------- */
.btn--primary {
  color: var(--navy); /* the kit's white is 3.1:1 on teal; navy is 5.3:1 */
}
.btn--small {
  padding: 8px 16px;
  font-size: 13px;
}
.btn--block {
  width: 100%;
  justify-content: center;
}
.btn--danger {
  background: #fff;
  color: var(--risk);
  border-color: #f3c6c6;
}
.btn--danger:hover {
  background: var(--risk-soft);
  border-color: var(--risk);
}

/* ---------- 8. Smaller screens and touch ---------- */
@media (max-width: 999px) {
  .site-nav {
    order: 3;
    flex-basis: 100%;
    flex-wrap: wrap;
    margin-inline-start: 0;
    gap: 0 22px;
  }
  .header-actions {
    margin-inline-start: auto;
  }
}
@media (max-width: 480px) {
  /* Room for the logo and "Open Medad" on one row: Sign out moves into the nav. */
  .brand small,
  .header-actions .btn--ghost {
    display: none;
  }
  .site-nav .site-nav__signout {
    display: inline-flex;
  }
}
/* .table--stack on phones: one block per row, each cell under its own small label (data-label),
   so the members table and its forms fit a 375 px screen without scrolling sideways. The header
   row stays for screen readers; numbers sit on the label's line. */
@media (max-width: 699px) {
  .table--stack thead {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .table--stack,
  .table--stack tbody,
  .table--stack tr,
  .table--stack td {
    display: block;
  }
  .table--stack tr {
    padding-block: 10px;
    border-block-end: 1px solid var(--line);
  }
  .table--stack tbody tr:first-child {
    padding-block-start: 0;
  }
  .table--stack tbody tr:last-child {
    border-block-end: 0;
    padding-block-end: 0;
  }
  .table--stack td,
  .table--stack td:first-child,
  .table--stack td:last-child {
    padding: 4px 0;
    border-block-end: 0;
    overflow-wrap: anywhere;
  }
  .table--stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-block-end: 2px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-3);
  }
  .table--stack td.num {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
  }
  .table--stack td.num::before {
    margin-block-end: 0;
  }
}
@media (max-width: 809px) {
  :root {
    --pad-x: 20px;
  }
  .site-header {
    position: static;
  }
  .page {
    padding-block: 28px 56px;
  }
  .card {
    padding: 22px 20px;
  }
  .card h2 {
    font-size: 22px;
  }
  .stat-band {
    padding: 24px 20px;
  }
}
@media (pointer: coarse) {
  .btn,
  .input,
  .site-nav a {
    min-block-size: 44px;
  }
}

/* ---------- 9. The staff console (/staff) ---------- */
/* A navy header on every console page, so a staff page is never mistaken for a customer's
   (STAFF-SPEC §1). The logo sits on a white disc, as in the footer. */
.site-header--staff {
  background: var(--navy);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-block-end-color: var(--navy);
}
.site-header--staff .brand span {
  color: #fff;
}
.site-header--staff .brand img {
  background: #fff;
  border-radius: 50%;
  padding: 3px;
}
.staff-tag {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy); /* 5.3:1 on teal, like the primary buttons */
  background: var(--teal);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.site-header--staff .site-nav a {
  color: var(--on-navy);
}
.site-header--staff .site-nav a:hover,
.site-header--staff .site-nav a[aria-current="page"] {
  color: #fff;
}
.site-header--staff :focus-visible {
  outline-color: #fff;
  box-shadow: 0 0 0 3px var(--navy);
}
.staff-who {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--on-navy);
  overflow-wrap: anywhere;
}
.header-actions .inline-form {
  flex-wrap: nowrap;
}

/* The overview's four key figures on one row at desktop widths. */
.stat-band--compact {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
}

/* Values that may be long (emails, links, keys) wrap instead of widening the page. */
.summary-list dd {
  min-inline-size: 0;
  overflow-wrap: anywhere;
}
.summary-list dd .status {
  white-space: normal;
}
/* break-word, not anywhere: a table column keeps the width of its longest word (an email) where
   there is room, and breaks it only where there is not (a phone). */
.wrap-long {
  overflow-wrap: break-word;
}

/* The console's forms: several short fields side by side where there is room. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 16px;
  align-items: start; /* labels on one line; a field's hint hangs below it */
}
.form-step {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}
.form-step legend {
  padding: 0;
  margin-block-end: 12px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-text);
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
}
input.input--check {
  flex: none;
  inline-size: 20px;
  block-size: 20px;
  min-block-size: 20px; /* not the 44 px of touch-sized fields: the label is the target */
  padding: 0;
  margin: 0;
  accent-color: var(--teal-text);
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}
.card--danger {
  border-color: #f3c6c6;
}
/* A heading part-way down a card starts a new part of it. */
.card > h3:not(:first-child) {
  margin-block-start: 28px;
}

/* In-page links to a firm's sections. */
.section-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-ui);
  font-size: 14px;
}

/* The two-step key on the setup page: the QR code, the key to type by hand. */
.qr {
  inline-size: 200px;
  block-size: 200px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
}
.secret-text {
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* Rows of a table the page may cut short. */
.table .detail {
  font-size: 13px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.table .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.table td.wide {
  min-inline-size: 220px;
}
.table td.when {
  white-space: nowrap; /* '2026-09-30 03:53' reads as one value */
}

@media (max-width: 809px) {
  .staff-who {
    display: none;
  }
  .table td.wide {
    min-inline-size: 0;
  }
}
