/* ─────────────────────────────────────────────────────────────
   Animated CLASH MATRIX — used both by the marketing mockup
   (HomeV3 RULES pillar) and the live editable matrix in the
   ClashMatrix page.

   Generalised over N disciplines via --cw3-mxmock-n
   (defaults to 8 for the marketing mockup).
   ───────────────────────────────────────────────────────────── */

.cw3-mxmock {
    --cw3-mxmock-n: 8;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(180deg, #0F1218 0%, #0A0C10 100%);
    border: 1px solid var(--cw3-line);
    border-radius: 8px;
    overflow: hidden;
    filter: none;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 12px 30px rgba(0, 0, 0, 0.5);
}

/* Live mode: stretch to fill the parent so the body's overflow:auto
   actually has a constrained box to scroll inside. */
.cw3-matrix-grid {
    height: 100%;
    min-height: 0;
    min-width: 0;
}

.cw3-mxmock-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    min-width: 0;
}

.cw3-mxmock-head-l { min-width: 0; }

.cw3-mxmock-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    letter-spacing: 0.10em;
    color: var(--cw3-text-3);
}

.cw3-mxmock-title {
    margin-top: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--cw3-text);
    line-height: 1.35;
}

.cw3-mxmock-num {
    font-weight: 600;
    color: var(--pillar-accent, var(--cw3-mech));
    margin-right: 4px;
}

.cw3-mxmock-name { color: var(--cw3-text-2); }

.cw3-mxmock-legend {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px 14px;
    max-width: 60%;
    font-size: 11.5px;
    letter-spacing: 0.06em;
    color: var(--cw3-text-3);
    line-height: 1.4;
}

.cw3-mxmock-legend-group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
}

.cw3-mxmock-legend-group--status {
    padding-left: 12px;
    border-left: 1px solid var(--cw3-line);
    color: var(--cw3-text-2);
}

.cw3-mxmock-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cw3-mxmock-legend-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border: 1px solid var(--cw3-line);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--cw3-text);
    font-size: 10px;
    font-weight: 600;
    font-style: normal;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.cw3-mxmock-sw {
    width: 11px;
    height: 11px;
    border-radius: 2px;
    flex-shrink: 0;
    display: inline-block;
}

.cw3-mxmock-sw--crit { background: var(--cw3-clash); }
.cw3-mxmock-sw--high { background: var(--cw3-struct); }
.cw3-mxmock-sw--mod  { background: var(--cw3-plumb); }
.cw3-mxmock-sw--low  { background: var(--cw3-mech); }
.cw3-mxmock-sw--info { background: var(--cw3-success); }
/* Fallback for custom priorities without a recognised name and no Color set. */
.cw3-mxmock-sw--custom { background: var(--cw3-line-2); border: 1px solid var(--cw3-line); }

.cw3-mxmock-body {
    position: relative;
    display: grid;
    grid-template-columns: 110px 1fr;
    grid-template-rows: 22px 1fr;
    gap: 4px;
    min-height: 0;
    overflow: auto;
}

.cw3-mxmock-corner {
    grid-row: 1;
    grid-column: 1;
    position: sticky;
    top: 0;
    left: 0;
    z-index: 4;
    background: linear-gradient(180deg, #0F1218 0%, #0A0C10 100%);
}

.cw3-mxmock-axis {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--cw3-text);
    font-weight: 500;
    display: grid;
}

.cw3-mxmock-axis--x {
    grid-row: 1;
    grid-column: 2;
    grid-template-columns: repeat(var(--cw3-mxmock-n, 8), 48px);
    /* Match the grid's internal padding + column gap so labels align with cells. */
    column-gap: 2px;
    padding: 0 3px;
    position: sticky;
    top: 0;
    z-index: 3;
    background: linear-gradient(180deg, #0F1218 0%, #0A0C10 100%);
}

.cw3-mxmock-axis--x li {
    text-align: center;
    align-self: end;
    padding-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cw3-mxmock-axis--y {
    grid-row: 2;
    grid-column: 1;
    grid-template-rows: repeat(var(--cw3-mxmock-n, 8), 48px);
    /* Match the grid's row gap + vertical padding so labels align with rows. */
    row-gap: 2px;
    padding: 3px 0;
    align-items: center;
    position: sticky;
    left: 0;
    z-index: 3;
    background: linear-gradient(180deg, #0F1218 0%, #0A0C10 100%);
}

.cw3-mxmock-axis--y li {
    text-align: right;
    padding-right: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cw3-mxmock-grid {
    grid-row: 2;
    grid-column: 2;
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--cw3-mxmock-n, 8), 48px);
    grid-template-rows: repeat(var(--cw3-mxmock-n, 8), 48px);
    gap: 2px;
    background: rgba(255, 255, 255, 0.012);
    border: 1px solid var(--cw3-line);
    border-radius: 4px;
    padding: 2px;
}

.cw3-mxmock-cell {
    background-color: var(--cw3-line-2);
    border-radius: 1.5px;
    opacity: 0.18;
    transform: scale(0.7);
    position: relative;
    /* button reset — used for live-mode keyboard a11y */
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    appearance: none;
    -webkit-appearance: none;
    background-image: none;
    cursor: default;
    box-shadow: none;
    outline: none;
}

.cw3-mxmock-cell--crit { background-color: var(--cw3-clash); }
.cw3-mxmock-cell--high { background-color: var(--cw3-struct); }
.cw3-mxmock-cell--mod  { background-color: var(--cw3-plumb); }
.cw3-mxmock-cell--low  { background-color: var(--cw3-mech); }
.cw3-mxmock-cell--info { background-color: var(--cw3-success); }
.cw3-mxmock-cell--na   { background-color: rgba(255, 255, 255, 0.06); }

.cw3-mxmock.is-visible .cw3-mxmock-cell {
    animation: cw3-mxcell-in 0.55s ease forwards;
    animation-delay: var(--cw3-mx-delay, 0s);
}

@keyframes cw3-mxcell-in {
    0%   { opacity: 0.05; transform: scale(0.65); }
    65%  { opacity: 1;    transform: scale(1.06); }
    100% { opacity: 0.92; transform: scale(1); }
}

.cw3-mxmock-cell--diag {
    background-color: transparent;
    opacity: 0.35;
}

.cw3-mxmock-cell--diag::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        45deg,
        var(--cw3-line) 0,
        var(--cw3-line) 1px,
        transparent 1px,
        transparent 4px
    );
    border-radius: 1.5px;
}

.cw3-mxmock.is-visible .cw3-mxmock-cell--crit {
    animation:
        cw3-mxcell-in 0.55s ease var(--cw3-mx-delay) forwards,
        cw3-mxcell-pulse 2.4s ease-in-out calc(var(--cw3-mx-delay) + 0.7s) infinite;
}

@keyframes cw3-mxcell-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(244, 63, 94, 0.4); }
    50%      { box-shadow: 0 0 11px rgba(244, 63, 94, 0.85); }
}

.cw3-mxmock-scan {
    pointer-events: none;
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        transparent 38%,
        rgba(34, 211, 238, 0.18) 48%,
        rgba(34, 211, 238, 0.34) 50%,
        rgba(34, 211, 238, 0.18) 52%,
        transparent 62%,
        transparent 100%
    );
    background-size: 220% 100%;
    background-position: -110% 0;
    mix-blend-mode: screen;
    opacity: 0;
}

.cw3-mxmock.is-visible .cw3-mxmock-scan {
    animation: cw3-mxscan 6.4s cubic-bezier(0.65, 0, 0.35, 1) 2.4s infinite;
}

@keyframes cw3-mxscan {
    0%   { background-position: -110% 0; opacity: 0; }
    8%   { opacity: 0.85; }
    72%  { opacity: 0.85; }
    100% { background-position: 220% 0; opacity: 0; }
}

.cw3-mxmock-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-top: 6px;
    font-size: 9.5px;
    letter-spacing: 0.08em;
    color: var(--cw3-text-3);
    border-top: 1px solid var(--cw3-line);
}

.cw3-mxmock-foot-num { color: var(--cw3-text-2); }

.cw3-mxmock-foot-r {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

@media (prefers-reduced-motion: reduce) {
    .cw3-mxmock.is-visible .cw3-mxmock-cell {
        animation: none;
        opacity: 0.92;
        transform: scale(1);
    }
    .cw3-mxmock.is-visible .cw3-mxmock-cell--crit {
        animation: none;
        box-shadow: 0 0 6px rgba(244, 63, 94, 0.5);
    }
    .cw3-mxmock.is-visible .cw3-mxmock-scan { animation: none; opacity: 0; }
}

@media (max-width: 720px) {
    .cw3-mxmock-head { flex-direction: column; }
    .cw3-mxmock-legend { max-width: 100%; justify-content: flex-start; }
    .cw3-mxmock-body { grid-template-columns: 48px 1fr; }
    .cw3-mxmock-axis--y li { padding-right: 6px; }
}

/* ─────────────────────────────────────────────────────────────
   Live-mode additions — only active when the matrix is rendered
   inside a .cw3-matrix-grid wrapper (the live ClashMatrix page,
   not the marketing mockup).
   ───────────────────────────────────────────────────────────── */

.cw3-matrix-grid .cw3-mxmock-cell {
    /* Live mode skips the staggered entry animation — feels marketing-y
       in a working tool. Steady-state opacity is driven by --cw3-mx-fill
       (rule-count intensity). */
    opacity: var(--cw3-mx-fill, 0.92);
    transform: scale(1);
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.25s ease;
}

.cw3-matrix-grid .cw3-mxmock-cell:not(.cw3-mxmock-cell--na):not([disabled]) {
    cursor: pointer;
}

.cw3-matrix-grid .cw3-mxmock-cell:not(.cw3-mxmock-cell--na):not([disabled]):hover {
    transform: scale(1.06);
    box-shadow: 0 0 0 1px var(--cw3-mech), 0 0 14px rgba(34, 211, 238, 0.4);
    z-index: 2;
}

.cw3-matrix-grid .cw3-mxmock-cell:focus-visible {
    outline: 2px solid var(--cw3-mech);
    outline-offset: 1px;
}

.cw3-matrix-grid .cw3-mxmock-cell--missing-contact::before {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--cw3-clash);
    box-shadow: 0 0 4px var(--cw3-clash);
    z-index: 2;
}

/* In-cell status order number — toggled on by the toolbar switch. Shows
   the dominant status's 1-based DisplayOrder so the user can read triage
   progression at a glance (e.g. "1" = untriaged, higher = further along).
   The number sits centred over the cell colour with a soft text shadow so
   it stays legible against any priority hue. */
.cw3-mxmock-cell-num {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7), 0 0 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    user-select: none;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
}
.cw3-matrix-grid--show-status-order .cw3-mxmock-cell-num {
    display: flex;
}
.cw3-matrix-grid--compact .cw3-mxmock-cell-num {
    font-size: 8px;
}

.cw3-matrix-grid .cw3-mxmock-cell--self-discipline {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.cw3-matrix-grid--locked .cw3-mxmock-cell { cursor: not-allowed; }
.cw3-matrix-grid--locked .cw3-mxmock-cell:hover {
    transform: none;
    box-shadow: none;
}

/* Stair-step triangular layout (live mode only). Y labels live INSIDE the
   cell grid, each in the column directly before its row's first cell, so
   they run diagonally and stay flush against the data. The X axis gets a
   leading spacer slot so its labels still line up with the cell columns. */
.cw3-matrix-grid .cw3-mxmock-body {
    grid-template-columns: 1fr;
    grid-template-rows: 22px 1fr;
}
.cw3-matrix-grid .cw3-mxmock-axis--x {
    grid-row: 1;
    grid-column: 1;
    grid-template-columns: var(--cw3-mxmock-y-width, 180px) repeat(var(--cw3-mxmock-n, 8), 48px);
}
.cw3-matrix-grid .cw3-mxmock-grid {
    grid-row: 2;
    grid-column: 1;
    grid-template-columns: var(--cw3-mxmock-y-width, 180px) repeat(var(--cw3-mxmock-n, 8), 48px);
    grid-template-rows: repeat(var(--cw3-mxmock-n, 8), 48px);
}
.cw3-matrix-grid--compact .cw3-mxmock-axis--x {
    grid-template-columns: var(--cw3-mxmock-y-width, 140px) repeat(var(--cw3-mxmock-n, 8), 22px);
}
.cw3-matrix-grid--compact .cw3-mxmock-grid {
    grid-template-columns: var(--cw3-mxmock-y-width, 140px) repeat(var(--cw3-mxmock-n, 8), 22px);
    grid-template-rows: repeat(var(--cw3-mxmock-n, 8), 22px);
}

.cw3-matrix-grid .cw3-mxmock-axis-spacer {
    list-style: none;
}

.cw3-matrix-grid .cw3-mxmock-y-label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 4px;
    padding-right: 8px;
    font-size: 10px;
    color: var(--cw3-text);
    font-weight: 500;
    letter-spacing: 0.06em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-width: 0;
}
.cw3-matrix-grid--compact .cw3-mxmock-y-label {
    font-size: 8px;
    padding-left: 2px;
    padding-right: 4px;
}

/* Currently-active cell — the one whose popover is open. Stays bold even when
   the search/dim filter is on, so the user always knows what they're editing. */
.cw3-matrix-grid .cw3-mxmock-cell--selected,
.cw3-matrix-grid--searching .cw3-mxmock-cell--selected {
    opacity: 1 !important;
    filter: none !important;
    transform: scale(1.12) !important;
    box-shadow:
        0 0 0 2px var(--cw3-text),
        0 0 0 4px var(--cw3-mech),
        0 0 18px rgba(34, 211, 238, 0.7);
    z-index: 4;
    animation: cw3-mxcell-selected-pulse 1.6s ease-in-out infinite;
}

@keyframes cw3-mxcell-selected-pulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--cw3-text), 0 0 0 4px var(--cw3-mech), 0 0 18px rgba(34, 211, 238, 0.5); }
    50%      { box-shadow: 0 0 0 2px var(--cw3-text), 0 0 0 4px var(--cw3-mech), 0 0 26px rgba(34, 211, 238, 0.85); }
}

/* Search highlighting — matches glow, non-matches fade. */
.cw3-matrix-grid--searching .cw3-mxmock-cell--search-dim {
    opacity: 0.12 !important;
    filter: saturate(0.4);
}
.cw3-matrix-grid--searching .cw3-mxmock-cell--search-match {
    opacity: 1 !important;
    box-shadow:
        0 0 0 1.5px var(--cw3-mech),
        0 0 14px rgba(34, 211, 238, 0.55),
        0 0 22px rgba(34, 211, 238, 0.25);
    z-index: 2;
}
.cw3-matrix-grid--searching .cw3-mxmock-cell--search-match:hover {
    transform: scale(1.08);
    box-shadow:
        0 0 0 2px var(--cw3-mech),
        0 0 22px rgba(34, 211, 238, 0.7),
        0 0 28px rgba(34, 211, 238, 0.35);
}

/* Compact density — Excel-style small cells. Fixed-size tracks (not 1fr)
   so cells truly compress regardless of available width. The leading
   column is sized for the Y labels, not for a cell. */
.cw3-matrix-grid--compact .cw3-mxmock-axis--x {
    grid-template-columns: var(--cw3-mxmock-y-width, 140px) repeat(var(--cw3-mxmock-n, 8), 22px);
    column-gap: 1px;
    padding: 0 3px;
}
.cw3-matrix-grid--compact .cw3-mxmock-grid {
    grid-template-columns: var(--cw3-mxmock-y-width, 140px) repeat(var(--cw3-mxmock-n, 8), 22px);
    grid-template-rows: repeat(var(--cw3-mxmock-n, 8), 22px);
    gap: 1px;
}
.cw3-matrix-grid--compact .cw3-mxmock-cell {
    border-radius: 1px;
}
.cw3-matrix-grid--compact .cw3-mxmock-axis {
    font-size: 8px;
}
.cw3-matrix-grid--compact .cw3-mxmock-axis--x li { padding-bottom: 2px; }
.cw3-matrix-grid--compact .cw3-mxmock-axis--y li { padding-right: 4px; }

.cw3-matrix-grid-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

/* ─────────────────────────────────────────────────────────────
   Cell quick-edit popover.
   ───────────────────────────────────────────────────────────── */

/* Token fallback for the popover. When the popover is portaled to <body>
   to escape ancestor stacking-contexts, it's no longer inside .cw3 and
   would lose all the custom properties the card/inputs reference. Restate
   them here so the dark theme renders identically wherever the element
   ends up. */
.cw3-matrix-cell-popover-overlay,
.cw3-matrix-popover-card {
    --cw3-bg: #0E1014;
    --cw3-panel: #16181D;
    --cw3-panel-2: #1B1E25;
    --cw3-line: #23262E;
    --cw3-line-2: #2C3038;
    --cw3-text: #EDEFF3;
    --cw3-text-2: #A8AEB7;
    --cw3-text-3: #6A707B;
    --cw3-mech: #22D3EE;
    --cw3-struct: #FF8A4C;
    --cw3-elec: #FACC15;
    --cw3-plumb: #A78BFA;
    --cw3-clash: #F43F5E;
    --cw3-success: #4ADE80;
}

.cw3-matrix-cell-popover-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 9998;
}

.cw3-matrix-popover-card--anchored {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 9999;
}

.cw3-matrix-popover-card {
    width: 380px;
    background: linear-gradient(180deg, #181D26 0%, #0E1116 100%);
    border: 1px solid rgba(34, 211, 238, 0.25);
    border-radius: 10px;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.75),
        0 0 0 1px rgba(34, 211, 238, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    color: var(--cw3-text);
    overflow: hidden;
    font-family: 'Geist', system-ui, sans-serif;
}

.cw3-matrix-popover-head {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px 14px;
    border-bottom: 1px solid var(--cw3-line);
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.05) 0%, transparent 100%);
}

.cw3-matrix-popover-head-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cw3-matrix-popover-eyebrow {
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--cw3-mech);
    font-weight: 600;
    flex: 1 1 auto;
}

.cw3-matrix-popover-pair {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--cw3-text);
    line-height: 1.3;
    letter-spacing: -0.005em;
}

.cw3-matrix-popover-disc {
    color: var(--cw3-text);
    word-break: break-word;
}

.cw3-matrix-popover-vs {
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cw3-text-3);
    font-weight: 500;
    padding: 2px 6px;
    border: 1px solid var(--cw3-line);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
    align-self: center;
}

.cw3-matrix-popover-count {
    display: inline-flex;
    align-items: center;
    width: max-content;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--cw3-text-2);
    padding: 2px 10px;
    border: 1px solid var(--cw3-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    flex: 0 0 auto;
    align-self: center;
}

.cw3-matrix-popover-close {
    background: transparent;
    border: 0;
    color: var(--cw3-text-3);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cw3-matrix-popover-close:hover {
    color: var(--cw3-text);
    background: rgba(255, 255, 255, 0.08);
}

.cw3-matrix-popover-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cw3-matrix-popover-row {
    display: grid;
    grid-template-columns: 70px 1fr 70px;
    gap: 10px;
    align-items: center;
}

.cw3-matrix-popover-label {
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--cw3-text-3);
    font-weight: 600;
}

.cw3-matrix-popover-select {
    min-width: 0;
}

/* MudSelect inside the popover — dark theme */
.cw3-matrix-popover-select .mud-input-outlined-border {
    border-color: var(--cw3-line) !important;
}
.cw3-matrix-popover-select .mud-input-slot,
.cw3-matrix-popover-select input,
.cw3-matrix-popover-select .mud-select-input {
    color: var(--cw3-text) !important;
}
.cw3-matrix-popover-select .mud-input-slot::placeholder,
.cw3-matrix-popover-select input::placeholder,
.cw3-matrix-popover-select .mud-select-input::placeholder {
    color: var(--cw3-text-2) !important;
    opacity: 1;
}
.cw3-matrix-popover-select:hover .mud-input-outlined-border {
    border-color: var(--cw3-mech) !important;
}
/* Chevron / dropdown adornment — make visible against the dark card */
.cw3-matrix-popover-select .mud-input-adornment .mud-icon-root,
.cw3-matrix-popover-select .mud-icon-root,
.cw3-matrix-popover-select svg {
    color: var(--cw3-text-2) !important;
    fill: currentColor !important;
}
.cw3-matrix-popover-select:hover .mud-input-adornment .mud-icon-root,
.cw3-matrix-popover-select:hover .mud-icon-root,
.cw3-matrix-popover-select:hover svg {
    color: var(--cw3-mech) !important;
}

/* Apply button — proper visible action button, not a link */
.cw3-matrix-popover-row .cw3-btn {
    justify-self: stretch;
    justify-content: center;
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.15) 0%, rgba(34, 211, 238, 0.05) 100%);
    border: 1px solid rgba(34, 211, 238, 0.35);
    color: var(--cw3-mech);
    font-weight: 600;
    letter-spacing: 0.04em;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    padding: 6px 10px;
}
.cw3-matrix-popover-row .cw3-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.28) 0%, rgba(34, 211, 238, 0.1) 100%);
    border-color: var(--cw3-mech);
    color: var(--cw3-text);
}
.cw3-matrix-popover-row .cw3-btn:active:not(:disabled) { transform: scale(0.97); }
.cw3-matrix-popover-row .cw3-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.cw3-matrix-popover-overwrite {
    padding-top: 10px;
    margin-top: 2px;
    border-top: 1px dashed var(--cw3-line);
}

.cw3-matrix-popover-empty {
    padding: 22px 14px;
    text-align: center;
}

.cw3-matrix-popover-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--cw3-line);
    background: rgba(0, 0, 0, 0.25);
}

.cw3-matrix-popover-foot .cw3-btn--primary {
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.22) 0%, rgba(34, 211, 238, 0.08) 100%);
    border: 1px solid var(--cw3-mech);
    color: var(--cw3-text);
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 7px 14px;
}
.cw3-matrix-popover-foot .cw3-btn--primary:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.35) 0%, rgba(34, 211, 238, 0.15) 100%);
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.3);
}

.cw3-matrix-popover-foot .cw3-btn--ghost {
    color: var(--cw3-text-2);
    border: 1px solid var(--cw3-line);
    padding: 7px 14px;
}
.cw3-matrix-popover-foot .cw3-btn--ghost:hover:not(:disabled) {
    color: var(--cw3-text);
    border-color: var(--cw3-text-3);
    background: rgba(255, 255, 255, 0.04);
}

/* ─────────────────────────────────────────────────────────────
   Dark-themed dropdown menu spawned by MudSelect inside the popover.
   Targeted via PopoverClass on the MudSelect.
   ───────────────────────────────────────────────────────────── */
.cw3-matrix-popover-menu.mud-popover,
.cw3-matrix-popover-menu .mud-popover {
    background: linear-gradient(180deg, #181D26 0%, #0E1116 100%) !important;
    border: 1px solid rgba(34, 211, 238, 0.3) !important;
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(34, 211, 238, 0.1) !important;
    color: var(--cw3-text) !important;
    border-radius: 8px !important;
    overflow: hidden;
}

/* Cover MudList items in both 7.x and 8.x class layouts. */
.cw3-matrix-popover-menu .mud-list,
.cw3-matrix-popover-menu .mud-list-padding,
.cw3-matrix-popover-menu .mud-list-item,
.cw3-matrix-popover-menu .mud-list-item-text,
.cw3-matrix-popover-menu .mud-list-item-text-secondary,
.cw3-matrix-popover-menu .mud-typography {
    color: var(--cw3-text) !important;
    background: transparent !important;
}

.cw3-matrix-popover-menu .mud-list-item {
    transition: background-color 0.12s ease, color 0.12s ease;
}

.cw3-matrix-popover-menu .mud-list-item:hover,
.cw3-matrix-popover-menu .mud-list-item:focus,
.cw3-matrix-popover-menu .mud-list-item-clickable:hover,
.cw3-matrix-popover-menu .mud-list-item.mud-list-item-hover {
    background: rgba(34, 211, 238, 0.12) !important;
}

.cw3-matrix-popover-menu .mud-list-item.mud-selected-item,
.cw3-matrix-popover-menu .mud-list-item.mud-selected-item:hover {
    background: rgba(34, 211, 238, 0.22) !important;
}
.cw3-matrix-popover-menu .mud-list-item.mud-selected-item,
.cw3-matrix-popover-menu .mud-list-item.mud-selected-item .mud-list-item-text,
.cw3-matrix-popover-menu .mud-list-item.mud-selected-item .mud-typography {
    color: var(--cw3-mech) !important;
}
