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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #22263a;
  --border: #2e3250;
  --accent: #6c8fff;
  --accent-hover: #849fff;
  --text: #e8eaf6;
  --text-muted: #7b82a8;
  --green: #4caf82;
  --red: #e05c5c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ── Auth ── */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--accent);
  text-align: center;
}

.tagline {
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
  margin-bottom: 28px;
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.tab.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  padding: 12px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-muted); }

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px;
  transition: background 0.15s;
  width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-google {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  display: flex;
  font-size: 0.9rem;
  gap: 10px;
  justify-content: center;
  padding: 11px;
  transition: border-color 0.15s;
  width: 100%;
}

.btn-google:hover { border-color: var(--accent); }

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 8px 16px;
  transition: border-color 0.15s;
}

.btn-secondary:hover { border-color: var(--accent); }

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
  text-decoration: underline;
}

.btn-link:hover { color: var(--text); }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.error-msg {
  color: var(--red);
  font-size: 0.875rem;
  text-align: center;
}

.error-msg.centered { margin-top: 16px; }

/* ── App ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.logo-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-small {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.tagline-small {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.editable-name {
  cursor: pointer;
  border-bottom: 1px dashed var(--text-muted);
  padding-bottom: 1px;
}

.editable-name:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.editable-name-input {
  font-size: inherit;
  font-family: inherit;
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent);
  outline: none;
  width: 80px;
  padding-bottom: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ── Search ── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 36px;
}

.search-bar input {
  flex: 1;
  font-size: 1rem;
  text-transform: uppercase;
}

.search-bar input::placeholder { text-transform: none; }

.search-bar .btn-primary {
  width: auto;
  padding: 12px 22px;
  white-space: nowrap;
}

.search-bar .btn-secondary {
  white-space: nowrap;
  padding: 12px 16px;
}

/* ── Watchlist ── */
.watchlist-section { margin-bottom: 36px; }

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.watchlist-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 6px 14px;
  transition: border-color 0.15s, background 0.15s;
}

.chip:hover { border-color: var(--accent); background: var(--surface-2); }

.chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0 0 2px;
}

.chip-remove:hover { color: var(--red); }

.muted { color: var(--text-muted); font-size: 0.875rem; }

/* ── Pulse Card ── */
.pulse-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.pulse-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.pulse-card-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.card-symbol {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.card-price-block {
  text-align: right;
}

.card-price {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.card-change {
  font-size: 0.875rem;
  font-weight: 600;
}

.card-change.positive { color: var(--green); }
.card-change.negative { color: var(--red); }

/* ── Analyst visual ── */
.analyst-visual {
  margin-bottom: 12px;
}

.rating-bar-track {
  display: flex;
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
  gap: 2px;
  margin-bottom: 8px;
}

.rating-seg {
  height: 100%;
  border-radius: 4px;
  transition: opacity 0.15s;
  min-width: 2px;
}

.rating-seg:hover { opacity: 0.75; }
.rating-buy  { background: var(--green); }
.rating-hold { background: #4b5563; }
.rating-sell { background: var(--red); }

.rating-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.rm-counts { display: flex; align-items: center; flex-wrap: wrap; }
.rm-buy  { color: var(--green); font-weight: 600; }
.rm-hold { color: #9ca3af; font-weight: 600; }
.rm-sell { color: var(--red); font-weight: 600; }
.rm-sep  { color: var(--text-muted); }

.rm-consensus {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.consensus-buy,
.consensus-strong-buy  { background: rgba(76,175,130,0.18); color: var(--green); }
.consensus-hold        { background: rgba(156,163,175,0.18); color: #9ca3af; }
.consensus-sell,
.consensus-strong-sell { background: rgba(224,92,92,0.18); color: var(--red); }

.price-targets-row {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.price-targets-row strong { color: var(--text); }
.pt-up   { color: var(--green); font-weight: 600; }
.pt-down { color: var(--red); font-weight: 600; }
.pt-sep  { color: var(--border); }

/* ── Skeleton loading ── */
.skeleton-line {
  height: 13px;
  border-radius: 4px;
  margin-bottom: 9px;
  width: 100%;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
}

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

.synthesis-error {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-style: italic;
}

/* ── Range bar ── */
.range-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.range-bar {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  position: relative;
  min-width: 120px;
}

.range-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--accent), var(--green));
  border-radius: 99px;
}

.range-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 50%;
}

.range-dot-price {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.range-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.range-label-year {
  font-size: 0.72rem;
  color: var(--text-muted);
  width: 100%;
  text-align: center;
  margin-top: -4px;
}

/* ── Pulse paragraphs ── */
.pulse-sections {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pulse-section-block {
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

.pulse-section-block:first-child { border-top: none; padding-top: 0; }

.pulse-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
}

.pulse-sub-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 16px;
  margin-bottom: 6px;
}

.pulse-para {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.7;
}

.events-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.event-date-header {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.event-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-item {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}

.event-category {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.cat-earnings    { background: rgba(108,143,255,0.15); color: #6c8fff; }
.cat-product     { background: rgba(76,175,130,0.15);  color: #4caf82; }
.cat-analyst     { background: rgba(168,124,232,0.15); color: #a87ce8; }
.cat-m-a         { background: rgba(232,160,80,0.15);  color: #e8a050; }
.cat-legal       { background: rgba(224,92,92,0.15);   color: #e05c5c; }
.cat-leadership  { background: rgba(80,200,200,0.15);  color: #50c8c8; }
.cat-macro       { background: rgba(160,160,160,0.15); color: #a0a0a0; }
.cat-competitor  { background: rgba(232,192,80,0.15);  color: #e8c050; }
.cat-partnership { background: rgba(80,128,232,0.15);  color: #5080e8; }
.cat-capital     { background: rgba(232,112,184,0.15); color: #e870b8; }
.cat-other       { background: rgba(123,130,168,0.15); color: #7b82a8; }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Loading ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 0;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .app-main { padding: 20px 16px 48px; }
  .pulse-card { padding: 20px; }
  .card-price { font-size: 1.3rem; }
  .search-bar { flex-direction: column; }
  .search-bar .btn-primary { width: 100%; }
  .search-bar .btn-secondary { width: 100%; }
  .rm-consensus { margin-left: 0; }
}
