:root {
  --bg: #0b0e14;
  --panel: #141922;
  --panel-2: #1b212d;
  --border: #232a37;
  --text: #e6e9ef;
  --muted: #8a93a6;
  --up: #26a69a;
  --down: #ef5350;
  --accent: #f7931a;      /* bitcoin orange */
  --accent-2: #4c9aff;
  --warn: #e2b340;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 14px; line-height: 1.45; }
body { padding-bottom: 40px; }
h1, h2 { font-weight: 650; }
b { font-weight: 650; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.loading { color: var(--muted); padding: 18px; text-align: center; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 20px; background: rgba(11,14,20,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; }
.brand h1 { font-size: 18px; letter-spacing: .2px; }
.brand .sub { font-size: 12px; color: var(--muted); }
.ticker { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.tk-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.tk-price { display: flex; flex-direction: column; }
.tk-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tk-chg { font-size: 13px; font-weight: 600; }
.tk-mini { display: flex; flex-direction: column; align-items: flex-start; }
.tk-time { font-variant-numeric: tabular-nums; font-size: 13px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 13px; }

/* ---------- Layout grid ---------- */
.grid {
  display: grid; gap: 16px; padding: 16px 20px; max-width: 1500px; margin: 0 auto;
  grid-template-columns: 2fr 1fr;
  grid-template-areas: "chart side" "news side";
}
.chart-card { grid-area: chart; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 16px; }
.news-card { grid-area: news; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; }

/* ---------- Chart ---------- */
.chart-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tf-tabs, .news-tabs { display: flex; gap: 4px; background: var(--panel-2); padding: 3px; border-radius: 8px; }
.tf-tabs button, .news-tabs button {
  border: none; background: transparent; color: var(--muted); font-weight: 600;
  padding: 5px 11px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: .12s;
}
.tf-tabs button:hover, .news-tabs button:hover { color: var(--text); }
.tf-tabs button.active, .news-tabs button.active { background: var(--accent); color: #1a1200; }
.ind-toggles { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.ind-toggles label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.chart { width: 100%; height: 380px; }
.rsi-chart { width: 100%; height: 96px; margin-top: 4px; }
.chart-readout { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.chart-readout b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Fear & Greed ---------- */
.fng { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.fng-gauge { flex-shrink: 0; }
.fng-arc {
  width: 92px; height: 92px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px; font-weight: 800;
  background: conic-gradient(var(--g-color) calc(var(--g) * 1%), var(--panel-2) 0);
  position: relative;
}
.fng-arc::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--panel); }
.fng-arc span { position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.fng-class { font-size: 17px; font-weight: 700; }
.fng-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.snapshot { border-top: 1px solid var(--border); padding-top: 10px; }
.snap-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.snap-row span { color: var(--muted); }
.snap-row b { font-variant-numeric: tabular-nums; }

/* ---------- US signals ---------- */
.us-row { display: flex; justify-content: space-between; align-items: center; }
.us-label { font-size: 13px; }
.us-val { font-size: 20px; font-variant-numeric: tabular-nums; }
.us-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.hint { color: var(--muted); cursor: help; font-size: 11px; }
.stables { display: flex; gap: 8px; margin-top: 12px; }
.stable { flex: 1; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.stable .s-sym { font-size: 11px; color: var(--muted); }
.stable .s-mcap { font-weight: 700; font-variant-numeric: tabular-nums; }
.stable .s-chg { font-size: 11px; font-variant-numeric: tabular-nums; }

/* ---------- Macro ---------- */
.macro-list { display: flex; flex-direction: column; }
.macro-item { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.macro-item:last-child { border-bottom: none; }
.m-left .m-label { font-size: 13px; font-weight: 600; }
.m-left .m-note { font-size: 11px; color: var(--muted); }
.m-right { text-align: right; }
.m-price { font-variant-numeric: tabular-nums; font-weight: 650; }
.m-chg { font-size: 12px; font-variant-numeric: tabular-nums; }
.impact-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }

/* ---------- Economic calendar ---------- */
.cal-list { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.cal-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 2px; border-bottom: 1px solid var(--border); cursor: pointer; }
.cal-item:last-child { border-bottom: none; }
.cal-item:hover { background: rgba(255,255,255,.02); }
.cal-info { font-size: 10px; color: var(--muted); font-weight: 400; }
.cal-item.open .cal-info { color: var(--accent); }
.cal-desc { display: none; margin-top: 7px; padding: 8px 10px; background: var(--panel-2);
  border-left: 2px solid var(--accent); border-radius: 0 6px 6px 0; font-size: 11.5px; color: var(--text); line-height: 1.55; }
.cal-item.open .cal-desc { display: block; }
.cal-item.imminent { background: linear-gradient(90deg, rgba(247,147,26,.10), transparent); border-radius: 8px; padding-left: 8px; }
.imp-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.imp-high { background: #ef5350; box-shadow: 0 0 0 3px rgba(239,83,80,.15); }
.imp-med { background: #e2b340; }
.imp-low { background: #5a6472; }
.cal-body { flex: 1; min-width: 0; }
.cal-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.cal-top b { font-size: 13px; }
.cal-when { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cal-when .rel { color: var(--accent); font-weight: 700; margin-right: 4px; }
.cal-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.cal-act { color: var(--up); font-weight: 600; }
.cal-foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ---------- News ---------- */
.news-list { display: flex; flex-direction: column; max-height: 460px; overflow-y: auto; }
.news-item { display: flex; gap: 10px; align-items: baseline; padding: 9px 2px; border-bottom: 1px solid var(--border); }
.news-item:last-child { border-bottom: none; }
.news-item .cat { flex-shrink: 0; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .3px; }
.cat.reg_etf { background: #3a2a12; color: #f0b35b; }
.cat.macro { background: #12303a; color: #5bc8f0; }
.cat.general { background: #26262e; color: #9aa3b5; }
.news-item .n-body { flex: 1; min-width: 0; }
.news-item .n-title { font-size: 13.5px; }
.news-item .n-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }

.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; margin-top: 8px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .grid { grid-template-columns: 1fr; grid-template-areas: "chart" "side" "news"; }
  .side { flex-direction: column; }
}
@media (max-width: 620px) {
  .topbar { gap: 10px; }
  .ticker { gap: 14px; }
  .tk-val { font-size: 18px; }
  .chart { height: 300px; }
  .brand .sub { display: none; }
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
