/*
 * Design tokens.
 *
 * Every colour in the app resolves through a role token defined here. That is
 * what makes runtime per-tenant theming possible at all — the old dashboards
 * baked hex values into generated HTML at build time, so a second tenant could
 * never have looked different from the first.
 *
 * "License Estate" is the app's visual identity as of 2026-09: a warm ledger
 * palette with a brass accent, flat hairline cards (no radius, no shadow), a
 * serif display face for headline figures and a monospace face for tabular
 * data — first built for the License board (PR #298), then promoted here to
 * be every product's default rather than kept a per-product exception.
 *
 * The categorical series and reserved status colours are untouched: they are
 * the validated reference palette from the dataviz skill — the categorical
 * order clears CVD and normal-vision separation gates in both modes, and the
 * status four are deliberately distinct from the series hues so a status
 * colour never impersonates a series. Nothing about this identity had reason
 * to gamble with either.
 *
 * Dark values are declared under BOTH scopes on purpose: the media query covers
 * the OS setting, the [data-theme] scope covers the in-app toggle, and the
 * :not() guard lets an explicit light choice beat OS dark.
 */

:root {
  color-scheme: light;

  /* Surfaces & ink */
  --surface-page: #f6f2ea;
  --surface-1: #ffffff;
  --surface-2: #efe9db;
  --surface-hover: #e6ddc8;
  --text-primary: #201a12;
  --text-secondary: #56503f;
  /* ITOPS-471: was #837a67, 3.8:1 on --surface-page (3.5:1 on surface-2).
     The app's #6b6250 (ITOPS-436): 5.4:1 on page, 6.0:1 on surface-1,
     5.0:1 on surface-2. */
  --text-muted: #6b6250;
  --border: #ddd3bd;
  --border-strong: #c7bb9e;

  /* Categorical — fixed order, never cycled. */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  /* Status — reserved. Never reused as a series colour, always with icon+label. */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --status-unknown: #898781;
  --success-text: #006300;

  --accent: #9c6b2e;
  --accent-wash: rgba(156, 107, 46, 0.14);

  --radius: 0px;
  --radius-sm: 2px;
  --shadow: none;
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
}

@media (prefers-color-scheme: dark) {
  /* No :where() wrapper: the claude.ai/design token compiler cannot parse it
     and drops these 21 dark values from its registry (reported by the design
     agent on the first synced build). Behavior is identical — an explicit
     light choice is excluded by the :not() either way, and the later
     [data-theme='dark'] block still wins ties for the in-app toggle. */
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --surface-page: #15120c;
    --surface-1: #1d1810;
    --surface-2: #262013;
    --surface-hover: #302818;
    --text-primary: #f2ecdd;
    --text-secondary: #c3b89e;
    --text-muted: #a89c81;
    --border: #362d1c;
    --border-strong: #4a3d24;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;

    --success-text: #0ca30c;
    --accent: #d9a34c;
    --accent-wash: rgba(217, 163, 76, 0.16);
    --shadow: none;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --surface-page: #15120c;
  --surface-1: #1d1810;
  --surface-2: #262013;
  --surface-hover: #302818;
  --text-primary: #f2ecdd;
  --text-secondary: #c3b89e;
  --text-muted: #a89c81;
  --border: #362d1c;
  --border-strong: #4a3d24;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;

  --success-text: #0ca30c;
  --accent: #d9a34c;
  --accent-wash: rgba(217, 163, 76, 0.16);
  --shadow: none;
}

/* --------------------------------------------------------------------- */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--surface-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.32rem 0.6rem;
  transition: background 0.12s ease;
}
button:hover { background: var(--surface-hover); }
button.primary { background: var(--accent); border-color: transparent; color: #fff; }
button.primary:hover { filter: brightness(1.08); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Layout ---------------------------------------------------------------- */

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/*
  height:100vh pins the rail to the viewport, which is what makes the nav stay
  put while the page scrolls. Without overflow-y it also CLIPS: an operator's
  rail carries the seven admin Settings entries plus a Switch-tenant list plus
  an All-tenants list, which passes 100vh on an ordinary laptop, and the items
  past the fold were not merely hidden -- there was nothing to scroll, so the
  wheel did nothing over them. The narrow-screen rule below has had the
  equivalent (overflow-x) since it was written; the column axis never got it.

  overscroll-behavior stops a flick at the end of the rail from scrolling the
  page underneath it, which reads as the nav "jumping".
*/
.rail {
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  gap: 0.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/*
  The brand holds still while the rest scrolls. It is the tenant's own mark and
  the only "which tenant am I in" cue on the page -- scrolling it away is
  exactly wrong on the screen where an operator moves between tenants. Sticky
  rather than a wrapper element, so App.tsx keeps one flat flex column and
  `.spacer` goes on pushing the footer down whenever the rail does fit.

  The background is not decoration: without it the nav items scroll THROUGH the
  brand instead of under it.
*/
.rail > .brand {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-1);
}

.brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.5rem 1rem; }
.brand img { max-height: 32px; max-width: 140px; object-fit: contain; }
.brand-fallback {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 0.9rem;
}
.brand-name { font-weight: 600; font-size: 0.95rem; line-height: 1.1; }
.brand-sub { color: var(--text-muted); font-size: 0.75rem; }

.nav-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.6rem; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.9rem;
}
/*
 * The unread marker on a nav item.
 *
 * margin-left:auto pushes it to the far edge rather than sitting against the
 * label, so a longer label never shunts it off the rail. It carries an
 * aria-label on the element itself — a coloured dot with no text is invisible to
 * a screen reader, and "there is something new" is exactly the kind of thing
 * that must not be conveyed by colour alone.
 */
.nav-dot {
  margin-left: auto; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex: none;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.nav-section { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 1rem 0.6rem 0.35rem; }

.main { padding: 1.75rem 2rem 4rem; max-width: 1400px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--text-primary); padding-bottom: 0.9rem; }
h1 { font-family: var(--font-display); font-weight: 500; font-size: 1.5rem;
  margin: 0 0 0.25rem; letter-spacing: -0.01em; }
.page-sub { color: var(--text-secondary); font-size: 0.9rem; margin: 0; }

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

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1rem; }
/* Vertical rhythm between stacked rows: the same 1rem as the grid's own gap.
   Pages used to hand-pick inline margins (1rem, 1.25rem, none), so adjacent
   grids touched on some screens and floated apart on others. */
.grid:not(:last-child) { margin-bottom: 1rem; }

/* EVERY span a card can ask for has to exist here. A class with no rule is not
   a no-op: the 12-column grid gives the unspanned child ONE column, so the card
   renders at ~1/12 of the row and its contents overflow — the same failure the
   integration tiles hit further down this file. `w-5`, `w-7` and `w-8` were in
   use and undefined, which is why the CMDB device editor (w-7) and its history
   panel (w-5) rendered at 277px and 245px on a 1920px screen with their form
   fields spilling out of the card, and why both Support cards (w-8) were 277px
   walls of text beside 1200px of empty page. tests/web-grid.test.mjs now fails
   if a span is used without a rule, because nothing about the symptom points
   at a missing CSS class. */
.w-3 { grid-column: span 3; }
.w-4 { grid-column: span 4; }
.w-5 { grid-column: span 5; }
.w-6 { grid-column: span 6; }
.w-7 { grid-column: span 7; }
.w-8 { grid-column: span 8; }
.w-12 { grid-column: span 12; }

@media (max-width: 1100px) {
  .w-3 { grid-column: span 6; }
  .w-4 { grid-column: span 6; }
  /* A 5-column card is ~430px here, which is where the history panel's change
     entries start wrapping every line. Give the pair the full row instead. */
  .w-5 { grid-column: span 12; }
  .w-7 { grid-column: span 12; }
  /* BUG-132: .w-6 was the one span left at half-width through this whole
     band, while input/select carry a 240px min-width floor — at ~253px of
     content box that is narrower than a single floored control. Promoting it
     the same way as w-3/w-4/w-5/w-7 closes the class rather than patching the
     one card (License administration's Contract rates/Seat caps/Seat
     rosters) that happened to be measured first. */
  .w-6 { grid-column: span 12; }
}

/*
  BUG-153 scroll-shadow layers, shared so .rail and the overflow-x tables
  do not triplicate the four-layer local/scroll trick. Cover pair
  (attachment local) + fade pair (attachment scroll); colours --surface-1
  and --text-muted. Rail consumes them only inside max-width 720px (its
  overflow is a layout change at that breakpoint). Tables consume them
  always-on — they overflow at desktop too when many columns exist.
*/
:root {
  --scroll-shadow-image:
    linear-gradient(to right, var(--surface-1) 55%, transparent),
    linear-gradient(to left, var(--surface-1) 55%, transparent),
    linear-gradient(to right, var(--text-muted), transparent),
    linear-gradient(to left, var(--text-muted), transparent);
  --scroll-shadow-position: left, right, left, right;
  --scroll-shadow-size: 34px 100%, 34px 100%, 34px 100%, 34px 100%;
  --scroll-shadow-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
  --scroll-shadow-attachment: local, local, scroll, scroll;
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  /* Laid out as a row here, so the column-axis scroll would only produce a
     stray scrollbar; and the brand must not stick sideways. */
  .rail { position: static; height: auto; flex-direction: row; overflow-x: auto; overflow-y: visible; }
  /*
    overflow-x:auto above makes the rail scroll but gives no sign that it
    does. Every rail with more items than fit -- any operator's, or any
    tenant's past ~6 products/settings entries -- read as a nav that simply
    stopped rather than one that continues (BUG-153), because the native
    scrollbar is exactly what a touch browser hides at rest.

    Classic scroll-shadow trick, CSS-only: four background layers in two
    pairs. The "cover" pair (background-attachment: local) is pinned to the
    CONTENT, so background-position:left/right places it at the content's own
    edges -- off past the visible box on whichever side still has more to
    scroll to, and exactly flush with the visible edge once there is none.
    The "fade" pair (background-attachment: scroll, the default) is pinned to
    the VIEWPORT instead, always painted at the box's visible left/right edge.
    Layer order matters: the cover pair is listed first (topmost), so it can
    occlude the fade pair beneath it. Net effect: a fade shows only on the
    edge that still has more to reveal, self-correcting at both scroll
    extremes with no scroll listener and no React state.
  */
  .rail {
    background-image: var(--scroll-shadow-image);
    background-position: var(--scroll-shadow-position);
    background-size: var(--scroll-shadow-size);
    background-repeat: var(--scroll-shadow-repeat);
    background-attachment: var(--scroll-shadow-attachment);
  }
  .rail > .brand { position: static; }
  .grid > * { grid-column: span 12 !important; }
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
/* Both of these wrap, and the pair is the whole fix (BUG-143, BUG-144).
   .card-head is icon + title + spacer + `actions`, and `actions` is a toolbar
   — a select, a filter input, a CSV button. Left at the initial nowrap, the
   only thing an over-long line could do was render past the card's right
   edge: nothing in the chain (.card, .card-head, .row) declares overflow-x —
   that treatment exists only for `.card > table` below — so the excess bled
   through .card, through main, and out of the document.
   The nested row matters independently: CMDB's outer toolbar row ALREADY set
   flexWrap and still overflowed, because a child that wraps onto its own line
   but is itself nowrap just overflows the line it wrapped onto. That is the
   observation that makes this a class fix and not three flexWrap props.
   Deliberately viewport-independent rather than a mobile breakpoint: the same
   squeeze produced BUG-132 in the 721-918px band, which a max-width rule
   aimed at phones would have walked straight past. Wrapping changes nothing
   about a line that already fits, which is what makes it safe for every other
   card in the app. */
.card-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem;
  flex-wrap: wrap; }
.card-title { font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; margin: 0; }

/* Stat tile: a headline number is not a chart. */
.stat-value { font-family: var(--font-display); font-weight: 500; font-size: 2rem;
  letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { color: var(--text-secondary); font-size: 0.8rem; margin-top: 0.15rem; }
.stat-delta { font-size: 0.78rem; display: inline-flex; align-items: center; gap: 0.2rem;
  margin-top: 0.5rem; color: var(--text-muted); }
.stat-delta.up { color: var(--success-text); }
.stat-delta.down { color: var(--status-critical); }

/* Status pill — colour NEVER alone; always icon + label. white-space:nowrap
   because a table's auto layout (table{width:100%}) squeezes a narrow
   column's cell to a share of the row that can be less than the pill's
   natural width — without this the pill's own border-radius:999px box
   shrank to fit, so a two-word label like "Not enrolled in Intune" wrapped
   into a lumpy two-line capsule instead of the column simply widening
   (the table already scrolls horizontally; that's the intended overflow
   path, not mid-pill text wrap). */
.pill { display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.5rem; white-space: nowrap;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

/*
 * A wide table scrolls INSIDE its card; it never widens the page.
 *
 * Without this, a table wider than the viewport pushed the whole document
 * sideways. That is not merely untidy: the row-action buttons live in the last
 * column — Enable/Connect on Integrations, the reclaim count on the License
 * board — so they ended up parked off-canvas in a place people do not think to
 * scroll, and the controls simply could not be reached on a narrow window.
 *
 * Applied at the CSS layer rather than by hand-wrapping each <table> in a
 * scroll div: there are two dozen of them across the products, only a third
 * were wrapped, and the next table anyone adds would have started out broken
 * again. `display: block` is what makes overflow apply to a table element;
 * column alignment is unaffected because the cells still lay out as a table
 * inside it (verified against header/body cell offsets, not assumed).
 *
 * Scoped to a DIRECT child of .card so a table already inside its own wrapper
 * does not get a second scrollbar, and so no absolutely-positioned popover in
 * a card (the CMDB column picker) is turned into a clipped scroll container —
 * which is exactly what putting the overflow on .card itself would have done.
 *
 * The overflow + BUG-153 sibling scroll-shadow rule is shared with
 * `.tenant-drawer > div > table` further down, so both surfaces keep one
 * declaration rather than two copies of overflow-x:auto.
 */

/*
 * The operator's tenant drawer is rendered INSIDE the tenants table, as a
 * <td colSpan> under the row it belongs to (OperatorConsole.tsx). So it is
 * never a child of .card, the rule above never reaches it, and the only
 * reason its Members and Tokens tables scrolled at all was an accident: the
 * outer tenants table is the scroll container, so reading the Role column
 * meant dragging the whole tenant list sideways, with the scrollbar parked
 * at the bottom of a table the reader was not looking at.
 *
 * The width line is the load-bearing one, and it is not decoration. A cell
 * in a table is as wide as the table, not as wide as what you can see: at a
 * 432px viewport the drawer measured 920px inside a 274px visible box, so
 * `overflow-x` on its tables did nothing whatsoever — they were never
 * narrower than their content. `100cqw` resolves against the scroll
 * container, which is what "what you can see" actually means here. Measured
 * before/after: Members 647px of content in a 647px box (no scrollbar, the
 * page scrolls) -> 647px in a 274px box (scrolls itself).
 *
 * `position: sticky` was tried first, on the drawer and on the cell, and
 * does neither job — it was measured sliding to -340px at scrollLeft 400.
 *
 * :has() keeps the containment on the ONE table that holds a drawer.
 * container-type establishes a containing block for absolutely-positioned
 * descendants, and applying it to every `.card > table` would put that in
 * front of popovers it has nothing to do with.
 *
 * Depth-2 on purpose. The Audit tab's table already sits in its own
 * overflow-x wrapper, one level deeper; matching every descendant would give
 * it a second scrollbar inside the first — the same mistake the rule above
 * avoids by staying a direct-child selector.
 */
.card > table:has(.row-panel) { container-type: inline-size; }
/* BUG-135. A <td>'s content box sits at the TABLE's inline coordinates, not
   the viewport's. Reaching the button that opens one of these panels means
   scrolling the table right — the opener is in the last column by design — and
   the panel then mounts at inline position 0 of that scrolled table, i.e. at
   viewport x = -scrollLeft. Measured on /operator/tenants at 375x812 with the
   table scrolled to 578: the drawer rendered at left -517.8, right -244.
   Entirely off-screen, every tab of it.
   Both declarations, and only together. `100cqw` (from a785072) makes the
   panel as wide as what you can SEE rather than as wide as the table; THAT
   narrowness is what gives `sticky` room to move. Sticky was tried here once
   and rejected as "sliding to -340px" — but that was before the width fix, so
   the box was as wide as its containing block and had zero slack to shift
   into. `left: 0` then pins it to the scrollport instead of to the table's
   inline origin. */
.row-panel { width: 100cqw; position: sticky; left: 0; }
/* Same fix where the panel has no wrapper element of its own to carry the
   class — the CELL takes it. A <td> cannot take `width: 100cqw` (its width is
   decided by table layout), so its content is clamped instead: the cell still
   spans the row, but what is inside it cannot be pushed past what is visible. */
/* Sticky on the CELL does not work and was measured, not assumed: a <td>
   spanning the row has no slack inside its containing block to shift into, so
   it stays at the table's inline origin (measured left -148.4 at scrollLeft
   199). The panel has to be a narrower box INSIDE the cell — which is what
   100cqw makes it — so the rule goes on the cell's children. */
td.row-panel > * { display: block; width: 100cqw; position: sticky; left: 0; }
.tenant-drawer { padding: 0.3rem 0 0.6rem; }
/*
 * BUG-153 sibling. Always-on (not the rail's 720px media query): these
 * tables overflow at desktop too when many columns exist. Shared
 * --scroll-shadow-* custom properties, same local/scroll attachment as
 * .rail. DataTable's maxHeight scroller is a wrapper div, not these
 * selectors, so sticky thead / vertical overflow are untouched.
 * background-image is on the scrolling table itself; it does not replace
 * .card's background (covers use --surface-1, so a non-overflowing table
 * looks unchanged). Sticky td.row-panel paints above the fade layers.
 */
.card > table,
.tenant-drawer > div > table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  background-image: var(--scroll-shadow-image);
  background-position: var(--scroll-shadow-position);
  background-size: var(--scroll-shadow-size);
  background-repeat: var(--scroll-shadow-repeat);
  background-attachment: var(--scroll-shadow-attachment);
}
th { text-align: left; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600;
  padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border);
  position: relative; }

/*
 * Client-adjustable column widths (DataTable, AuditTable). A drag handle
 * pinned to the header cell's right edge — width, not position, is set by
 * JS (useResizableColumns), this only supplies the grab target and its
 * hover/active affordance. Widened past its 1px visual line with a
 * transparent margin either side, the same "thin target gets a fatter
 * invisible hit area" fix the donut's slice arcs use.
 */
.col-resize-handle {
  position: absolute; top: 0; right: -4px; bottom: 0; width: 9px;
  cursor: col-resize; touch-action: none; z-index: 1;
}
.col-resize-handle::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 1px;
  background: var(--border-strong);
}
.col-resize-handle:hover::after, .col-resize-handle.active::after {
  background: var(--accent); width: 2px; left: 3.5px;
}
td { padding: 0.6rem; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
td.strong { color: var(--text-primary); font-family: var(--font-display); font-size: 1rem; font-weight: 500; }
tbody tr:hover { background: var(--surface-2); }
.tabular { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
/* Money and counts line up on the right edge. Paired with .tabular this is
   what makes a column of figures comparable at a glance -- tabular-nums
   alone only equalises digit WIDTH, so a left-aligned column still ragged
   at the decimal point. Both halves have to be present to be worth it. */
th.right, td.right { text-align: right; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--text-secondary); }
.empty svg { color: var(--text-muted); margin-bottom: 0.75rem; }

.banner { display: flex; gap: 0.6rem; padding: 0.75rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2); font-size: 0.875rem;
  color: var(--text-secondary); margin-bottom: 1.25rem; align-items: flex-start; }
.banner.warn { border-color: var(--status-warning); }
.banner.serious { border-color: var(--status-serious); }
.banner.critical { border-color: var(--status-critical); }
/* Only the border is tinted. A filled status background would make the body
   text sit on a hue whose contrast changes between light and dark, and the
   icon + heading already carry the state. */

/* Wraps. Four entries in this log — BUG-141, BUG-143, BUG-144, BUG-147 — are
   the same missing declaration: a .row left at the initial nowrap, holding
   children with hard-pinned minWidth, and no overflow-x anywhere above it
   (that treatment exists only for `.card > table`). The excess has nowhere to
   go, so it renders past the card's right edge and the document itself scrolls
   sideways.
   Scoped to `.card-head .row` first, which closed three board toolbars and
   left the fourth — NotificationPanels' alert rows live in the card BODY. The
   rule belongs on .row itself: wrapping does nothing to a line that already
   fits, so the only lines it changes are the ones that are currently broken.
   Verified as safe rather than argued: `layout-probe.mjs sweep --routes all`
   exits 0 across 28 routes at 1440x900, 900x700 AND 375x812 with this rule in
   place, where 375x812 had four findings without it. */
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.spacer { flex: 1; }

/*
  Source badges on a device row (the legacy board's _source_dots). Absent
  sources keep their place at low opacity rather than disappearing: what the
  reader is scanning for is the GAP, and a row that simply drops the marks it
  lacks makes every row a different shape and the gap invisible.
*/
.src-badges { display: inline-flex; gap: 0.25rem; align-items: center; }
.src-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--series-1);
}
/* Not display:none and not visibility:hidden — it has to hold its column. */
.src-badge.absent { opacity: 0.22; color: var(--text-muted); }
@media (prefers-reduced-motion: no-preference) {
  .src-badge { transition: opacity 120ms ease; }
}
input[type='text'], input[type='url'], select {
  font: inherit; padding: 0.45rem 0.6rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-1);
  color: var(--text-primary); min-width: 240px;
}

/* Forms ----------------------------------------------------------------- */
/* Added in Phase 5: the onboarding wizard is the first screen that asks for
   more than a single value, so the field wrapper and the multi-line/secret
   inputs earn their place here rather than being styled inline per form. */

input[type='password'], textarea {
  font: inherit; padding: 0.45rem 0.6rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-1);
  color: var(--text-primary); min-width: 240px; width: 100%;
}
textarea {
  min-height: 5.5rem; resize: vertical;
  font-family: var(--font-mono), ui-monospace, monospace; font-size: 0.8rem;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:disabled:hover { background: var(--surface-1); filter: none; }

.field { display: block; margin-bottom: 0.85rem; }
.field > input, .field > textarea { box-sizing: border-box; width: 100%; }
.field-label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.25rem; }
.field-label .opt { font-weight: 400; color: var(--text-muted); }
.field-help { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.25rem; }

/* Wizard ---------------------------------------------------------------- */

.steps { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.25rem; }
.step {
  display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.82rem;
  padding: 0.35rem 0.7rem; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-secondary); background: var(--surface-1);
}
.step.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.step.done { color: var(--status-good); border-color: var(--status-good); }
.mono {
  font-family: var(--font-mono), ui-monospace, monospace; font-size: 0.8rem;
  background: var(--surface-2); padding: 0.15rem 0.35rem; border-radius: var(--radius-sm);
  word-break: break-all;
}
pre.mono { display: block; padding: 0.6rem 0.75rem; white-space: pre-wrap; margin: 0.5rem 0 0; }

/* Integration tiles ------------------------------------------------------ */
/* Its own auto-fill grid, deliberately not `.grid`: the 12-column grid gives
   an unspanned child one column, which is how the old selection list ended up
   ~90px wide. auto-fill/minmax fits any viewport with no span bookkeeping,
   and the 720px `.grid > *` override never touches it. */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.75rem;
}
.tile {
  display: flex; align-items: center; gap: 0.6rem; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-1); padding: 0.7rem 0.85rem;
  cursor: pointer; text-align: left; font-size: 0.88rem;
  transition: border-color 0.12s, background 0.12s;
}
.tile:hover { border-color: var(--border-strong); }
.tile.selected { border-color: var(--accent); background: var(--accent-wash); }
.tile-name {
  font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* The expanded credential panel: spans the full grid row beneath its tile. */
.tile-detail {
  grid-column: 1 / -1;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-1); padding: 0.9rem 1rem;
}

/* Donut chart (components/charts.tsx). Every color resolves through role
   tokens, so both dark scopes are covered by the token blocks above — no
   dark duplication needed here. The legend is a required part of the form:
   light-mode series hues sit below 3:1 on --surface-1 and the visible
   name+value rows are the documented relief. */
.donut-wrap {
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
}
/* DonutChart layout="column": a card too narrow to give the legend anything
   beside a fixed-size figure without truncating names. The figure centers
   above a legend that gets the card's full content width instead of
   card_width minus the figure. */
.donut-wrap-column {
  flex-direction: column; align-items: stretch;
}
.donut-wrap-column .donut-figure { align-self: center; }
.donut-figure { position: relative; flex: none; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  pointer-events: none;
}
.donut-center-value { font-size: 1.05rem; font-weight: 600; color: var(--text-primary); }
.donut-center-label { font-size: 0.72rem; color: var(--text-muted); }
.donut-legend {
  display: flex; flex-direction: column; gap: 0.35rem;
  font-size: 0.82rem; min-width: 0; flex: 1;
}
.donut-legend-row {
  display: flex; align-items: center; gap: 0.5rem; min-width: 0;
}
.donut-swatch {
  width: 10px; height: 10px; border-radius: 3px; flex: none;
}
.donut-legend-name {
  color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; min-width: 0;
}
.donut-legend-value {
  color: var(--text-primary); margin-left: auto; font-variant-numeric: tabular-nums;
}
/* A donut that navigates somewhere. Same layout as .donut-wrap (both classes
   are applied together); this only adds the affordance. Colors are role
   tokens, so both dark scopes are already covered. */
.donut-link {
  display: flex; cursor: pointer; text-decoration: none; color: inherit;
  border-radius: var(--radius-sm); padding: 0.35rem; margin: -0.35rem;
}
.donut-link:hover { background: var(--surface-2); }
.donut-link:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

/* VendorLogo (components/VendorLogo.tsx): a few Simple Icons brand marks
   (apple, github, jetbrains) are near-black with no dark-mode variant of
   their own, and disappear against --surface-1 in dark mode. Inverting them
   turns #000000 into white; left alone in light mode, where black already
   has plenty of contrast. Declared in both dark scopes on purpose, same
   rule as every other colour in this file — the media query covers the OS
   setting, the [data-theme] block covers the in-app toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .vendor-logo-invert-dark { filter: invert(1) hue-rotate(180deg); }
}
:root[data-theme='dark'] .vendor-logo-invert-dark { filter: invert(1) hue-rotate(180deg); }

/*
 * Seat/capacity dial (License's UtilBar, apps/web/src/products/license/
 * LicenseBoard.tsx) — a conic-gradient gauge reading a fixed allotment, not
 * a horizontal fill bar. `--pct` and `--dial-color` are set inline per row.
 */
.util-dial-cell { display: flex; align-items: center; gap: 0.55rem; }
.util-dial {
  --pct: 0;
  --dial-color: var(--status-good);
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--dial-color) calc(var(--pct) * 1%), var(--border) 0);
  position: relative;
}
.util-dial::after {
  content: '';
  position: absolute; inset: 4px;
  border-radius: 50%;
  background: var(--surface-1);
}
.util-dial-pct { font-family: var(--font-mono); font-size: 0.78rem; min-width: 34px; text-align: right; }

/*
 * Coverage fingerprint (Asset board) — a fixed 5-cell glyph reading which of
 * the tenant's systems saw a device, replacing a plain icon-badge row
 * (the legacy .src-badge treatment) with a deliberate present/absent shape.
 * Presence is a fill, never a hue: colouring segments by --series-N (the
 * donuts on the same page already use those 8 hues for an unrelated
 * grouping) would let a coincidental colour match misread as a real
 * connection, so every segment shares one colour — --accent, the same
 * "this is a deliberate mark" treatment the nav's own active item uses.
 */
.coverage-fingerprint { display: inline-flex; gap: 0.15rem; align-items: center; }
.coverage-fingerprint-seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent-wash);
  color: var(--accent);
}
/* Not display:none and not visibility:hidden — same reason as .src-badge:
   the gap has to hold its place, or the pattern isn't legible as a shape. */
.coverage-fingerprint-seg.absent { border-color: var(--border); background: none; color: var(--text-muted); opacity: 0.5; }
.coverage-fingerprint-seg[role='button'] { cursor: pointer; }
@media (prefers-reduced-motion: no-preference) {
  .coverage-fingerprint-seg { transition: opacity 120ms ease, background 120ms ease, border-color 120ms ease; }
}

/* Coverage-pattern cohort rows (Asset board) — a clickable list, same hover
   fill as any other row (tbody tr:hover) and the global :focus-visible ring,
   so nothing new was invented for this to feel like everything around it. */
.coverage-patterns { display: flex; flex-direction: column; }
/* wrap, not nowrap: a narrow viewport can't fit the glyph, count and
   description on one line, and without wrap the count/description shrink
   instead of the row growing taller — each squeezed into a column narrower
   than its own text, so "104 devices" broke onto two lines mid-phrase
   (measured: a 55px-wide description box on a 375px viewport). Wrapping the
   whole row lets the description drop to its own full-width line instead. */
.coverage-pattern-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; padding: 0.5rem 0.3rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.coverage-pattern-row:last-child { border-bottom: none; }
.coverage-pattern-row:hover { background: var(--surface-2); }
.coverage-pattern-desc { font-size: 0.85rem; color: var(--text-secondary); }

/*
 * Lifecycle stage flow (LifecycleBoard) — a sequence of occupancy buckets,
 * not a conversion funnel: see StageFlow's own doc comment for why. wrap,
 * not nowrap, from Phase 1's own lesson (coverage-pattern rows squeezed at
 * a narrow viewport before that existed) — a node stays paired with its own
 * arrow (both live in one flex-row wrapper) even when it wraps to a new line.
 */
.stage-flow { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.stage-flow-node {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 150px;
  flex: 1 1 150px;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.stage-flow-node[role='button'] { cursor: pointer; }
.stage-flow-node[role='button']:hover { background: var(--surface-hover); }
.stage-flow-arrow { color: var(--text-muted); flex: none; }
.stage-flow-exit {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  min-width: 110px;
  flex: 0 1 110px;
  padding: 0.7rem 0.8rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.stage-flow-exit[role='button'] { cursor: pointer; }
.stage-flow-exit[role='button']:hover { background: var(--surface-hover); }

/* ── Insights feed (FR-027 P2) ─────────────────────────────────────────────
   A list, not a table: each row is a short argument (what, why, do this) and
   a table would force the argument into one cell. State is carried by the
   row class AND by the pill/meta text, never by colour alone. */
.insight-list { list-style: none; margin: 0; padding: 0; }
.insight-row { padding: 0.8rem 0; border-top: 1px solid var(--border); }
.insight-row:first-child { border-top: 0; padding-top: 0.2rem; }
.insight-row.resolved, .insight-row.dismissed { opacity: 0.6; }
.insight-row.open { opacity: 1; }
.insight-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.insight-title { font-weight: 600; color: var(--text-primary); }
.insight-amount { margin-left: auto; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.insight-why { margin: 0.3rem 0 0; color: var(--text-secondary); font-size: 0.9rem; }
.insight-action { margin: 0.2rem 0 0; font-size: 0.9rem; }
.insight-error { margin: 0.3rem 0 0; font-size: 0.78rem; color: var(--status-critical); word-break: break-word; }
.insight-meta {
  display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
  margin-top: 0.45rem; font-size: 0.78rem; color: var(--text-muted);
}
.insight-open { display: inline-flex; align-items: center; gap: 0.25rem; }

/* A proposal card inside an Ask answer (FR-027 P4): visibly separate from the
   prose so a suggestion never reads as part of the answer's claims. */
.proposal {
  margin-top: 0.7rem; padding: 0.6rem 0.8rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1);
}

/* Sign-in page — ledger welcome (not the signed-in shell)
   Hotter brass / terracotta wash — scoped so boards stay quieter. */
.signin {
  --signin-accent: #c47a2a;
  --signin-accent-deep: #a35f18;
  --signin-wash: rgba(196, 122, 42, 0.22);
  --signin-wash-2: rgba(232, 107, 52, 0.12);

  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
  background:
    radial-gradient(900px 520px at 8% -5%, var(--signin-wash), transparent 58%),
    radial-gradient(700px 480px at 92% 12%, var(--signin-wash-2), transparent 55%),
    linear-gradient(165deg, #faf6ee 0%, #f3ebe0 45%, #efe4d4 100%);
}

.signin-top {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.25rem 0;
}
.signin-theme {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.signin-theme:hover {
  background: var(--surface-hover);
  color: var(--signin-accent);
}

.signin-stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 420px);
  gap: 2.5rem;
  align-items: center;
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

.signin-aside { max-width: 28rem; }
.signin-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--signin-accent) 0%, var(--signin-accent-deep) 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 1.1rem;
  box-shadow: 0 6px 16px rgba(196, 122, 42, 0.28);
}
.signin-display {
  font-family: var(--font-display);
  font-weight: 550;
  font-size: clamp(1.85rem, 2.6vw, 2.35rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  color: var(--text-primary);
}
.signin-lede {
  margin: 0 0 1.25rem;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.45;
}
.signin-points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.55rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.signin-points li {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
}
.signin-points li::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  margin-top: 0.38rem;
  border-radius: 50%;
  background: var(--signin-accent);
  box-shadow: 0 0 0 3px var(--signin-wash);
  flex: none;
}

.signin-panel {
  padding: 1.35rem 1.35rem 1.5rem;
  border-radius: 6px;
  border-color: color-mix(in srgb, var(--signin-accent) 22%, var(--border));
  box-shadow:
    0 1px 0 rgba(32, 26, 18, 0.04),
    0 12px 32px rgba(164, 95, 24, 0.08);
}
.signin-panel-head { margin-bottom: 1.1rem; }
.signin-panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.signin-panel-sub {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.4;
}

.signin-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.signin-actions { display: grid; gap: 0.65rem; }
.signin-primary {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.55rem;
  font-weight: 600;
  background: linear-gradient(180deg, var(--signin-accent) 0%, var(--signin-accent-deep) 100%) !important;
  border-color: transparent !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(196, 122, 42, 0.35);
}
.signin-primary:hover { filter: brightness(1.06); }
.signin-primary:disabled,
.signin-secondary:disabled { opacity: 0.65; cursor: wait; }
.signin-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}
.signin-alt {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.35rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.signin-alt-label {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.1rem;
}
.signin-secondary {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.4rem;
  border-color: color-mix(in srgb, var(--signin-accent) 28%, var(--border));
}
.signin-secondary:hover {
  background: var(--signin-wash);
  color: var(--text-primary);
  border-color: var(--signin-accent);
}

.signin-dev { display: grid; gap: 0.75rem; }
.signin-dev .field { margin: 0; }
.signin-dev .banner { margin: 0; }

@keyframes signin-spin {
  to { transform: rotate(360deg); }
}
.signin-spin { animation: signin-spin 0.85s linear infinite; }

@media (max-width: 820px) {
  .signin-stage {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: stretch;
    padding-top: 0.5rem;
  }
  .signin-aside { max-width: none; }
  .signin-points { display: none; }
  .signin-lede { margin-bottom: 0; }
}

:root[data-theme='dark'] .signin {
  --signin-accent: #e8a84a;
  --signin-accent-deep: #d4892e;
  --signin-wash: rgba(232, 168, 74, 0.2);
  --signin-wash-2: rgba(235, 104, 52, 0.12);
  background:
    radial-gradient(900px 520px at 8% -5%, var(--signin-wash), transparent 58%),
    radial-gradient(700px 480px at 92% 12%, var(--signin-wash-2), transparent 55%),
    linear-gradient(165deg, #1c1610 0%, #15120c 50%, #19140f 100%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .signin {
    --signin-accent: #e8a84a;
    --signin-accent-deep: #d4892e;
    --signin-wash: rgba(232, 168, 74, 0.2);
    --signin-wash-2: rgba(235, 104, 52, 0.12);
    background:
      radial-gradient(900px 520px at 8% -5%, var(--signin-wash), transparent 58%),
      radial-gradient(700px 480px at 92% 12%, var(--signin-wash-2), transparent 55%),
      linear-gradient(165deg, #1c1610 0%, #15120c 50%, #19140f 100%);
  }
}
