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

/* ── Login overlay ────────────────────────────────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: #0d0b1e;
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(192, 132, 252, 0.10) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(244, 114, 182, 0.10) 0%, transparent 50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#login-overlay.hidden { display: none; }

.login-card {
  background: #16132b;
  border: 1px solid #332d5c;
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-logo {
  font-size: 2.8rem;
  text-align: center;
}

.login-title {
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  color: #f0e6ff;
}

.login-subtitle {
  font-size: 0.9rem;
  text-align: center;
  color: #9d8ec8;
  margin-top: -8px;
}

.login-error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #f87171;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  text-align: center;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #9d8ec8;
}

.login-field input {
  background: #1f1b38;
  border: 1px solid #332d5c;
  border-radius: 10px;
  color: #f0e6ff;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.login-field input:focus {
  border-color: #c084fc;
}

.login-btn {
  margin-top: 4px;
  background: linear-gradient(135deg, #c084fc, #f472b6);
  border: none;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 13px;
  transition: opacity 0.2s;
}
.login-btn:hover { opacity: 0.88; }

:root {
  --bg: #0d0b1e;
  --surface: #16132b;
  --surface2: #1f1b38;
  --border: #332d5c;
  --accent: #c084fc;
  --accent2: #f472b6;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --text: #f0e6ff;
  --muted: #9d8ec8;
  --radius: 18px;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(192, 132, 252, 0.07) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(244, 114, 182, 0.07) 0%, transparent 50%);
  color: var(--text);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  padding-bottom: 60px;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  text-align: center;
  padding: 52px 0 36px;
}
header h1 {
  font-size: 2.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.logo-icon {
  font-size: 2.4rem;
  flex-shrink: 0;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}
.title-text {
  background: linear-gradient(135deg, #c084fc, #f472b6, #fb923c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle {
  color: var(--muted);
  margin-top: 10px;
  font-size: 1rem;
  font-weight: 600;
}

/* ── Search ───────────────────────────────────────────────────────────────── */
.search-section { text-align: center; margin-bottom: 36px; }
.search-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}
#ticker-input {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 50px;
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 12px 22px;
  width: 280px;
  outline: none;
  text-transform: uppercase;
  letter-spacing: .08em;
  transition: border-color .2s, box-shadow .2s;
}
#ticker-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(192,132,252,0.15);
}
#ticker-input::placeholder { letter-spacing: 0; font-weight: 400; }
#analyze-btn {
  background: linear-gradient(135deg, #c084fc, #f472b6);
  border: none;
  border-radius: 50px;
  color: #fff;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  padding: 12px 28px;
  transition: opacity .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 15px rgba(192,132,252,0.35);
}
#analyze-btn:hover {
  opacity: .9;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(192,132,252,0.45);
}
#analyze-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
#analyze-btn:active { transform: translateY(0); }

.quick-picks {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 600;
}
.chip {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  color: var(--text);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: .82rem;
  font-weight: 700;
  padding: 5px 14px;
  transition: all .2s;
}
.chip:hover {
  background: var(--border);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── State ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px;
  color: var(--muted);
  font-weight: 600;
}
.spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-right-color: var(--accent2);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  background: rgba(248,113,113,0.1);
  border: 1.5px solid rgba(248,113,113,0.4);
  border-radius: var(--radius);
  color: #fca5a5;
  padding: 16px 20px;
  margin-bottom: 24px;
  text-align: center;
  font-weight: 600;
}

/* ── Stock header ─────────────────────────────────────────────────────────── */
.stock-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.stock-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #c084fc, #f472b6, #fb923c);
}
.stock-identity { display: flex; align-items: center; gap: 12px; }
.stock-identity h2 { font-size: 1.5rem; font-weight: 800; }
.ticker-badge {
  background: linear-gradient(135deg, rgba(192,132,252,0.2), rgba(244,114,182,0.2));
  border: 1.5px solid rgba(192,132,252,0.5);
  border-radius: 10px;
  color: var(--accent);
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .1em;
  padding: 4px 12px;
}
.price-block { text-align: right; }
.current-price { font-size: 2.2rem; font-weight: 800; display: block; }
.price-change { font-size: 1rem; font-weight: 700; }
.price-change.up { color: var(--green); }
.price-change.down { color: var(--red); }

/* ── Score card ───────────────────────────────────────────────────────────── */
.score-section { margin-bottom: 20px; }

.score-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  display: flex;
  gap: 36px;
  align-items: center;
  transition: border-color 0.3s;
}
.score-card[data-rating="strong-buy"]  { border-color: rgba(52,211,153,0.55); }
.score-card[data-rating="buy"]         { border-color: rgba(110,231,183,0.4); }
.score-card[data-rating="hold"]        { border-color: rgba(251,191,36,0.45); }
.score-card[data-rating="sell"]        { border-color: rgba(252,165,165,0.4); }
.score-card[data-rating="strong-sell"] { border-color: rgba(248,113,113,0.55); }

.score-left {
  text-align: center;
  flex-shrink: 0;
  min-width: 100px;
}
.score-number-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
}
.score-number {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  transition: color 0.3s;
}
.score-denom {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}
.score-label {
  font-size: 1rem;
  font-weight: 800;
  margin-top: 6px;
  transition: color 0.3s;
}

.score-right { flex: 1; min-width: 0; }

.score-title {
  font-size: .78rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 14px;
}

.score-bar-wrap { margin-bottom: 18px; }
.score-bar-track {
  height: 10px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 5px;
}
.score-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease, background 0.3s;
}
.score-bar-ends {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
}

.score-factors {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sf-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .78rem;
}
.sf-label {
  width: 108px;
  flex-shrink: 0;
  color: var(--muted);
  font-weight: 600;
}
.sf-bar-wrap { flex: 1; }
.sf-bar-track {
  height: 5px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
}
.sf-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}
.sf-pts {
  flex-shrink: 0;
  font-weight: 800;
  color: var(--text);
  font-size: .78rem;
  width: 40px;
  text-align: right;
}
.sf-max { color: var(--muted); font-weight: 600; }

/* ── Verdict ──────────────────────────────────────────────────────────────── */
.verdict-section {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.verdict-card {
  flex: 1;
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  transition: transform .2s;
}
.verdict-card:hover { transform: translateY(-2px); }
.verdict-card.bullish {
  background: linear-gradient(135deg, rgba(52,211,153,0.08), rgba(52,211,153,0.04));
  border-color: rgba(52,211,153,0.4);
}
.verdict-card.bearish {
  background: linear-gradient(135deg, rgba(248,113,113,0.08), rgba(248,113,113,0.04));
  border-color: rgba(248,113,113,0.4);
}
.verdict-card.neutral {
  background: linear-gradient(135deg, rgba(251,191,36,0.08), rgba(251,191,36,0.04));
  border-color: rgba(251,191,36,0.4);
}
.verdict-icon { font-size: 2.8rem; line-height: 1; }
.verdict-text h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 5px; }
.verdict-text p { color: var(--muted); font-size: .88rem; line-height: 1.5; }

.signal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  flex: 1;
  min-width: 200px;
}
.signal-chip {
  border-radius: 50px;
  font-size: .78rem;
  font-weight: 700;
  padding: 6px 14px;
  border: 1.5px solid transparent;
}
.signal-chip.bull {
  background: rgba(52,211,153,0.12);
  border-color: rgba(52,211,153,0.4);
  color: var(--green);
}
.signal-chip.bear {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.4);
  color: var(--red);
}
.signal-chip.neut {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--muted);
}

/* ── Metrics ──────────────────────────────────────────────────────────────── */
.section-title {
  font-size: .95rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 14px;
}
.metrics-section { margin-bottom: 20px; }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.metric-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: transform .2s, border-color .2s;
}
.metric-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}
.metric-label {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.metric-value { font-size: 1.15rem; font-weight: 800; }

/* ── Range selector ───────────────────────────────────────────────────────── */
.range-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.range-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: .82rem;
  font-weight: 800;
  padding: 6px 16px;
  transition: all .2s;
}
.range-btn:hover { border-color: var(--accent); color: var(--text); }
.range-btn.active {
  background: linear-gradient(135deg, #c084fc, #f472b6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 12px rgba(192,132,252,0.35);
}
.range-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Charts ───────────────────────────────────────────────────────────────── */
.chart-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.chart-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  grid-column: 1 / -1;
}
.chart-card.half { grid-column: auto; }
.chart-card h3 { font-size: .95rem; font-weight: 800; margin-bottom: 14px; }
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.chart-header h3 { margin-bottom: 0; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: .75rem; color: var(--muted); font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.price  { background: #c084fc; }
.dot.ma20   { background: #fbbf24; }
.dot.ma50   { background: #fb923c; }
.dot.ma200  { background: #f472b6; }

.chart-wrap { position: relative; height: 300px; }
.chart-wrap.short { height: 160px; }

.rsi-labels {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.rsi-overbought { color: var(--red); }
.rsi-oversold   { color: var(--green); }

/* ── Analysis grid ────────────────────────────────────────────────────────── */
.analysis-section { margin-bottom: 24px; }
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.analysis-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: transform .2s, border-color .2s;
}
.analysis-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}
.analysis-card h4 {
  font-size: .92rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text);
}
.analysis-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(51,45,92,0.7);
  font-size: .85rem;
}
.analysis-row:last-child { border-bottom: none; }
.analysis-row .label { color: var(--muted); font-weight: 600; }
.analysis-row .val { font-weight: 800; }
.val.bull { color: var(--green); }
.val.bear { color: var(--red); }
.val.neut { color: var(--yellow); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .chart-section { grid-template-columns: 1fr; }
  .chart-card.half { grid-column: 1 / -1; }
  .stock-header { flex-direction: column; }
  .price-block { text-align: left; }
  header h1 { font-size: 2rem; }
  .score-card { flex-direction: column; gap: 20px; }
  .score-left { min-width: unset; width: 100%; }
  .sf-label { width: 90px; }
}
