@import url("./card-foundation.css");
@import url("./market-card-shared.css");
@import url("./rotating-card-shared.css");

:root {
  /* Фон/текст совпадают с основным сайтом (globals.css theme-b): фон rgb(13,20,33) */
  --bg: #0d1421;
  --panel: #161b22;
  --panel-2: #1c232c;
  --border: #2a313c;
  --text: #f8fafc;
  --muted: #8b97a7;
  --pos: #2ea043;
  --pos-soft: rgba(46,160,67,.14);
  --neg: #e5534b;
  --neg-soft: rgba(229,83,75,.14);
  --accent: #388bfd;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}
html.light, body.light {
  /* Светлая тема = основной сайт (globals.css theme-a): фон #ffffff, текст #111827 */
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f0f3f6;
  --border: #d8dee4;
  --text: #111827;
  --muted: #656d76;
  --pos: #1a7f37;
  --pos-soft: rgba(26,127,55,.12);
  --neg: #cf222e;
  --neg-soft: rgba(207,34,46,.10);
  --accent: #0969da;
  --shadow: 0 1px 3px rgba(140,149,159,.25);
}

body.embedded { background: var(--bg); min-height: 100vh; }

/* ───── Toolbar ───── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.search-input {
  width: 180px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text); font: inherit;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.sorts { display: flex; gap: 6px; flex-wrap: wrap; }
.sortbtn {
  padding: 7px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--muted); font: inherit; cursor: pointer;
}
.sortbtn:hover { color: var(--text); }
.meta { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.stale-badge {
  background: var(--neg-soft); color: var(--neg); border: 1px solid var(--neg);
  border-radius: 6px; padding: 1px 6px; font-size: 11px;
}
.ranking-info {
  margin: -3px 0 13px; color: var(--muted); font-size: 12px;
  overflow-wrap: anywhere;
}

.errbox {
  margin-bottom: 14px; padding: 10px 12px; border-radius: 8px;
  background: var(--neg-soft); border: 1px solid var(--neg); color: var(--neg); font-size: 13px;
}

/* ───── Таблица ───── */
.board { margin-bottom: 18px; }
.board-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.board-head h2 { font-size: 16px; margin: 0; }
.board-sub { color: var(--muted); font-size: 12px; }
.table-scroll {
  border: 1px solid var(--border); border-radius: 12px; overflow-x: auto;
  background: var(--panel); box-shadow: var(--shadow);
}
.ftable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ftable th, .ftable td { padding: 9px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
.ftable thead th {
  background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .3px; position: sticky; top: 0; z-index: 1; user-select: none;
}
.ftable th.num, .ftable td.num { text-align: right; }
.ftable th.sortable { cursor: pointer; }
.ftable th.sortable:hover { color: var(--text); }
.ftable th.active { color: var(--accent); }
.ftable tbody tr:last-child td { border-bottom: none; }
.ftrow { cursor: pointer; transition: background .12s; }
.ftrow:hover { background: var(--panel-2); }
.ftrow.sel { background: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.ftrow.sel { background: rgba(56,139,253,.10); }
.c-rank { color: var(--muted); }
.coin-sym { font-weight: 700; }
.c-w b { font-weight: 700; }
.c-w .w-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.ftable td.pos, .byx td.pos, .hist-summary b.pos { color: var(--pos); }
.ftable td.neg, .byx td.neg, .hist-summary b.neg { color: var(--neg); }
.c-ex.empty { color: var(--muted); opacity: .5; }
.c-w.pos { background: var(--pos-soft); }
.c-w.neg { background: var(--neg-soft); }

.board-empty { padding: 16px; text-align: center; color: var(--muted); }

/* ───── Drill-down ───── */
.detail {
  margin-bottom: 16px; padding: 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.detail-head h2 { font-size: 16px; margin: 0; }
.detail-head #detailCoin { color: var(--accent); font-weight: 700; }
.detail-close {
  margin-left: auto; width: 28px; height: 28px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); font-size: 18px; line-height: 1;
}
.detail-close:hover { color: var(--text); }
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 760px) { .detail-grid { grid-template-columns: 1fr; } }
.chart-sub, .byx-sub { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.hist-chart {
  width: 100%; height: 180px; display: block;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
}
.hist-chart .area { fill: rgba(56,139,253,.12); stroke: none; }
.hist-chart .line { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.hist-chart .zero { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.hist-summary { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.hist-summary b { font-variant-numeric: tabular-nums; }

.byx-table { overflow-x: auto; }
.byx { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.byx th, .byx td { padding: 7px 9px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.byx th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .3px; font-weight: 600; }
.byx th.num, .byx td.num { text-align: right; }
.byx tbody tr:last-child td { border-bottom: none; }
.byx-ex { font-weight: 600; }
.byx .est { color: var(--muted); margin-right: 1px; cursor: help; }
.byx-note { margin-top: 6px; font-size: 11px; color: var(--muted); }

/* ───── Объяснение ───── */
.explain { margin-top: 18px; padding: 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border); }
.explain h3 { margin: 0 0 8px; font-size: 14px; }
.explain p { margin: 0 0 8px; color: var(--text); }
.explain .disclaimer { color: var(--muted); font-size: 12px; margin-bottom: 0; }

@media (max-width: 560px) {
  .ftable th, .ftable td { padding: 8px 9px; }
  .search-input { width: 100%; }
  .meta { margin-left: 0; }
}

.fc-row { grid-template-columns: 1fr auto; }
.fc-rv { color: var(--text); }
.fc-rv.pos { color: #16c784; }
.fc-rv.neg { color: #ea3943; }
.fcard-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.fc-coin { flex-shrink: 0; }
