/* ═══════════════════════════════════════════════════════════════
   HFT Dashboard – Premium Glassmorphism Dark Mode
   Palette: Deep Navy · Red=UP · Blue=DOWN · Cyan=SURGE
   ═══════════════════════════════════════════════════════════════ */

/* ─── Custom Properties ─────────────────────────────────────── */
:root {
  /* PnL Panel */
  --pnl-h: 72px;
  /* Strategy Hub */
  --hub-h: 56px;
  /* Position highlight */
  --color-position: #ffd60a;
  --color-position-glow: rgba(255, 214, 10, 0.4);
  /* Toast */
  --color-success: #00ffcc;
  --color-danger: #ff2d55;
  --color-warning: #ffd60a;
  --color-info: #4facfe;
  /* Background */
  --bg-base: #050810;
  --bg-secondary: #080c18;

  /* Glass */
  --glass-bg: rgba(10, 16, 36, 0.65);
  --glass-bg-hover: rgba(12, 20, 45, 0.85);
  --glass-blur: blur(14px) saturate(160%);

  /* Borders */
  --border-subtle: rgba(80, 140, 255, 0.07);
  --border-card: rgba(80, 140, 255, 0.13);
  --border-card-hover: rgba(79, 172, 254, 0.32);

  /* Colors: Japanese market convention (Red=UP, Blue=DOWN) */
  --color-up: #ff2d55;
  --color-up-dim: rgba(255, 45, 85, 0.15);
  --color-up-glow: rgba(255, 45, 85, 0.45);
  --color-down: #0a84ff;
  --color-down-dim: rgba(10, 132, 255, 0.15);
  --color-down-glow: rgba(10, 132, 255, 0.45);

  /* Surge / Accent */
  --color-surge: #00ffcc;
  --color-surge-dim: rgba(0, 255, 204, 0.12);
  --color-surge-glow: rgba(0, 255, 204, 0.4);
  --color-warn: #ffd60a;
  --color-accent: #4facfe;
  --color-accent-glow: rgba(79, 172, 254, 0.3);

  /* Text */
  --text-primary: #dde8ff;
  --text-secondary: rgba(200, 220, 255, 0.6);
  --text-muted: rgba(180, 205, 255, 0.32);

  /* Typography */
  --font:
    -apple-system, "SF Pro Display", "Helvetica Neue", "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;

  /* Layout */
  --header-h: 64px;
  --controls-h: 50px;
  --card-min: 196px;
  --radius: 13px;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ─── Background ─────────────────────────────────────────────── */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(79, 172, 254, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 172, 254, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
}

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 90% 45% at 15% -5%,
      rgba(79, 172, 254, 0.1) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 35% at 85% 105%,
      rgba(255, 45, 85, 0.07) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 50% 50% at 50% 50%,
      rgba(0, 255, 204, 0.03) 0%,
      transparent 70%
    );
}

/* ─── Header Alert ────────────────────────────────────────── */
.header-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 45, 85, 0.12);
  border: 1px solid rgba(255, 45, 85, 0.3);
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: #ff3b30;
  margin-right: 8px;
  white-space: nowrap;
}

.header-alert.hidden {
  display: none;
}

.alert-pulse {
  width: 6px;
  height: 6px;
  background: #ff3b30;
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(255, 59, 48, 0.4);
  animation: alertPulse 1.5s infinite;
}

@keyframes alertPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(255, 59, 48, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0);
  }
}

.alert-value {
  color: #fff;
  font-family: var(--font-mono);
  margin-left: 4px;
  cursor: pointer;
  user-select: all;
  transition: opacity 0.2s;
}

.alert-value:hover {
  text-decoration: underline;
  opacity: 0.8;
}

.alert-link {
  color: inherit;
  text-decoration: underline;
  opacity: 0.8;
  margin-left: 4px;
}
.alert-link:hover {
  opacity: 1;
}

/* ─── Header ─────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 16px;
  background: rgba(5, 8, 16, 0.82);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
}

/* Logo */
.header-left {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  user-select: none;
}

.logo-icon {
  font-size: 22px;
  animation: pulse-icon 2.4s ease-in-out infinite;
}
@keyframes pulse-icon {
  0%,
  100% {
    filter: drop-shadow(0 0 5px rgba(255, 214, 10, 0.6));
  }
  50% {
    filter: drop-shadow(0 0 14px rgba(255, 214, 10, 1));
  }
}

.logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--text-primary);
}
.logo-accent {
  color: var(--color-accent);
  text-shadow: 0 0 12px var(--color-accent-glow);
}

.market-time {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--border-card);
  border-radius: 7px;
  padding: 4px 11px;
}

/* Stats bar */
.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--glass-bg);
  border: 1px solid var(--border-card);
  border-radius: 11px;
  padding: 6px 8px;
  backdrop-filter: var(--glass-blur);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 14px;
  gap: 2px;
}
.stat-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  transition: color 0.3s ease;
  min-width: 2ch;
  text-align: center;
}
.stat-value.surge {
  color: var(--color-surge);
  text-shadow: 0 0 9px var(--color-surge-glow);
}
.stat-value.up {
  color: var(--color-up);
}
.stat-value.down {
  color: var(--color-down);
}

.stat-divider {
  width: 1px;
  height: 30px;
  background: var(--border-subtle);
}

/* Connection status + latency */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Login Trigger Button */
.btn-login {
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid rgba(255, 45, 85, 0.4);
  background: rgba(255, 45, 85, 0.15);
  color: #ff3b30;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  outline: none;
}
.btn-login:hover:not(:disabled) {
  background: rgba(255, 45, 85, 0.25);
  border-color: rgba(255, 45, 85, 0.6);
  color: #ff4d42;
  box-shadow: 0 0 10px rgba(255, 45, 85, 0.2);
}
.btn-login:disabled {
  border: 1px solid var(--border-subtle);
  background: var(--glass-bg);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

/* Latency indicator */
.latency-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-card);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.latency-label {
  font-size: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.latency-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-surge);
  transition:
    color 0.4s ease,
    text-shadow 0.4s ease;
}
.latency-indicator.latency-warn .latency-value {
  color: var(--color-warn);
}
.latency-indicator.latency-danger .latency-value {
  color: var(--color-up);
  text-shadow: 0 0 8px var(--color-up-glow);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 16px;
  border-radius: 22px;
  border: 1px solid var(--border-card);
  background: var(--glass-bg);
  font-size: 13px;
  font-weight: 600;
  transition:
    border-color 0.3s ease,
    background 0.3s ease;
  backdrop-filter: var(--glass-blur);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition:
    background 0.3s ease,
    box-shadow 0.3s ease;
}

.connection-status.connected {
  border-color: rgba(0, 255, 204, 0.3);
}
.connection-status.connected .status-dot {
  background: var(--color-surge);
  box-shadow:
    0 0 6px var(--color-surge-glow),
    0 0 12px var(--color-surge-glow);
  animation: dot-blink 2.2s ease-in-out infinite;
}
.connection-status.connected .status-text {
  color: var(--color-surge);
}

.connection-status.disconnected .status-dot {
  background: var(--color-up);
  box-shadow: 0 0 6px var(--color-up-glow);
}
.connection-status.disconnected .status-text {
  color: var(--color-up);
}
.connection-status .status-text {
  color: var(--text-muted);
}

@keyframes dot-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ─── Controls ───────────────────────────────────────────────── */
.controls {
  position: sticky;
  top: var(--header-h);
  z-index: 190;
  min-height: var(--controls-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 28px;
  background: rgba(5, 8, 16, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.controls-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex-shrink: 0;
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sort-btn {
  padding: 5px 13px;
  border-radius: 7px;
  border: 1px solid var(--border-card);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
}
.sort-btn:hover {
  background: rgba(79, 172, 254, 0.09);
  border-color: rgba(79, 172, 254, 0.28);
  color: var(--text-primary);
}
.sort-btn.active {
  background: var(--color-surge-dim);
  border-color: rgba(0, 255, 204, 0.42);
  color: var(--color-surge);
  box-shadow: 0 0 10px rgba(0, 255, 204, 0.12);
}

/* Search */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  width: 13px;
  height: 13px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  background: var(--glass-bg);
  border: 1px solid var(--border-card);
  border-radius: 9px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  padding: 6px 14px 6px 30px;
  width: 190px;
  outline: none;
  transition: all 0.2s ease;
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-input:focus {
  border-color: rgba(79, 172, 254, 0.48);
  background: rgba(10, 16, 36, 0.88);
  box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.09);
}

/* ─── PnL Panel ──────────────────────────────────────────────── */
.pnl-panel {
  position: sticky;
  top: calc(var(--header-h) + var(--controls-h));
  z-index: 180;
  display: flex;
  align-items: center;
  gap: 0;
  height: var(--pnl-h);
  padding: 0 28px;
  background: rgba(5, 8, 16, 0.8);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
}

/* Total PnL block */
.pnl-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex-shrink: 0;
  min-width: 160px;
}

.pnl-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.pnl-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  transition:
    color 0.4s ease,
    text-shadow 0.4s ease;
}
.pnl-value.profit {
  color: var(--color-surge);
  text-shadow: 0 0 14px var(--color-surge-glow);
}
.pnl-value.loss {
  color: var(--color-up);
  text-shadow: 0 0 14px var(--color-up-glow);
}
.pnl-value.neutral {
  color: var(--text-secondary);
}

/* Vertical divider between pnl-main and stats */
.pnl-divider {
  width: 1px;
  height: 40px;
  background: var(--border-subtle);
  flex-shrink: 0;
  margin: 0 20px;
}

/* Stats row */
.pnl-stats {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
}

.pnl-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0 18px;
}

.pnl-stat-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pnl-stat-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.pnl-stat-sep {
  width: 1px;
  height: 28px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

/* Mini PnL chart */
.pnl-chart-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  margin-left: auto;
  padding-left: 16px;
}

/* CSV export button */
.btn-export {
  flex-shrink: 0;
  margin-left: 12px;
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid rgba(79, 172, 254, 0.35);
  background: rgba(79, 172, 254, 0.07);
  color: var(--color-accent);
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  text-transform: uppercase;
}
.btn-export:hover {
  background: rgba(79, 172, 254, 0.16);
  border-color: rgba(79, 172, 254, 0.55);
  box-shadow: 0 0 10px rgba(79, 172, 254, 0.18);
  color: var(--text-primary);
}
.btn-export:active {
  transform: scale(0.97);
}

#pnl-chart {
  display: block;
  border-radius: 6px;
  background: rgba(10, 16, 36, 0.5);
}

/* ─── Strategy Hub ───────────────────────────────────────────── */
.strategy-hub {
  position: sticky;
  top: calc(var(--header-h) + var(--controls-h) + var(--pnl-h));
  z-index: 170;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--hub-h);
  padding: 0 28px;
  background: rgba(4, 6, 14, 0.88);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
}

.hub-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}

.hub-cards {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.hub-cards::-webkit-scrollbar {
  display: none;
}

.hub-empty {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* Strategy card */
.hub-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-card);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  flex-shrink: 0;
  transition:
    border-color 0.25s ease,
    background 0.25s ease;
  min-width: 180px;
}
.hub-card.active {
  border-color: rgba(0, 255, 204, 0.22);
}
.hub-card.inactive {
  opacity: 0.45;
}

.hub-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.hub-card-id {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}
.hub-card-status {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-surge);
}
.hub-card.inactive .hub-card-status {
  color: var(--text-muted);
}

.hub-card-stats {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: var(--font-mono);
}
.hub-stat-pnl {
  font-weight: 700;
}
.hub-stat-pnl.profit {
  color: var(--color-surge);
}
.hub-stat-pnl.loss {
  color: var(--color-up);
}
.hub-stat-pnl.neutral {
  color: var(--text-secondary);
}
.hub-stat {
  color: var(--text-secondary);
  white-space: nowrap;
}
.hub-stat.has-pos {
  color: var(--color-position);
  font-weight: 700;
}
.hub-stat-sep {
  color: var(--text-muted);
  user-select: none;
}

/* Trading HALT banner */
.hub-halt-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 6px 16px;
  border-radius: 8px;
  background: rgba(255, 45, 85, 0.14);
  border: 1px solid rgba(255, 45, 85, 0.55);
  font-size: 12px;
  font-weight: 700;
  color: var(--color-up);
  letter-spacing: 0.06em;
  animation: halt-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.halt-icon {
  font-size: 14px;
}

@keyframes halt-pulse {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(255, 45, 85, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 45, 85, 0.65);
  }
}

/* Body-level HALT flash overlay */
@keyframes halt-flash {
  0% {
    opacity: 0;
  }
  15% {
    opacity: 0.18;
  }
  100% {
    opacity: 0;
  }
}
body.halt-flash::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #ff2d55;
  pointer-events: none;
  animation: halt-flash 0.9s ease-out forwards;
}

/* ─── Main Grid ──────────────────────────────────────────────── */
.main-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: 9px;
  padding: 18px 28px 32px;
  min-height: calc(
    100vh - var(--header-h) - var(--controls-h) - var(--pnl-h) - var(--hub-h)
  );
}

/* ─── Empty State ────────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100px 24px;
  gap: 14px;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 52px;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}
.empty-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
}
.empty-sub {
  font-size: 13px;
}

/* ─── Stock Cards ────────────────────────────────────────────── */
.stock-card {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 13px 15px 12px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 9px;
  min-height: 116px;
  transition:
    transform 0.14s ease,
    border-color 0.3s ease,
    background 0.3s ease,
    box-shadow 0.3s ease;
  cursor: default;
  will-change: transform;
}

.stock-card:hover {
  transform: translateY(-3px) scale(1.005);
  border-color: var(--border-card-hover);
  background: var(--glass-bg-hover);
}

/* IN POSITION highlight (gold border) */
.stock-card.in-position {
  border-color: rgba(255, 214, 10, 0.55);
  box-shadow:
    0 0 16px rgba(255, 214, 10, 0.18),
    inset 0 0 20px rgba(255, 214, 10, 0.05);
}

/* IN POSITION badge */
.position-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--color-position);
  background: rgba(255, 214, 10, 0.1);
  border: 1px solid rgba(255, 214, 10, 0.38);
  border-radius: 4px;
  padding: 2px 6px;
  text-transform: uppercase;
  white-space: nowrap;
  animation: position-glow 2s ease-in-out infinite;
}
@keyframes position-glow {
  0%,
  100% {
    box-shadow: 0 0 4px rgba(255, 214, 10, 0.25);
  }
  50% {
    box-shadow: 0 0 10px rgba(255, 214, 10, 0.55);
  }
}

/* Card header badges container */
.card-header-right {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Surge levels */
.stock-card.surge-high {
  border-color: rgba(0, 255, 204, 0.52);
  box-shadow:
    0 0 18px rgba(0, 255, 204, 0.16),
    inset 0 0 24px rgba(0, 255, 204, 0.05);
  animation: surge-pulse-high 1.6s ease-in-out infinite;
}
.stock-card.surge-medium {
  border-color: rgba(0, 255, 204, 0.28);
  box-shadow: 0 0 9px rgba(0, 255, 204, 0.1);
}

@keyframes surge-pulse-high {
  0%,
  100% {
    box-shadow:
      0 0 18px rgba(0, 255, 204, 0.16),
      inset 0 0 24px rgba(0, 255, 204, 0.05);
  }
  50% {
    box-shadow:
      0 0 32px rgba(0, 255, 204, 0.32),
      inset 0 0 36px rgba(0, 255, 204, 0.09);
  }
}

/* Card Header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.stock-code {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.06em;
}

/* Surge badge */
.surge-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--color-surge);
  background: var(--color-surge-dim);
  border: 1px solid rgba(0, 255, 204, 0.32);
  border-radius: 5px;
  padding: 2px 7px;
  opacity: 0;
  transform: scale(0.75) translateY(-4px);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease;
  pointer-events: none;
}
.surge-badge.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.surge-arrow {
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  fill: var(--color-surge);
}

/* Price */
.card-price {
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.price-value {
  font-family: var(--font-mono);
  font-size: 23px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  transition:
    color 0.25s ease,
    text-shadow 0.25s ease;
}
.price-unit {
  font-size: 11px;
  color: var(--text-muted);
}

/* Card Footer */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.change-badge {
  display: flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  transition:
    color 0.25s ease,
    background 0.25s ease;
}
.change-badge.up {
  color: var(--color-up);
  background: var(--color-up-dim);
  border: 1px solid rgba(255, 45, 85, 0.22);
}
.change-badge.down {
  color: var(--color-down);
  background: var(--color-down-dim);
  border: 1px solid rgba(10, 132, 255, 0.22);
}
.change-badge.flat {
  color: var(--text-muted);
  background: rgba(200, 220, 255, 0.04);
  border: 1px solid var(--border-subtle);
}

.volume-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.volume-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.volume-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  transition: color 0.25s ease;
}

/* Surge progress bar (bottom edge) */
.surge-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--color-surge) 0%,
    rgba(0, 255, 204, 0) 100%
  );
  border-radius: 0 0 0 var(--radius);
  width: 0%;
  transition: width 0.55s cubic-bezier(0.25, 1, 0.5, 1);
}

/* ─── Price Flash Animations ─────────────────────────────────── */
@keyframes flash-up {
  0% {
    color: var(--text-primary);
    text-shadow: none;
  }
  25% {
    color: var(--color-up);
    text-shadow: 0 0 14px var(--color-up-glow);
  }
  100% {
    color: var(--text-primary);
    text-shadow: none;
  }
}
@keyframes flash-down {
  0% {
    color: var(--text-primary);
    text-shadow: none;
  }
  25% {
    color: var(--color-down);
    text-shadow: 0 0 14px var(--color-down-glow);
  }
  100% {
    color: var(--text-primary);
    text-shadow: none;
  }
}

.price-value.flash-up {
  animation: flash-up 0.85s ease-out forwards;
}
.price-value.flash-down {
  animation: flash-down 0.85s ease-out forwards;
}

/* ─── Toast Notification System ─────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 320px;
}

.toast {
  pointer-events: all;
  background: rgba(8, 12, 26, 0.92);
  border-radius: 10px;
  border: 1px solid var(--border-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  overflow: hidden;
  /* Start hidden: slide in from right */
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  transition:
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.32s ease;
}
.toast.toast-visible {
  transform: translateX(0);
  opacity: 1;
}
.toast.toast-hiding {
  transform: translateX(calc(100% + 24px));
  opacity: 0;
}

/* Colour variants */
.toast-success {
  border-color: rgba(0, 255, 204, 0.42);
}
.toast-warning {
  border-color: rgba(255, 214, 10, 0.5);
}
.toast-danger {
  border-color: rgba(255, 45, 85, 0.55);
}
.toast-info {
  border-color: rgba(79, 172, 254, 0.4);
}

.toast-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
}

.toast-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}
.toast-success .toast-icon {
  color: var(--color-surge);
}
.toast-warning .toast-icon {
  color: var(--color-warn);
}
.toast-danger .toast-icon {
  color: var(--color-up);
}
.toast-info .toast-icon {
  color: var(--color-accent);
}

.toast-content {
  flex: 1;
  min-width: 0;
}
.toast-message {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-detail {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-top: 2px;
}
.toast-success .toast-message {
  color: var(--color-surge);
}
.toast-warning .toast-message {
  color: var(--color-warn);
}
.toast-danger .toast-message {
  color: var(--color-up);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 0 0 0 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s ease;
}
.toast-close:hover {
  color: var(--text-primary);
}

/* Auto-dismiss progress bar */
.toast-progress {
  height: 2px;
  background: var(--border-subtle);
  position: relative;
  overflow: hidden;
}
.toast-progress::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  transform-origin: left;
  animation: toast-drain var(--toast-dur, 4s) linear forwards;
}
.toast-success .toast-progress::after {
  background: var(--color-surge);
}
.toast-warning .toast-progress::after {
  background: var(--color-warn);
}
.toast-danger .toast-progress::after {
  background: var(--color-up);
}
.toast-info .toast-progress::after {
  background: var(--color-accent);
}

@keyframes toast-drain {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(79, 172, 254, 0.22);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 172, 254, 0.44);
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1280px) {
  :root {
    --card-min: 180px;
  }
}
@media (max-width: 900px) {
  :root {
    --card-min: 160px;
  }
  .stats-bar {
    display: none;
  }
  .header {
    padding: 0 16px;
  }
  .controls {
    padding: 8px 16px;
  }
  .main-grid {
    padding: 12px 16px 24px;
    gap: 7px;
  }
  .pnl-panel {
    padding: 0 16px;
  }
  .pnl-chart-wrap {
    display: none;
  }
  .pnl-stat-item {
    padding: 0 10px;
  }
  .strategy-hub {
    padding: 0 16px;
  }
  .toast-container {
    width: 280px;
    right: 12px;
  }
}
@media (max-width: 600px) {
  :root {
    --card-min: 140px;
    --pnl-h: 60px;
    --hub-h: 52px;
  }
  .sort-controls {
    overflow-x: auto;
    padding-bottom: 2px;
    gap: 4px;
  }
  .sort-btn {
    font-size: 11px;
    padding: 4px 9px;
  }
  .search-input {
    width: 140px;
  }
  .logo-text {
    font-size: 17px;
  }
  .market-time {
    display: none;
  }
  .latency-indicator {
    display: none;
  }
  .pnl-main {
    min-width: 120px;
  }
  .pnl-value {
    font-size: 17px;
  }
  .pnl-stat-item:nth-child(n + 4) {
    display: none;
  }
  .pnl-chart-wrap {
    display: none;
  }
  .btn-export {
    display: none;
  }
  .hub-halt-banner {
    display: none;
  }
  .toast-container {
    width: 240px;
    right: 8px;
    top: 12px;
  }
  .toast-message {
    font-size: 12px;
  }
}
