/* ==========================================================================
   ApiTraffic brand skin.

   The vendor theme is re-coloured in place (see apps/ui/scripts/recolor-theme.mjs);
   this layer carries the parts a colour swap cannot express: the marketing
   site's typography and surface treatment (apps/www/src/styles/global.css) and
   the contrast/focus rules the product needs to meet WCAG 2.2 AA.
   ========================================================================== */

:root {
  --at-brand: #59bb7a;
  --at-brand-bright: #6ee7a0;
  --at-brand-deep: #2f9e5e;
  --at-on-brand: #04150d;

  --at-radius-sm: 8px;
  --at-radius: 12px;
  --at-radius-lg: 18px;

  --at-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
    sans-serif;
  --at-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --at-focus: var(--at-brand-bright);
}

html.dark-style {
  --at-bg: #070b0a;
  --at-surface: #0d1512;
  --at-surface-raised: #131d19;
  --at-line: rgba(255, 255, 255, 0.09);
  --at-line-strong: rgba(255, 255, 255, 0.16);
  --at-text: #eaf2ee;
  --at-text-soft: #cddbd4;
  --at-text-dim: #93a69e;
  --at-link: var(--at-brand-bright);
  --at-hover: rgba(255, 255, 255, 0.045);
  --at-shadow: 0 24px 60px -34px rgba(0, 0, 0, 0.9);

  /* semantic foregrounds, tuned for >= 4.5:1 on dark surfaces */
  --at-fg-primary: #6ee7a0;
  --at-fg-success: #5fdd93;
  --at-fg-danger: #ff9a9a;
  --at-fg-warning: #ffc46b;
  --at-fg-info: #63d9ec;
  --at-fg-secondary: #b3c1ba;
}

html.light-style {
  --at-bg: #f5f9f7;
  --at-surface: #ffffff;
  --at-surface-raised: #ffffff;
  --at-line: #dde5e1;
  --at-line-strong: #c3d2cb;
  --at-text: #16241e;
  --at-text-soft: #33413b;
  --at-text-dim: #5f716a;
  --at-link: #146c43;
  --at-hover: rgba(20, 108, 67, 0.06);
  --at-shadow: 0 18px 40px -30px rgba(6, 37, 26, 0.45);

  /* semantic foregrounds, tuned for >= 4.5:1 on light surfaces */
  --at-fg-primary: #146c43;
  --at-fg-success: #146c43;
  --at-fg-danger: #b02a37;
  --at-fg-warning: #8a5300;
  --at-fg-info: #0b6a7d;
  --at-fg-secondary: #52635c;
}

/* ------------------------------------------------------------ typography -- */

body {
  font-family: var(--at-font);
  letter-spacing: -0.005em;
}

code,
pre,
kbd,
samp,
.mono,
.font-monospace {
  font-family: var(--at-mono);
}

/* Bootstrap renders inline code in its own pink; inside a block it should just
   inherit whatever the highlighter or surface sets. */
code {
  color: var(--at-fg-primary);
}

pre code,
.hljs code,
code .hljs {
  color: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6,
.card-title {
  letter-spacing: -0.02em;
  color: var(--at-text);
}

.text-muted {
  color: var(--at-text-dim) !important;
}

/* Section labels — the uppercase micro-headings used on the marketing site. */
.at-eyebrow,
.menu-header-text {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--at-text-dim);
}

/* ------------------------------------------------------------- surfaces -- */

.card,
.modal-content,
.dropdown-menu,
.offcanvas,
.popover,
.accordion-item,
.list-group,
.toast {
  border-radius: var(--at-radius-lg);
  border: 1px solid var(--at-line);
  box-shadow: var(--at-shadow);
}

.card {
  background-color: var(--at-surface);
}

/* Modals, menus, drawers and popovers open *over* the page, and usually over a
   card. They shipped at `--at-surface`, i.e. the exact colour of that card, so
   the only thing separating them was a 9%-white hairline and a black drop
   shadow — and on a near-black page a black shadow expresses no elevation at
   all. In a dark theme elevation has to come from lightness: a raised surface
   and an edge you can actually see. */
.modal-content,
.dropdown-menu,
.offcanvas,
.popover,
.toast {
  background-color: var(--at-surface-raised);
  border-color: var(--at-line-strong);
}

html.dark-style .modal-content,
html.dark-style .dropdown-menu,
html.dark-style .offcanvas,
html.dark-style .popover,
html.dark-style .toast {
  box-shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* The page behind a dialog is already near-black, so the backdrop has little
   room to darken it; it takes the extra it has. */
.modal-backdrop.show {
  opacity: 0.6;
}

/* The close control ships as a filled chip with its own drop shadow, which on
   a raised dialog reads as a detached tile floating off the corner. */
.modal .btn-close,
.offcanvas .btn-close {
  background-color: transparent;
  box-shadow: none;
  border-radius: 999px;
}

.modal .btn-close:hover,
.offcanvas .btn-close:hover {
  background-color: var(--at-hover);
}

.card-header,
.card-footer {
  background-color: transparent;
  border-color: var(--at-line);
}

.table {
  --bs-table-border-color: var(--at-line);
}

.table > :not(caption) > * > * {
  border-bottom-color: var(--at-line);
}

.table > thead th,
.table > thead td {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--at-text-dim);
}

hr,
.dropdown-divider {
  border-color: var(--at-line);
  opacity: 1;
}

/* ------------------------------------------------------ brand foreground -- */

/* The brand green is a surface colour, not a text colour: white text on it is
   only 2.4:1. Filled brand surfaces use the dark ink from the marketing site. */
.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active,
.btn-primary.disabled,
.btn-primary:disabled,
.show > .btn-primary.dropdown-toggle,
.bg-primary,
.badge.bg-primary,
.progress-bar,
.nav-pills .nav-link.active,
.page-item.active .page-link,
.page-link.active,
.list-group-item-action.active,
.dropdown-item:not(.disabled).active,
.dropdown-item:not(.disabled):active,
.btn-outline-primary:hover,
.btn-outline-primary:active,
.btn-outline-primary.active,
.btn-check:checked + .btn-outline-primary,
.timeline .timeline-point-primary {
  color: var(--at-on-brand) !important;
  border-color: transparent;
}

.btn-primary {
  background-color: var(--at-brand);
  font-weight: 600;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--at-brand-bright);
}

/* Brand as *text* needs the darker shade on light backgrounds. */
.text-primary,
a,
.btn-link,
.page-link,
.link-primary {
  color: var(--at-link);
}

.text-primary {
  color: var(--at-link) !important;
}

a:hover,
.btn-link:hover {
  color: var(--at-brand-deep);
}

html.dark-style a:hover,
html.dark-style .btn-link:hover {
  color: var(--at-brand-bright);
}

.btn-outline-primary,
.btn-label-primary {
  color: var(--at-link);
}

/* --------------------------------------------- check / radio / switch -- */

/* Geometry first: the box has to stay square and the radio round, so nothing
   here may set a height (or a min-height) the width does not match. */
.form-check-input {
  width: 1.125rem;
  height: 1.125rem;
  border-width: 1px;
  border-radius: 0.3125rem;
  transition: background-color 0.12s ease-in-out, border-color 0.12s ease-in-out;
}

.form-check-input[type='radio'] {
  border-radius: 50%;
}

.form-switch .form-check-input {
  width: 1.875rem;
  height: 1.125rem;
  border-radius: 999px;
}

/* The template drops a 2px shadow under the filled state; at 18px it only
   smudges the edge. Matches the vendor selector so it actually wins. */
.form-check-input,
.form-check .form-check-input:checked,
.form-check .form-check-input[type='checkbox']:indeterminate {
  box-shadow: none;
}

/* The empty box is the only state drawn purely as a boundary, so it carries
   the 3:1 the rest of the skin gets from a fill (1.4.11). The template's own
   light-mode border lands at 1.2:1 on white. */
.form-check-input:not(:checked):not(:indeterminate) {
  background-color: transparent;
  border-color: var(--at-text-dim);
}

.form-check-input:hover:not(:disabled):not(:checked) {
  border-color: var(--at-brand);
}

/* A switch reads as a knob travelling along a track, so its off state keeps a
   fill where an empty checkbox wants none. */
.form-switch .form-check-input:not(:checked) {
  background-color: var(--at-hover);
}

/* The 24px target (2.5.8, AA) comes from the row rather than from stretching
   the box. Vertical padding on the label extends its hit area without giving
   it a block formatting context — some labels are two lines split by a <br>,
   which a flex or grid label would lay out side by side. */
.form-check:not(.custom-option) {
  min-height: 1.5rem;
  margin-bottom: 0.25rem;
}

.form-check:not(.custom-option) > .form-check-label {
  padding-block: 0.125rem;
  cursor: pointer;
}

.form-check-input:disabled,
.form-check-input:disabled ~ .form-check-label {
  cursor: default;
}

/* Checkbox / radio ticks are drawn in white by the template; on the brand
   green that is a 2.4:1 icon, so they are re-drawn in the same dark ink. */
.form-check-input:checked[type='checkbox'] {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%2304150d' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}

.form-check-input:checked[type='radio'] {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%2304150d'/%3e%3c/svg%3e");
}

.form-switch .form-check-input:checked {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%2304150d'/%3e%3c/svg%3e");
}

/* The off-state knob ships as the template's indigo; it is the only piece of
   the switch the recolour pass cannot reach (it is an inline SVG data URI). */
.form-switch .form-check-input:not(:checked),
.form-switch .form-check-input:not(:checked):focus {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%237b8a84'/%3e%3c/svg%3e");
}

html.light-style .form-switch .form-check-input:not(:checked),
html.light-style .form-switch .form-check-input:not(:checked):focus {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%235f716a'/%3e%3c/svg%3e");
}

/* --------------------------------------------------------------- buttons -- */

.btn {
  border-radius: 999px;
  font-weight: 550;
}

.btn-sm {
  border-radius: 999px;
}

/* WCAG 2.2 target size (2.5.8, AA): give every control a 24x24 hit area.
   Checks and radios are deliberately absent — a min-height wider than their
   width turns the box into a rectangle and the radio into an ellipse; they
   take their target from `.form-check` instead. */
.btn,
.form-control,
.form-select,
.page-link,
.nav-link,
.dropdown-item {
  min-height: 24px;
}

.btn-icon,
.btn-icon-only {
  min-width: 24px;
  min-height: 24px;
}

/* ------------------------------------------------------- option cards -- */

/* The Off / Monitor / Enforcing style pickers. Their descriptions differ in
   length, so without an explicit height the cards in a row end at different
   points and the radio floats to a different height in each one. */
.custom-option {
  height: 100%;
  border-radius: var(--at-radius);
  border-color: var(--at-line-strong);
  transition: border-color 0.12s ease-in-out, background-color 0.12s ease-in-out;
}

.custom-option:hover:not(.checked) {
  border-color: var(--at-brand);
}

.custom-option.checked {
  background-color: rgba(89, 187, 122, 0.08);
}

/* Bottom-align the control so every card in the row agrees on where it sits;
   the template centres it with `text-align`, which a flex column ignores. */
.custom-option-icon .custom-option-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.custom-option-icon .custom-option-content > .form-check-input {
  align-self: center;
}

/* --------------------------------------------------------------- inputs -- */

.form-control,
.form-select,
.input-group-text {
  border-radius: var(--at-radius);
  background-color: var(--at-surface);
  border-color: var(--at-line-strong);
  color: var(--at-text);
}

.form-control::placeholder {
  color: var(--at-text-dim);
  opacity: 1;
}

html.dark-style .form-control,
html.dark-style .form-select,
html.dark-style .input-group-text {
  background-color: rgba(0, 0, 0, 0.28);
}

/* ------------------------------------------------------------ navigation -- */

.layout-menu,
.bg-menu-theme {
  background-color: var(--at-surface) !important;
  border-right: 1px solid var(--at-line);
}

html.dark-style .layout-menu,
html.dark-style .bg-menu-theme {
  background-color: #0a1210 !important;
}

.bg-menu-theme .menu-item .menu-link {
  border-radius: var(--at-radius);
  color: var(--at-text-soft);
}

.bg-menu-theme .menu-item .menu-link:hover {
  background-color: var(--at-hover);
  color: var(--at-text);
}

.bg-menu-theme .menu-item.active > .menu-link {
  background: rgba(89, 187, 122, 0.14);
  color: var(--at-link);
  box-shadow: inset 0 0 0 1px rgba(89, 187, 122, 0.26);
}

html.dark-style .bg-menu-theme .menu-item.active > .menu-link {
  color: #b8f0cf;
}

.bg-menu-theme .menu-header {
  color: var(--at-text-dim);
}

/* Collapsible section headers in the account menu. */
.btn.menu-header-toggle {
  padding: 10px 24px !important;
  color: var(--at-text-dim);
  text-align: left;
}

.menu-header-toggle:hover .menu-header-text {
  color: var(--at-text);
}

#layout-top-navbar {
  padding-bottom: 8px;
}

/* The template paints a fixed scrim where its sticky navbar would be; this
   layout scrolls its own navbar, so the scrim only greys out the breadcrumb. */
.layout-navbar-fixed .layout-wrapper:not(.layout-horizontal) .layout-page:before {
  display: none;
}

/* ---------------------------------------------------------------- focus -- */

/* The template removes focus rings from link-style buttons; put a visible,
   theme-aware ring back on everything that can take focus (2.4.7 / 2.4.11). */
:focus-visible {
  outline: 2px solid var(--at-focus);
  outline-offset: 2px;
}

.btn:focus-visible,
.btn.btn-link:focus-visible,
.btn-link:active:focus-visible,
.page-link:focus-visible,
.dropdown-item:focus-visible,
.menu-link:focus-visible,
.nav-link:focus-visible,
.form-check-input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--at-focus) !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--at-brand);
  box-shadow: 0 0 0 3px rgba(89, 187, 122, 0.25);
}

/* Skip link — first tab stop, hidden until focused (2.4.1). */
.at-skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 2000;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--at-brand);
  color: var(--at-on-brand);
  font-weight: 600;
  transition: top 0.15s ease-in-out;
}

.at-skip-link:focus {
  top: 12px;
  color: var(--at-on-brand);
}

/* ---------------------------------------------------------- colour mode -- */

.at-mode-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--at-line);
  background: transparent;
  color: var(--at-text-soft);
}

.at-mode-toggle:hover {
  background: var(--at-hover);
  color: var(--at-text);
}

/* ------------------------------------------------------ third-party UI -- */

/* Toasts, tooltips and the request-body viewers sit outside the vendor theme. */
.Toastify__toast {
  background: var(--at-surface-raised) !important;
  color: var(--at-text) !important;
  border: 1px solid var(--at-line) !important;
  border-radius: var(--at-radius) !important;
}

.Toastify__close-button {
  color: var(--at-text-dim) !important;
  opacity: 1;
}

.tooltip-inner {
  background: var(--at-surface-raised);
  color: var(--at-text);
  border: 1px solid var(--at-line-strong);
  border-radius: var(--at-radius-sm);
}

/* The viewer's root carries `json-viewer-theme-<mode>`, not `.json-viewer`, so
   the earlier selector here never matched anything. Colours come from the
   colorspace in RenderBody; this is the panel and the typeface. */
[class*='json-viewer-theme-'] {
  background: transparent !important;
  font-family: var(--at-mono) !important;
  font-size: 0.75rem;
  /* Punctuation outside a typed token (the closing brace) inherits MUI's own
     text colour, and a custom colorspace leaves MUI in light mode — so on dark
     it lands at rgba(0,0,0,.87). It inherits from here instead — !important
     because emotion injects the MUI rule after this stylesheet. */
  color: var(--at-text) !important;
}

.apexcharts-tooltip,
.apexcharts-menu {
  background: var(--at-surface-raised) !important;
  color: var(--at-text) !important;
  border: 1px solid var(--at-line-strong) !important;
}

.apexcharts-tooltip-title,
.apexcharts-menu-item:hover {
  background: var(--at-hover) !important;
  border-color: var(--at-line) !important;
}

/* ------------------------------------------------- semantic colour (AA) -- */

/* Sneat's semantic hues are tuned for decoration, not text: on both surfaces
   they land around 2:1. Text, soft-filled badges/alerts and outline buttons all
   get the mode-specific accessible foreground instead. */
.text-primary,
.btn-label-primary,
.badge.bg-label-primary,
.alert-primary,
.nav-tabs .nav-link.active,
.btn-outline-primary:not(:hover):not(:active):not(.active) {
  color: var(--at-fg-primary) !important;
}

.text-success,
.btn-label-success,
.badge.bg-label-success,
.alert-success,
.btn-outline-success:not(:hover):not(:active):not(.active) {
  color: var(--at-fg-success) !important;
}

.text-danger,
.btn-label-danger,
.badge.bg-label-danger,
.alert-danger,
.dropdown-item.text-danger,
.btn-outline-danger:not(:hover):not(:active):not(.active) {
  color: var(--at-fg-danger) !important;
}

.text-warning,
.btn-label-warning,
.badge.bg-label-warning,
.alert-warning,
.btn-outline-warning:not(:hover):not(:active):not(.active) {
  color: var(--at-fg-warning) !important;
}

.text-info,
.btn-label-info,
.badge.bg-label-info,
.alert-info,
.btn-outline-info:not(:hover):not(:active):not(.active) {
  color: var(--at-fg-info) !important;
}

.text-secondary,
.text-lighter,
.text-light,
.btn-label-secondary,
.badge.bg-label-secondary,
.alert-secondary,
.btn-outline-secondary:not(:hover):not(:active):not(.active) {
  color: var(--at-fg-secondary) !important;
}

/* Every other soft tint recolours with its foreground, but the neutral one is
   mixed from the template's indigo, so on dark it reads blue-violet against a
   green-black surface. Neutral means neutral: tint it from the text colour. */
html.dark-style .badge.bg-label-secondary,
html.dark-style .btn-label-secondary,
html.dark-style .alert-secondary {
  background-color: rgba(234, 242, 238, 0.08) !important;
  border-color: transparent;
}

/* The SDK vendor logos are dark artwork on transparent, so they need a light
   plate to stay visible on the dark surface. */
html.dark-style .sdk-tile .custom-option-body img {
  background: #f3f6f4;
  border-radius: var(--at-radius-sm);
  padding: 8px 12px;
  box-sizing: content-box;
}

/* Bootstrap's fixed light/dark utilities predate the two modes; both are used
   for "slightly recessed panel" and "body-coloured text", so map them to the
   surface tokens instead of literal white/black. */
.bg-light,
.card-header.bg-light,
pre.bg-light {
  background-color: var(--at-surface-raised) !important;
  color: var(--at-text) !important;
  border-color: var(--at-line);
}

html.dark-style .bg-light,
html.dark-style pre.bg-light {
  background-color: rgba(255, 255, 255, 0.04) !important;
}

.text-dark,
.text-black,
.text-black-75 {
  color: var(--at-text) !important;
}

/* Solid fills: light hues need dark ink, danger needs a darker fill. */
.btn-success,
.btn-warning,
.btn-info,
.badge.bg-success,
.badge.bg-warning,
.badge.bg-info,
.bg-success,
.bg-warning,
.bg-info {
  color: var(--at-on-brand) !important;
}

.btn-danger,
.badge.bg-danger,
.bg-danger {
  background-color: #c62828 !important;
  border-color: #c62828 !important;
  color: #ffffff !important;
}

.alert {
  border-radius: var(--at-radius);
}

/* -------------------------------------------------------- outseta widget -- */

/* The auth widget renders inline (no iframe) with its own light palette and
   the template's old purple accent, so it is re-skinned here. */
.o--Reset--reset > div {
  --accent-color: var(--at-brand) !important;
}

.o--Widget--widget {
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
}

.o--Widget--widget h1,
.o--Widget--widget h2,
.o--Widget--widget h3 {
  color: var(--at-text) !important;
}

.o--Label--label,
.o--Widget--widget label,
.o--Widget--widget p,
.o--Widget--widget span {
  color: var(--at-text-soft) !important;
}

.o--Input--input,
.o--Widget--widget select,
.o--Widget--widget textarea {
  background-color: var(--at-surface) !important;
  border: 1px solid var(--at-line-strong) !important;
  border-radius: var(--at-radius) !important;
  color: var(--at-text) !important;
}

html.dark-style .o--Input--input,
html.dark-style .o--Widget--widget select,
html.dark-style .o--Widget--widget textarea {
  background-color: rgba(0, 0, 0, 0.28) !important;
}

.o--Input--input:focus {
  outline: 2px solid var(--at-focus) !important;
  outline-offset: 1px;
}

.o--Button--btn {
  background-color: var(--at-brand) !important;
  border-color: var(--at-brand) !important;
  border-radius: 999px !important;
  font-weight: 600 !important;
}

.o--Button--btn,
.o--Button--btn .o--Button--children,
.o--Button--btn span {
  color: var(--at-on-brand) !important;
}

.o--Button--btn:focus-visible {
  outline: 2px solid var(--at-focus) !important;
  outline-offset: 2px;
}

.o--Widget--widget a {
  color: var(--at-link) !important;
}

html.dark-style .o--Widget--widget a {
  color: var(--at-brand-bright) !important;
}

/* --------------------------------------------------------------- motion -- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------- forced colours -- */

@media (forced-colors: active) {
  .btn,
  .card,
  .form-control,
  .form-select {
    border: 1px solid ButtonBorder;
  }

  :focus-visible {
    outline: 2px solid Highlight;
  }
}
