:root {
  color-scheme: dark;
  --bg: #080b12;
  --panel: #0f1420;
  --panel-2: #141b29;
  --line: #273044;
  --text: #f2f5f9;
  --muted: #8e9aaf;
  --accent: #74a7ff;
  --buy: #35d07f;
  --sell: #ff5f6d;
  --warn: #f4c95d;
  --shadow: 0 18px 55px rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: radial-gradient(circle at 15% -10%, #16213a 0, transparent 34rem), var(--bg); color: var(--text); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 18px 24px; border-bottom: 1px solid rgba(255,255,255,.08); background: rgba(8,11,18,.88); backdrop-filter: blur(18px); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.35rem, 2vw, 2rem); letter-spacing: -.03em; }
h2 { margin-bottom: 16px; font-size: 1rem; }
.eyebrow { color: var(--accent); font-weight: 800; letter-spacing: .14em; font-size: .68rem; margin-bottom: 5px; }
.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: .82rem; }
.status-wrap { display: flex; align-items: center; gap: 8px; color: #d8deea; }
.status-dot { width: 9px; height: 9px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 14px currentColor; }
.status-dot.ok { background: var(--buy); } .status-dot.error { background: var(--sell); } .status-dot.warn { background: var(--warn); } .status-dot.busy { background: #8d7bff; animation: pulse 1s infinite; } .status-dot.muted { background: #5d6677; }
.clock { color: var(--muted); }
.layout { display: grid; grid-template-columns: 320px minmax(0,1fr); gap: 18px; max-width: 1800px; margin: 0 auto; padding: 18px; }
.settings-panel { min-width: 0; }
.settings-form { display: grid; gap: 12px; position: sticky; top: 96px; max-height: calc(100vh - 114px); overflow: auto; padding-right: 3px; }
.setting-card, .results-card, .progress-card, .accuracy-note { background: linear-gradient(180deg, rgba(20,27,41,.94), rgba(14,19,30,.94)); border: 1px solid rgba(255,255,255,.08); border-radius: 16px; box-shadow: var(--shadow); }
.setting-card { padding: 16px; }
.setting-card label { display: grid; gap: 6px; color: #bbc5d6; font-size: .78rem; font-weight: 700; margin-bottom: 12px; }
.grid { display: grid; gap: 10px; } .grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
input, select, textarea { width: 100%; color: var(--text); background: #0a0f19; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(116,167,255,.12); }
textarea { resize: vertical; min-height: 150px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; line-height: 1.45; }
.checkbox-field { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 8px !important; padding-top: 25px; }
.checkbox-field input, .switch-label input { width: auto; accent-color: var(--accent); }
.toggle-row { display: flex; gap: 16px; flex-wrap: wrap; }
.switch-label { display: flex !important; align-items: center; gap: 8px !important; margin: 0 !important; }
.switch-label.wide { margin-bottom: 12px !important; }
.hint { color: var(--muted); font-size: .72rem; line-height: 1.45; margin: 8px 0 0; }
.content { min-width: 0; display: grid; gap: 14px; align-content: start; }
.actionbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
button { border: 1px solid transparent; border-radius: 10px; padding: 9px 13px; font-weight: 800; color: white; }
.primary { background: #2d67d7; } .primary:hover { background: #3774eb; }
.secondary { background: #182236; border-color: #2a3852; } .secondary:hover { border-color: #46628e; }
.ghost { background: transparent; border-color: var(--line); color: #c8d1df; }
.danger { background: #60303a; border-color: #7d3d49; }
.next-scan { color: var(--muted); font-size: .8rem; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.stat { background: #0f1521; border: 1px solid rgba(255,255,255,.07); border-radius: 14px; padding: 14px; }
.stat span { color: var(--muted); font-size: .72rem; display: block; margin-bottom: 5px; }
.stat strong { font-size: 1.45rem; letter-spacing: -.04em; }
.progress-card { padding: 12px 14px; }
.progress-track { height: 6px; background: #20283a; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #568de8, #8d7bff); transition: width .2s ease; }
.progress-text { color: var(--muted); font-size: .74rem; margin-top: 8px; }
.results-card { overflow: hidden; }
.results-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-end; padding: 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.results-head h2 { font-size: 1.2rem; margin: 0; }
.results-controls { display: flex; align-items: flex-end; gap: 8px; }
.results-controls label { color: var(--muted); font-size: .72rem; display: grid; gap: 4px; }
.results-controls select { min-width: 170px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 315px); position: relative; }
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 1600px; font-size: .75rem; }
th { position: sticky; top: 0; z-index: 3; background: #111827; color: #8795aa; text-align: left; font-size: .67rem; text-transform: uppercase; letter-spacing: .06em; padding: 10px 11px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px; border-bottom: 1px solid rgba(255,255,255,.055); color: #d7deea; white-space: nowrap; }
tbody tr:hover td { background: rgba(116,167,255,.035); }
.coin-cell { font-weight: 900; color: white; }
.signal-pill, .level-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-weight: 900; font-size: .67rem; }
.signal-pill.buy { color: #8df1b9; background: rgba(53,208,127,.13); border: 1px solid rgba(53,208,127,.32); }
.signal-pill.sell { color: #ff9ba3; background: rgba(255,95,109,.13); border: 1px solid rgba(255,95,109,.32); }
.level-pill { color: #d9d0ff; background: rgba(141,123,255,.12); border: 1px solid rgba(141,123,255,.28); }
.empty-state { text-align: center; padding: 72px 20px; color: var(--muted); }
.empty-state h3 { color: #d6ddea; margin-bottom: 7px; }
.empty-state p { max-width: 560px; margin: 0 auto; line-height: 1.6; }
.empty-icon { font-size: 2rem; margin-bottom: 8px; color: var(--accent); }
.accuracy-note { padding: 14px 16px; color: var(--muted); font-size: .77rem; line-height: 1.55; }
.accuracy-note strong { color: #d6deeb; }
.mobile-settings { display: none; background: #182236; border-color: #2a3852; }
.toast-stack { position: fixed; z-index: 99; right: 18px; bottom: 18px; display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { transform: translateY(10px); opacity: 0; transition: .2s ease; padding: 11px 13px; border-radius: 11px; background: #182132; border: 1px solid #2f3a50; color: #e9edf5; box-shadow: var(--shadow); font-size: .8rem; }
.toast.show { transform: none; opacity: 1; } .toast.buy { border-color: rgba(53,208,127,.5); } .toast.sell, .toast.error { border-color: rgba(255,95,109,.5); }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 1050px) {
  .layout { grid-template-columns: 1fr; }
  .mobile-settings { display: block; }
  .settings-panel { display: none; }
  .settings-panel.open { display: block; }
  .settings-form { position: static; max-height: none; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .table-wrap { max-height: 65vh; }
}
@media (max-width: 680px) {
  .topbar { padding: 14px; align-items: flex-start; }
  .header-right { font-size: .7rem; }
  .layout { padding: 10px; }
  .settings-form { grid-template-columns: 1fr; }
  .stats-grid { gap: 7px; }
  .stat { padding: 11px; }
  .stat strong { font-size: 1.18rem; }
  .actionbar { align-items: stretch; }
  .actionbar .button-row { width: 100%; }
  .actionbar button { flex: 1 1 auto; }
  .results-head { align-items: stretch; flex-direction: column; }
  .results-controls { width: 100%; align-items: end; }
  .results-controls label { flex: 1; }
  .results-controls select { min-width: 0; }
  .grid.two { grid-template-columns: 1fr 1fr; }
}

/* Historical scanner */
.history-card { margin-top: 2px; }
.history-head { align-items: flex-end; }
.history-summary { margin: 8px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.5; max-width: 760px; }
.history-controls { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.history-controls label { color: var(--muted); font-size: .72rem; display: grid; gap: 4px; min-width: 145px; }
.history-controls input, .history-controls select { min-width: 145px; }
.history-stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; padding: 14px 18px 0; }
.history-progress { margin: 14px 18px 0; box-shadow: none; }
.history-results-head { margin-top: 4px; }
.historical-wrap { max-height: 58vh; }

@media (max-width: 680px) {
  .history-controls { width: 100%; align-items: stretch; }
  .history-controls label { flex: 1 1 140px; min-width: 0; }
  .history-controls button { flex: 1 1 150px; }
  .history-stats { grid-template-columns: 1fr; padding: 10px 12px 0; }
  .history-progress { margin: 10px 12px 0; }
}

.mobile-link-card{display:flex;gap:.55rem;align-items:flex-start;flex-wrap:wrap;padding:.85rem 1rem;margin-bottom:1rem;border:1px solid var(--border,#283142);border-radius:12px;background:rgba(125,211,252,.06);font-size:.9rem}.mobile-link-card strong{white-space:nowrap}.mobile-link-card span{opacity:.78;min-width:0;flex:1}
