:root {
  --bg: #f4efe5;
  --panel: rgba(255, 252, 247, 0.92);
  --panel-strong: #fffaf1;
  --text: #1c1a17;
  --muted: #665f57;
  --line: rgba(28, 26, 23, 0.12);
  --accent: #b6461d;
  --accent-soft: rgba(182, 70, 29, 0.12);
  --good: #1c7c54;
  --warn: #9a5b00;
  --danger: #a02d24;
  --shadow: 0 24px 80px rgba(59, 36, 19, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(182, 70, 29, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(28, 124, 84, 0.14), transparent 24%),
    linear-gradient(180deg, #f8f1e6 0%, #efe6d7 100%);
  min-height: 100vh;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 80px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.auth-view {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(560px, 100%);
  padding: 32px;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.app-shell {
  display: grid;
  gap: 18px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 24px;
  padding: 12px 0 20px;
}

.hero-copy {
  max-width: 760px;
}

.hero-actions {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.session-badge {
  margin: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.9rem;
}

.eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: var(--accent);
}

h1 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(2.4rem, 6vw, 5.2rem);
  line-height: 0.94;
  font-weight: 700;
}

h2 {
  margin: 0;
}

.lede {
  max-width: 680px;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--muted);
}

.view-switch {
  display: flex;
  gap: 10px;
  padding: 10px;
}

.tab-button {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 14px 18px;
  background: rgba(28, 26, 23, 0.05);
  color: var(--text);
  box-shadow: none;
}

.tab-button.active {
  background: linear-gradient(135deg, #b6461d, #d86b35);
  color: #fff8f2;
  box-shadow: 0 18px 40px rgba(182, 70, 29, 0.22);
}

.view-panel {
  display: grid;
  gap: 18px;
}

.view-panel.is-hidden,
[hidden] {
  display: none !important;
}

.view-panel.is-active {
  display: grid;
}

.controls,
.favorites-panel {
  padding: 24px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--panel-strong);
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 86px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  background: linear-gradient(135deg, #b6461d, #d86b35);
  color: #fff8f2;
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(182, 70, 29, 0.28);
}

button:disabled {
  opacity: 0.7;
  cursor: progress;
}

.secondary-button {
  background: rgba(28, 26, 23, 0.08);
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--line);
}

.actions,
.section-head,
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.section-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.inline-field input {
  width: 96px;
  padding: 10px 12px;
}

.hint,
.status,
.status-text {
  color: var(--muted);
}

.warning {
  color: var(--warn);
}

.summary {
  padding: 18px 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.summary-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.status {
  margin: 0 4px;
  min-height: 24px;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.stock-card {
  padding: 20px;
  display: grid;
  gap: 18px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.badge-group {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.symbol {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.market {
  margin: 6px 0 0;
  color: var(--muted);
}

.badge {
  border-radius: 999px;
  background: rgba(28, 124, 84, 0.12);
  color: var(--good);
  padding: 10px 14px;
  font-weight: 700;
}

.risk-pill {
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  background: rgba(28, 26, 23, 0.04);
}

.risk-pill[data-risk="Low"] {
  color: var(--good);
  background: rgba(28, 124, 84, 0.08);
}

.risk-pill[data-risk="Medium"] {
  color: var(--warn);
  background: rgba(218, 163, 63, 0.14);
}

.risk-pill[data-risk="High"] {
  color: var(--danger);
  background: rgba(176, 61, 49, 0.12);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.reason-block h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.reasons {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.favorites-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-chip {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 250, 241, 0.82);
  padding: 14px;
}

.summary-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.summary-chip strong {
  font-size: 1.2rem;
}

.favorites-list {
  overflow-x: auto;
}

.favorites-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.favorites-table th,
.favorites-table td {
  border-top: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

.favorites-table tr.near-stop td {
  background: rgba(218, 163, 63, 0.14);
}

.favorites-table th {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.favorite-symbol,
.favorite-score {
  font-weight: 700;
}

.favorite-score {
  color: var(--good);
}

.favorite-marks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mark-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: rgba(28, 124, 84, 0.08);
  color: var(--good);
  white-space: nowrap;
}

.mark-pill[data-kind="stop"] {
  background: rgba(176, 61, 49, 0.12);
  color: var(--danger);
}

.favorite-empty,
.empty-state {
  padding: 22px;
  text-align: center;
}

@media (max-width: 720px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 24px;
  }

  .hero,
  .actions,
  .section-head,
  .card-actions,
  .view-switch {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
    justify-items: stretch;
  }

  .field-grid,
  .summary,
  .metrics {
    grid-template-columns: 1fr;
  }

  button,
  .tab-button {
    width: 100%;
  }
}
