/* Mercado Cripto — v1.0.0 */
:root {
  color-scheme: light;
  --bg: #F2F4F8;
  --surface: #FFFFFF;
  --surface-2: #F7F8FB;
  --ink: #15233B;
  --muted: #5B6B82;
  --line: #DDE3EB;
  --accent: #3446C9;
  --accent-soft: #E6E9FB;
  --up: #0A8F5B;
  --up-soft: #E3F5EC;
  --down: #CF3A3A;
  --down-soft: #FBE8E8;
  --star: #E8A317;
  --btc: #F2A33A;
  --eth: #6B7BD8;
  --other: #A9B4C3;
  --pad: clamp(14px, 2.4vw, 36px);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E1522; --surface: #151F30; --surface-2: #1A2639; --ink: #E6ECF4; --muted: #93A3B8;
    --line: #26344A; --accent: #8A98FF; --accent-soft: #232D52; --up: #2BC48A; --up-soft: #12302A;
    --down: #FF6B6B; --down-soft: #3A1E25; --star: #F5B83D; --other: #5E6C82;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1522; --surface: #151F30; --surface-2: #1A2639; --ink: #E6ECF4; --muted: #93A3B8;
  --line: #26344A; --accent: #8A98FF; --accent-soft: #232D52; --up: #2BC48A; --up-soft: #12302A;
  --down: #FF6B6B; --down-soft: #3A1E25; --star: #F5B83D; --other: #5E6C82;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums; min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Topo */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px;
  padding: 12px var(--pad); background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(var(--btc) 0 55%, var(--eth) 55% 72%, var(--other) 72% 100%);
}
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.on { color: var(--ink); background: var(--surface-2); }
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input {
  width: 100%; height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2);
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(15, 25, 45, .16); max-height: 420px; overflow-y: auto;
}
.search-results a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--ink); }
.search-results a:hover, .search-results a.active { background: var(--surface-2); text-decoration: none; }
.search-results img { width: 22px; height: 22px; border-radius: 50%; }
.search-results .sym { margin-left: 2px; }
.search-results .r { margin-left: auto; color: var(--muted); font-size: 13px; }
.search-results .none { padding: 10px; color: var(--muted); }
.tools { display: flex; align-items: center; gap: 8px; }
.tools select, .icon-btn {
  height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); padding: 0 10px; cursor: pointer;
}
.icon-btn { width: 38px; padding: 0; font-size: 18px; line-height: 1; }

/* Faixa global */
.global {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  padding: 12px var(--pad); background: var(--surface); border-bottom: 1px solid var(--line); font-size: 14px;
}
.g-item { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.g-lbl { color: var(--muted); }
.g-val { font-weight: 650; }
.g-dom { flex: 1; min-width: 280px; }
.dom-bar { flex: 1; display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--line); min-width: 120px; }
.dom-bar span { height: 100%; transition: width .4s ease; }
.dom-legend { display: flex; gap: 12px; color: var(--muted); }
.dom-legend b { color: var(--ink); font-weight: 650; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }

/* Conteúdo */
.wrap { flex: 1; width: 100%; padding: 24px var(--pad) 32px; }
h1 { font-size: clamp(20px, 2.2vw, 26px); line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.tabs a { padding: 6px 14px; border-radius: 7px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a[aria-selected="true"] { background: var(--accent); color: var(--surface); }
.count { font-size: 12px; padding: 0 7px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.tabs a[aria-selected="true"] .count { background: var(--surface); color: var(--accent); }
.count:empty { display: none; }

.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--down-soft); color: var(--down); }
.notice.info { background: var(--accent-soft); color: var(--accent); }

/* Tabela */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.coins { width: 100%; border-collapse: collapse; min-width: 1180px; }
.coins th, .coins td { padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: left; white-space: nowrap; }
.coins tbody tr:last-child td { border-bottom: 0; }
.coins thead th { position: sticky; top: 0; background: var(--surface); font-size: 13px; color: var(--muted); font-weight: 600; z-index: 2; }
.coins th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.coins th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.coins th button[data-dir]::after { content: "▲"; font-size: 9px; }
.coins th button[data-dir="-1"]::after { content: "▼"; }
.coins .num { text-align: right; }
.coins th.num button { justify-content: flex-end; }
.coins tbody tr:hover td { background: var(--surface-2); }
.coins .c-fav { width: 44px; padding-right: 0; }
.coins .c-rank { width: 52px; color: var(--muted); }
.coins .c-spark { width: 140px; text-align: right; }
.coins td.c-fav, .coins td.c-rank, .coins td.c-name { position: sticky; background: var(--surface); z-index: 1; }
.coins td.c-fav { left: 0; } .coins td.c-rank { left: 44px; } .coins td.c-name { left: 96px; }
.coins th.c-fav { left: 0; z-index: 3; } .coins th.c-rank { left: 44px; z-index: 3; } .coins th.c-name { left: 96px; z-index: 3; }
.coins th.c-fav, .coins th.c-rank, .coins th.c-name { position: sticky; }
.coins tbody tr:hover td.c-fav, .coins tbody tr:hover td.c-rank, .coins tbody tr:hover td.c-name { background: var(--surface-2); }
.coins .c-fav, .coins .c-rank { min-width: 44px; max-width: 44px; box-sizing: border-box; }
.coins .c-rank { min-width: 52px; max-width: 52px; }
.coin-link { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; }
.coin-link:hover { text-decoration: none; }
.coin-link:hover .nm { text-decoration: underline; }
.coin-link .nm { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.coin-link .sym { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
.coin-link img { width: 26px; height: 26px; border-radius: 50%; flex: none; }
.sym { color: var(--muted); font-weight: 500; font-size: .9em; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px !important; white-space: normal !important; }

.star { border: 0; background: none; cursor: pointer; font-size: 18px; line-height: 1; color: var(--other); opacity: .6; padding: 4px; }
.star[aria-pressed="true"], .star:hover { opacity: 1; }
.star:hover { color: var(--muted); }
.star[aria-pressed="true"] { color: var(--star); }
.star.big { font-size: 28px; }

.pct { font-weight: 600; }
.pct.up { color: var(--up); }
.pct.down { color: var(--down); }
.pct.up::before { content: "▲ "; font-size: .7em; vertical-align: 1px; }
.pct.down::before { content: "▼ "; font-size: .7em; vertical-align: 1px; }
.spark { width: 120px; height: 36px; display: inline-block; vertical-align: middle; }
.spark polyline { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark.up polyline { stroke: var(--up); }
.spark.down polyline { stroke: var(--down); }

td.flash-up { animation: flashUp 1.2s ease-out; }
td.flash-down { animation: flashDown 1.2s ease-out; }
@keyframes flashUp { from { background: var(--up-soft); } }
@keyframes flashDown { from { background: var(--down-soft); } }

.pager { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 38px; height: 38px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }
.pager a { color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.pager span { color: var(--muted); }

/* Detalhe */
.crumbs { display: flex; gap: 8px; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.coin-head {
  display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 22px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px;
}
.coin-id { display: flex; align-items: center; gap: 16px; }
.coin-id img { width: 48px; height: 48px; border-radius: 50%; }
.coin-meta { display: flex; align-items: center; gap: 10px; margin-top: 6px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.rank:not(:empty) { background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 6px; font-weight: 650; }
.coin-price { text-align: right; }
.price { font-size: clamp(28px, 3.6vw, 44px); font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.changes { display: flex; gap: 14px; justify-content: flex-end; margin-top: 6px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }

.coin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.chart-card, .stats, .about { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.chart-card { padding: 18px 20px; }
.chart-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 25, 45, .12); }
.chart { position: relative; height: 380px; }
.chart svg { display: block; width: 100%; height: 100%; }
.chart .grid line { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .axis text { fill: var(--muted); font-size: 12px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart.up .line { stroke: var(--up); } .chart.down .line { stroke: var(--down); }
.chart.up .area { fill: var(--up); opacity: .10; } .chart.down .area { fill: var(--down); opacity: .10; }
.chart .cross { stroke: var(--muted); stroke-dasharray: 2 3; }
.chart .hdot { stroke: var(--surface); stroke-width: 2; }
.chart.up .hdot { fill: var(--up); } .chart.down .hdot { fill: var(--down); }
.chart .tip {
  position: absolute; pointer-events: none; padding: 8px 10px; border-radius: 8px; font-size: 13px; white-space: nowrap;
  background: var(--ink); color: var(--surface); transform: translate(-50%, calc(-100% - 12px));
}
.chart .tip b { display: block; font-size: 14px; }
.chart .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; }
.chart-note { margin: 10px 0 0; color: var(--muted); font-size: 13px; min-height: 1.5em; }

.stats { padding: 6px 20px 16px; }
.stats dl { margin: 0; }
.stats .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-weight: 600; }
.stats dd small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.row-range dd { flex: 1; }
.range-bar { width: 100%; height: 6px; background: var(--line); border-radius: 3px; position: relative; margin: 6px 0 2px; }
.range-bar i { position: absolute; top: -3px; width: 4px; height: 12px; border-radius: 2px; background: var(--ink); transform: translateX(-50%); }
.links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.links a { padding: 6px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }

.about { padding: 20px 24px; margin-top: 20px; }
.about h2 { margin: 0 0 10px; font-size: 18px; }
.desc { white-space: pre-line; max-width: 80ch; color: var(--ink); }
.desc.clamp { max-height: 9em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px 0; font-weight: 600; }

.foot {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px var(--pad); color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); background: var(--surface);
}

@media (max-width: 1100px) {
  .coin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 10px 14px; }
  .search { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
  .tools { margin-left: auto; }
  .global { gap: 10px 20px; }
  .g-dom { flex-basis: 100%; flex-wrap: wrap; white-space: normal; }
  .dom-bar { flex-basis: 100%; }
  .dom-legend { flex-wrap: wrap; }
  .coin-price { text-align: left; }
  .changes { justify-content: flex-start; }
  .chart { height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
