:root {
  color-scheme: light;
  --hm0: #efebe2; --hm1: #cce3fd; --hm2: #9dc8f7; --hm3: #6aabf1; --hm4: #338ced; --hm5: #1b64be;
  --bg: #f4f1ea;
  --surface: #fbfaf7;
  --surface-2: #efebe2;
  --border: #ddd6c8;
  --text: #1d1b17;
  --text-2: #6b655a;
  --accent: #b9831d;
  --accent-ink: #ffffff;
  --accent-soft: #f3e4c2;
  --good: #1d7f3a;
  --warn: #b54708;
  --grid: #e6e0d4;
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
  --s5: #ee7fac; --s6: #008a17; --s7: #6a4ce2; --s8: #ec4647;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 16px rgba(40, 30, 10, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --hm0: #202228; --hm1: #0e3d7e; --hm2: #1757ac; --hm3: #2370cd; --hm4: #338ced; --hm5: #84b9f3;
    --bg: #101114;
    --surface: #17181c;
    --surface-2: #202228;
    --border: #2e3038;
    --text: #ece9e2;
    --text-2: #9b978e;
    --accent: #e0ac46;
    --accent-ink: #17181c;
    --accent-soft: #3a3020;
    --good: #4cc26f;
    --warn: #f0954d;
    --grid: #26282f;
    --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
    --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --hm0: #202228; --hm1: #0e3d7e; --hm2: #1757ac; --hm3: #2370cd; --hm4: #338ced; --hm5: #84b9f3;
  --bg: #101114;
  --surface: #17181c;
  --surface-2: #202228;
  --border: #2e3038;
  --text: #ece9e2;
  --text-2: #9b978e;
  --accent: #e0ac46;
  --accent-ink: #17181c;
  --accent-soft: #3a3020;
  --good: #4cc26f;
  --warn: #f0954d;
  --grid: #26282f;
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
  --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* скрытое не должно перекрывать страницу, даже если у него есть display */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--text-2); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* шапка */
.topbar { position: sticky; top: 0; padding-top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 20px; min-height: 58px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 16px; white-space: nowrap; }
.brand-coin { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab { padding: 8px 12px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-weight: 500; white-space: nowrap; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--accent-soft); }
.topbar-right { display: flex; gap: 8px; align-items: center; }

/* элементы */
select, input[type=number], input[type=search] {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-height: 38px; max-width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 18px; border: 1px solid transparent; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.icon-btn { display: grid; place-items: center; font-size: 18px; width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check select { min-height: 30px; padding: 2px 6px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.panel > summary { cursor: pointer; font-weight: 600; }

.page { padding: 24px 0 8px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; }
.scan-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }

.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px 20px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 13px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }

.progress { position: relative; height: 26px; margin: 16px 0 0; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.progress-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-soft); transition: width .2s; }
.progress-text { position: relative; display: block; text-align: center; font-size: 13px; line-height: 26px; }

.results-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 20px 0 8px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font: inherit; font-size: 13px; font-weight: 500; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.pill.active { background: var(--text); color: var(--bg); border-color: var(--text); }
#dealSearch { min-width: 240px; flex: 0 1 300px; }
.summary { color: var(--text-2); font-size: 13px; margin-bottom: 8px; min-height: 20px; }

/* таблицы */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--text); }
th.sorted::after { content: " ↓"; }
th.sorted.asc::after { content: " ↑"; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; }
.deals tbody tr { cursor: pointer; }
.deals tbody tr:hover { background: var(--surface-2); }
.item-cell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.item-cell img { width: 44px; height: 44px; flex: none; }
.item-name { font-weight: 600; }
.sub { font-size: 12px; color: var(--text-2); }
.price { font-weight: 600; }
.profit { color: var(--good); font-weight: 700; white-space: nowrap; }
.risk { color: var(--warn); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.tag.new { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.old { color: var(--warn); }
.empty { padding: 48px 16px; text-align: center; color: var(--text-2); }
.empty-icon { font-size: 36px; }
.more-row { text-align: center; margin: 14px 0; }

/* цены */
.search-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.combo { position: relative; flex: 1 1 320px; }
.combo input { width: 100%; font-size: 16px; min-height: 46px; }
.combo-list { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 360px; overflow: auto; }
.combo-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.combo-list li img { width: 32px; height: 32px; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--surface-2); }
#priceQuality { min-height: 46px; }
.item-card { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 14px; }
.prices td.best { color: var(--good); font-weight: 700; }
.chart-panel { margin-top: 18px; position: relative; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart-head h3 { margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 4px; }
.legend button { font: inherit; font-size: 13px; display: flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--text); cursor: pointer; padding: 2px 0; }
.legend button[aria-pressed="false"] { color: var(--text-2); opacity: .55; }
.legend .sw { width: 14px; height: 4px; border-radius: 2px; }
.chart { width: 100%; height: 300px; }
.chart svg { display: block; width: 100%; height: 100%; }
.chart text { fill: var(--text-2); font-size: 11px; }
.chart .gridline { stroke: var(--grid); }
.chart .crosshair { stroke: var(--text-2); stroke-dasharray: 3 3; }
.chart-empty { display: grid; place-items: center; height: 100%; color: var(--text-2); }
.tooltip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow); font-size: 13px; min-width: 170px; }
.tooltip .t-date { font-weight: 600; margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 6px; }
.tooltip .t-row b { margin-left: auto; padding-left: 12px; }
.tooltip .sw { width: 10px; height: 10px; border-radius: 50%; }
.chart-table { margin-top: 10px; }
.chart-table summary { cursor: pointer; color: var(--text-2); font-size: 13px; }
.chart-table .table-wrap { margin-top: 8px; max-height: 320px; box-shadow: none; }

.small-note { font-size: 13px; margin: 10px 0 0; }
.gold-badge { font-size: 13px; font-weight: 600; text-decoration: none; color: var(--text); background: var(--accent-soft); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.fav-btn { margin-left: auto; }
.fav-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.calc { margin-top: 24px; }
.calc h2 { margin-bottom: 4px; }
.inline-field { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.inline-field input { width: 90px; }
.price-input { width: 120px; text-align: right; min-height: 32px !important; padding: 4px 8px !important; }
.calc-result { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 14px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--text-2); }
.stat .v { font-size: 20px; font-weight: 700; }
.stat .v.good { color: var(--good); }
.stat .v.bad { color: var(--warn); }
.my-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.wide-panel { grid-column: 1 / -1; position: relative; }
.table-wrap.flat { box-shadow: none; margin-top: 10px; }
.watch-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.watch-form .combo { flex: 1 1 200px; }
.watch-form .combo input { min-height: 38px; font-size: 15px; }
.watch-form input[type=number] { width: 120px; }
.icon-del { background: none; border: 0; color: var(--text-2); cursor: pointer; font-size: 16px; }
.hit { color: var(--good); font-weight: 700; }
.chart.small { height: 220px; }
#tab-pvp .panel, #tab-my .panel { margin-bottom: 14px; }
.pvp-search input { flex: 1 1 300px; font-size: 16px; min-height: 46px; }
.result-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 16px; }
.result { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.result:hover { background: var(--surface-2); }
.pvp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.pvp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.pvp-cols .panel { min-width: 0; }
.gear { display: flex; flex-wrap: wrap; gap: 2px; min-width: 150px; }
.gear-item { position: relative; width: 36px; height: 36px; }
.gear-item img { width: 36px; height: 36px; }
.gear-item b { position: absolute; right: 0; bottom: 0; font-size: 10px; background: var(--surface); border-radius: 4px; padding: 0 3px; }
.events td { vertical-align: top; }
.nowrap { white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover { background: var(--surface-2); }
.regear-controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 10px 0 14px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
#tab-analytics .panel { margin-bottom: 14px; }
#tab-analytics h2 { font-size: 18px; }
.route-row { display: flex; gap: 6px; align-items: center; }
.route-row select { flex: 1; min-width: 0; }
.route-cities { grid-column: span 2; }
.warn-stat { background: var(--accent-soft); }
.v.small, .muted.small { font-size: 13px; font-weight: 500; }
.bars { position: relative; }
.bars svg text { fill: var(--text-2); font-size: 11px; }
.bars .gridline { stroke: var(--grid); }
.spark { display: block; }
.trend td { vertical-align: middle; }
.pvp-links { display: flex; gap: 8px; flex-wrap: wrap; }
.tops-boards { margin: 12px 0; }
.leaderboard { list-style: none; margin: 0; padding: 0; }
.leaderboard li { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.leaderboard li:last-child { border-bottom: 0; }
.leaderboard li:nth-child(-n+3) { font-size: 16px; }
.lb-place { width: 30px; text-align: center; flex: none; color: var(--text-2); font-weight: 600; }
.lb-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.leaderboard b { font-variant-numeric: tabular-nums; }
.prem-btn { font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; white-space: nowrap; }
.prem-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.prem-btn[aria-pressed="true"] .prem-off, .prem-btn[aria-pressed="false"] .prem-on { display: none; }
.calc-route { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; margin: 4px 0 16px; padding: 12px; background: var(--surface-2); border-radius: 12px; }
.help-banner { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--accent); font-size: 14px; }
.help-banner a { font-weight: 600; }
.fresh-panel { margin-top: 14px; }
.fresh-panel summary { font-weight: 600; }
.live-toggle input:checked + * , .live-toggle:has(input:checked) { color: var(--text); font-weight: 600; }
.route-tools { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 12px; }
.route-actions { white-space: nowrap; }
.qty-input { width: 70px; min-height: 32px !important; padding: 4px 6px !important; text-align: right; }
.route-actions .btn.small { padding: 5px 10px; }
.journal td { vertical-align: top; }
.sell-row td { background: var(--surface-2); }
.sell-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.sell-form input { width: 120px; min-height: 34px; }
.csv-box { width: 100%; margin-top: 10px; font: 12px/1.4 ui-monospace, monospace; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.best-panel { margin-top: 16px; }
.best-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 10px; }
.best-card { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.best-card:hover, .best-card:focus-visible { border-color: var(--accent); }
.best-route { font-weight: 600; }
.best-card .profit { font-size: 18px; }
.route-notice { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.buy-check { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; margin: 0 4px; }
.buy-check input { width: 18px; height: 18px; accent-color: var(--accent); }
#routeTable tr.bought td { background: color-mix(in srgb, var(--good) 10%, transparent); }
#routeTable tr.bought .item-name { text-decoration: line-through; text-decoration-color: var(--text-2); }
.travel-edit input { width: 52px; min-height: 26px; padding: 2px 4px; font-size: 13px; }
.insights h4 { margin: 14px 0 0; }
.subnav { margin: -4px 0 16px; }
.ctab > .panel { margin-bottom: 14px; }
.ctab h2 { font-size: 18px; margin: 0; }
.compare-form { margin: 0 0 14px; }
.compare-form input { flex: 1 1 240px; }
.compare td.best { color: var(--good); font-weight: 700; }
.watch-chips { margin-top: 8px; }
.watch-chips .chip { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.watch-chips a { color: var(--text); }
.mtab .small-note { margin: 0 0 10px; }
#mkControls { margin-bottom: 14px; }
#mkControls h2 { font-size: 18px; margin: 0; }
.heatmap { display: flex; flex-direction: column; gap: 2px; overflow-x: auto; padding-bottom: 4px; }
.hm-row { display: grid; grid-template-columns: 28px repeat(24, minmax(14px, 1fr)); gap: 2px; min-width: 420px; }
.hm-head span { font-size: 10px; color: var(--text-2); text-align: left; }
.hm-day { font-size: 12px; color: var(--text-2); line-height: 18px; }
.hm-cell { display: inline-block; height: 18px; border-radius: 3px; min-width: 14px; }
.hm-legend { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.hm-legend .hm-cell { width: 16px; height: 12px; }
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 14px; margin-top: 10px; }
.build-slot { display: grid; grid-template-columns: 1fr auto; gap: 4px; align-items: end; }
.build-slot .label { grid-column: 1 / -1; }
.build-slot input { width: 100%; }
.pop-build { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pop-build:last-child { border-bottom: 0; }
.gs-modal { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.gs-box { width: min(620px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; }
.gs-box input { width: 100%; font-size: 17px; min-height: 46px; }
.gs-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 55vh; overflow: auto; }
.gs-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.gs-list li img { width: 32px; height: 32px; }
.gs-list li[aria-selected="true"], .gs-list li:hover { background: var(--surface-2); }
.gs-kind { margin-left: auto; font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.gs-hint { margin-top: 8px; }
.sync-code { font-size: 15px; letter-spacing: .06em; padding: 6px 10px; }
.fb-form { display: flex; flex-direction: column; gap: 10px; }
.fb-form textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; resize: vertical; }
.fb-form input { width: 100%; }
.footer a { color: var(--text-2); margin: 0 8px; }
.lang-btn { font-size: 12px; font-weight: 700; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.help-grid p { margin: 0; color: var(--text-2); }
.footer { padding: 28px 16px 36px; font-size: 13px; text-align: center; }

/* телефон: сделки карточками */
@media (display-mode: standalone) { .footer { padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px)); } }
@media (max-width: 420px) { .brand b { display: none; } .topbar-right { gap: 4px; } .prem-btn .prem-on, .prem-btn .prem-off { display: none !important; } .prem-btn { padding: 6px 8px; } }
@media (max-width: 720px) {
  .brand-long { display: none; }
  .brand { gap: 8px; }
  .topbar-right { gap: 6px; }
  .topbar-right { flex-wrap: nowrap; }
  .topbar-right select { padding: 4px 6px; min-height: 34px; font-size: 14px; max-width: 96px; }
  .topbar-right .icon-btn { width: 34px; height: 34px; }
  .prem-btn { padding: 6px 9px; font-size: 12px; }
  #installBtn { padding: 6px 10px; }
  .route-cities { grid-column: auto; }
  .pvp-cols { grid-template-columns: 1fr; }
  .my-grid { grid-template-columns: 1fr; }
  .gold-badge { display: none; }
  h1 { font-size: 22px; }
  .topbar-inner { gap: 8px 12px; padding-top: 8px; padding-bottom: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .topbar-right { margin-left: auto; }
  #dealSearch { flex: 1 1 100%; min-width: 0; }
  .deals thead { display: none; }
  .deals, .deals tbody, .deals tr, .deals td { display: block; width: 100%; }
  .deals tr { padding: 12px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .deals td { border: 0; padding: 0; }
  .deals td:first-child { grid-column: 1 / -1; }
  .deals td.num { text-align: left; }
  .deals td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
  .item-cell { min-width: 0; }
  .chart { height: 240px; }
}

/* Accessible navigation and lightweight search landing pages. */
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 12px; background: var(--surface); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.seo-header { padding-top: 20px; padding-bottom: 20px; font-weight: 700; }
.seo-landing { max-width: 860px; padding-bottom: 20px; }
.seo-landing .panel { margin-bottom: 16px; }
.seo-cta { display: inline-block; text-decoration: none; margin: 8px 0; }
.seo-links { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0; list-style: none; }
.footer .seo-links { justify-content: center; }
@media (max-width: 720px) {
  .topbar-inner { gap: 8px; }
  .topbar-right { flex-wrap: wrap; min-width: 0; max-width: 100%; }
  .topbar-right .icon-btn { width: 44px; height: 44px; }
  .topbar-right select, .prem-btn, #installBtn { min-height: 44px; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--border); padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px)); overscroll-behavior-x: contain; }
  .tabs .tab { flex: 0 0 auto; display: flex; align-items: center; min-height: 44px; padding: 8px 12px; }
  body:has(.tabs) { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .deals tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deals td { min-width: 0; overflow-wrap: anywhere; }
  .seo-links a { display: inline-block; padding: 6px 0; }
}

.dashboard-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding: clamp(20px, 5vw, 48px);
  border-top: 3px solid var(--accent);
  background: linear-gradient(125deg, var(--accent-soft), var(--surface) 72%);
}
.dashboard-head h1 { font-size: clamp(28px, 5vw, 48px); }
.dashboard-head p { margin: 8px 0 0; color: var(--text-2); }
.dashboard-settings summary { cursor: pointer; min-height: 44px; align-content: center; }
.dashboard-settings fieldset { border: 1px solid var(--border); border-radius: 8px; }
.dashboard-settings label { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.dashboard-settings input { accent-color: var(--accent); }
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr));
  gap: 12px;
}
.dashboard-card { display: flex; flex-direction: column; min-width: 0; }
.dashboard-card h2 { font-size: 15px; color: var(--text-2); }
.dashboard-value { font-size: 19px; font-weight: 650; overflow-wrap: anywhere; }
.dashboard-card a { margin-top: auto; min-height: 44px; align-content: center; }

.deal-confidence summary { cursor: pointer; color: var(--text); }
.deal-confidence .sub { white-space: normal; }

.page > .page-head, .pvp-head { border-inline-start: 3px solid var(--accent); padding-inline-start: 14px; }
.tool-details { margin-block: 12px; }
.tool-details summary { cursor: pointer; min-height: 44px; align-content: center; font-weight: 650; }
.tool-details textarea { display: block; width: 100%; margin-block: 8px; background: var(--surface); color: var(--text); }
.table-wrap tbody tr:focus-within { outline: 1px solid var(--accent); outline-offset: -1px; }
@media (hover: hover) { .table-wrap tbody tr:hover { background-color: var(--surface-2); } }
@media (prefers-reduced-motion: no-preference) { .page:not([hidden]) { animation: section-in .15s ease-out; } }
@keyframes section-in { from { opacity: .8; } to { opacity: 1; } }

@media (max-width: 640px) {
  #dealsTable td[data-label="Купить"] button { min-height: 44px; margin: .25rem .25rem 0 0; }
  #dealsTable details summary { min-height: 36px; display: list-item; padding-block: .4rem; }
  .sell-form output { flex-basis: 100%; font-variant-numeric: tabular-nums; }
}
@media (max-width: 700px) {
  #journalBox .journal, #journalBox tbody { display: block; min-width: 0; width: 100%; }
  #journalBox thead { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  #journalBox tr:not([hidden]) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: .5rem; gap: .35rem; }
  #journalBox td { display: block; min-width: 0; white-space: normal; text-align: start; padding: .4rem; }
  #journalBox td:first-child, #journalBox td:last-child { grid-column: 1 / -1; }
  #journalBox td[data-label]::before { content: attr(data-label); display: block; color: var(--text-2); font-size: .75rem; }
  #journalBox button { min-height: 44px; }
  #journalBox .sell-form { display: grid; gap: .5rem; }
}

#buyIdeas .buy-idea {
  display: grid;
  gap: .75rem;
  padding: clamp(.85rem, 2vw, 1.25rem);
  margin-block: .7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
}
.buy-idea header, .buy-idea footer { display: flex; align-items: center; gap: .75rem; }
.buy-idea header img { background: var(--surface-2); border-radius: 9px; }
.buy-idea small { display: block; color: var(--text-2); font-size: .8rem; }
.idea-route { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: .65rem; background: var(--surface-2); padding: .8rem; border-radius: 8px; }
.idea-route div { display: grid; gap: .15rem; overflow-wrap: anywhere; }
.idea-route > span { color: var(--text-2); }
.buy-idea footer { justify-content: space-between; }
.buy-idea footer b { color: var(--good); font-size: 1.25rem; }
.buy-idea footer > span { background: var(--accent-soft); color: var(--text); border-radius: 6px; padding: .25rem .55rem; }
#buyIdeas > button { min-height: 44px; margin: .4rem; }
@media (min-width: 760px) {
  #buyIdeas .buy-idea { grid-template-columns: minmax(0,1fr) minmax(0,1.4fr) minmax(0,1fr); align-items: center; }
  .buy-idea > small { grid-column: 2 / -1; }
}

/* Common reading rhythm across scanner tools and static guides. */
.num, .stat .v, .dashboard-value { font-variant-numeric: tabular-nums; }
.tab[aria-current="page"] { box-shadow: inset 0 -2px var(--accent); }
.dashboard-card { border-top: 2px solid var(--accent); gap: .45rem; }
.dashboard-card .dashboard-value { margin-block: .2rem .65rem; }
.panel > summary { padding-block: .35rem; }
.trip-heading { width: 100%; grid-column: 1 / -1; margin-block: .4rem; }
.trip-profit { border-inline-start: 3px solid var(--good); }
.stock-item { display: flex; align-items: center; gap: .6rem; }
.stock-item img { flex: none; background: var(--surface-2); border-radius: 6px; }
.stock-item small, .guide-list span { display: block; color: var(--text-2); }
.reading { max-width: 76ch; margin-block: 1rem 3rem; }
.reading article { padding: clamp(1.1rem, 4vw, 2.8rem); }
.reading p { line-height: 1.65; }
.reading .lead { color: var(--text-2); font-size: 1.1rem; }
.reading h2 { margin-top: 1.6rem; }
.guide-list { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,210px),1fr)); gap: .8rem; margin-top: 1rem; }
.guide-list a { padding: 1rem; border: 1px solid var(--border); border-top: 2px solid var(--accent); border-radius: 10px; text-decoration: none; background: var(--surface-2); color: var(--text); }
.guide-list span { margin-top: .5rem; }
@media (max-width: 720px) {
  #routeTable .route-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .5rem; padding-top: .65rem; border-top: 1px solid var(--border); white-space: normal; }
  #routeTable .route-actions::before { display: none; }
  .route-actions label { display: grid; gap: .25rem; }
  .route-actions input[type=number] { width: 100%; min-height: 44px !important; }
  #routeTable .buy-check { display: flex; justify-content: center; align-items: center; background: var(--accent-soft); border-radius: 8px; min-height: 44px; }
  .route-actions .icon-del { justify-self: end; min-width: 44px; }
  #inventory-form, #inventory-value-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  #inventory-form > :first-child, #inventory-form > button, #inventory-value-form > button { grid-column: 1 / -1; }
  #inventory-form :is(select,input,button), #inventory-value-form :is(input,button) { min-height: 44px; }
}

.guide-library { max-width: 1080px; }
.guide-cover {
  padding: clamp(20px, 5vw, 52px);
  border-radius: 18px;
  color: #fff7e6;
  background: radial-gradient(ellipse at top right, #554735, transparent 65%), #232529;
  border-bottom: 4px solid #bc9456;
}
.guide-cover h1, .reading h1 { font-family: Georgia, serif; font-size: clamp(1.8rem, 4vw, 3rem); }
.guide-cover p { max-width: 52ch; color: #e5dfd4; }
.guide-cover nav { display: flex; flex-wrap: wrap; gap: .5rem; }
.guide-cover nav a { display: inline-flex; align-items: center; min-height: 44px; padding: .5rem .85rem; border: 1px solid #897a62; border-radius: 8px; color: #fff7e6; text-decoration: none; }
.guide-topic { margin-block: clamp(1.5rem, 4vw, 2.8rem); scroll-margin-top: 1rem; }
.guide-library .guide-list { grid-template-columns: repeat(auto-fit,minmax(min(100%,265px),1fr)); }
.guide-library .guide-list a { display: grid; grid-template-columns: 58px 1fr; align-content: start; align-items: center; gap: .6rem .8rem; background: var(--surface); box-shadow: var(--shadow); }
.guide-library .guide-list a:hover, .guide-library .guide-list a:focus-visible { border-color: var(--accent); }
.guide-list img { border-radius: 10px; background: var(--surface-2); }
.guide-library .guide-list span { grid-column: 1 / -1; margin: 0; line-height: 1.5; }
.guide-contents { padding: .8rem 1rem; border-inline-start: 3px solid var(--accent); background: var(--surface-2); border-radius: 6px; }
.guide-contents summary { cursor: pointer; font-weight: 650; }
.guide-contents li { margin-block: .5rem; }
.guide-contents a { color: var(--text); text-underline-offset: .2em; }
.reading section { scroll-margin-top: 1.2rem; }
.reading section:target h2 { border-inline-start: 3px solid var(--accent); padding-inline-start: .6rem; }

.shopping { margin-block: 1rem; }
.shopping section { border-top: 1px solid var(--border); padding-block: 1rem; }
.shopping-line { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding-block: .5rem; }
.shopping-line > span { flex: 1 1 180px; }
.shopping-line small { display: block; color: var(--text-2); }
.shopping-line input { width: 6rem; }

/* Keep the main phone workflow within easy reach. */
#scanResultsHeading, #shopping > summary { scroll-margin-top: calc(108px + env(safe-area-inset-top, 0px)); }
#scanResultsHeading { margin-block: 20px 0; font-size: 1.15rem; }
#scanResultsHeading + .results-head, #scanResultsHeading + [hidden] + .results-head { margin-top: 8px; }
.deal-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.deal-actions .deal-shopping { border-color: var(--accent); }
@media (max-width: 720px) {
  #tab-deals :is(.scan-box button, .deal-actions button, #shopping button, #shopping > summary, #settingsPanel > summary, .shopping-line input) {
    min-height: 44px;
  }
  #tab-deals :is(#shopping, #settingsPanel) > summary { align-content: center; }
  .deal-actions button { min-width: 44px; max-width: 100%; white-space: normal; }
  .deal-actions .deal-shopping { flex: 1 1 100%; }
  .shopping-line input { font-size: 16px; }
}

.scan-empty { padding: clamp(18px, 5vw, 42px) 16px; }
.scan-empty h3 { margin: 0; color: var(--text); }
.scan-empty p { max-width: 55ch; margin: .65rem auto 1rem; }
.scan-empty button { min-height: 44px; max-width: 100%; }
#settingsPanel :is(input, button, summary) { scroll-margin-top: calc(108px + env(safe-area-inset-top, 0px)); }


/* Per-server favorite routes */
.favorite-routes, .favorite-route-active { margin-bottom: 12px; }
.favorite-route-active h2 { margin: 0; font-size: 1.15rem; }
.favorite-route-active p { margin: 7px 0; }
.favorite-route-list { padding: 0; list-style: none; display: grid; gap: 7px; }
.favorite-route-list li { display: flex; align-items: stretch; gap: 7px; min-width: 0; }
.favorite-route-list li button:first-child { flex: 1; min-width: 0; white-space: normal; text-align: left; }
.favorite-route-list button { min-height: 44px; }
.favorite-route-form { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.favorite-route-form .field { flex: 1 1 145px; }
.favorite-route-form select { width: 100%; }
#favorite-route-status:empty { display: none; }

/* Short reading guide beneath the dashboard widgets. */
.home-trade-guide { margin-top: 16px; }
.home-trade-guide h2 { margin: 0 0 10px; }
.home-trade-guide ol { padding-inline-start: 1.25em; }
.home-trade-guide li + li { margin-top: 8px; }

.route-alternatives { margin-top: 12px; }
.route-alternatives h2 { margin: 0; font-size: 1.15rem; }
.route-alternative-list { display: grid; gap: 8px; list-style: none; padding: 0; }
.route-alternative-list li { border-top: 1px solid var(--border); padding-top: 8px; }
.route-alternative-list a { display: inline-flex; align-items: center; min-height: 44px; margin-top: 4px; }
