/* AuthMantra UI, theme. Loaded last, so it has the final word on colour, type and the shape of every common component.
   Direction: rich, with contrast. A tinted canvas, crisp white cards with real edges, coloured stat tiles, a tab bar that reads as one control,
   deep teal-to-blue for the main action. Light mode only for colour; dark mode keeps its own palette from ui.css. */

/* Visually hidden text, everywhere (older pages use .sr-only, newer ones .ui-sr). */
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── One typeface and one scale for old and new pages ───────────────────────────────────────────── */
.ui-body .ui-content, .ui-body .ui-content :is(h1, h2, h3, h4, p, label, input, select, textarea, button, td, th, li, legend, summary) { font-family: var(--ui-font); }
.ui-content h2:not(.ui-card__title):not(.ui-page-title) { font-size: 1.15rem; font-weight: 590; letter-spacing: -0.01em; }
.ui-content h3 { font-size: 1.02rem; font-weight: 590; letter-spacing: -0.01em; color: var(--ui-text); }
.ui-content p.small, .ui-content .small { font-size: 0.86rem; }
.ui-content .muted, .ui-content .ui-muted { color: var(--ui-text-2); }

:root:not([data-theme="dark"]) {
  --ui-bg: #F7F8FA;  /* calm, near-neutral canvas: white cards carry the contrast, not the background */
  --ui-border: #E3E7EC;
  --ui-border-strong: #CBD2DC;
  --ui-text: #0F1A2B;
  --ui-text-2: #4A5568;
  --ui-text-3: #55657A;  /* 5.6:1 on white, 5.1:1 on the light panels */
  --ui-accent-soft: #E3F7F6;
  --th-canvas: #F7F8FA;
  --th-primary: #0F7A78;
  --th-primary-hover: #0C6664;
  --th-card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);  /* a thin edge does the work; the shadow just lifts it off the page a hair */
  --th-card-shadow-hover: 0 2px 8px -2px rgba(15, 23, 42, 0.10), 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* ── Canvas: a visible tint, fixed behind the content, never washed out ─────────────────────────── */
:root:not([data-theme="dark"]) .ui-body { background: var(--th-canvas); background-attachment: fixed; }
:root:not([data-theme="dark"]) .ui-main { background: none !important; animation: none !important; }

/* ── Page header ────────────────────────────────────────────────────────────────────────────────── */
.ui-page-title, .ui-content > .ui-page-header h1, .page-head h2, .ui-content > div > h2:first-child { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.025em; color: var(--ui-text); }
.ui-page-desc { font-size: 0.98rem; color: var(--ui-text-2); max-width: 78ch; }
.ui-page-header { margin-bottom: 22px; }

/* ── Cards: white, a real edge, a soft shadow, one padding ──────────────────────────────────────── */
:root:not([data-theme="dark"]) :is(.ui-card, .card, .panel, .conn-card, .apps-card) { background: #FFFFFF; border: 1px solid var(--ui-border); box-shadow: var(--th-card-shadow); }
:is(.ui-card, .card) { border-radius: 12px; }
.card:not(.ui-card) { padding: 22px 24px; }
.card.inset { box-shadow: none; }
:root:not([data-theme="dark"]) .card.inset { background: linear-gradient(160deg, #F7FBFD 0%, #EEF5FA 100%); }
.ui-card__head { padding: 20px 24px 0; }
.ui-card__title { font-size: 1.06rem; font-weight: 590; letter-spacing: -0.01em; }
.ui-card__desc { font-size: 0.88rem; color: var(--ui-text-2); }
/* The accent line on a card you can act on: one static gradient, a little thicker, never half-drawn. */
.ui-card:has(form)::before { height: 4px !important; background: linear-gradient(90deg, #0ABFBC 0%, #1F8FBF 50%, #3F5FD0 100%) !important; background-size: 100% 100% !important; animation: none !important; opacity: 1 !important; }
.ui-card:has(table)::before, .ui-card--flush::before { opacity: 1 !important; }

/* Section rows (title on the left, a control on the right) line up on one baseline. */
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 14px; min-height: 40px; }
.section-row > h3 { margin: 0; }
.section-row form, .section-row .inline-form { margin: 0; display: flex; gap: 8px; align-items: center; }
.section-row select { width: auto !important; min-width: 220px; max-width: 320px; }
.section-row label:not(.sr-only):not(.ui-sr) { margin: 0 !important; }

/* ── Stat tiles: colour, by position, so a row of numbers reads at a glance ─────────────────────── */
:root:not([data-theme="dark"]) {
  --th-t1: #0A9C99; --th-t1-soft: #DDF5F3;
  --th-t2: #2F64C8; --th-t2-soft: #E2EAFA;
  --th-t3: #7A55D3; --th-t3-soft: #ECE6FA;
  --th-t4: #D0841A; --th-t4-soft: #FCF0DC;
  --th-t5: #D24A6E; --th-t5-soft: #FBE4EA;
}
.ui-stat { border-radius: 12px; padding: 18px 20px; border: 1px solid var(--ui-border); }
.ui-stat__value { font-size: 2.1rem; font-weight: 700; color: var(--ui-text); }
.ui-stat__label, .ui-stat__top { color: var(--ui-text-2); font-weight: 590; }
.ui-stat__icon, .ui-body .ui-stat__icon { width: 38px !important; height: 38px !important; border-radius: 11px !important; color: #fff !important; box-shadow: 0 6px 14px -6px rgba(16, 24, 40, 0.35); }
:root:not([data-theme="dark"]) :is(.ui-pam-hero, .ui-grid-stats, .ui-stats, .ui-grid-4, .ui-grid-3, .ui-grid-5) > .ui-stat { --c: var(--th-t1); --s: var(--th-t1-soft); }
:root:not([data-theme="dark"]) :is(.ui-pam-hero, .ui-grid-stats, .ui-stats, .ui-grid-4, .ui-grid-3, .ui-grid-5) > .ui-stat:nth-child(5n+2) { --c: var(--th-t2); --s: var(--th-t2-soft); }
:root:not([data-theme="dark"]) :is(.ui-pam-hero, .ui-grid-stats, .ui-stats, .ui-grid-4, .ui-grid-3, .ui-grid-5) > .ui-stat:nth-child(5n+3) { --c: var(--th-t3); --s: var(--th-t3-soft); }
:root:not([data-theme="dark"]) :is(.ui-pam-hero, .ui-grid-stats, .ui-stats, .ui-grid-4, .ui-grid-3, .ui-grid-5) > .ui-stat:nth-child(5n+4) { --c: var(--th-t4); --s: var(--th-t4-soft); }
:root:not([data-theme="dark"]) :is(.ui-pam-hero, .ui-grid-stats, .ui-stats, .ui-grid-4, .ui-grid-3, .ui-grid-5) > .ui-stat:nth-child(5n+5) { --c: var(--th-t5); --s: var(--th-t5-soft); }
:root:not([data-theme="dark"]) .ui-stat { background: linear-gradient(150deg, #FFFFFF 0%, #FFFFFF 38%, var(--s, var(--th-t1-soft)) 100%) !important; border-color: color-mix(in srgb, var(--c, var(--th-t1)) 22%, var(--ui-border)); }
:root:not([data-theme="dark"]) .ui-stat .ui-stat__icon { background: linear-gradient(135deg, var(--c, var(--th-t1)) 0%, color-mix(in srgb, var(--c, var(--th-t1)) 70%, #1A2332) 100%) !important; }
:root:not([data-theme="dark"]) .ui-stat::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--c, var(--th-t1)); height: auto !important; inset: 14px auto 14px 0 !important; }
.ui-stat { position: relative; overflow: hidden; }
/* Tones the page asked for win over position. */
:root:not([data-theme="dark"]) .ui-stat.ui-stat--success { --c: #12925A; --s: #DFF5E9; }
:root:not([data-theme="dark"]) .ui-stat.ui-stat--warning, :root:not([data-theme="dark"]) .ui-stat.ui-stat--warn { --c: #C27714; --s: #FCEFD8; }
:root:not([data-theme="dark"]) .ui-stat.ui-stat--danger { --c: #C93A3A; --s: #FCE3E3; }
/* Every tile in a row is the same height, and its parts sit in the same places. */
:is(.ui-pam-hero, .ui-grid-stats, .ui-stats) { align-items: stretch; }
:is(.ui-pam-hero, .ui-grid-stats, .ui-stats) > .ui-stat { height: 100%; justify-content: flex-start; }
.ui-stat > .ui-stat__foot { margin-top: auto; }
.ui-stat__foot .ui-stat__hint { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Tabs: one bar, pill tabs, the current one filled ───────────────────────────────────────────── */
.ui-tabs { border-bottom: 0 !important; margin: 0 0 22px; overflow-x: auto; }
:root:not([data-theme="dark"]) .ui-tabs__list { display: inline-flex; gap: 4px; padding: 5px; background: rgba(255, 255, 255, 0.85); border: 1px solid var(--ui-border); border-radius: 10px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05); }
.ui-tab { border-radius: 8px !important; padding: 8px 14px !important; font-weight: 500; color: var(--ui-text-2); transition: background-color 160ms, color 160ms, box-shadow 160ms; }
.ui-tab:hover { background: var(--ui-accent-soft) !important; color: var(--ui-text) !important; box-shadow: none !important; }
.ui-tab[aria-current="page"] { background: var(--th-primary, var(--ui-accent)) !important; color: #fff !important; box-shadow: 0 6px 14px -8px rgba(11, 122, 147, 0.8) !important; }
.ui-tab[aria-current="page"]::after { display: none !important; }
.ui-tab[aria-current="page"] .ui-tab__count { background: rgba(255, 255, 255, 0.25); color: #fff; }
.ui-tab__count { background: var(--ui-surface-3); color: var(--ui-text-2); }

/* ── Buttons: the main action is deep and clear; secondary actions are crisp white ──────────────── */
:root:not([data-theme="dark"]) :is(.ui-btn--primary, .ui-body .btn.primary, .ui-body .btn.saffron) {
  --b-fg: #fff; color: #fff !important; border: 0 !important; background: var(--th-primary) !important; background-size: 100% 100% !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 8px 18px -10px rgba(11, 122, 147, 0.9) !important; font-weight: 590; }
:root:not([data-theme="dark"]) :is(.ui-btn--primary, .ui-body .btn.primary, .ui-body .btn.saffron):hover { background: var(--th-primary-hover) !important; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 12px 22px -10px rgba(11, 122, 147, 0.95) !important; }
:root:not([data-theme="dark"]) :is(.ui-btn--primary, .btn.primary) .icon { stroke: #fff; }
:root:not([data-theme="dark"]) .ui-btn--secondary, :root:not([data-theme="dark"]) .ui-body .btn:not(.primary):not(.saffron):not(.ghost):not(.subtle):not(.danger) { background: #fff; border: 1px solid var(--ui-border-strong); color: var(--ui-text); }
.ui-btn, .ui-body .btn { min-height: 38px; border-radius: 10px; }
.ui-btn--sm { min-height: 32px; }
.ui-btn.is-busy::after { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }

/* ── Inputs: white on white cards need a clear edge ──────────────────────────────────────────────── */
:root:not([data-theme="dark"]) :is(.ui-input, .ui-select, .ui-textarea) { border-color: var(--ui-border-strong); background-color: #fff; }
:is(.ui-input, .ui-select, .ui-textarea) { min-height: 42px; border-radius: 10px; }
.ui-textarea { min-height: 96px; }

/* ── Tables: a tinted header row and a clear hover ──────────────────────────────────────────────── */
:root:not([data-theme="dark"]) .ui-table thead th, :root:not([data-theme="dark"]) .ui-content table:not(.ui-table) thead th { background: #F8F9FB; color: var(--ui-text-2); font-weight: 500; letter-spacing: 0.04em; }
:root:not([data-theme="dark"]) .ui-table tbody tr:hover td { background: #F3FAFA; }

/* ── Badges: readable, with a little weight ─────────────────────────────────────────────────────── */
.ui-badge { font-weight: 500; }

/* ── Sidebar: the same deep gradient as the brand, current item bright ─────────────────────────── */
:root:not([data-theme="dark"]) .ui-side { background: linear-gradient(180deg, #0B5C66 0%, #0D4E78 55%, #23439A 100%) !important; }
.ui-nav__item[aria-current="page"] { background: rgba(255, 255, 255, 0.16) !important; color: #fff !important; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }

/* ── App and catalogue tiles: colour on hover, a clear edge at rest ─────────────────────────────── */
:root:not([data-theme="dark"]) :is(.apps-card, .conn-card, .ui-link-card) { border-color: var(--ui-border); }
:is(.apps-card, .conn-card, .ui-link-card, a.ui-stat) { transition: transform 220ms cubic-bezier(0.22, 0.9, 0.3, 1), box-shadow 220ms, border-color 220ms; }
:is(.apps-card, .ui-link-card, a.ui-stat):hover { transform: translateY(-3px); box-shadow: var(--th-card-shadow-hover); border-color: rgba(10, 160, 160, 0.55); }

/* ── Spacing between the big blocks of a page ───────────────────────────────────────────────────── */
.ui-content > :is(.ui-card, .card, .integration-grid, .ui-grid-2, .ui-pam-hero, .ui-grid-stats, section) + :is(.ui-card, .card, .integration-grid, .ui-grid-2, .ui-pam-hero, .ui-grid-stats, section) { margin-top: 20px; }
.integration-grid { gap: 20px; }
.ui-pam-hero, .ui-grid-stats { gap: 16px; margin-bottom: 20px; }

@media (prefers-reduced-motion: reduce) { :is(.apps-card, .conn-card, .ui-link-card, a.ui-stat, .ui-tab) { transition: none; } }

/* ── Admin panel: each section card carries its colour ──────────────────────────────────────────── */
:root:not([data-theme="dark"]) .ui-panelcard { --c: var(--th-t1); background: linear-gradient(165deg, #FFFFFF 0%, #FFFFFF 55%, color-mix(in srgb, var(--c) 9%, #fff) 100%) !important; border-top: 4px solid var(--c) !important; }
:root:not([data-theme="dark"]) .ui-panelcard:nth-child(6n+1) { --c: #5B5BD6; }
:root:not([data-theme="dark"]) .ui-panelcard:nth-child(6n+2) { --c: #0A8F9C; }
:root:not([data-theme="dark"]) .ui-panelcard:nth-child(6n+3) { --c: #2F64C8; }
:root:not([data-theme="dark"]) .ui-panelcard:nth-child(6n+4) { --c: #12925A; }
:root:not([data-theme="dark"]) .ui-panelcard:nth-child(6n+5) { --c: #C93A4F; }
:root:not([data-theme="dark"]) .ui-panelcard:nth-child(6n+6) { --c: #7A55D3; }
.ui-panelcard__list a { border-radius: 8px; transition: background-color 160ms, color 160ms, padding-left 200ms; }
.ui-panelcard__list a:hover { background: color-mix(in srgb, var(--c, #0A8F9C) 10%, #fff); color: var(--ui-text); padding-left: 10px; text-decoration: none; }

/* Two cards side by side are one height, whatever wraps them (a section, a div). */
.ui-grid-2 { align-items: stretch !important; }
.ui-grid-2 > :is(.ui-card, section, .card) { height: 100%; }
.ui-grid-2 > :is(section, div):has(> .ui-card:only-child) > .ui-card { height: 100%; }

/* ── Search-and-filter bars: a deliberate two-row layout, not a wrap ────────────────────────────────
   Row 1: the search box on the left, the extra filters and view switch on the right. Row 2: the quick-filter chips. */
.ui-toolbar { display: grid !important; grid-template-columns: minmax(220px, 420px) 1fr; grid-template-areas: "search end" "chips chips"; align-items: center; gap: 12px 16px; padding: 18px 24px !important; }
.ui-toolbar:not(:has(.ui-chips)) { grid-template-areas: "search end"; }
.ui-toolbar:not(:has(.ui-toolbar__end > *)) { grid-template-columns: minmax(220px, 420px) 1fr; }
.ui-toolbar > .ui-search { grid-area: search; width: 100%; max-width: none; margin: 0 !important; }
.ui-toolbar > .ui-chips { grid-area: chips; }
.ui-toolbar > .ui-toolbar__end { grid-area: end; margin: 0 !important; justify-content: flex-end; flex-wrap: wrap; align-items: center; gap: 8px; }
.ui-toolbar > .ui-toolbar__end:empty { display: none; }
.ui-toolbar .ui-select, .ui-toolbar .apps-filter { width: auto; min-width: 170px; min-height: 38px; }
.ui-card--flush > .ui-card__body > .ui-toolbar { padding-inline: 24px !important; margin: 0; }
.ui-card--flush > .ui-card__body > .apps-grid { padding: 20px 24px 24px !important; }
@media (max-width: 760px) { .ui-toolbar { grid-template-columns: 1fr; grid-template-areas: "search" "end" "chips"; } .ui-toolbar > .ui-toolbar__end { justify-content: flex-start; } }
/* Chips: the chosen one carries the brand colour, like the tabs. */
.ui-chip { height: 32px; font-weight: 500; }
:root:not([data-theme="dark"]) .ui-chip { background: #fff; }
:root:not([data-theme="dark"]) .ui-chip:hover { background: var(--ui-accent-soft); border-color: var(--ui-accent-ink); }
:root:not([data-theme="dark"]) .ui-chip[aria-pressed="true"] { background: var(--th-primary) !important; border-color: transparent !important; color: #fff !important; box-shadow: 0 6px 14px -8px rgba(11, 122, 147, 0.8); }

/* ── Older cards (.card.stack): a header band, an even rhythm, sub-sections set apart ───────────── */
.card.stack { gap: 16px !important; padding: 0 24px 24px !important; overflow: hidden; }
.card.stack > :is(:first-child, input[type=hidden]:first-child + *):is(h3, .section-row) {
  margin: 0 -24px 4px !important; padding: 0 24px !important; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--ui-border); }
:root:not([data-theme="dark"]) .card.stack > :is(:first-child, input[type=hidden]:first-child + *):is(h3, .section-row) { background: linear-gradient(90deg, #F2FAFA 0%, #F1F5FC 100%); }
.card.stack > :is(:first-child, input[type=hidden]:first-child + *):is(h3, .section-row) h3, .card.stack > h3:first-child { margin: 0 !important; font-size: 1.06rem; font-weight: 590; }
.card.stack > :is(:first-child, input[type=hidden]:first-child + *):is(h3, .section-row) + p { margin-top: 0; }
.card.stack p { margin: 0; }
.card.stack > form.stack, .card.stack > form:not(.inline-form) { display: grid; gap: 16px; margin: 0; }
.card.stack h4 { margin: 8px 0 0; padding-top: 18px; border-top: 1px dashed var(--ui-border-strong); font-size: 0.98rem; font-weight: 590; letter-spacing: 0; text-transform: none; color: var(--ui-text); }
.card.stack > form > h4:first-of-type, .card.stack form.stack > h4 { margin-top: 4px; }
.card.stack .field { display: grid; gap: 6px; margin: 0; }
.card.stack .field > label { margin: 0 !important; font-size: 0.84rem; font-weight: 500; color: var(--ui-text-2); }
.card.stack .two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px 20px; margin: 0; }
.card.stack .two-col > div { margin: 0 !important; }
.card.stack > .empty-mini, .card.stack p.muted:only-of-type { color: var(--ui-text-2); }
.card.stack > div:last-child > .btn, .card.stack form > div:last-child > .btn, .card.stack form > .btn:last-child { margin-top: 4px; }
/* Cards side by side in an older grid: same height, headers on one line. */
.integration-grid:has(> .card.stack) { align-items: stretch; }
.integration-grid > .card.stack { height: 100%; align-content: start; }
.ui-card--flush > .ui-card__body > form.ui-toolbar, .ui-card > form.ui-toolbar { margin: 0 !important; }
.ui-toolbar > .ui-toolbar__end { flex-wrap: nowrap; }
@media (max-width: 1100px) { .ui-toolbar > .ui-toolbar__end { flex-wrap: wrap; } }
.ui-toolbar .ui-segmented, .ui-toolbar .apps-viewtoggle { flex: none; }
.ui-card--flush > .ui-card__body > .apps-grid, .ui-card--flush > .ui-card__body > [data-apps-root] > .apps-grid { padding: 20px 24px 24px !important; margin: 0 !important; }
.ui-card--flush > .ui-card__body > [data-apps-root] { margin: 0 !important; padding: 0 !important; }

/* ── Row actions follow the pointer, everywhere ─────────────────────────────────────────────────────
   In any list of rows (attention items, table rows, rule lists, connection and app cards) the action button rests white;
   the row under the pointer (or holding keyboard focus) fills its button with the brand colour. In a priority list the first row
   carries the colour until the pointer enters the list. Danger buttons keep their own colour. */
:where(.hm-row, .ui-list > li, .ui-table tbody tr, .rule-list > li, .conn-card, .apps-card, .rq) :where(.ui-btn--primary, .ui-btn--secondary, .btn.primary, .btn:not(.ghost):not(.subtle):not(.danger):not(.danger-ghost)):not(.ui-btn--danger) {
  background: #fff !important; color: var(--ui-text) !important; border: 1px solid var(--ui-border-strong) !important; box-shadow: none !important;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease, box-shadow 200ms ease; }
:where(.hm-row, .ui-list > li, .ui-table tbody tr, .rule-list > li, .conn-card, .apps-card, .rq) :where(.ui-btn--primary, .ui-btn--secondary, .btn.primary, .btn):not(.ui-btn--danger) .icon { stroke: currentColor; }
/* Rows are all alike: no fill on hover, no highlighted first row, no coloured edge, no lift (15 Nov 2026). */
:root:not([data-theme="dark"]) .hm-row { border-left: 1px solid var(--ui-border) !important; }
:root:not([data-theme="dark"]) .hm-row[data-tone="danger"] { border-left: 2px solid var(--ui-danger) !important; }
@media (prefers-reduced-motion: reduce) { .hm-row, .rule-list > li, .ui-list > li { transition: none; transform: none !important; } }

/* ── Every tile answers the pointer the same way ──────────────────────────────────────────────────
   App cards, catalogue cards, launch tiles, stat tiles, link cards, quick actions, admin-panel cards, connection cards:
   on hover (or keyboard focus inside) a light teal-to-blue tint washes in, the edge turns teal and the tile lifts a little. */
:root {
  --th-tint: linear-gradient(150deg, rgba(10, 191, 188, 0.12) 0%, rgba(47, 95, 196, 0.08) 100%);
  --th-tint-edge: rgba(10, 160, 160, 0.55);
}
:root[data-theme="dark"] { --th-tint: linear-gradient(150deg, rgba(10, 191, 188, 0.18) 0%, rgba(47, 95, 196, 0.14) 100%); }
:is(.apps-card, .conn-card, .ui-app, .ui-launch__tile, .ui-link-card, .ui-quick > a, .ui-quick > *, .ui-panelcard, a.ui-stat, .card.inset, .integration-grid > .card, .ui-grid-2 > .ui-card, label.ui-radio) {
  background-image: none; transition: background-color 220ms ease, box-shadow 220ms ease, border-color 220ms ease, transform 220ms cubic-bezier(0.22, 0.9, 0.3, 1); }
:is(.apps-card, .conn-card, .ui-app, .ui-launch__tile, .ui-link-card, .ui-quick > a, .ui-quick > *, .ui-panelcard, a.ui-stat, .card.inset, .integration-grid > .card):is(:hover, :focus-within):not(:has(.ui-menu[open], details[open] .ui-menu)) {
  background-image: var(--th-tint) !important; background-color: #fff; border-color: var(--th-tint-edge) !important; box-shadow: var(--th-card-shadow-hover, 0 18px 36px -14px rgba(16, 24, 40, 0.28)) !important; }
:root[data-theme="dark"] :is(.apps-card, .conn-card, .ui-app, .ui-launch__tile, .ui-link-card, .ui-quick > a, .ui-quick > *, .ui-panelcard, a.ui-stat, .card.inset, .integration-grid > .card):is(:hover, :focus-within) { background-color: var(--ui-surface); }
:is(.apps-card, .conn-card, .ui-app, .ui-launch__tile, .ui-link-card, .ui-quick > a, .ui-quick > *, a.ui-stat):is(:hover, :focus-within) { transform: translateY(-3px); }
/* Stat tiles and admin-panel cards already carry their own colour wash: the tint is laid over it, so it still reads. */
:root:not([data-theme="dark"]) :is(.ui-stat, .ui-panelcard):is(:hover, :focus-within) { background: var(--th-tint), linear-gradient(150deg, #FFFFFF 0%, #FFFFFF 38%, var(--s, var(--th-t1-soft, #DDF5F3)) 100%) !important; }
:root:not([data-theme="dark"]) .ui-stat:is(:hover, :focus-within) { border-color: color-mix(in srgb, var(--c, #0A9C99) 55%, #fff) !important; }
/* The catalogue's Add link and the app name pick up the colour too. */
.apps-card:is(:hover, :focus-within) :is(.apps-card__id b, .apps-card__id strong, h3) { color: #0B6F80; }
.apps-card:is(:hover, :focus-within) .apps-logo { box-shadow: 0 6px 14px -6px rgba(11, 122, 147, 0.55); }
@media (prefers-reduced-motion: reduce) { :is(.apps-card, .conn-card, .ui-app, .ui-launch__tile, .ui-link-card, .ui-quick > a, .ui-quick > *, a.ui-stat) { transform: none !important; transition: none; } }
/* An empty-state line: the icon chip keeps its size; only the text stretches. */
.ui-emptyline > .ui-ic { flex: none !important; min-width: 0 !important; }
/* Directory-style stat tiles (.pp-stat) match the other stat tiles: a colour per position, a wash, a coloured edge, the hover tint. */
:root:not([data-theme="dark"]) .pp-stats > .pp-stat { --c: var(--th-t1); --s: var(--th-t1-soft); position: relative; overflow: hidden;
  background: linear-gradient(150deg, #FFFFFF 0%, #FFFFFF 40%, var(--s) 100%); border-color: color-mix(in srgb, var(--c) 22%, var(--ui-border)); }
:root:not([data-theme="dark"]) .pp-stats > .pp-stat:nth-child(5n+2) { --c: var(--th-t2); --s: var(--th-t2-soft); }
:root:not([data-theme="dark"]) .pp-stats > .pp-stat:nth-child(5n+3) { --c: var(--th-t3); --s: var(--th-t3-soft); }
:root:not([data-theme="dark"]) .pp-stats > .pp-stat:nth-child(5n+4) { --c: var(--th-t4); --s: var(--th-t4-soft); }
:root:not([data-theme="dark"]) .pp-stats > .pp-stat:nth-child(5n+5) { --c: var(--th-t5); --s: var(--th-t5-soft); }
:root:not([data-theme="dark"]) .pp-stats > .pp-stat::before { content: ""; position: absolute; inset: 12px auto 12px 0; width: 4px; border-radius: 0 4px 4px 0; background: var(--c); }
.pp-stat { transition: transform 220ms cubic-bezier(0.22, 0.9, 0.3, 1), box-shadow 220ms, border-color 220ms; }
:root:not([data-theme="dark"]) .pp-stats > .pp-stat:is(:hover, :focus-within) { background: var(--th-tint), linear-gradient(150deg, #FFFFFF 0%, #FFFFFF 40%, var(--s) 100%) !important;
  border-color: color-mix(in srgb, var(--c) 55%, #fff) !important; box-shadow: var(--th-card-shadow-hover) !important; transform: translateY(-3px); }

/* ── Alignment fixes from review ──────────────────────────────────────────────────────────────────── */
/* Toolbars with their own filter group (Directory): search, filters and the button on one row; chips underneath. */
.ui-toolbar:has(> .pp-filters) { grid-template-columns: minmax(220px, 360px) 1fr auto; grid-template-areas: "search filters end" "chips chips chips"; }
.ui-toolbar > .pp-filters { grid-area: filters; justify-content: flex-end; flex-wrap: nowrap; gap: 8px; min-width: 0; }
.ui-toolbar > .pp-filters > .ui-select { width: auto; min-width: 0; flex: 0 1 160px; }
@media (max-width: 1200px) { .ui-toolbar:has(> .pp-filters) { grid-template-columns: 1fr auto; grid-template-areas: "search end" "filters filters" "chips chips"; } .ui-toolbar > .pp-filters { justify-content: flex-start; flex-wrap: wrap; } }
/* Older cards that do not start with a title band keep their top padding. */
.card.stack:not(:has(> :is(:first-child, input[type=hidden]:first-child + *):is(h3, .section-row))) { padding-top: 24px !important; }
/* The title band sits flush with the card's top edge and corners. */
.card.stack > :is(:first-child, input[type=hidden]:first-child + *):is(h3, .section-row) { margin-top: 0 !important; border-radius: 16px 16px 0 0; }
.card.stack:has(> :is(:first-child, input[type=hidden]:first-child + *):is(h3, .section-row)) { padding-top: 0 !important; }
/* A note right after a button (or a row of buttons) is set apart from it. */
:is(.ui-btn, .btn, button) + :is(p, .muted, .small, .ui-muted), div:has(> :is(.ui-btn, .btn, button):only-child) + :is(p, .muted, .small, .ui-muted) { margin-top: 14px !important; }
/* Grouped fields (fieldset) start right below the title, with even space inside. */
.card fieldset, .ui-card fieldset { margin: 4px 0 0 !important; padding: 16px 20px 16px !important; }
.card fieldset > legend { padding: 0 8px; }
.card fieldset + fieldset { margin-top: 16px !important; }
.card > .section-row + fieldset, .card.stack > .section-row + * { margin-top: 0 !important; }
/* A note right after a form is set apart from the form's last button. */
form + :is(p, .ui-muted, .muted, .small) { margin-top: 16px !important; }
/* Cards side by side: their closing buttons line up along the bottom. */
.integration-grid > .card.stack { display: flex !important; flex-direction: column; }
.integration-grid > .card.stack > :last-child:is(button, .btn, .ui-btn, div:has(> :is(button, .btn, .ui-btn):only-child)) { margin-top: auto !important; }
/* A card that is a form itself (Inline hooks): its button sits on the bottom line too. */
.integration-grid > form.card.stack > :last-child:is(button, .btn, .ui-btn, div:has(> :is(button, .btn, .ui-btn):only-child)) { margin-top: auto !important; }

/* Calm hover: cards and rows no longer move under the pointer. A card that lifts away from the pointer at its edge drops, is hovered again and lifts again, which shows as flashing.
   The cue is a soft shadow and border colour change, eased slowly. */
.ui-body :is(.apps-card, .conn-card, .ui-link-card, a.ui-stat, .ui-stat, .ui-app, .ui-launch__tile, .ui-todo__card, .ui-todo__card *, .hm-row, .rule-list > li, .ui-list > li, a.ui-ws__tile, .pp-stat, .ui-quick > a, .app-tile, .tile, .kpi, .feature, .choice, .app-chip):hover {
  transform: none !important; }
.ui-body :is(.apps-card, .conn-card, .ui-link-card, a.ui-stat, .ui-stat, .ui-app, .ui-launch__tile, .ui-todo__card, .hm-row, .rule-list > li, .ui-list > li, a.ui-ws__tile, .pp-stat, .ui-quick > a, .app-tile, .tile, .kpi, .feature, .choice, .app-chip) {
  transition: box-shadow 320ms ease, border-color 320ms ease, background-color 320ms ease !important; }
.ui-body .ui-nav__item:hover { transform: none !important; }

/* A button whose form has just been sent: dimmed and inert until the answer arrives, so it cannot be sent twice. */
.is-sending { opacity: .6; pointer-events: none; cursor: progress; }

/* ── Flat, not lit: a duotone chip with no bevel, one easing curve, a small lift on hover (15 Nov 2026 -- the inset
   highlights and drop shadows read as dated skeuomorphism next to a flat reference like Linear or Stripe). ── */
:root { --th-ease: cubic-bezier(.22, 1, .36, 1); }
:root:not([data-theme="dark"]) .ui-stat .ui-stat__icon { box-shadow: none; transition: none; }
:root:not([data-theme="dark"]) :is(.ui-card, .card, .ui-stat, .conn-card, .apps-card) { transition: box-shadow .18s var(--th-ease), border-color .18s var(--th-ease); }
@media (hover: hover) { :root:not([data-theme="dark"]) :is(.ui-stat, .conn-card, .apps-card):hover { box-shadow: var(--th-card-shadow-hover); } }
/* Application tiles on the launchpad and the catalogue: a flat duotone chip, no bevel. */
:root:not([data-theme="dark"]) :is(.app-tile__icon, .app-icon, .launch-icon, .apps-card__icon) { border-radius: 10px; box-shadow: none; }
/* Focus: a clear ring for keyboard users; motion off when asked */
:is(a, button, [role="tab"], summary, input, select, textarea):focus-visible { outline: 3px solid #0A9C99; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }

/* ── Calmer, crisper surfaces (4 Nov 2026): a lighter canvas, flat white tiles with a thin tint edge instead of a colour wash, tight shadows
   instead of wide soft ones, and no frosted-glass blur, so text stays sharp and tiles stop looking hazy. Contrast is kept by darker text. ── */
:root:not([data-theme="dark"]) :is(.app-header, .topbar, .admin-top, .ui-top) { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; background: #FFFFFF !important; }
:root:not([data-theme="dark"]) .ui-stat { background: linear-gradient(180deg, #FFFFFF 0%, color-mix(in srgb, var(--c, var(--th-t1)) 5%, #fff) 100%) !important; }
:root:not([data-theme="dark"]) .ui-panelcard { background: linear-gradient(180deg, #FFFFFF 0%, color-mix(in srgb, var(--c) 4%, #fff) 100%) !important; }
:root:not([data-theme="dark"]) .pp-stats > .pp-stat { background: linear-gradient(180deg, #FFFFFF 0%, color-mix(in srgb, var(--c, #0ABFBC) 5%, #fff) 100%); }
:root:not([data-theme="dark"]) :is(.ui-stat, .ui-panelcard, .pp-stats > .pp-stat):is(:hover, :focus-within) { background: var(--th-tint), #FFFFFF !important; }
:root:not([data-theme="dark"]) .card.inset { background: #F8FAFC; }
.ui-body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-feature-settings: "kern" 1, "liga" 1; }
.ui-content .ui-muted, .ui-content .muted, .ui-content small.ui-muted { color: var(--ui-text-2); }
.ui-content :is(h1, h2, h3, .ui-page-title, .ui-card__title) { color: var(--ui-text); }
/* Headings on a dark banner stay light (the rule above once turned "Good afternoon, Rohan" navy on navy). */
.ui-content .ui-hero--navy :is(h1, h2, h3) { color: #fff; }
.dx-body, .dx-article p { color: var(--ui-text); font-size: 1rem; line-height: 1.65; }
:root:not([data-theme="dark"]) :is(.ui-launch__tile, .ui-app) { background: #FFFFFF; border-color: color-mix(in srgb, var(--tone-a, #0ABFBC) 22%, var(--ui-border)); }
:root:not([data-theme="dark"]) :is(.ui-launch__tile, .ui-app):is(:hover, :focus-within) { background: var(--th-tint), #FFFFFF; }

/* ── Visual system (2.23): calm operational surfaces ─────────────────────────────────────────────────────────
   V1 colour: surfaces are neutral; teal is the one action and accent colour; colour otherwise carries meaning only
   (green verified, amber warning, red failure). Metric cards no longer cycle through five colours.
   V2 type: one scale (title, section, body, label, helper); table text is full-strength, not muted; numbers align.
   V3 density: empty states are compact so the next action sits higher.
   Motion: no page-wide arrival fade on every navigation; drawers, dialogs and changed states keep their short transitions. */
:root { --ui-fs-title: 1.5rem; --ui-fs-section: 1.125rem; --ui-fs-body: 0.9375rem; --ui-fs-label: 0.875rem; --ui-fs-helper: 0.8125rem; }
:root:not([data-theme="dark"]) .ui-stat:not(.ui-stat--success):not(.ui-stat--warning):not(.ui-stat--warn):not(.ui-stat--danger) {
  --c: var(--th-primary, var(--ui-accent)) !important; --s: transparent !important; background: var(--ui-surface, #FFFFFF) !important; border-color: var(--ui-border) !important; }
:root:not([data-theme="dark"]) .ui-stat:not(.ui-stat--success):not(.ui-stat--warning):not(.ui-stat--warn):not(.ui-stat--danger)::before { display: none; }
:root:not([data-theme="dark"]) .ui-stat .ui-stat__icon { background: var(--ui-accent-soft) !important; color: var(--th-primary, var(--ui-accent)) !important; }
:root:not([data-theme="dark"]) :is(.ui-stat--success, .ui-stat--warning, .ui-stat--warn, .ui-stat--danger) .ui-stat__icon { background: var(--s) !important; color: var(--c) !important; }
.ui-stat__value, .ui-stat b, .ui-chip__n, .ui-table td, .hm-row__t b, [data-num] { font-variant-numeric: tabular-nums; }
.ui-page-title, .ui-main h1 { font-size: var(--ui-fs-title); line-height: 1.25; font-weight: 590; }
.ui-card__title, .ui-main h2, .ui-section-h h2 { font-size: var(--ui-fs-section); line-height: 1.35; font-weight: 590; }
.ui-label, .ui-field > label { font-size: var(--ui-fs-label); font-weight: 500; color: var(--ui-text); }
.ui-help, .ui-field small, .ui-muted small { font-size: var(--ui-fs-helper); }
.ui-table td { color: var(--ui-text); font-size: var(--ui-fs-body); }
.ui-table td.ui-muted, .ui-table td .ui-muted { color: var(--ui-text-2); }
.ui-empty { padding: 16px 16px !important; gap: 4px !important; }
.ui-empty__art { width: 56px !important; height: 38px !important; }
.ui-empty__art svg { width: 56px !important; height: 38px !important; }
.ui-empty__glyph { right: 2px !important; top: 6px !important; transform: scale(0.6); }
@media (prefers-reduced-motion: no-preference) { .ui-main > * { animation: none !important; } }
/* V1: one accent for navigation cards and the people counts too (no colour cycling by position). */
:root:not([data-theme="dark"]) .ui-panelcard:nth-child(n) { --c: var(--th-primary, var(--ui-accent)) !important; }
:root:not([data-theme="dark"]) .pp-stats > .pp-stat:nth-child(n) { --c: var(--th-primary, var(--ui-accent)) !important; --s: transparent !important; }

/* AI-written text (app/richtext.py, AMRich in ui.js): paragraphs, bullets, numbered steps, bold */
.ai-text p { margin: 0 0 .5em; }
.ai-text > :last-child { margin-bottom: 0; }
.ai-text__list { margin: .25em 0 .6em; padding-left: 1.3em; }
.ai-text__list li { margin: 0 0 .35em; }
.ai-text__list li::marker { color: var(--ui-accent, #0E9F9A); }
.ai-text strong { font-weight: 590; }
.ai-text code { font: .92em ui-monospace, SFMono-Regular, Menlo, monospace; background: rgba(14, 159, 154, .08); padding: 1px 4px; border-radius: 4px; }
.ai-text__h { font-weight: 590; }

/* Organisation details: paired fields line up at the top (a help line under one must not stretch its neighbour) and rows breathe. */
#org-details .ui-card .ui-grid-2 { align-items: start !important; gap: 4px 16px; margin-top: 12px; }
#org-details .ui-card .ui-field { margin-bottom: 0; align-content: start; align-self: start; }

/* ── Responsive: a table that is not in a scroll wrapper scrolls inside itself instead of pushing the whole page sideways
   (found 15 Nov 2026: a wide .ui-table with no .ui-table-wrap made an 820px tablet page 2,462px wide). ui.js turns every table of three or more
   columns into stacked cards at 640px and below, so up to 1100px every unwrapped table scrolls, and at 640px and below only the ones that do not
   stack (fewer than three columns, or ui-table--keep) need it. Wrapped tables are left exactly as they were. */
@media (min-width: 641px) and (max-width: 1100px) {
  .ui-content table.ui-table { display: block; max-width: 100%; overflow-x: auto; }
  .ui-content :is(.ui-table-wrap, .table-container) table.ui-table { display: table; max-width: none; overflow: visible; }
}
@media (max-width: 640px) {
  .ui-content table.ui-table:not(.ui-table--stack) { display: block; max-width: 100%; overflow-x: auto; }
  .ui-content :is(.ui-table-wrap, .table-container) table.ui-table:not(.ui-table--stack) { display: table; max-width: none; overflow: visible; }
}

/* Contrast corrections from the page-by-page audit (every text at least 4.5:1, large text 3:1) */
.ui-nav__tag--ai { color: #fff !important; }
.in-sev--medium { background: #b45309 !important; } .in-sev--low { background: #1d4ed8 !important; }
.ui-tab[aria-current="page"] .ui-tab__count { background: rgba(0, 0, 0, 0.24); color: #fff; }
.ui-btn--secondary { color: #3f4a57; }
.auth-meta, .auth-meta span { color: #4b5d63; }
.pp-stat__hint { color: #556274; }
