/* ==========================================================================
   Copper Scheduling — design tokens & Bootstrap theming

   Loaded after bootstrap.min.css (see main.ts). Everything in here is either
   a token definition or a re-binding of a Bootstrap CSS variable, so that
   component styles never need to hardcode a colour.
   ========================================================================== */

:root {
  /* --- Brand scale -------------------------------------------------------
     Derived from the logo, which is built from #5ec1ad (light teal) and
     #145e53 (dark teal). The scale keeps that hue (~168deg) and varies
     lightness/saturation so we get usable tints and shades.
     600 is the primary action colour: 5.39:1 against white (WCAG AA). */
  --cu-brand-50: #f2f8f7;
  --cu-brand-100: #ddeeeb;
  --cu-brand-200: #b2dcd4;
  --cu-brand-300: #75c7b7;
  --cu-brand-400: #42b39d;
  --cu-brand-500: #30917f;
  --cu-brand-600: #227766;
  --cu-brand-700: #186254;
  --cu-brand-800: #114a3f;
  --cu-brand-900: #0b322b;

  --cu-brand-rgb: 34, 119, 102; /* = --cu-brand-600, for rgba() composition */

  /* The two colours lifted verbatim from the logo. Use these for the mark
     itself and for accents that sit on dark brand surfaces, where the 600
     shade is too dark to read. */
  --cu-logo-teal: #5ec1ad;
  --cu-logo-teal-dark: #145e53;

  /* --- Surfaces ---------------------------------------------------------- */
  --cu-surface: #ffffff;
  --cu-surface-sunken: #f7f8f9;
  --cu-surface-accent: var(--cu-brand-50);

  /* --- Borders ----------------------------------------------------------- */
  --cu-border: #e3e6e8;
  --cu-border-strong: #cdd2d6;
  --cu-border-accent: var(--cu-brand-200);

  /* --- Text -------------------------------------------------------------- */
  --cu-text: #1c2529;
  --cu-text-muted: #5f6c72;
  --cu-text-subtle: #8a959b;

  /* --- Typography ---------------------------------------------------------
     Inter is self-hosted via @fontsource-variable (no external request, works
     behind a firewall). The variable file covers 100–900, so weights are free.

     The scale below replaces sixteen separately-chosen font sizes that had
     drifted into near-duplicates — 0.625, 0.6875, 0.7, 0.75, 0.8125, 0.875,
     0.9, 0.9375rem all appeared, several of them one pixel apart. */
  --cu-font-sans: "Inter Variable", "Inter", system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --cu-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;

  --cu-text-2xs: 0.6875rem;  /* 11px — micro labels: version, month, flags */
  --cu-text-xs: 0.75rem;     /* 12px — badges, column headers, small caps */
  --cu-text-sm: 0.8125rem;   /* 13px — secondary and supporting text */
  --cu-text-md: 0.875rem;    /* 14px — dense body, code */
  --cu-text-base: 0.9375rem; /* 15px — app default */
  --cu-text-lg: 1rem;        /* 16px — wordmark */
  --cu-text-xl: 1.125rem;    /* 18px — emphasised numerals */
  --cu-text-2xl: 1.25rem;    /* 20px — page headings */
  --cu-text-3xl: 1.5rem;     /* 24px — card titles */

  /* Icon sizing is deliberately a separate scale: an icon's font-size is a
     glyph dimension, not a reading size, so it should not track body text. */
  --cu-icon-sm: 0.875rem;
  --cu-icon-md: 1.0625rem;
  --cu-icon-lg: 1.25rem;
  --cu-icon-xl: 2.5rem;

  /* --- Radii ------------------------------------------------------------- */
  --cu-radius-sm: 0.25rem;
  --cu-radius: 0.5rem;
  --cu-radius-lg: 0.75rem;
  --cu-radius-pill: 999px;

  /* --- Elevation ---------------------------------------------------------
     Shadows are tinted with the dark brand colour rather than pure black,
     which keeps them from looking grey against the teal palette. */
  --cu-shadow-sm: 0 1px 2px rgba(16, 54, 48, 0.06), 0 1px 3px rgba(16, 54, 48, 0.08);
  --cu-shadow: 0 2px 4px rgba(16, 54, 48, 0.06), 0 4px 12px rgba(16, 54, 48, 0.10);
  --cu-shadow-lg: 0 8px 24px rgba(16, 54, 48, 0.14);

  /* --- Status colours ----------------------------------------------------
     Tuned for a small glyph on a near-white surface, which Bootstrap's own
     semantic colours do not handle well at either end: --bs-warning is far too
     pale to read (1.6:1), while --bs-warning-text-emphasis is so dark (8:1)
     that it stops registering as a colour at all — it is meant for text on an
     amber background, not for a standalone icon.

     Each of these clears the 3:1 minimum for graphical indicators against
     every surface it actually appears on, including the tinted diff rows in
     the nomination table, where the warning triangle sits. */
  --cu-status-ok: #00964e;
  --cu-status-warning: #c47a00;
  --cu-status-error: #e03131;
  --cu-status-info: var(--cu-brand-600);
  --cu-status-pending: var(--cu-text-muted);
  --cu-status-none: var(--cu-text-subtle);

  /* --- Chart series --------------------------------------------------------
     The two profile lines need to be told apart at a glance in a 2px stroke.
     The first pairing (brand teal against indigo) sat only 64deg apart in hue
     and read as two similar cool colours. Teal against orange is 149deg apart
     — near-complementary — and is also the pairing that survives red/green
     colour blindness, which teal against violet does not. */
  --cu-chart-ours: #0d7d6b;
  --cu-chart-theirs: #e8590c;

  /* --- Code syntax ---------------------------------------------------------
     Used by the highlighted code samples. Each clears 4.5:1 against the
     sunken surface the code panels sit on. Types take the brand teal; the
     rest are spread around the wheel so neighbouring tokens stay distinct. */
  --cu-code-keyword: #7c3aed;
  --cu-code-string: #2f7d32;
  --cu-code-number: #b45309;
  --cu-code-function: #1d4ed8;
  --cu-code-type: #0d7d6b;
  --cu-code-comment: var(--cu-text-muted);

  /* --- Motion ------------------------------------------------------------ */
  --cu-transition: 0.15s ease-in-out;
}

/* ==========================================================================
   Bootstrap variable re-binding
   ========================================================================== */

:root,
[data-bs-theme="light"] {
  --bs-primary: var(--cu-brand-600);
  --bs-primary-rgb: var(--cu-brand-rgb);
  --bs-primary-text-emphasis: var(--cu-brand-800);
  --bs-primary-bg-subtle: var(--cu-brand-100);
  --bs-primary-border-subtle: var(--cu-brand-200);

  /* Links use 700 rather than 600 — underlined body text needs the extra
     contrast more than a button does. */
  --bs-link-color: var(--cu-brand-700);
  --bs-link-color-rgb: 24, 98, 84;
  --bs-link-hover-color: var(--cu-brand-800);
  --bs-link-hover-color-rgb: 17, 74, 63;

  --bs-focus-ring-color: rgba(var(--cu-brand-rgb), 0.25);

  --bs-border-color: var(--cu-border);
  --bs-border-radius: var(--cu-radius-sm);
  --bs-border-radius-lg: var(--cu-radius);

  --bs-body-font-family: var(--cu-font-sans);
  --bs-font-monospace: var(--cu-font-mono);

  /* The one broad change in this pass: 16px → 15px throughout. A scheduling
     tool is read in dense tables, and 15px is the usual base for that kind of
     UI. Revert this single line to go back to Bootstrap's default. */
  --bs-body-font-size: var(--cu-text-base);

  /* Body text is a touch darker and cooler than Bootstrap's #212529. The
     -rgb / secondary / tertiary values are kept in step so .text-muted and
     friends stay consistent with it. */
  --bs-body-color: var(--cu-text);
  --bs-body-color-rgb: 28, 37, 41;
  --bs-secondary-color: rgba(28, 37, 41, 0.75);
  --bs-secondary-color-rgb: 28, 37, 41;
  --bs-tertiary-color: rgba(28, 37, 41, 0.5);
  --bs-tertiary-color-rgb: 28, 37, 41;
  --bs-tertiary-bg: var(--cu-surface-sunken);
}

/* --- Buttons -------------------------------------------------------------
   Bootstrap bakes literal hex values into each .btn-* variant, so the
   variants have to be restated rather than inheriting --bs-primary. */

.btn-primary {
  --bs-btn-bg: var(--cu-brand-600);
  --bs-btn-border-color: var(--cu-brand-600);
  --bs-btn-hover-bg: var(--cu-brand-700);
  --bs-btn-hover-border-color: var(--cu-brand-700);
  --bs-btn-active-bg: var(--cu-brand-800);
  --bs-btn-active-border-color: var(--cu-brand-800);
  --bs-btn-disabled-bg: var(--cu-brand-600);
  --bs-btn-disabled-border-color: var(--cu-brand-600);
  --bs-btn-focus-shadow-rgb: var(--cu-brand-rgb);
}

.btn-outline-primary {
  --bs-btn-color: var(--cu-brand-700);
  --bs-btn-border-color: var(--cu-brand-600);
  --bs-btn-hover-bg: var(--cu-brand-600);
  --bs-btn-hover-border-color: var(--cu-brand-600);
  --bs-btn-active-bg: var(--cu-brand-700);
  --bs-btn-active-border-color: var(--cu-brand-700);
  --bs-btn-disabled-color: var(--cu-brand-600);
  --bs-btn-disabled-border-color: var(--cu-brand-600);
  --bs-btn-focus-shadow-rgb: var(--cu-brand-rgb);
}

/* A bare .btn (used throughout for the emoji icon buttons) never gets a
   focus ring in stock Bootstrap: --bs-btn-focus-shadow-rgb is undefined, so
   the rgba() resolves to nothing. Give it the brand ring. */
.btn {
  --bs-btn-focus-shadow-rgb: var(--cu-brand-rgb);
}

/* --- Navigation ---------------------------------------------------------- */

.nav-pills {
  --bs-nav-pills-link-active-bg: var(--cu-brand-600);
}

/* --- Dropdowns & list groups --------------------------------------------- */

.dropdown-menu {
  --bs-dropdown-link-active-bg: var(--cu-brand-600);
  --bs-dropdown-border-color: var(--cu-border);
  --bs-dropdown-border-radius: var(--cu-radius);
}

.list-group {
  --bs-list-group-active-bg: var(--cu-brand-600);
  --bs-list-group-active-border-color: var(--cu-brand-600);
  --bs-list-group-border-color: var(--cu-border);
}

/* --- Form controls -------------------------------------------------------
   The focus border and ring are hardcoded blue in Bootstrap. */

.form-control:focus,
.form-select:focus {
  border-color: var(--cu-brand-300);
  box-shadow: 0 0 0 0.25rem rgba(var(--cu-brand-rgb), 0.25);
}

.form-check-input:focus {
  border-color: var(--cu-brand-300);
  box-shadow: 0 0 0 0.25rem rgba(var(--cu-brand-rgb), 0.25);
}

.form-check-input:checked {
  background-color: var(--cu-brand-600);
  border-color: var(--cu-brand-600);
}

/* The switch knob is an inlined SVG whose fill is a literal colour, so the
   focus-state image has to be restated with the brand tint. */
.form-switch .form-check-input:focus {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%27-4 -4 8 8%27%3e%3ccircle r=%273%27 fill=%27%2375c7b7%27/%3e%3c/svg%3e");
}

/* ==========================================================================
   Dark theme

   Applied by ThemeService via data-bs-theme="dark" on <html>. Only tokens are
   redefined — no component rule needs to know a theme exists, which is what
   the token work in the earlier passes bought us.

   Every pairing here was checked: the tightest is text-subtle on the base
   surface at 4.67:1, and each status colour clears 3:1 as a graphical
   indicator. The sidebar is deliberately unchanged; it was already the one
   dark surface in the app and it still reads as the brand anchor.
   ========================================================================== */

:root[data-bs-theme="dark"] {
  --cu-surface: #12171a;
  --cu-surface-sunken: #0d1214;
  --cu-surface-accent: #10312b;

  --cu-border: #262f35;
  --cu-border-strong: #38434a;
  --cu-border-accent: #1c4f45;

  --cu-text: #e6ebee;
  --cu-text-muted: #9fadb5;
  --cu-text-subtle: #75848c;

  /* Brand shades flip: on a dark ground the mid-tones read as the accent and
     the deep shades become surfaces. */
  --cu-brand-50: #10312b;
  --cu-brand-100: #16453c;

  --cu-status-ok: #3ddc97;
  --cu-status-warning: #e8a33d;
  --cu-status-error: #ff6b6b;
  --cu-status-info: #5ec1ad;

  --cu-chart-ours: #4fd1b8;
  --cu-chart-theirs: #ff922b;

  --cu-code-keyword: #c4a7ff;
  --cu-code-string: #8bd99a;
  --cu-code-number: #f0b35a;
  --cu-code-function: #82b1ff;
  --cu-code-type: #5ec1ad;

  --cu-status-pending: var(--cu-text-muted);
  --cu-status-none: var(--cu-text-subtle);

  --cu-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  --cu-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.5);
  --cu-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);

  /* --- Bootstrap rebinding --------------------------------------------- */
  --bs-body-bg: var(--cu-surface);
  --bs-body-color: var(--cu-text);
  --bs-body-color-rgb: 230, 235, 238;
  --bs-emphasis-color: #ffffff;
  --bs-secondary-color: rgba(230, 235, 238, 0.75);
  --bs-secondary-color-rgb: 230, 235, 238;
  --bs-tertiary-color: rgba(230, 235, 238, 0.5);
  --bs-tertiary-bg: var(--cu-surface-sunken);
  --bs-border-color: var(--cu-border);

  --bs-primary: var(--cu-brand-400);
  --bs-primary-rgb: 66, 179, 157;
  --bs-link-color: var(--cu-brand-300);
  --bs-link-color-rgb: 117, 199, 183;
  --bs-link-hover-color: var(--cu-brand-200);
  --bs-focus-ring-color: rgba(66, 179, 157, 0.35);
}

/* On a dark ground the primary needs to be light with dark text, the inverse
   of the light theme. */
:root[data-bs-theme="dark"] .btn-primary {
  --bs-btn-color: var(--cu-brand-900);
  --bs-btn-bg: var(--cu-brand-400);
  --bs-btn-border-color: var(--cu-brand-400);
  --bs-btn-hover-color: var(--cu-brand-900);
  --bs-btn-hover-bg: var(--cu-brand-300);
  --bs-btn-hover-border-color: var(--cu-brand-300);
  --bs-btn-active-color: var(--cu-brand-900);
  --bs-btn-active-bg: var(--cu-brand-200);
  --bs-btn-disabled-color: var(--cu-brand-900);
  --bs-btn-disabled-bg: var(--cu-brand-400);
}

:root[data-bs-theme="dark"] .btn-outline-primary {
  --bs-btn-color: var(--cu-brand-300);
  --bs-btn-border-color: var(--cu-brand-500);
  --bs-btn-hover-color: var(--cu-brand-900);
  --bs-btn-hover-bg: var(--cu-brand-400);
  --bs-btn-hover-border-color: var(--cu-brand-400);
  --bs-btn-active-color: var(--cu-brand-900);
  --bs-btn-active-bg: var(--cu-brand-300);
}

:root[data-bs-theme="dark"] .nav-pills {
  --bs-nav-pills-link-active-color: var(--cu-brand-900);
  --bs-nav-pills-link-active-bg: var(--cu-brand-400);
}

/* Badge hues restated for a dark ground: light text on a deep tint. */
:root[data-bs-theme="dark"] .cu-badge--teal {
  color: #7fd8c6;
  background-color: #10312b;
  border-color: #1c4f45;
}

:root[data-bs-theme="dark"] .cu-badge--indigo {
  color: #a9b2f5;
  background-color: #1b1f3d;
  border-color: #2e3663;
}

:root[data-bs-theme="dark"] .cu-badge--slate {
  color: #b7c4cc;
  background-color: #1b2429;
  border-color: #2c3941;
}

:root[data-bs-theme="dark"] .table > tbody > tr.cu-row-diff {
  --bs-table-bg: #2a1a1d;
  --bs-table-hover-bg: #382226;
  --bs-table-striped-bg: #331e22;
}

/* ==========================================================================
   Copper Scheduling — shared component & utility styles

   Everything here used to live in <style> blocks inside individual Aurelia
   templates. Those blocks were global anyway (Aurelia 1 hoists them into
   <head> and leaves them there), so collecting them means the rules are
   applied deterministically instead of depending on which views happen to
   have been rendered.
   ========================================================================== */

/* --- Utilities ----------------------------------------------------------- */

.mouse-hand {
  cursor: pointer;
}

.tighter {
  font-size: var(--cu-text-md);
  letter-spacing: 0.5px;
}

/* --- Tables --------------------------------------------------------------
   Applied via .table-sticky on the table itself. Previously this was a bare
   `thead th` rule duplicated in nomination.html and communication.html, which
   leaked onto every other table in the app once either page had been opened. */

.table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: var(--cu-surface);
  border-bottom: 1px solid var(--cu-border-strong);
}

/* Shared treatment for the data tables. Column headers become quiet labels so
   the data, not the chrome, carries the weight. */
.cu-table thead th {
  font-size: var(--cu-text-xs);
  font-weight: 600;
  color: var(--cu-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Numeric columns: right aligned with tabular figures, so digits line up both
   down a column and across the columns being compared. */
.cu-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Rows where our figure and the counterparty's disagree. This replaces
   .table-danger, which flooded the row in saturated pink — worst of all over
   the numbers you are there to compare. A soft tint plus a left accent marks
   the row without competing with its contents.

   The accent has to be a border, not a box-shadow: Bootstrap 5.3 paints row
   hover and striping with `box-shadow: inset 0 0 0 9999px`, so a shadow here
   would knock out the hover state. */
.table > tbody > tr.cu-row-diff {
  --bs-table-bg: #fdf2f3;
  --bs-table-hover-bg: #f8e4e6;
  --bs-table-striped-bg: #f8e8ea;
}

.cu-table > tbody > tr > td:first-child {
  border-left: 3px solid transparent;
}

.cu-table > tbody > tr.cu-row-diff > td:first-child {
  border-left-color: var(--bs-danger);
}

/* --- Badge family ----------------------------------------------------------
   Correlation ids, message ids and message types used to be three unrelated
   badges with their own sizes, shapes and palettes. They are now one base
   with hue variants, so they read as a set: identifiers get the monospace
   square treatment, categorical labels get the pill.

   Every pairing below clears 7.5:1 text-on-background. */

.cu-badge {
  display: inline-block;
  max-width: 100%;
  padding: 0.25em 0.55em;
  overflow: hidden;
  font-size: var(--cu-text-xs);
  font-weight: 500;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid;
  border-radius: var(--cu-radius-sm);
}

.cu-badge--mono {
  font-family: var(--cu-font-mono);
}

.cu-badge--pill {
  border-radius: var(--cu-radius-pill);
}

.cu-badge--teal {
  color: #12564a;
  background-color: #e6f4f1;
  border-color: #b5ddd4;
}

.cu-badge--indigo {
  color: #2e3a8c;
  background-color: #eaecfb;
  border-color: #c2c9f0;
}

.cu-badge--slate {
  color: #31434f;
  background-color: #eef1f4;
  border-color: #ccd5dc;
}

/* --- Effect (MW value) -----------------------------------------------------
   Deliberately not a badge. This renders inside three side-by-side numeric
   columns whose whole purpose is comparison, and a coloured pill around every
   figure fights that. It was also the worst contrast in the app: the old
   `badge bg-info text-secondary` was grey on cyan at 2.4:1.

   Tabular figures so digits line up down the column and across columns. */

.cu-effect {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}

.cu-effect__value {
  font-weight: 500;
  color: var(--cu-text);
}

.cu-effect__unit {
  margin-left: 0.25em;
  font-size: 0.8em;
  color: var(--cu-text-muted);
}

/* A zero reading is real data, not missing data — muted, but still readable
   at 5.4:1 rather than greyed out. */
.cu-effect.is-zero .cu-effect__value {
  font-weight: 400;
  color: var(--cu-text-muted);
}

/* --- Code panels (code-box element, xml dialog) --------------------------- */

.code-box-container {
  position: relative;
}

.code-box-container pre,
.code-panel {
  margin-bottom: 0;
  padding: 1rem;
  overflow-x: auto;
  font-size: var(--cu-text-md);
  background-color: var(--cu-surface-sunken);
  border: 1px solid var(--cu-border);
  border-radius: var(--cu-radius);
}

.code-box-container .copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  display: none;
}

.code-box-container:hover .copy-btn {
  display: inline-block;
}

/* Syntax colours for highlight.js output. Written against the --cu-code-*
   tokens instead of importing a stock highlight.js theme, so the samples
   follow the app's light and dark themes. */
.hljs-keyword,
.hljs-built_in,
.hljs-literal,
.hljs-meta .hljs-keyword {
  color: var(--cu-code-keyword);
}

.hljs-string,
.hljs-regexp,
.hljs-subst {
  color: var(--cu-code-string);
}

.hljs-number,
.hljs-variable,
.hljs-template-variable,
.hljs-attr {
  color: var(--cu-code-number);
}

.hljs-title,
.hljs-title.function_,
.hljs-section {
  color: var(--cu-code-function);
}

.hljs-type,
.hljs-title.class_,
.hljs-params .hljs-type {
  color: var(--cu-code-type);
}

.hljs-comment,
.hljs-quote,
.hljs-meta {
  font-style: italic;
  color: var(--cu-code-comment);
}

/* --- Copy fields -----------------------------------------------------------
   A label, a value, and the controls that act on it. Each row is a grid with a
   fixed label column, so values line up down a list instead of starting
   wherever the previous label happened to end. The value needs `min-width: 0`
   so a long URL wraps inside its track instead of pushing the buttons off the
   card. */

.cu-copy-field {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.25rem 0;
}

.cu-copy-field__label {
  font-size: var(--cu-text-sm);
  color: var(--cu-text-muted);
}

.cu-copy-field__value {
  min-width: 0;
  font-size: var(--cu-text-md);
  color: var(--cu-text);
  word-break: break-word;
}

/* For a row with nothing to show yet - says where the value comes from instead. */
.cu-copy-field__value--pending {
  font-style: italic;
  color: var(--cu-text-muted);
}

.cu-copy-field__actions {
  display: inline-flex;
  gap: 0.125rem;
}

/* Actions stay out of the way until the row is pointed at or tabbed into.
   Only where hovering exists - on touch screens they are always shown. */
@media (hover: hover) {
  .cu-copy-field__actions {
    opacity: 0;
    transition: opacity var(--cu-transition);
  }

  .cu-copy-field:hover .cu-copy-field__actions,
  .cu-copy-field:focus-within .cu-copy-field__actions {
    opacity: 1;
  }
}

/* Too narrow for two columns: the label goes above its value. */
@media (max-width: 575.98px) {
  .cu-copy-field {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 0.125rem;
  }

  .cu-copy-field__label {
    grid-column: 1 / -1;
  }
}

copy-field {
  display: block;
}

/* A run of copy fields, split by hairlines. Rows are either <copy-field>
   elements or bare .cu-copy-field rows built by hand, in any order. */
.cu-field-list > * + copy-field > .cu-copy-field,
.cu-field-list > * + .cu-copy-field {
  border-top: 1px solid var(--cu-border);
}

/* --- Numbered steps (integration page) -------------------------------------
   A card that is one step in a sequence: a number badge, a title and a short
   line saying what the step is for. */

.cu-step__header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.cu-step__number {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  font-size: var(--cu-text-sm);
  font-weight: 700;
  color: var(--cu-brand-700);
  background-color: var(--cu-brand-50);
  border: 1px solid var(--cu-brand-200);
  border-radius: var(--cu-radius-pill);
}

.cu-step__title {
  margin: 0.125rem 0 0.25rem;
  font-size: var(--cu-text-xl);
  font-weight: 600;
}

.cu-step__lead {
  margin: 0;
  font-size: var(--cu-text-sm);
  color: var(--cu-text-muted);
}

/* --- Runtime configuration card (overview list) --------------------------- */

.config-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* `width: calc((100% - 120px) / 7)` used to sit here, assuming seven cards
     per row. It never actually applied: the card's parent is shrink-to-fit, so
     a percentage width is cyclic and CSS resolves it as auto — leaving the card
     pinned at its min-width. Every card was 200px wide, minus 40px of side
     padding, giving customer names only 160px before they wrapped. */
  min-width: 15.5rem;
  max-width: 20rem;
  height: 125px;
  padding: 1rem;
  cursor: pointer;
  background-color: var(--cu-surface-sunken);
  border: 1px solid var(--cu-border);
  border-radius: var(--cu-radius-lg);
  box-shadow: var(--cu-shadow-sm);
  transition: transform var(--cu-transition), box-shadow var(--cu-transition),
    background-color var(--cu-transition);
}

.config-card:hover {
  background-color: var(--cu-surface);
  border-color: var(--cu-border-accent);
  box-shadow: var(--cu-shadow);
  transform: translateY(-2px);
}

.config-card .config-title {
  font-size: var(--cu-text-3xl);
  font-weight: 600;
  color: var(--cu-text);
}

.config-card .config-icon {
  align-self: flex-end;
  font-size: var(--cu-icon-lg);
  color: var(--cu-brand-500);
}

.config-card .config-customername {
  margin-top: 0.3rem;
  font-size: var(--cu-text-md);
  color: var(--cu-text-muted);
}

.config-card .config-flag {
  /* sized off the icon font-size, so it occupies the same line as the lightning it replaces */
  height: 1em;
  vertical-align: -0.125em;
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--cu-border);
}

.config-card .hide-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  font-size: var(--cu-icon-sm);
  color: var(--cu-text-subtle);
  background: transparent;
  border: none;
}

.config-card:hover .hide-btn {
  display: block;
}

.config-card .hide-btn:hover {
  color: #f87171;
  cursor: pointer;
}

/* --- Calendar grid (overview detail) ---------------------------------------
   Was a <table> standing in for a calendar, with each cell printing a full ISO
   date. It is now a real grid: one column for the week number and seven for
   the days, so the columns line up by construction rather than by cell width. */

.cu-calendar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  max-width: 62rem;
}

.cu-calendar__grid {
  display: grid;
  grid-template-columns: auto repeat(7, minmax(4.5rem, 1fr));
  gap: 0.375rem;
  width: 100%;
}

.cu-calendar__weekday {
  padding: 0.25rem 0;
  font-size: var(--cu-text-xs);
  font-weight: 600;
  color: var(--cu-text-muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cu-calendar__weekday--weekend {
  color: var(--cu-text-subtle);
}

/* Pinned to column 1 so every week starts a fresh row. Without this, a week
   returning fewer than seven dates would push the following week's label into
   the wrong column and cascade the misalignment down the whole grid — a table
   row would simply have ended early. */
.cu-calendar__week {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.625rem;
  font-size: var(--cu-text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--cu-text-subtle);
  white-space: nowrap;
}

.cu-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  min-height: 4.75rem;
  padding: 0.5rem 0.25rem;
  font-family: inherit;
  color: var(--cu-text);
  cursor: pointer;
  background-color: var(--cu-surface-sunken);
  border: 1px solid var(--cu-border);
  border-radius: var(--cu-radius);
  transition: background-color var(--cu-transition), border-color var(--cu-transition),
    box-shadow var(--cu-transition), transform var(--cu-transition);
}

.cu-day:hover {
  background-color: var(--cu-brand-50);
  border-color: var(--cu-border-accent);
  box-shadow: var(--cu-shadow-sm);
  transform: translateY(-1px);
}

.cu-day:focus-visible {
  outline: 2px solid var(--cu-brand-600);
  outline-offset: 2px;
}

/* Month is labelled only where it changes, so the eye gets the boundary
   without the same three letters repeating across every cell. */
.cu-day__month {
  font-size: var(--cu-text-2xs);
  font-weight: 700;
  color: var(--cu-brand-600);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1;
}

.cu-day__number {
  font-size: var(--cu-text-xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.cu-day__status {
  font-size: var(--cu-icon-md);
  line-height: 1;
}

/* Today is marked with the brand ring rather than a filled block, so the
   status colour inside it stays the loudest thing in the cell. */
.cu-day.is-today {
  background-color: var(--cu-surface);
  border-color: var(--cu-brand-600);
  box-shadow: inset 0 0 0 1px var(--cu-brand-600);
}

.cu-day.is-today .cu-day__number {
  color: var(--cu-brand-700);
}

.cu-day.is-today:hover {
  background-color: var(--cu-brand-50);
}

/* --- Nomination table ----------------------------------------------------- */

.label-cell {
  white-space: nowrap;
}

/* Right aligned to match the read-only .cu-effect values in the same column,
   so the figures do not jump sideways when you enter edit mode. */
.mw-editor {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
}

.mw-editor .mw-input {
  width: 5rem;
}

.mw-editor .unit {
  font-size: var(--cu-text-md);
  color: var(--cu-text-muted);
}

/* Unread-style count bubble on the status messages icon */

/* Sits on the messages button; the button itself supplies the display mode. */
.icon-badge-speech-bubble {
  position: relative;
  overflow: visible;
}

.badge-speech-bubble {
  position: absolute;
  top: -6px;
  right: -6px;
  padding: 2px 6px;
  font-size: 0.7em;
  font-weight: bold;
  line-height: 1;
  color: #fff;
  background: var(--bs-danger);
  border-radius: 50%;
}

/* --- Dialogs --------------------------------------------------------------
   Aurelia dialogs must clear the sticky table headers (z-index 1020). */

ux-dialog-overlay {
  z-index: 1040 !important;
}

ux-dialog-container {
  z-index: 1050 !important;
}

/* --- Application sidebar --------------------------------------------------
   The dark rail that hosts the brand, the customer switcher, the primary nav
   and the signed-in user. It is the one deliberately dark surface in the app,
   so that navigation chrome reads as clearly separate from the data.

   Every foreground colour here was picked against the rail background: the
   lowest-contrast pairing in use is --cu-brand-400 on --cu-brand-900 at
   5.4:1, so all of it clears WCAG AA including the small text. */

.cu-sidebar {
  display: flex;
  flex-direction: column;
  width: 20rem;
  height: 100vh;
  padding: 1.25rem 0.875rem;
  overflow-y: auto;
  color: var(--cu-brand-100);
  background-color: var(--cu-brand-900);
  scrollbar-width: thin;
  scrollbar-color: var(--cu-brand-700) transparent;
}

.cu-sidebar::-webkit-scrollbar {
  width: 8px;
}

.cu-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.cu-sidebar::-webkit-scrollbar-thumb {
  background-color: var(--cu-brand-700);
  border-radius: 4px;
}

/* Unstyled buttons in the rail: strip the UA chrome and inherit typography. */
.cu-switcher__trigger,
.cu-switcher__item,
.cu-switcher__toggle,
.cu-user__signout {
  font-family: inherit;
  cursor: pointer;
  background: none;
  border: 0;
}

/* --- Brand lockup --------------------------------------------------------- */

.cu-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.25rem 0.5rem 1.125rem;
  color: #fff;
  text-decoration: none;
}

.cu-sidebar__brand:hover,
.cu-sidebar__brand:focus {
  color: #fff;
}

.cu-sidebar__wordmark {
  font-size: var(--cu-text-lg);
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* --- Customer / environment switcher -------------------------------------- */

.cu-switcher {
  position: relative;
  margin-bottom: 1.25rem;
}

.cu-switcher__trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  color: var(--cu-brand-100);
  text-align: left;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--cu-brand-700);
  border-radius: var(--cu-radius);
  transition: background-color var(--cu-transition), border-color var(--cu-transition);
}

.cu-switcher__trigger:hover {
  background-color: var(--cu-brand-800);
  border-color: var(--cu-brand-600);
}

.cu-switcher__trigger:focus-visible,
.cu-switcher__item:focus-visible,
.cu-switcher__toggle:focus-visible,
.cu-user__signout:focus-visible,
.cu-sidebar__brand:focus-visible {
  outline: 2px solid var(--cu-logo-teal);
  outline-offset: 2px;
}

.cu-switcher__labels {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.cu-switcher__label {
  overflow: hidden;
  font-size: var(--cu-text-md);
  font-weight: 600;
  color: var(--cu-brand-100);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cu-switcher__sublabel {
  overflow: hidden;
  font-size: var(--cu-text-xs);
  color: var(--cu-brand-300);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chevron drawn with borders rather than a glyph, so it stays consistent
   across platforms and rotates on open. */
.cu-switcher__chevron {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  margin-bottom: 0.2rem;
  border-right: 2px solid var(--cu-brand-300);
  border-bottom: 2px solid var(--cu-brand-300);
  transform: rotate(45deg);
  transition: transform var(--cu-transition);
}

.cu-switcher__chevron.is-open {
  margin-top: 0.2rem;
  margin-bottom: 0;
  transform: rotate(-135deg);
}

.cu-switcher__menu {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  left: 0;
  z-index: 1050;
  max-height: 18rem;
  padding: 0.25rem;
  overflow-y: auto;
  background-color: var(--cu-brand-800);
  border: 1px solid var(--cu-brand-700);
  border-radius: var(--cu-radius);
  box-shadow: var(--cu-shadow-lg);
}

.cu-switcher__item {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-left: 3px solid transparent;
  border-radius: var(--cu-radius-sm);
  transition: background-color var(--cu-transition);
}

.cu-switcher__item:hover {
  background-color: var(--cu-brand-700);
}

.cu-switcher__item.is-current {
  background-color: var(--cu-brand-700);
  border-left-color: var(--cu-logo-teal);
}

/* Hidden configurations are marked with a flag rather than dimmed. The old
   opacity: 0.5 dropped the secondary text below readable contrast. */
.cu-switcher__item.is-hidden-config .cu-switcher__label {
  color: var(--cu-brand-300);
  font-weight: 500;
}

.cu-switcher__flag {
  display: inline-block;
  padding: 0 0.35em;
  margin-left: 0.35em;
  font-size: var(--cu-text-2xs);
  font-weight: 600;
  color: var(--cu-brand-200);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: 1px;
  background-color: var(--cu-brand-600);
  border-radius: var(--cu-radius-sm);
}

.cu-switcher__divider {
  height: 1px;
  margin: 0.25rem 0.5rem;
  background-color: var(--cu-brand-700);
}

.cu-switcher__toggle {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: var(--cu-text-xs);
  color: var(--cu-brand-300);
  text-align: left;
  border-radius: var(--cu-radius-sm);
}

.cu-switcher__toggle:hover {
  color: var(--cu-brand-100);
  background-color: var(--cu-brand-700);
}

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

.cu-nav {
  margin-bottom: 1.5rem;
}

.cu-nav .nav-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.125rem;
  font-size: var(--cu-text-base);
  color: var(--cu-brand-200);
  border-left: 3px solid transparent;
  border-radius: var(--cu-radius-sm);
  transition: background-color var(--cu-transition), color var(--cu-transition);
}

.cu-nav .nav-link:hover {
  color: #fff;
  background-color: var(--cu-brand-800);
}

.cu-nav .nav-link.active {
  color: #fff;
  background-color: var(--cu-brand-600);
  border-left-color: var(--cu-logo-teal);
}

.cu-nav .nav-link:focus-visible {
  outline: 2px solid var(--cu-logo-teal);
  outline-offset: -2px;
}

/* --- Footer: signed-in user and version ------------------------------------ */

.cu-sidebar__footer {
  margin-top: auto;
  padding-top: 0.875rem;
  border-top: 1px solid var(--cu-brand-800);
}

.cu-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.25rem;
}

.cu-user__avatar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: var(--cu-text-xs);
  font-weight: 700;
  color: var(--cu-brand-900);
  background-color: var(--cu-logo-teal);
  border-radius: 50%;
}

.cu-user__details {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.cu-user__name {
  overflow: hidden;
  font-size: var(--cu-text-sm);
  color: var(--cu-brand-100);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cu-user__signout {
  align-self: flex-start;
  padding: 0;
  font-size: var(--cu-text-xs);
  color: var(--cu-brand-300);
  text-decoration: underline;
}

.cu-user__signout:hover {
  color: var(--cu-logo-teal);
}

.cu-sidebar__version {
  padding: 0.5rem 0.25rem 0;
  font-size: var(--cu-text-2xs);
  color: var(--cu-brand-400);
}

/* --- Page title ------------------------------------------------------------
   Deliberately plain: this used to be a grey rounded box with a shadow, which
   cost ~5.5rem of vertical space on every page and competed with the content
   for attention. The heading now carries the hierarchy on its own. */

.cu-page-title__heading {
  margin: 0;
  font-size: var(--cu-text-2xl);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--cu-text);
}

.cu-page-title__subheading {
  margin: 0.125rem 0 0;
  font-size: var(--cu-text-sm);
  line-height: 1.4;
  color: var(--cu-text-muted);
}

/* --- Content header band ---------------------------------------------------
   The fixed region above the scrolling content: page title plus the optional
   toolbar slot. Only nomination and communication supply a toolbar, so the
   band has to sit correctly with the title alone — hence the bottom padding
   here rather than relying on the toolbar's own spacing. */

.cu-main {
  /* Positioning context for the floating back-to-top control, so it centres
     over the content rather than the whole window. */
  position: relative;
  height: 100vh;
  background-color: var(--cu-surface);
}

.cu-header {
  padding: 0.875rem 1.25rem 0.5rem;
  background-color: var(--cu-surface);
  border-bottom: 1px solid var(--cu-border);
}

.cu-content {
  /* Containing block for absolutely positioned descendants, so they scroll
     and clip with the pane. Without it they resolve against .cu-main instead,
     escape the scroll container, and stretch the document - e.g. the
     .visually-hidden label in every communication row produced a second,
     page-level scrollbar next to this pane's own. */
  position: relative;
  padding: 1.25rem;
  overflow-y: auto;
}

/* --- Toolbar ---------------------------------------------------------------
   The strip under the page title. It was a single flat flex row of unrelated
   controls whose natural heights ranged from ~20px (the emergency switch) to
   ~46px (the reload button), with no indication of which control did what.

   Controls are now grouped by what they act on — the day, the schedule, the
   selected schedule's overrides, submission — with dividers between groups,
   and everything is pinned to one control height. */

.cu-toolbar {
  --cu-control-height: 2.25rem;

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

/* A group is an atomic unit: it wraps as a whole at the toolbar level and
   never breaks up internally.

   Both declarations matter. Without `flex-shrink: 0` the toolbar shrinks the
   group when space runs short, and since the select inside has a hard
   `min-width` floor it cannot absorb that — so the group would satisfy the
   shrink by wrapping its own children instead, dropping the select onto a
   line below the button next to it. `nowrap` makes that impossible outright;
   any remaining pressure is taken by wrapping between groups. */
.cu-toolbar__group {
  display: flex;
  flex-wrap: nowrap;
  flex-shrink: 0;
  align-items: center;
  gap: 0.375rem;
}

/* Trailing group, pushed to the right edge. */
.cu-toolbar__group--end {
  margin-left: auto;
}


.cu-toolbar__sep {
  flex-shrink: 0;
  width: 1px;
  height: 1.5rem;
  background-color: var(--cu-border);
}

.cu-toolbar__select {
  min-width: 14rem;
}

/* One height for every control in the bar. */
.cu-toolbar .btn,
.cu-toolbar .form-select,
.cu-toolbar .form-control {
  display: inline-flex;
  align-items: center;
  height: var(--cu-control-height);
  padding-top: 0;
  padding-bottom: 0;
}

.cu-toolbar .form-check.form-switch {
  display: flex;
  align-items: center;
  height: var(--cu-control-height);
  margin-bottom: 0;
}

/* --- Icon buttons ----------------------------------------------------------
   These carried a bare `.btn`, which has no background, no border and no
   hover — so the emoji looked like decoration rather than a control. Square,
   bordered, and self-sufficient so they also work outside a toolbar. */

.cu-icon-btn {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: var(--cu-icon-md);
  line-height: 1;
  cursor: pointer;
  background-color: var(--cu-surface);
  border: 1px solid var(--cu-border-strong);
  border-radius: var(--cu-radius-sm);
  transition: background-color var(--cu-transition), border-color var(--cu-transition);
}

.cu-icon-btn:hover {
  background-color: var(--cu-surface-sunken);
  border-color: var(--cu-brand-400);
}

/* For secondary affordances that should not compete, such as the info toggle
   sitting next to Force submit. */
.cu-icon-btn--quiet {
  background-color: transparent;
  border-color: transparent;
}

.cu-icon-btn--quiet:hover {
  background-color: var(--cu-surface-sunken);
  border-color: var(--cu-border);
}

/* --- Date navigator ----------------------------------------------------------
   One bordered control, « ‹ [ date ] › », instead of loose buttons around a
   calendar icon. The segments share the outer border and are split by hairline
   dividers. Week steps are drawn quieter than day steps so the common action
   reads first. */

.cu-datenav {
  display: inline-flex;
  flex-shrink: 0;
  align-items: stretch;
  height: var(--cu-control-height, 2.25rem);
  background-color: var(--cu-surface);
  border: 1px solid var(--cu-border-strong);
  border-radius: var(--cu-radius-sm);
  overflow: hidden;
  transition: border-color var(--cu-transition);
}

.cu-datenav:hover {
  border-color: var(--cu-brand-400);
}

.cu-datenav > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  color: var(--cu-text);
  background-color: transparent;
  border: 0;
  cursor: pointer;
  transition: background-color var(--cu-transition), color var(--cu-transition);
}

.cu-datenav > button + button {
  border-left: 1px solid var(--cu-border);
}

.cu-datenav > button:hover {
  background-color: var(--cu-surface-sunken);
}

.cu-datenav > button:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid var(--cu-brand-500);
  outline-offset: -2px;
}

.cu-datenav > .cu-datenav__step {
  width: 2rem;
  font-size: var(--cu-icon-sm);
}

.cu-datenav > .cu-datenav__step--week {
  color: var(--cu-text-muted);
}

.cu-datenav > .cu-datenav__step--week:hover {
  color: var(--cu-text);
}

/* Just the calendar glyph - the page heading already spells out the date, and
   the full date is in the tooltip. Same size as a regular icon button. */
.cu-datenav > .cu-datenav__date {
  width: 2.25rem;
  font-size: var(--cu-icon-md);
}

/* Brand-tinted when the selected date is today, so it is easy to tell when
   you have stepped away from it. */
.cu-datenav > .cu-datenav__date.is-today {
  color: var(--cu-brand-500);
}

/* --- Schedule kind indicator (domestic / foreign) --------------------------- */

.cu-schedule-kind {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: var(--cu-control-height, 2.25rem);
  padding: 0 0.5rem;
  background-color: var(--cu-surface-sunken);
  border: 1px solid var(--cu-border);
  border-radius: var(--cu-radius-sm);
}

.cu-schedule-kind__label {
  font-size: var(--cu-text-2xs);
  font-weight: 600;
  color: var(--cu-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cu-toolbar__filter-label {
  font-size: var(--cu-text-xs);
  font-weight: 600;
  color: var(--cu-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* The status glyph is a bare element, not a control — align and size it so it
   reads as a peer of the buttons either side of it. */
.cu-toolbar status-icon {
  display: inline-flex;
  align-items: center;
  height: var(--cu-control-height);
  font-size: var(--cu-icon-md);
}

/* --- Icons -----------------------------------------------------------------
   Bootstrap Icons replace the emoji that were previously used as UI controls
   and status indicators. Emoji rendered differently on every OS, could not be
   coloured, and carried no accessible name.

   Convention: the <i> is always aria-hidden. Buttons carry an aria-label;
   standalone indicators carry a .visually-hidden text node instead, so the
   meaning survives for screen readers without duplicating the tooltip. */

/* Compact variant for icon buttons inside tables, cards and dialog headers. */
.cu-icon-btn--sm {
  width: 1.75rem;
  height: 1.75rem;
  font-size: var(--cu-text-md);
}

/* --- Status colours --------------------------------------------------------
   The emoji carried their own colour; icons need it supplied. Both scales use
   Bootstrap's semantic colours so they match the alerts elsewhere. */

.cu-status {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.cu-status--ok {
  color: var(--cu-status-ok);
}

.cu-status--info {
  color: var(--cu-status-info);
}

.cu-status--warning {
  color: var(--cu-status-warning);
}

.cu-status--error {
  color: var(--cu-status-error);
}

.cu-status--pending {
  color: var(--cu-status-pending);
}

.cu-status--none {
  color: var(--cu-status-none);
}

/* --- Counterparty ---------------------------------------------------------- */

.cu-counterparty .bi {
  color: var(--cu-text-muted);
}

/* --- Empty state -----------------------------------------------------------
   One shared treatment, so "nothing here" looks deliberate rather than like a
   view that failed to render. Previously only the settings page had one. */

.cu-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.cu-empty__icon {
  margin-bottom: 0.75rem;
  font-size: var(--cu-icon-xl);
  line-height: 1;
  color: var(--cu-text-subtle);
}

.cu-empty__message {
  margin: 0;
  font-size: var(--cu-text-base);
  color: var(--cu-text-muted);
}

.cu-empty__hint {
  margin: 0.25rem 0 0;
  font-size: var(--cu-text-sm);
  color: var(--cu-text-subtle);
}

/* --- Global request indicator ----------------------------------------------
   A slim indeterminate bar pinned to the top of the viewport. It is driven by
   ApiClient.busy, which only flips true once a request has been outstanding
   for 300ms — so the overview page's 5-second poll never flashes it. */

.cu-progress {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2100;
  height: 3px;
  overflow: hidden;
  background-color: var(--cu-brand-100);
}

.cu-progress__bar {
  width: 40%;
  height: 100%;
  background-color: var(--cu-brand-600);
  border-radius: 0 var(--cu-radius-pill) var(--cu-radius-pill) 0;
  animation: cu-progress-slide 1.1s ease-in-out infinite;
}

@keyframes cu-progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* Respect a reduced-motion preference: hold a steady bar instead of sliding. */
@media (prefers-reduced-motion: reduce) {
  .cu-progress__bar {
    width: 100%;
    animation: none;
  }
}

/* --- Dialogs that host large content ---------------------------------------
   Opt-in via .cu-dialog-fill on the <ux-dialog>.

   aurelia-dialog renders the dialog inside a fixed, scrolling container:

     ux-dialog-container   position: fixed; inset: 0; overflow-y: auto
       > div               padding: 30px
         > div             height: fit-content; margin: auto
           > ux-dialog     display: table; height: fit-content

   The XML and status-message dialogs used to cap only their inner scroll
   region at 80vh, so the header, tabs, padding and footer stacked on top and
   the container grew a second scrollbar around the first.

   Capping the dialog with a vh calculation was not enough either: it depends
   on guessing the container's chrome exactly, and any error still leaves the
   container scrollable. Instead the whole chain is made definite-height and
   the container is told outright that it may not scroll — two scrollbars then
   become impossible rather than merely unlikely.

   Scoped with :has() so only dialogs opting in are affected. In particular
   init-override-dialog has an absolutely-positioned suggestion list in its
   body that a blanket overflow:hidden would clip. */

/* The container keeps aurelia-dialog default overflow-y: auto. It is a safety
   valve, not the mechanism: if the cap below ever fails, the user can still
   scroll to the content instead of losing access to it. When the cap works,
   nothing overflows and no outer scrollbar appears. */

/* The wrapper is taken out of flow and pinned 30px inside the container.
   ux-dialog-container is position: fixed with all four insets, so it is
   definitively sized — which makes the wrapper definitively sized too, and a
   percentage max-height on the dialog inside it therefore always resolves.

   This replaces a chain of height:100% / max-height:100% through the padded
   div. That chain was correct in principle but depended on box-sizing, on the
   flex axis, and on overriding fit-content — and each of those broke it in
   turn. Absolute positioning depends on none of them.

   Safe to take the wrapper out of flow because every dialog here opens with
   lock: true, so aurelia-dialog sets overlayDismiss = false and nothing needs
   clicks to land on the container behind the dialog. */

ux-dialog-container:has(ux-dialog.cu-dialog-fill) > div > div {
  position: absolute;
  top: 30px;
  right: 30px;
  bottom: 30px;
  left: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  max-height: none;
  margin: 0;
}

ux-dialog.cu-dialog-fill {
  /* aurelia-dialog ships "display: table" and "height: fit-content". */
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 0;
  max-height: 100%;
}
ux-dialog.cu-dialog-fill > ux-dialog-header,
ux-dialog.cu-dialog-fill > ux-dialog-footer {
  flex: 0 0 auto;
}

ux-dialog.cu-dialog-fill > ux-dialog-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;

  /* Without this a flex item keeps min-height: auto and refuses to shrink
     below its content, so the inner scroll never engages and the dialog
     overflows anyway — the whole fix hinges on this line. */
  min-height: 0;
}

/* The one box inside a filled dialog that scrolls. */
.cu-dialog-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.cu-dialog-scroll > .code-panel {
  min-height: 100%;
  margin: 0;
}

/* --- Dialog header ---------------------------------------------------------
   Was a col-2 / col-8 / col-2 grid, which squeezed "Communication details"
   into two lines and cost the body a chunk of vertical space. */

.cu-dialog-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.cu-dialog-header__title {
  flex: 0 0 auto;
  margin: 0;
  font-size: var(--cu-text-xl);
  font-weight: 600;
  white-space: nowrap;
}

.cu-dialog-header__meta {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 0;
}

.cu-dialog-header__actions {
  flex: 0 0 auto;
}

/* --- Schedule profile chart -------------------------------------------------
   Turns the nomination table into a shape. The table is exact but you cannot
   see a divergence in it — that needs scanning ~96 rows of figures. Here the
   two curves and the red bands over differing periods say it immediately.

   preserveAspectRatio="none" lets the plot stretch to any width; strokes use
   vector-effect so they stay 2px rather than stretching with it. */

.cu-chart {
  margin-bottom: 1rem;
  background-color: var(--cu-surface-sunken);
  border: 1px solid var(--cu-border);
  border-radius: var(--cu-radius);
}

.cu-chart__svg {
  display: block;
  width: 100%;
  height: 190px;
}

.cu-chart__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.75rem 0;
  font-size: var(--cu-text-xs);
  color: var(--cu-text-muted);
}

.cu-chart__key {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-weight: 600;
}

.cu-chart__key::before {
  width: 0.75rem;
  height: 0.1875rem;
  content: "";
  border-radius: 2px;
}

.cu-chart__key--ours::before { background-color: var(--cu-chart-ours); }
.cu-chart__key--theirs::before { background-color: var(--cu-chart-theirs); }
.cu-chart__key--diff { color: var(--cu-status-error); }
.cu-chart__key--diff::before { background-color: var(--cu-status-error); }

.cu-chart__readout {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.cu-chart__readout-ours { font-weight: 600; color: var(--cu-chart-ours); }
.cu-chart__readout-theirs { font-weight: 600; color: var(--cu-chart-theirs); }
.cu-chart__unit { font-size: var(--cu-text-2xs); color: var(--cu-text-subtle); }

.cu-chart__grid { stroke: var(--cu-border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cu-chart__tick { font-size: 11px; fill: var(--cu-text-subtle); font-variant-numeric: tabular-nums; }
.cu-chart__diff { fill: var(--cu-status-error); opacity: 0.13; }

.cu-chart__area { fill: var(--cu-chart-ours); opacity: 0.10; stroke: none; }

.cu-chart__line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.cu-chart__line--ours { stroke: var(--cu-chart-ours); }

/* Dashed as well as differently hued: shape carries the distinction even in
   greyscale or for a viewer who cannot separate the two colours. */
.cu-chart__line--theirs { stroke: var(--cu-chart-theirs); stroke-dasharray: 6 4; }

.cu-chart__cursor {
  stroke: var(--cu-text-subtle);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}

/* Dark variants come from the --cu-chart-* tokens; no per-rule overrides. */

/* --- Command palette --------------------------------------------------------
   Ctrl/Cmd+K. Everything reachable in this app — a customer, a page, a date —
   previously took a dropdown, a date picker or a nav click. This collapses all
   of it into one keystroke. */

.cu-palette {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2200;
  display: flex;
  justify-content: center;
  padding: 12vh 1rem 1rem;
  background-color: rgba(11, 50, 43, 0.45);
  backdrop-filter: blur(2px);
}

.cu-palette__panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 34rem;
  max-height: 70vh;
  overflow: hidden;
  background-color: var(--cu-surface);
  border: 1px solid var(--cu-border-strong);
  border-radius: var(--cu-radius-lg);
  box-shadow: var(--cu-shadow-lg);
}

.cu-palette__search {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  color: var(--cu-text-subtle);
  border-bottom: 1px solid var(--cu-border);
}

.cu-palette__input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: inherit;
  font-size: var(--cu-text-lg);
  color: var(--cu-text);
  background: none;
  border: 0;
  outline: none;
}

.cu-palette__hint,
.cu-palette__footer kbd {
  padding: 0.1rem 0.35rem;
  font-family: var(--cu-font-mono);
  font-size: var(--cu-text-2xs);
  color: var(--cu-text-muted);
  background-color: var(--cu-surface-sunken);
  border: 1px solid var(--cu-border-strong);
  border-radius: var(--cu-radius-sm);
}

.cu-palette__results {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.375rem;
  margin: 0;
  overflow-y: auto;
  list-style: none;
}

.cu-palette__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.625rem;
  cursor: pointer;
  border-radius: var(--cu-radius-sm);
}

.cu-palette__item.is-highlighted {
  background-color: var(--cu-brand-50);
}

.cu-palette__icon {
  flex-shrink: 0;
  font-size: var(--cu-icon-md);
  color: var(--cu-brand-600);
}

.cu-palette__labels {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.cu-palette__title {
  overflow: hidden;
  font-size: var(--cu-text-base);
  font-weight: 500;
  color: var(--cu-text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cu-palette__subtitle {
  overflow: hidden;
  font-size: var(--cu-text-xs);
  color: var(--cu-text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cu-palette__kind {
  flex-shrink: 0;
  font-size: var(--cu-text-2xs);
  font-weight: 600;
  color: var(--cu-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cu-palette__empty {
  padding: 1.5rem 1rem;
  font-size: var(--cu-text-sm);
  color: var(--cu-text-muted);
  text-align: center;
}

.cu-palette__footer {
  display: flex;
  flex: 0 0 auto;
  gap: 1rem;
  padding: 0.5rem 1rem;
  font-size: var(--cu-text-2xs);
  color: var(--cu-text-subtle);
  border-top: 1px solid var(--cu-border);
}

.cu-palette__footer kbd { margin-right: 0.15rem; }

:root[data-bs-theme="dark"] .cu-palette__item.is-highlighted {
  background-color: var(--cu-brand-50);
}

:root[data-bs-theme="dark"] .cu-palette__icon {
  color: var(--cu-brand-300);
}

/* --- Sidebar footer meta row (version + theme toggle) ---------------------- */

.cu-sidebar__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.cu-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  font-size: var(--cu-icon-sm);
  color: var(--cu-brand-300);
  cursor: pointer;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--cu-radius-sm);
  transition: background-color var(--cu-transition), color var(--cu-transition);
}

.cu-theme-toggle:hover {
  color: var(--cu-logo-teal);
  background-color: var(--cu-brand-800);
}

.cu-theme-toggle:focus-visible {
  outline: 2px solid var(--cu-logo-teal);
  outline-offset: 2px;
}

/* --- Period picked from the profile chart -----------------------------------
   Clicking a bar scrolls its row into view; this flash says which one it
   landed on. It animates the same inset box-shadow Bootstrap uses for row
   hover and striping, so it reliably paints over them and then hands control
   straight back when the animation ends. */

.cu-table > tbody > tr.is-focused > td {
  animation: cu-row-flash 1.8s ease-out;
}

@keyframes cu-row-flash {
  0%,
  20% {
    box-shadow: inset 0 0 0 9999px rgba(var(--cu-brand-rgb), 0.3);
  }

  100% {
    box-shadow: inset 0 0 0 9999px rgba(var(--cu-brand-rgb), 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cu-table > tbody > tr.is-focused > td {
    animation-duration: 0.01s;
    box-shadow: inset 0 0 0 9999px rgba(var(--cu-brand-rgb), 0.3);
  }
}

/* The plot is clickable, so say so. */
.cu-chart__svg {
  cursor: pointer;
}

/* --- Back to top ------------------------------------------------------------
   Floats over the bottom of the content pane once it has been scrolled a
   screenful. Positioned against .cu-main rather than the viewport so it centres
   over the content, not under the sidebar.

   Always rendered and toggled with a class, so it can fade rather than pop —
   and visibility (not just opacity) is animated so the hidden state is
   genuinely gone: no stray click target, and nothing announced to a screen
   reader while it is not offered. */

.cu-to-top {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  font-family: inherit;
  font-size: var(--cu-text-xs);
  font-weight: 600;
  color: var(--cu-text-muted);
  visibility: hidden;
  cursor: pointer;
  background-color: var(--cu-surface);
  border: 1px solid var(--cu-border-strong);
  border-radius: var(--cu-radius-pill);
  box-shadow: var(--cu-shadow);
  opacity: 0;
  transform: translateX(-50%) translateY(0.5rem);
  transition: opacity var(--cu-transition), transform var(--cu-transition),
    visibility var(--cu-transition), color var(--cu-transition),
    border-color var(--cu-transition);
}

.cu-to-top.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.cu-to-top:hover {
  color: var(--cu-brand-700);
  border-color: var(--cu-brand-400);
}

.cu-to-top:focus-visible {
  outline: 2px solid var(--cu-brand-600);
  outline-offset: 2px;
}

:root[data-bs-theme="dark"] .cu-to-top:hover {
  color: var(--cu-brand-300);
}

@media (prefers-reduced-motion: reduce) {
  .cu-to-top {
    transition: none;
    transform: translateX(-50%);
  }

  .cu-to-top.is-visible {
    transform: translateX(-50%);
  }
}

