/* ==========================================================================
   Nexa-Switch :: operations UI design system

   A restrained, data-first fintech palette layered over Lumo. Light is the
   default; dark is applied by Vaadin's theme variant on <html>.

   Conventions
   -----------
   --ns-*   Nexa-Switch semantic tokens
   --lumo-* Lumo tokens we deliberately re-point so stock Vaadin components
            inherit the design system instead of looking like default Vaadin.
   ========================================================================== */

html {
  /* --- Brand ------------------------------------------------------------ */
  --ns-brand: #2f54ff;
  --ns-brand-strong: #2444e0;
  --ns-brand-soft: #edf1ff;
  --ns-brand-contrast: #ffffff;

  /* --- Surfaces --------------------------------------------------------- */
  --ns-canvas: #f7f8fb;
  --ns-surface: #ffffff;
  --ns-surface-raised: #ffffff;
  --ns-surface-sunken: #f2f4f9;
  --ns-nav: #0d1220;
  --ns-nav-fg: #9aa5bd;
  --ns-nav-fg-active: #ffffff;
  --ns-nav-hover: rgba(255, 255, 255, 0.06);
  --ns-nav-active: rgba(47, 84, 255, 0.18);

  /* --- Text ------------------------------------------------------------- */
  --ns-text: #0f1729;
  --ns-text-secondary: #55607a;
  --ns-text-tertiary: #8b94a8;

  /* --- Lines ------------------------------------------------------------ */
  --ns-border: #e4e8f1;
  --ns-border-strong: #ccd4e3;

  /* --- Status ----------------------------------------------------------- */
  --ns-success: #0c7c56;
  --ns-success-soft: #e2f5ed;
  --ns-warning: #9a5b06;
  --ns-warning-soft: #fdf0dc;
  --ns-danger: #b91f36;
  --ns-danger-soft: #fceaed;

  /* Chart series. Ordered so the first three carry the meanings the dashboard repeats
     everywhere: 1 is all payments, 2 is success, 3 is failure. Chosen to stay
     distinguishable side by side and to survive the common colour vision deficiencies -
     which is also why nothing on the dashboard relies on colour alone. */
  --ns-series-1: #2f54ff;
  --ns-series-2: #0c7c56;
  --ns-series-3: #b91f36;
  --ns-series-4: #8a5cf5;
  --ns-series-5: #b06d00;
  --ns-series-6: #0e7490;
  --ns-heat: #2f54ff;
  --ns-info: #17629f;
  --ns-info-soft: #e7f1fb;
  --ns-neutral: #55607a;
  --ns-neutral-soft: #eceff5;

  /* --- Shape and depth -------------------------------------------------- */
  --ns-radius: 10px;
  --ns-radius-sm: 7px;
  --ns-radius-lg: 14px;
  --ns-shadow-xs: 0 1px 2px rgba(15, 23, 41, 0.05);
  --ns-shadow-sm: 0 1px 3px rgba(15, 23, 41, 0.07), 0 1px 2px rgba(15, 23, 41, 0.04);
  --ns-shadow-md: 0 6px 16px rgba(15, 23, 41, 0.09);
  --ns-shadow-lg: 0 18px 44px rgba(15, 23, 41, 0.14);

  --ns-nav-width: 250px;
  --ns-nav-width-collapsed: 68px;

  /* --- Lumo re-pointing ------------------------------------------------- */
  --lumo-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  --lumo-primary-color: var(--ns-brand);
  --lumo-primary-color-50pct: rgba(47, 84, 255, 0.5);
  --lumo-primary-color-10pct: var(--ns-brand-soft);
  --lumo-primary-text-color: var(--ns-brand);
  --lumo-primary-contrast-color: var(--ns-brand-contrast);

  --lumo-base-color: var(--ns-surface);
  --lumo-tint: var(--ns-surface);
  --lumo-contrast-5pct: var(--ns-surface-sunken);
  --lumo-contrast-10pct: var(--ns-border);
  --lumo-contrast-20pct: var(--ns-border-strong);

  --lumo-body-text-color: var(--ns-text);
  --lumo-header-text-color: var(--ns-text);
  --lumo-secondary-text-color: var(--ns-text-secondary);
  --lumo-tertiary-text-color: var(--ns-text-tertiary);

  --lumo-success-color: var(--ns-success);
  --lumo-error-color: var(--ns-danger);

  --lumo-border-radius-s: var(--ns-radius-sm);
  --lumo-border-radius-m: var(--ns-radius);
  --lumo-border-radius-l: var(--ns-radius-lg);

  --lumo-font-size-xxs: 0.6875rem;
  --lumo-font-size-xs: 0.75rem;
  --lumo-font-size-s: 0.8125rem;
  --lumo-font-size-m: 0.875rem;
  --lumo-font-size-l: 1rem;
  --lumo-font-size-xl: 1.25rem;
  --lumo-font-size-xxl: 1.5rem;

  --lumo-space-xs: 0.3rem;
  --lumo-space-s: 0.6rem;
  --lumo-space-m: 1rem;
  --lumo-space-l: 1.5rem;
  --lumo-space-xl: 2.25rem;

  --lumo-size-s: 1.875rem;
  --lumo-size-m: 2.25rem;

  background-color: var(--ns-canvas);
}

/* ------------------------------------------------------------------ dark -- */

[theme~='dark'] {
  /* Lifted and desaturated for a dark ground: the light palette reads as neon on it. */
  --ns-series-1: #7d99ff;
  --ns-series-2: #34d399;
  --ns-series-3: #f87f8f;
  --ns-series-4: #b28bff;
  --ns-series-5: #f0b45f;
  --ns-series-6: #38bdf8;
  --ns-heat: #7d99ff;

  --ns-brand: #6183ff;
  --ns-brand-strong: #7d99ff;
  --ns-brand-soft: #17203b;

  --ns-canvas: #070a11;
  --ns-surface: #0e131e;
  --ns-surface-raised: #131926;
  --ns-surface-sunken: #151c2a;
  --ns-nav: #090d15;
  --ns-nav-fg: #8b96ad;
  --ns-nav-active: rgba(97, 131, 255, 0.2);

  --ns-text: #e8ecf5;
  --ns-text-secondary: #98a2b6;
  --ns-text-tertiary: #6b7691;

  --ns-border: #1d2534;
  --ns-border-strong: #2a3446;

  --ns-success: #3ec994;
  --ns-success-soft: #0e2a20;
  --ns-warning: #e2ab63;
  --ns-warning-soft: #2a2013;
  --ns-danger: #f4788f;
  --ns-danger-soft: #2c1418;
  --ns-info: #6fb0f2;
  --ns-info-soft: #11223a;
  --ns-neutral: #98a2b6;
  --ns-neutral-soft: #182031;

  --ns-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.45);
  --ns-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --ns-shadow-md: 0 8px 20px rgba(0, 0, 0, 0.5);
  --ns-shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.6);

  --lumo-base-color: var(--ns-surface);
  --lumo-shade: #ffffff;
}

/* ---------------------------------------------------------------- shell -- */

vaadin-app-layout {
  --vaadin-app-layout-drawer-overlay-background: rgba(7, 10, 17, 0.6);
  background: var(--ns-canvas);
}

vaadin-app-layout::part(navbar) {
  background: color-mix(in srgb, var(--ns-surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ns-border);
  min-height: 58px;
}

vaadin-app-layout::part(drawer) {
  background: var(--ns-nav);
  border-right: none;
  width: var(--ns-nav-width);
  transition: width 160ms ease;
}

vaadin-app-layout[dir='ltr']::part(drawer) {
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.05);
}

/* Collapsed rail */
vaadin-app-layout.ns-rail::part(drawer) {
  width: var(--ns-nav-width-collapsed);
}

.ns-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 16px;
  height: 58px;
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
  white-space: nowrap;
}

.ns-brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--ns-brand) 0%, #7a5bff 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(47, 84, 255, 0.4);
}

.ns-brand-name {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.ns-brand-name b {
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: #fff;
}

.ns-brand-name span {
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6f7b95;
}

/* ------------------------------------------------------------------ nav -- */

.ns-nav-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 8px 16px;
}

.ns-nav-section {
  padding: 14px 12px 5px;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #5f6a83;
}

/* Collapsible nav groups (vaadin-details). The clickable label is a light-DOM
   <vaadin-details-summary> child slotted into the summary slot - vaadin-details does NOT expose a
   "summary" part, so it must be targeted as an element (::part(summary) silently matches nothing).
   Its chevron lives in the summary's own shadow, reachable as ::part(toggle). The group's links are
   the details content, which IS a real part (::part(content)). */
vaadin-details.ns-nav-group {
  background: transparent;
  border: none;
  box-shadow: none;
  margin: 0;
}
vaadin-details.ns-nav-group vaadin-details-summary {
  padding: 9px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ns-nav-fg);
  border-radius: 8px;
  cursor: pointer;
}
vaadin-details.ns-nav-group vaadin-details-summary:hover {
  color: var(--ns-nav-fg-active);
  background: var(--ns-nav-hover);
}
vaadin-details.ns-nav-group vaadin-details-summary::part(toggle) {
  color: #5f6a83;
  margin-right: 4px;
}
vaadin-details.ns-nav-group::part(content) {
  padding: 0;
}
.ns-nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
/* Icons-only rail: a group header truncated to "Payme"/"Infrast" reads as a broken layout, and a
   closed accordion would hide its link icons entirely. So hide the summaries and force every
   group's content open, leaving a clean, centered column of link icons. The groups' own
   opened/closed state is untouched, so expanding the drawer restores the accordion exactly. */
.ns-rail vaadin-details.ns-nav-group vaadin-details-summary {
  display: none !important;
}
.ns-rail vaadin-details.ns-nav-group::part(content) {
  display: block !important;
}

.ns-rail .ns-nav-section {
  padding: 12px 12px 4px;
  color: transparent;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 6px;
  height: 1px;
  overflow: hidden;
}

/* Collapsed rail: icons, and nothing else.

   The label is taken out of the flow rather than left to the item's overflow to clip. Clipping is
   what the rail did before, and it left the first few letters of every entry showing - "Da",
   "Tra", "Ref", "Co" - which reads as a layout that has broken rather than one that has been
   collapsed on purpose. Every link carries a title attribute, so the name is a hover away. */
.ns-rail .ns-nav-item {
  justify-content: center;
  padding-inline: 0;
  gap: 0;
}

.ns-rail .ns-nav-item > span {
  display: none;
}

.ns-rail .ns-brand {
  justify-content: center;
  padding: 0;
}

.ns-rail .ns-brand-name {
  display: none;
}

/* A version number clipped to "Nexa-S" says less than no version number at all. */
.ns-rail .ns-nav-foot {
  display: none;
}

.ns-nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  margin-bottom: 1px;
  border-radius: 8px;
  color: var(--ns-nav-fg);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: background 110ms ease, color 110ms ease;
}

.ns-nav-item vaadin-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

.ns-nav-item:hover {
  background: var(--ns-nav-hover);
  color: #fff;
}

.ns-nav-item.ns-active {
  background: var(--ns-nav-active);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--ns-brand);
}

.ns-nav-item:focus-visible {
  outline: 2px solid var(--ns-brand);
  outline-offset: -2px;
}

.ns-nav-foot {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.6875rem;
  color: #5f6a83;
  white-space: nowrap;
  overflow: hidden;
}

/* --------------------------------------------------------------- navbar -- */

.ns-navbar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 16px 0 6px;
  box-sizing: border-box;
}

.ns-crumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 0.8125rem;
  color: var(--ns-text-tertiary);
}

.ns-crumbs b {
  color: var(--ns-text);
  font-weight: 600;
}

.ns-navbar-search {
  width: 260px;
  max-width: 32vw;
}

.ns-user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 9px 4px 5px;
  border-radius: 999px;
  border: 1px solid var(--ns-border);
  background: var(--ns-surface);
  cursor: pointer;
}

.ns-user-chip:hover {
  background: var(--ns-surface-sunken);
}

.ns-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ns-brand-soft);
  color: var(--ns-brand);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ns-user-chip-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: left;
}

.ns-user-chip-text b {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ns-text);
}

.ns-user-chip-text span {
  font-size: 0.625rem;
  color: var(--ns-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ----------------------------------------------------------------- page -- */

.ns-view {
  padding: 18px 22px 26px;
  width: 100%;
  box-sizing: border-box;
}

/*
 * Vaadin's VerticalLayout is a flex column that aligns children to the start, so a card keeps its
 * intrinsic width instead of filling the row. Every direct child of a view should span the content
 * width; grids inside them handle their own columns.
 */
.ns-view > * {
  width: 100%;
  box-sizing: border-box;
}

/* Card rows: each card is as tall as its own content, never padded to match its neighbour. */
.ns-row {
  display: grid;
  gap: 14px;
  width: 100%;
  align-items: start;
}

.ns-row-metrics {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.ns-row-cards {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.ns-row-wide {
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}

/* Equal-height cards.

   .ns-row defaults to align-items:start, which lets each card shrink to its own content. That is
   right for detail panels of different lengths and wrong for a set of peers: connectors are the
   same kind of thing, so ragged bottoms read as an alignment fault rather than as information.

   Opt-in rather than a change to .ns-row, which six other views rely on collapsing. */
.ns-row-equal {
  align-items: stretch;
}

.ns-row-equal > * {
  height: 100%;
}

/* The card and its body become columns so the extra height has somewhere to go. Without this a
   stretched card keeps its content at natural height and simply grows a gap at the bottom. */
.ns-row-equal > .ns-card {
  display: flex;
  flex-direction: column;
}

.ns-row-equal > .ns-card > .ns-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* The body of a connector card is a single wrapper div; it has to stretch too, or the action
   inside it has no height to be pushed down through. */
.ns-row-equal > .ns-card > .ns-card-body > * {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* The action sits on the bottom edge of the card, so the buttons line up across the row even
   though the text above them does not.

   Margins only. The class is on the button itself, so padding here is the button's own internal
   padding: a padding-top of 10px against Lumo's padding-bottom of 0 pushed the label down inside
   the button and left it visibly off centre. Space above an element belongs to its margin. There
   is no margin-top to set either - the card body is a flex column with its own gap, and
   margin-top:auto is what carries the button to the bottom.

   No stretch: filling the card width centres the label and turns a small action into a banner.
   Its size stays what it was. */
.ns-card-action {
  margin-top: auto;
  align-self: flex-start;
}

/* Detail blocks inside a card, so a single wide card still uses its width. */
.ns-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px 22px;
  align-items: start;
}

/* Connector cards: health, latency and the enabled badge on one line, so the card that used to
   spend two grid rows on them spends one. */
.ns-connector-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 12px;
}

/* The "needs credentials" note as a small pill instead of a full-width tinted box: same amber
   meaning, a fraction of the height. self-start so it hugs its text rather than stretching. */
.ns-connector-warn {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--ns-warning) 22%, transparent);
  background: var(--ns-warning-soft);
  color: var(--ns-warning);
  font-size: 0.6875rem;
  white-space: nowrap;
}

/* Data grids fill the remaining viewport height instead of leaving the page half empty. */
.ns-grid-fill {
  height: calc(100vh - 292px);
  min-height: 340px;
}

.ns-grid-fill-tall {
  height: calc(100vh - 216px);
  min-height: 380px;
}

.ns-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.ns-page-header h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 660;
  letter-spacing: -0.015em;
  color: var(--ns-text);
}

.ns-page-header p {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--ns-text-secondary);
  max-width: 78ch;
}

/* ----------------------------------------------------------------- card -- */

.ns-card {
  background: var(--ns-surface);
  border: 1px solid var(--ns-border);
  border-radius: var(--ns-radius);
  box-shadow: var(--ns-shadow-xs);
  overflow: hidden;
}

/* Title on the left, actions on the right - and when the two no longer fit side by side, the
   actions take a line of their own rather than crushing the title into three.

   A third action is what forced this. A card narrow enough to be one of five across a wide screen
   has about 410px of header, which "Arrangements, Configure, Details" and a title do not share.
   Without a wrap the subtitle broke mid-phrase - "CYBERSOURCE - priority / 30" - and every card in
   the row started its body at a different height. */
.ns-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--ns-border);
}

/* The title block is what yields: it may shrink, and its text ends in an ellipsis rather than
   wrapping, so the header keeps the two-line shape it has when everything fits. */
.ns-card-head > :first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.ns-card-head h3 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 620;
  color: var(--ns-text);
}

/* A title is a name, so it is clipped rather than wrapped. A subtitle is not: on a connector card
   it is "AIRTEL - priority 10", but on a form card it is a sentence explaining what the group is
   for, and clipping that to "The client id and secret issued for your Airtel developer ..." throws
   away the half that says what to do. It wraps, as it did before the header was taught to. */
.ns-card-head h3 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ns-card-head .ns-sub {
  font-size: 0.75rem;
  color: var(--ns-text-secondary);
}

/* The actions travel as one unit, so a wrap can never strand a single button on a line of its
   own with its two neighbours above it. */
.ns-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  margin-left: auto;
}

/* Tighter than a small button standing on its own: three of these share a header no wider than a
   sentence, and Lumo's padding is drawn for a button with room around it. */
.ns-card-actions vaadin-button {
  margin: 0;
  padding-inline: 8px;
}

/* A card in a row of cards answers to its own width, not the window's.

   Five connectors across a wide screen are each about 440px, and whether a header fits on one
   line is a fact about that 440, which no media query knows. Scoped to cards that are grid items
   with a width the grid has already decided, so nothing here can collapse a card whose width
   depends on what is inside it. */
.ns-row > .ns-card {
  container-type: inline-size;
}

/* 520px is where the widest of these headers stops fitting on one line, measured rather than
   guessed at.

   Below it every header in the row drops its actions underneath - all of them, including the card
   with a single action that would still have fitted. Cards in a row are the same width, so the
   decision comes out the same for each one and the headers stay level with each other. Letting
   each card decide for itself is what produced a row where two headers were one line and three
   were two, which reads as a fault rather than as a narrow screen. */
@container (max-width: 520px) {
  .ns-card-actions {
    flex-basis: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
}

.ns-card-body {
  padding: 16px;
}

.ns-card-body-flush {
  padding: 0;
}

/* --------------------------------------------------------------- metric -- */

.ns-metric {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 16px;
  background: var(--ns-surface);
  border: 1px solid var(--ns-border);
  border-radius: var(--ns-radius);
  box-shadow: var(--ns-shadow-xs);
  min-width: 0;
}

.ns-metric-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.ns-metric-label {
  font-size: 0.6875rem;
  font-weight: 620;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ns-text-secondary);
}

.ns-metric-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: var(--ns-neutral-soft);
  color: var(--ns-neutral);
  flex: 0 0 27px;
}

.ns-metric-icon vaadin-icon {
  width: 14px;
  height: 14px;
}

.ns-metric-icon.ns-tone-success {
  background: var(--ns-success-soft);
  color: var(--ns-success);
}
.ns-metric-icon.ns-tone-warning {
  background: var(--ns-warning-soft);
  color: var(--ns-warning);
}
.ns-metric-icon.ns-tone-danger {
  background: var(--ns-danger-soft);
  color: var(--ns-danger);
}
.ns-metric-icon.ns-tone-brand {
  background: var(--ns-brand-soft);
  color: var(--ns-brand);
}

.ns-metric-value {
  font-size: 1.6rem;
  font-weight: 660;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--ns-text);
  line-height: 1.1;
}

.ns-metric-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  color: var(--ns-text-tertiary);
}

.ns-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.ns-trend vaadin-icon {
  width: 12px;
  height: 12px;
}

.ns-trend.ns-up {
  color: var(--ns-success);
}
.ns-trend.ns-down {
  color: var(--ns-danger);
}
.ns-trend.ns-flat {
  color: var(--ns-text-tertiary);
}

/* --------------------------------------------------------------- status -- */

.ns-status {
  /* A badge dropped straight into a flex column would otherwise stretch to the column width.
     flex-start is the cross axis, so in a column it means "do not stretch" - which is what this
     is for - but in a ROW it means "sit at the top". The rule below puts it back to centre in the
     three horizontal action rows, where a badge sits beside buttons and has to share their line. */
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 640;
  letter-spacing: 0.015em;
  white-space: nowrap;
  border: 1px solid transparent;
}

/* A badge beside buttons in a horizontal action row. Buttons are taller than a badge, so a
   top-aligned badge reads as misaligned by about ten pixels - visible, and the kind of thing that
   makes a header look untidy without it being obvious why. */
.ns-page-header vaadin-horizontal-layout .ns-status,
.ns-panel-actions .ns-status,
.ns-card-head .ns-status {
  align-self: center;
}

.ns-status .ns-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 6px;
}

.ns-status.ns-tone-success {
  background: var(--ns-success-soft);
  color: var(--ns-success);
  border-color: color-mix(in srgb, var(--ns-success) 22%, transparent);
}
.ns-status.ns-tone-warning {
  background: var(--ns-warning-soft);
  color: var(--ns-warning);
  border-color: color-mix(in srgb, var(--ns-warning) 22%, transparent);
}
.ns-status.ns-tone-danger {
  background: var(--ns-danger-soft);
  color: var(--ns-danger);
  border-color: color-mix(in srgb, var(--ns-danger) 22%, transparent);
}
.ns-status.ns-tone-info {
  background: var(--ns-info-soft);
  color: var(--ns-info);
  border-color: color-mix(in srgb, var(--ns-info) 22%, transparent);
}
.ns-status.ns-tone-neutral {
  background: var(--ns-neutral-soft);
  color: var(--ns-neutral);
  border-color: color-mix(in srgb, var(--ns-neutral) 18%, transparent);
}

/* ----------------------------------------------------------------- grid -- */

vaadin-grid {
  --lumo-border-radius-l: 0;
  border: none;
  font-size: 0.8125rem;
}

vaadin-grid::part(header-cell) {
  background: var(--ns-surface-sunken);
  font-size: 0.6875rem;
  font-weight: 620;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ns-text-secondary);
}

vaadin-grid::part(cell) {
  border-color: var(--ns-border);
}

vaadin-grid::part(row):hover > [part~='cell'] {
  background: var(--ns-surface-sunken);
}

.ns-mono {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.75rem;
  letter-spacing: -0.01em;
}

.ns-num {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- state -- */

.ns-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 24px;
  text-align: center;
}

.ns-state-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--ns-surface-sunken);
  color: var(--ns-text-tertiary);
}

.ns-state-icon vaadin-icon {
  width: 20px;
  height: 20px;
}

.ns-state-icon.ns-tone-danger {
  background: var(--ns-danger-soft);
  color: var(--ns-danger);
}

.ns-state h4 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 620;
  color: var(--ns-text);
}

.ns-state p {
  margin: 0;
  max-width: 46ch;
  font-size: 0.8125rem;
  color: var(--ns-text-secondary);
}

/* ------------------------------------------------------------- skeleton -- */

.ns-skeleton {
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--ns-surface-sunken) 25%,
    color-mix(in srgb, var(--ns-surface-sunken) 55%, var(--ns-border)) 37%,
    var(--ns-surface-sunken) 63%
  );
  background-size: 400% 100%;
  animation: ns-shimmer 1.3s ease-in-out infinite;
}

@keyframes ns-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ns-skeleton {
    animation: none;
  }
  vaadin-app-layout::part(drawer) {
    transition: none;
  }
  /* Everything the dashboard animates arrives in its final state instead. The charts stay
     fully interactive - hover, tooltip, legend toggling, click to filter - only the movement
     goes. The draw-on animations are additionally skipped in the charts' own scripts, which is
     what stops a line being left half drawn. */
  .tc-line,
  .tc-area,
  .dn-slice,
  .ns-reason-meter-fill,
  .ns-enter,
  .ns-kpi {
    animation: none !important;
    transition: none !important;
  }
  .tc-line {
    stroke-dasharray: none !important;
    stroke-dashoffset: 0 !important;
  }
  .ns-reason-meter-fill {
    transform: none !important;
  }
}

/* ------------------------------------------------------------- timeline -- */

.ns-timeline {
  display: flex;
  flex-direction: column;
}

.ns-timeline-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
}

.ns-timeline-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ns-timeline-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--ns-neutral);
  box-shadow: 0 0 0 3px var(--ns-neutral-soft);
}

.ns-timeline-dot.ns-tone-success {
  background: var(--ns-success);
  box-shadow: 0 0 0 3px var(--ns-success-soft);
}
.ns-timeline-dot.ns-tone-warning {
  background: var(--ns-warning);
  box-shadow: 0 0 0 3px var(--ns-warning-soft);
}
.ns-timeline-dot.ns-tone-danger {
  background: var(--ns-danger);
  box-shadow: 0 0 0 3px var(--ns-danger-soft);
}
.ns-timeline-dot.ns-tone-info {
  background: var(--ns-info);
  box-shadow: 0 0 0 3px var(--ns-info-soft);
}

.ns-timeline-line {
  flex: 1;
  width: 2px;
  min-height: 16px;
  background: var(--ns-border);
}

.ns-timeline-body {
  padding-bottom: 15px;
  min-width: 0;
}

.ns-timeline-body b {
  font-size: 0.8125rem;
  font-weight: 620;
  color: var(--ns-text);
}

.ns-timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--ns-text-tertiary);
}

.ns-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border: 1px solid var(--ns-border);
  border-radius: 999px;
  background: var(--ns-surface-sunken);
  font-size: 0.6875rem;
  color: var(--ns-text-secondary);
  white-space: nowrap;
}

.ns-kv {
  margin-top: 7px;
  padding: 8px 10px;
  background: var(--ns-surface-sunken);
  border-radius: 7px;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.6875rem;
  color: var(--ns-text-secondary);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ----------------------------------------------------------- definition -- */

.ns-dl {
  display: grid;
  grid-template-columns: minmax(150px, 210px) 1fr;
}

.ns-dl > div {
  display: contents;
}

.ns-dl dt,
.ns-dl dd {
  padding: 8px 0;
  border-bottom: 1px solid var(--ns-border);
  margin: 0;
  font-size: 0.8125rem;
  min-width: 0;
}

.ns-dl dt {
  color: var(--ns-text-secondary);
  font-size: 0.75rem;
}

.ns-dl dd {
  color: var(--ns-text);
  word-break: break-word;
}

/* ---------------------------------------------------------------- chart -- */

.ns-chart {
  width: 100%;
  overflow-x: auto;
}

.ns-chart svg {
  display: block;
  width: 100%;
  /* Fixed height: the viewBox would otherwise scale the plot taller on wide screens. */
  height: 230px;
}

.ns-chart-bar {
  fill: var(--ns-brand);
  opacity: 0.85;
}

.ns-chart-bar-success {
  fill: var(--ns-success);
}

.ns-chart-axis {
  stroke: var(--ns-border);
  stroke-width: 1;
}

.ns-chart-label {
  fill: var(--ns-text-tertiary);
  font-size: 9px;
  font-family: var(--lumo-font-family);
}

.ns-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--ns-text-secondary);
}

.ns-legend-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ns-legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

/* --------------------------------------------------------------- meters -- */

.ns-meter {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--ns-surface-sunken);
}

.ns-meter > span {
  display: block;
  height: 100%;
}

.ns-gauge {
  --ns-gauge-value: 0;
  position: relative;
  width: 92px;
  height: 92px;
  flex: 0 0 92px;
  border-radius: 50%;
  background: conic-gradient(
    var(--ns-success) calc(var(--ns-gauge-value) * 1%),
    var(--ns-surface-sunken) 0
  );
  display: grid;
  place-items: center;
}

.ns-gauge::after {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--ns-surface);
}

.ns-gauge-value {
  position: relative;
  font-size: 1.05rem;
  font-weight: 660;
  font-variant-numeric: tabular-nums;
  color: var(--ns-text);
}

/* ---------------------------------------------------------- flow canvas -- */

.ns-flow {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  padding: 4px 0 2px;
}

.ns-flow-node {
  display: flex;
  flex: 1 1 150px;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 140px;
  padding: 11px 12px;
  border: 1px solid var(--ns-border);
  border-radius: var(--ns-radius);
  background: var(--ns-surface);
  box-shadow: var(--ns-shadow-xs);
  text-align: center;
}

.ns-flow-node b {
  font-size: 0.8125rem;
  font-weight: 620;
  color: var(--ns-text);
}

.ns-flow-node span {
  font-size: 0.6875rem;
  color: var(--ns-text-secondary);
}

.ns-flow-node.ns-accent {
  border-color: color-mix(in srgb, var(--ns-brand) 40%, var(--ns-border));
  background: var(--ns-brand-soft);
}

.ns-flow-arrow {
  flex: 0 0 22px;
  width: 22px;
  align-self: center;
  height: 2px;
  background: var(--ns-border-strong);
  position: relative;
}

.ns-flow-arrow::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--ns-border-strong);
}

@media (max-width: 900px) {
  .ns-flow {
    flex-direction: column;
    align-items: center;
  }

  .ns-flow-node {
    flex: 0 0 auto;
    width: 100%;
    max-width: 340px;
  }

  .ns-flow-arrow {
    flex: 0 0 18px;
    width: 2px;
    height: 18px;
  }

  .ns-flow-arrow::after {
    right: auto;
    top: auto;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 6px solid var(--ns-border-strong);
    border-bottom: 0;
  }
}

/* ---------------------------------------------------------------- login -- */

.ns-login {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
  width: 100%;
  background: var(--ns-canvas);
}

.ns-login-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 44px;
  color: #fff;
  background: radial-gradient(125% 125% at 0% 0%, #1a2a6d 0%, #0c1226 52%, #070a11 100%);
  overflow: hidden;
}

.ns-login-aside h2 {
  /* Lumo colours headings with --lumo-header-text-color, which is dark; the aside is dark. */
  color: #ffffff;
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.22;
  font-weight: 640;
  letter-spacing: -0.02em;
  max-width: 17ch;
}

.ns-login-aside p {
  color: #a4b0cd;
  margin: 10px 0 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: #a4b0cd;
  max-width: 46ch;
}

.ns-login-points {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}

.ns-login-point {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.8125rem;
  color: #cbd4e8;
}

.ns-login-point vaadin-icon {
  width: 16px;
  height: 16px;
  color: #8aa2ff;
  flex: 0 0 16px;
}

.ns-login-main {
  display: grid;
  place-items: center;
  padding: 32px;
}

.ns-login-card {
  width: 100%;
  max-width: 372px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.ns-login-card-hidden {
  display: none !important;
}

.ns-login-note {
  margin-top: 15px;
  padding: 11px 13px;
  border: 1px dashed var(--ns-border-strong);
  border-radius: 9px;
  background: var(--ns-surface-sunken);
  font-size: 0.75rem;
  color: var(--ns-text-secondary);
  line-height: 1.5;
}

/* ----------------------------------------------------------- responsive -- */

@media (max-width: 1100px) {
  .ns-login {
    grid-template-columns: minmax(0, 1fr);
  }
  .ns-login-aside {
    display: none;
  }
}

@media (max-width: 900px) {
  .ns-view {
    padding: 14px 14px 32px;
  }
  .ns-navbar-search {
    display: none;
  }
  .ns-dl {
    grid-template-columns: minmax(0, 1fr);
  }
  .ns-dl dt {
    border-bottom: none;
    padding-bottom: 0;
  }
  .ns-user-chip-text {
    display: none;
  }
}

/* Utility */
.ns-muted {
  color: var(--ns-text-secondary);
}
.ns-tertiary {
  color: var(--ns-text-tertiary);
}
.ns-small {
  font-size: 0.75rem;
}
.ns-strong {
  font-weight: 620;
}
.ns-full {
  width: 100%;
}
.ns-wrap {
  white-space: normal;
}

/* The card above the form provides the heading, so hide the component's own. */
.ns-login-card vaadin-login-form-wrapper::part(form-title) {
  display: none;
}

/* --------------------------------------------------- TOTP digit input boxes -- */

.ns-otp-digit,
.ns-setup-digit {
  width: 48px;
  height: 56px;
  font-size: 1.5rem;
  text-align: center;
  font-weight: 600;
  border: 2px solid var(--lumo-contrast-20pct);
  border-radius: 12px;
  outline: none;
  background: transparent;
  color: var(--lumo-body-text-color);
  transition: border-color 0.2s, box-shadow 0.2s;
  caret-color: var(--ns-accent, #4361ee);
}
.ns-otp-digit:focus,
.ns-setup-digit:focus {
  border-color: var(--ns-accent, #4361ee);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

/* -------------------------------------------------------- status chip tabs -- */

.ns-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ns-chip-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--ns-border);
  border-radius: 999px;
  background: var(--ns-surface);
  font-size: 0.75rem;
  font-weight: 560;
  color: var(--ns-text-secondary);
  cursor: pointer;
  user-select: none;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.ns-chip-tab:hover {
  border-color: var(--ns-border-strong);
  color: var(--ns-text);
}

.ns-chip-tab .ns-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ns-surface-sunken);
  color: var(--ns-text-secondary);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.ns-chip-tab.ns-active {
  border-color: color-mix(in srgb, var(--ns-brand) 55%, var(--ns-border));
  background: var(--ns-brand-soft);
  color: var(--ns-brand-strong, var(--ns-brand));
}

.ns-chip-tab.ns-active .ns-chip-count {
  background: color-mix(in srgb, var(--ns-brand) 18%, transparent);
  color: var(--ns-brand-strong, var(--ns-brand));
}

.ns-chip-tab.ns-tone-success.ns-active {
  border-color: color-mix(in srgb, var(--ns-success) 55%, var(--ns-border));
  background: color-mix(in srgb, var(--ns-success) 12%, transparent);
  color: var(--ns-success);
}

.ns-chip-tab.ns-tone-danger.ns-active {
  border-color: color-mix(in srgb, var(--ns-danger) 55%, var(--ns-border));
  background: color-mix(in srgb, var(--ns-danger) 12%, transparent);
  color: var(--ns-danger);
}

.ns-chip-tab.ns-tone-warning.ns-active {
  border-color: color-mix(in srgb, var(--ns-warning) 55%, var(--ns-border));
  background: color-mix(in srgb, var(--ns-warning) 14%, transparent);
  color: var(--ns-warning);
}

/* ------------------------------------------------------ mode badge + scope -- */

.ns-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 640;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ns-mode-badge vaadin-icon {
  width: 12px;
  height: 12px;
}

.ns-mode-badge.ns-test {
  background: color-mix(in srgb, var(--ns-warning) 16%, transparent);
  color: var(--ns-warning);
  border: 1px solid color-mix(in srgb, var(--ns-warning) 32%, transparent);
}

.ns-mode-badge.ns-live {
  background: color-mix(in srgb, var(--ns-success) 14%, transparent);
  color: var(--ns-success);
  border: 1px solid color-mix(in srgb, var(--ns-success) 30%, transparent);
}

.ns-scope-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 560;
  color: var(--ns-text-secondary);
  white-space: nowrap;
}

.ns-scope-chip vaadin-icon {
  width: 14px;
  height: 14px;
  color: var(--ns-text-tertiary);
}

/* ----------------------------------------------------------- command palette -- */

.ns-palette-trigger {
  color: var(--ns-text-secondary) !important;
  font-size: 0.8rem;
}

.ns-kbd {
  margin-left: 8px;
  padding: 1px 6px;
  border: 1px solid var(--ns-border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--ns-surface-sunken);
  color: var(--ns-text-tertiary);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.ns-palette::part(overlay) {
  padding: 0;
  border-radius: var(--ns-radius-lg);
}

.ns-palette::part(content) {
  padding: 12px 12px 0;
}

.ns-palette-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 340px;
  overflow-y: auto;
  padding: 8px 0 4px;
}

.ns-palette-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--ns-radius);
  cursor: pointer;
}

.ns-palette-row vaadin-icon {
  width: 15px;
  height: 15px;
  color: var(--ns-text-tertiary);
  flex: 0 0 auto;
}

.ns-palette-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ns-palette-text b {
  font-size: 0.8125rem;
  font-weight: 580;
  color: var(--ns-text);
}

.ns-palette-text span {
  font-size: 0.6875rem;
  color: var(--ns-text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ns-palette-row.ns-active {
  background: var(--ns-brand-soft);
}

.ns-palette-row.ns-active vaadin-icon {
  color: var(--ns-brand);
}

.ns-palette-empty {
  padding: 18px 10px;
  color: var(--ns-text-tertiary);
  font-size: 0.8125rem;
  text-align: center;
}

.ns-palette-foot {
  padding: 8px 10px 10px;
  border-top: 1px solid var(--ns-border);
}

/* ------------------------------------------------------------- code block -- */

.ns-code-block {
  max-height: 460px;
  overflow: auto;
  padding: 14px 16px;
  border: 1px solid var(--ns-border);
  border-radius: var(--ns-radius);
  background: var(--ns-surface-sunken);
  color: var(--ns-text);
  font-family: var(--ns-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.75rem;
  line-height: 1.55;
  white-space: pre;
  tab-size: 2;
}

/* -------------------------------------------------------- first run cards -- */

.ns-start-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-bottom: 4px;
  border-radius: 9px;
  background: var(--ns-brand-soft);
  color: var(--ns-brand);
}

.ns-start-icon vaadin-icon {
  width: 15px;
  height: 15px;
}

/* ------------------------------------------------------- reorderable order -- */

.ns-order-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--ns-border);
  border-radius: var(--ns-radius);
  background: var(--ns-surface);
  font-size: 0.8125rem;
}

.ns-order-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--ns-surface-sunken);
  color: var(--ns-text-secondary);
  font-size: 0.6875rem;
  font-weight: 640;
}

/* ------------------------------------------------------------ routing map -- */

.rm-root {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rm-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rm-tabs,
.rm-zoom {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--ns-border);
  border-radius: var(--ns-radius);
  background: var(--ns-surface-sunken);
}

.rm-tab {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ns-text-secondary);
}

.rm-tab-active {
  background: var(--ns-surface);
  color: var(--ns-text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12);
}

.rm-viewport {
  border: 1px solid var(--ns-border);
  border-radius: var(--ns-radius);
  background: var(--ns-surface-sunken);
  overflow: hidden;
}

/* Clips rather than scrolls: the drawing is moved by a transform on the stage, so a scrollbar
   here would fight the pan. touch-action none stops a touch drag being taken by the page. */
/* Sizes to the drawing rather than to a fixed height: a fixed height left an empty band under a
   two-lane map. Zooming in overflows and is clipped, which is what the pan is for. */
.rm-canvas {
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.rm-canvas.rm-grabbing {
  cursor: grabbing;
}

/* The matrix is a table and has to behave like one. */
.rm-canvas.rm-canvas-matrix {
  overflow: auto;
  cursor: default;
  touch-action: auto;
}

.rm-stage {
  transform-origin: 0 0;
}

/* Fills the card, capped by an inline max-width the server computes from the drawing's natural
   size - only the server knows that, and only the browser knows the card's width, so the cap has
   to be expressed as a limit rather than as a size. Uncapped, a two-column map stretched 3.7x;
   uncapped the other way, it sat marooned at 422px in a 900px card. Centred, because a drawing
   narrower than its container reads as clipped when it is flush left. */
.rm-svg {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  overflow: visible;
}

.rm-col {
  fill: var(--ns-text-tertiary);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.rm-node rect {
  fill: var(--ns-surface);
  stroke: var(--ns-border);
  stroke-width: 1;
}

.rm-node-title {
  fill: var(--ns-text);
  font-size: 12px;
  font-weight: 640;
}

.rm-node-sub {
  fill: var(--ns-text-tertiary);
  font-size: 10px;
}

/* The method is the subject of the lane, so it is the one node that carries the accent. The
   connectors are graded instead: the first attempt reads solid, a failover reads provisional. */
.rm-node-method rect {
  fill: color-mix(in srgb, var(--ns-brand) 14%, var(--ns-surface));
  stroke: color-mix(in srgb, var(--ns-brand) 45%, var(--ns-border));
}

.rm-node-primary rect {
  fill: color-mix(in srgb, var(--ns-success) 12%, var(--ns-surface));
  stroke: color-mix(in srgb, var(--ns-success) 42%, var(--ns-border));
}

.rm-node-fallback rect {
  fill: var(--ns-surface);
  stroke: color-mix(in srgb, var(--ns-success) 32%, var(--ns-border));
  stroke-dasharray: 4 3;
}

.rm-node-empty rect {
  fill: var(--ns-surface-sunken);
  stroke-dasharray: 4 3;
}

.rm-node-empty .rm-node-title {
  fill: var(--ns-text-secondary);
  font-weight: 600;
}

.rm-edge {
  stroke-width: 1.5;
  fill: none;
}

.rm-edge-primary {
  stroke: color-mix(in srgb, var(--ns-success) 55%, var(--ns-border));
}

.rm-edge-fallback {
  stroke: var(--ns-border-strong);
  stroke-dasharray: 5 4;
}

/* Marching ants along the failover edges, and nothing else on the page moves. The dash cycle is
   5 + 4, so the offset travels exactly one period and the loop has no visible seam.

   Only the failover edges: a first attempt is what happens, and animating it would imply
   something is in flight. A dashed line that crawls reads as a path held in reserve, which is
   what a fallback is. Off entirely under prefers-reduced-motion - a continuous loop in the
   corner of the eye is the exact thing that setting exists to stop. */
@media (prefers-reduced-motion: no-preference) {
  .rm-edge-fallback {
    animation: rm-march 900ms linear infinite;
  }
}

@keyframes rm-march {
  to {
    stroke-dashoffset: -9;
  }
}

/* No arrowhead at all - the line marks the absence of a hop rather than a hop. */
.rm-edge-muted {
  stroke: var(--ns-border);
  stroke-dasharray: 2 4;
}

.rm-arrow-primary {
  fill: color-mix(in srgb, var(--ns-success) 55%, var(--ns-border));
}

.rm-arrow-fallback {
  fill: var(--ns-border-strong);
}

.rm-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.rm-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--ns-text-secondary);
}

.rm-swatch {
  width: 16px;
  height: 0;
  border-top-width: 2px;
  border-top-style: solid;
}

.rm-key-primary {
  border-top-color: color-mix(in srgb, var(--ns-success) 55%, var(--ns-border));
}

.rm-key-fallback {
  border-top-style: dashed;
  border-top-color: var(--ns-border-strong);
}

.rm-summary {
  font-size: 0.75rem;
  color: var(--ns-text-tertiary);
}

.rm-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--ns-text-secondary);
}

/* --- matrix ---------------------------------------------------------------- */

.rm-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.rm-matrix th,
.rm-matrix td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--ns-border);
  text-align: center;
}

.rm-matrix thead th {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ns-text-tertiary);
  white-space: nowrap;
}

.rm-matrix tbody th {
  text-align: left;
  font-weight: 620;
  color: var(--ns-text);
  white-space: nowrap;
}

/* The number is the attempt position, so it has to read as an order rather than a quantity. */
.rm-matrix td.rm-cell-primary,
.rm-matrix td.rm-cell-fallback {
  font-variant-numeric: tabular-nums;
  font-weight: 660;
}

.rm-matrix td.rm-cell-primary {
  background: color-mix(in srgb, var(--ns-success) 16%, transparent);
  color: var(--ns-text);
}

.rm-matrix td.rm-cell-fallback {
  background: color-mix(in srgb, var(--ns-success) 7%, transparent);
  color: var(--ns-text-secondary);
}

/* Visible only to a screen reader: the cell is deliberately blank to the eye, but an empty
   cell tells someone reading by keyboard nothing at all. */
.rm-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------------------------- routing fallback chain -- */

/* One payment method: its default provider, then the chain that backs it up.
   Grouped in a bordered block because the three controls belong to each other -
   loose in the form, the chain reads as a fourth unrelated field. */
.ns-chain-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--ns-border);
  border-radius: var(--ns-radius);
  background: var(--ns-surface-sunken);
}

.ns-chain-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Indented and marked, so the chain reads as consequences of the provider above
   it rather than as siblings of it. */
.ns-chain-rows .ns-order-row {
  margin-left: 14px;
  background: var(--ns-surface);
  border-style: dashed;
}

.ns-chain-rows .ns-order-row::before {
  content: "";
  position: absolute;
  margin-left: -14px;
  width: 8px;
  border-top: 1px dashed var(--ns-border);
}

.ns-chain-rows .ns-order-row {
  position: relative;
}

/* ----------------------------------------------------------------- notice -- */

.ns-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 11px 14px;
  border: 1px solid var(--ns-border);
  border-radius: var(--ns-radius);
  background: var(--ns-surface-sunken);
  color: var(--ns-text-secondary);
  font-size: 0.78rem;
  line-height: 1.5;
}

.ns-notice vaadin-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--ns-brand);
}

/* ------------------------------------------------------ payment detail tabs -- */

.ns-detail-tabs::part(content) {
  padding: 14px 0 0;
}

.ns-detail-tabs vaadin-tab {
  font-size: 0.8125rem;
}

.ns-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 17px;
  margin-left: 7px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ns-surface-sunken);
  color: var(--ns-text-secondary);
  font-size: 0.6563rem;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
}

vaadin-tab[selected] .ns-tab-count {
  background: color-mix(in srgb, var(--ns-brand) 16%, transparent);
  color: var(--ns-brand-strong, var(--ns-brand));
}

/* ================================================================ reporting == */

/* Section navigation inside the reports area: one sidebar entry, several rooms. */
.ns-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ns-border);
}

.ns-section-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--ns-radius);
  color: var(--ns-text-secondary);
  font-size: 0.8125rem;
  font-weight: 560;
  cursor: pointer;
  user-select: none;
}

.ns-section-tab vaadin-icon {
  width: 14px;
  height: 14px;
}

.ns-section-tab:hover {
  background: var(--ns-surface-sunken);
  color: var(--ns-text);
}

.ns-section-tab.ns-active {
  background: var(--ns-brand-soft);
  color: var(--ns-brand-strong, var(--ns-brand));
}

/* A heading above a group of template cards. */
.ns-group-heading {
  display: block;
  margin: 16px 0 8px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ns-text-tertiary);
}

.ns-template-card,
.ns-choice-card {
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

.ns-template-card:hover,
.ns-choice-card:hover {
  border-color: var(--ns-border-strong);
  box-shadow: var(--ns-shadow-sm, var(--ns-shadow-xs));
}

.ns-choice-card.ns-selected {
  border-color: color-mix(in srgb, var(--ns-brand) 45%, var(--ns-border));
  background: var(--ns-brand-soft);
}

/* -------------------------------------------------------- builder stepper -- */

.ns-stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 4px;
}

.ns-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--ns-border);
  border-radius: 999px;
  background: var(--ns-surface);
  color: var(--ns-text-secondary);
  font-size: 0.78rem;
  font-weight: 560;
  cursor: pointer;
  user-select: none;
}

.ns-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--ns-surface-sunken);
  color: var(--ns-text-tertiary);
  font-size: 0.6875rem;
  font-weight: 700;
}

.ns-step.ns-active {
  border-color: color-mix(in srgb, var(--ns-brand) 50%, var(--ns-border));
  background: var(--ns-brand-soft);
  color: var(--ns-brand-strong, var(--ns-brand));
}

.ns-step.ns-active .ns-step-number {
  background: var(--ns-brand);
  color: #ffffff;
}

.ns-step.ns-done .ns-step-number {
  background: color-mix(in srgb, var(--ns-success) 18%, transparent);
  color: var(--ns-success);
}

/* ------------------------------------------------------------ field picker -- */

.ns-field-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 420px;
  overflow-y: auto;
  margin-top: 10px;
}

.ns-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--ns-radius);
}

.ns-field-row:hover {
  background: var(--ns-surface-sunken);
}

/* ---------------------------------------------------------- result figures -- */

.ns-figure {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--ns-border);
  border-radius: var(--ns-radius-lg);
  background: var(--ns-surface);
  box-shadow: var(--ns-shadow-xs);
}

.ns-figure-label {
  font-size: 0.6563rem;
  font-weight: 680;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ns-text-tertiary);
}

.ns-figure-value {
  font-size: 1.5rem;
  font-weight: 640;
  letter-spacing: -0.01em;
  color: var(--ns-text);
}

.ns-figure-hint {
  font-size: 0.6875rem;
  color: var(--ns-text-secondary);
}

/* ------------------------------------------------------- definition summary -- */

.ns-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 20px;
}

.ns-kv-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ns-kv-key {
  font-size: 0.6563rem;
  font-weight: 680;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ns-text-tertiary);
}

.ns-kv-value {
  font-size: 0.8125rem;
  font-weight: 560;
  color: var(--ns-text);
}

/* ================================================================ dashboard == */

.ns-dashboard {
  gap: 14px;
}

/* --- filter bar ------------------------------------------------------------- */

.ns-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 14px;
  margin-top: 12px;
  background: var(--ns-surface-raised);
  border: 1px solid var(--ns-border);
  border-radius: 12px;
}

.ns-filter-bar vaadin-select {
  min-width: 148px;
}

.ns-active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ns-filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ns-brand);
  background: var(--ns-brand-soft);
  border: 1px solid var(--ns-border);
  border-radius: 999px;
}

/* --- layout grids ---------------------------------------------------------- */

.ns-kpi-grid {
  display: grid;
  /* Counts that divide six, not auto-fit: auto-fit takes as many as fit, which at a common
     desktop width is five - leaving the sixth card alone on a row of its own. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 860px) {
  .ns-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1680px) {
  .ns-kpi-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.ns-dash-primary {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ns-dash-split {
  display: grid;
  /* 720px, not 400: the connector table carries seven columns and needs about that much to show
     all of them. Below the width for two such tracks the panels stack full width instead, which
     is better than sitting side by side with a column clipped behind a scrollbar. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 720px), 1fr));
  gap: 14px;
  /* Each panel sizes to its own content. The default stretch makes both as tall as the taller
     one, which left a short table sitting above a block of dead space. */
  align-items: start;
}

.ns-dash-thirds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

/* --- KPI card -------------------------------------------------------------- */

.ns-kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: var(--ns-surface-raised);
  border: 1px solid var(--ns-border);
  border-radius: 12px;
  animation: ns-kpi-in 260ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes ns-kpi-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.ns-kpi-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.ns-kpi-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ns-text-tertiary);
}

.ns-kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--ns-surface-sunken);
  color: var(--ns-text-secondary);
  flex: none;
}

.ns-kpi-icon vaadin-icon {
  width: 14px;
  height: 14px;
}

.ns-kpi-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ns-text);
  /* Tabular figures so a counting animation does not make the layout twitch. */
  font-variant-numeric: tabular-nums;
}

.ns-kpi-delta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ns-kpi-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
}

.ns-kpi-chip vaadin-icon {
  width: 11px;
  height: 11px;
}

.ns-kpi-chip.is-good {
  color: var(--ns-success);
  background: var(--ns-success-soft);
}

.ns-kpi-chip.is-bad {
  color: var(--ns-danger);
  background: var(--ns-danger-soft);
}

.ns-kpi-chip.is-neutral {
  color: var(--ns-text-secondary);
  background: var(--ns-surface-sunken);
}

.ns-kpi-footnote {
  margin-top: -2px;
}

.ns-kpi .ns-chart-spark {
  margin-top: 2px;
}

/* --- panel ----------------------------------------------------------------- */

.ns-panel {
  display: flex;
  flex-direction: column;
  background: var(--ns-surface-raised);
  border: 1px solid var(--ns-border);
  border-radius: 12px;
  overflow: hidden;
  min-width: 0;
}

.ns-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ns-border);
}

.ns-panel-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ns-text);
}

.ns-panel-subtitle {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--ns-text-tertiary);
}

.ns-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ns-panel-actions vaadin-select {
  min-width: 150px;
}

.ns-panel-body {
  padding: 14px 16px;
  min-width: 0;
}

/* setAllRowsVisible(true) sizes the grid to its rows; without this the component's own default
   height wins and a two row table reserves space for ten. */
/* A grid told to show all its rows should be exactly as tall as those rows. Vaadin's default
   height is applied as a min-height too, so overriding height alone still padded a two-row table
   out to 340px of empty space. */
.ns-panel-body vaadin-grid {
  height: auto;
  min-height: auto;
  max-height: none;
}

.ns-enter {
  animation: ns-panel-in 220ms ease-out both;
}

@keyframes ns-panel-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.ns-panel-error {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  font-size: 13px;
  color: var(--ns-danger);
  background: var(--ns-danger-soft);
  border-radius: 10px;
}

/* --- legends --------------------------------------------------------------- */

.ns-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ns-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ns-text-secondary);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease, opacity 140ms ease;
}

.ns-legend-item:hover {
  background: var(--ns-surface-sunken);
}

.ns-legend-item:focus-visible {
  outline: 2px solid var(--ns-brand);
  outline-offset: 1px;
}

/* A switched-off series stays legible and keeps its swatch: it is off, not gone. */
.ns-legend-item.is-off {
  opacity: 0.45;
  text-decoration: line-through;
}

.ns-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: none;
}

.ns-slice-legend {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.ns-slice-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 140ms ease;
}

.ns-slice-legend-item:hover {
  background: var(--ns-surface-sunken);
}

.ns-slice-legend-item:focus-visible {
  outline: 2px solid var(--ns-brand);
  outline-offset: 1px;
}

.ns-slice-name {
  font-size: 12.5px;
  color: var(--ns-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.ns-slice-share {
  font-size: 12px;
  font-weight: 700;
  color: var(--ns-text);
}

.ns-donut-holder {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.ns-donut-holder .ns-chart-donut {
  width: 168px;
  flex: none;
}

/* --- trend chart ----------------------------------------------------------- */

.trend-chart {
  position: relative;
  width: 100%;
}

.tc-svg {
  /* Its own aspect, not a forced height: stretching the viewBox to a fixed height squashes
     the axis text horizontally. */
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 1;
  min-height: 200px;
  display: block;
  overflow: visible;
}

.tc-grid {
  stroke: var(--ns-border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.tc-axis {
  fill: var(--ns-text-tertiary);
  font-size: 11px;
  font-family: inherit;
}

.tc-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* Non-scaling so a wide card does not thicken the stroke with it. */
  vector-effect: non-scaling-stroke;
  transition: opacity 200ms;
}

.tc-area {
  transition: opacity 200ms;
}

.tc-line.off,
.tc-area.off,
.tc-dot.off {
  opacity: 0;
  pointer-events: none;
}

.tc-cursor {
  stroke: var(--ns-border-strong);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0;
  vector-effect: non-scaling-stroke;
}

.tc-cursor.on {
  opacity: 1;
}

.tc-dot {
  opacity: 0;
  stroke: var(--ns-surface-raised);
  stroke-width: 2;
  transition: opacity 120ms;
}

.tc-dot.on {
  opacity: 1;
}

.tc-capture {
  fill: transparent;
}

/* The tooltip belongs to the card, not to the viewport: it tracks the cursor horizontally and
   stays inside the panel, so it never covers a neighbouring chart. */
.tc-tip {
  position: absolute;
  top: 4px;
  pointer-events: none;
  z-index: 2;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--ns-border-strong);
  background: var(--ns-surface-raised);
  box-shadow: 0 8px 22px rgba(15, 23, 41, 0.14);
  font-size: 12px;
  white-space: nowrap;
}

.tc-tip-head {
  font-weight: 700;
  margin-bottom: 3px;
  color: var(--ns-text);
}

.tc-tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ns-text-secondary);
}

.tc-tip-row b {
  margin-inline-start: auto;
  padding-inline-start: 16px;
  color: var(--ns-text);
  font-variant-numeric: tabular-nums;
}

.tc-legend,
.dn-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding-top: 8px;
}

.tc-key,
.dn-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  padding: 2px 0;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  color: var(--ns-text-secondary);
  transition: opacity 150ms, color 150ms;
}

.tc-key:focus-visible,
.dn-key:focus-visible {
  outline: 2px solid var(--ns-brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* A switched-off series keeps its swatch and its name: it is off, not gone. */
.tc-key.off {
  opacity: 0.4;
  text-decoration: line-through;
}

.tc-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: 0 0 auto;
}

/* --- donut ----------------------------------------------------------------- */

.donut-chart {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.dn-svg {
  width: 200px;
  max-width: 100%;
  height: 200px;
  flex: 0 0 auto;
  /* Start at twelve o'clock, the way a share is read. */
  transform: rotate(-90deg);
}

.dn-track {
  fill: none;
  stroke: var(--ns-surface-sunken);
  stroke-width: 22;
}

.dn-slice {
  fill: none;
  stroke-width: 22;
  stroke-linecap: butt;
  cursor: pointer;
  transition: stroke-width 180ms, opacity 180ms;
}

.dn-slice.up {
  stroke-width: 28;
}

.dn-slice.dim {
  opacity: 0.32;
}

/* Counter-rotated so the centre figure stays upright inside a rotated svg. */
.dn-value,
.dn-caption {
  transform: rotate(90deg);
  transform-origin: center;
  font-family: inherit;
}

.dn-value {
  fill: var(--ns-text);
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dn-caption {
  fill: var(--ns-text-tertiary);
  font-size: 11px;
}

.dn-legend {
  flex-direction: column;
  flex: 1 1 150px;
  min-width: 0;
  gap: 2px;
  padding-top: 0;
}

.dn-key {
  width: 100%;
  padding: 3px 0;
}

.dn-key.dim {
  opacity: 0.45;
}

.dn-key-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dn-key-value {
  margin-inline-start: auto;
  padding-inline-start: 12px;
  font-weight: 700;
  color: var(--ns-text);
  font-variant-numeric: tabular-nums;
}

/* The donut and the figures it cannot state, side by side. */
.ns-donut-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ns-donut-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ns-border);
}

.ns-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ns-stat-label {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ns-text-tertiary);
}

.ns-stat-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--ns-text);
  font-variant-numeric: tabular-nums;
}

.ns-stat-sub {
  font-size: 11.5px;
  color: var(--ns-text-tertiary);
}

/* --- failure reasons ------------------------------------------------------- */

.ns-reason-list {
  display: flex;
  flex-direction: column;
}

.ns-reason-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--ns-border);
}

.ns-reason-row:last-child {
  border-bottom: 0;
}

.ns-reason-row.is-clickable {
  cursor: pointer;
}

.ns-reason-row.is-clickable:hover {
  background: var(--ns-surface-sunken);
}

.ns-reason-row.is-clickable:focus-visible {
  outline: 2px solid var(--ns-brand);
  outline-offset: -2px;
}

.ns-reason-code {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ns-text);
}

.ns-reason-where {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ns-reason-figures {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.ns-reason-count {
  font-size: 14px;
  font-weight: 700;
  color: var(--ns-text);
  font-variant-numeric: tabular-nums;
}

.ns-reason-share {
  font-size: 12px;
  color: var(--ns-text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* A thin proportional rule, not a chart: enough to rank the list at a glance. */
.ns-reason-meter {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 2px;
  background: var(--ns-surface-sunken);
  overflow: hidden;
}

.ns-reason-meter-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--ns-series-3);
  transform-origin: left center;
  animation: ns-meter 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes ns-meter {
  from {
    transform: scaleX(0);
  }
}

/* --- charts row ------------------------------------------------------------ */

.ns-charts-row {
  display: grid;
  /* The two cards in a row share a bottom edge. Their content is different lengths - a chart
     against a chart plus a table - so the shorter card gains the difference as breathing room
     rather than leaving the row with a ragged edge. */
  align-items: stretch;
  /* min() so the track falls back to the container on a narrow screen: a bare minmax(420px, ..)
     is a hard floor and overflows the page on a phone. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: 14px;
  width: 100%;
}

/* Scoped to the dashboard rows on purpose: the panels elsewhere in the app are laid out on their
   own and must keep their content at the top. */
.ns-charts-row .ns-panel-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  /* A chart cannot stretch to fill: its viewBox has a fixed aspect, and forcing the height would
     letterbox or distort the drawing. Centring it in the spare room is the honest alternative. */
  justify-content: center;
}

/* A chart with a table under it is read top down, so that one stays put. */
.ns-charts-row .ns-panel-body > .ns-donut-body {
  flex: 1 1 auto;
  justify-content: flex-start;
}

/* --- skeletons ------------------------------------------------------------- */

.ns-skeleton-card {
  gap: 10px;
}

.ns-skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 0;
}

.ns-skeleton-line {
  height: 13px;
  border-radius: 6px;
}

.ns-skeleton-line.is-short {
  width: 58%;
}

.ns-skeleton-line.is-value {
  height: 26px;
  width: 72%;
}

/* --- narrower screens ------------------------------------------------------ */

@media (max-width: 1100px) {
  .ns-dash-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .ns-kpi-grid {
    /* Two columns still fit a phone at this size; one would make the reader scroll past six. */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .ns-kpi-value {
    font-size: 22px;
  }
  .ns-filter-bar vaadin-select {
    min-width: 132px;
    flex: 1;
  }
  .donut-chart {
    justify-content: center;
  }
  .dn-svg {
    width: 168px;
    height: 168px;
  }
  .tc-svg {
    /* Taller relative to its width, or a 24-bucket day becomes an unreadable sliver. */
    aspect-ratio: 16 / 10;
  }
}

/* --- connector setup wizard ------------------------------------------------ */

.ns-stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--ns-border);
  border-radius: 12px;
  background: var(--ns-surface-raised);
}

.ns-step {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ns-text-tertiary);
}

.ns-step-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--ns-border-strong);
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
}

.ns-step-label {
  font-size: 13px;
}

/* The current step is the only one in full contrast: a stepper where every step looks equally
   active tells the reader nothing about where they are. */
.ns-step.is-current {
  color: var(--ns-text);
}

.ns-step.is-current .ns-step-marker {
  background: var(--ns-brand);
  border-color: var(--ns-brand);
  color: #fff;
}

.ns-step.is-current .ns-step-label {
  font-weight: 700;
}

.ns-step.is-done {
  color: var(--ns-text-secondary);
}

.ns-step.is-done .ns-step-marker {
  background: var(--ns-surface-sunken);
  border-color: var(--ns-border-strong);
}

/* A step lays its group cards out across the form.

   One column down the middle was the earlier choice, and on a wide display it left more empty
   page than form. What makes flowing them across safe is that it is the connector's own groups
   that move - credentials beside endpoint, each still read top to bottom - rather than the fields
   within a group being dealt out into columns. A sprawl of secrets side by side was the thing
   worth avoiding, and a group card is too narrow for one.

   Capped, because a field stretched across an ultrawide monitor is its own kind of unreadable. */
.ns-setup-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  max-width: 1400px;
}

/* Flex rather than a grid of auto-fit tracks, and for a reason worth recording: the notes and the
   button row span the full width, and an item spanning every track stops auto-fit collapsing the
   empty ones. Three groups then sat in a four column grid with a column of nothing beside them -
   the same wasted space this was meant to remove, only narrower. Flex shares the leftover width
   out among the cards actually on the line. */
.ns-setup-steps > .ns-card,
.ns-setup-group > .ns-card {
  flex: 1 1 330px;
  min-width: 0;
  /* A card alone on a line would otherwise grow to the whole width of the form, which is how a
     step with one group - payment methods, the summary - ends up as a metre-wide box holding
     three checkboxes. */
  max-width: 700px;
}

/* Notes, warnings, the button row and the health line belong to the step rather than to any one
   group of fields, so they read across the whole form. */
.ns-setup-steps > :not(.ns-card),
.ns-setup-group > :not(.ns-card) {
  flex: 1 1 100%;
  min-width: 0;
}

/* Credential cards pack into columns rather than being laid out in rows.

   Rows work while the groups are of much the same size, and stop working as soon as they are not.
   Providers are not alike: MTN declares a product subscription of one field, an API user of two,
   an endpoint of three and callbacks of four, which in a row came out 239, 398, 634 and 707 with
   a 468px hole under the first of them. The arrangement form is worse again, because it adds the
   six-field commercial terms card to that. Packed into columns a short card is followed by the
   next card instead of by the bottom of a row: MTN's arrangement form went from 1469px with three
   holes to 1104px with none.

   Reading order stays down one column and on to the next, which is also the tab order: the DOM
   does not change.

   column-width rather than column-count, so a narrow window gets one column instead of two thin
   ones. */
.ns-setup-columns {
  display: block;
  columns: 440px;
  column-gap: 14px;
}

.ns-setup-columns > .ns-card,
.ns-setup-columns > .ns-setup-group > .ns-card {
  /* A card is one thing. Without this a column boundary falls through the middle of a group and
     leaves half its fields at the top of the next column. */
  break-inside: avoid;
  width: 100%;
  max-width: none;
  margin: 0 0 14px;
}

/* Notes, the documentation link and the button row belong to the form rather than to a column of
   it, so they read across the whole width. */
.ns-setup-columns > :not(.ns-card):not(.ns-setup-group),
.ns-setup-columns > .ns-setup-group > :not(.ns-card) {
  column-span: all;
}

/* The arrangement form asks for a wider column than a setup step does, because of the one card a
   setup step does not have. Commercial terms carries six fields, and at 440 they would sit one to
   a line and make that card 874px on its own - taller than both the columns beside it. At 480 the
   form is two columns of 693, the fields inside pair up, and the card comes back to 521. */
.ns-arrangement-form {
  columns: 480px;
}

/* A holder that groups cards for the code's convenience should not become a column of its own:
   its cards are peers of the ones beside it. Its children are laid out by the two rules above,
   which name the holder as well as the step - display:contents removes the box, not the parent
   relationship a selector sees. */
.ns-setup-group {
  display: contents;
}

/* Fields flow across the card they are in, which in practice means one per row: a group card in
   a three-group step is about 460px, and a credential field wants all of it. It is the step with
   a single card - payment methods, the summary - that has the room for more than one, and there
   the alternative is a row of checkboxes with a metre of empty card beside them. */
.ns-setup-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  align-items: start;
  gap: 18px;
}

.ns-setup-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ns-setup-notes,
.ns-setup-warning {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.5;
}

.ns-setup-notes {
  border: 1px solid var(--ns-border);
  background: var(--ns-surface-sunken);
  color: var(--ns-text-secondary);
}

/* Amber rather than red: nothing here has failed, but something will not work as expected. */
.ns-setup-warning {
  border: 1px solid var(--ns-warning-border, var(--ns-border-strong));
  background: var(--ns-warning-surface, var(--ns-surface-sunken));
  color: var(--ns-text);
}

.ns-setup-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.ns-setup-summary {
  display: flex;
  flex-direction: column;
}

.ns-setup-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--ns-border);
}

.ns-setup-summary-row:last-child {
  border-bottom: 0;
}

.ns-setup-summary-value {
  font-size: 13px;
  color: var(--ns-text);
  overflow-wrap: anywhere;
}

.ns-setup-health {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ns-text-secondary);
  padding-top: 4px;
}

@media (max-width: 640px) {
  .ns-setup-summary-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .ns-stepper {
    gap: 8px 14px;
  }
}

/* ------------------------------------------------ routing map: node dragging -- */

/* Individual nodes are draggable, so they advertise it and the viewport's grab cursor gives way
   to a move cursor over a box. */
.rm-node {
  cursor: grab;
}

.rm-node.rm-node-dragging {
  cursor: grabbing;
}

/* Lifts while held. No transition on the transform: the node has to track the pointer exactly,
   and easing a drag makes it feel like it is being pulled through treacle. */
.rm-node.rm-node-dragging rect {
  filter: drop-shadow(0 3px 8px rgb(0 0 0 / 0.28));
  stroke-width: 1.5;
}

/* Text inside a node would otherwise be selected by the drag instead of moving it. */
.rm-svg text {
  user-select: none;
  -webkit-user-select: none;
}
