/*
 * "Console" design system (admin, customer portal and sign-in pages): tokens, shell and
 * components on top of Bootstrap 5.3. See docs/ADMIN_UI.md.
 *
 * Identity, taken from the SIP.cr logo (docs/brand/):
 *   ink    #021534  the wordmark navy: sidebar, text
 *   signal #007F66  the ring's deep teal end: the one accent, for actions and links
 *          #1FCF9C  the ring's bright green: the accent on ink (sidebar, dark theme)
 *   series #2E4F86  a lighter navy: second chart series only
 *   paper  #F5F4F0  page background; surfaces are white on top of it
 *
 * Rules of thumb:
 *  - Colours only come from the --ui-* tokens below; both themes redefine them.
 *  - Colour is for status and for the one accent. A normal state is quiet (a dot and a word);
 *    only states that need action get a tinted chip.
 *  - Type is IBM Plex Sans; anything a person copies (numbers, IPs, URIs, ids) is IBM Plex Mono.
 *  - Components are .ui-* classes. Bootstrap classes still work and are re-skinned through --bs-*.
 */

/* ---------------------------------------------------------------- fonts (self-hosted, see vendor/THIRD_PARTY.md) */
@font-face {
  font-family: "Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap;
  src: url("vendor/fonts/plex-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap;
  src: url("vendor/fonts/plex-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face { font-family: "Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("vendor/fonts/plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("vendor/fonts/plex-mono-500.woff2") format("woff2"); }
/* Icons: Material Symbols Outlined, weight 300, cut down to the names in vendor/fonts/icons.txt. */
@font-face { font-family: "Console Symbols"; font-style: normal; font-weight: 300; font-display: block; src: url("vendor/fonts/symbols.woff2?v=b539983b") format("woff2"); }

/* ---------------------------------------------------------------- tokens */
:root,
[data-bs-theme=light] {
  --ui-font: "Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ui-mono: "Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ui-bg: #F5F4F0;
  --ui-surface: #FFFFFF;
  --ui-surface-2: #FAF9F6;
  --ui-hover: #F0EEE9;
  --ui-border: #E2DFD7;
  --ui-border-soft: #ECEAE3;
  --ui-border-strong: #C9C5BA;
  --ui-text: #021534;
  --ui-text-2: #22304A;
  --ui-muted: #4A5670;
  --ui-subtle: #646E84;
  --ui-faint: #9AA2B2;

  --ui-accent: #00735C;
  --ui-accent-rgb: 0, 115, 92;
  --ui-accent-fill: #007F66;
  --ui-accent-hover: #00624F;
  --ui-accent-soft: #E3F5EF;
  --ui-accent-soft-border: #B5E3D3;
  --ui-on-accent: #FFFFFF;
  --ui-series-2: #2E4F86;

  --ui-ok-bg: #E2F3E7;     --ui-ok-fg: #17663F;     --ui-ok-dot: #1F9D5B;
  --ui-warn-bg: #FBEFCF;   --ui-warn-fg: #7A4D00;   --ui-warn-dot: #D08A00;
  --ui-danger-bg: #FBE3DF; --ui-danger-fg: #A8231A; --ui-danger-dot: #D33A2C;
  --ui-info-bg: #E9F0FE;   --ui-info-fg: #0847B8;   --ui-info-dot: #0068F8;
  --ui-neutral-bg: #EFEDE7; --ui-neutral-fg: #2A3152; --ui-neutral-dot: #9DA1B2;
  --ui-danger-banner-bg: #FDF1EF; --ui-danger-banner-border: #F3C4BD; --ui-danger-banner-fg: #7A1810;
  --ui-warn-banner-bg: #FDF7E6;   --ui-warn-banner-border: #EFD999;   --ui-warn-banner-fg: #5F3C00;
  --ui-info-banner-bg: #F1F5FE;   --ui-info-banner-border: #C6D9FB;   --ui-info-banner-fg: #0A2F7A;

  /* The sidebar is ink in both themes. */
  --ui-side-bg: #04112B;
  --ui-side-text: #C3CCDD;
  --ui-side-strong: #FFFFFF;
  --ui-side-muted: #7D8AA6;
  --ui-side-hover: rgba(255, 255, 255, .06);
  --ui-side-active: rgba(255, 255, 255, .11);
  --ui-side-border: rgba(255, 255, 255, .10);
  --ui-side-accent: #1FCF9C;

  --ui-radius: 8px;
  --ui-radius-sm: 6px;
  --ui-shadow-pop: 0 10px 28px rgba(2, 21, 52, .14), 0 1px 2px rgba(2, 21, 52, .08);
  --ui-sidebar-w: 224px;
  /* The page column: it takes the width the window gives it, up to a cap, and is centred in the
     space beside the sidebar. The top bar and the impersonation band keep their full-width
     background and line their contents up with it. Pages put the width to work in columns
     (.ui-main-col, .ui-pick-grid, .ui-grid) and never stretch a short thing across it. */
  --ui-content-max: 2240px;
  --ui-gutter: 32px;
  --ui-band-pad: max(var(--ui-gutter), calc((100% - var(--ui-content-max)) / 2 + var(--ui-gutter)));
  --ui-topbar-h: 52px;
}

[data-bs-theme=dark] {
  --ui-bg: #050D1C;
  --ui-surface: #0B1526;
  --ui-surface-2: #101B2E;
  --ui-hover: #16233A;
  --ui-border: #22304A;
  --ui-border-soft: #1A263C;
  --ui-border-strong: #36476A;
  --ui-text: #EEECE5;
  --ui-text-2: #D2D1D6;
  --ui-muted: #A3ADBF;
  --ui-subtle: #8693A8;
  --ui-faint: #586683;

  --ui-accent: #3DDBAE;
  --ui-accent-rgb: 61, 219, 174;
  --ui-accent-fill: #1FCF9C;
  --ui-accent-hover: #6FE6C3;
  --ui-accent-soft: rgba(31, 207, 156, .14);
  --ui-accent-soft-border: rgba(31, 207, 156, .34);
  --ui-on-accent: #04121F;
  --ui-series-2: #8EA8D8;

  --ui-ok-bg: rgba(46, 190, 115, .14);   --ui-ok-fg: #5FD897;     --ui-ok-dot: #2EBE73;
  --ui-warn-bg: rgba(232, 164, 23, .16); --ui-warn-fg: #F1BE4D;   --ui-warn-dot: #E8A417;
  --ui-danger-bg: rgba(238, 88, 73, .16); --ui-danger-fg: #FF8A7C; --ui-danger-dot: #EE5849;
  --ui-info-bg: rgba(111, 168, 255, .16); --ui-info-fg: #A9C8FF;  --ui-info-dot: #6FA8FF;
  --ui-neutral-bg: #1A2538; --ui-neutral-fg: #D2D1D6; --ui-neutral-dot: #6A7890;
  --ui-danger-banner-bg: rgba(238, 88, 73, .10); --ui-danger-banner-border: rgba(238, 88, 73, .38); --ui-danger-banner-fg: #FFC9C2;
  --ui-warn-banner-bg: rgba(232, 164, 23, .10);  --ui-warn-banner-border: rgba(232, 164, 23, .38); --ui-warn-banner-fg: #F6DFA4;
  --ui-info-banner-bg: rgba(111, 168, 255, .10); --ui-info-banner-border: rgba(111, 168, 255, .36); --ui-info-banner-fg: #CFE0FF;

  --ui-side-bg: #030B19;
  --ui-shadow-pop: 0 10px 28px rgba(0, 0, 0, .55), 0 0 0 1px var(--ui-border);
}

/* Bootstrap re-skin through its own variables (same selectors, loaded later, so these win). */
:root,
[data-bs-theme=light],
[data-bs-theme=dark] {
  --bs-body-font-family: var(--ui-font);
  --bs-body-font-size: .875rem;
  --bs-body-line-height: 1.5;
  --bs-body-bg: var(--ui-bg);
  --bs-body-color: var(--ui-text);
  --bs-emphasis-color: var(--ui-text);
  --bs-secondary-color: var(--ui-muted);
  --bs-tertiary-color: var(--ui-subtle);
  --bs-secondary-bg: var(--ui-hover);
  --bs-tertiary-bg: var(--ui-surface-2);
  --bs-border-color: var(--ui-border);
  --bs-border-color-translucent: var(--ui-border);
  --bs-border-radius: var(--ui-radius-sm);
  --bs-border-radius-lg: var(--ui-radius);
  --bs-primary: var(--ui-accent);
  --bs-primary-rgb: var(--ui-accent-rgb);
  --bs-link-color: var(--ui-accent);
  --bs-link-color-rgb: var(--ui-accent-rgb);
  --bs-link-hover-color: var(--ui-accent-hover);
  --bs-link-decoration: none;
  --bs-heading-color: var(--ui-text);
  --bs-primary-bg-subtle: var(--ui-accent-soft);
  --bs-primary-text-emphasis: var(--ui-accent-hover);
  --bs-primary-border-subtle: var(--ui-accent-soft-border);
  --bs-success-bg-subtle: var(--ui-ok-bg);         --bs-success-text-emphasis: var(--ui-ok-fg);         --bs-success-border-subtle: transparent;
  --bs-warning-bg-subtle: var(--ui-warn-banner-bg); --bs-warning-text-emphasis: var(--ui-warn-banner-fg); --bs-warning-border-subtle: var(--ui-warn-banner-border);
  --bs-danger-bg-subtle: var(--ui-danger-banner-bg); --bs-danger-text-emphasis: var(--ui-danger-banner-fg); --bs-danger-border-subtle: var(--ui-danger-banner-border);
  --bs-info-bg-subtle: var(--ui-info-banner-bg);   --bs-info-text-emphasis: var(--ui-info-banner-fg);   --bs-info-border-subtle: var(--ui-info-banner-border);
  --bs-secondary-bg-subtle: var(--ui-neutral-bg);  --bs-secondary-text-emphasis: var(--ui-neutral-fg);
  --bs-light-bg-subtle: var(--ui-surface-2);
  --bs-dark-bg-subtle: var(--ui-neutral-bg);       --bs-dark-text-emphasis: var(--ui-neutral-fg);
}

/* ---------------------------------------------------------------- base */
html, body { background: var(--ui-bg); }
body {
  font-family: var(--ui-font);
  color: var(--ui-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -.01em; color: var(--ui-text); }
.tnum, .table td { font-variant-numeric: tabular-nums; }
.font-monospace, code, kbd, pre { font-family: var(--ui-mono); }
code { color: var(--ui-text-2); background: var(--ui-neutral-bg); padding: .1em .35em; border-radius: 4px; font-size: .85em; }
:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.text-muted { color: var(--ui-subtle) !important; }
::selection { background: rgba(var(--ui-accent-rgb), .22); }
.visually-hidden-focusable:focus { position: fixed !important; top: 8px; left: 8px; z-index: 2000; background: var(--ui-surface); padding: 8px 12px; border-radius: var(--ui-radius-sm); box-shadow: var(--ui-shadow-pop); }

/* Icon font. The fixed 1em box keeps the layout still while the font loads. */
.material-icons-outlined {
  font-family: "Console Symbols";
  font-weight: 300; font-style: normal;
  font-size: 20px; line-height: 1; width: 1em; height: 1em;
  display: inline-block; overflow: hidden; flex: none;
  letter-spacing: normal; text-transform: none; white-space: nowrap; word-wrap: normal; direction: ltr;
  font-feature-settings: "liga"; -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  vertical-align: middle; user-select: none;
}

/* ---------------------------------------------------------------- shell */
.ui-shell { display: flex; min-height: 100vh; }

.ui-sidebar {
  width: var(--ui-sidebar-w);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--ui-side-bg);
  color: var(--ui-side-text);
  padding: 14px 10px 14px;
  display: flex;
  flex-direction: column;
  z-index: 1035;
}
.ui-brand { display: flex; align-items: center; gap: 8px; padding: 4px 10px 14px; color: var(--ui-text); }
.ui-brand:hover { text-decoration: none; color: var(--ui-text); }
/* The logo file has built-in padding: crop it to the mark + wordmark. */
.ui-brand-logo { height: 30px; width: auto; flex: none; }
.ui-brand-logo-dark { display: none; }
[data-bs-theme=dark] .ui-brand-logo-dark, .ui-sidebar .ui-brand-logo-dark, .ui-auth-aside .ui-brand-logo-dark { display: block; }
[data-bs-theme=dark] .ui-brand-logo-light, .ui-sidebar .ui-brand-logo-light, .ui-auth-aside .ui-brand-logo-light { display: none; }
.ui-brand-tag { margin-left: auto; font-size: 11px; color: var(--ui-side-muted); }
.ui-tenant { margin: 0 4px 12px; padding: 0 6px 12px; border-bottom: 1px solid var(--ui-side-border); font-size: 12.5px; min-width: 0; }
.ui-tenant-name { font-weight: 600; color: var(--ui-side-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-tenant-role { color: var(--ui-side-muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-tenant .ui-pill { color: var(--ui-side-text); }

.ui-nav { display: flex; flex-direction: column; gap: 1px; }
.ui-nav-group { font-size: 11px; font-weight: 500; letter-spacing: .04em; color: var(--ui-side-muted); padding: 16px 10px 6px; }
.ui-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--ui-radius-sm);
  color: var(--ui-side-text); font-size: 13.5px; line-height: 20px;
}
.ui-nav-link .material-icons-outlined { font-size: 19px; color: var(--ui-side-muted); }
.ui-nav-link:hover { background: var(--ui-side-hover); color: var(--ui-side-strong); text-decoration: none; }
.ui-nav-link.active { background: var(--ui-side-active); color: var(--ui-side-strong); font-weight: 500; }
.ui-nav-link.active .material-icons-outlined { color: var(--ui-side-accent); }
.ui-nav-count { margin-left: auto; }
.ui-sidebar .ui-count { background: rgba(255, 255, 255, .12); color: var(--ui-side-strong); }
.ui-sidebar .ui-count-warn { background: var(--ui-warn-dot); color: #201400; }
.ui-sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--ui-side-border); display: flex; flex-direction: column; gap: 1px; }
/* Activation steps shown in the sidebar while an account is not active yet. */
.ui-side-steps { list-style: none; margin: 4px 0 0; padding: 0 6px; counter-reset: step; }
.ui-side-steps > li { position: relative; padding: 0 0 18px 28px; font-size: 13px; color: var(--ui-side-muted); counter-increment: step; }
.ui-side-steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--ui-side-border); font-size: 11px; line-height: 18px; text-align: center; font-family: var(--ui-mono); }
.ui-side-steps > li::after { content: ""; position: absolute; left: 10px; top: 22px; bottom: 2px; width: 1px; background: var(--ui-side-border); }
.ui-side-steps > li:last-child::after { display: none; }
.ui-side-steps > li.is-done { color: var(--ui-side-text); }
.ui-side-steps > li.is-done::before { content: "\2713"; background: rgba(255, 255, 255, .14); border-color: transparent; color: var(--ui-side-strong); font-family: var(--ui-font); }
.ui-side-steps > li.is-current { color: var(--ui-side-strong); font-weight: 500; }
.ui-side-steps > li.is-current::before { background: var(--ui-accent-fill); border-color: var(--ui-accent-fill); color: var(--ui-on-accent); }
.ui-side-steps small { display: block; font-size: 11.5px; font-weight: 400; color: var(--ui-side-muted); }

.ui-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ui-topbar {
  position: sticky; top: 0; z-index: 1030;
  min-height: var(--ui-topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 8px var(--ui-band-pad);
  background: var(--ui-bg);
  border-bottom: 1px solid var(--ui-border);
}
.ui-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--ui-subtle); min-width: 0; }
.ui-crumbs a { color: var(--ui-subtle); }
.ui-crumbs a:hover { color: var(--ui-text); }
.ui-crumbs .sep { color: var(--ui-faint); }
.ui-crumbs .current { color: var(--ui-text); font-weight: 500; }
.ui-search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  width: 400px; max-width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm);
  background: var(--ui-surface); color: var(--ui-subtle);
}
.ui-search:focus-within { border-color: var(--ui-accent); box-shadow: 0 0 0 3px rgba(var(--ui-accent-rgb), .16); }
.ui-search input { border: 0; background: transparent; flex: 1; min-width: 0; font-size: 13px; outline: none; color: var(--ui-text); }
.ui-search input::placeholder { color: var(--ui-subtle); }
.ui-kbd { font-family: var(--ui-mono); font-size: 11px; line-height: 16px; border: 1px solid var(--ui-border-strong); border-radius: 4px; padding: 0 5px; color: var(--ui-subtle); background: var(--ui-surface-2); }
.ui-avatar { position: relative; width: 30px; height: 30px; border-radius: 50%; background: var(--ui-side-bg); color: #fff; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; display: inline-flex; align-items: center; justify-content: center; border: 0; }
/* A dot on the avatar: something in the account menu wants attention (2FA is off). */
.ui-avatar.has-notice::after { content: ""; position: absolute; top: -1px; right: -1px; width: 9px; height: 9px; border-radius: 50%; background: var(--ui-warn-dot); border: 2px solid var(--ui-bg); }
.ui-content { padding: 24px var(--ui-gutter) 64px; width: 100%; max-width: var(--ui-content-max); margin-inline: auto; }
.ui-impersonation { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px var(--ui-band-pad); background: var(--ui-warn-bg); color: var(--ui-warn-fg); font-size: 13px; border-bottom: 1px solid var(--ui-warn-banner-border); }

.ui-backdrop { display: none; }
@media (max-width: 991.98px) {
  .ui-sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--ui-shadow-pop); }
  .ui-nav-open .ui-sidebar { transform: none; }
  .ui-nav-open .ui-backdrop { display: block; position: fixed; inset: 0; background: rgba(2, 21, 52, .45); z-index: 1034; }
  :root { --ui-gutter: 16px; }
  .ui-content { padding-top: 16px; padding-bottom: 48px; }
  .ui-search { width: auto; flex: 1; }
}

/* Bare shell: error pages and anonymous requests (no sidebar). */
.ui-bare { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 32px 16px; }
.ui-bare > .alert, .ui-bare-card { width: 100%; max-width: 480px; }
.ui-bare-brand { padding: 0; }
.ui-bare-card .ui-card-body { padding: 32px 28px; }
.ui-bare-code { font-family: var(--ui-mono); font-size: 48px; font-weight: 500; line-height: 1; color: var(--ui-faint); margin-bottom: 12px; }

/* Sign-in pages: ink panel with the pitch, paper panel with the form. */
.ui-auth { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, 40%) minmax(0, 1fr); }
.ui-auth-aside { background: var(--ui-side-bg); color: var(--ui-side-text); padding: 32px 48px 40px; display: flex; flex-direction: column; }
.ui-auth-aside .ui-brand { padding: 0; }
.ui-auth-pitch { margin: auto 0; max-width: 420px; }
.ui-auth-pitch h2 { color: var(--ui-side-strong); font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin: 0 0 14px; }
.ui-auth-pitch p { font-size: 15px; line-height: 1.55; margin: 0 0 24px; color: var(--ui-side-text); }
.ui-auth-points { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ui-side-border); }
.ui-auth-points > li { padding: 12px 0; border-bottom: 1px solid var(--ui-side-border); font-size: 13.5px; color: var(--ui-side-text); }
.ui-auth-points strong { display: block; color: var(--ui-side-strong); font-weight: 500; }
.ui-auth-foot { font-size: 12px; color: var(--ui-side-muted); }
.ui-auth-foot a { color: var(--ui-side-text); text-decoration: underline; text-underline-offset: 2px; }
.ui-auth-main { display: flex; flex-direction: column; min-width: 0; }
.ui-auth-bar { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 14px 24px; }
.ui-auth-bar .ui-brand { margin-right: auto; padding: 0; display: none; }
.ui-auth-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px 24px 64px; }
.ui-auth-card { width: 100%; max-width: 380px; }
.ui-auth-card h1 { font-size: 24px; font-weight: 600; letter-spacing: -.015em; margin: 0 0 6px; }
.ui-auth-card .ui-auth-sub { color: var(--ui-muted); font-size: 14px; margin: 0 0 24px; }
.ui-auth-card .form-control { padding: .55rem .75rem; font-size: .9375rem; }
.ui-auth-card .btn-primary { width: 100%; padding-top: .55rem; padding-bottom: .55rem; font-size: .9375rem; }
.ui-auth-alt { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--ui-border); font-size: 13.5px; color: var(--ui-muted); }
.ui-auth-progress { display: flex; gap: 6px; margin-bottom: 20px; }
.ui-auth-progress > span { flex: 1; height: 3px; border-radius: 2px; background: var(--ui-border); }
.ui-auth-progress > span.is-done { background: var(--ui-accent-fill); }
.ui-auth-progress > span.is-current { background: var(--ui-text); }
@media (max-width: 900px) {
  .ui-auth { grid-template-columns: minmax(0, 1fr); }
  .ui-auth-aside { display: none; }
  .ui-auth-bar .ui-brand { display: flex; }
}

/* ---------------------------------------------------------------- page header */
.ui-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
.ui-page-header-main { min-width: 0; }
.ui-page-title { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.018em; line-height: 1.25; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.ui-page-sub { margin: 4px 0 0; font-size: 13.5px; color: var(--ui-muted); max-width: 72ch; }
.ui-page-sub a { color: var(--ui-muted); text-decoration: underline; text-decoration-color: var(--ui-border-strong); text-underline-offset: 2px; }
.ui-page-sub a:hover { color: var(--ui-text); }
.ui-page-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- buttons & forms */
.btn {
  --bs-btn-font-size: .8125rem;
  --bs-btn-font-weight: 500;
  --bs-btn-padding-y: .375rem;
  --bs-btn-padding-x: .75rem;
  --bs-btn-border-radius: var(--ui-radius-sm);
  --bs-btn-focus-box-shadow: 0 0 0 3px rgba(var(--ui-accent-rgb), .25);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn .material-icons-outlined { font-size: 18px; }
.btn-sm { --bs-btn-padding-y: .25rem; --bs-btn-padding-x: .625rem; --bs-btn-font-size: .75rem; }
.btn-sm .material-icons-outlined { font-size: 16px; }
.btn-primary {
  --bs-btn-bg: var(--ui-accent-fill); --bs-btn-border-color: var(--ui-accent-fill); --bs-btn-color: var(--ui-on-accent);
  --bs-btn-hover-bg: var(--ui-accent-hover); --bs-btn-hover-border-color: var(--ui-accent-hover); --bs-btn-hover-color: var(--ui-on-accent);
  --bs-btn-active-bg: var(--ui-accent-hover); --bs-btn-active-border-color: var(--ui-accent-hover); --bs-btn-active-color: var(--ui-on-accent);
  --bs-btn-disabled-bg: var(--ui-accent-fill); --bs-btn-disabled-border-color: var(--ui-accent-fill); --bs-btn-disabled-color: var(--ui-on-accent);
}
[data-bs-theme=dark] .btn-primary { --bs-btn-hover-bg: #1F66E0; --bs-btn-hover-border-color: #1F66E0; --bs-btn-active-bg: #1F66E0; --bs-btn-active-border-color: #1F66E0; }
/* The neutral button. .btn-outline-secondary and .btn-light share it so old markup matches. */
.btn-default, .btn-outline-secondary, .btn-light, .btn-secondary {
  --bs-btn-bg: var(--ui-surface); --bs-btn-border-color: var(--ui-border-strong); --bs-btn-color: var(--ui-text);
  --bs-btn-hover-bg: var(--ui-hover); --bs-btn-hover-border-color: var(--ui-border-strong); --bs-btn-hover-color: var(--ui-text);
  --bs-btn-active-bg: var(--ui-hover); --bs-btn-active-border-color: var(--ui-border-strong); --bs-btn-active-color: var(--ui-text);
  --bs-btn-disabled-bg: var(--ui-surface); --bs-btn-disabled-border-color: var(--ui-border); --bs-btn-disabled-color: var(--ui-faint);
}
.btn-ghost {
  --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-color: var(--ui-muted);
  --bs-btn-hover-bg: var(--ui-hover); --bs-btn-hover-border-color: transparent; --bs-btn-hover-color: var(--ui-text);
  --bs-btn-active-bg: var(--ui-hover); --bs-btn-active-border-color: transparent;
  --bs-btn-disabled-bg: transparent; --bs-btn-disabled-border-color: transparent; --bs-btn-disabled-color: var(--ui-faint);
}
.btn-icon { --bs-btn-padding-x: 0; width: 32px; height: 32px; }
.btn-sm.btn-icon { width: 28px; height: 28px; }
.btn-danger {
  --bs-btn-bg: var(--ui-danger-dot); --bs-btn-border-color: var(--ui-danger-dot); --bs-btn-color: #fff;
  --bs-btn-hover-bg: var(--ui-danger-fg); --bs-btn-hover-border-color: var(--ui-danger-fg);
}
/* Edit is not a warning: neutralise the old yellow action buttons. */
.btn-warning { --bs-btn-bg: var(--ui-surface); --bs-btn-border-color: var(--ui-border-strong); --bs-btn-color: var(--ui-text); --bs-btn-hover-bg: var(--ui-hover); --bs-btn-hover-border-color: var(--ui-border-strong); --bs-btn-hover-color: var(--ui-text); --bs-btn-active-bg: var(--ui-hover); --bs-btn-active-color: var(--ui-text); }

.form-control, .form-select {
  font-size: .875rem;
  border-color: var(--ui-border-strong);
  border-radius: var(--ui-radius-sm);
  background-color: var(--ui-surface);
  color: var(--ui-text);
  padding: .4rem .65rem;
}
.form-control::placeholder { color: var(--ui-faint); }
.form-control:disabled, .form-control[readonly] { background-color: var(--ui-surface-2); color: var(--ui-muted); }
.form-select { padding-right: 2rem; }
.form-control-sm, .form-select-sm { font-size: .8125rem; padding-top: .25rem; padding-bottom: .25rem; }
.form-control:focus, .form-select:focus { border-color: var(--ui-accent); box-shadow: 0 0 0 3px rgba(var(--ui-accent-rgb), .16); }
.form-label { font-size: .8125rem; font-weight: 500; color: var(--ui-text); margin-bottom: .35rem; }
.form-text { font-size: .75rem; color: var(--ui-subtle); }
.form-check-input { border-color: var(--ui-border-strong); }
.form-check-input:checked { background-color: var(--ui-accent-fill); border-color: var(--ui-accent-fill); }
.input-group-text { font-size: .875rem; background: var(--ui-surface-2); border-color: var(--ui-border-strong); color: var(--ui-subtle); }

/* ---------------------------------------------------------------- surfaces */
.card {
  --bs-card-bg: var(--ui-surface);
  --bs-card-border-color: var(--ui-border);
  --bs-card-border-radius: var(--ui-radius);
  --bs-card-inner-border-radius: calc(var(--ui-radius) - 1px);
  --bs-card-cap-bg: transparent;
  --bs-card-spacer-y: 1rem;
  --bs-card-spacer-x: 1rem;
  box-shadow: none;
}
.card.rounded-4 { border-radius: var(--ui-radius) !important; }
.card.border-0 { border: 1px solid var(--ui-border) !important; }
.card-header { border-bottom-color: var(--ui-border-soft); }
.shadow, .shadow-sm { box-shadow: none !important; }
.dropdown-menu, .modal-content, .toast { box-shadow: var(--ui-shadow-pop) !important; }

.ui-card { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); min-width: 0; }
.ui-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--ui-border-soft); }
.ui-card-title { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0; }
.ui-card-meta { font-size: 12px; color: var(--ui-subtle); }
.ui-card-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.ui-card-body { padding: 14px 16px; }
.ui-card-foot { padding: 10px 16px; border-top: 1px solid var(--ui-border-soft); font-size: 13px; }

.dropdown-menu { --bs-dropdown-font-size: .8125rem; --bs-dropdown-border-color: var(--ui-border); --bs-dropdown-border-radius: var(--ui-radius); --bs-dropdown-bg: var(--ui-surface); --bs-dropdown-link-color: var(--ui-text); --bs-dropdown-link-hover-bg: var(--ui-hover); --bs-dropdown-link-active-bg: var(--ui-accent-soft); --bs-dropdown-link-active-color: var(--ui-accent-hover); --bs-dropdown-item-padding-y: .375rem; --bs-dropdown-divider-bg: var(--ui-border-soft); --bs-dropdown-min-width: 12rem; }
.dropdown-item { display: flex; align-items: center; gap: 8px; }
.dropdown-item .material-icons-outlined { font-size: 18px; color: var(--ui-subtle); }
.dropdown-item.text-danger .material-icons-outlined { color: inherit; }
.dropdown-item .ui-dot { margin-left: auto; }
.modal { --bs-modal-border-radius: 10px; --bs-modal-bg: var(--ui-surface); --bs-modal-border-color: var(--ui-border); --bs-modal-header-border-color: var(--ui-border-soft); --bs-modal-footer-border-color: var(--ui-border-soft); }
.modal-title { font-size: 16px; font-weight: 600; }
.offcanvas { --bs-offcanvas-bg: var(--ui-surface); --bs-offcanvas-border-color: var(--ui-border); }
.alert { --bs-alert-border-radius: var(--ui-radius); --bs-alert-padding-y: .625rem; --bs-alert-padding-x: .875rem; font-size: 13.5px; }
.alert-success { --bs-alert-border-color: transparent; }
.alert-dismissible .btn-close { padding: .8rem .875rem; font-size: 10px; }

/* ---------------------------------------------------------------- status: pills, dots, tags
 * A normal state is a dot and a word. States that need someone to act (warn, danger) get a chip. */
.ui-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; line-height: 18px; letter-spacing: 0; white-space: nowrap; color: var(--ui-text-2); }
.ui-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ui-neutral-dot); display: inline-block; }
.ui-pill-ok .ui-dot, .ui-dot-ok { background: var(--ui-ok-dot); }
.ui-pill-info .ui-dot, .ui-dot-info { background: var(--ui-info-dot); }
.ui-pill-neutral { color: var(--ui-subtle); }
.ui-pill-warn, .ui-pill-danger { padding: 1px 8px; border-radius: 4px; }
.ui-pill-warn { background: var(--ui-warn-bg); color: var(--ui-warn-fg); }     .ui-pill-warn .ui-dot, .ui-dot-warn { background: var(--ui-warn-dot); }
.ui-pill-danger { background: var(--ui-danger-bg); color: var(--ui-danger-fg); } .ui-pill-danger .ui-dot, .ui-dot-danger { background: var(--ui-danger-dot); }
/* A live state: the dot breathes. */
.ui-dot-live { background: var(--ui-ok-dot); box-shadow: 0 0 0 0 rgba(31, 157, 91, .5); animation: ui-live 2s ease-out infinite; }
@keyframes ui-live { 0% { box-shadow: 0 0 0 0 rgba(31, 157, 91, .45); } 70%, 100% { box-shadow: 0 0 0 6px rgba(31, 157, 91, 0); } }
@media (prefers-reduced-motion: reduce) { .ui-dot-live { animation: none; } }
.ui-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; line-height: 16px; color: var(--ui-muted); border: 1px solid var(--ui-border); border-radius: 4px; padding: 0 6px; white-space: nowrap; background: var(--ui-surface); }
.ui-count { display: inline-block; min-width: 20px; text-align: center; font-size: 11px; font-weight: 600; line-height: 16px; background: var(--ui-neutral-bg); color: var(--ui-neutral-fg); border-radius: 10px; padding: 1px 6px; font-variant-numeric: tabular-nums; }
.ui-count-warn { background: var(--ui-warn-bg); color: var(--ui-warn-fg); }
.ui-count-danger { background: var(--ui-danger-bg); color: var(--ui-danger-fg); }
/* Bootstrap badges: flatten to the same language. */
.badge { font-weight: 500; font-size: 11.5px; border-radius: 4px; padding: .3em .6em; }

/* ---------------------------------------------------------------- tabs */
.ui-tabs { display: flex; flex-wrap: wrap; gap: 0 22px; border-bottom: 1px solid var(--ui-border); margin-bottom: 16px; }
.ui-tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px 0; margin-bottom: -1px; font-size: 13.5px; color: var(--ui-muted); border: 0; border-bottom: 2px solid transparent; background: none; white-space: nowrap; }
.ui-tab:hover { color: var(--ui-text); text-decoration: none; }
.ui-tab.active { color: var(--ui-text); font-weight: 500; border-bottom-color: var(--ui-text); }
/* Section navigation: the tabs a sidebar section owns, rendered by the shell above the page. */
.ui-subnav { margin: -8px 0 24px; }
/* Old nav-pills/nav-tabs on un-migrated pages adopt the underline look. */
.nav-pills, .nav-tabs { gap: 0 22px; border-bottom: 1px solid var(--ui-border); }
.nav-pills .nav-link, .nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; border-radius: 0 !important; background: none !important; color: var(--ui-muted); padding: 10px 0; margin-bottom: -1px; font-size: 13.5px; font-weight: 400 !important; }
.nav-pills .nav-link.active, .nav-tabs .nav-link.active { color: var(--ui-text) !important; border-bottom-color: var(--ui-text); font-weight: 500 !important; }
.nav-pills .nav-link .material-icons-outlined, .nav-tabs .nav-link .material-icons-outlined { display: none; }

/* ---------------------------------------------------------------- toolbar & filters */
.ui-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.ui-toolbar-end { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ui-toolbar-end.is-active > .ui-muted { color: var(--ui-text); }
.ui-field { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm); background: var(--ui-surface); color: var(--ui-subtle); min-width: 0; }
.ui-field:focus-within { border-color: var(--ui-accent); box-shadow: 0 0 0 3px rgba(var(--ui-accent-rgb), .16); }
.ui-field input { border: 0; background: transparent; flex: 1; min-width: 0; font-size: 13px; outline: none; color: var(--ui-text); }
.ui-field .material-icons-outlined { font-size: 18px; }
.ui-select { height: 32px; font-size: 13px; padding: 0 2rem 0 .65rem; width: auto; max-width: 220px; }
.ui-select.is-set { border-color: var(--ui-accent); color: var(--ui-accent-hover); background-color: var(--ui-accent-soft); }

/* ---------------------------------------------------------------- data table */
.ui-table-card { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); overflow: hidden; }
/* position: relative keeps absolutely placed children (a .visually-hidden header label) inside
   the scroller; without it they sit at the table's full width and make the page scroll sideways. */
.ui-table-scroll { position: relative; overflow-x: auto; }
.ui-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 0; }
.ui-table th { font-size: 12px; font-weight: 500; color: var(--ui-subtle); text-align: left; padding: 10px 14px 9px; border-bottom: 1px solid var(--ui-border); white-space: nowrap; }
.ui-table th a { color: inherit; display: inline-flex; align-items: center; gap: 2px; }
.ui-table th a:hover { color: var(--ui-text); text-decoration: none; }
.ui-table th .material-icons-outlined { font-size: 16px; color: var(--ui-faint); }
.ui-table th a.sorted { color: var(--ui-text); }
.ui-table th a.sorted .material-icons-outlined { color: var(--ui-text); }
.ui-table td { padding: 10px 14px; border-bottom: 1px solid var(--ui-border-soft); color: var(--ui-text); vertical-align: middle; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ui-table tbody tr:last-child td { border-bottom: 0; }
.ui-table tbody tr:hover td { background: var(--ui-surface-2); }
.ui-table .num { text-align: right; }
.ui-table .actions { text-align: right; width: 1%; }
.ui-table .actions > * + * { margin-left: 4px; }
.ui-table .wrap { white-space: normal; }
.ui-cell-title { font-weight: 500; color: var(--ui-text); }
.ui-cell-title:hover { color: var(--ui-accent); }
.ui-cell-sub { font-size: 12px; color: var(--ui-subtle); margin-top: 1px; }
.ui-table-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--ui-border); font-size: 13px; color: var(--ui-muted); }
.ui-table-foot .ui-pager { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* Bootstrap tables on un-migrated pages. */
.table { --bs-table-bg: transparent; --bs-table-color: var(--ui-text); --bs-table-border-color: var(--ui-border-soft); --bs-table-hover-bg: var(--ui-surface-2); --bs-table-striped-bg: var(--ui-surface-2); font-size: 13.5px; }
.table > thead, .table-light { --bs-table-bg: transparent; --bs-table-color: var(--ui-subtle); --bs-table-border-color: var(--ui-border); }
.table > thead th { font-size: 12px; font-weight: 500; color: var(--ui-subtle); text-transform: none; white-space: nowrap; }

/* ---------------------------------------------------------------- banners */
.ui-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 16px; border-radius: var(--ui-radius); border: 1px solid var(--ui-border); background: var(--ui-surface); font-size: 13.5px; margin-bottom: 16px; }
.ui-banner .material-icons-outlined { font-size: 20px; }
.ui-banner-text { flex: 1 1 360px; min-width: 0; }
.ui-banner-text strong { font-weight: 600; }
.ui-banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ui-banner-danger { background: var(--ui-danger-banner-bg); border-color: var(--ui-danger-banner-border); color: var(--ui-danger-banner-fg); }
.ui-banner-warn { background: var(--ui-warn-banner-bg); border-color: var(--ui-warn-banner-border); color: var(--ui-warn-banner-fg); }
.ui-banner-info { background: var(--ui-info-banner-bg); border-color: var(--ui-info-banner-border); color: var(--ui-info-banner-fg); }
/* A quiet inline note inside a card or a form (no icon needed). */
.ui-note { font-size: 13px; color: var(--ui-muted); padding: 10px 12px; border-radius: var(--ui-radius-sm); background: var(--ui-surface-2); border: 1px solid var(--ui-border-soft); }
.ui-note strong { color: var(--ui-text); font-weight: 600; }

/* ---------------------------------------------------------------- data display */
.ui-kv { display: grid; grid-template-columns: minmax(96px, 140px) minmax(0, 1fr); gap: 9px 12px; margin: 0; font-size: 13.5px; align-items: baseline; }
.ui-kv dt { color: var(--ui-subtle); font-weight: 400; }
.ui-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.ui-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); }
.ui-kpi { padding: 14px 16px; border-left: 1px solid var(--ui-border-soft); min-width: 0; }
.ui-kpi:first-child { border-left: 0; }
.ui-kpi-label { font-size: 12.5px; color: var(--ui-muted); }
.ui-kpi-value { font-size: 24px; font-weight: 500; letter-spacing: -.015em; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.ui-kpi-value small { font-size: 13px; font-weight: 400; color: var(--ui-subtle); letter-spacing: 0; }
.ui-kpi-sub { font-size: 12px; color: var(--ui-subtle); margin-top: 2px; }
a.ui-kpi { display: block; color: inherit; text-decoration: none; }
a.ui-kpi:hover { background: var(--ui-surface-2); }
a.ui-kpi:hover .ui-kpi-label { color: var(--ui-accent); }
a.ui-kpi:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: -2px; }
.ui-meter { height: 8px; border-radius: 4px; background: var(--ui-neutral-bg); overflow: hidden; }
.ui-meter > span { display: block; height: 100%; background: var(--ui-ok-dot); border-radius: 4px; }
.ui-meter-accent > span { background: var(--ui-accent-fill); }
.ui-meter-warn > span { background: var(--ui-warn-dot); }
.ui-meter-danger > span { background: var(--ui-danger-dot); }
.ui-meter-sm { height: 5px; width: 72px; display: inline-block; vertical-align: middle; }
.ui-figure { font-size: 34px; font-weight: 500; letter-spacing: -.025em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ui-figure small { font-size: 15px; font-weight: 400; color: var(--ui-subtle); letter-spacing: 0; }
.ui-layout-rail { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
/* A main column with several cards sets them two abreast once each can be 760px wide (a 2560px
   screen and up); anything that is not a card (a section title, a form) keeps the whole row, and
   so does a card marked .ui-span. */
.ui-layout-rail > .ui-main-col { flex: 7 1 560px; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; align-content: start; }
.ui-layout-rail > .ui-main-col:has(> :is(.ui-card, .ui-table-card) ~ :is(.ui-card, .ui-table-card)) { grid-template-columns: repeat(auto-fit, minmax(min(100%, 760px), 1fr)); }
.ui-layout-rail > .ui-main-col > :not(.ui-card, .ui-table-card), .ui-layout-rail > .ui-main-col > .ui-span { grid-column: 1 / -1; }
.ui-layout-rail > .ui-rail { flex: 2 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
/* Beside the main column the rail takes a share of a wide page, up to 380px. The cap starts at a
   width where the two always sit side by side: a rail that wrapped under the column fills the line. */
@media (min-width: 1200px) { .ui-layout-rail > .ui-rail { max-width: 380px; } }
.ui-stack { display: flex; flex-direction: column; gap: 16px; }
/* Vertical rhythm for blocks placed straight in the page body (inside stacks the gap does it). */
.ui-content > :is(.ui-kpis, .ui-grid, .ui-card, .ui-table-card, .ui-layout-rail, .ui-stack, .ui-form) { margin-bottom: 16px; }

/* Responsive grids of cards. */
.ui-grid { display: grid; gap: 16px; }
.ui-grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.ui-grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.ui-section-title { font-size: 15px; font-weight: 600; margin: 8px 0 10px; letter-spacing: -.005em; }
.ui-mono { font-family: var(--ui-mono); font-size: .93em; letter-spacing: -.01em; }
.ui-page-title .ui-mono { font-size: .92em; font-weight: 500; letter-spacing: -.02em; }
.ui-code { font-family: var(--ui-mono); font-size: 12.5px; line-height: 1.55; background: var(--ui-surface-2); border: 1px solid var(--ui-border); border-radius: var(--ui-radius-sm); padding: 10px 12px; margin: 0; max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ui-text); }
.ui-muted { color: var(--ui-muted); }
.ui-subtle { color: var(--ui-subtle); }
.ui-num-pos { color: var(--ui-ok-fg); }
.ui-num-neg { color: var(--ui-danger-fg); }
/* <time> elements are rewritten to the viewer's zone by ui.js; the zone label is quieter. */
.ui-time { white-space: nowrap; }
.ui-time-zone { color: var(--ui-subtle); font-size: .88em; }

/* A value a person copies: the value in mono and a copy button that appears with it. */
.ui-copy { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; }
.ui-copy > :first-child { min-width: 0; overflow-wrap: anywhere; }
.ui-copy .btn { flex: none; color: var(--ui-faint); }
.ui-copy:hover .btn, .ui-copy .btn:focus-visible { color: var(--ui-text); }
/* Connection sheet: label, value to paste, copy button. One row per field. */
.ui-sheet { margin: 0; max-width: 760px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-sm); background: var(--ui-surface-2); container-type: inline-size; }
.ui-sheet > div { display: grid; grid-template-columns: minmax(110px, 170px) minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 7px 8px 7px 12px; border-bottom: 1px solid var(--ui-border-soft); font-size: 13.5px; }
.ui-sheet > div:last-child { border-bottom: 0; }
.ui-sheet dt { color: var(--ui-subtle); font-weight: 400; }
.ui-sheet dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-family: var(--ui-mono); font-size: 13px; }
/* In a narrow place (a rail card) the label column would leave the value a few pixels and break
   an address into pairs of characters: the label goes above, the value keeps the row. */
@container (max-width: 440px) {
  .ui-sheet > div { grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; padding-top: 8px; padding-bottom: 8px; }
  .ui-sheet dt { grid-column: 1 / -1; font-size: 12px; }
}

/* Plain divided list inside a card (recent items, side facts). */
.ui-list { list-style: none; margin: 0; padding: 0; }
.ui-list > li { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--ui-border-soft); font-size: 13.5px; min-width: 0; }
.ui-list > li:last-child { border-bottom: 0; }
.ui-list-main { flex: 1; min-width: 0; }
.ui-list-end { margin-left: auto; text-align: right; white-space: nowrap; }

/* A call as a sequence of moments: ring, answer, hang up. */
.ui-timeline { list-style: none; margin: 0; padding: 0; }
.ui-timeline > li { position: relative; padding: 0 0 18px 24px; font-size: 13.5px; }
.ui-timeline > li:last-child { padding-bottom: 0; }
.ui-timeline > li::before { content: ""; position: absolute; left: 3px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--ui-surface); border: 2px solid var(--ui-border-strong); }
.ui-timeline > li::after { content: ""; position: absolute; left: 7px; top: 17px; bottom: -3px; width: 1px; background: var(--ui-border); }
.ui-timeline > li:last-child::after { display: none; }
.ui-timeline > li.is-ok::before { background: var(--ui-ok-dot); border-color: var(--ui-ok-dot); }
.ui-timeline > li.is-warn::before { background: var(--ui-warn-dot); border-color: var(--ui-warn-dot); }
.ui-timeline > li.is-danger::before { background: var(--ui-danger-dot); border-color: var(--ui-danger-dot); }
.ui-timeline > li.is-skipped { color: var(--ui-subtle); }
.ui-timeline-what { font-weight: 500; }
.ui-timeline-when { display: block; font-size: 12.5px; color: var(--ui-subtle); }

/* Steps of a short flow (onboarding, new trunk). */
.ui-steps { display: flex; gap: 6px; list-style: none; margin: 0 0 24px; padding: 0; counter-reset: uistep; max-width: 960px; }
.ui-steps > li { flex: 1; min-width: 0; padding-top: 10px; border-top: 2px solid var(--ui-border); font-size: 13px; color: var(--ui-subtle); counter-increment: uistep; }
.ui-steps > li::before { content: counter(uistep, decimal-leading-zero); display: block; font-family: var(--ui-mono); font-size: 11px; color: var(--ui-faint); }
.ui-steps > li.is-done { border-top-color: var(--ui-text); color: var(--ui-text-2); }
.ui-steps > li.is-current { border-top-color: var(--ui-accent-fill); color: var(--ui-text); font-weight: 500; }
.ui-steps > li.is-current::before { color: var(--ui-accent); }
.ui-steps > li > button { all: unset; cursor: pointer; display: block; width: 100%; }
.ui-steps > li > button:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }

/* Pick one of a few things (what are you connecting?): radio inputs drawn as tiles. */
.ui-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
.ui-choice { position: relative; display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius-sm); background: var(--ui-surface); cursor: pointer; min-width: 0; }
.ui-choice:hover { background: var(--ui-surface-2); }
.ui-choice input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.ui-choice:has(input:checked) { border-color: var(--ui-accent-fill); box-shadow: inset 0 0 0 1px var(--ui-accent-fill); background: var(--ui-accent-soft); }
.ui-choice:has(input:focus-visible) { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.ui-choice-name { font-size: 13.5px; font-weight: 500; color: var(--ui-text); }
.ui-choice-hint { font-size: 12px; color: var(--ui-subtle); }

/* Simple bar for small inline charts: <div class="ui-bars"><span style="height:40%"></span>…</div> */
.ui-bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.ui-bars > span { flex: 1; min-width: 3px; background: var(--ui-accent-fill); opacity: .85; border-radius: 2px 2px 0 0; }
.ui-bars > span:hover { opacity: 1; }
.ui-bars-sm { height: 44px; gap: 2px; }

/* ---------------------------------------------------------------- forms
 * <form class="ui-form">
 *   <section class="ui-form-section">
 *     <div class="ui-form-section-head"><h2>Title</h2><p>What these settings do.</p></div>
 *     <div class="ui-form-fields"> …fields; .ui-span-2 for full width… </div>
 *   </section>
 *   <div class="ui-form-actions"> Cancel · Save </div>
 * </form>
 */
/* A form is one column of sections, 960px at most. A form with several sections, where the page
   has room for two columns of at least 880px (screens wider than 1920px), sets them two abreast,
   so a long form is on screen at once. Wizards and narrow forms stay in one column; anything
   that is not a section (the actions bar, a notice) keeps the whole row. */
.ui-form { max-width: 960px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.ui-form:has(> .ui-form-section ~ .ui-form-section):not(.ui-form-narrow, [data-steps]) { max-width: 1936px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 880px), 960px)); }
.ui-form > :not(.ui-form-section) { grid-column: 1 / -1; }
/* A section standing on its own under a form (the security card on the profile) is as wide as
   one column of it. */
.ui-content > .ui-form-section { max-width: 960px; }
.ui-form-narrow { max-width: 640px; }
.ui-form-section { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; padding: 20px; background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); }
.ui-form-section-head h2 { font-size: 14px; font-weight: 600; margin: 0 0 4px; }
.ui-form-section-head p { font-size: 13px; color: var(--ui-subtle); margin: 0; }
.ui-form-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; align-content: start; }
.ui-form-fields > * { min-width: 0; }
.ui-form-fields > .ui-span-2, .ui-form-fields > .form-check, .ui-form-fields > .ui-check-row { grid-column: 1 / -1; }
.ui-form-fields .form-label { margin-bottom: .3rem; }
.ui-form-fields .mb-3 { margin-bottom: 0 !important; }
.ui-check-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-sm); }
.ui-check-row .form-check-input { margin-top: 2px; flex: none; }
.ui-check-row-text { font-size: 13.5px; }
.ui-check-row-text strong { display: block; font-weight: 500; }
.ui-check-row-text span { color: var(--ui-subtle); font-size: 12.5px; }
.ui-form-actions { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 0; background: linear-gradient(to bottom, transparent, var(--ui-bg) 35%); }
.ui-form-actions .ui-form-actions-start { margin-right: auto; }
@media (max-width: 767.98px) {
  .ui-form-section { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px; }
  .ui-form-fields { grid-template-columns: minmax(0, 1fr); }
  .ui-steps > li { font-size: 0; }
  .ui-steps > li.is-current { font-size: 13px; flex: 3; }
}
.invalid-feedback, .form-error { font-size: 12px; color: var(--ui-danger-fg); }
.is-invalid { border-color: var(--ui-danger-dot) !important; }

.ui-empty { text-align: center; padding: 44px 16px; color: var(--ui-muted); }
.ui-empty .material-icons-outlined { font-size: 30px; color: var(--ui-faint); }
.ui-empty-title { margin: 10px 0 4px; font-size: 15px; font-weight: 600; color: var(--ui-text); }
.ui-empty p { font-size: 13.5px; margin: 0 auto 16px; max-width: 46ch; }
.ui-empty p:last-child { margin-bottom: 0; }

/* Scrollable, bordered checklist (communication/new company picker). */
.ui-picklist { border: 1px solid var(--ui-border); border-radius: var(--ui-radius-sm); background: var(--ui-surface); max-height: 360px; overflow-y: auto; }
.ui-picklist .form-check { margin: 0; padding: 8px 12px 8px 36px; border-bottom: 1px solid var(--ui-border-soft); }
.ui-picklist .form-check:last-child { border-bottom: 0; }
.ui-picklist .form-check:hover { background: var(--ui-hover); }
.ui-picklist .form-check[hidden] { display: none; }
/* Rendered campaign body (communication/show). */
.ui-email-preview { max-height: 420px; overflow-y: auto; font-size: 13px; overflow-wrap: anywhere; }
.ui-email-preview-frame { display: block; width: 100%; height: 420px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); background: #fff; }

/* ---------------------------------------------------------------- toasts */
.ui-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1090; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.ui-toast { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; background: var(--ui-side-bg); border-radius: var(--ui-radius); box-shadow: var(--ui-shadow-pop); font-size: 13.5px; color: #fff; }
.ui-toast .material-icons-outlined { font-size: 18px; }
.ui-toast-success .material-icons-outlined { color: #5FD897; }
.ui-toast-danger .material-icons-outlined { color: #FF8A7C; }
.ui-toast-info .material-icons-outlined { color: var(--ui-side-accent); }
.ui-toast .btn-close { margin-left: auto; font-size: 10px; filter: invert(1) grayscale(1) brightness(2); }

/* ---------------------------------------------------------------- page-specific (portal) */
/* portal: numbers/dashboard */
.ui-chart-box { position: relative; height: 300px; }
.ui-chart-box-sm { height: 200px; }
.ui-narrow { max-width: 640px; }

/* portal: trunk groups (drag to reorder) */
.ui-sortable > li { cursor: move; }
.ui-sortable > li:hover { background: var(--ui-hover); }
.ui-sortable > li.dragging { opacity: .5; background: var(--ui-accent-soft); }
.ui-sortable > li.drag-over { box-shadow: inset 0 3px 0 var(--ui-accent); }
.ui-drag-handle { cursor: grab; color: var(--ui-subtle); }
.ui-drag-handle:active { cursor: grabbing; }

/* portal: numbers selection tables */
.ui-col-check { width: 36px; }
.ui-table tr.is-selected td { background: var(--ui-accent-soft); }
/* Pick sheet: a list of single values to choose from (numbers to buy) set as a ledger of cells,
   as many across as fit, so a hundred of them are on screen at once. Each cell is a label around
   its checkbox. A column is as wide as the longest value (--pick-ch, in characters, set by the
   page) plus the checkbox, so nothing is cut and no room is given away. */
.ui-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--pick-ch, 17) * 1ch + 50px)), 1fr)); overflow: hidden; font-family: var(--ui-mono); font-size: 13px; }
.ui-pick { display: flex; align-items: center; gap: 8px; min-width: 0; height: 38px; margin: 0 -1px -1px 0; padding: 0 12px; border-right: 1px solid var(--ui-border-soft); border-bottom: 1px solid var(--ui-border-soft); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ui-text); cursor: pointer; }
.ui-pick > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ui-pick:hover { background: var(--ui-surface-2); }
.ui-pick:has(:checked) { background: var(--ui-accent-soft); font-weight: 500; }
.ui-pick:has(:focus-visible) { outline: 2px solid var(--ui-accent); outline-offset: -2px; }
.ui-pick .form-check-input { margin: 0; flex: none; }
.ui-bulk-list { display: flex; flex-direction: column; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); max-height: 40vh; overflow-y: auto; }
.ui-bulk-list > * { padding: 8px 12px; border-top: 1px solid var(--ui-border-soft); }
.ui-bulk-list > :first-child { border-top: 0; }

/* portal: profile 2FA setup (QR codes must stay on white to scan) */
.ui-qr { display: inline-block; padding: 12px; background: #fff; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); line-height: 0; }
.ui-qr img { width: 220px; height: 220px; max-width: 100%; }
.ui-code-input { text-align: center; font-size: 22px; letter-spacing: .3em; font-family: var(--ui-mono); }

/* portal: home */
.ui-home-lead { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); margin-bottom: 16px; }
.ui-home-lead > * { padding: 18px 20px; border-left: 1px solid var(--ui-border-soft); min-width: 0; }
.ui-home-lead > :first-child { border-left: 0; }
.ui-home-lead h2 { font-size: 12.5px; font-weight: 400; color: var(--ui-muted); margin: 0 0 6px; letter-spacing: 0; }
.ui-home-lead p { font-size: 12.5px; color: var(--ui-subtle); margin: 8px 0 0; }
@media (max-width: 900px) {
  .ui-home-lead { grid-template-columns: minmax(0, 1fr); }
  .ui-home-lead > * { border-left: 0; border-top: 1px solid var(--ui-border-soft); }
  .ui-home-lead > :first-child { border-top: 0; }
}

/* Channels in use over 24 hours: one column per ten minutes, as high as the most calls up at
 * once in it, under the channel limit (the dashed line). `--top` is the height of the chart in
 * channels and `--cap` the limit; up to twelve channels each one is a lane (`has-lanes`), 12px
 * high until the chart is 72px. A column at the limit is `is-full`. calls.js adds the hour axis and the reading under the pointer.
 * <section class="ui-occupancy" data-occupancy='{"from": 1794300000, "slot": 600}'>
 *   <div class="ui-occupancy-head"><div class="ui-figure">2 <small>of 4</small></div><p class="ui-occupancy-readout" data-occupancy-readout>…</p></div>
 *   <div class="ui-occupancy-plot has-lanes" style="--top: 4; --cap: 4" data-occupancy-plot><i></i><i style="--v: 2"></i>…</div>
 *   <div class="ui-occupancy-axis" data-occupancy-axis></div></section> */
.ui-occupancy-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; }
.ui-home-lead .ui-occupancy-readout { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ui-occupancy-readout b { font-weight: 600; color: var(--ui-text); }
.ui-occupancy-readout .ui-occupancy-when { color: var(--ui-text); font-weight: 500; }
.ui-occupancy-plot { position: relative; isolation: isolate; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; height: clamp(40px, calc(var(--top, 6) * 12px), 72px); margin-top: 13px; border-bottom: 1px solid var(--ui-border); touch-action: pan-y; }
.ui-occupancy-plot > i { display: block; height: calc(var(--v, 0) / var(--top, 1) * 100%); background: var(--ui-accent-fill); transform-origin: bottom; }
.ui-occupancy-plot > i[style] { min-height: 2px; }
.ui-occupancy-plot > i.is-full { background: var(--ui-warn-dot); }
.ui-occupancy-plot::before { content: ""; position: absolute; left: 0; right: 0; bottom: calc(var(--cap, 1) / var(--top, 1) * 100%); border-top: 1px dashed var(--ui-border-strong); pointer-events: none; }
.ui-occupancy-plot.has-lanes::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(to top, transparent 0, transparent calc(100% / var(--top, 1) - 1px), var(--ui-surface) calc(100% / var(--top, 1) - 1px), var(--ui-surface) calc(100% / var(--top, 1))); }
.ui-occupancy-mark { position: absolute; top: 0; bottom: 0; z-index: -1; background: var(--ui-surface-2); }
.ui-occupancy-plot.is-hovering > i { opacity: .45; }
.ui-occupancy-plot.is-hovering > i.is-hot { opacity: 1; }
.ui-occupancy-axis { position: relative; height: 14px; margin-top: 5px; font-family: var(--ui-mono); font-size: 11px; line-height: 14px; color: var(--ui-faint); }
.ui-occupancy-axis > span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.ui-occupancy-axis > span.is-day { color: var(--ui-subtle); }
.ui-occupancy-axis > span.is-now { left: auto; right: 0; transform: none; color: var(--ui-text); font-weight: 500; }
@media (prefers-reduced-motion: no-preference) {
  .ui-occupancy-plot.is-arriving > i { animation: ui-traffic-rise .42s cubic-bezier(.2, .7, .2, 1) backwards; animation-delay: calc(var(--at, 0) * 380ms); }
  .ui-occupancy-plot > i { transition: opacity .12s; }
}

/* Home's latest calls. Four columns, so the call bars fit a narrower card than on the calls page;
   a card with room to spare gives it to the bars and adds the trunk. */
.ui-home-recent { container: home-recent / inline-size; }
.ui-home-recent-extra { display: none; }
@container home-recent (min-width: 680px) { .ui-home-recent .ui-callshape-col { width: 30%; } }
@container home-recent (min-width: 900px) { .ui-home-recent .ui-callshape-col { width: 38%; } }
@container home-recent (min-width: 1100px) { .ui-home-recent-extra { display: table-cell; } }
@container home-recent (max-width: 899.98px) { .ui-home-recent .ui-callshape-max { display: none; } }
@container home-recent (max-width: 679.98px) {
  .ui-home-recent :is(.ui-callshape, .ui-callshape-scale) { min-width: 0; }
  .ui-home-recent .ui-callshape > i { display: none; }
  .ui-home-recent .ui-callshape > span { margin-left: 0; }
}

/* Choices as full-width rows, each with a radio mark, a name and a line of explanation. */
.ui-choices-stack { grid-template-columns: minmax(0, 1fr); }
.ui-choices-stack .ui-choice { padding: 11px 14px 11px 42px; }
.ui-choices-stack .ui-choice::before { content: ""; position: absolute; left: 14px; top: 14px; width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--ui-border-strong); background: var(--ui-surface); }
.ui-choices-stack .ui-choice:has(input:checked)::before { border-color: var(--ui-accent-fill); background: var(--ui-accent-fill); box-shadow: inset 0 0 0 3px var(--ui-surface); }
.ui-choices-stack .ui-choice-hint { font-size: 12.5px; }

details > summary { cursor: pointer; font-size: 13.5px; width: fit-content; }
details > summary:hover { color: var(--ui-text); }
.tab-content > .tab-pane { display: none; }
.tab-content > .tab-pane.active { display: block; }

/* A stepped form scrolls back to its steps, clear of the sticky top bar and with the page title in view. */
form[data-steps] { scroll-margin-top: 132px; }
.ui-choices-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 575.98px) { .ui-choices-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* A call drawn to scale: how long it rang, how long people talked.
 * <div class="ui-callbar"><span class="ui-callbar-ring" style="flex-grow:4"><span>Rang 4s</span></span>
 *                         <span class="ui-callbar-talk" style="flex-grow:100"><span>Talked 1m 40s</span></span></div> */
.ui-callbar { display: flex; gap: 2px; margin: 2px 0 34px; }
.ui-callbar > span { position: relative; flex: 1 1 0; min-width: 28px; height: 8px; border-radius: 2px; }
.ui-callbar > span > span { position: absolute; left: 0; top: 14px; font-size: 12px; color: var(--ui-subtle); white-space: nowrap; }
.ui-callbar > span:last-child:not(:first-child) > span { left: auto; right: 0; }
.ui-callbar-ring { background: repeating-linear-gradient(90deg, var(--ui-border-strong) 0 4px, transparent 4px 7px); }
.ui-callbar-talk { background: var(--ui-accent-fill); }

/* The same call in a table row: ringing (dashes) and talking (solid) on one scale for every row
 * of the page, the duration right after the bar. --ring and --talk are percentages of that scale;
 * the column header prints the scale's full length where a bar of 100% would end.
 * <th class="ui-callshape-col"><span class="ui-callshape-scale"><span>Duration</span><span class="ui-callshape-max">5m</span></span></th>
 * <td><div class="ui-callshape" style="--ring: 2.6; --talk: 43.3"><i class="ui-callshape-ring"></i><i class="ui-callshape-talk"></i><span>2m 10s</span></div></td> */
.ui-callshape, .ui-callshape-scale { --label: 84px; position: relative; display: flex; align-items: center; min-width: 150px; }
.ui-callshape > i { flex: none; display: block; height: 6px; min-width: 3px; border-radius: 1px; }
.ui-callshape > i + i { margin-left: 2px; }
.ui-callshape-ring { width: calc((100% - var(--label)) * var(--ring, 0) / 100); background: repeating-linear-gradient(90deg, var(--ui-border-strong) 0 3px, transparent 3px 5px); }
.ui-callshape-talk { width: calc((100% - var(--label)) * var(--talk, 0) / 100); background: var(--ui-accent-fill); }
/* Longer than the scale: the bar fills it and ends in a point. */
.ui-callshape.is-over > i:last-of-type { clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 50%, calc(100% - 4px) 100%, 0 100%); }
.ui-callshape > span { margin-left: 8px; }
.ui-callshape > span:first-child { margin-left: 0; }
.ui-callshape-max { position: absolute; right: var(--label); padding-right: 5px; border-right: 1px solid var(--ui-border-strong); color: var(--ui-faint); font-family: var(--ui-mono); font-size: 11px; line-height: 12px; }
.ui-table tbody tr:hover .ui-callshape-talk { background: var(--ui-accent-hover); }

/* Traffic strip: calls over time above the list they summarise. One cell per day (per week on a
 * very long range), and inside a day as many slices as the width can hold, down to one an hour.
 * calls.js draws the cells from data-traffic and turns a click or a drag into the list's dates.
 * <section class="ui-card ui-traffic" data-traffic="{…}">
 *   <div class="ui-card-head">… <div class="ui-traffic-readout" data-traffic-readout>Calls <b>1,284</b>…</div></div>
 *   <div class="ui-traffic-body"><div class="ui-traffic-plot" data-traffic-plot></div><div class="ui-traffic-axis" data-traffic-axis></div></div>
 * </section> */
.ui-traffic > .ui-card-head { border-bottom: 0; padding-bottom: 6px; min-height: 46px; }
.ui-traffic-legend { display: inline-flex; gap: 12px; margin-left: 6px; font-size: 12px; color: var(--ui-subtle); white-space: nowrap; }
.ui-traffic-legend i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 2px; background: var(--ui-accent-fill); }
.ui-traffic-legend i.is-missed { background: var(--ui-border-strong); }
.ui-traffic-readout { margin-left: auto; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; gap: 2px 20px; font-size: 12.5px; color: var(--ui-subtle); white-space: nowrap; }
.ui-traffic-readout b { margin-left: 5px; font-size: 14px; font-weight: 600; color: var(--ui-text); font-variant-numeric: tabular-nums; }
.ui-traffic-readout .ui-traffic-when { color: var(--ui-text); font-weight: 500; }
.ui-traffic-body { padding: 2px 16px 10px; }
.ui-traffic-plot, .ui-traffic-axis { display: grid; grid-template-columns: repeat(var(--cells, 30), minmax(0, 1fr)); gap: 0 var(--cell-gap, 2px); }
.ui-traffic-plot { height: 76px; border-bottom: 1px solid var(--ui-border); cursor: pointer; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.ui-traffic-cell { display: flex; align-items: flex-end; gap: var(--slice-gap, 1px); min-width: 0; height: 100%; border-radius: 2px 2px 0 0; }
.ui-traffic-cell.is-hot { background: var(--ui-surface-2); }
.ui-traffic-cell.is-picked { background: var(--ui-accent-soft); }
.ui-traffic-slice { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; transform-origin: bottom; }
.ui-traffic-slice > b, .ui-traffic-slice > i { display: block; flex: none; min-height: 2px; }
.ui-traffic-slice > b { background: var(--ui-border-strong); }
.ui-traffic-slice > i { background: var(--ui-accent-fill); }
.ui-traffic-slice > :first-child { border-radius: 1px 1px 0 0; }
.ui-traffic-plot.is-hovering .ui-traffic-slice { opacity: .5; }
.ui-traffic-plot.is-hovering .ui-traffic-cell.is-hot .ui-traffic-slice { opacity: .8; }
.ui-traffic-plot.is-hovering .ui-traffic-slice.is-hot, .ui-traffic-plot.is-hovering .ui-traffic-cell.is-picked .ui-traffic-slice { opacity: 1; }
.ui-traffic-axis { margin-top: 5px; height: 14px; font-family: var(--ui-mono); font-size: 11px; line-height: 14px; color: var(--ui-faint); }
.ui-traffic-axis > span { position: relative; display: flex; justify-content: center; min-width: 0; white-space: nowrap; }
.ui-traffic-axis > span.is-start { justify-content: flex-start; }
.ui-traffic-axis > span.is-month { color: var(--ui-subtle); }
.ui-traffic-axis > span.is-today { color: var(--ui-text); font-weight: 500; }
.ui-traffic-axis em { position: absolute; top: 0; font-style: normal; transform: translateX(-50%); }
/* The bars rise once, when the page arrives. */
@media (prefers-reduced-motion: no-preference) {
  .ui-traffic-plot.is-arriving .ui-traffic-slice { animation: ui-traffic-rise .42s cubic-bezier(.2, .7, .2, 1) backwards; animation-delay: calc(var(--at, 0) * 380ms); }
  .ui-traffic-slice { transition: opacity .12s; }
}
@keyframes ui-traffic-rise { from { transform: scaleY(0); } }
@media (max-width: 767.98px) {
  .ui-traffic-legend { display: none; }
  .ui-traffic-readout { margin-left: 0; justify-content: flex-start; flex-basis: 100%; }
}

/* A list with the selected row's detail beside it. The panel only exists on a window wide enough
 * (1620px) for the list to keep its columns next to it; below that the row's link goes to the
 * detail page as it always did.
 * <div class="ui-peek-layout" data-peek><section class="ui-table-card">…<tr data-peek-url="/cdrs/12">…</section>
 *   <aside class="ui-peek" data-peek-panel><div class="ui-peek-bar">…</div><div class="ui-peek-body" data-peek-body></div></aside></div> */
.ui-peek-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
/* The list is a size container, so its columns can answer to the room it has. That also makes it
   the containing block of fixed-position descendants: no Popper menus (strategy: fixed) in here. */
.ui-peek-layout > .ui-table-card { container: peek-list / inline-size; }
.ui-peek { display: none; }
/* Width the list can spare goes to the bars, a third of it at most (a table never takes a
   column below its content, so a list with little to spare gives less than this asks for).
   A list too narrow for them drops the bars and keeps the duration, as before they existed. */
@container peek-list (min-width: 1130px) { .ui-callshape-col { width: 34%; } }
@container peek-list (max-width: 1299.98px) { .ui-callshape-max { display: none; } }
@container peek-list (max-width: 1129.98px) {
  .ui-peek-layout:not(.is-open) :is(.ui-callshape, .ui-callshape-scale) { min-width: 0; }
  .ui-peek-layout:not(.is-open) .ui-callshape > i { display: none; }
  .ui-peek-layout:not(.is-open) .ui-callshape > span { margin-left: 0; }
  /* Beside the open panel the list gives up what the panel repeats: `ui-peek-extra` columns
     first, then the bars, then `ui-peek-extra-2`. With the panel closed every column stays. */
  .ui-peek-layout.is-open .ui-peek-extra { display: none; }
  .ui-peek-layout.is-open .ui-callshape-col { width: 30%; }
}
@container peek-list (max-width: 989.98px) {
  .ui-peek-layout.is-open :is(.ui-callshape, .ui-callshape-scale) { min-width: 0; }
  .ui-peek-layout.is-open .ui-callshape > i { display: none; }
  .ui-peek-layout.is-open .ui-callshape > span { margin-left: 0; }
  .ui-peek-layout.is-open .ui-callshape-col { width: auto; }
}
@container peek-list (max-width: 879.98px) { .ui-peek-layout.is-open .ui-peek-extra-2 { display: none; } }
.ui-table tr.is-selected td:first-child { box-shadow: inset 2px 0 0 var(--ui-accent-fill); }
/* Walking the list with the keyboard keeps the selected row clear of the sticky top bar. */
.ui-peek-layout tbody tr { scroll-margin: calc(var(--ui-topbar-h) + 12px) 0 12px; }
@media (min-width: 1620px) {
  .ui-peek-layout.is-peekable tbody tr { cursor: pointer; }
  .ui-peek-layout.is-open { grid-template-columns: minmax(0, 1fr) clamp(400px, 26%, 620px); }
  .ui-peek-layout.is-open > .ui-peek {
    display: flex; flex-direction: column;
    position: sticky; top: calc(var(--ui-topbar-h) + 16px); max-height: calc(100vh - var(--ui-topbar-h) - 32px);
    background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); overflow: hidden;
  }
}
.ui-peek-bar { display: flex; align-items: center; gap: 2px; padding: 5px 8px 5px 16px; border-bottom: 1px solid var(--ui-border-soft); font-size: 12.5px; color: var(--ui-subtle); }
.ui-peek-pos { margin-right: auto; }
.ui-peek-body { overflow-y: auto; padding: 16px 16px 4px; transition: opacity .12s; }
.ui-peek[aria-busy="true"] .ui-peek-body { opacity: .45; }
.ui-peek-body .ui-page-header { margin-bottom: 14px; }
.ui-peek-body .ui-page-title { font-size: 17px; gap: 6px 10px; }
.ui-peek-body .ui-layout-rail, .ui-peek-body .ui-main-col, .ui-peek-body .ui-rail { display: block; max-width: none; }
.ui-peek-body .ui-card { border: 0; border-top: 1px solid var(--ui-border-soft); border-radius: 0; background: none; }
.ui-peek-body .ui-card-head { padding: 12px 0 2px; border-bottom: 0; }
.ui-peek-body .ui-card-body { padding: 6px 0 14px; }

.ui-narrow { display: flex; flex-direction: column; gap: 16px; }

/* Button labels stay on one line. */
.btn { white-space: nowrap; }

/* A long value in a table cell (SIP URI, URL): one line, cut with an ellipsis; the full value is the title. */
.ui-clip { display: inline-block; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
