/* ==================================================================
   PortSignal — Design tokens & base styles
================================================================== */
:root {
  --bg: #0a0e17;
  --bg-soft: #0d1220;
  --card: #131a2b;
  --card-hover: #182036;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8eaf0;
  --text-muted: #97a1b8;
  --text-dim: #626b82;
  --primary: #6d6bff;
  --primary-hover: #8482ff;
  --primary-dim: rgba(109, 107, 255, 0.16);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.14);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.14);
  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.14);
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.45);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
  --container: 1160px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--primary-dim); }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.section { padding: 88px 0; }
.section-alt { background: var(--bg-soft); }
.section-head { max-width: 640px; margin: 0 0 40px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-hover);
  background: var(--primary-dim);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.section-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.section-desc { color: var(--text-muted); font-size: 15.5px; line-height: 1.7; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4c4aeb);
  color: #fff;
  box-shadow: 0 8px 24px rgba(109, 107, 255, 0.35);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-hover), var(--primary)); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------------- Header ---------------- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(10, 14, 23, 0.75);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}
.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav a {
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.nav-toggle { display: none; }

/* ---------------- Hero ---------------- */
.hero {
  position: relative;
  padding: 96px 0 72px;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 560px;
  background: radial-gradient(60% 60% at 30% 20%, rgba(109, 107, 255, 0.28), transparent 70%),
    radial-gradient(50% 50% at 80% 10%, rgba(34, 197, 94, 0.18), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 56px;
  align-items: center;
}
.hero-title {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.28;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}
.hero-title .accent {
  background: linear-gradient(135deg, #8482ff, #22c55e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-desc {
  font-size: 16.5px;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 32px;
  max-width: 520px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }
.hero-meta {
  display: flex;
  gap: 22px;
  color: var(--text-dim);
  font-size: 13.5px;
  flex-wrap: wrap;
}
.hero-meta b { color: var(--text); font-weight: 700; }

/* Hero mock dashboard card */
.hero-card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
}
.hero-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.hero-card-head span { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.hero-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-dim); }
.hero-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.hero-stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.hero-stat .label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.hero-stat .value { font-size: 19px; font-weight: 800; }
.hero-mini-news {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.hero-mini-news:last-child { margin-bottom: 0; }
.hero-mini-news .txt { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.hero-mini-news .txt b { color: var(--text); }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---------------- Cards / grid ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

/* ---------------- Dashboard stat cards ---------------- */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.stat-card .label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-card .value { font-size: 25px; font-weight: 800; letter-spacing: -0.01em; }
.stat-card .sub { font-size: 12.5px; color: var(--text-dim); margin-top: 6px; }
.stat-card .value.pos { color: var(--green); }
.stat-card .value.neg { color: var(--red); }

/* ---------------- Portfolio builder ---------------- */
.builder-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}
.search-box { position: relative; margin-bottom: 14px; }
.search-input {
  width: 100%;
  padding: 13px 16px 13px 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card-hover);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 20;
}
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(255, 255, 255, 0.05); }
.search-result-item .name { font-size: 14px; font-weight: 700; }
.search-result-item .meta { font-size: 12px; color: var(--text-dim); }
.search-result-item .price { font-size: 13px; color: var(--text-muted); }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.selected-stock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary-dim);
  border: 1px solid rgba(109, 107, 255, 0.35);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.selected-stock .name { font-weight: 700; font-size: 14.5px; }
.selected-stock .meta { font-size: 12px; color: var(--text-muted); }
.selected-stock button { color: var(--text-dim); background: none; border: none; font-size: 18px; }

.holdings-empty {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-dim);
}
.holdings-empty .icon { font-size: 32px; margin-bottom: 12px; }
.holdings-empty p { font-size: 14px; margin-bottom: 4px; }
.holdings-empty .sub { font-size: 12.5px; }

.holding-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.9fr 0.9fr 0.9fr 0.7fr 32px;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.holding-row:last-child { border-bottom: none; }
.holding-head {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 700;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--border);
}
.holding-row .stock-name { font-weight: 700; }
.holding-row .stock-ticker { font-size: 11.5px; color: var(--text-dim); }
.holding-row .pos { color: var(--green); font-weight: 700; }
.holding-row .neg { color: var(--red); font-weight: 700; }
.remove-btn {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
}
.remove-btn:hover { background: var(--red-dim); border-color: rgba(239,68,68,0.4); color: var(--red); }

/* ---------------- News section ---------------- */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.filter-chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-chip:hover:not(.active) { background: rgba(255,255,255,0.05); color: var(--text); }

.news-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.news-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.news-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.news-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.news-source-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.news-title { font-size: 15.5px; font-weight: 700; line-height: 1.45; }
.news-summary { font-size: 13.5px; color: var(--text-muted); line-height: 1.65; }
.news-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.news-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.impact-meter { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.impact-bar { width: 64px; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.impact-bar > span { display: block; height: 100%; border-radius: 999px; }
.news-empty { grid-column: 1 / -1; text-align: center; padding: 48px 0; color: var(--text-dim); }

/* modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,6,12,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px; backdrop-filter: blur(3px);
}
.modal {
  background: var(--card-hover);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  max-width: 560px; width: 100%;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  max-height: 82vh;
  overflow-y: auto;
}
.modal-close {
  float: right;
  background: none; border: none; color: var(--text-dim); font-size: 20px;
}

/* ---------------- Signals section ---------------- */
.summary-band {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.opinion-box {
  background: linear-gradient(135deg, rgba(109,107,255,0.1), rgba(34,197,94,0.06));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 28px;
}
.opinion-box .head { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 10px; font-size: 14.5px; }
.opinion-box p { color: var(--text); line-height: 1.75; font-size: 14.5px; }
.signal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.signal-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.signal-card .name-block { display: flex; align-items: center; gap: 10px; }
.signal-card .ticker-pill {
  font-size: 11px; color: var(--text-dim); background: rgba(255,255,255,0.05);
  border: 1px solid var(--border); padding: 2px 8px; border-radius: 6px;
}
.signal-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.signal-stat { text-align: left; }
.signal-stat .k { font-size: 11.5px; color: var(--text-dim); margin-bottom: 4px; }
.signal-stat .v { font-size: 15px; font-weight: 700; }
.sentiment-bar {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  margin-bottom: 14px;
  background: rgba(255,255,255,0.06);
}
.sentiment-bar .seg-pos { background: var(--green); }
.sentiment-bar .seg-neg { background: var(--red); }
.sentiment-bar .seg-neu { background: var(--text-dim); }
.signal-reason {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.65;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

/* ---------------- CTA ---------------- */
.cta {
  background: linear-gradient(135deg, rgba(109,107,255,0.16), rgba(34,197,94,0.1));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 56px 40px;
  text-align: center;
}
.cta h2 { font-size: 28px; font-weight: 800; margin-bottom: 12px; letter-spacing: -0.02em; }
.cta p { color: var(--text-muted); margin-bottom: 28px; font-size: 15px; }
.cta-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------------- Footer ---------------- */
.footer { border-top: 1px solid var(--border); padding: 48px 0 32px; }
.footer-top { display: flex; justify-content: space-between; gap: 40px; margin-bottom: 28px; flex-wrap: wrap; }
.footer-desc { max-width: 480px; color: var(--text-muted); font-size: 13.5px; line-height: 1.75; }
.footer-cols { display: flex; gap: 56px; }
.footer-col h4 { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.footer-col a, .footer-col span {
  display: block; font-size: 13.5px; color: var(--text-muted); margin-bottom: 8px;
}
.disclaimer {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 20px;
}
.footer-bottom {
  display: flex; justify-content: space-between; color: var(--text-dim); font-size: 12.5px; flex-wrap: wrap; gap: 8px;
}

/* ---------------- Live-data additions ---------------- */
.server-banner {
  background: rgba(239, 68, 68, 0.1);
  border-bottom: 1px solid rgba(239, 68, 68, 0.3);
}
.server-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  font-size: 13.5px;
  color: var(--text);
  flex-wrap: wrap;
}
.server-banner code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12.5px;
}

.refresh-box { display: flex; align-items: center; gap: 10px; }
.update-time { font-size: 12px; color: var(--text-dim); }
@keyframes spin-kf { to { transform: rotate(360deg); } }
.spin { display: inline-flex; animation: spin-kf 0.8s linear infinite; }

.search-hint { padding: 12px 14px; font-size: 13px; color: var(--text-dim); }
.builder-note { margin-top: 10px; font-size: 11.5px; color: var(--text-dim); line-height: 1.55; }

.selected-stock button { cursor: pointer; }

.tag-kw { color: var(--primary-hover); background: var(--primary-dim); border-color: transparent; }

.mini-dot {
  margin-top: 5px;
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  display: inline-block;
}
a.hero-mini-news { text-decoration: none; transition: background 0.15s ease; }
a.hero-mini-news:hover { background: rgba(255, 255, 255, 0.05); }

a.news-card { text-decoration: none; color: inherit; cursor: pointer; }
.news-open {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary-hover);
}
a.news-card:hover .news-open { color: var(--primary); }

/* ---------------- Scrollbar ---------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ---------------- Responsive ---------------- */
@media (max-width: 980px) {
  .hero-inner { grid-template-columns: 1fr; }
  .builder-grid { grid-template-columns: 1fr; }
  .grid-4, .summary-band { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .news-grid { grid-template-columns: 1fr; }
  .nav { display: none; }
  .signal-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .hero-title { font-size: 32px; }
  .section-title { font-size: 24px; }
  .grid-4, .grid-3, .grid-2, .summary-band { grid-template-columns: 1fr; }
  .holding-row { grid-template-columns: 1fr; row-gap: 6px; }
  .holding-head { display: none; }
  .signal-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .cta { padding: 40px 20px; }
  .footer-top { flex-direction: column; }
}
