/* =========================================================
   MarketPulse v2 — styles.css
   Complete component library: shell, sidebar, topbar, cards,
   tables, charts, asset analysis, screener, settings, modal,
   toasts, responsive. Matches the existing dashboard look.
   ========================================================= */

/* ---------- Reset & base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

::selection { background: var(--brand-soft); color: var(--brand); }

/* Scrollbar */
.scroll-y::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar,
.modal-body::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-y::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 8px;
}
.scroll-y::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   APP SHELL — 3-column grid
   ========================================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--right-w);
  min-height: 100vh;
  background: var(--bg);
}
.app-shell.no-right {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

/* =========================================================
   LEFT SIDEBAR
   ========================================================= */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 50;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 18px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--divider);
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6c5dd3 0%, #8b7be8 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  box-shadow: var(--sh-brand);
  flex-shrink: 0;
}
.brand-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-version {
  font-size: 10px;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  margin-left: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 12px 16px;
}
.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 18px 8px 6px;
}
.nav-section-label:first-child { margin-top: 8px; }

.nav-list { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item i {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item:hover { background: var(--bg); color: var(--text-1); }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.nav-badge {
  margin-left: auto;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  height: 18px;
  min-width: 18px;
  padding: 0 6px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
}
.nav-badge.is-alert { background: var(--danger); color: #fff; }

/* Upgrade / disclaimer card */
.upgrade-card {
  margin: 12px;
  padding: 16px;
  border-radius: var(--r-xl);
  background: linear-gradient(135deg, #6c5dd3 0%, #8b7be8 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.upgrade-card::after {
  content: "";
  position: absolute;
  right: -20px; top: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}
.upgrade-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.2);
  display: grid; place-items: center;
  font-size: 16px;
  margin-bottom: 8px;
}
.upgrade-title { font-size: 14px; font-weight: 700; margin: 0 0 4px; }
.upgrade-sub { font-size: 12px; color: rgba(255, 255, 255, 0.85); margin: 0 0 12px; line-height: 1.4; }
.btn-upgrade {
  width: 100%;
  height: 34px;
  border-radius: var(--r-md);
  background: #fff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  transition: transform 0.15s ease;
}
.btn-upgrade:hover { transform: translateY(-1px); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  z-index: 45;
}
.sidebar-overlay.show { display: block; }

/* =========================================================
   MAIN AREA
   ========================================================= */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 360px;
  max-width: 100%;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 10px;
  height: 40px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.search-wrap:focus-within {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}
.search-wrap > i.bi-search {
  position: absolute;
  left: 12px;
  font-size: 16px;
  color: var(--text-3);
  pointer-events: none;
}
.search-input {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 0 12px 0 38px;
  font-size: 14px;
  color: var(--text-1);
}
.search-input::placeholder { color: var(--text-3); }
.search-kbd {
  margin-right: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-family: inherit;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  max-height: 360px;
  overflow-y: auto;
  display: none;
  z-index: 60;
}
.search-results.show { display: block; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.search-result-item:hover { background: var(--surface-2); }
.search-result-item + .search-result-item { border-top: 1px solid var(--divider); }
.sr-sym { font-weight: 700; color: var(--text-1); font-size: 13px; min-width: 64px; }
.sr-name { font-size: 13px; color: var(--text-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-type { font-size: 11px; color: var(--text-3); text-transform: uppercase; }
.search-empty { padding: 16px 12px; font-size: 13px; color: var(--text-3); text-align: center; }

.mobile-menu-btn { display: none !important; }

/* Date / refresh label button */
.date-picker-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.date-picker-btn:hover { border-color: var(--brand); color: var(--text-1); }
.date-picker-btn .live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-bg);
}
.date-picker-btn .live-dot.stale { background: var(--text-3); box-shadow: 0 0 0 3px var(--bg); }

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  gap: 2px;
}
.seg-btn {
  height: 32px;
  min-width: 48px;
  padding: 0 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s ease;
}
.seg-btn:hover { color: var(--text-1); }
.seg-btn.active {
  background: var(--surface);
  color: var(--text-1);
  font-weight: 600;
  box-shadow: var(--sh-sm);
}

/* Buttons */
.btn-primary-solid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r-md);
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--sh-brand);
  transition: background 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}
.btn-primary-solid:hover { background: var(--brand-hover); transform: translateY(-1px); }
.btn-primary-solid:active { transform: translateY(0); }
.btn-primary-solid:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary-solid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-1);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-secondary-solid:hover { border-color: var(--brand); color: var(--brand); }
.btn-secondary-solid:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-1);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-secondary-sm:hover { border-color: var(--brand); color: var(--brand); }

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  color: var(--text-2);
  font-size: 18px;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}
.btn-icon:hover { background: var(--bg); color: var(--text-1); }
.btn-icon.has-badge .dot-badge {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.avatar-btn {
  display: flex;
  align-items: center;
  position: relative;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background-image: linear-gradient(135deg, #6c5dd3, #8b7be8);
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.status-ring {
  position: absolute;
  right: -1px; bottom: -1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--surface);
}
.status-ring.online { background: var(--success); }

.icon-actions { display: flex; align-items: center; gap: 4px; }

/* =========================================================
   CONTENT
   ========================================================= */
.content {
  flex: 1;
  padding: 20px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.greeting {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
  letter-spacing: -0.02em;
}
.greeting .wave { font-style: normal; }
.sub-greeting { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.view-section { display: none; flex-direction: column; gap: 20px; animation: fade-in 0.25s ease; }
.view-section.active { display: flex; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Metrics ---------- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: var(--sh-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.metric-card:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.metric-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 20px;
}
.icon-purple { background: var(--brand-soft); color: var(--brand); }
.icon-amber { background: var(--warning-bg); color: var(--warning); }
.icon-green { background: var(--success-bg); color: var(--success); }
.icon-blue { background: var(--info-bg); color: var(--info); }
.icon-red { background: var(--danger-bg); color: var(--danger); }

.trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
  height: 22px;
}
.trend i { font-size: 14px; }
.trend.up { background: var(--success-bg); color: var(--success); }
.trend.down { background: var(--danger-bg); color: var(--danger); }
.trend.flat { background: var(--bg); color: var(--text-2); }

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.metric-value .unit { font-size: 18px; font-weight: 600; color: var(--text-2); margin-left: 2px; }
.metric-label { margin: 4px 0 0; font-size: 13px; color: var(--text-2); }
.metric-sub { margin: 6px 0 0; font-size: 12px; color: var(--text-3); }

/* ---------- Panels / cards ---------- */
.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--divider);
  flex-wrap: wrap;
}
.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-title i { color: var(--brand); font-size: 18px; }
.panel-subtitle { font-size: 12px; color: var(--text-3); margin: 0; }
.panel-body { padding: 8px; }
.panel-body.p-0 { padding: 0; }
.panel-body.p-20 { padding: 20px; }

.panel-tools { display: flex; align-items: center; gap: 8px; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ---------- Watchlist table ---------- */
.table-scroll { overflow-x: auto; max-width: 100%; }
.watchlist-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 880px;
}
.watchlist-table thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
  background: var(--surface);
}
.watchlist-table thead th.num { text-align: right; }
.watchlist-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  font-size: 13px;
  color: var(--text-1);
  vertical-align: middle;
}
.watchlist-table tbody td.num { text-align: right; }
.watchlist-table tbody tr:last-child td { border-bottom: none; }
.watchlist-table tbody tr { transition: background 0.15s ease; cursor: pointer; }
.watchlist-table tbody tr:hover td { background: var(--surface-2); }

.wl-asset { display: flex; align-items: center; gap: 10px; }
.wl-badge {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.wl-badge.crypto { background: var(--crypto-bg); color: var(--crypto-fg); }
.wl-badge.stock { background: var(--stock-bg); color: var(--stock-fg); }
.wl-badge img { width: 100%; height: 100%; object-fit: cover; }
.wl-name { font-size: 13px; font-weight: 600; color: var(--text-1); display: flex; align-items: center; gap: 6px; }
.wl-sym { font-size: 11px; color: var(--text-3); }

.wl-price { font-weight: 700; color: var(--text-1); }
.wl-change { font-size: 12px; font-weight: 600; }
.wl-change.up { color: var(--success); }
.wl-change.down { color: var(--danger); }

.wl-action {
  text-align: right;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.wl-chevron { color: var(--text-3); font-size: 14px; }

.row-remove-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-size: 14px;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}
.row-remove-btn:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

/* ---------- Watchlist tabs (Crypto / Stocks) ---------- */
.wl-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--r-md);
  margin: 12px 16px 0;
}
.wl-tab {
  flex: 1;
  height: 36px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.wl-tab.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--sh-sm);
}
.wl-tab:hover:not(.active) { color: var(--text-1); }
.wl-tab .tab-count {
  font-size: 11px;
  background: var(--brand-soft);
  color: var(--brand);
  padding: 1px 6px;
  border-radius: var(--r-full);
}

/* Market closed badge — shown near watchlist when ADX is closed */
.market-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: var(--warning-bg);
  color: #b45309;
  border: 1px solid rgba(255, 171, 0, 0.35);
  white-space: nowrap;
}
.market-badge .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulseFade 1.6s ease-in-out infinite;
}
.market-badge.open {
  background: var(--success-bg);
  color: #047857;
  border-color: rgba(0, 196, 140, 0.35);
}
.market-badge.open .pulse-dot { background: var(--success); }
@keyframes pulseFade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Sparkline */
.spark { display: inline-block; vertical-align: middle; }
.spark svg { display: block; }

/* ---------- Signal pills (rating tones) ---------- */
.signal-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--r-full);
  text-transform: capitalize;
  white-space: nowrap;
}
.signal-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.tone-strong-bull { background: #d6f5e9; color: #009066; }
.tone-bull { background: var(--success-bg); color: var(--success); }
.tone-neutral { background: var(--bg); color: var(--text-2); }
.tone-bear { background: var(--danger-bg); color: var(--danger); }
.tone-strong-bear { background: #fbdcdc; color: #c92a2d; }

/* Generic tag */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--bg);
  color: var(--text-2);
}
.tag.green { background: var(--success-bg); color: var(--success); }
.tag.red { background: var(--danger-bg); color: var(--danger); }
.tag.amber { background: var(--warning-bg); color: #b45309; }
.tag.blue { background: var(--info-bg); color: var(--info); }
.tag.purple { background: var(--brand-soft); color: var(--brand); }

/* ---------- Donut chart ---------- */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 20px;
}
.donut {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: conic-gradient(
    var(--success) 0deg 0deg,
    var(--text-3) 0deg 0deg,
    var(--danger) 0deg 0deg
  );
  display: grid;
  place-items: center;
}
.donut::before {
  content: "";
  position: absolute;
  inset: 18px;
  background: var(--surface);
  border-radius: 50%;
}
.donut-center { position: relative; text-align: center; z-index: 1; }
.donut-value { display: block; font-size: 30px; font-weight: 700; color: var(--text-1); line-height: 1; letter-spacing: -0.02em; }
.donut-label { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 0 8px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: var(--success); }
.dot-gray { background: var(--text-3); }
.dot-red { background: var(--danger); }
.legend-label { color: var(--text-2); }
.legend-value { margin-left: auto; font-weight: 700; color: var(--text-1); }

/* ---------- Market trend card ---------- */
.trend-bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding: 16px 20px; overflow: hidden; }
.trend-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.trend-bar {
  width: 100%;
  max-width: 32px;
  min-height: 4px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: linear-gradient(180deg, var(--brand) 0%, #8b7be8 100%);
  transition: height 0.3s ease;
}
.trend-bar.down { background: linear-gradient(180deg, var(--danger) 0%, #ff7a7c 100%); }
.trend-bar-label { font-size: 10px; color: var(--text-3); font-weight: 600; white-space: nowrap; }

/* =========================================================
   RIGHT PANEL
   ========================================================= */
.right-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.rp-section { border-bottom: 1px solid var(--divider); }
.rp-section:last-child { border-bottom: none; }
.rp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
}
.rp-title { font-size: 13px; font-weight: 700; color: var(--text-1); margin: 0; letter-spacing: -0.01em; }

.rp-market-status { padding: 4px 20px 16px; }
.ms-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13px;
}
.ms-label { color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.ms-label i { font-size: 14px; color: var(--text-3); }
.ms-value { font-weight: 600; color: var(--text-1); }
.ms-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.ms-status .pulse { width: 8px; height: 8px; border-radius: 50%; }
.ms-status.open .pulse { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.ms-status.closed .pulse { background: var(--text-3); }
.ms-status.pre .pulse { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-bg); }

.mover-list { padding: 4px 8px 12px; }
.mover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s ease;
}
.mover-item:hover { background: var(--surface-2); }
.mover-badge {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.mover-badge.crypto { background: var(--crypto-bg); color: var(--crypto-fg); }
.mover-badge.stock { background: var(--stock-bg); color: var(--stock-fg); }
.mover-info { flex: 1; min-width: 0; }
.mover-sym { font-size: 13px; font-weight: 700; color: var(--text-1); }
.mover-price { font-size: 11px; color: var(--text-3); }
.mover-chg { font-size: 12px; font-weight: 700; }
.mover-chg.up { color: var(--success); }
.mover-chg.down { color: var(--danger); }

.mini-wl { padding: 4px 8px 12px; }
.mini-asset {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s ease;
}
.mini-asset:hover { background: var(--surface-2); }
.mini-info { flex: 1; min-width: 0; }
.mini-sym { font-size: 13px; font-weight: 700; color: var(--text-1); }
.mini-sub { font-size: 11px; color: var(--text-3); }
.mini-remove {
  width: 22px; height: 22px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 11px;
  color: var(--text-3);
  background: transparent;
  transition: all 0.15s ease;
  flex-shrink: 0;
  opacity: 0;
}
.mini-asset:hover .mini-remove { opacity: 1; }
.mini-remove:hover { background: var(--danger-bg); color: var(--danger); }

.rp-risk { padding: 16px 20px; }
.risk-notice {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--warning-bg);
  border: 1px solid #ffe9a8;
}
.risk-notice i { color: #b45309; font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.risk-notice p { margin: 0; font-size: 12px; color: #7c5a14; line-height: 1.5; }

/* =========================================================
   ASSET ANALYSIS VIEW
   ========================================================= */
.asset-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px 24px;
  box-shadow: var(--sh-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.asset-ident { display: flex; align-items: center; gap: 14px; }
.asset-logo {
  width: 52px; height: 52px;
  border-radius: var(--r-lg);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #6c5dd3, #8b7be8);
  overflow: hidden;
  flex-shrink: 0;
}
.asset-logo img { width: 100%; height: 100%; object-fit: cover; }
.asset-name { font-size: 20px; font-weight: 700; color: var(--text-1); margin: 0; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.asset-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.asset-price-block { text-align: right; }
.asset-price { font-size: 30px; font-weight: 700; color: var(--text-1); letter-spacing: -0.02em; line-height: 1; }
.asset-change { margin-top: 6px; font-size: 14px; font-weight: 600; }
.asset-change.up { color: var(--success); }
.asset-change.down { color: var(--danger); }
.asset-change.flat { color: var(--text-2); }

.asset-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.asset-grid.has-aside { grid-template-columns: minmax(0, 1fr) 360px; }

/* Chart */
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-sm); overflow: hidden; }
.chart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--divider); flex-wrap: wrap; gap: 10px;
}
.chart-tf { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.chart-tf button {
  height: 28px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.chart-tf button.active { background: var(--surface); color: var(--text-1); box-shadow: var(--sh-sm); }
.chart-container { height: 420px; padding: 8px 8px 12px; }
.chart-fallback {
  height: 420px;
  display: grid; place-items: center;
  color: var(--text-3); font-size: 13px;
}

/* Indicators grid */
.indicators-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--divider);
}
.indicator-cell {
  background: var(--surface);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ind-label { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.ind-value { font-size: 18px; font-weight: 700; color: var(--text-1); letter-spacing: -0.01em; }
.ind-tag { align-self: flex-start; }

/* Decision engine */
.decision-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-sm); overflow: hidden; }
.decision-head { padding: 18px 20px; border-bottom: 1px solid var(--divider); display: flex; align-items: center; gap: 8px; }
.decision-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.decision-score-wrap { padding: 24px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; border-bottom: 1px solid var(--divider); }
.score-ring {
  position: relative;
  width: 120px; height: 120px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-ring::before {
  content: "";
  position: absolute; inset: 12px;
  background: var(--surface);
  border-radius: 50%;
  z-index: 0;
}
.score-num {
  position: relative;
  z-index: 1;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
  line-height: 1;
  text-align: center;
}
.score-of {
  position: relative;
  z-index: 1;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}
.score-rating { font-size: 14px; font-weight: 700; text-transform: capitalize; }
.score-confidence { font-size: 12px; color: var(--text-3); }

.factors-list { padding: 8px 12px 12px; }
.factor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--r-md);
}
.factor-row:hover { background: var(--surface-2); }
.factor-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.factor-signal { font-size: 11px; }
.factor-points { font-size: 13px; font-weight: 700; color: var(--text-1); min-width: 40px; text-align: right; }
.factor-weight { font-size: 11px; color: var(--text-3); min-width: 48px; text-align: right; }

.factor-row-head {
  font-size: 11px; color: var(--text-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 8px 4px;
}
.disclaimer-note {
  margin: 8px 12px 12px;
  padding: 10px 12px;
  background: var(--warning-bg);
  border-radius: var(--r-md);
  font-size: 11px; color: #7c5a14; line-height: 1.5;
  display: flex; gap: 8px;
}
.disclaimer-note i { color: #b45309; flex-shrink: 0; }

/* Multi-timeframe table */
.mtf-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.mtf-table thead th {
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 14px; border-bottom: 1px solid var(--divider); white-space: nowrap;
}
.mtf-table thead th.num { text-align: center; }
.mtf-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--divider); font-size: 13px; color: var(--text-1); }
.mtf-table tbody td.num { text-align: center; }
.mtf-table tbody tr:last-child td { border-bottom: none; }
.mtf-tf { font-weight: 700; color: var(--text-1); }
.mtf-agreement {
  padding: 14px 18px; border-top: 1px solid var(--divider);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--surface-2);
}
.mtf-agreement-label { font-size: 13px; color: var(--text-2); }
.mtf-agreement-val { font-size: 14px; font-weight: 700; color: var(--text-1); }
.mtf-consensus { font-size: 12px; font-weight: 600; color: var(--brand); text-transform: capitalize; }

/* Trade scenario — separated cards */
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
}
.scenario-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--sh-sm);
  transition: box-shadow 0.2s ease;
}
.scenario-cell:hover { box-shadow: var(--sh-md); }
.sc-label { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.sc-value { font-size: 18px; font-weight: 700; color: var(--text-1); letter-spacing: -0.01em; }
.sc-sub { font-size: 11px; color: var(--text-3); }
.scenario-cell.tone-green { background: var(--success-bg); border-color: #b8eccf; }
.scenario-cell.tone-green .sc-value { color: var(--success); }
.scenario-cell.tone-red { background: var(--danger-bg); border-color: #f3b8b9; }
.scenario-cell.tone-red .sc-value { color: var(--danger); }

.targets-list { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.target-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border);
}
.target-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.target-price { font-size: 14px; font-weight: 700; color: var(--success); }
.target-multiple { font-size: 11px; color: var(--text-3); }

/* Investment calculator */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px 20px;
}
.calc-field { display: flex; flex-direction: column; gap: 6px; }
.calc-field.full { grid-column: 1 / -1; }
.calc-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.calc-input {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 12px;
  font-size: 14px;
  color: var(--text-1);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.calc-input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.calc-result {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 4px;
}
.calc-result-cell {
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.calc-result-cell .lbl { font-size: 11px; color: var(--text-3); font-weight: 600; }
.calc-result-cell .val { font-size: 16px; font-weight: 700; color: var(--text-1); margin-top: 2px; }
.calc-result-cell.gain .val { color: var(--success); }
.calc-result-cell.loss .val { color: var(--danger); }

/* =========================================================
   SCREENER VIEW
   ========================================================= */
.screener-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.filter-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-sm); overflow: hidden; position: sticky; top: 84px; }
.filter-head { padding: 16px 18px; border-bottom: 1px solid var(--divider); }
.filter-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.filter-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 18px; }
.filter-field { display: flex; flex-direction: column; gap: 8px; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; }
.filter-label .val { color: var(--brand); font-weight: 700; }
.filter-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px;
  border-radius: var(--r-full);
  background: var(--bg);
  outline: none;
}
.filter-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand); cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: var(--sh-sm);
}
.filter-range::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand); cursor: pointer; border: 3px solid var(--surface);
}
.filter-select {
  height: 38px; border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 0 10px; font-size: 13px; color: var(--text-1); background: var(--surface);
  outline: none;
}
.filter-select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.filter-actions { display: flex; gap: 8px; }
.filter-actions .btn-primary-solid { flex: 1; }

.screener-results { min-width: 0; }
.results-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.results-count { font-size: 13px; color: var(--text-2); }
.results-count b { color: var(--text-1); }

.screener-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 640px; }
.screener-table thead th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em; padding: 12px 14px;
  border-bottom: 1px solid var(--divider); white-space: nowrap; background: var(--surface);
}
.screener-table thead th.num { text-align: right; }
.screener-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--divider); font-size: 13px; color: var(--text-1); }
.screener-table tbody td.num { text-align: right; }
.screener-table tbody tr:last-child td { border-bottom: none; }
.screener-table tbody tr { transition: background 0.15s ease; }
.screener-table tbody tr:hover td { background: var(--surface-2); }

.add-btn-row {
  height: 30px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand);
  display: inline-flex; align-items: center; gap: 4px;
  transition: all 0.15s ease;
}
.add-btn-row:hover { background: var(--brand); color: #fff; }
.add-btn-row.added { background: var(--success-bg); color: var(--success); }

/* =========================================================
   SETTINGS VIEW
   ========================================================= */
.settings-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-sm); overflow: hidden; }
.settings-head { padding: 16px 20px; border-bottom: 1px solid var(--divider); }
.settings-head h3 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.settings-head h3 i { color: var(--brand); }
.settings-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 18px; }

.weight-row { display: flex; flex-direction: column; gap: 8px; }
.weight-row-head { display: flex; align-items: center; justify-content: space-between; }
.weight-name { font-size: 13px; font-weight: 600; color: var(--text-1); display: flex; align-items: center; gap: 8px; }
.weight-name i { color: var(--text-3); font-size: 15px; }
.weight-val { font-size: 13px; font-weight: 700; color: var(--brand); }
.weight-bar {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: var(--r-full);
  background: var(--bg); outline: none;
}
.weight-bar::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand); cursor: pointer; border: 3px solid var(--surface); box-shadow: var(--sh-sm);
}
.weight-bar::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand); cursor: pointer; border: 3px solid var(--surface);
}
.weight-total { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.weight-total.ok { background: var(--success-bg); border-color: #bff0e0; }
.weight-total.bad { background: var(--danger-bg); border-color: #ffcaca; }
.weight-total-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.weight-total-val { font-size: 14px; font-weight: 700; }

.io-row { display: flex; gap: 8px; }
.io-row button { flex: 1; }

/* =========================================================
   ADD ASSET MODAL
   ========================================================= */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.5);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  width: 100%; max-width: 560px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modal-in 0.2s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--divider);
}
.modal-title { font-size: 17px; font-weight: 700; color: var(--text-1); margin: 0; }
.modal-close {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--text-3);
  transition: all 0.15s ease;
}
.modal-close:hover { background: var(--bg); color: var(--text-1); }

.modal-tabs {
  display: flex; gap: 2px; padding: 4px; margin: 16px 20px 0;
  background: var(--bg); border-radius: var(--r-md);
}
.modal-tab {
  flex: 1; height: 36px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.15s ease;
}
.modal-tab.active { background: var(--surface); color: var(--brand); box-shadow: var(--sh-sm); }

.modal-search { padding: 14px 20px 8px; }
.modal-search .search-wrap { width: 100%; }

.modal-body { padding: 8px 20px 20px; overflow-y: auto; flex: 1; }
.quick-picks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.quick-pick {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-1);
  transition: all 0.15s ease;
}
.quick-pick:hover { border-color: var(--brand); color: var(--brand); }
.quick-pick.added { background: var(--success-bg); color: var(--success); border-color: #bff0e0; }

.result-list { display: flex; flex-direction: column; gap: 6px; }
.result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface);
  transition: border-color 0.15s ease;
}
.result-item:hover { border-color: var(--brand); }
.result-badge {
  width: 34px; height: 34px; border-radius: var(--r-md);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.result-badge.crypto { background: var(--crypto-bg); color: var(--crypto-fg); }
.result-badge.stock { background: var(--stock-bg); color: var(--stock-fg); }
.result-info { flex: 1; min-width: 0; }
.result-sym { font-size: 13px; font-weight: 700; color: var(--text-1); }
.result-name { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-add {
  height: 32px; padding: 0 12px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; gap: 4px;
  transition: all 0.15s ease;
}
.result-add:hover { background: var(--brand-hover); }
.result-add.added { background: var(--success); }

/* Manual form */
.manual-form { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.form-input, .form-select {
  height: 40px; border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 0 12px; font-size: 14px; color: var(--text-1); background: var(--surface);
  outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }

/* =========================================================
   TOASTS
   ========================================================= */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  padding: 12px 14px;
  min-width: 280px;
  animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast.out { animation: toast-out 0.25s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }
.toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--info); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13px; font-weight: 700; color: var(--text-1); }
.toast-msg { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.toast-close { color: var(--text-3); font-size: 16px; }

/* ---------- Empty / loading states ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; text-align: center; gap: 8px;
}
.empty-state i { font-size: 40px; color: var(--text-3); opacity: 0.6; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--text-1); }
.empty-msg { font-size: 13px; color: var(--text-2); max-width: 320px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
i.spin { animation: spin 0.8s linear infinite; display: inline-block; }
.loading-overlay { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--text-2); font-size: 13px; }

/* ---------- Footer ---------- */
.app-footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-brand { font-size: 13px; font-weight: 600; color: var(--text-1); display: flex; align-items: center; gap: 6px; }
.footer-meta { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.footer-disclaimer { font-size: 11px; color: var(--text-3); }

/* ---------- Helpers ---------- */
.text-up { color: var(--success); }
.text-down { color: var(--danger); }
.text-muted { color: var(--text-3); }
.fw-700 { font-weight: 700; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1200px) {
  .app-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .right-panel { display: none; }
  .app-shell.no-right { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .asset-grid.has-aside { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    box-shadow: var(--sh-lg);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .mobile-menu-btn { display: grid !important; }
  .screener-layout { grid-template-columns: 1fr; }
  .filter-card { position: static; }
  .content { padding: 16px 16px 0; }
  .topbar { padding: 0 16px; gap: 10px; }
  .search-wrap { width: 100%; max-width: 260px; }
}

@media (max-width: 768px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .scenario-grid { grid-template-columns: repeat(2, 1fr); }
  .calc-result { grid-template-columns: 1fr; }
  .date-picker-btn span,
  .btn-primary-solid span,
  .btn-secondary-solid span { display: none; }
  .search-kbd { display: none; }
}

@media (max-width: 640px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .indicators-grid { grid-template-columns: 1fr; }
  .scenario-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .segmented { display: none; }
  .topbar-right { gap: 6px; }
  .asset-price { font-size: 24px; }
  .content { padding: 14px 14px 0; gap: 16px; }
  .asset-header { padding: 16px; }
  .chart-container { height: 300px; }
  .toast-container { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

/* =========================================================
   GUIDE PAGE
   ========================================================= */
.guide-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.guide-section { border-left: 4px solid var(--brand); }
.guide-section.success { border-left-color: var(--success); }
.guide-section.warning { border-left-color: var(--warning); }
.guide-section.info { border-left-color: var(--info); }
.guide-section.danger { border-left-color: var(--danger); }

.guide-card {
  padding: 20px;
}
.guide-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.guide-card h3 i { font-size: 20px; color: var(--brand); }
.guide-card.success h3 i { color: var(--success); }
.guide-card.warning h3 i { color: var(--warning); }
.guide-card.info h3 i { color: var(--info); }
.guide-card.danger h3 i { color: var(--danger); }
.guide-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
  list-style: disc;
}
.guide-card li {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
  line-height: 1.5;
}
.guide-card li strong { color: var(--text-1); }
.guide-card p {
  font-size: 13px;
  color: var(--text-2);
  margin: 0 0 8px;
  line-height: 1.55;
}
.guide-card .kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 1px 6px;
  border-radius: var(--r-sm);
}

/* Guide hero at the top of the guide view */
.guide-hero {
  background: linear-gradient(135deg, var(--brand-soft) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px 28px;
  margin-bottom: 4px;
}
.guide-hero h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.guide-hero h2 i { color: var(--brand); }
.guide-hero p {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  max-width: 640px;
  line-height: 1.55;
}

@media (max-width: 768px) {
  .guide-card { padding: 16px; }
  .guide-hero { padding: 18px 20px; }
  .guide-hero h2 { font-size: 18px; }
}

/* ---------- Last updated note + stale/loading indicators ---------- */
.last-updated-note {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--divider);
}
.last-updated-note i { font-size: 14px; }
.last-updated-note .market-closed-tag {
  background: var(--warning-bg);
  color: #b45309;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-weight: 600;
  font-size: 11px;
}
.last-updated-note .market-open-tag {
  background: var(--success-bg);
  color: var(--success);
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-weight: 600;
  font-size: 11px;
}

.wl-loading {
  color: var(--text-3);
  font-size: 12px;
  font-style: italic;
}
.stale-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: var(--warning);
  background: var(--warning-bg);
  padding: 1px 5px;
  border-radius: var(--r-sm);
  margin-left: 4px;
  text-transform: uppercase;
}

.trend-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 80px;
  color: var(--text-3);
  font-size: 13px;
}


/* ---------- Logout button ---------- */
.btn-logout {
  width: 100%;
  height: 34px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  margin-top: 8px;
}
.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-bg);
}

/* ---------- User dropdown (avatar menu) ---------- */
.avatar-wrap { position: relative; }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  z-index: 100;
  overflow: hidden;
  animation: dropdownIn 0.15s ease;
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface-2);
}
.user-dropdown-header .avatar { flex-shrink: 0; }
.user-dropdown-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
}
.user-dropdown-sub {
  font-size: 11px;
  color: var(--text-3);
}
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: all 0.15s ease;
}
.user-dropdown-item:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.user-dropdown-item i { font-size: 16px; }
