/* =============================================================================
   Settings > Modules (19 Oct 2026). AM look, every brand colour from the
   theme (--am-blue*, --accent), so all themes in Branding reach it.
   ============================================================================= */

.mx-page { --mx-line: var(--border-default); --mx-ink: var(--text-primary); --mx-muted: var(--text-secondary); --mx-faint: var(--text-muted); }
.mx-loading { margin: 24px 28px; font-size: 13.5px; color: var(--mx-muted); }

/* ---- Header with counts ------------------------------------------------------ */
.mx-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 22px 28px 6px; flex-wrap: wrap; }
.mx-header__text { flex: 1 1 420px; min-width: 0; }
.mx-header__title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; color: var(--mx-ink); }
.mx-header__description { margin: 4px 0 0; max-width: 760px; font-size: 13.5px; line-height: 1.5; color: var(--mx-muted); }
.mx-stats { display: flex; gap: 8px; flex: none; }
.mx-stat {
    min-width: 92px; padding: 8px 12px; border: 1px solid var(--mx-line); border-radius: var(--radius-medium); background: var(--surface-panel);
    display: flex; flex-direction: column; gap: 1px;
}
.mx-stat strong { font-size: 18px; font-weight: 700; color: var(--am-blue, #19213b); line-height: 1.2; }
.mx-stat span { font-size: 11.5px; color: var(--mx-muted); }
.mx-stat--soon { border-style: dashed; }

.mx-notice {
    display: flex; align-items: center; gap: 8px; margin: 12px 28px 0; padding: 10px 14px;
    border: 1px solid var(--status-danger); border-radius: var(--radius-medium); background: var(--status-danger-tint); color: var(--status-danger); font-size: 13px;
}

/* ---- Toolbar: quick views, search, count -------------------------------------- */
.mx-toolbar { display: flex; align-items: center; gap: 12px; margin: 14px 28px 0; padding-bottom: 14px; border-bottom: 1px solid var(--mx-line); flex-wrap: wrap; }
.mx-views { display: flex; gap: 6px; flex-wrap: wrap; }
.mx-view { height: 30px; }
/* The AM list search (form-field__control invoice-search); only its place here. */
.mx-search { flex: 0 1 300px; width: auto; min-width: 200px; margin-left: auto; }
.mx-count { font-size: 12.5px; color: var(--mx-faint); white-space: nowrap; }

/* ---- Layout: categories on the left, cards on the right ------------------------- */
.mx-body { padding: var(--content-gap-top) 28px 28px; }
.mx-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.mx-rail { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.mx-rail__item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 8px 10px;
    border: 0; border-radius: 6px; background: none; cursor: pointer; text-align: left; font: inherit; font-size: 13.5px; color: var(--mx-muted);
}
.mx-rail__item:hover { background: var(--am-blue-tint, #f4f5fa); color: var(--mx-ink); }
.mx-rail__item--on { background: var(--am-blue-soft, #e6e9f2); color: var(--am-blue, #19213b); font-weight: 600; }
.mx-rail__item:focus-visible { outline: none; box-shadow: var(--am-focus); }
.mx-rail__count { min-width: 22px; padding: 1px 6px; border-radius: 10px; background: var(--surface-panel); font-size: 11.5px; font-weight: 600; text-align: center; color: var(--mx-muted); }
.mx-rail__item--on .mx-rail__count { color: var(--am-blue, #19213b); }

.mx-content { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.mx-group__heading { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.mx-group__name { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mx-muted); }
.mx-group__count { padding: 0 7px; border-radius: 10px; background: var(--am-blue-soft, #e6e9f2); font-size: 11px; font-weight: 700; color: var(--am-blue, #19213b); }
.mx-content { container-type: inline-size; }
/* Three cards a row (24 Oct 2026), two when the content area is narrow, one on a phone. */
.mx-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@container (max-width: 1080px) { .mx-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container (max-width: 760px) { .mx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 480px) { .mx-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---- Card --------------------------------------------------------------------- */
/* The same card as Connected Apps (integrations.css .app-card): one soft grey
   face and one dark tile for every module, whatever the theme. Only the
   buttons follow the theme. */
.mx-card {
    display: flex; flex-direction: column; gap: 12px; padding: 16px; min-width: 0;
    border: 1px solid var(--border-default, #e8ebed); border-radius: var(--radius-large, 5px);
    background: var(--surface-app-card, #f8f8f8);
    transition: border-color .15s ease;
}
.mx-card:hover { border-color: var(--border-strong, #d5dadf); }
.mx-card__head { display: flex; align-items: center; gap: 11px; }
.mx-card__icon {
    flex: 0 0 40px; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-medium, 5px); background: var(--surface-app-mark, #3d3d3e); color: #fff;
}
.mx-card__identity { flex: 1; min-width: 0; }
.mx-card__name { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--mx-ink); line-height: 1.3; }
.mx-card__group { font-size: 12px; color: var(--mx-faint); }
.mx-card__description { margin: 0; flex: 1; font-size: 13px; line-height: 1.5; color: var(--mx-muted); }
.mx-card__actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* Equal widths, but never narrower than the label: a third button wraps. */
.mx-card__actions .am-btn { flex: 1 1 0; min-width: fit-content; justify-content: center; min-height: 32px; }
/* The quiet button is white with a grey edge, like Details on Connected Apps;
   the primary one carries the theme. */
.mx-card__actions .am-btn--soft { background: var(--surface-panel); color: var(--text-secondary, #43484f); box-shadow: inset 0 0 0 1px var(--border-strong, #d5dadf); }
.mx-card__actions .am-btn--soft:hover { background: var(--surface-subtle); color: var(--text-primary, #101828); }

/* Not installed or not in the plan: present, quieter. */
/* One tile shade for every card: the pill says installed or not. */

/* Coming soon: dashed, a soft tinted face, and only Preview. */
.mx-card--soon { border-style: dashed; }
.mx-card--soon:hover { box-shadow: none; }

/* ---- Pills --------------------------------------------------------------------- */
.mx-pill { flex: none; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.mx-pill--green { background: var(--status-success-tint); color: var(--status-success); }
.mx-pill--navy { background: var(--am-blue-soft, #e6e9f2); color: var(--am-blue, #19213b); }
.mx-pill--grey { background: var(--status-neutral-tint); color: var(--mx-muted); }
.mx-pill--outline { background: var(--surface-panel); color: var(--mx-muted); box-shadow: inset 0 0 0 1px var(--mx-line); }
.mx-pill--soon { background: var(--am-blue, #19213b); color: #fff; }

/* The About panel's pill for a coming-soon module. */
.mod-showcase__pill--soon { background: var(--am-blue, #19213b); color: #fff; }

/* ---- Sub-modules (19 Oct 2026) -------------------------------------------------- */
/* The "+N sub-modules" chip on a parent's card. The hit area reaches past the
   chip so it is an easy tap without looking heavy. */
.mx-card__subs {
    position: relative; align-self: flex-start; display: inline-flex; align-items: center; gap: 5px;
    height: 26px; margin-top: -4px; padding: 0 10px; border: 0; border-radius: var(--radius-button); cursor: pointer;
    background: var(--am-blue-soft, #e6e9f2); color: var(--am-blue, #19213b);
    font: inherit; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.mx-card__subs::before { content: ''; position: absolute; inset: -8px -4px; }
.mx-card__subs:hover { box-shadow: inset 0 0 0 1px var(--am-blue, #19213b); }
.mx-card__subs:focus-visible { outline: none; box-shadow: var(--am-focus); }

/* The section in the About panel. The panel sits outside .mx-page, so the
   page's ink colours are set again here. */
.mx-subs { --mx-line: var(--border-default); --mx-ink: var(--text-primary); --mx-muted: var(--text-secondary); --mx-faint: var(--text-muted); margin: 18px 0 4px; scroll-margin-top: 12px; }
.mx-subs__lead { margin: 0 0 10px; font-size: 13px; line-height: 1.5; color: var(--text-secondary, var(--mx-muted)); }
.mx-subs__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mx-sub {
    display: flex; align-items: center; gap: 12px; padding: 12px; min-width: 0;
    border: 1px solid var(--border-default, #e8ebed); border-radius: var(--radius-large, 5px);
    background: var(--surface-app-card, #f8f8f8);
}
.mx-sub--soon { border-style: dashed; }
.mx-sub__icon {
    flex: 0 0 34px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-medium, 5px); background: var(--surface-app-mark, #3d3d3e); color: #fff;
}
.mx-sub__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mx-sub__name { font-size: 13.5px; font-weight: 700; line-height: 1.35; color: var(--text-primary, var(--mx-ink)); }
.mx-sub__description { font-size: 12.5px; line-height: 1.45; color: var(--text-secondary, var(--mx-muted)); }
.mx-sub__hint { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--am-blue, #19213b); }
.mx-sub__action { flex: none; display: flex; }
.mx-sub__action .am-btn { min-width: 96px; min-height: 34px; justify-content: center; }
.mx-sub__action .am-btn--soft { background: var(--surface-panel); color: var(--text-secondary, #43484f); box-shadow: inset 0 0 0 1px var(--border-strong, #d5dadf); }
.mx-sub__action .am-btn--soft:hover:not(:disabled) { background: var(--surface-subtle); color: var(--text-primary, #101828); }
.mx-sub__action .am-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---- Empty -------------------------------------------------------------------- */
.mx-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 56px 16px; text-align: center; color: var(--mx-muted); font-size: 13px; }
.mx-empty strong { font-size: 15px; color: var(--mx-ink); }
.mx-empty__icon { width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--am-blue-soft, #e6e9f2); color: var(--am-blue, #19213b); }

/* ---- Small screens ------------------------------------------------------------ */
@media (max-width: 900px) {
    .mx-layout { grid-template-columns: minmax(0, 1fr); }
    .mx-rail { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
    .mx-rail::-webkit-scrollbar { display: none; }
    .mx-rail__item { width: auto; flex: none; }
}
@media (max-width: 640px) {
    .mx-header, .mx-body { padding-left: 16px; padding-right: 16px; }
    .mx-toolbar, .mx-notice { margin-left: 16px; margin-right: 16px; }
    .mx-search { flex: 1 1 100%; margin-left: 0; }
    .mx-stats { width: 100%; }
    .mx-stat { flex: 1; min-width: 0; }
}
/* Sub-module rows stack: icon and words, then the pill, then a full-width
   button with a 40px tap target. */
@media (max-width: 560px) {
    .mx-sub { flex-wrap: wrap; align-items: flex-start; }
    .mx-sub__text { flex: 1 1 calc(100% - 46px); }
    .mx-sub__pill { margin-left: 46px; }
    .mx-sub__action { flex: 1 1 100%; }
    .mx-sub__action .am-btn { width: 100%; min-height: 40px; }
    .mx-card__subs { height: 28px; }
}

/* ---- RM-090: Agent Meeko on a module ------------------------------------------
   The badge on a card says how far Meeko may go in that module and opens its
   Agent Meeko tab. Same shape as the sub-modules chip beside it. */
.mx-meeko-badge {
    position: relative; align-self: flex-start; display: inline-flex; align-items: center; gap: 5px;
    height: 26px; margin-top: -4px; padding: 0 10px; border: 0; border-radius: var(--radius-button);
    cursor: pointer; background: var(--am-blue-soft); color: var(--am-blue);
    font: inherit; font-size: var(--font-size-small); font-weight: 600; white-space: nowrap;
}
.mx-meeko-badge::before { content: ''; position: absolute; inset: -8px -4px; }
.mx-meeko-badge:hover { box-shadow: inset 0 0 0 1px var(--am-blue); }
.mx-meeko-badge:focus-visible { outline: none; box-shadow: var(--am-focus); }
.mx-meeko-badge--off { background: var(--surface-subtle); color: var(--text-secondary); }

/* About and Agent Meeko tabs in a module's panel. */
.mx-tabs__strip { margin: -4px 0 18px; }
.mx-tabs__strip .record-tab { display: inline-flex; align-items: center; gap: 6px; }
.mx-tabs__pane[hidden] { display: none; }

/* A module that is not installed: what Meeko could do there, as a quieter badge. */
.mx-meeko-badge--preview { background: var(--surface-panel); color: var(--text-secondary); box-shadow: inset 0 0 0 1px var(--border-strong); }

/* RM-092: when a coming-soon module is expected, under its description. */
.mx-card__release {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    height: 26px;
    padding: 0 9px;
    border-radius: var(--radius-button);
    background: var(--surface-subtle);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

/* RM-105: a module's own Settings tab. */
.mx-setting__title { margin: 4px 0 10px; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.mx-setting { padding: 14px 16px; border: 1px solid var(--border-subtle); border-radius: 5px; background: var(--surface-panel); }
.mx-setting + .mx-setting { margin-top: 10px; }
.mx-setting__hint { margin: 6px 0 0 50px; font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }
@media (max-width: 560px) { .mx-setting__hint { margin-left: 0; } }
