:root {
    --mi-primary: #2f6db0;      /* MitImpact blue (from legacy #337CBB) */
    --mi-primary-dark: #24547f;
    --mi-primary-darker: #1b3d66;
    --mi-teal: #17a2b8;         /* cyan/teal from the lab logo */
    --mi-accent: #e8871e;       /* warm orange accent from the lab logo */
    --mi-ink: #1c2b3a;
    --mi-bg: #f6f9fc;
    --mi-grad: linear-gradient(135deg, #24547f 0%, #2f6db0 50%, #17a2b8 100%);
}

body {
    background: var(--mi-bg);
    color: var(--mi-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---- Nav ---- */
.mi-nav {
    background: #fff;
    border-bottom: 1px solid #e3ecf5;
    box-shadow: 0 1px 12px rgba(47, 109, 176, .07);
}
.mi-nav .navbar-brand { color: var(--mi-primary-dark); letter-spacing: .3px; display: flex; align-items: center; gap: .5rem; }
.mi-nav .navbar-brand img { height: 30px; width: auto; }
.mi-nav .nav-link { color: var(--mi-ink); font-weight: 500; }
.mi-nav .nav-link:hover, .mi-nav .nav-link.active { color: var(--mi-primary); }

/* ---- Hero ---- */
.mi-hero {
    background: var(--mi-grad);
    color: #fff;
    padding: 5rem 0 4rem;
    position: relative;
    overflow: hidden;
}
.mi-hero-sm { padding: 3.5rem 0; }
.mi-hero-sub { letter-spacing: 3px; text-transform: uppercase; opacity: .85; font-size: .85rem; }
.mi-hero::after {
    content: ""; position: absolute; right: -80px; top: -80px;
    width: 320px; height: 320px; border-radius: 50%;
    background: rgba(255,255,255,.08);
}

/* ---- Search box ---- */
.mi-search { max-width: 680px; }
.mi-search-input::placeholder { font-size: .82rem; opacity: .7; }
.mi-search .form-control:focus,
.mi-search-sm .form-control:focus { box-shadow: none; }
.mi-search-sm { max-width: 560px; }
.mi-btn {
    background: var(--mi-ink); color: #fff; font-weight: 600; border: none;
}
.mi-btn:hover { background: var(--mi-primary-darker); color: #fff; }

.mi-examples .mi-chip {
    display: inline-block; padding: .2rem .7rem; margin: .15rem;
    background: rgba(255,255,255,.18); color: #fff; border-radius: 999px;
    font-size: .85rem; text-decoration: none; transition: background .15s;
}
.mi-examples .mi-chip:hover { background: rgba(255,255,255,.32); }

/* ---- Feature cards ---- */
.mi-feature {
    background: #fff; border-radius: 16px; padding: 2rem 1.5rem;
    box-shadow: 0 4px 20px rgba(47,109,176,.08);
    transition: transform .15s, box-shadow .15s;
}
.mi-feature:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(47,109,176,.15); }
.mi-feature-icon { font-size: 2.4rem; color: var(--mi-primary); }
.mi-badge-new {
    background: var(--mi-accent); font-size: .6rem; vertical-align: middle;
    text-transform: uppercase; letter-spacing: .5px;
}

/* ---- Latest update panel ---- */
.mi-update {
    background: #fff; border: 1px solid #e3ecf5; border-left: 4px solid var(--mi-teal);
    border-radius: 12px; box-shadow: 0 2px 14px rgba(47,109,176,.06);
}
.mi-update-tag { color: var(--mi-teal); font-weight: 700; }

/* ---- Result page ---- */
.mi-result-head { background: #fff; border-bottom: 1px solid #e3ecf5; }
.mi-variant-name { font-size: 1.35rem; font-weight: 700; color: var(--mi-primary-dark); }
.mi-badge-type { background: var(--mi-teal); }  /* keep DB casing: tRNA, rRNA */
.mi-badge-aa { background: var(--mi-accent); }

/* result tabs when multiple variants */
.mi-tabs { border-bottom: 2px solid #e3ecf5; flex-wrap: wrap; }
.mi-tabs .nav-link {
    color: var(--mi-primary-dark); font-weight: 600; border: none;
    border-bottom: 3px solid transparent; border-radius: 0; margin-bottom: -2px;
}
.mi-tabs .nav-link:hover { color: var(--mi-primary); background: #f0f6fc; }
.mi-tabs .nav-link.active {
    color: var(--mi-primary); background: transparent; border-bottom-color: var(--mi-primary);
}
.mi-tabs .nav-link .mi-tab-allele { font-family: ui-monospace, "Courier New", monospace; font-size: .82rem; }

.mi-card { border: 1px solid #e3ecf5; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 12px rgba(47,109,176,.05); }
.mi-card-header {
    background: #eaf2fb; color: var(--mi-primary-dark); font-weight: 600;
    border-bottom: 1px solid #dbe8f5; padding: .6rem 1rem;
}
.mi-table th.mi-key {
    width: 45%; font-weight: 500; color: #5a6b7d; background: #fbfdff;
    font-size: .87rem; padding-left: 1rem;   /* breathing room from card edge */
}
.mi-table td.mi-val { font-size: .87rem; word-break: break-word; padding-right: 1rem; }
.mi-table td.mi-val a { color: var(--mi-primary); text-decoration: none; }
.mi-table td.mi-val a:hover { text-decoration: underline; }
.mi-table > tbody > tr:last-child > * { border-bottom: 0; }
.mi-multival { list-style: none; margin: 0; padding: 0; }
.mi-multival li { padding: .1rem 0; border-bottom: 1px dotted #eef3f9; }
.mi-multival li:last-child { border-bottom: 0; }
.mi-multival-more { margin-top: .2rem; }
.mi-multival-more summary { cursor: pointer; color: var(--mi-primary); font-size: .8rem; }
.mi-multival-more .mi-multival { margin-top: .25rem; }

/* ---- cross-reference badges (ClinVar disease DB) ---- */
.mi-table td.mi-val a.mi-xref { font-size: .7rem; font-weight: 600; margin: .1rem .2rem .1rem 0; text-decoration: none; color: #fff; }
.mi-table td.mi-val a.mi-xref:hover { opacity: .85; color: #fff; }
.mi-xref-mondo    { background: #3b5bdb; }
.mi-xref-omim     { background: #7048e8; }
.mi-xref-medgen   { background: #0c8599; }
.mi-xref-orphanet { background: #e8590c; }
.mi-xref-hpo      { background: #d6336c; }
.mi-xref-mesh     { background: #5c940d; }
.mi-xref-clingen  { background: #087f5b; }
.mi-xref-gtr      { background: #364fc7; }
.mi-info { color: var(--mi-teal); cursor: help; margin-left: .35rem; font-size: .8rem; }
.mi-info.text-danger { color: #c9302c !important; }

/* score-range tooltips: wider, left-aligned; red when the call is pathogenic */
.tooltip-inner { max-width: 320px; text-align: left; line-height: 1.5; }
.tooltip { --bs-tooltip-bg: #24547f; }
.mi-tip-danger { --bs-tooltip-bg: #b02a37; }

/* ---- Content pages (news, cite, legend, license) ---- */
.mi-page { max-width: 900px; }
.mi-page h2 { color: var(--mi-primary-dark); font-weight: 700; }
.mi-page-head {
    background: var(--mi-grad); color: #fff; padding: 2.5rem 0;
}
.mi-news-item { border-bottom: 1px solid #e7eef5; padding: 1rem 0; }
.mi-news-item:last-child { border-bottom: 0; }
.mi-news-date { color: var(--mi-teal); font-weight: 700; white-space: nowrap; }
.mi-news-item .hl { color: var(--mi-primary); }
/* ---- Output legend ---- */
.mi-legend-nav {
    display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 2rem;
}
.mi-legend-chip {
    display: inline-block; padding: .3rem .85rem; border-radius: 999px;
    background: #eaf2fb; color: var(--mi-primary-dark); font-size: .85rem;
    font-weight: 600; text-decoration: none; transition: background .15s, color .15s;
}
.mi-legend-chip:hover { background: var(--mi-primary); color: #fff; }
.mi-legend-card { scroll-margin-top: 5rem; }
.mi-legend-card .card-header { font-size: 1.05rem; }
.mi-legend-row {
    display: flex; gap: 1.2rem; padding: .55rem 0; border-bottom: 1px solid #eef3f9;
}
.mi-legend-row:last-child { border-bottom: 0; }
.mi-legend-term {
    flex: 0 0 200px; font-weight: 700; color: var(--mi-primary-dark); font-size: .92rem;
}
.mi-legend-desc { flex: 1 1 auto; color: #45525f; font-size: .92rem; line-height: 1.55; }
.mi-legend-desc code { background: #eef3f9; color: var(--mi-primary-dark); padding: .05rem .35rem; border-radius: 5px; }
.mi-legend-desc .patho {
    background: #fdeceb; color: #c9302c; font-weight: 600; padding: .05rem .4rem; border-radius: 6px;
}
@media (max-width: 576px) {
    .mi-legend-row { flex-direction: column; gap: .2rem; }
    .mi-legend-term { flex-basis: auto; }
}
.mi-cite-ref { border-left: 3px solid var(--mi-teal); padding-left: 1rem; margin-bottom: 1.25rem; }
.mi-cite-ref .title { color: var(--mi-primary); font-style: italic; }

/* ---- rCRS note + genetic code ---- */
.mi-rcrs-note { color: rgba(255,255,255,.85); font-size: .85rem; }
.mi-rcrs-note a { color: #fff; text-decoration: underline; }
.mi-rcrs-sep { opacity: .5; margin: 0 .4rem; }

#gencode-modal .modal-content { border-radius: 18px; border: none; box-shadow: 0 20px 60px rgba(27,61,102,.25); overflow: hidden; }
#gencode-modal .modal-header { background: var(--mi-grad); color: #fff; border-bottom: none; }
#gencode-modal .modal-header .btn-close { filter: invert(1) grayscale(1) brightness(2); }
#gencode-modal .modal-body { padding: 1.5rem; }

.mi-gc-grid {
    display: grid;
    grid-template-columns: 52px repeat(4, 1fr) 60px;
    gap: 4px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.mi-gc-h {
    background: var(--mi-primary-dark); color: #fff; font-weight: 600; font-size: .78rem;
    border-radius: 6px; padding: .35rem .3rem;
    display: flex; align-items: center; justify-content: center; text-align: center;
}
.mi-gc-span4 { grid-column: span 4; }
.mi-gc-corner { background: transparent; }
.mi-gc-third { font-size: .68rem; letter-spacing: .12em; }

.mi-gc-cell {
    background: #f3f8fd; border-radius: 6px; padding: .35rem .5rem;
    display: flex; flex-direction: column; justify-content: center; gap: .15rem;
}
.mi-gc-line { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.mi-gc-codons { color: #5a6b7d; font-size: .76rem; }
.mi-gc-aa { font-weight: 600; color: var(--mi-primary-dark); font-size: .78rem; white-space: nowrap; }
.mi-gc-line.patho .mi-gc-codons,
.mi-gc-line.patho .mi-gc-aa { color: var(--mi-accent); font-weight: 700; }

@media (max-width: 576px) {
    .mi-gc-grid { grid-template-columns: 40px repeat(4, 1fr) 44px; gap: 3px; }
    .mi-gc-h { font-size: .68rem; padding: .25rem; }
    .mi-gc-codons, .mi-gc-aa { font-size: .68rem; }
    .mi-gc-line { flex-direction: column; gap: 0; }
}

/* ---- Stats dashboards ---- */
.mi-stat-total { font-size: 1.4rem; font-weight: 700; }
.mi-stat-card .card-body { padding: 1.25rem 1.25rem .5rem; }

/* ---- Notfound ---- */
.mi-notfound-icon { font-size: 3rem; color: var(--mi-primary); }

/* ---- Footer ---- */
.mi-footer { background: #fff; border-top: 1px solid #e3ecf5; color: #5a6b7d; }
.mi-footer a { color: var(--mi-primary); text-decoration: none; }
.mi-footer a:hover { text-decoration: underline; }
.mi-footer .mi-lab-logo { max-width: 110px; height: auto; }
.mi-footer h6 { color: var(--mi-primary-dark); font-weight: 700; }

/* ---- Molecule feature illustrations ---- */
.mi-mol {
    border-radius: 20px; padding: 1.4rem 1rem 1.2rem; text-align: center;
    transition: transform .15s, box-shadow .15s;
}
.mi-mol:hover { transform: translateY(-4px); box-shadow: 0 10px 26px rgba(47,109,176,.12); }
.mi-mol-protein { background: #e9f1fb; }
.mi-mol-trna    { background: #fdeef2; }
.mi-mol-rrna    { background: #e9f5ec; }
.mi-mol-head { font-weight: 700; font-size: 1.2rem; color: #2a3947; margin-bottom: .5rem; }
.mi-mol svg { width: 100%; height: 150px; display: block; }
.mi-mol img { width: 100%; height: 150px; object-fit: contain; display: block; }

.mi-mol-link { display: block; text-decoration: none; color: inherit; cursor: pointer; }

.mi-badge-available {
    background: var(--mi-teal); font-size: .58rem; vertical-align: middle;
    text-transform: uppercase; letter-spacing: .5px;
}
.mi-badge-soon {
    background: var(--mi-accent); font-size: .58rem; vertical-align: middle;
    text-transform: uppercase; letter-spacing: .5px;
}

/* ---- News timeline ---- */
.mi-timeline { position: relative; padding-left: 2.4rem; }
.mi-timeline::before {
    content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px;
    width: 2px; background: linear-gradient(var(--mi-teal), #e3ecf5);
}
.mi-tl-item { position: relative; padding: 0 0 1.6rem 0; }
.mi-tl-dot {
    position: absolute; left: -2.4rem; top: 2px; width: 24px; height: 24px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: .7rem; box-shadow: 0 0 0 4px var(--mi-bg);
}
.mi-tl-dot.kind-release { background: var(--mi-teal); }
.mi-tl-dot.kind-paper   { background: var(--mi-primary); }
.mi-tl-dot.kind-news    { background: var(--mi-accent); }
.mi-tl-card {
    background: #fff; border: 1px solid #e3ecf5; border-radius: 12px;
    padding: .9rem 1.1rem; box-shadow: 0 2px 12px rgba(47,109,176,.05);
    transition: transform .12s, box-shadow .12s;
}
.mi-tl-card:hover { transform: translateX(3px); box-shadow: 0 6px 18px rgba(47,109,176,.12); }
.mi-tl-meta { display: flex; align-items: center; gap: .6rem; margin-bottom: .35rem; }
.mi-tl-date { font-weight: 700; color: var(--mi-primary-dark); font-size: .9rem; }
.mi-tl-kind {
    font-size: .62rem; text-transform: uppercase; letter-spacing: .5px;
    padding: .1rem .5rem; border-radius: 999px; font-weight: 600;
}
.mi-tl-kind.kind-release { background: #e3f5f8; color: #0f7c90; }
.mi-tl-kind.kind-paper   { background: #e7f0fb; color: var(--mi-primary-dark); }
.mi-tl-kind.kind-news    { background: #fdf0e1; color: #b5670f; }
.mi-tl-card .hl { color: var(--mi-primary); }

/* ---- EVmutation co-variation network ---- */
.mi-evm-svg { width: 100%; max-width: 460px; height: auto; display: block; }
.mi-evm-label { font: 700 13px system-ui, sans-serif; fill: #fff; pointer-events: none; }
.mi-evm-weight { font: 500 10px ui-monospace, "Courier New", monospace; fill: #5a6b7d; }
.mi-evm-center-label { font: 700 12px system-ui, sans-serif; fill: #fff; pointer-events: none; }
.mi-evm-label-dark { fill: #1b3d66; }
.mi-evm-caption { font-size: .8rem; color: #5a6b7d; }
.mi-evm-textlist summary { cursor: pointer; color: var(--mi-primary); font-size: .8rem; text-align: center; }
.mi-evm-text-scroll { max-height: 220px; overflow-y: auto; margin-top: .4rem; padding-right: .3rem; }
.mi-evm-text-scroll .mi-multival li { font-size: .82rem; }

/* ---- MitoWheel (genome location) ---- */
.mi-wheel-svg { width: 100%; max-width: 300px; height: auto; display: block; }
.mi-wheel-gene { font: 700 15px system-ui, sans-serif; fill: var(--mi-primary-dark); }
.mi-wheel-pos { font: 500 12px ui-monospace, "Courier New", monospace; fill: #5a6b7d; }
.mi-wheel-legend { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .78rem; color: #5a6b7d; }
.mi-wheel-legend .mi-dot {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    margin-right: .3rem; vertical-align: middle;
}
.mi-wheel-caption {
    font-size: .82rem; font-weight: 600; color: var(--mi-primary-dark);
    min-height: 1.2em; margin-top: .25rem; text-align: center;
}
/* interactive arcs */
.mi-wheel-arc { transition: opacity .12s; cursor: pointer; }
.mi-wheel-arc.is-hover { opacity: 1 !important; filter: brightness(1.12); }

/* ---- 3D structure viewer (square: structures are globular/vertical) ---- */
.mi-viewer-wrap { position: relative; }
.mi-viewer {
    width: 460px; max-width: 100%; aspect-ratio: 1.2 / 1; height: auto;
    margin: 0 auto; border-radius: 12px; background: #fff; overflow: hidden;
    border: 1px solid #e3ecf5;
}
.mi-viewer-empty {
    width: 460px; max-width: 100%; aspect-ratio: 1.2 / 1; margin: 0 auto;
    border: 1px dashed #ccd8e6; border-radius: 12px; color: #8ba0b5;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem;
}
.mi-viewer-legend { font-size: .8rem; color: #5a6b7d; }
.mi-viewer-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }

/* ---- Cookie banner ---- */
.mi-cookie {
    position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 1080;
    max-width: 620px; margin: 0 auto;
    background: #fff; border: 1px solid #e3ecf5; border-radius: 14px;
    box-shadow: 0 8px 30px rgba(27,61,102,.18);
    padding: .9rem 1.1rem; display: flex; align-items: center; gap: 1rem;
}
.mi-cookie p { margin: 0; font-size: .88rem; color: var(--mi-ink); }
.mi-cookie .bi { color: var(--mi-teal); }
.mi-cookie.hide { display: none; }

/* tRNA cloverleaf (trnaplot.py) */
.mi-trna-svg { width: 100%; max-width: 440px; height: auto; display: block; margin: 0 auto; }
.mi-trna-backbone { fill: none; stroke: #b8c4d1; stroke-width: 1.4; }
.mi-trna-pair { stroke: #8fa3b8; stroke-width: 2.2; stroke-linecap: round; }
.mi-trna-nt circle { stroke: #9fb0c2; stroke-width: 1; }
.mi-trna-nt text { font: 600 9px system-ui, sans-serif; fill: #24547f; text-anchor: middle; pointer-events: none; }
.mi-trna-nt:hover circle { stroke: #24547f; stroke-width: 2; }
.mi-trna-nt.on-dark text { fill: #fff; }
/* the rings live inside .mi-trna-nt groups, so they must out-rank
   ".mi-trna-nt circle" (and its :hover) or they inherit the thin grey outline */
.mi-trna-nt circle.mi-trna-ring,
.mi-trna-nt:hover circle.mi-trna-ring { fill: none; stroke: #1b3d66; stroke-width: 2.6; }
.mi-trna-nt circle.mi-trna-ring-partner,
.mi-trna-nt:hover circle.mi-trna-ring-partner { fill: none; stroke: #1b3d66; stroke-width: 1.6; stroke-dasharray: 2.5 2; }
.mi-trna-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem .75rem; margin-top: .5rem; font-size: .74rem; color: #5a6b7d; }
.mi-trna-key { display: inline-flex; align-items: center; gap: .3rem; }
.mi-trna-key span { width: .7rem; height: .7rem; border-radius: 50%; display: inline-block; border: 1px solid #9fb0c2; }
.mi-trna-arm { font: 500 10px system-ui, sans-serif; fill: #5a6b7d; }
.mi-trna-end { font: 700 10px system-ui, sans-serif; fill: #5a6b7d; }
.mi-trna-ring-swatch { display: inline-block; width: .75rem; height: .75rem; border-radius: 50%; border: 2px solid #1b3d66; vertical-align: -1px; margin-right: .2rem; }
.mi-trna-ring-swatch.partner { border-width: 1.5px; border-style: dashed; margin-left: .2rem; }
