/* Таблица сырья и фьючерсов. Стили не затрагивают экономический календарь. */
.mi-market {--mi-border:#d9dce1;--mi-accent:#2f80c0;--mi-muted:#6b7078;width:100%;min-width:0;color:#333;font-size:13px;line-height:1.5;}
.mi-market *, .mi-market *::before, .mi-market *::after, .mi-history *, .mi-history *::before, .mi-history *::after {box-sizing:border-box;}
.mi-market [hidden], .mi-history [hidden] {display:none!important;}
.mi-market__filters {display:flex;flex-direction:column;gap:16px;margin:0 0 20px;padding:20px 24px;border:1px solid #e5e7ea;border-radius:12px;background:#f6f7f8;}
.mi-market__top {padding-bottom:14px;border-bottom:1px solid #e2e5e8;}
.mi-market__fields {display:flex;flex-wrap:wrap;align-items:flex-end;gap:14px;}
.mi-market .mi-market__fields label {display:flex;flex:1 1 145px;flex-direction:column;gap:7px;min-width:0;margin:0;color:var(--mi-muted);font-size:12px;font-weight:400;}
.mi-market .mi-market__fields input, .mi-market .mi-market__fields select, .mi-market .mi-market__search input {display:block;width:100%;min-width:0;height:40px;margin:0;padding:0 12px;border:1px solid var(--mi-border);border-radius:7px;background:#fff;color:#333;font:inherit;font-size:13px;box-shadow:none;transition:border-color .15s,box-shadow .15s;}
.mi-market .mi-market__fields select {appearance:none;padding-right:34px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%23777' stroke-width='1.5'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;}
.mi-market .mi-market__fields input:hover, .mi-market .mi-market__fields select:hover, .mi-market .mi-market__search input:hover {border-color:#bfc4ca;}
.mi-market .mi-market__fields input:focus, .mi-market .mi-market__fields select:focus, .mi-market .mi-market__search input:focus {outline:none;border-color:var(--mi-accent);box-shadow:0 0 0 3px rgba(47,128,192,.12);}
.mi-market .mi-market__submit {flex:0 0 auto;height:40px;margin:0;padding:0 22px;border:1px solid #333;border-radius:7px;background:#333;color:#fff;font:inherit;cursor:pointer;}
.mi-market .mi-market__submit:hover {background:#484848;}
.mi-market .mi-market__switch {position:relative;display:inline-flex;align-items:center;gap:10px;min-height:28px;margin:0;font-size:13px;font-weight:400;cursor:pointer;}
.mi-market__switch input {position:absolute;width:1px;height:1px;margin:0;padding:0;opacity:0;clip-path:inset(50%);}
.mi-market__track {position:relative;display:inline-block;flex:0 0 38px;width:38px;height:22px;border-radius:11px;background:#b8bdc5;transition:background-color .2s;}
.mi-market__track span {position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.15);transition:transform .2s;}
.mi-market__switch input:checked ~ .mi-market__track {background:var(--mi-accent);}
.mi-market__switch input:checked ~ .mi-market__track span {transform:translateX(16px);}
.mi-market__main-label, .mi-market__all-label {color:#777;}
.mi-market__switch input:not(:checked) ~ .mi-market__main-label, .mi-market__switch input:checked ~ .mi-market__all-label {color:#333;font-weight:600;}
.mi-market__switch input:focus-visible ~ .mi-market__track {outline:3px solid rgba(47,128,192,.3);outline-offset:3px;}
.mi-market__toolbar {display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:12px;margin-bottom:12px;}
.mi-market .mi-market__search {display:flex;flex:0 1 420px;flex-direction:column;gap:7px;min-width:0;width:100%;margin:0;color:var(--mi-muted);font-size:12px;font-weight:400;}
.mi-market__count {padding-bottom:10px;font-size:12px;color:#777;}
.mi-market__note {margin:0 0 12px;color:#777;font-size:12px;}
.mi-market__table-wrap {width:100%;max-width:100%;overflow-x:auto;border:1px solid #e5e7ea;border-radius:10px;background:#fff;-webkit-overflow-scrolling:touch;}
.mi-market .mi-market__table {width:100%;min-width:1000px;table-layout:fixed;margin:0;border-collapse:separate;border-spacing:0;font-size:13px;background:#fff;}
.mi-market__col-name {width:auto;}
.mi-market__col-unit {width:105px;}
.mi-market__col-number {width:115px;}
.mi-market .mi-market__table th, .mi-market .mi-market__table td {height:46px;padding:10px;border:0;border-bottom:1px solid #eef0f2;line-height:1.45;vertical-align:middle;text-align:right;}
.mi-market .mi-market__table th {background:#f6f7f8;color:#666;font-size:12px;font-weight:500;}
.mi-market .mi-market__table th:first-child, .mi-market .mi-market__table td:first-child {text-align:left;overflow-wrap:anywhere;}
.mi-market .mi-market__table td:not(:first-child) {white-space:nowrap;font-variant-numeric:tabular-nums;}
.mi-market .mi-market__table tbody tr:last-child td {border-bottom:0;}
.mi-market .mi-market__table tbody tr:hover td {background:#fafbfc;}
.mi-market .mi-market__table th button {display:inline-flex;align-items:center;justify-content:flex-end;gap:4px;width:100%;margin:0;padding:0;border:0;background:none;color:inherit;font:inherit;text-align:inherit;cursor:pointer;}
.mi-market .mi-market__table th:first-child button {justify-content:flex-start;}
.mi-market__sort-arrow {min-width:10px;font-size:10px;color:#888;}
.mi-market th[aria-sort="ascending"] .mi-market__sort-arrow::after {content:'↑';}
.mi-market th[aria-sort="descending"] .mi-market__sort-arrow::after {content:'↓';}
.mi-market .mi-market__object {display:inline;margin:0;padding:0;border:0;background:none;color:#2f80c0;font:inherit;text-align:left;cursor:pointer;}
.mi-market .mi-market__object:hover {text-decoration:underline;}
.mi-market .mi-market__table .mi-market__close {font-weight:700;}
.mi-market .mi-market__table td[colspan] {height:70px;text-align:center;color:#777;white-space:normal;}
.mi-market__loading {display:inline-flex;align-items:center;justify-content:center;gap:8px;}
.mi-market__loading img {width:16px;height:16px;}
.mi-market .mi-positive, .mi-history .mi-positive {color:#208345;}
.mi-market .mi-negative, .mi-history .mi-negative {color:#c23b3b;}
.mi-market .mi-neutral, .mi-history .mi-neutral {color:#777;}
.mi-market button:focus-visible, .mi-market__table-wrap:focus-visible, .mi-history button:focus-visible, .mi-history__table-wrap:focus-visible {outline:2px solid #2f80c0;outline-offset:3px;}

/* Попап истории. */
.mi-history {width:min(1120px,calc(100vw - 40px));height:min(850px,calc(100dvh - 48px));max-width:none;max-height:none;margin:auto;padding:0;border:0;border-radius:12px;background:#fff;color:#333;box-shadow:0 12px 60px rgba(0,0,0,.22);font-family:inherit;font-size:13px;overflow:hidden;}
.mi-history::backdrop {background:rgba(0,0,0,.45);}
.mi-history[open] {display:flex;flex-direction:column;}
.mi-history.is-expanded {width:100vw;height:100dvh;border-radius:0;}
.mi-history__header {display:flex;align-items:center;justify-content:space-between;flex:0 0 auto;gap:16px;padding:16px 20px;border-bottom:1px solid #e5e7ea;background:#f6f7f8;}
.mi-history h2 {margin:0;font-size:18px;font-weight:600;line-height:1.4;}
.mi-history__subtitle {margin:4px 0 0;color:#777;font-size:12px;}
.mi-history__actions {display:flex;flex:0 0 auto;gap:8px;}
.mi-history button {display:inline-flex;align-items:center;justify-content:center;height:34px;margin:0;padding:0 12px;border:1px solid #d9dce1;border-radius:6px;background:#fff;color:#555;font:inherit;cursor:pointer;}
.mi-history button:hover {background:#f1f1f1;}
.mi-history button:disabled {opacity:.4;cursor:default;}
.mi-history .mi-history__close {width:34px;padding:0;font-size:24px;}
.mi-history__body {min-height:0;overflow-y:auto;padding:8px 20px 10px;}
.mi-history__status {display:flex;align-items:center;justify-content:center;gap:8px;min-height:90px;color:#777;}
.mi-history__chart {width:100%;height:330px;min-width:0;}
.mi-history.is-expanded .mi-history__chart {height:clamp(320px,48dvh,650px);}
.mi-history__table-header {display:flex;justify-content:space-between;align-items:center;gap:12px;margin:6px 0 8px;}
.mi-history__table-header h3 {margin:0;font-size:14px;font-weight:600;}
.mi-history__table-header > div {display:flex;gap:6px;}
.mi-history__table-wrap {max-width:100%;overflow-x:auto;border:1px solid #e5e7ea;border-radius:8px;-webkit-overflow-scrolling:touch;}
.mi-history .mi-history__table {width:max-content;min-width:100%;margin:0;border-collapse:separate;border-spacing:0;font-size:12px;}
.mi-history .mi-history__table th, .mi-history .mi-history__table td {min-width:130px;padding:8px 12px;border:0;border-bottom:1px solid #eef0f2;text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums;}
.mi-history .mi-history__table thead th {background:#f6f7f8;font-weight:500;color:#666;}
.mi-history .mi-history__table th:first-child {position:sticky;left:0;z-index:1;min-width:135px;background:#fff;text-align:left;color:#666;font-weight:500;border-right:1px solid #e5e7ea;}
.mi-history .mi-history__table thead th:first-child {background:#f6f7f8;z-index:2;}
.mi-history .mi-history__table tbody tr:last-child th, .mi-history .mi-history__table tbody tr:last-child td {border-bottom:0;}
.mi-history .mi-history__table .mi-history__close-row th, .mi-history .mi-history__table .mi-history__close-row td {background:#f3f8fc;font-weight:700;}

@media(max-width:760px) {
    .mi-market__filters {padding:18px 16px;}
    .mi-market__fields {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}
    .mi-market .mi-market__fields input, .mi-market .mi-market__fields select, .mi-market .mi-market__search input {height:44px;font-size:16px;}
    .mi-market .mi-market__submit {height:44px;}
    .mi-market__count {padding-bottom:0;}
	
	/* Закрепляем колонку с названием */
	.mi-market .mi-market__table th:first-child,
	.mi-market .mi-market__table td:first-child:not([colspan]) {
		position: sticky;
		left: 0;
		z-index: 2;
		background: #fff;
		box-shadow: 2px 0 4px rgba(0, 0, 0, .08);
	}

	.mi-market .mi-market__table thead th:first-child {
		z-index: 3;
		background: #f6f7f8;
	}

	.mi-market .mi-market__table tbody tr:hover td:first-child {
		background: #fafbfc;
	}
	
}
@media(max-width:480px) {
    .mi-market__filters {padding:16px 12px;}
    .mi-market__fields {grid-template-columns:minmax(0,1fr);}
    .mi-market .mi-market__search {flex-basis:100%;}
    .mi-market .mi-market__submit {width:100%;}
    .mi-history {width:calc(100vw - 16px);height:calc(100dvh - 20px);}
    .mi-history__header {padding:12px;align-items:flex-start;gap:8px;}
    .mi-history h2 {font-size:15px;}
    .mi-history__body {padding:8px 12px;}
    .mi-history__chart {height:280px;}
    .mi-history button {height:40px;padding:0 8px;}
    .mi-history .mi-history__close {width:40px;}
}
@media(prefers-reduced-motion:reduce) {.mi-market *, .mi-history * {transition:none!important;}}

/* Онлайн-статус берётся из quotes.json; серый также для отсутствующей/устаревшей цены. */
.mi-market__name-wrap {display:inline-flex;align-items:center;gap:8px;min-width:0;}
.mi-market__status-dot {display:inline-block;flex:0 0 8px;width:8px;height:8px;border-radius:50%;background:#a8afb8;cursor:help;}
.mi-market__status-dot.is-on {background:#28a35a;}
.mi-market__status-dot:focus-visible {outline:2px solid #2f80c0;outline-offset:3px;}
.mi-market__note:empty {display:none;}
