/* SignalDesk shared UI: new background shell, legacy content controls */
:root {
  --bg: #080d11; --bg-soft: #0b1418; --panel-1: #101820; --panel-2: #0d151c;
  --text: #edf5fb; --muted: #91a0ae; --line: rgba(222,236,248,.12);
  --line-strong: rgba(222,236,248,.2);
  --up: #24d39a; --down: #ff6961; --warn: #f6b82f; --cyan: #7ab7ff; --blue: #24d39a;
  --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --app-vh: 100vh;
  --app-dvh: 100dvh;
  --bottom-nav-offset: max(env(safe-area-inset-bottom), 0px);
  --bottom-nav-height: calc(64px + var(--bottom-nav-offset));
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { background: #080d11; color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(circle at 78% -12%, rgba(36,211,154,.13), transparent 34rem),
    radial-gradient(circle at 8% 0%, rgba(36,211,154,.055), transparent 30rem),
    linear-gradient(180deg, rgba(255,255,255,.025), transparent 16rem),
    #080d11;
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  min-width: 0;
  overflow-x: hidden;
}
img, svg, canvas, video { max-width: 100%; }
button, input, select, textarea { font: inherit; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { display: flex; align-items: center; gap: 16px; min-height: calc(56px + var(--safe-top)); padding: var(--safe-top) max(22px, var(--safe-right)) 0 max(22px, var(--safe-left)); background: rgba(8,13,17,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); min-width: 0; }
.topbar .logo { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.topbar .logo:hover { text-decoration: none; }
.topbar-search { flex: 1; max-width: 360px; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-1); color: var(--muted); }
.topbar-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; text-transform: uppercase; }
.topbar-search input::placeholder { color: var(--muted); text-transform: none; }
.topbar nav { display: flex; gap: 4px; margin-left: auto; min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a, .topbar nav button { flex: 0 0 auto; white-space: nowrap; }
.topbar nav a,
.topbar nav button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.topbar nav a:hover,
.topbar nav button:hover { color: var(--text); background: rgba(36,211,154,.07); text-decoration: none; }
.topbar nav a.active,
.topbar nav button.active { color: var(--up); background: rgba(36,211,154,.08); border-color: rgba(36,211,154,.22); }

.page { width: min(100%, 1260px); max-width: 1260px; margin: 0 auto; padding: 24px max(20px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(20px, var(--safe-left)); }
.page-wide { width: min(100%, 1500px); max-width: 1500px; }
.page-narrow { width: min(100%, 900px); max-width: 900px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1;
  text-transform: uppercase;
}
.page-title {
  margin-top: 6px;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.16;
}
.page-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  max-width: 720px;
}
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.card { background: var(--panel-1); border: 1px solid var(--line); border-radius: 10px; padding: 20px; box-shadow: none; min-width: 0; }
.card-hover:hover { border-color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
thead th { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 12px; border-bottom: 1px solid var(--line); text-align: left; background: rgba(15,17,23,.35); }
tbody td { padding: 12px; border-bottom: 1px solid rgba(45,55,72,.65); font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(96,165,250,.05); }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-up { background: rgba(52,211,153,.12); color: var(--up); border: 1px solid rgba(52,211,153,.28); }
.badge-down { background: rgba(248,113,113,.12); color: var(--down); border: 1px solid rgba(248,113,113,.28); }
.badge-warn { background: rgba(251,191,36,.12); color: var(--warn); border: 1px solid rgba(251,191,36,.28); }
.badge-muted { background: #111827; color: var(--muted); border: 1px solid var(--line); }

.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 14px; border-radius: 7px; font-size: 13px; font-weight: 700; cursor: pointer; transition: color .15s, background .15s, border-color .15s, transform .15s; border: 0; line-height: 1.2; touch-action: manipulation; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .topbar nav a:focus-visible, .topbar nav button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid rgba(36,211,154,.42); outline-offset: 2px; }
.btn-primary { background: var(--up); color: #07100d; }
.btn-primary:hover { background: #34e6ad; filter: none; }
.btn-outline { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-outline:hover { color: var(--text); background: rgba(36,211,154,.07); border-color: rgba(36,211,154,.24); }
.btn-danger { background: rgba(127,29,29,.22); color: #fecaca; border: 1px solid rgba(248,113,113,.34); }
.btn-danger:hover { background: rgba(127,29,29,.34); border-color: rgba(248,113,113,.52); color: #fff; }
.btn-symbol { width: 15px; height: 15px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.sd-dot { width: 8px; height: 8px; display: inline-block; border-radius: 999px; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 16%, transparent); flex: 0 0 auto; }
.sd-mini-icon {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--up);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  flex: 0 0 auto;
}
.ai-chat-trigger { color: transparent !important; font-size: 0 !important; }
.ai-chat-trigger::before { content: "AI"; color: #08160f; font-size: 12px; font-weight: 900; letter-spacing: 0; }

.has-support-unread { position: relative; }
.support-unread-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--down);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 4px rgba(255,105,97,.12);
  pointer-events: none;
}

@media (max-width: 720px) {
  body { padding-bottom: var(--bottom-nav-height); }
  .page { padding: 16px max(12px, var(--safe-right)) calc(16px + var(--safe-bottom)) max(12px, var(--safe-left)); }
  .page-header { margin-bottom: 16px; }
  .page-title { font-size: 20px; }
  .page-actions { width: 100%; justify-content: stretch; }
  .page-actions .btn { flex: 1 1 auto; min-height: 44px; }
  .topbar { padding: var(--safe-top) max(14px, var(--safe-right)) 0 max(14px, var(--safe-left)); gap: 10px; min-height: calc(64px + var(--safe-top)); flex-wrap: nowrap; align-content: center; }
  .topbar .logo { flex: 0 0 auto; }
  .topbar-search { order: 2; flex: 1 1 100%; max-width: none; min-width: 112px; }
  .topbar nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: max(env(safe-area-inset-bottom), 0px);
    z-index: 80;
    margin-left: 0;
    padding: 8px max(10px, var(--safe-right)) 8px max(10px, var(--safe-left));
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--line-strong);
    background: rgba(8, 13, 17, .96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 -14px 34px rgba(0,0,0,.32);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .topbar nav a,
  .topbar nav button {
    flex: 0 0 82px;
    min-width: 82px;
    max-width: 104px;
    height: 48px;
    min-height: 48px;
    padding: 0 10px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 13px !important;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    box-sizing: border-box;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .topbar nav a.active,
  .topbar nav a:hover,
  .topbar nav button:hover {
    color: var(--text);
    border-color: rgba(36,211,154,.34);
    background: rgba(36,211,154,.08);
    text-decoration: none;
  }
  .topbar nav .support-unread-dot { top: 3px; right: 5px; }
  .card { padding: 16px; border-radius: 10px; }
  .btn { min-height: 44px; }
  thead th, tbody td { padding: 10px; }
}

.modal-overlay,
.modal-backdrop {
  padding: max(16px, var(--safe-top)) max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
}
.modal-overlay > .card,
.modal-backdrop > .modal,
.modal-backdrop > .card {
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Legacy Tailwind-compatible classes (used by watchlist.js, positions.js, etc.) ── */
.text-green { color: var(--up); }
.text-red { color: var(--down); }
.text-green-400 { color: var(--up); }
.text-red-400 { color: var(--down); }
.text-red-300 { color: rgba(255,91,87,.7); }
.text-blue-400, .text-blue-500 { color: var(--cyan); }
.text-purple-400 { color: #d8b4fe; }
.text-gray-400, .text-gray-500, .text-gray-600 { color: var(--muted); }
.text-gray-300 { color: #cbd5e1; }
.text-gray-200 { color: var(--text); opacity: .85; }
.text-gray-800 { color: #1d2a35; }
.text-gray-900 { color: var(--bg); }
.text-white { color: var(--text); }
.text-yellow-400 { color: var(--warn); }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-lg { font-size: 17px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 22px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-mono { font-family: var(--mono); }
.row-hover:hover { background: rgba(36,211,154,.05); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.leading-relaxed { line-height: 1.625; }
.py-6 { padding-top: 24px; padding-bottom: 24px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.py-12 { padding-top: 48px; padding-bottom: 48px; }
.py-16 { padding-top: 64px; padding-bottom: 64px; }
.px-6 { padding-left: 24px; padding-right: 24px; }
.px-5 { padding-left: 20px; padding-right: 20px; }
.p-5 { padding: 20px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.p-8 { padding: 32px; }
.p-12 { padding: 48px; }
.mt-1 { margin-top: 4px; }
.mt-3 { margin-top: 12px; }
.mt-5 { margin-top: 20px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 12px; }
.ml-auto { margin-left: auto; }
.mx-4 { margin-left: 16px; margin-right: 16px; }
.space-y-3 > * + * { margin-top: 12px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }
.grid { display: grid; }
.grid > * { min-width: 0; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-cols-8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.col-span-1 { grid-column: span 1 / span 1; }
.col-span-2 { grid-column: span 2 / span 2; }
.col-span-4 { grid-column: span 4 / span 4; }
.min-h-screen { min-height: 100vh; min-height: 100svh; min-height: 100dvh; }
.max-w-5xl { max-width: 1024px; }
.max-w-7xl { max-width: 1280px; }
.max-w-md { max-width: 448px; }
.max-w-4xl { max-width: 896px; }
.max-w-6xl { max-width: 1152px; }
.w-full { width: 100%; }
.w-8 { width: 32px; }
.h-8 { height: 32px; }
.hidden { display: none; }
.block { display: block; }
.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.inset-0 { inset: 0; }
.fixed { position: fixed; }
.z-50 { z-index: 50; }
.z-\[100\] { z-index: 100; }
.rounded-lg { border-radius: 8px; }
.border { border: 1px solid var(--line); }
.border-b { border-bottom: 1px solid var(--line); }
.border-gray-700 { border-color: var(--line); }
.border-gray-800 { border-color: var(--line); }
.bg-gray-700 { background: #2d3748; }
.bg-gray-800 { background: var(--panel-1); }
.bg-gray-900 { background: var(--bg); }
.bg-blue-600 { background: var(--up); color: #07100d; }
.bg-blue-900 { background: rgba(36,211,154,.12); }
.bg-red-600 { background: var(--down); color: #fff; }
.bg-red-900 { background: rgba(255,91,87,.12); }
.bg-yellow-900 { background: rgba(120,53,15,.38); }
.bg-gray-600 { background: #374151; color: #fff; }
.bg-gray-800 { background: #1a2332; }
.hover\:bg-blue-800:hover { background: rgba(36,211,154,.16); }
.hover\:bg-yellow-800:hover { background: rgba(133,77,14,.58); }
.hover\:bg-gray-500:hover { background: #4b5563; color: #fff; }
.hover\:bg-gray-600:hover { background: #374151; }
.hover\:bg-blue-700:hover { background: #34e6ad; color: #07100d; }
.hover\:bg-red-700:hover { background: #dc2626; color: #fff; }
.hover\:bg-red-800:hover { background: rgba(255,91,87,.2); }
.hover\:bg-red-900:hover { background: rgba(255,91,87,.18); }
.hover\:text-white:hover { color: var(--text); }
.hover\:text-red-400:hover { color: var(--down); }
.rounded { border-radius: 6px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.gap-1 { gap: 4px; }
.gap-1\.5 { gap: 6px; }
.transition-colors { transition: color .15s, background-color .15s, border-color .15s; }
.transition-all { transition: all .15s; }
.focus\:outline-none:focus { outline: none; }
.focus\:border-blue-500:focus { border-color: var(--up); }
.focus\:border-blue-600:focus { border-color: var(--up); }
.tracking-tight { letter-spacing: -0.02em; }
.uppercase { text-transform: uppercase; }
.cursor-pointer { cursor: pointer; }
.flex-wrap { flex-wrap: wrap; }
.mx-auto { margin-left: auto; margin-right: auto; }
.max-h-\[90vh\] { max-height: 90vh; }
.whitespace-nowrap { white-space: nowrap; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }
.flex-shrink-0 { flex-shrink: 0; }
.select-none { user-select: none; }
.min-w-max { min-width: max-content; }
input, select, textarea { background: var(--bg); color: var(--text); border-color: var(--line); }
select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; font-size: 13px; }
.sm\:grid-cols-2, .md\:grid-cols-2, .md\:grid-cols-3, .md\:grid-cols-4, .md\:grid-cols-8, .lg\:grid-cols-2, .lg\:grid-cols-3, .lg\:grid-cols-4, .lg\:grid-cols-5, .lg\:grid-cols-6, .lg\:col-span-1, .lg\:col-span-2 { }
@media (min-width: 640px) { .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 768px) { .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .md\:grid-cols-8 { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .lg\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } .lg\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } .lg\:col-span-1 { grid-column: span 1 / span 1; } .lg\:col-span-2 { grid-column: span 2 / span 2; } }

@media (max-width: 640px) {
  .px-6 { padding-left: 16px; padding-right: 16px; }
  .p-6 { padding: 18px; }
  .p-8 { padding: 22px; }
  .grid-cols-2, .grid-cols-3, .grid-cols-4, .grid-cols-5, .grid-cols-6, .grid-cols-8 { grid-template-columns: 1fr; }
  .min-w-max { min-width: 720px; }
}

@keyframes sd-price-up   { from { background: rgba(52,211,153,.20); } to { background: transparent; } }
@keyframes sd-price-down { from { background: rgba(248,113,113,.20); } to { background: transparent; } }
.sd-flash-up   { animation: sd-price-up   .8s ease-out; border-radius:3px; }
.sd-flash-down { animation: sd-price-down .8s ease-out; border-radius:3px; }
