/*
 * Company Workspace — presentation layer on top of Bootstrap 5.3.
 *
 * Built to the EnergyUp International design system (design_system.md): teal
 * brand, Untitled-UI neutral scale, Inter, 8px control radius / 12px container
 * radius, soft shadows. Section 5 of that document is the source of every
 * token below; nothing here invents a colour or a radius.
 *
 * Still a deliberate copy of ERP.Modules.PlatformAdmin/wwwroot/css/admin.css,
 * for the same reason ERP.Modules.GroupManager/wwwroot/css/groupmanager.css is
 * one (spec 007 T004, research R-012). Constitution V forbids a module reaching
 * into another module's content root, and a static-asset path is as much an
 * internal as a type is: linking
 * /_content/ERP.Modules.PlatformAdmin/css/admin.css would make this surface
 * break whenever the administration surface restyles. The structural class
 * names are identical — .admin-shell, .admin-sidebar, .admin-nav-link and the
 * rest keep their names here — so the three layouts stay comparable and a fix
 * ported between the sheets stays a straight copy rather than a translation.
 *
 * WHAT IS NEW HERE, and nowhere else: the module catalogue's own furniture —
 * .module-grid, .module-card and its states, the .toolbar above the grid, and
 * .admin-rail-foot. The company surface is the only one that presents modules
 * as a browsable grid, so those rules would be dead weight in the other two
 * sheets. Every one of them is built from the tokens already declared above,
 * as design system §6.6 requires of a new component.
 *
 * Everything else here is visual: tokens, the application shell, and
 * refinements to the Bootstrap components the pages already use. No behaviour,
 * no new markup contracts — a page that only uses stock Bootstrap classes still
 * picks up the restyled cards, tables, badges, and forms.
 *
 * Light theme only, by design: the layout pins data-bs-theme="light" so the
 * workspace looks identical regardless of the operating-system appearance.
 *
 * NOT here: the anonymous sign-in shell (.auth-page, .auth-panel, .auth-brand*,
 * .auth-card, .auth-lede, .auth-foot, .auth-note) and the verification-code
 * field (.code-input). Those live in
 * ERP.SharedKernel.Web/wwwroot/css/auth.css — a shared-kernel asset, not
 * another module's, so the rule above holds — and the layout links it after
 * this sheet, so the platform-administration, group-manager, and company
 * sign-in screens are identical by construction rather than by three files
 * agreeing. Restyle them there, once.
 *
 * Direction is expressed with logical properties throughout (inline-start /
 * inline-end rather than left / right) so the workspace mirrors correctly under
 * dir="rtl" — design system §6.9.
 */

/* ---------------------------------------------------------------- tokens */

:root,
[data-bs-theme="light"] {
    color-scheme: light;

    /* brand — reserved for interactive intent, never for state */
    --brand-50: #F0F8F6;
    --brand-100: #D6EDE9;
    --brand-700: #1B6E63;
    --brand-800: #155A51;
    --brand-900: #10453E;

    /* neutrals */
    --gray-50: #F9FAFB;
    --gray-100: #F2F4F7;
    --gray-200: #EAECF0;
    --gray-300: #D0D5DD;
    --gray-400: #98A2B3;
    --gray-500: #667085;
    --gray-600: #475467;
    --gray-700: #344054;
    --gray-900: #101828;

    /* status — reserved for state, never for a button */
    --success-bg: #ECFDF3;
    --success-fg: #067647;
    --warning-bg: #FFFAEB;
    --warning-fg: #B54708;
    --error-bg: #FEF3F2;
    --error-fg: #B42318;
    --info-bg: #EFF8FF;
    --info-fg: #175CD3;

    /* surfaces */
    --canvas: var(--gray-50);
    --surface: #FFFFFF;
    --border: var(--gray-200);

    /* radius — 8px for controls, 12px for containers, nothing else */
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-full: 9999px;

    /* elevation */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .10), 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, .08), 0 4px 6px -2px rgba(16, 24, 40, .03);
    --focus-ring: 0 0 0 4px rgba(27, 110, 99, .18);

    /* type */
    --font-sans: "Inter", -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, sans-serif;
    --font-mono: "Cascadia Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

    /* layout */
    --sidebar-w: 232px;
    --topbar-h: 72px;
    --content-max: 1440px;

    /* motion — §4: 150ms for colour and shadow, 200ms for expansion */
    --t-fast: 150ms ease-out;
    --t-med: 200ms ease-out;

    /*
     * Bootstrap's own variables, pointed at the same tokens. Stock components
     * on pages this sheet does not name still land inside the system.
     */
    --bs-body-font-family: var(--font-sans);
    --bs-link-color: var(--brand-700);
    --bs-link-hover-color: var(--brand-800);
    --bs-border-color: var(--border);
    --bs-secondary-color: var(--gray-600);
    --bs-tertiary-color: var(--gray-500);
    --bs-body-color: var(--gray-900);
    --bs-emphasis-color: var(--gray-900);
    --bs-focus-ring-color: rgba(27, 110, 99, .18);
}

/* ------------------------------------------------------------------ base */

body.admin-body {
    background: var(--canvas);
    color: var(--gray-900);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.admin-body h1,
.admin-body h2,
.admin-body h3,
.admin-body h4 {
    color: var(--gray-900);
    font-weight: 600;
}

.admin-body code,
.admin-body .mono {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

/*
 * Deliberately scoped to the content regions and excluding .btn. A blanket
 * `.admin-body a` rule outranks both Bootstrap's `.btn { color: … }` and this
 * sheet's own `.admin-nav-link`, which paints button-links invisible (brand
 * text on the brand fill) and repaints the sidebar nav.
 */
.admin-content a:not(.btn),
.auth-panel a:not(.btn) {
    color: var(--brand-700);
    text-decoration: none;
}

.admin-content a:not(.btn):hover,
.auth-panel a:not(.btn):hover {
    color: var(--brand-800);
    text-decoration: underline;
}

.text-muted,
.form-text,
.text-body-secondary {
    color: var(--gray-600) !important;
}

/*
 * §4 accessibility floor: a visible ring on every focusable control. Scoped to
 * the things a person actually operates — a blanket `:focus-visible` also hits
 * the programmatically focused containers Bootstrap uses (the offcanvas panel
 * takes tabindex="-1"), and repaints them on open.
 */
.admin-body a:focus-visible,
.admin-body button:focus-visible,
.admin-body input:focus-visible,
.admin-body select:focus-visible,
.admin-body textarea:focus-visible,
.admin-body summary:focus-visible,
.admin-body [role="button"]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

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

.admin-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.admin-sidebar {
    background: var(--surface);
    border-inline-end: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
}

/*
 * At lg and above the aside is the static 232px rail of §2. Below it, the
 * markup's .offcanvas-lg hands the same element to Bootstrap as a drawer —
 * declared in markup, so there is no console JavaScript to keep in step.
 */
@media (min-width: 992px) {
    .admin-sidebar {
        flex: 0 0 var(--sidebar-w);
        width: var(--sidebar-w);
        position: sticky;
        top: 0;
        height: 100vh;
    }
}

/* The logo block: brand lockup, plus the drawer's close control below lg. */
.admin-brand-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-inline-end: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    flex: 1 1 auto;
    min-width: 0;
    color: var(--gray-900);
    text-decoration: none;
}

.admin-brand:hover {
    color: var(--gray-900);
    text-decoration: none;
}

.admin-brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: var(--r-md);
    background: var(--brand-50);
    color: var(--brand-700);
}

.admin-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.admin-brand-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-900);
}

.admin-brand-sub {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
}

.admin-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.admin-nav-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    padding: 12px 12px 4px;
}

.admin-nav-label:first-child {
    padding-top: 0;
}

/* §3 Sidebar nav item: 40px tall, 8px radius, 12px icon gap, 14/500. */
.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: var(--r-md);
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color var(--t-fast), color var(--t-fast);
}

.admin-nav-link:hover {
    background: var(--gray-50);
    color: var(--gray-900);
    text-decoration: none;
}

/* Active is a solid brand fill — the one place teal appears in the rail. */
.admin-nav-link.active {
    background: var(--brand-700);
    color: #fff;
}

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

.admin-nav-link svg {
    flex: 0 0 auto;
}

/* Trailing count badge, right-aligned (§3). */
.admin-nav-count {
    margin-inline-start: auto;
    background: var(--gray-100);
    color: var(--gray-700);
    border-radius: var(--r-sm);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 8px;
    font-variant-numeric: tabular-nums;
}

.admin-nav-link.active .admin-nav-count {
    background: rgba(255, 255, 255, .18);
    color: #fff;
}

/* --------------------------------------------------------- the user chip */

/*
 * §3 Topbar: 40px round avatar with a presence dot, name 14/600, email 13/400.
 * Used in the topbar on desktop and in the drawer footer on small screens —
 * one component, two placements.
 */
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-chip-avatar {
    position: relative;
    flex: 0 0 auto;
}

/* 32px rather than the base 40px, and the reason is the photo. Gray initials at
   40px sat quietly in a 72px topbar; a photograph at the same diameter does not
   — it carries far more visual weight and started reading as the loudest thing
   up there, louder than the workspace name beside it. 32px is the declared
   roster size (avatar.css), not a new number, and it lines the chip up with the
   reminder indicator sitting next to it. The other two shells carry the same
   value for the same reason. */
.user-chip-avatar .avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--r-full);
    font-size: 0.75rem;
}

/* 8px follows the avatar down from 40px to 32px. Left at 10px the dot would
   have grown from roughly a third of the circle to nearly half of it and turned
   into the thing you notice first — the dot is meant to qualify the avatar, not
   compete with it. The 2px ring stays: it is what separates green from a dark
   photo underneath. */
.user-chip-presence {
    position: absolute;
    inset-block-end: 0;
    inset-inline-end: 0;
    width: 8px;
    height: 8px;
    border-radius: var(--r-full);
    background: var(--success-fg);
    border: 2px solid var(--surface);
}

/* The markup nests spans, so the column direction has to be declared here —
   inline children would otherwise run together on one line. */
.admin-identity {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
    line-height: 1.35;
}

.admin-identity-name,
.admin-identity-mail {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-identity-name {
    color: var(--gray-900);
    font-weight: 600;
    font-size: 0.875rem;
}

.admin-identity-mail {
    color: var(--gray-500);
    font-size: 0.8125rem;
}

/* Icon button: 40×40 hit area, 8px radius, gray-100 hover (§3 Topbar). */
.icon-button,
.admin-signout {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    border-radius: var(--r-md);
    color: var(--gray-600);
    transition: background-color var(--t-fast), color var(--t-fast);
}

.icon-button:hover,
.admin-signout:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

/* ---------------------------------------------------------------- topbar */

.admin-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: var(--topbar-h);
}

.admin-topbar-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.admin-topbar-end {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Only a drawer needs a handle, so the handle only exists where the drawer does. */
.admin-drawer-toggle {
    display: grid;
}

@media (min-width: 992px) {
    .admin-drawer-toggle {
        display: none;
    }
}

/* The shell's buttons, held against the kit. A page that links erp-ui.css
   (Profile) brings the kit's .icon-button — 36px, inline-flex — at the same
   specificity and later, which shrank the top bar's buttons and put the drawer
   handle on a desktop. Scoped to the shell's two bars, so the kit keeps its own
   button inside the page. */
.admin-topbar .icon-button,
.admin-brand-row .icon-button {
    display: grid;
    justify-content: normal;
    width: 40px;
    height: 40px;
}

@media (min-width: 992px) {
    .admin-topbar .admin-drawer-toggle {
        display: none;
    }
}

.admin-content {
    padding: 32px 24px 64px;
    flex: 1 1 auto;
    width: 100%;
    max-width: var(--content-max);
}

@media (max-width: 767.98px) {
    .admin-topbar {
        padding-inline: 16px;
        gap: 8px;
    }

    /* The chip keeps its avatar and loses its text: at this width the page
       title needs the room more than the address does. */
    .admin-topbar .admin-identity {
        display: none;
    }

    .admin-content {
        padding: 24px 16px 48px;
    }
}

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

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

.page-title {
    font-size: 1.5rem;
    line-height: 2rem;
    font-weight: 600;
    margin: 0;
}

.page-subtitle {
    color: var(--gray-600);
    margin: 4px 0 0;
    font-size: 1rem;
    max-width: 46rem;
}

.page-head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.breadcrumb {
    font-size: 0.875rem;
    margin-bottom: 12px;
    --bs-breadcrumb-divider-color: var(--gray-400);
    --bs-breadcrumb-item-padding-x: 8px;
}

.breadcrumb-item.active {
    color: var(--gray-600);
}

/*
 * Section header with a right-aligned count (§2). The count is real data —
 * the number of things in the section — so the device carries information
 * rather than decorating the gap above a card.
 */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin: 32px 0 16px;
}

.section-head:first-child {
    margin-top: 0;
}

.section-head-title {
    font-size: 1.125rem;
    line-height: 1.75rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.section-head-count {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-500);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.section-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

/*
 * Icon tile, §1.4: 40×40, 8px radius, brand-50 ground, brand-700 glyph. The
 * console's one repeated ornament — it anchors card heads, empty states, and
 * result screens so the surfaces read as one product.
 */
.icon-tile {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: var(--r-md);
    background: var(--brand-50);
    color: var(--brand-700);
}

.icon-tile-lg {
    width: 56px;
    height: 56px;
    border-radius: var(--r-lg);
}

.icon-tile-success { background: var(--success-bg); color: var(--success-fg); }
.icon-tile-warning { background: var(--warning-bg); color: var(--warning-fg); }
.icon-tile-danger  { background: var(--error-bg);   color: var(--error-fg); }
.icon-tile-neutral { background: var(--gray-100);   color: var(--gray-600); }

/* ----------------------------------------------------------------- cards */

.card {
    --bs-card-bg: var(--surface);
    --bs-card-border-color: var(--gray-200);
    --bs-card-border-radius: var(--r-lg);
    --bs-card-inner-border-radius: var(--r-lg);
    --bs-card-spacer-x: 24px;
    --bs-card-spacer-y: 24px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--t-fast);
}

.card-title {
    font-size: 1rem;
    line-height: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

/* The lede under a card title, when the card has one. */
.card-title + .form-text,
.card-title + p {
    margin-bottom: 20px;
}

.card-header {
    background: transparent;
    border-bottom-color: var(--gray-200);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2,
.card-header .card-title {
    margin: 0;
    font-size: 1rem;
}

/*
 * Card head with the icon tile leading — the shape §3's module card uses, put
 * to work here for the panels that carry an action rather than a metric.
 */
.card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.card-head .card-title {
    margin-bottom: 0;
}

.card-head-body {
    min-width: 0;
    flex: 1 1 auto;
}

.card-head-body .form-text {
    margin-top: 4px;
    margin-bottom: 0;
}

/* Stat tiles ---------------------------------------------------------- */

/*
 * Not in §3 — built from §3's Card plus the §1.1 status triplets, as rule 6
 * allows. A tile reports one number and the state that number is in; the dot
 * and the label carry the state together, never colour alone.
 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 500;
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--r-full);
    background: var(--stat-color, var(--gray-400));
    flex: 0 0 auto;
}

.stat-value {
    font-size: 1.875rem;
    line-height: 2.375rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-top: 4px;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
}

.stat-hint {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-top: auto;
    padding-top: 4px;
}

.stat-success { --stat-color: var(--success-fg); }
.stat-neutral { --stat-color: var(--gray-400); }

/* A tile that is reporting a problem tints, so the estate's sore spots are
   findable at a glance without a status colour landing on a control. */
.stat-warning {
    --stat-color: var(--warning-fg);
    background: var(--warning-bg);
    border-color: color-mix(in srgb, var(--warning-fg) 20%, transparent);
}

.stat-warning .stat-card-head,
.stat-warning .stat-hint {
    color: var(--warning-fg);
}

.stat-danger {
    --stat-color: var(--error-fg);
    background: var(--error-bg);
    border-color: color-mix(in srgb, var(--error-fg) 20%, transparent);
}

.stat-danger .stat-card-head,
.stat-danger .stat-hint {
    color: var(--error-fg);
}

/* Key/value list ------------------------------------------------------ */

.kv-list {
    display: flex;
    flex-direction: column;
    margin: 0;
}

.kv-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-200);
}

.kv-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.kv-row:first-child {
    padding-top: 0;
}

.kv-key {
    color: var(--gray-600);
    font-size: 0.875rem;
    flex: 0 0 auto;
}

.kv-value {
    text-align: end;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
    min-width: 0;
    overflow-wrap: anywhere;
}

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

.table-card {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.table-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.table-card-title {
    font-size: 1rem;
    line-height: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--gray-900);
}

.table-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-scroll {
    overflow-x: auto;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--gray-900);
    --bs-table-border-color: var(--gray-200);
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table > thead > tr > th {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-600);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 12px 24px;
    white-space: nowrap;
}

.table > tbody > tr > td {
    padding: 16px 24px;
    border-bottom-color: var(--gray-200);
    vertical-align: middle;
    color: var(--gray-600);
}

.table > tbody > tr:last-child > td {
    border-bottom: 0;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: var(--gray-50);
    background-color: var(--gray-50);
    color: var(--gray-600);
}

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

.cell-primary {
    font-weight: 500;
    color: var(--gray-900);
}

a.cell-primary {
    color: var(--gray-900) !important;
}

a.cell-primary:hover {
    color: var(--brand-700) !important;
    text-decoration: none !important;
}

.cell-sub {
    display: inline-block;
    font-size: 0.8125rem;
    color: var(--gray-500);
    line-height: 1.4;
}

/* A sub-line that is a sentence rather than a value — measured so it wraps
   instead of stretching the column it sits in. */
.cell-note {
    max-width: 30rem;
    white-space: normal;
}

.row-attention > td {
    background: var(--error-bg);
}

/* A table nested inside a card — the dense variant used by the module list. */
.table-inset {
    --bs-table-bg: transparent;
    font-size: 0.875rem;
}

.table-inset > thead > tr > th {
    background: transparent;
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-500);
    font-size: 0.75rem;
    font-weight: 500;
}

.table-inset > tbody > tr > td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

.table-inset > tbody > tr:last-child > td {
    border-bottom: 0;
}

/* Identity cell ------------------------------------------------------- */

.identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* §1.1 gives avatars the gray-100 ground, which keeps teal on interaction. */
.avatar {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: var(--r-full);
    display: grid;
    place-items: center;
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-700);
    text-transform: uppercase;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 1.125rem;
}

.identity-body {
    min-width: 0;
}

/* Code chip ----------------------------------------------------------- */

.chip-code {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--r-sm);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

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

/*
 * §3 Badge / status pill: 2px 8px, 6px radius, 12px/500, leading 6px dot.
 * Every pill pairs its colour with a word — status is never signalled by
 * colour alone (§4).
 */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: var(--r-sm);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
    border: 1px solid transparent;
}

.pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: var(--r-full);
    background: currentColor;
    flex: 0 0 auto;
}

.pill-lg {
    font-size: 0.875rem;
    padding: 4px 10px;
}

.pill-success {
    color: var(--success-fg);
    background: var(--success-bg);
    border-color: color-mix(in srgb, var(--success-fg) 20%, transparent);
}

.pill-warning {
    color: var(--warning-fg);
    background: var(--warning-bg);
    border-color: color-mix(in srgb, var(--warning-fg) 20%, transparent);
}

.pill-danger {
    color: var(--error-fg);
    background: var(--error-bg);
    border-color: color-mix(in srgb, var(--error-fg) 20%, transparent);
}

.pill-neutral {
    color: var(--gray-600);
    background: var(--gray-100);
    border-color: var(--gray-200);
}

/*
 * "Invited" is a notice, not a warning — §1.1's Info triplet. Teal never
 * appears on a badge, so this is the informational blue rather than the brand.
 */
.pill-accent {
    color: var(--info-fg);
    background: var(--info-bg);
    border-color: color-mix(in srgb, var(--info-fg) 20%, transparent);
}

/* Stock badges inherit the same language for any markup not updated. */
.badge {
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--r-sm);
    padding: 2px 8px;
}

.badge.text-bg-light {
    background: var(--gray-100) !important;
    color: var(--gray-700) !important;
}

.badge.text-bg-secondary {
    background: var(--gray-100) !important;
    color: var(--gray-700) !important;
}

.badge.text-bg-success {
    background: var(--success-bg) !important;
    color: var(--success-fg) !important;
}

/* ------------------------------------------------------------- controls */

/* §3 Button: 44px lg / 40px md / 36px sm, 8px radius, 14px/600. */
.btn {
    --bs-btn-border-radius: var(--r-md);
    --bs-btn-font-size: 0.875rem;
    --bs-btn-font-weight: 600;
    --bs-btn-padding-x: 16px;
    --bs-btn-padding-y: 10px;
    --bs-btn-line-height: 1.25rem;
    --bs-btn-disabled-opacity: 0.5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}

.btn:focus-visible {
    box-shadow: var(--focus-ring);
}

.btn-sm {
    --bs-btn-font-size: 0.875rem;
    --bs-btn-padding-x: 12px;
    --bs-btn-padding-y: 7px;
    --bs-btn-border-radius: var(--r-md);
}

.btn-lg {
    --bs-btn-font-size: 1rem;
    --bs-btn-padding-x: 20px;
    --bs-btn-padding-y: 12px;
    --bs-btn-border-radius: var(--r-md);
}

/* Primary — the only saturated fill in the system, and one per view (§6.2). */
.btn-primary {
    --bs-btn-bg: var(--brand-700);
    --bs-btn-border-color: var(--brand-700);
    --bs-btn-hover-bg: var(--brand-800);
    --bs-btn-hover-border-color: var(--brand-800);
    --bs-btn-active-bg: var(--brand-900);
    --bs-btn-active-border-color: var(--brand-900);
    --bs-btn-disabled-bg: var(--brand-700);
    --bs-btn-disabled-border-color: var(--brand-700);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-700);
    --bs-btn-border-color: var(--gray-300);
    --bs-btn-bg: var(--surface);
    --bs-btn-hover-color: var(--brand-800);
    --bs-btn-hover-bg: var(--brand-50);
    --bs-btn-hover-border-color: var(--gray-300);
    --bs-btn-active-color: var(--brand-900);
    --bs-btn-active-bg: var(--brand-100);
    --bs-btn-active-border-color: var(--gray-300);
    box-shadow: var(--shadow-xs);
}

/* Secondary — white fill, gray-300 border, gray-700 text, shadow-xs (§3). */
.btn-outline-secondary,
.btn-secondary {
    --bs-btn-color: var(--gray-700);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--gray-300);
    --bs-btn-hover-color: var(--gray-900);
    --bs-btn-hover-bg: var(--gray-50);
    --bs-btn-hover-border-color: var(--gray-300);
    --bs-btn-active-color: var(--gray-900);
    --bs-btn-active-bg: var(--gray-100);
    --bs-btn-active-border-color: var(--gray-300);
    box-shadow: var(--shadow-xs);
}

/*
 * A destructive action stays a secondary button — a status colour on a fill
 * is out (§1.1) — but its text carries the consequence.
 */
.btn-outline-danger {
    --bs-btn-color: var(--error-fg);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: color-mix(in srgb, var(--error-fg) 30%, var(--gray-300));
    --bs-btn-hover-color: var(--error-fg);
    --bs-btn-hover-bg: var(--error-bg);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--error-fg) 40%, transparent);
    --bs-btn-active-color: var(--error-fg);
    --bs-btn-active-bg: var(--error-bg);
    --bs-btn-active-border-color: color-mix(in srgb, var(--error-fg) 40%, transparent);
    box-shadow: var(--shadow-xs);
}

.btn-outline-success {
    --bs-btn-color: var(--success-fg);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: color-mix(in srgb, var(--success-fg) 30%, var(--gray-300));
    --bs-btn-hover-color: var(--success-fg);
    --bs-btn-hover-bg: var(--success-bg);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--success-fg) 40%, transparent);
    --bs-btn-active-color: var(--success-fg);
    --bs-btn-active-bg: var(--success-bg);
    --bs-btn-active-border-color: color-mix(in srgb, var(--success-fg) 40%, transparent);
    box-shadow: var(--shadow-xs);
}

.btn-link {
    --bs-btn-color: var(--brand-700);
    --bs-btn-hover-color: var(--brand-800);
    --bs-btn-font-weight: 600;
    text-decoration: none;
}

/* §3 Input: label above at 14/500 gray-700, 6px gap. */
.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    background-color: var(--surface);
    border: 1px solid var(--gray-300);
    color: var(--gray-900);
    border-radius: var(--r-md);
    padding: 10px 14px;
    font-size: 1rem;
    line-height: 1.5rem;
    box-shadow: var(--shadow-xs);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.form-control-sm,
.form-select-sm {
    padding: 8px 12px;
    font-size: 0.875rem;
    line-height: 1.25rem;
    border-radius: var(--r-md);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--surface);
    color: var(--gray-900);
    border-color: var(--brand-700);
    box-shadow: var(--focus-ring);
}

.form-control::placeholder {
    color: var(--gray-500);
}

.form-control:disabled,
.form-select:disabled {
    background-color: var(--gray-50);
    color: var(--gray-500);
}

.form-select {
    --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2398A2B3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m6 9 6 6 6-6'/%3e%3c/svg%3e");
    background-size: 20px 20px;
    padding-inline-end: 42px;
}

.form-text,
.field-hint {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-top: 6px;
}

/* §3 Checkbox: 16×16, 4px radius, brand fill when checked. */
.form-check-input {
    width: 1rem;
    height: 1rem;
    margin-top: 0.25rem;
    border-color: var(--gray-300);
    border-radius: 4px;
}

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

.form-check-input:focus {
    border-color: var(--brand-700);
    box-shadow: var(--focus-ring);
}

.form-check-label {
    font-size: 0.875rem;
    color: var(--gray-700);
    padding-inline-start: 4px;
}

fieldset legend {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* --------------------------------------------------------------- alerts */

.alert {
    border-radius: var(--r-lg);
    border-width: 1px;
    padding: 16px;
    font-size: 0.875rem;
    margin-bottom: 24px;
}

.alert:last-child {
    margin-bottom: 0;
}

.alert-success {
    --bs-alert-color: var(--success-fg);
    --bs-alert-bg: var(--success-bg);
    --bs-alert-border-color: color-mix(in srgb, var(--success-fg) 22%, transparent);
}

.alert-warning {
    --bs-alert-color: var(--warning-fg);
    --bs-alert-bg: var(--warning-bg);
    --bs-alert-border-color: color-mix(in srgb, var(--warning-fg) 22%, transparent);
}

.alert-danger {
    --bs-alert-color: var(--error-fg);
    --bs-alert-bg: var(--error-bg);
    --bs-alert-border-color: color-mix(in srgb, var(--error-fg) 22%, transparent);
}

.alert-info {
    --bs-alert-color: var(--info-fg);
    --bs-alert-bg: var(--info-bg);
    --bs-alert-border-color: color-mix(in srgb, var(--info-fg) 22%, transparent);
}

.alert a {
    color: inherit;
    font-weight: 600;
}

/* ------------------------------------------------------- action panels */

/*
 * A card whose action is destructive or otherwise not routine — the tint
 * carries the warning so the button does not have to shout.
 */
.action-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    background: var(--surface);
    padding: 24px;
    box-shadow: var(--shadow-xs);
}

.action-card-danger {
    border-color: color-mix(in srgb, var(--error-fg) 24%, var(--gray-200));
    background: var(--error-bg);
}

.action-card-danger .action-card-title {
    color: var(--error-fg);
}

.action-card-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
    line-height: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.action-card > p {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-bottom: 20px;
    max-width: 44rem;
}

.action-card-danger > p {
    color: color-mix(in srgb, var(--error-fg) 88%, var(--gray-900));
}

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

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-600);
}

.empty-state-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border-radius: var(--r-md);
    background: var(--brand-50);
    color: var(--brand-700);
}

.empty-state-title {
    color: var(--gray-900);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.empty-state-hint {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin: 0 auto;
    max-width: 26rem;
}

/* ------------------------------------------------------- live indicator */

.live-dot {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.live-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: var(--r-full);
    background: var(--success-fg);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--success-fg) 60%, transparent);
    animation: live-pulse 2.4s ease-out infinite;
}

@keyframes live-pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success-fg) 50%, transparent); }
    70%  { box-shadow: 0 0 0 6px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* --------------------------------------------------------------- panels */

.result-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: var(--r-lg);
    margin-bottom: 20px;
}

.result-icon-success {
    background: var(--success-bg);
    color: var(--success-fg);
}

.result-icon-warning {
    background: var(--warning-bg);
    color: var(--warning-fg);
}

.result-icon-danger {
    background: var(--error-bg);
    color: var(--error-fg);
}

.form-panel {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    padding: 24px;
}

.form-panel + .form-panel {
    margin-top: 24px;
}

.form-panel-head {
    margin-bottom: 20px;
}

.form-panel-head .section-label + p {
    margin: 4px 0 0;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding-top: 24px;
    margin-top: 24px;
    border-top: 1px solid var(--gray-200);
}

/* A form's actions sitting at the foot of a card body, not a panel. */
.card-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

/*
 * Measures. A form is easier to complete when its fields stop at a readable
 * width, so the two widths the console uses are named here rather than typed
 * into a style attribute on each page (§6.1).
 */
.measure-sm { max-width: 32rem; }
.measure-md { max-width: 44rem; }
.measure-center { margin-inline: auto; }

.table-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}

.table-actions form {
    margin: 0;
}

/* --------------------------------------------------------- module lists */

/*
 * The module catalogue, on the company page and the create form. A subcategory
 * is a labelled block inside the card rather than another bordered box — the
 * nesting was three containers deep, and depth is not hierarchy.
 */
.module-group + .module-group {
    margin-top: 32px;
}

.module-group-title {
    font-size: 1.125rem;
    line-height: 1.75rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 12px;
}

.module-subgroup + .module-subgroup {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

/*
 * Subcategories side by side, for a module list that is read-only and so has
 * narrow rows. A list with editable periods keeps the single stacked column —
 * two date fields and a button do not fit beside anything.
 */
.module-subgrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
    gap: 24px 32px;
}

.module-subgrid .module-subgroup,
.module-subgrid .module-subgroup + .module-subgroup {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.module-subgroup-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.module-note {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin: 0;
}

/* The date pair a grant or a period change is edited through. */
.period-fields {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.period-fields .form-control {
    width: 9.5rem;
}

/* A grant row on the create form: checkbox, then its two dates. */
.grant-row {
    display: grid;
    grid-template-columns: minmax(12rem, 1.4fr) repeat(2, minmax(8rem, 1fr));
    gap: 12px;
    align-items: end;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-200);
}

.grant-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.grant-row .form-check {
    margin: 0;
    padding-bottom: 8px;
}

@media (max-width: 767.98px) {
    .grant-row {
        grid-template-columns: 1fr 1fr;
    }

    .grant-row .form-check {
        grid-column: 1 / -1;
        padding-bottom: 0;
    }
}

/* ------------------------------------------------------------- the rail */

/*
 * Below lg the aside is a Bootstrap drawer. Bootstrap's own .offcanvas-lg
 * rules zero the background and the border at lg and above; this sheet is
 * linked after Bootstrap, so the rail's own paint wins there.
 */
.admin-sidebar.offcanvas-lg {
    --bs-offcanvas-width: 280px;
    --bs-offcanvas-bg: var(--surface);
    --bs-offcanvas-border-color: var(--gray-200);
    --bs-offcanvas-padding-x: 0;
    --bs-offcanvas-padding-y: 0;
}

/* ------------------------------------------------- the module catalogue */

/*
 * The company surface's one repeated object: a subcategory on the workspace,
 * a module inside one. Not in §3, so it is built here from the tokens already
 * declared above, as §6.6 requires — it is §3's Card (same surface, border,
 * radius, shadow) with the head, meta and footer rows a catalogue entry needs.
 *
 * The mockup's cards also carry a progress bar, an open-item count and a
 * favourite star. Nothing behind this surface knows any of those, so none of
 * them are drawn. A card reports what the platform actually holds: the module's
 * standing, and whether this person can open it.
 */

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 24px;
}

/*
 * A card is an <a> when it can be entered and a <div> when it cannot, so the
 * base rule assumes neither. Column flex plus the auto margin on .module-card-meta
 * is what keeps the pills and footers of a ragged row aligned with each other
 * instead of stepping down the row behind uneven descriptions.
 */
.module-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    text-decoration: none;
    transition: box-shadow var(--t-fast), border-color var(--t-fast);
}

a.module-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--brand-100);
    text-decoration: none;
}

.module-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.module-card-title {
    font-size: 1rem;
    line-height: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.module-card-desc {
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--gray-600);
    margin: 0;
}

.module-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-block-start: auto;
    padding-block-start: 4px;
}

.module-card-count {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
}

.module-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-block-start: 16px;
    border-block-start: 1px solid var(--gray-200);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--brand-700);
}

.module-card-foot svg {
    flex: 0 0 auto;
}

/* The arrow points the way out, which is the other way round under RTL. */
[dir="rtl"] .module-card-foot svg {
    transform: scaleX(-1);
}

/*
 * Locked: the company does not hold this module, or holds it without this
 * person on it. Muted rather than hidden, because the shape of what exists is
 * itself information — and inert, because the server refuses a direct
 * navigation either way. The lock is paired with a worded pill; state is never
 * signalled by appearance alone (§4).
 */
.module-card-locked {
    background: var(--gray-50);
    box-shadow: none;
}

.module-card-locked .module-card-title {
    color: var(--gray-600);
}

.module-card-locked .icon-tile {
    background: var(--gray-100);
    color: var(--gray-500);
}

.module-card-lock {
    flex: 0 0 auto;
    color: var(--gray-400);
}

/* Reserved: named in the catalogue, holding nothing yet. Dashed, so it reads
   as an outline of something planned rather than a card that failed to load. */
.module-card-soon {
    background: transparent;
    border-style: dashed;
    box-shadow: none;
}

.module-card-soon .module-card-title {
    color: var(--gray-500);
}

/*
 * The filter hides cards and whole sections. Both carry display rules of their
 * own — a grid item and a block — so the attribute needs the weight to win.
 */
.module-card[hidden],
.workspace-section[hidden] {
    display: none !important;
}

/* ---------------------------------------------------------------- toolbar */

/*
 * The row above the grid. Search and status narrow the cards already on the
 * page, and they narrow nothing when scripting is off, which is why every card
 * is rendered server-side rather than fetched.
 */
.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

/*
 * The two controls that actually filter, in one wrapper that ships hidden and
 * is revealed by module-filter.js. One wrapper rather than two hidden controls,
 * so a browser without scripting is shown no half-built row.
 */
.toolbar-live {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    flex: 1 1 auto;
}

.toolbar-live[hidden] {
    display: none;
}

.toolbar-search {
    position: relative;
    flex: 1 1 18rem;
    max-width: 24rem;
}

.toolbar-search .form-control {
    padding-inline-start: 42px;
}

.toolbar-search svg {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 14px;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

.toolbar .form-select {
    width: auto;
    min-width: 10rem;
}

/* --------------------------------------------------------- the rail foot */

/*
 * Pinned below the nav, where §2's sidebar diagram puts Support and Settings.
 * .admin-nav already takes flex: 1 1 auto, so this block needs no positioning
 * of its own to sit at the bottom of a tall rail.
 */
.admin-rail-foot {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border-block-start: 1px solid var(--gray-200);
}

.admin-rail-foot form {
    margin: 0;
}

/*
 * The sign-out controls read as rail items rather than buttons — a rail footed
 * with bordered buttons competes with the nav above it for the same attention,
 * and §6.2 allows one primary per view, which the content already spends.
 */
.admin-rail-action {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 0;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: start;
    transition: background-color var(--t-fast), color var(--t-fast);
}

.admin-rail-action:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.admin-rail-action svg {
    flex: 0 0 auto;
}

/* Ending every other session is not the routine one, and hovers like it. */
.admin-rail-action-danger {
    color: var(--gray-600);
}

.admin-rail-action-danger:hover {
    background: var(--error-bg);
    color: var(--error-fg);
}

/* ------------------------------------------------------------------ brand */

/*
 * The company surface is the one a company's own people look at every day, so
 * it carries the product's own mark rather than the generic icon tile the two
 * internal consoles use. The image is wider than it is tall (the star arc), so
 * it is sized by height and left to find its width, beside the same title and
 * sub-line the consoles set.
 */
.admin-brand-logo {
    display: block;
    width: auto;
    height: 40px;
    flex: 0 0 auto;
}

/* ------------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
    .live-dot::before {
        animation: none;
    }

    /* §4: drop to opacity-only, never to nothing that reads as broken. */
    .admin-nav-link,
    .admin-rail-action,
    .btn,
    .card,
    .module-card,
    .form-control,
    .form-select {
        transition: none;
    }
}


/* ------------------------------------------------------ reminders page (012) */

/*
 * Two screens: the list, and the thread of one reminder. Workspace-only — there
 * is exactly one reminders page and it lives here (FR-025), so no module loads
 * these rules. The toolbar indicator and its sheet are elsewhere, in the shared
 * reminder-indicator.css, because those do render inside modules.
 *
 * Tokens only, per design system §6.1. Three judgement calls worth recording:
 *
 *   Composing is an ACTION, not furniture. The form used to sit permanently in a
 *   340px column beside the list, which made the page look like a form with a
 *   list attached and pushed its own submit button below the fold. It is now
 *   behind one primary button, and the list has the full width.
 *
 *   The thread is a LEDGER, not a chat. Notes can never be edited or deleted
 *   (FR-012, FR-013), so every entry sits on one rail in one column rather than
 *   in opposing bubbles. Opposing bubbles promise a conversation you can take
 *   back, and a thread holding a single note read as a rendering fault.
 *
 *   Unread is never colour alone (§4). It is a brand rail on the row's leading
 *   edge, a heavier name, and a dot with an accessible label — three signals,
 *   any one of which survives on its own.
 */

.reminders-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-block-end: 20px;
}

.reminders-head .page-title,
.reminders-head .page-subtitle {
    margin: 0;
}

.reminders-head .page-subtitle {
    margin-block-start: 4px;
}

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

/*
 * Hidden until asked for. It re-opens by itself when a submission is refused,
 * so the refusals and the text the person typed are never behind a closed
 * panel — that state is decided on the server, which is what keeps it correct
 * with JavaScript unavailable.
 */
.reminder-compose {
    margin-block-end: 20px;
    animation: reminder-compose-in var(--t-med);
}

.reminder-compose[hidden] {
    display: none;
}

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

    to {
        opacity: 1;
        transform: none;
    }
}

.reminder-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.reminder-form .form-field {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
}

/* The note is the substance of a reminder, so it gets the full width under the
   two pickers that qualify it. */
.reminder-form .form-field-wide {
    grid-column: 1 / -1;
}

.reminder-form .form-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-block-start: 16px;
    border-block-start: 1px solid var(--border);
}

@media (max-width: 720px) {
    .reminder-form {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ------------------------------------------------------------------ toolbar */

.reminder-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    border-block-end: 1px solid var(--border);
}

/* Three mutually exclusive options, all visible at once — one click to switch,
   and each is a real address rather than a dropdown's hidden state. */
.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--gray-100);
    border-radius: var(--r-md);
}

.segmented-option {
    padding: 6px 14px;
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--t-fast), color var(--t-fast);
}

.admin-content .segmented-option:hover {
    color: var(--gray-900);
    text-decoration: none;
}

.admin-content .segmented-option.is-active {
    background: var(--surface);
    color: var(--gray-900);
    font-weight: 600;
    box-shadow: var(--shadow-xs);
}

.reminder-module-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reminder-module-filter .form-select {
    min-inline-size: 180px;
}

/* --------------------------------------------------------------- list rows */

.reminder-rows {
    list-style: none;
    margin: 0;
    padding: 0;
}

.reminder-row + .reminder-row {
    border-block-start: 1px solid var(--border);
}

.reminder-row-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    color: inherit;
    text-decoration: none;
    transition: background var(--t-fast);
}

.admin-content .reminder-row-link:hover {
    background: var(--gray-50);
    text-decoration: none;
}

/* Spec 013 FR-024: <vc:avatar> owns the .avatar element now, so this class is a
   wrapper that places the row's avatar and the 36px override moves to the child.
   The rendered size is unchanged — a list row keeps its own size between the
   32px of a roster table and the 40px of the thread. */
.reminder-row-avatar {
    flex: 0 0 auto;
    display: flex;
}

.reminder-row-avatar > .avatar {
    inline-size: 36px;
    block-size: 36px;
    font-size: 0.8125rem;
}

.reminder-row-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-inline-size: 0;
    flex: 1 1 auto;
}

.reminder-row-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.reminder-row-name {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--gray-900);
}

/* Whose thread it is matters more than which way it went, so the direction is
   the quieter half of the line. */
.reminder-direction {
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.reminder-row-preview {
    font-size: 0.875rem;
    color: var(--gray-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reminder-row-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.reminder-row-time {
    font-size: 0.8125rem;
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Unread, signalled three ways so none of them is load-bearing alone. */
.reminder-row.is-unread .reminder-row-link::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    inline-size: 3px;
    background: var(--brand-700);
}

.reminder-row.is-unread .reminder-row-name {
    font-weight: 600;
}

.reminder-row.is-unread .reminder-row-preview {
    color: var(--gray-700);
}

.reminder-unread-dot {
    flex-shrink: 0;
    inline-size: 8px;
    block-size: 8px;
    border-radius: var(--r-full);
    background: var(--brand-700);
}

/* ------------------------------------------------------------------- pager */

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    border-block-start: 1px solid var(--border);
}

.pager-status,
.pager-page {
    font-size: 0.8125rem;
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
}

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

/* ------------------------------------------------------ one reminder: thread */

/*
 * A reading measure, not the full width of the workspace. The old full-bleed
 * layout left one short note stranded in a field of white and made the reply box
 * look like the page's main event.
 */
.reminder-detail {
    max-inline-size: 760px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-block-end: 12px;
    font-size: 0.8125rem;
    color: var(--gray-500);
    text-decoration: none;
}

.admin-content .back-link:hover {
    color: var(--gray-900);
    text-decoration: none;
}

.reminder-detail-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-block-end: 20px;
}

.reminder-detail-head .page-title {
    margin: 0;
}

.reminder-detail-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 0;
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.reminder-notes {
    list-style: none;
    margin: 0;
    padding: 20px 20px 4px;
}

/*
 * THE RAIL. One hairline down the thread with each note's avatar sitting on it
 * as a node, so order is carried by the structure and every entry only has to
 * say who and when. It stops at the last note rather than running into the reply
 * box, because the box is not an entry in the record.
 */
.reminder-note {
    position: relative;
    display: flex;
    gap: 14px;
    padding-block-end: 20px;
}

.reminder-note::before {
    content: "";
    position: absolute;
    inset-block-start: 32px;
    inset-block-end: 0;
    inset-inline-start: 15px;
    inline-size: 2px;
    background: var(--gray-200);
}

.reminder-note:last-child {
    padding-block-end: 8px;
}

.reminder-note:last-child::before {
    display: none;
}

.reminder-note-node {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    inline-size: 32px;
    block-size: 32px;
    border-radius: var(--r-full);
    display: grid;
    place-items: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-100);
    box-shadow: 0 0 0 3px var(--surface);
}

/* The viewer's own entries are tinted, not moved. Same column, same order. */
.reminder-note.is-mine .reminder-note-node {
    background: var(--brand-100);
    color: var(--brand-900);
}

.reminder-note-body {
    min-inline-size: 0;
    flex: 1 1 auto;
    padding-block-start: 4px;
}

.reminder-note-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 4px;
}

.reminder-note-author {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-900);
}

.reminder-note-time {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
}

.reminder-note-text {
    margin: 0;
    color: var(--gray-700);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------ one reminder: reply */

.reminder-reply {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 20px 20px;
    border-block-start: 1px solid var(--border);
    background: var(--gray-50);
    border-end-start-radius: var(--r-lg);
    border-end-end-radius: var(--r-lg);
}

.reminder-reply-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-block-start: 4px;
}

.reminder-reply-foot .field-hint {
    margin: 0;
    font-size: 0.8125rem;
}

/* §4: honour reduced motion by dropping to opacity-only transitions. */
@media (prefers-reduced-motion: reduce) {

    .segmented-option,
    .reminder-row-link {
        transition: none;
    }

    .reminder-compose {
        animation: none;
    }
}

/* ================================================================= profile
   Spec 013, in the EnergyUp cards (docs/cbam/profile-prototype.html). The page
   links erp-ui.css and the form sheet's stylesheet for itself, so the cbam-ov
   parts it reads are the kit's; what is here is only the page's own
   arrangement. Kit tokens only, logical properties throughout. */

/* Who you are on the left, where you work on the right — the width the old
   46rem measure left empty is where the modules go. One column below lg, the
   identity card first. */
.profile-layout {
    display: grid;
    grid-template-columns: minmax(18rem, 22rem) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 991.98px) {
    .profile-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* The answer to "is this me?": the page's only oversized avatar, the name, and
   the address it signs in with. */
.profile-me {
    display: grid;
    justify-items: center;
    gap: .5rem;
    margin-block-start: 1.25rem;
    text-align: center;
}

.profile-me-name {
    margin: .25rem 0 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.75rem;
    color: var(--gray-900);
    overflow-wrap: anywhere;
}

.profile-layout .cbam-ov-ledger {
    margin-block-start: 1.25rem;
    padding-block-start: 1rem;
    border-block-start: 1px solid var(--border);
}

/* The ledger's 11rem label column is sized for a full-width card; in a 20rem
   one it leaves the value a sliver, so a role badge runs off the card and a
   one-line hint stacks five deep. The labels here are a word or two. */
.profile-layout .cbam-ov-ledger > div {
    grid-template-columns: minmax(5rem, 7rem) minmax(0, 1fr);
}

/* Two module cards a row beside the identity card; the set's own 26rem minimum
   would leave one. */
.profile-work {
    display: grid;
    gap: 1.5rem;
    min-inline-size: 0;
}

.profile-work .cbam-ov-section-head {
    margin: 0;
}

.profile-work .cbam-ov-cards {
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
}

/* The catalogue's glyph is drawn at 24px for the Modules page's tiles; in the
   circle it takes the circle's own icon size. */
.profile-work .cbam-ov-circle svg {
    inline-size: 1.25rem;
    block-size: 1.25rem;
}

/* The kit's .form-row bottom-aligns, which levels a button with the boxes
   beside it; two boxes that each carry their own refusal want the top instead,
   or the error under one pushes its neighbour down a line. */
.profile-name-row {
    align-items: flex-start;
}

/* The photo step: what is on file now, beside the box that replaces it. */
.profile-photo-now {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-block-end: 1rem;
    font-size: .875rem;
    color: var(--gray-600);
}

/* One role name. Neutral, because a role is a fact about somebody rather than a
   state to react to, and because nothing on this page acts on it. */
.role-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--r-sm);
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: nowrap;
}
