/*
 * Atlas · Market rates (market-rates.html, docs/market-rates.md). The look of
 * the approved mockup (2026-12-01) on the admin tokens of css/admin-shell.css.
 * Every class here starts with "mr-".
 *
 * The band colours are the one data scale of the map (one hue, checked with
 * the dataviz rules; shared/market-rates.js BAND_COLORS holds the same
 * values for the Admin app). Dark mode turns the scale over: a high rate is
 * the brightest tile. "No data" is never a step of the scale: a gray hatch
 * and the words.
 */
:root {
    --mr-b0: #184f95;
    --mr-b1: #256abf;
    --mr-b2: #3987e5;
    --mr-b3: #86b6ef;
    --mr-b4: #cde2fb;
    --mr-t0: #ffffff;
    --mr-t1: #ffffff;
    --mr-t2: #0a0a1a;
    --mr-t3: #0a0a1a;
    --mr-t4: #0a0a1a;
    --mr-nd: #22253a;
    --mr-ndl: #383c5c;
    --mr-ndt: #f4f4f7;
    --mr-scrim: rgba(5, 6, 15, 0.6);
    --mr-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
[data-theme="light"] {
    --mr-b0: #86b6ef;
    --mr-b1: #5598e7;
    --mr-b2: #256abf;
    --mr-b3: #184f95;
    --mr-b4: #0d366b;
    --mr-t0: #0d1a38;
    --mr-t1: #0d1a38;
    --mr-t2: #ffffff;
    --mr-t3: #ffffff;
    --mr-t4: #ffffff;
    --mr-nd: #e9ebf1;
    --mr-ndl: #c9cdd8;
    --mr-ndt: #0d1a38;
    --mr-scrim: rgba(13, 26, 56, 0.45);
    --mr-shadow: 0 8px 24px rgba(13, 26, 56, 0.18);
}

.mr-main { padding-bottom: 48px; }
.mr-main :focus-visible,
.mr-dialog :focus-visible,
.mr-skip:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}
.mr-main [tabindex="-1"]:focus,
.mr-dialog [tabindex="-1"]:focus { outline: none; }

/* The first Tab stop. */
.mr-skip {
    position: absolute;
    top: -48px;
    left: 8px;
    z-index: 30;
    display: flex;
    align-items: center;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface-1);
    color: var(--color-text-1);
    font-weight: 600;
    text-decoration: none;
}
.mr-skip:focus { top: 6px; }

.mr-svg {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.mr-svg-s { width: 16px; height: 16px; }
.mr-icon { display: inline-flex; }
.btn .mr-icon { margin-right: 8px; }
.mr-icon-btn { width: 40px; padding: 0; justify-content: center; }
.mr-icon-btn .mr-icon { margin: 0; }

.mr-auth { padding: 48px 0; text-align: center; }

/* The heading: the name, the file line, the two actions. */
.mr-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 0 16px;
    min-height: 40px;
}
.mr-title { margin: 0; font-size: 20px; font-weight: 600; }
.mr-src { color: var(--color-text-2); font-size: 13px; }
.mr-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.mr-link,
.mr-gaps li a {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.mr-crumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin: 0 0 8px;
    color: var(--color-text-2);
    font-size: 13px;
}
.mr-crumb a { color: inherit; text-decoration: none; }
.mr-crumb a:hover { color: var(--color-text-1); text-decoration: underline; }

.mr-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 0 0 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--status-warning-soft);
    color: var(--color-text-1);
}
.mr-banner > .mr-svg { color: var(--status-warning); }
.mr-banner > span { flex: 1; min-width: 200px; }
.mr-banner b { font-weight: 600; }
.mr-alert {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--status-danger-soft);
    color: var(--status-danger-text);
}
.mr-dialog .mr-alert { margin: 0; }

/* Cards and grids. */
.mr-grid { display: grid; gap: 16px; }
.mr-g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mr-split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.mr-split.mr-one { grid-template-columns: minmax(0, 1fr); }
.mr-split.mr-one .mr-gaps { display: none; }
.mr-stats { margin: 0 0 16px; }
.mr-stat {
    display: block;
    width: 100%;
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface-1);
    color: var(--color-text-1);
    font: inherit;
    text-align: left;
}
button.mr-stat { cursor: pointer; }
button.mr-stat:hover { border-color: var(--color-text-2); }
.mr-stat strong { display: block; font-size: 28px; font-weight: 600; line-height: 1.15; }
.mr-stat span { display: block; margin-top: 4px; color: var(--color-text-2); font-size: 13px; }
.mr-card {
    position: relative;
    margin: 0 0 16px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface-1);
}
.mr-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 57px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
}
.mr-card-head h3 { margin: 0 auto 0 0; font-size: 15px; font-weight: 600; }
.mr-card-body { padding: 16px; }
.mr-scroll { position: relative; overflow-x: auto; }
.mr-mapwrap { margin: -6px; padding: 6px; }

/* Filters, one row. */
.mr-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.mr-search {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 8px;
    min-width: 220px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--color-control-border, var(--color-border));
    border-radius: 8px;
    background: var(--color-surface-1);
    color: var(--color-text-2);
}
.mr-search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: none;
    background: none;
    color: var(--color-text-1);
    font: inherit;
}
.mr-search input::placeholder { color: var(--color-text-2); }
.mr-search:focus-within,
.mr-select:focus-within { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.mr-seg > button { min-height: 36px; }
.mr-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 4px 0 12px;
    border: 1px solid var(--color-control-border, var(--color-border));
    border-radius: 8px;
    background: var(--color-surface-1);
    color: var(--color-text-2);
    font-size: 13px;
}
.mr-select select {
    height: 36px;
    padding: 0 4px;
    border: 0;
    background: var(--color-surface-1);
    color: var(--color-text-1);
    font: inherit;
    font-size: 13px;
}
.mr-select select:focus-visible { outline: none; }

/* The tile map: one equal square for each state, in its place on the map. */
.mr-tiles {
    display: grid;
    grid-template-columns: repeat(11, minmax(52px, 1fr));
    gap: 8px;
    min-width: 652px;
}
.mr-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    grid-column: var(--c);
    grid-row: var(--r);
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 0;
    border-radius: 8px;
    font: inherit;
    line-height: 1.1;
    cursor: pointer;
    transition: box-shadow 0.12s;
}
.mr-tile .mr-ab { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.mr-tile .mr-v { font-size: 15px; font-weight: 600; }
.mr-tile.mr-b0 { background: var(--mr-b0); color: var(--mr-t0); }
.mr-tile.mr-b1 { background: var(--mr-b1); color: var(--mr-t1); }
.mr-tile.mr-b2 { background: var(--mr-b2); color: var(--mr-t2); }
.mr-tile.mr-b3 { background: var(--mr-b3); color: var(--mr-t3); }
.mr-tile.mr-b4 { background: var(--mr-b4); color: var(--mr-t4); }
.mr-tile.mr-nd {
    background: var(--mr-nd) repeating-linear-gradient(135deg, transparent 0 5px, var(--mr-ndl) 5px 7px);
    color: var(--mr-ndt);
}
.mr-tile.mr-nd .mr-v { font-size: 12px; font-weight: 400; }
.mr-tile:hover { box-shadow: inset 0 0 0 2px var(--color-text-1); }
.mr-tile.mr-hit { box-shadow: inset 0 0 0 3px var(--color-text-1), inset 0 0 0 5px var(--color-surface-1); }
.mr-tile:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }

.mr-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 16px 0 0;
    padding: 0;
    color: var(--color-text-2);
    font-size: 12px;
    list-style: none;
}
.mr-legend li { display: flex; align-items: center; gap: 8px; }
.mr-sw {
    display: inline-block;
    flex: none;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    vertical-align: -3px;
}
.mr-sw.mr-b0 { background: var(--mr-b0); }
.mr-sw.mr-b1 { background: var(--mr-b1); }
.mr-sw.mr-b2 { background: var(--mr-b2); }
.mr-sw.mr-b3 { background: var(--mr-b3); }
.mr-sw.mr-b4 { background: var(--mr-b4); }
.mr-sw.mr-nd {
    background: var(--mr-nd) repeating-linear-gradient(135deg, transparent 0 3px, var(--mr-ndl) 3px 5px);
    box-shadow: inset 0 0 0 1px var(--mr-ndl);
}
.mr-val { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }

/* The card of the pointer and of keyboard focus on the map. */
.mr-tip {
    position: fixed;
    z-index: 25;
    max-width: 260px;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface-1);
    box-shadow: var(--mr-shadow);
    color: var(--color-text-1);
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
}
.mr-tip.mr-on { opacity: 1; }
.mr-tip b { display: block; font-size: 15px; font-weight: 600; }
.mr-tip .mr-mu { display: block; }

/* Tables. */
.mr-table { width: 100%; border-collapse: collapse; }
.mr-table th {
    padding: 8px 16px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-2);
    font-size: 12px;
    font-weight: 400;
    text-align: left;
    white-space: nowrap;
}
.mr-table th button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    margin: 0 -8px;
    padding: 0 8px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--color-text-2);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}
.mr-table th button:hover { background: var(--color-surface-2); color: var(--color-text-1); }
.mr-table th[aria-sort="ascending"] button,
.mr-table th[aria-sort="descending"] button { color: var(--color-text-1); font-weight: 600; }
.mr-table .mr-ar { display: inline-block; width: 12px; }
.mr-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-1);
    vertical-align: middle;
}
.mr-table tr:last-child td { border-bottom: 0; }
.mr-table .mr-r { text-align: right; }
.mr-table th.mr-r button { margin-left: auto; }
.mr-table td.mr-nw { white-space: nowrap; }
.mr-table tbody tr.mr-row { cursor: pointer; }
.mr-table tbody tr.mr-row:hover td { background: var(--color-surface-2); }
.mr-table a.mr-lk { color: var(--color-text-1); font-weight: 600; text-decoration: none; }
.mr-table a.mr-lk:hover { text-decoration: underline; }
.mr-table tr.mr-grp th {
    padding: 16px 16px 8px;
    background: var(--color-surface-bg);
    color: var(--color-text-2);
    font-size: 13px;
    font-weight: 600;
}
.mr-sub { display: block; color: var(--color-text-2); font-size: 13px; }
.mr-mu { color: var(--color-text-2); }
.mr-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--color-surface-2);
    color: var(--color-text-2);
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
}
.mr-chip-inf { background: var(--status-info-soft); color: var(--status-info-text); }
.mr-chip-wa { background: var(--status-warning-soft); color: var(--status-warning-text); }
.mr-table td.mr-rate { min-width: 120px; }
.mr-table td.mr-rate .mr-sub { white-space: normal; }
a.mr-src-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 3px;
}
a.mr-src-link:hover { text-decoration-thickness: 2px; }

/* No data. */
.mr-gaps h4 { margin: 0 0 8px; color: var(--color-text-2); font-size: 13px; font-weight: 600; }
.mr-gaps ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.mr-gaps ul:last-child { margin-bottom: 0; }
.mr-gaps li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px 0 8px;
    border-radius: 8px;
    background: var(--color-surface-2);
    font-size: 13px;
}
.mr-gaps li a { color: var(--color-text-1); }

/* Dialogs over the page. */
.mr-scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 80px 16px 16px;
    overflow: auto;
    background: var(--mr-scrim);
}
.mr-dialog {
    width: min(560px, 100%);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: var(--color-surface-1);
    box-shadow: var(--mr-shadow);
    color: var(--color-text-1);
}
.mr-dialog-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 8px 24px; }
.mr-dialog-head h2 { margin: 0 auto 0 0; font-size: 18px; font-weight: 600; }
.mr-dialog-body { display: grid; gap: 16px; padding: 8px 24px 16px; }
.mr-dialog-body h3 { margin: 0 0 8px; color: var(--color-text-2); font-size: 13px; font-weight: 600; }
.mr-dialog-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
}
.mr-dialog-foot:empty { display: none; }
.mr-dialog .mr-table td,
.mr-dialog .mr-table th { padding: 8px 0; }
.mr-dialog .mr-compare td + td,
.mr-dialog .mr-compare th + th { text-align: right; }
.mr-dialog .mr-src-link { margin-top: 4px; font-size: 13px; }
.mr-dialog td.mr-was-now { vertical-align: top; white-space: nowrap; }
.mr-was-now s { color: var(--color-text-2); }
.mr-up { font-weight: 600; }
.mr-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface-bg);
}
.mr-file-t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.mr-ref { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.mr-ref li {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--status-danger-soft);
    font-size: 13px;
}
.mr-ref li b { color: var(--status-danger-text); font-weight: 600; white-space: nowrap; }
.mr-grp2 { display: grid; gap: 4px; }
.mr-run { justify-self: start; }
body.mr-dialog-open { overflow: hidden; }

/* Windows High Contrast: the words stay, and each tile keeps a border. */
@media (forced-colors: active) {
    .mr-tile,
    .mr-sw,
    .mr-stat,
    .mr-card { border: 1px solid CanvasText; }
    .mr-tile.mr-nd,
    .mr-sw.mr-nd { background: Canvas; }
    .mr-tile:focus-visible { outline-color: Highlight; }
}

/* Reduce Motion: nothing moves. */
@media (prefers-reduced-motion: reduce) {
    .mr-tile,
    .mr-tip { transition: none; }
}

/* Smaller screens: 1100, 820 and 390 px. */
@media (max-width: 1100px) {
    .mr-split { grid-template-columns: minmax(0, 1fr); }
    .mr-g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mr-table th,
    .mr-table td { padding-right: 12px; padding-left: 12px; }
}
@media (max-width: 820px) {
    .mr-search { min-width: 0; flex-basis: 100%; }
    .mr-card .mr-table th,
    .mr-card .mr-table td { white-space: nowrap; }
}
@media (max-width: 560px) {
    .mr-title { flex-basis: 100%; }
    .mr-head > .mr-src { flex-basis: 100%; }
    .mr-head > .mr-icon-btn + .mr-title { flex-basis: auto; }
    .mr-actions { margin-left: 0; }
    .mr-stat { padding: 12px; }
    .mr-stat strong { font-size: 18px; }
    .mr-filters { display: grid; grid-template-columns: 1fr 1fr; }
    .mr-filters .mr-search,
    .mr-filters .mr-select { grid-column: 1 / -1; }
    .mr-filters .mr-seg > button { flex: 1; }
    .mr-select select { flex: 1; }
    .mr-scrim { padding: 16px 8px; }
}
