/* Additions to Bootstrap (assets/bootstrap/css/bootstrap.min.css): the gateway's colors and type, and what Bootstrap has no component for. */

/*
 * Colors. Bootstrap's body background is the panel color (cards, navbar,
 * inputs, modal), and the page behind the panels is a shade darker, so the
 * panels stand out.
 */
:root {
  --brand: #14233c;
  --brand-accent: #f5a623;
  --page-bg: #f6f7f9;
  /* Status words in running text (.text-ok, .text-bad): Bootstrap's light
     emphasis colors are nearly black, they read as color only on a badge. */
  --status-ok: #146c43;
  --status-bad: #b02a37;
  /* Set by admin.js from the sticky navigation's real height. */
  --navbar-height: 57px;
}
/* Dark: blue-tinted greys and a light blue accent instead of Bootstrap's neutral grey. */
[data-bs-theme="dark"] {
  --brand: #f2f4f7;
  --page-bg: #14171c;
  --bs-body-bg: #1c2028;
  --bs-body-bg-rgb: 28, 32, 40;
  --bs-body-color: #e6e8ec;
  --bs-body-color-rgb: 230, 232, 236;
  --bs-emphasis-color: #f2f4f7;
  --bs-emphasis-color-rgb: 242, 244, 247;
  --bs-secondary-color: #98a2b3;
  --bs-secondary-bg: #262c38;
  --bs-tertiary-bg: #20252f;
  --bs-border-color: #323846;
  --bs-primary: #7aa2f7;
  --bs-primary-rgb: 122, 162, 247;
  --bs-link-color: #7aa2f7;
  --bs-link-color-rgb: 122, 162, 247;
  --bs-link-hover-color: #a5c0fa;
  --bs-link-hover-color-rgb: 165, 192, 250;
  --bs-primary-text-emphasis: #a5c0fa;
  --bs-primary-bg-subtle: #1b2540;
  --bs-primary-border-subtle: #2c3d6b;
  --bs-success-text-emphasis: #6ccf97;
  --bs-success-bg-subtle: #12301f;
  --bs-success-border-subtle: #1f5236;
  --bs-danger-text-emphasis: #f97066;
  --bs-danger-bg-subtle: #3a1716;
  --bs-danger-border-subtle: #6b2622;
  --bs-warning-text-emphasis: #fdb022;
  --bs-warning-bg-subtle: #3a2a12;
  --bs-warning-border-subtle: #6b4d1c;
  --bs-secondary-text-emphasis: #c5ccd8;
  --bs-secondary-bg-subtle: #262c38;
  --bs-secondary-border-subtle: #3a4152;
  --status-ok: #6ccf97;
  --status-bad: #f97066;
}
body { background-color: var(--page-bg); }

/*
 * The scrollbar's room is always kept: otherwise a classic (Windows) scrollbar
 * that comes and goes with the page length pushes the centred content sideways.
 * Bootstrap's modal makes up for a scrollbar it hides by padding the page,
 * which with the kept room would now shift it the other way.
 */
html { scrollbar-gutter: stable; }
body.modal-open { padding-right: 0 !important; }
.modal-open .sticky-top { padding-right: 0 !important; margin-right: 0 !important; }
.modal { padding-right: 0 !important; }

/* Bootstrap compiles its button and checkbox colors: the dark accent is set here. */
[data-bs-theme="dark"] .btn-primary {
  --bs-btn-color: #14171c;
  --bs-btn-bg: #7aa2f7;
  --bs-btn-border-color: #7aa2f7;
  --bs-btn-hover-color: #14171c;
  --bs-btn-hover-bg: #93b4f9;
  --bs-btn-hover-border-color: #93b4f9;
  --bs-btn-active-color: #14171c;
  --bs-btn-active-bg: #a5c0fa;
  --bs-btn-active-border-color: #a5c0fa;
  --bs-btn-disabled-color: #14171c;
  --bs-btn-disabled-bg: #7aa2f7;
  --bs-btn-disabled-border-color: #7aa2f7;
  --bs-btn-focus-shadow-rgb: 122, 162, 247;
}
[data-bs-theme="dark"] .btn-outline-primary {
  --bs-btn-color: #7aa2f7;
  --bs-btn-border-color: #7aa2f7;
  --bs-btn-hover-color: #14171c;
  --bs-btn-hover-bg: #7aa2f7;
  --bs-btn-hover-border-color: #7aa2f7;
  --bs-btn-active-color: #14171c;
  --bs-btn-active-bg: #93b4f9;
  --bs-btn-active-border-color: #93b4f9;
  --bs-btn-focus-shadow-rgb: 122, 162, 247;
}
/* Neutral buttons: Bootstrap's grey outline looks disabled. Dark text, a clear border. */
.btn-outline-secondary {
  --bs-btn-color: var(--bs-emphasis-color);
  --bs-btn-border-color: #ced4da;
  --bs-btn-hover-color: var(--bs-emphasis-color);
  --bs-btn-hover-bg: #eef0f3;
  --bs-btn-hover-border-color: #adb5bd;
  --bs-btn-active-color: var(--bs-emphasis-color);
  --bs-btn-active-bg: #e2e5ea;
  --bs-btn-active-border-color: #adb5bd;
}
[data-bs-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: #c5ccd8;
  --bs-btn-border-color: #4a5366;
  --bs-btn-hover-color: #14171c;
  --bs-btn-hover-bg: #c5ccd8;
  --bs-btn-hover-border-color: #c5ccd8;
  --bs-btn-active-color: #14171c;
  --bs-btn-active-bg: #dde2ea;
  --bs-btn-active-border-color: #dde2ea;
}
[data-bs-theme="dark"] .btn-danger {
  --bs-btn-color: #14171c;
  --bs-btn-bg: #f97066;
  --bs-btn-border-color: #f97066;
  --bs-btn-hover-color: #14171c;
  --bs-btn-hover-bg: #fa8a82;
  --bs-btn-hover-border-color: #fa8a82;
  --bs-btn-active-color: #14171c;
  --bs-btn-active-bg: #fba49e;
  --bs-btn-active-border-color: #fba49e;
  --bs-btn-focus-shadow-rgb: 249, 112, 102;
}
[data-bs-theme="dark"] .btn-outline-danger {
  --bs-btn-color: #f97066;
  --bs-btn-border-color: #f97066;
  --bs-btn-hover-color: #14171c;
  --bs-btn-hover-bg: #f97066;
  --bs-btn-hover-border-color: #f97066;
  --bs-btn-active-color: #14171c;
  --bs-btn-active-bg: #fa8a82;
  --bs-btn-active-border-color: #fa8a82;
  --bs-btn-focus-shadow-rgb: 249, 112, 102;
}
[data-bs-theme="dark"] .form-check-input:checked { background-color: #7aa2f7; border-color: #7aa2f7; }

/*
 * Type. Bootstrap's headings are weight 500, which Segoe UI (Windows) does not
 * have: they fell back to regular and looked like large body text.
 */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6, .modal-title { font-weight: 600; color: var(--bs-emphasis-color); }
.form-label { margin-bottom: 0.25rem; font-size: 0.875rem; font-weight: 600; }
.table, .stat-count { font-variant-numeric: tabular-nums; }
/* Mono values (keys, types, payloads): neutral instead of Bootstrap's pink. */
code { color: var(--bs-emphasis-color); background: var(--bs-tertiary-bg); padding: 0.1rem 0.3rem; border-radius: var(--bs-border-radius-sm); }
/* In tables, links and titles a key is just mono text, not a chip. */
td code, a code, h1 code { padding: 0; background: none; }
a code { color: inherit; }
pre { background: var(--bs-tertiary-bg); padding: 0.75rem; border-radius: var(--bs-border-radius); font-size: 0.8125rem; }
pre code { padding: 0; background: none; }

/* Links: color shows a link, the underline only on hover. Links in running text keep a soft one. */
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.intro a, .alert a { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(var(--bs-link-color-rgb), 0.4); }

/* Side gutter: 16px on phones, 24px from tablets up. */
.container-xxl { --bs-gutter-x: 2rem; }
@media (min-width: 992px) {
  .container-xxl { --bs-gutter-x: 3rem; }
}

/* Navigation: logo and name, then the pages; the active one is marked on the bottom border. */
.navbar { --bs-navbar-padding-y: 0; }
.navbar .nav-link { padding-block: 1.125rem; white-space: nowrap; }
.navbar .nav-link.active { box-shadow: inset 0 -2px 0 var(--brand-accent); }
.navbar .vr { margin: 0.75rem 0.5rem; }
@media (max-width: 1199.98px) {
  .navbar-brand { padding-block: 0.75rem; }
  .navbar .nav-link { padding-block: 0.5rem; }
  .navbar .nav-link.active { box-shadow: inset 2px 0 0 var(--brand-accent); padding-left: 0.75rem; }
  .navbar .vr { display: none; }
}
.brand { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; color: var(--brand); text-decoration: none; }
.brand:hover { color: var(--brand); text-decoration: none; }
.brand .logo { display: block; height: 20px; width: auto; }
.brand .product { font-size: 0.6875rem; font-weight: 600; line-height: 1; letter-spacing: 0.02em; color: var(--bs-secondary-color); }

/*
 * The menu (navMenu.hbs): administration, theme and logout. Wide screens:
 * a three-line button at the right that opens a dropdown, marked like a
 * link when one of its pages is open. Narrow screens: the end of the menu.
 */
.nav-menu-button { display: flex; align-items: center; padding: 0.375rem 0.5rem; border: var(--bs-border-width) solid var(--bs-border-color); border-radius: var(--bs-border-radius); background: transparent; color: var(--bs-navbar-color); }
.nav-menu-button:hover, .nav-menu-button[aria-expanded="true"] { background-color: var(--bs-tertiary-bg); }
.nav-menu-button .navbar-toggler-icon { width: 1.25em; height: 1.25em; }
.nav-menu-button.active { box-shadow: inset 0 -2px 0 var(--brand-accent); }
.nav-menu { --bs-dropdown-min-width: 13rem; --bs-dropdown-link-active-bg: var(--bs-tertiary-bg); --bs-dropdown-link-active-color: var(--bs-emphasis-color); }
.nav-menu .dropdown-item.active { font-weight: 600; }
.theme-icon { width: 1em; height: 1em; margin-right: 0.375rem; vertical-align: -0.125em; }
/* The chosen theme gets a check mark, not a highlighted row. */
.nav-menu .theme-item { position: relative; padding-right: 2rem; }
.nav-menu .theme-item.active { background: none; color: var(--bs-dropdown-link-color); font-weight: 600; }
.nav-menu .theme-item.active::after { content: "✓"; position: absolute; right: 1rem; }
.nav-menu-narrow { margin-top: 0.5rem; padding: 0.75rem 0; border-top: var(--bs-border-width) solid var(--bs-border-color); }
.nav-menu-narrow .navbar-nav { margin-bottom: 0.75rem; }

/* Page header (pageHeader.hbs): breadcrumb, title with its status, meta line and actions. */
.page-header { margin-bottom: 1.25rem; }
.page-header .breadcrumb { --bs-breadcrumb-margin-bottom: 0.25rem; --bs-breadcrumb-divider-color: var(--bs-secondary-color); font-size: 0.875rem; }
.page-header .breadcrumb a { color: var(--bs-secondary-color); }
.page-header .breadcrumb a:hover { color: var(--bs-link-color); }
.page-header .breadcrumb-item.active { color: var(--bs-secondary-color); }
.page-title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; min-height: 2.375rem; }
.page-title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0; font-size: 1.5rem; letter-spacing: -0.01em; }
.page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.page-meta { margin-top: 0.25rem; font-size: 0.875rem; color: var(--bs-secondary-color); }
.page-meta > * + *::before { content: "·"; margin: 0 0.5rem; }

/* What a page or section is about ({{intro}}, help.ts). */
.intro { margin-bottom: 1.25rem; color: var(--bs-secondary-color); font-size: 0.9375rem; }
.intro p { margin-bottom: 0.4rem; }
.intro p:last-child { margin-bottom: 0; }

/* Sections (section.hbs): a card with its title in the header band. */
.section { margin-bottom: 1.5rem; box-shadow: 0 1px 2px rgb(16 24 40 / 5%); }
.row > * > .section { margin-bottom: 0; height: 100%; }
.section > .card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1.25rem; background-color: var(--bs-tertiary-bg); }
.section > .card-body { padding: 1.25rem; }
.section-title { margin: 0; font-size: 1rem; }
.section-count { margin-left: 0.25rem; color: var(--bs-secondary-color); font-weight: 400; }
.section-aside { font-size: 0.875rem; color: var(--bs-secondary-color); }
.section .intro { font-size: 0.875rem; }
.subsection-title { margin: 1.5rem 0 0.5rem; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--bs-secondary-color); }
.subsection-title:first-child { margin-top: 0; }
/* A form's buttons: a footer band across the card. */
.section .form-actions { margin: 1.25rem -1.25rem -1.25rem; padding: 0.75rem 1.25rem; border-top: var(--bs-border-width) solid var(--bs-border-color); background-color: var(--bs-tertiary-bg); border-radius: 0 0 var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius); }
/* A section whose content is a table: the table runs to the card's edges. */
.section-flush > .card-body { padding: 0; }
.section-flush .intro { padding: 1rem 1.25rem 0; margin-bottom: 1rem; }
.section-flush .table { margin-bottom: 0; }
.section-flush .table > :not(caption) > * > :first-child { padding-left: 1.25rem; }
.section-flush .table > :not(caption) > * > :last-child { padding-right: 1.25rem; }
.section-flush .table > tbody > tr:last-child > * { border-bottom-width: 0; }
.section-footer { padding: 0.75rem 1.25rem; border-top: var(--bs-border-width) solid var(--bs-border-color); }
.section-flush > .card-body > :last-child.section-footer { border-radius: 0 0 var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius); }
.section-flush .list-group-item { padding-inline: 1.25rem; }
.section-empty { margin: 0; padding: 1rem 1.25rem; font-size: 0.875rem; color: var(--bs-secondary-color); }
/* "Nothing here" in a section: one quiet style everywhere. */
.empty-note { margin: 0; font-size: 0.875rem; color: var(--bs-secondary-color); }
/* Text colors like Bootstrap's own utilities, so they win over the quiet styles above. */
.text-ok { color: var(--status-ok) !important; }
.text-bad { color: var(--status-bad) !important; }
/* Rows of a short list (dashboard, client page). */
.list-row + .list-row { margin-top: 0.5rem; }
.list-meta { font-size: 0.8125rem; color: var(--bs-secondary-color); }

/* Tables: dense rows, column titles on a band, short values on one line. */
.table { --bs-table-bg: transparent; font-size: 0.875rem; }
.table > :not(caption) > * > * { padding: 0.5rem 0.75rem; }
.table > thead th { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--bs-secondary-color); white-space: nowrap; background-color: var(--bs-tertiary-bg); }
/* A row's buttons on one line and centred: each sits in its own form, some with an input. */
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; white-space: nowrap; }
td .form-control[type="text"] { min-width: 10rem; }
td.empty { padding-block: 1.5rem !important; color: var(--bs-secondary-color); text-align: center; }
/*
 * Long tables keep their column titles in view below the sticky navigation.
 * Only on wide screens: narrower ones scroll tables sideways, and a sticky
 * title cannot leave that scroll box.
 */
@media (min-width: 1200px) {
  .table-responsive { overflow: visible; }
  .table > thead > tr > th { position: sticky; top: var(--navbar-height); z-index: 2; }
}
/*
 * A message: title on its own line, the payload as a small link at the end
 * of the text (its JSON opens below). Never squeezed to a word per line:
 * narrow screens scroll the table instead.
 */
.message-cell { min-width: 16rem; }
.message-cell details { display: inline; margin-left: 0.5rem; font-size: 0.8125rem; }
.message-cell summary { display: inline; color: var(--bs-secondary-color); cursor: pointer; list-style: none; text-decoration: underline dotted; text-underline-offset: 2px; }
.message-cell summary::-webkit-details-marker { display: none; }
.message-cell details[open] pre { display: block; margin: 0.25rem 0 0; }
.message-cell .resend { margin-left: 0.5rem; }
.message-error { font-size: 0.8125rem; color: var(--bs-secondary-color); }

/*
 * Badges: one style everywhere (views.ts statusBadgeHtml). They hold
 * lowercase words, centred halfway between the x-height and the cap height:
 * the font's line box leaves them about a pixel low in fonts with a tall
 * ascent (Segoe UI), the x-height alone puts words with tall letters
 * (blocked) too high. Browsers without text-box keep Bootstrap's padding.
 */
.badge { font-size: 0.75rem; font-weight: 600; }
@supports (text-box: trim-both cap alphabetic) {
  .badge { text-box: trim-both cap alphabetic; padding-top: 0.45em; padding-bottom: 0.55em; }
}
h1 .badge { vertical-align: middle; }
/* A new API key: shown once, must stand out. */
pre.key { font-size: 0.95rem; white-space: pre-wrap; word-break: break-all; border: 2px solid var(--bs-success); }
/* Copy buttons on keys and examples (admin.js), in the block's top right corner. */
.copyable { position: relative; }
.copyable .copy-button { position: absolute; top: 0.5rem; right: 0.5rem; background-color: var(--bs-body-bg); }
.copyable pre { padding-right: 5rem; }
@media (max-width: 767.98px) {
  .copyable pre { padding-top: 2.75rem; padding-right: 0.75rem; }
}
/* Onboarding examples: quiet titles, the open one marked by weight and a light band. */
.accordion { --bs-accordion-active-bg: var(--bs-tertiary-bg); --bs-accordion-active-color: var(--bs-emphasis-color); --bs-accordion-btn-focus-box-shadow: none; }
.accordion-button { font-size: 0.875rem; font-weight: 400; }
.accordion-button:not(.collapsed) { font-weight: 600; }
.section-flush .accordion-button, .section-flush .accordion-body { padding-inline: 1.25rem; }

/* Page state that must not be missed carries a "!" mark. */
.alert-warning, .alert-danger { position: relative; padding-left: 2.75rem; }
.alert-warning::before, .alert-danger::before {
  content: "!";
  position: absolute;
  left: 0.9rem;
  top: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  font-weight: 700;
  line-height: 1;
}
.alert-warning::before { background: var(--bs-warning-text-emphasis); color: var(--bs-warning-bg-subtle); }
.alert-danger::before { background: var(--bs-danger-text-emphasis); color: var(--bs-danger-bg-subtle); }

/* A notice about a choice in a form appears only once the choice is made. */
.show-if-checked:not(:has(input[type="checkbox"]:checked)) .alert,
.show-if-typed:not(:has(input[placeholder]:not(:placeholder-shown))) .alert,
.show-if-changed:not(:has(select option:checked:not([selected]))) .alert {
  display: none;
}

/*
 * Results of form actions (flash.ts). Sticky without height: they start below
 * the navigation (never over it), stay in view when the page scrolls, and do
 * not push the page down.
 */
.toasts { position: sticky; top: calc(var(--navbar-height) + 1rem); z-index: 1090; height: 0; display: flex; flex-direction: column; align-items: flex-end; }

/* Counts of the last 24 hours on the overview: problems stand out, zeros recede. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0.5rem; }
@media (max-width: 575.98px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}
.stat { display: flex; flex-direction: column; gap: 0.125rem; padding: 0.625rem 0.75rem; border: var(--bs-border-width) solid var(--bs-border-color); border-radius: var(--bs-border-radius); color: inherit; text-decoration: none; }
.stat:hover { border-color: var(--bs-primary); text-decoration: none; }
.stat-label { font-size: 0.75rem; color: var(--bs-secondary-color); white-space: nowrap; }
.stat-count { font-size: 1.5rem; font-weight: 600; line-height: 1.2; color: var(--bs-emphasis-color); }
.stat-zero .stat-count { color: var(--bs-secondary-color); font-weight: 400; }
.stat-bad { border-color: var(--bs-danger-border-subtle); background-color: var(--bs-danger-bg-subtle); }
.stat-bad .stat-count, .stat-bad .stat-label { color: var(--bs-danger-text-emphasis); }

/* Detail facts (label above value). */
.facts { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; margin: 0; }
.facts dt { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--bs-secondary-color); }
.facts dd { margin: 0; }

/* Login. */
.login { max-width: 380px; margin: 10vh auto; }
.login .brand .logo { height: 28px; }
.login .brand .product { font-size: 1rem; }

/* (i) help icons (help.ts, admin.js). */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
  color: var(--bs-secondary-color);
  font: italic 600 11px/1 Georgia, "Times New Roman", serif;
  letter-spacing: normal;
  text-transform: none;
  vertical-align: middle;
  cursor: help;
}
.info-icon:hover, .info-icon:focus { color: var(--bs-primary); }
.info-icon:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
.help-popover { --bs-popover-max-width: min(380px, calc(100vw - 16px)); --bs-popover-font-size: 0.8125rem; }
.help-popover p { margin-bottom: 0.5rem; }
.help-popover p:last-child { margin-bottom: 0; }
