.ma-panel {
    border-color: #475569;
}

.ma-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.ma-button {
    appearance: none;
    border: 1px solid #facc15;
    border-radius: 11px;
    padding: 12px 18px;
    background: #111827;
    color: #facc15;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}

.ma-button:hover {
    background: #1e293b;
}

.ma-button:disabled {
    opacity: .55;
    cursor: wait;
}

.ma-status {
    color: #94a3b8;
    font-size: 13px;
}

.ma-note {
    margin-top: 14px;
    padding: 12px 14px;
    border-left: 3px solid #38bdf8;
    border-radius: 8px;
    background: rgba(15, 23, 42, .7);
    color: #cbd5e1;
    line-height: 1.5;
}

.ma-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20000;
    padding: 24px;
    background: rgba(2, 6, 23, .86);
    overflow-y: auto;
}

.ma-modal.is-open {
    display: block;
}

body.ma-modal-open {
    overflow: hidden;
}

.ma-dialog {
    position: relative;
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 26px;
    border: 1px solid #334155;
    border-radius: 18px;
    background: #0f172a;
    color: #e5e7eb;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}

.ma-close {
    position: absolute;
    top: 14px;
    right: 16px;
    border: 0;
    background: transparent;
    color: #cbd5e1;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

.ma-close:hover {
    color: #fff;
}

.ma-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    margin: 18px 0;
}

.ma-summary-card {
    padding: 14px;
    border: 1px solid #334155;
    border-radius: 12px;
    background: #111827;
}

.ma-summary-label {
    margin-bottom: 7px;
    color: #94a3b8;
    font-size: 12px;
}

.ma-summary-value {
    color: #f8fafc;
    font-size: 19px;
    font-weight: 800;
}

.ma-warning {
    margin: 14px 0;
    padding: 12px 14px;
    border: 1px solid #854d0e;
    border-radius: 10px;
    background: rgba(113, 63, 18, .28);
    color: #fde68a;
    line-height: 1.5;
}

.ma-method,
.ma-quality-box {
    margin: 14px 0;
    padding: 14px;
    border: 1px solid #334155;
    border-radius: 12px;
    background: #111827;
    color: #cbd5e1;
    line-height: 1.55;
}

.ma-match {
    margin: 12px 0;
    border: 1px solid #334155;
    border-radius: 13px;
    background: #111827;
    overflow: hidden;
}

.ma-match > summary {
    display: grid;
    grid-template-columns: 70px 130px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 15px;
    cursor: pointer;
    list-style: none;
}

.ma-match > summary::-webkit-details-marker {
    display: none;
}

.ma-rank {
    color: #94a3b8;
    font-weight: 700;
}

.ma-period {
    color: #f8fafc;
    font-size: 18px;
    font-weight: 850;
}

.ma-similarity {
    color: #2dd4bf;
    font-size: 20px;
    font-weight: 850;
}

.ma-quality-ok {
    color: #2dd4bf;
}

.ma-quality-watch {
    color: #facc15;
}

.ma-match-body {
    padding: 0 15px 16px;
    border-top: 1px solid #263244;
}

.ma-metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    gap: 10px;
    margin: 14px 0;
}

.ma-metric {
    padding: 11px;
    border-radius: 9px;
    background: #0b1220;
}

.ma-metric-label {
    color: #94a3b8;
    font-size: 11px;
    margin-bottom: 5px;
}

.ma-metric-value {
    font-weight: 750;
}

.ma-table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-top: 14px;
}

.ma-table {
    width: 100%;
    min-width: 1040px;
    border-collapse: collapse;
    font-size: 12px;
}

.ma-table th,
.ma-table td {
    padding: 9px 8px;
    border-bottom: 1px solid #263244;
    text-align: right;
    vertical-align: top;
}

.ma-table th:first-child,
.ma-table td:first-child {
    text-align: left;
}

.ma-table th {
    background: #172033;
    color: #cbd5e1;
}

.ma-raw {
    display: block;
    margin-top: 3px;
    color: #64748b;
    font-size: 10px;
}

.ma-loading,
.ma-error {
    padding: 28px 8px;
    text-align: center;
}

.ma-error {
    color: #fca5a5;
}

.ma-limitations {
    margin-top: 20px;
    color: #94a3b8;
    line-height: 1.55;
    font-size: 13px;
}

@media (max-width: 850px) {
    .ma-summary-grid {
        grid-template-columns: repeat(2, minmax(130px, 1fr));
    }

    .ma-match > summary {
        grid-template-columns: 50px 100px 1fr;
    }

    .ma-match > summary > :last-child {
        grid-column: 2 / -1;
    }

    .ma-metrics {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .ma-dialog {
        padding: 20px 14px;
    }
}

/* Historical analogues glossary */

.ma-button-secondary {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.70);
    box-shadow: none;
}

.ma-button-secondary:hover {
    background: rgba(148, 163, 184, 0.12);
}

.ma-glossary-intro {
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.08);
    line-height: 1.6;
}

.ma-glossary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.ma-glossary-item {
    padding: 16px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.035);
}

.ma-glossary-item h3,
.ma-glossary-how h3,
.ma-glossary-important h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.ma-glossary-item p,
.ma-glossary-how p,
.ma-glossary-important p {
    margin: 0;
    line-height: 1.6;
}

.ma-glossary-formula {
    margin-top: 12px;
    padding: 9px 11px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.08);
    font-family: Consolas, "Courier New", monospace;
    text-align: center;
}

.ma-glossary-how,
.ma-glossary-important {
    margin-top: 16px;
    padding: 16px;
    border-radius: 12px;
}

.ma-glossary-how {
    border: 1px solid rgba(16, 185, 129, 0.30);
    background: rgba(16, 185, 129, 0.08);
}

.ma-glossary-important {
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.10);
}

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

    .ma-actions {
        align-items: stretch;
    }

    .ma-actions .ma-button {
        width: 100%;
    }
}
