/* Bassenger operator dashboard.
   Palette derived from the product icon: navy #03103F, envelope blue #3DBBFF, russet #B5471B,
   cream #FDEACB. Text/background pairs meet WCAG AA in both themes. */

:root {
  color-scheme: light dark;

  --navy: #03103f;
  --blue: #3dbbff;
  --russet: #b5471b;
  --cream: #fdeacb;

  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #0b1535;
  --muted: #4a5578;
  --border: #d5d0c4;
  --border-strong: #8e94aa;
  --link: #0a5a9e;
  --focus: #0a5a9e;

  --bar-bg: var(--navy);
  --bar-text: #ffffff;
  --bar-muted: #c3cdf0;

  --primary-bg: #0a4f8c;
  --primary-text: #ffffff;
  --danger-bg: #a8280d;
  --danger-text: #ffffff;
  --danger: #9b1c0c;

  --prod-bg: var(--russet);
  --prod-text: #ffffff;
  --prod-ink: #8f3310;
  --dev-bg: #dfe6f5;
  --dev-text: #1b2a5c;

  --ok-bg: #e3f3e9;
  --ok-text: #155c33;
  --warn-bg: #fcefcf;
  --warn-text: #6d4300;
  --error-bg: #fbe5e0;
  --error-text: #8f1a0b;
  --info-bg: #e0effb;
  --info-text: #0b4a82;
  --neutral-bg: #eaecf3;
  --neutral-text: #3b4566;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --radius: 6px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --shadow: 0 1px 2px rgb(3 16 63 / 8%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #060c26;
    --surface: #0d1740;
    --surface-2: #141f52;
    --text: #eef1fa;
    --muted: #aab4d8;
    --border: #2a3670;
    --border-strong: #6470a8;
    --link: #74ceff;
    --focus: #74ceff;

    --bar-bg: #020a2c;
    --bar-text: #ffffff;
    --bar-muted: #b4bfe6;

    --primary-bg: var(--blue);
    --primary-text: var(--navy);
    --danger-bg: #c8401f;
    --danger-text: #ffffff;
    --danger: #ffa391;

    --prod-bg: var(--russet);
    --prod-text: #ffffff;
    --prod-ink: #ffb08f;
    --dev-bg: #18245c;
    --dev-text: #d5dcf7;

    --ok-bg: #0f3320;
    --ok-text: #8fe0ae;
    --warn-bg: #3d2c05;
    --warn-text: #f7cd77;
    --error-bg: #47150c;
    --error-text: #ffa896;
    --info-bg: #0b2f52;
    --info-text: #93d6ff;
    --neutral-bg: #1b2757;
    --neutral-text: #c6cdea;
    --shadow: none;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  overflow-x: hidden;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
fieldset,
figure {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

fieldset {
  border: 0;
  min-width: 0;
}

a {
  color: var(--link);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

main:focus,
h1:focus {
  outline: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.mono {
  font-family: var(--mono);
  font-size: 0.93em;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
}

.sub {
  color: var(--muted);
  font-size: 12.5px;
}

.prewrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.error-text {
  color: var(--danger);
}

.ok-text {
  color: var(--ok-text);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-width: 0;
}

.stack > * {
  min-width: 0;
}

.boot {
  padding: var(--s6);
  text-align: center;
  color: var(--muted);
}

/* ── Top bar ─────────────────────────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  left: var(--s2);
  top: -100px;
  z-index: 50;
  padding: var(--s2) var(--s3);
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--focus);
  border-radius: var(--radius);
  font: inherit;
}

.skip-link:focus {
  top: var(--s2);
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  background: var(--bar-bg);
  color: var(--bar-text);
  flex-wrap: wrap;
}

.topbar :focus-visible {
  outline-color: var(--blue);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: var(--bar-text);
  text-decoration: none;
  font-weight: 650;
  font-size: 16px;
}

.brand__icon {
  border-radius: 7px;
  display: block;
}

.context {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: var(--s3);
  align-items: center;
  text-align: left;
  padding: var(--s1) var(--s3);
  background: transparent;
  color: var(--bar-text);
  border: 1px solid var(--bar-muted);
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
  min-width: 0;
}

.context:hover {
  background: rgb(255 255 255 / 10%);
}

.context__label {
  grid-column: 1;
  font-size: 11px;
  color: var(--bar-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.context__value {
  grid-column: 1;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.context__switch {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-size: 12.5px;
  color: var(--bar-muted);
  white-space: nowrap;
}

.topbar__spacer {
  flex: 1 1 0;
}

.who {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
  color: var(--bar-muted);
  font-size: 13px;
}

.who__email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 28ch;
}

.menu-btn {
  display: none;
}

.envbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s1) var(--s3);
  padding: 6px var(--s4);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.envbar__env {
  letter-spacing: 0.06em;
  font-size: 13px;
}

.envbar--production {
  background: var(--prod-bg);
  color: var(--prod-text);
  border-bottom: 4px solid var(--navy);
}

.envbar--development {
  background: var(--dev-bg);
  color: var(--dev-text);
}

.envbar__paused {
  font-weight: 650;
  padding: 0 var(--s2);
  border: 1px solid currentcolor;
  border-radius: 999px;
}

.env-text--production {
  color: var(--prod-ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/* ── Layout ──────────────────────────────────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  align-items: start;
  min-height: calc(100vh - 90px);
}

.nav {
  padding: var(--s4) var(--s3);
  border-right: 1px solid var(--border);
  align-self: stretch;
  background: var(--surface);
}

.nav__group + .nav__group {
  margin-top: var(--s4);
}

.nav__title {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 var(--s2) var(--s1);
}

.nav__link {
  display: block;
  padding: 6px var(--s2);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.nav__link:hover {
  background: var(--surface-2);
}

.nav__link[aria-current='page'] {
  background: var(--surface-2);
  border-left-color: var(--link);
  font-weight: 650;
}

.main {
  padding: var(--s5);
  min-width: 0;
  max-width: 1400px;
}

.back {
  margin-bottom: var(--s2);
  font-size: 13px;
}

.page__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s3);
  margin-bottom: var(--s4);
}

.page__title {
  font-size: 22px;
  line-height: 1.25;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.subtitle {
  font-size: 18px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.lead {
  color: var(--muted);
  margin-top: var(--s1);
  max-width: 75ch;
}

.page__actions,
.card__actions,
.row-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
}

.page__body {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-width: 0;
}

.page__body > * {
  min-width: 0;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: var(--s4);
  align-items: start;
}

.two-col > * {
  min-width: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: var(--s4);
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  min-width: 0;
}

.card > * {
  min-width: 0;
}

.card__title {
  font-size: 15px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.form-page {
  max-width: 980px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
}

.toolbar__text {
  color: var(--muted);
}

.row-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
}

.plain-list {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.occ-list {
  gap: var(--s2);
}

/* ── Buttons ─────────────────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  min-height: 34px;
  padding: 6px var(--s3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn[aria-busy='true'] {
  cursor: progress;
}

.btn--primary {
  background: var(--primary-bg);
  border-color: var(--primary-bg);
  color: var(--primary-text);
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-bg);
  filter: brightness(1.12);
}

.btn--danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

.dialog .btn--danger[type='submit'] {
  background: var(--danger-bg);
  border-color: var(--danger-bg);
  color: var(--danger-text);
}

.dialog .btn--danger[type='submit']:hover:not(:disabled) {
  background: var(--danger-bg);
  filter: brightness(1.12);
}

.btn--small {
  min-height: 28px;
  padding: 2px var(--s2);
  font-size: 13px;
}

.btn--block {
  width: 100%;
}

.btn--onbar {
  background: transparent;
  color: var(--bar-text);
  border-color: var(--bar-muted);
}

.btn--onbar:hover:not(:disabled) {
  background: rgb(255 255 255 / 10%);
}

.btn[aria-pressed='true'] {
  background: var(--surface-2);
  border-color: var(--text);
}

/* ── Chips, badges, notices ──────────────────────────────────────────────────────────────── */

.chip {
  display: inline-block;
  padding: 1px var(--s2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  overflow-wrap: anywhere;
}

.chip--onbar {
  background: transparent;
  color: var(--bar-text);
  border-color: var(--bar-muted);
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
}

.badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--s1);
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px var(--s2);
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge__glyph {
  font-weight: 700;
}

.badge--ok {
  background: var(--ok-bg);
  color: var(--ok-text);
  border-color: var(--ok-text);
}

.badge--warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: var(--warn-text);
}

.badge--error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-text);
}

.badge--info {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: var(--info-text);
}

.badge--neutral {
  background: var(--neutral-bg);
  color: var(--neutral-text);
  border-color: var(--border-strong);
}

.notice {
  display: flex;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  border: 1px solid;
  border-left-width: 4px;
}

.notice__glyph {
  font-weight: 700;
  flex: none;
  width: 1.1em;
  text-align: center;
}

.notice__body {
  min-width: 0;
  overflow-wrap: anywhere;
}

.notice--info {
  background: var(--info-bg);
  color: var(--info-text);
}

.notice--ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.notice--warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.notice--danger {
  background: var(--error-bg);
  color: var(--error-text);
}

.notice a {
  color: inherit;
}

.state {
  padding: var(--s5) var(--s4);
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
}

.state--loading {
  flex-direction: row;
  justify-content: center;
  border-style: solid;
  border-color: var(--border);
}

.state--error {
  color: var(--error-text);
  background: var(--error-bg);
  border: 1px solid var(--error-text);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Tiles ───────────────────────────────────────────────────────────────────────────────── */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s3);
}

.tiles--small {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s2);
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--s3);
  min-width: 0;
}

.tile--warn {
  border-left-color: var(--warn-text);
}

.tile--error {
  border-left-color: var(--error-text);
}

.tile__label {
  color: var(--muted);
  font-size: 12.5px;
}

.tile__value {
  font-size: 22px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.tiles--small .tile__value {
  font-size: 18px;
}

.tile__label .badge {
  white-space: normal;
}

.card > .field > select.input,
.filters + .field > select.input {
  max-width: 420px;
}

.tile__sub {
  color: var(--muted);
  font-size: 12.5px;
}

.asof {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── Definition lists ────────────────────────────────────────────────────────────────────── */

.dl {
  display: flex;
  flex-direction: column;
}

.dl__row {
  display: grid;
  grid-template-columns: minmax(110px, 34%) minmax(0, 1fr);
  gap: var(--s3);
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.dl__row:first-child {
  border-top: 0;
}

.dl dt {
  color: var(--muted);
}

.dl dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.dl--compact .dl__row {
  padding: 3px 0;
  border-top: 0;
}

.time-stack {
  display: inline-flex;
  flex-direction: column;
}

.pre {
  margin: 0;
  padding: var(--s2) var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: 12.5px/1.5 var(--mono);
  overflow: auto;
  max-height: 320px;
  white-space: pre;
}

.details > summary {
  cursor: pointer;
  font-weight: 600;
  padding: var(--s1) 0;
}

.details[open] > summary {
  margin-bottom: var(--s2);
}

/* ── Tables ──────────────────────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.table th,
.table td {
  text-align: left;
  vertical-align: top;
  padding: var(--s2) var(--s3);
  border-top: 1px solid var(--border);
  font-weight: 400;
  overflow-wrap: anywhere;
  min-width: 0;
}

.table thead th {
  border-top: 0;
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

.table .mono {
  overflow-wrap: break-word;
}

.table .num {
  text-align: right;
  white-space: nowrap;
}

.table .col-select {
  width: 1%;
}

.pager {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 34px;
}

/* ── Forms ───────────────────────────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  min-width: 0;
}

.label,
legend.label {
  font-weight: 600;
  font-size: 13px;
  padding: 0;
}

.req {
  color: var(--danger);
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
  max-width: 80ch;
}

.input {
  width: 100%;
  min-height: 34px;
  padding: 6px var(--s2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.input.mono {
  font-family: var(--mono);
  font-size: 13px;
}

textarea.input {
  resize: vertical;
  line-height: 1.45;
}

.input:disabled,
.input[readonly] {
  background: var(--surface-2);
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
  border-width: 2px;
}

.check {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--primary-bg);
}

.check-label {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--s2);
  cursor: pointer;
}

.field--check .hint,
.checkbox .hint,
.radio .hint,
.radio-card .hint {
  margin-left: 24px;
}

.fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
}

.radio-cards__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: var(--s2);
}

.radio-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--s2) var(--s3);
  background: var(--surface);
}

.radio-card:has(input:checked) {
  border-color: var(--link);
  box-shadow: inset 4px 0 0 var(--link);
  background: var(--surface-2);
}

.radio-card__title {
  font-weight: 650;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: var(--s2) var(--s4);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: var(--s3) var(--s4);
  align-items: start;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: var(--s3);
  align-items: end;
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filters__actions {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}

.kv__rows {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.kv__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
  gap: var(--s2);
}

.kv > .btn {
  align-self: flex-start;
}

.copybox {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  min-width: 0;
}

.copybox__row {
  display: flex;
  gap: var(--s2);
  align-items: flex-start;
}

.copybox__row .input {
  flex: 1 1 auto;
  min-width: 0;
}

.target,
.audience {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.zone-preview__title {
  font-size: 14px;
  margin-bottom: var(--s2);
}

.confirm-line {
  font-size: 15px;
}

/* ── App picker ──────────────────────────────────────────────────────────────────────────── */

.apps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: var(--s4);
}

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.app-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s2);
}

.app-card__name {
  font-size: 16px;
  font-weight: 650;
}

.env-links {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.env-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  border-left-width: 6px;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
}

.env-link:hover {
  background: var(--surface-2);
}

.env-link__name {
  font-weight: 650;
}

.env-link__sub {
  color: var(--muted);
  font-size: 12.5px;
}

.env-link--production {
  border-color: var(--russet);
}

.env-link--production .env-link__name,
.env-link--production .env-link__mark {
  color: var(--prod-ink);
  letter-spacing: 0.05em;
}

/* ── Login ───────────────────────────────────────────────────────────────────────────────── */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s4);
}

.login__card {
  width: min(100%, 380px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  box-shadow: var(--shadow);
}

.login__icon {
  border-radius: 20px;
  align-self: center;
}

.login__title {
  font-size: 22px;
  text-align: center;
}

.login__card > .lead {
  text-align: center;
  margin: 0;
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

/* ── Dialogs ─────────────────────────────────────────────────────────────────────────────── */

.dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px rgb(3 16 63 / 35%);
}

.dialog--wide {
  width: min(760px, calc(100vw - 24px));
}

.dialog::backdrop {
  background: rgb(3 10 40 / 60%);
}

.dialog__form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 26px);
}

.dialog__head {
  padding: var(--s4) var(--s4) var(--s2);
}

.dialog__title {
  font-size: 17px;
  font-weight: 650;
}

.dialog__body {
  padding: var(--s2) var(--s4) var(--s4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-width: 0;
}

.dialog__body > * {
  min-width: 0;
}

.dialog__error:not(:empty) {
  padding: 0 var(--s4) var(--s3);
}

.dialog__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 10px 10px;
}

/* ── Toasts ──────────────────────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toasts--alerts {
  bottom: auto;
  top: var(--s4);
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  border: 1px solid var(--info-text);
  border-left-width: 4px;
  background: var(--info-bg);
  color: var(--info-text);
  box-shadow: 0 4px 16px rgb(3 16 63 / 25%);
}

.toast--success {
  background: var(--ok-bg);
  color: var(--ok-text);
  border-color: var(--ok-text);
}

.toast--error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-text);
}

.toast__glyph {
  font-weight: 700;
  flex: none;
}

.toast__text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast__close {
  flex: none;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 var(--s1);
}

/* ── Narrow screens ──────────────────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .menu-btn {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 6px var(--s3);
    background: transparent;
    color: var(--bar-text);
    border: 1px solid var(--bar-muted);
    border-radius: var(--radius);
    font: inherit;
    font-weight: 550;
    cursor: pointer;
  }

  .nav {
    display: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav--open {
    display: block;
  }

  .nav__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .main {
    padding: var(--s4) var(--s3);
  }

  .who__email {
    display: none;
  }

  .brand__name {
    display: none;
  }
}

@media (max-width: 720px) {
  /* Tables become stacked, labelled cards; nothing scrolls sideways at page level. */
  .table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .table,
  .table tbody,
  .table tr,
  .table th,
  .table td {
    display: block;
    width: 100%;
  }

  .table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .table tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--s1) var(--s3);
    margin-bottom: var(--s2);
  }

  .table tbody th,
  .table td {
    display: grid;
    grid-template-columns: minmax(84px, 34%) minmax(0, 1fr);
    gap: var(--s3);
    padding: 5px 0;
    border-top: 1px solid var(--border);
    text-align: left;
  }

  .table tr > :first-child {
    border-top: 0;
  }

  .table tbody th::before,
  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
  }

  .table .num {
    text-align: left;
  }

  .table .col-select {
    width: 100%;
  }

  .dl__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .kv__row {
    grid-template-columns: minmax(0, 1fr);
  }

  .page__title {
    font-size: 19px;
  }
}

@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;
  }

  .spinner {
    animation: none;
    border-top-color: var(--border-strong);
  }
}

@media (forced-colors: active) {
  .badge,
  .notice,
  .tile,
  .radio-card:has(input:checked) {
    border: 1px solid CanvasText;
  }

  .nav__link[aria-current='page'] {
    outline: 2px solid Highlight;
  }
}
