:root {
  --bg: #080b10;
  --bg-elevated: #0e1319;
  --surface: #121820;
  --surface-2: #1a2230;
  --surface-hover: #1f2838;
  --text: #edf2f7;
  --muted: #7d8da3;
  --accent: #4da3ff;
  --accent-2: #5eead4;
  --up: #3dd68c;
  --down: #f87171;
  --warn: #fbbf24;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --glow: 0 0 0 1px rgba(255, 255, 255, 0.04);
  --panel-accent: var(--accent);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 156, 245, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(167, 139, 250, 0.08), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body:not(.loaded) .layout,
body:not(.loaded) .hero,
body:not(.loaded) .market-shell { opacity: 0; }

body.loaded .layout,
body.loaded .hero,
body.loaded .market-shell {
  animation: rise 0.5s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

a { color: var(--accent); text-decoration: none; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 11, 16, 0.72);
  backdrop-filter: blur(16px) saturate(1.2);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3d9cf5 0%, #5eead4 100%);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85rem;
  color: #0b0f14;
  box-shadow: 0 4px 16px rgba(61, 156, 245, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand p {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s;
}

body.loaded .status-dot {
  background: var(--up);
  box-shadow: 0 0 8px rgba(61, 214, 140, 0.6);
}

.btn {
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  color: var(--text);
  padding: 0.48rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn:hover {
  border-color: rgba(77, 163, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.1);
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: wait; transform: none; }

.hero { padding: 1.25rem 1.5rem 0.75rem; max-width: 1400px; margin: 0 auto; }

.hero-greeting {
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 0.85rem;
  color: var(--text);
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.65rem;
}

.brief-card {
  --brief-accent: var(--accent);
  position: relative;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.03) 0%, transparent 60%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem 0.75rem 1rem;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s var(--ease);
}

.brief-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--brief-accent);
  border-radius: 3px 0 0 3px;
}

.brief-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.brief-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.brief-icon { font-size: 0.75rem; line-height: 1; }

.brief-text {
  display: block;
  font-size: 0.84rem;
  margin-top: 0.35rem;
  line-height: 1.4;
  color: var(--text);
}

.market-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem 0.75rem;
}

.market-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.04) 0%, rgba(61, 156, 245, 0.04) 100%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--glow);
}

.mood-badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mood-risk-off {
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.3);
}

.mood-risk-on {
  background: rgba(61, 214, 140, 0.12);
  color: #6ee7b7;
  border-color: rgba(61, 214, 140, 0.3);
}

.mood-neutral {
  background: var(--surface-2);
  color: var(--muted);
}

.ticker {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  min-width: 108px;
  transition: border-color 0.2s;
}

.ticker:hover { border-color: var(--border-strong); }

.ticker .sym {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.ticker .price {
  font-size: 1.08rem;
  font-weight: 600;
  margin-top: 0.1rem;
  letter-spacing: -0.02em;
}

.ticker .chg {
  font-family: var(--mono);
  font-size: 0.72rem;
  margin-top: 0.12rem;
  display: block;
}

.ticker .chg.up { color: var(--up); }
.ticker .chg.down { color: var(--down); }

.market-headline {
  flex: 1 1 180px;
  font-size: 0.88rem;
  color: var(--muted);
  padding-left: 0.25rem;
}

.tabs-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem 1rem;
  position: sticky;
  top: 68px;
  z-index: 15;
  background: linear-gradient(180deg, rgba(8, 11, 16, 0.95) 70%, transparent);
  backdrop-filter: blur(8px);
}

.tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tab-count {
  font-family: var(--mono);
  font-size: 0.62rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.tab.active .tab-count {
  background: rgba(77, 163, 255, 0.2);
  color: var(--accent);
}

.tab.active,
.tab:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

.tab.active {
  border-color: rgba(77, 163, 255, 0.45);
  background: rgba(77, 163, 255, 0.1);
  box-shadow: 0 0 0 1px rgba(77, 163, 255, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 0 1.5rem 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow), var(--glow);
  min-height: 160px;
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--panel-accent, var(--accent)), transparent 80%);
  opacity: 0.85;
}

.panel[data-type="priority"]::before {
  background: linear-gradient(90deg, #fbbf24, #f472b6, transparent);
}

.panel-wide { grid-column: 1 / -1; }
.panel[data-hidden="true"] { display: none; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  gap: 0.5rem;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  color: var(--muted);
}

.alerts-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.alert-chip {
  font-family: var(--mono);
  font-size: 0.66rem;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.28);
  color: var(--warn);
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
}

.subtabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.subtab {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  text-transform: capitalize;
  transition: all 0.15s;
}

.subtab:hover { color: var(--text); border-color: var(--border-strong); }

.subtab.active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--panel-accent, var(--accent)) 50%, transparent);
  background: color-mix(in srgb, var(--panel-accent, var(--accent)) 12%, transparent);
}

.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.stock-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  transition: border-color 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stock-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
}

.sparkline {
  flex-shrink: 0;
  opacity: 0.9;
}

.sparkline.up { color: var(--up); }
.sparkline.down { color: var(--down); }
.sparkline.flat { color: var(--muted); }

.ticker .sparkline {
  margin-top: 0.35rem;
  opacity: 0.75;
}

.stock-card:hover { transform: translateY(-1px); border-color: var(--border-strong); }

.stock-card.hot {
  border-color: rgba(251, 191, 36, 0.45);
  background: linear-gradient(145deg, rgba(251, 191, 36, 0.06), var(--surface-2));
}

.stock-card .label {
  font-size: 0.62rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-card .sym {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.8rem;
}

.stock-card .price {
  font-family: var(--mono);
  font-size: 0.92rem;
  margin-top: 0.18rem;
}

.stock-card .chg { font-family: var(--mono); font-size: 0.7rem; }
.stock-card .chg.up { color: var(--up); }
.stock-card .chg.down { color: var(--down); }

.feed {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-2) transparent;
}

.feed::-webkit-scrollbar { width: 5px; }
.feed::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: 999px;
}

.card {
  display: flex;
  gap: 0.7rem;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: inherit;
  transition: border-color 0.2s, background 0.2s, transform 0.15s var(--ease);
  animation: card-in 0.35s var(--ease) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card:nth-child(1) { animation-delay: 0.02s; }
.card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3) { animation-delay: 0.06s; }
.card:nth-child(4) { animation-delay: 0.08s; }
.card:nth-child(5) { animation-delay: 0.1s; }

.card:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
  text-decoration: none;
}

.card.unread {
  border-left: 3px solid var(--panel-accent, var(--accent));
  padding-left: calc(0.75rem - 2px);
}

.card.unread h3 { font-weight: 600; }

.card .thumb {
  width: 100px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
}

.card-body { min-width: 0; flex: 1; }

.card h3 {
  margin: 0 0 0.28rem;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.38;
  letter-spacing: -0.01em;
}

.card .meta {
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--muted);
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.card .meta > span:first-child {
  color: color-mix(in srgb, var(--text) 75%, var(--muted));
}

.card .summary {
  margin: 0.32rem 0 0;
  font-size: 0.76rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
}

.tag {
  font-size: 0.6rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(94, 234, 212, 0.1);
  color: var(--accent-2);
  text-transform: capitalize;
}

.tag.verified {
  background: rgba(61, 214, 140, 0.12);
  color: var(--up);
}

.tag.severity {
  background: rgba(248, 113, 113, 0.12);
  color: var(--down);
}

.empty {
  color: var(--muted);
  font-size: 0.86rem;
  padding: 1.25rem 0.5rem;
  text-align: center;
  font-style: italic;
}

.footer {
  text-align: center;
  padding: 1.75rem 1.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
  max-width: 1400px;
  margin: 0 auto;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-brief { height: 52px; }
.skeleton-card { height: 64px; margin-bottom: 0.45rem; }

.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }

  .tabs-wrap { display: none; }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    justify-content: space-around;
    gap: 0.15rem;
    padding: 0.45rem 0.35rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    background: rgba(8, 11, 16, 0.88);
    backdrop-filter: blur(16px) saturate(1.3);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
  }

  .bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 0.35rem 0.2rem;
    border-radius: 10px;
    cursor: pointer;
    min-width: 0;
    transition: color 0.2s, background 0.2s;
  }

  .bottom-nav-btn.active {
    color: var(--accent);
    background: rgba(77, 163, 255, 0.1);
  }

  .bottom-nav-icon {
    font-size: 1.1rem;
    line-height: 1;
  }

  .bottom-nav-label {
    font-size: 0.58rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .stock-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .tabs-wrap { top: 60px; }
  .card .thumb { width: 80px; height: 45px; }
  .brief-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .brief-grid { grid-template-columns: 1fr; }
  .hero-greeting { font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}