:root {
  --bg: #0b0d10;
  --panel: #12161b;
  --panel-2: #181d24;
  --line: #232a33;
  --text: #e6e9ee;
  --muted: #8a94a3;
  --gold: #d4a646;
  --buy: #22c55e;
  --sell: #ef4444;
  --neutral: #94a3b8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --blue: #3b82f6;
  --radius: 12px;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; letter-spacing: .01em; }
main { max-width: 1280px; margin: 0 auto; padding: 0 16px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

/* Header */
.top {
  max-width: 1280px; margin: 0 auto; padding: 18px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M6 22l6-7 5 4 9-11' stroke='%230b0d10' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/70% no-repeat;
}
h1 { font-size: 20px; }
h1 span { color: var(--gold); }
.sub { margin: 0; color: var(--muted); font-size: 12px; }
.quote { text-align: right; }
.price { font: 600 26px/1.1 var(--mono); }
.meta { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--neutral); }
.dot.ok { background: var(--buy); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.dot.stale { background: var(--yellow); }
.dot.err { background: var(--sell); }

.banner {
  max-width: 1248px; margin: 0 auto 16px; padding: 12px 16px; border-radius: var(--radius);
  background: rgba(234,179,8,.1); border: 1px solid rgba(234,179,8,.35); color: #fde68a;
}
.banner code { font-family: var(--mono); background: rgba(0,0,0,.3); padding: 1px 5px; border-radius: 4px; }

section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* Confluence */
.conf-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.conf-meter { position: relative; height: 10px; border-radius: 99px; background: linear-gradient(90deg, rgba(239,68,68,.25), rgba(148,163,184,.12), rgba(34,197,94,.25)); overflow: hidden; }
.conf-fill { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; transition: all .4s; }
.conf-mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: var(--muted); }
.conf-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }
.conf-labels strong { color: var(--text); font-size: 13px; }
.alerts { display: flex; gap: 8px; align-items: center; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); }
.switch input { accent-color: var(--gold); width: 16px; height: 16px; }
select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 13px;
}

/* Timeframe cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; background: none; border: 0; padding: 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; cursor: pointer; text-align: left; color: inherit; font: inherit;
  display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, transform .15s;
  border-top: 3px solid var(--neutral);
}
.card:hover { border-color: #3a4552; }
.card.selected { outline: 2px solid var(--gold); outline-offset: -1px; }
.card.bull { border-top-color: var(--buy); }
.card.bear { border-top-color: var(--sell); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; }
.tf { font: 600 18px var(--mono); }
.bias { font-size: 12px; font-weight: 600; }
.bias.bull { color: var(--buy); }
.bias.bear { color: var(--sell); }
.bias.neutral { color: var(--neutral); }
.sig { display: flex; flex-direction: column; gap: 2px; }
.sig-label { font-weight: 700; font-size: 13px; letter-spacing: .02em; }
.sig-label.buy { color: var(--buy); }
.sig-label.sell { color: var(--sell); }
.sig-meta { color: var(--muted); font-size: 12px; }
.vals { display: flex; gap: 8px; font: 12px var(--mono); }
.vals .g { color: var(--green); }
.vals .r { color: var(--red); }
.vals .y { color: var(--yellow); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.chip.warn { color: #fde68a; border-color: rgba(234,179,8,.35); }
.chip.good { color: #86efac; border-color: rgba(34,197,94,.35); }
.chip.bad { color: #fca5a5; border-color: rgba(239,68,68,.35); }
.forming { font-size: 11px; color: var(--muted); font-style: italic; }

/* Chart */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button {
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 11px; font: 600 13px var(--mono); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--gold); color: #111; border-color: var(--gold); }
.legend { font: 12px var(--mono); color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.chart { width: 100%; }
.price-chart { height: 380px; }
.tdi-chart { height: 200px; border-top: 1px solid var(--line); }
.key { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 10px; }
.key i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* History */
.history h2 { margin-bottom: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; font-family: var(--mono); }
td.buy { color: var(--buy); font-weight: 600; }
td.sell { color: var(--sell); font-weight: 600; }
td.pos { color: var(--buy); }
td.neg { color: var(--sell); }
.empty { color: var(--muted); text-align: center; padding: 20px; }

/* Rules */
.rules ul { padding-left: 18px; margin: 10px 0; color: #c4cad3; }
.rules li { margin-bottom: 6px; }
.rules .buy { color: var(--buy); }
.rules .sell { color: var(--sell); }
.disclaimer { color: var(--muted); font-size: 12px; margin: 10px 0 0; border-top: 1px solid var(--line); padding-top: 10px; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 10; max-width: calc(100vw - 32px); }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--neutral);
  border-radius: 10px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: in .25s ease-out;
}
.toast.buy { border-left-color: var(--buy); }
.toast.sell { border-left-color: var(--sell); }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 640px) {
  .top { flex-direction: column; align-items: flex-start; }
  .quote { text-align: left; }
  .meta { justify-content: flex-start; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .price-chart { height: 300px; }
  .tdi-chart { height: 170px; }
  section { padding: 12px; }
}
