/* SPDX-FileCopyrightText: chargebyte GmbH */
/* SPDX-License-Identifier: LicenseRef-chargebyte-proprietary */
/* P8.1 design Y16-Y22 (D017): the base stylesheet of every page. Colours come only from the
   brand tokens of /branding/*.css (light and dark), except the .qr white box (Y22). Hover and
   active change only a border or keep the surface (ruling C11); only --tk-text stands on
   --tk-surface-2. No web font, no image, no animation. */

/* --- Y16: scale ---------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;
  --tk-radius: 10px;
  --tk-space-1: 0.25rem;
  --tk-space-2: 0.5rem;
  --tk-space-3: 0.75rem;
  --tk-space-4: 1rem;
  --tk-space-5: 1.5rem;
  --tk-space-6: 2rem;
  --tk-space-7: 3rem;
  --tk-width: 72rem;
  --tk-font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Liberation Sans", Arial,
    sans-serif;
  --tk-mono: ui-monospace, "SFMono-Regular", "DejaVu Sans Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  background-color: var(--tk-bg);
  color: var(--tk-text);
  font-family: var(--tk-font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* --- typography ---------------------------------------------------------------------------- */
h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.25;
}
h1 {
  font-size: 1.75rem;
  margin: 0 0 var(--tk-space-5);
}
h2 {
  font-size: 1.375rem;
  margin: var(--tk-space-6) 0 var(--tk-space-3);
}
h3 {
  font-size: 1.125rem;
  margin: var(--tk-space-5) 0 var(--tk-space-2);
}
p,
ul,
ol {
  margin: 0 0 var(--tk-space-4);
}
ul,
ol {
  padding-left: var(--tk-space-5);
}
li + li {
  margin-top: var(--tk-space-1);
}
small {
  font-size: 0.875rem;
}
a {
  color: var(--tk-accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover {
  text-decoration-thickness: 2px;
}
code,
pre {
  font-family: var(--tk-mono);
}
code {
  font-size: 0.875em;
  overflow-wrap: anywhere;
}
pre {
  margin: 0 0 var(--tk-space-4);
  padding: var(--tk-space-3) var(--tk-space-4);
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--tk-text);
  background-color: var(--tk-surface-2);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
}
pre code {
  font-size: inherit;
  overflow-wrap: normal;
}

/* --- Y17: header and navigation -------------------------------------------------------------- */
.site-header {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  column-gap: var(--tk-space-4);
  padding: var(--tk-space-3) max(var(--tk-space-4), calc((100% - var(--tk-width)) / 2 + var(--tk-space-4)));
  background-color: var(--tk-surface);
  border-top: 4px solid var(--tk-accent);
  border-bottom: 1px solid var(--tk-border);
}
.site-header:has(> nav) {
  padding-bottom: 0;
}
.site-brand {
  position: relative;
  z-index: 1;
  grid-column: 1;
  grid-row: 1;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--tk-space-3);
  min-width: 0;
  min-height: 2.5rem;
  color: var(--tk-text);
  text-decoration: none;
}
.brand-icon {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
}
.brand-banner {
  display: block;
}
.brand-banner img {
  display: block;
  height: 28px;
  width: auto;
  max-width: 20rem;
  object-fit: contain;
  object-position: left center;
}
.brand-name {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand-banner + .brand-name {
  padding-left: var(--tk-space-3);
  border-left: 1px solid var(--tk-border-strong);
}
.site-header nav {
  display: grid;
  grid-column: 1 / -1;
  grid-row: 1 / span 2;
  grid-template-columns: subgrid;
  grid-template-rows: subgrid;
  align-items: center;
  font-size: 0.9375rem;
}
.site-header nav p {
  grid-column: 3;
  grid-row: 1;
  min-width: 0;
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
  color: var(--tk-muted);
  font-size: 0.875rem;
}
.site-header nav ul {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  margin: var(--tk-space-2) 0 0 calc(-1 * var(--tk-space-3));
  padding: 0;
  list-style: none;
}
.site-header nav li + li {
  margin-top: 0;
}
.site-header nav li a {
  display: block;
  padding: var(--tk-space-2) var(--tk-space-3);
  color: var(--tk-text);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.site-header nav li a:hover {
  border-bottom-color: var(--tk-border-strong);
}
.site-header nav li a[aria-current="page"] {
  font-weight: 600;
  border-bottom-color: var(--tk-accent-ink);
}
.site-header nav form {
  grid-column: 4;
  grid-row: 1;
  margin: 0;
}
/* P8.4 design H12 (D018): the "?" link to the page's guide section, last in the first row */
.help-link {
  position: relative;
  z-index: 1;
  grid-column: -2;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: var(--tk-text);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--tk-border-strong);
  border-radius: var(--tk-radius);
}
.help-link:hover {
  border-color: var(--tk-accent-ink);
}
@media (max-width: 40rem) {
  .site-header {
    grid-template-columns: auto 1fr auto auto;
  }
  .site-header nav {
    grid-row: 1 / span 3;
  }
  .site-header nav p {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: var(--tk-space-2);
    text-align: left;
  }
  .site-header nav form {
    grid-column: 3;
  }
  .site-header nav ul {
    grid-row: 3;
  }
}
@media (max-width: 24rem) {
  .site-header {
    column-gap: var(--tk-space-3);
  }
  .site-brand {
    gap: var(--tk-space-2);
  }
  .brand-banner + .brand-name {
    padding-left: 0;
    border-left: 0;
  }
}
.site-header nav button {
  min-height: 2rem;
  padding: 0 var(--tk-space-3);
  font-size: 0.875rem;
}

/* --- Y16: content width, the narrow card of the auth and OAuth pages ------------------------ */
main {
  display: block;
  max-width: var(--tk-width);
  margin: 0 auto;
  padding: var(--tk-space-6) var(--tk-space-4) var(--tk-space-7);
  overflow-x: auto;
}
main.narrow {
  width: calc(100% - 2 * var(--tk-space-4));
  max-width: 30rem;
  margin: var(--tk-space-7) auto;
  padding: var(--tk-space-6);
  background-color: var(--tk-surface);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
}
main > :last-child {
  margin-bottom: 0;
}
.narrow h1 {
  font-size: 1.5rem;
}

/* --- Y17: buttons ---------------------------------------------------------------------------- */
button,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--tk-space-2);
  min-height: 2.5rem;
  margin: 0;
  padding: 0 var(--tk-space-4);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--tk-text);
  background-color: var(--tk-surface);
  border: 1px solid var(--tk-border-strong);
  border-radius: var(--tk-radius);
  text-decoration: none;
  cursor: pointer;
}
button:hover,
a.button:hover {
  border-color: var(--tk-text);
}
button:active,
a.button:active {
  border-color: var(--tk-text);
}
.primary {
  color: var(--tk-on-accent);
  background-color: var(--tk-accent);
  border-color: var(--tk-accent-ink);
  font-weight: 600;
}
.danger {
  color: var(--tk-danger);
  border-color: var(--tk-danger);
}
.danger:hover,
.danger:active {
  border-color: var(--tk-danger);
  text-decoration: underline;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
button:disabled:hover {
  border-color: var(--tk-border-strong);
}
.primary:disabled:hover {
  border-color: var(--tk-accent-ink);
}
p > button + button,
p > a.button + a.button {
  margin-left: var(--tk-space-2);
}

/* --- Y17: forms ------------------------------------------------------------------------------ */
input,
select,
textarea {
  font: inherit;
  color: var(--tk-text);
  accent-color: var(--tk-accent);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  min-height: 2.5rem;
  max-width: 100%;
  padding: 0 var(--tk-space-3);
  background-color: var(--tk-bg);
  border: 1px solid var(--tk-border-strong);
  border-radius: var(--tk-radius);
}
textarea {
  padding: var(--tk-space-2) var(--tk-space-3);
}
textarea {
  width: 100%;
}
/* P8.3 N14: the file field is its button and the file name, no text-field box around them */
input[type="file"] {
  min-height: 2.5rem;
  max-width: 100%;
  padding: 0;
  background: none;
  border: 0;
}
input[type="file"]::file-selector-button {
  min-height: 2.5rem;
  margin-right: var(--tk-space-3);
  padding: 0 var(--tk-space-4);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--tk-text);
  background-color: var(--tk-surface);
  border: 1px solid var(--tk-border-strong);
  border-radius: var(--tk-radius);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover {
  border-color: var(--tk-text);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover,
select:hover,
textarea:hover {
  border-color: var(--tk-text);
}
input[type="checkbox"],
input[type="radio"] {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0 var(--tk-space-2) 0 0;
  vertical-align: -0.2em;
}
label {
  overflow-wrap: anywhere;
}
form > p,
fieldset > p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--tk-space-2) var(--tk-space-3);
}
form > p > label,
fieldset > p > label {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--tk-space-2);
}
form > p > label:has(> input[type="checkbox"]),
form > p > label:has(> input[type="radio"]),
fieldset > p > label:has(> input[type="checkbox"]),
fieldset > p > label:has(> input[type="radio"]) {
  display: block;
}
.narrow form > p > label:has(> input:not([type="checkbox"]):not([type="radio"])) {
  display: grid;
  width: 100%;
  gap: var(--tk-space-1);
  font-weight: 500;
}
.narrow input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%;
}
.narrow form > p:last-child {
  margin-top: var(--tk-space-5);
}
.narrow form:last-child > p:last-child {
  margin-bottom: 0;
}
fieldset {
  margin: 0 0 var(--tk-space-4);
  padding: var(--tk-space-3) var(--tk-space-4) var(--tk-space-1);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
}
legend {
  padding: 0 var(--tk-space-1);
  font-weight: 600;
}
fieldset p {
  margin-bottom: var(--tk-space-2);
}

/* --- Y17: tables ----------------------------------------------------------------------------- */
table {
  width: 100%;
  margin: 0 0 var(--tk-space-5);
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
  font-size: 0.9375rem;
}
caption {
  caption-side: top;
  padding: 0 0 var(--tk-space-2);
  text-align: left;
  color: var(--tk-muted);
  font-size: 0.875rem;
}
th,
td {
  padding: var(--tk-space-2) var(--tk-space-3);
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
  border-bottom: 1px solid var(--tk-border);
}
thead th {
  color: var(--tk-text);
  background-color: var(--tk-surface-2);
  font-size: 0.8125rem;
  font-weight: 600;
  overflow-wrap: normal;
  white-space: nowrap;
}
thead th:first-child {
  border-top-left-radius: var(--tk-radius);
}
thead th:last-child {
  border-top-right-radius: var(--tk-radius);
}
tbody tr:last-child > * {
  border-bottom: 0;
}
/* §11: break-word on a cell does not lower its min-content; untrusted text (always in bdi) and
   ids (code) may break anywhere, so a long unbroken string cannot widen the table */
td bdi,
td code {
  overflow-wrap: anywhere;
}
td code {
  font-size: 0.8125rem;
}
td time {
  white-space: nowrap;
}
/* untrusted text (a serial, a description, a name) keeps a readable width before it breaks */
td:has(> bdi:not(:empty)),
td:has(> a > bdi) {
  min-width: 9rem;
}
/* §11: a table of eight or more columns (the closed requests) cannot fit 1024px with one-line
   dates, and on a phone no table fits: such a table scrolls itself, so main and the header keep
   their width. As a block box the table draws its frame on the edge cells (the caption stays
   outside it). */
main table:has(> thead > tr > th:nth-child(8)) {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border: 0;
}
main table:has(> thead > tr > th:nth-child(8)) :is(th, td):first-child {
  border-left: 1px solid var(--tk-border);
}
main table:has(> thead > tr > th:nth-child(8)) :is(th, td):last-child {
  border-right: 1px solid var(--tk-border);
}
main table:has(> thead > tr > th:nth-child(8)) thead th {
  border-top: 1px solid var(--tk-border);
}
main table:has(> thead > tr > th:nth-child(8)) tbody tr:last-child > * {
  border-bottom: 1px solid var(--tk-border);
}
main table:has(> thead > tr > th:nth-child(8)) tbody tr:last-child > :first-child {
  border-bottom-left-radius: var(--tk-radius);
}
main table:has(> thead > tr > th:nth-child(8)) tbody tr:last-child > :last-child {
  border-bottom-right-radius: var(--tk-radius);
}
@media (max-width: 40rem) {
  main table {
    display: block;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    border: 0;
  }
  main table :is(th, td):first-child {
    border-left: 1px solid var(--tk-border);
  }
  main table :is(th, td):last-child {
    border-right: 1px solid var(--tk-border);
  }
  main table thead th {
    border-top: 1px solid var(--tk-border);
  }
  main table tbody tr:last-child > * {
    border-bottom: 1px solid var(--tk-border);
  }
  main table tbody tr:last-child > :first-child {
    border-bottom-left-radius: var(--tk-radius);
  }
  main table tbody tr:last-child > :last-child {
    border-bottom-right-radius: var(--tk-radius);
  }
  /* the table scrolls anyway: a description gets lines of a readable length */
  td:has(> bdi:not(:empty)) {
    min-width: 14rem;
  }
}
td form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--tk-space-2);
  margin: 0;
}
td form + form {
  margin-top: var(--tk-space-2);
}
td form label {
  font-size: 0.875rem;
}
td button {
  min-height: 2.25rem;
  padding: 0 var(--tk-space-3);
  font-size: 0.875rem;
}
td ul {
  margin: 0;
  padding-left: var(--tk-space-4);
}

/* --- Y17: the dl card, notices, badges, the QR box ----------------------------------------- */
main dl {
  display: grid;
  grid-template-columns: minmax(8rem, max-content) 1fr;
  gap: var(--tk-space-2) var(--tk-space-5);
  margin: 0 0 var(--tk-space-5);
  padding: var(--tk-space-4) var(--tk-space-5);
  background-color: var(--tk-surface);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
}
dt {
  color: var(--tk-muted);
  font-weight: 500;
}
dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.notice,
.notice-danger {
  padding: var(--tk-space-3) var(--tk-space-4);
  color: var(--tk-text);
  background-color: var(--tk-surface);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
}
.notice {
  border-left: 4px solid var(--tk-accent-ink);
}
.notice-danger {
  border-left: 4px solid var(--tk-danger);
}
.narrow .notice,
.narrow .notice-danger {
  background-color: var(--tk-bg);
}
.badge {
  display: inline-block;
  padding: 0 var(--tk-space-2);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.5rem;
  white-space: nowrap;
  color: var(--tk-text);
  background-color: var(--tk-surface-2);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
}
/* content-box: the SVG has a fixed width and height and no viewBox, so under the global
   border-box the padding would come out of the code and clip its right and bottom edge
   (S15: the finder pattern and quiet zone were cut, phones could not scan it). For the same
   reason never give it a width or max-width: a smaller box crops the code, it does not scale it. */
.qr svg {
  display: block;
  box-sizing: content-box;
  background-color: #fff;
  padding: var(--tk-space-3);
  border-radius: var(--tk-radius);
}

/* --- Y18: focus, forced colours ------------------------------------------------------------ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--tk-accent-ink);
  outline-offset: 2px;
}
@media (forced-colors: active) {
  button,
  a.button,
  input,
  select,
  textarea {
    border: 1px solid ButtonText;
  }
  .notice,
  .notice-danger,
  .badge,
  main dl,
  main.narrow {
    border-color: CanvasText;
  }
}
