/* ===================================
   Incidence Matrices window (reuses the .invm shell and colour tokens)
   =================================== */
.mtx .mtx-header { background: linear-gradient(135deg, #0f766e 0%, #1e3a8a 100%); }

.mtx-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.mtx-spacer { flex: 1; }
.mtx-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--invm-text); cursor: pointer; }
.mtx-btn {
    border: 1px solid var(--invm-border); background: var(--invm-bg); color: var(--invm-text);
    border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.mtx-btn:hover { border-color: var(--invm-accent); }

.mtx-wrap { overflow: auto; max-height: 52vh; border: 1px solid var(--invm-border); border-radius: 10px; background: var(--invm-surface); }
.mtx .mtx-table { border-collapse: separate; border-spacing: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.mtx .mtx-table th, .mtx .mtx-table td {
    padding: 7px 12px; text-align: center; border: none !important;
    border-right: 1px solid var(--invm-border) !important; border-bottom: 1px solid var(--invm-border) !important;
    background: var(--invm-bg); color: var(--invm-text);
}
.mtx .mtx-table thead th {
    position: sticky; top: 0; z-index: 2; background: var(--invm-surface-2);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.mtx .mtx-table tbody th {
    position: sticky; left: 0; z-index: 1; background: var(--invm-surface-2); text-align: left;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.mtx .mtx-table .mtx-corner { left: 0; z-index: 3; color: var(--invm-muted); font-weight: 600; }
.mtx .mtx-cell { min-width: 44px; cursor: default; }
.mtx .mtx-cell.zero { color: var(--invm-muted); }
.mtx .mtx-cell.nz { font-weight: 700; color: var(--invm-accent); }
.mtx .mtx-cell.pos { font-weight: 700; color: var(--invm-pos); }
.mtx .mtx-cell.neg { font-weight: 700; color: var(--invm-neg); }
.mtx .mtx-table .hl { background: var(--invm-hl) !important; }
.mtx .mtx-sum, .mtx .mtx-sumh { background: var(--invm-surface) !important; color: var(--invm-muted) !important; }
.mtx .mtx-sum.nonzero { color: var(--invm-warn) !important; font-weight: 700; }

.mtx-explain {
    margin-top: 10px; padding: 10px 12px; border-radius: 10px; min-height: 22px;
    background: var(--invm-info-soft); color: var(--invm-text); font-size: 13.5px;
}

.mtx-eq-grid { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.3fr); gap: 14px; }
.mtx-eq-box { border: 1px solid var(--invm-border); border-radius: 10px; padding: 12px; background: var(--invm-surface); }
.mtx-sigma-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.mtx-sigma {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 8px; border: 1px solid var(--invm-border); border-radius: 8px; background: var(--invm-bg);
    font-size: 13px; font-weight: 600; color: var(--invm-text);
}
.mtx-sigma span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mtx-sigma input {
    width: 58px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--invm-border);
    background: var(--invm-surface); color: var(--invm-text); font-size: 14px; text-align: right;
}
.mtx-sigma input:focus { outline: none; border-color: var(--invm-accent); }
.mtx-eq-actions { margin-top: 10px; }
.mtx-small { font-size: 12.5px; color: var(--invm-text); margin: 10px 0 0; line-height: 1.6; }
.mtx .mtx-result-table { width: 100%; margin-top: 8px; }
.mtx .mtx-result-table td.pos { color: var(--invm-pos); font-weight: 700; }
.mtx .mtx-result-table td.neg { color: var(--invm-neg); font-weight: 700; }
.mtx .mtx-result-table td.zero { color: var(--invm-muted); }
.mtx .mtx-result-table .mtx-result { font-weight: 700; }
.mtx .mtx-result-table tr.mtx-neg-row td, .mtx .mtx-result-table tr.mtx-neg-row th { background: color-mix(in srgb, var(--invm-neg) 14%, var(--invm-bg)); }
.mtx-verdict { margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; color: var(--invm-text); }
.mtx-verdict.ok { background: var(--invm-ok-soft); }
.mtx-verdict.bad { background: color-mix(in srgb, var(--invm-neg) 16%, var(--invm-bg)); }
.mtx-verdict.info { background: var(--invm-info-soft); }

@media (max-width: 760px) {
    .mtx-eq-grid { grid-template-columns: 1fr; }
}

/* Não herdar a borda global de <table> */
.mtx .mtx-table { border: none !important; outline: none; }
.mtx .mtx-result-table { border: 1px solid var(--invm-border) !important; border-radius: 8px; overflow: hidden; }
