:root {
  --bg: #050505;
  --panel: rgba(8, 8, 8, 0.96);
  --panel-border: rgba(255, 255, 255, 0.08);
  --ink: #1f1b18;
  --muted: #6c6258;
  --accent: #9b6b2b;
  --accent-strong: #6d4617;
  --good: #0fa958;
  --warn: #e29a1a;
  --bad: #e04444;
  --shadow: 0 24px 60px rgba(74, 46, 17, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Aptos", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(226, 154, 26, 0.12), transparent 22%),
    radial-gradient(circle at bottom right, rgba(15, 169, 88, 0.08), transparent 18%),
    linear-gradient(160deg, #030303 0%, #070707 48%, #101010 100%);
}

.app-shell {
  width: min(1600px, calc(100% - 24px));
  margin: 12px auto;
  display: grid;
  gap: 16px;
  min-height: calc(100vh - 24px);
}

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

.status-label,
.score-label,
.recommendation-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  color: var(--muted);
  margin: 0 0 8px;
}

.score-meaning {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
}

.rsi-summary {
  font-weight: 700;
}

h2,
h3 {
  margin: 0;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
}

.panel-header p,
.status-note,
.status-date,
.indicator-card span,
#bestWindowReason {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.panel-header h2,
.panel-header .dashboard-header-row > div > p {
  color: #f5f1ea;
}

.panel.output > .panel-header p,
.panel.controls > .panel-header p,
.panel.prompt-panel > .panel-header p {
  color: #c7beb2;
}

.indicator-card small,
#capitalImpact,
#riskStake {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 8px;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 0.78fr 1.22fr;
  align-items: start;
}

.panel {
  padding: 24px;
}

.panel-header {
  margin-bottom: 18px;
}

.dashboard-header-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.dashboard-clock {
  min-width: 120px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(108, 98, 88, 0.12);
  text-align: right;
}

.dashboard-clock span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.dashboard-clock strong {
  font-size: 1.1rem;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
}

.dashboard-clock-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
  width: 100%;
}

.controls {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 12px;
}

.control-group {
  display: grid;
  gap: 8px;
}

.control-help {
  color: var(--muted);
  font-size: 0.82rem;
}

.control-indicator {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(108, 98, 88, 0.18);
  background: rgba(255, 255, 255, 0.8);
}

.control-indicator strong {
  font-size: 1rem;
  color: var(--ink);
}

.control-indicator span {
  color: var(--muted);
  font-size: 0.84rem;
}

.api-key-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(108, 98, 88, 0.18);
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
}

#testRsiButton {
  padding: 10px 14px;
  border: 1px solid rgba(108, 98, 88, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

#testRsiButton:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 169, 88, 0.35);
  background: rgba(255, 255, 255, 1);
}

#apiKeyStatus {
  color: var(--muted);
  font-size: 0.85rem;
}

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

select,
input[type="range"] {
  width: 100%;
}

select {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(108, 98, 88, 0.18);
  background: rgba(255, 255, 255, 0.8);
}

.value-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.source-panel {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(108, 98, 88, 0.16);
  background: rgba(255, 255, 255, 0.56);
}

.source-list {
  display: grid;
  gap: 10px;
}

.source-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(108, 98, 88, 0.12);
}

.source-row strong {
  display: block;
  font-size: 1rem;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
}

.source-row span {
  color: var(--muted);
  line-height: 1.45;
}

.source-badge {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.brief-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(108, 98, 88, 0.16);
  background: rgba(255, 255, 255, 0.56);
}

.brief-card p,
.brief-card span {
  margin: 0;
  color: var(--muted);
}

.brief-card strong {
  display: block;
  margin: 6px 0;
  font-size: 1.2rem;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
}

.output {
  display: grid;
  gap: 18px;
  min-height: 70vh;
}

.headline-score {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 245, 228, 0.86), rgba(240, 229, 211, 0.78));
}

.prediction-callout {
  margin-top: 18px;
}

#focusScore {
  font-size: clamp(2.8rem, 6vw, 4.2rem);
}

.signal-pill {
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  background: rgba(166, 61, 64, 0.1);
  color: var(--bad);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

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

.market-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
}

.summary-card,
.market-card,
.trend-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(108, 98, 88, 0.14);
  background: rgba(255, 255, 255, 0.62);
}

.summary-card p,
.summary-card span,
.trend-header p,
#trendSubtitle {
  margin: 0;
  color: var(--muted);
}

.market-list,
.score-guide {
  display: grid;
  gap: 10px;
}

.market-row,
.score-band {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(108, 98, 88, 0.12);
}

.market-row strong,
.score-band strong {
  display: block;
  font-size: 1rem;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
}

.market-row span,
.score-band span {
  color: var(--muted);
  line-height: 1.45;
}

.market-status {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.summary-card strong {
  display: block;
  margin: 6px 0;
  font-size: 1.3rem;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
}

.trend-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

.trend-custom-range {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.trend-custom-range input[type="datetime-local"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(108, 98, 88, 0.18);
  background: rgba(255, 255, 255, 0.8);
  font: inherit;
}

.compact-control {
  min-width: 180px;
}

.chart-shell {
  height: 320px;
  padding: 12px 0;
  position: relative;
}

#trendChart {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.trend-line {
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-area {
  fill: rgba(155, 107, 43, 0.14);
  stroke: none;
}

.trend-dot {
  fill: var(--accent-strong);
  cursor: pointer;
}

.trend-scale {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.trend-range-summary {
  color: var(--muted);
  line-height: 1.45;
  margin-top: 8px;
}

.chart-tooltip {
  position: absolute;
  min-width: 110px;
  max-width: 180px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(31, 27, 24, 0.92);
  color: #fff9f0;
  font-size: 0.84rem;
  line-height: 1.4;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  box-shadow: 0 18px 40px rgba(31, 27, 24, 0.22);
  z-index: 2;
}

.prediction-callout {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(108, 98, 88, 0.14);
  background: rgba(255, 248, 236, 0.82);
}

.tone-up {
  color: var(--good);
}

.tone-down {
  color: var(--bad);
}

.tone-neutral {
  color: var(--warn);
}

.prediction-callout h3 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.prediction-metric {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.prediction-metric span {
  color: var(--muted);
  line-height: 1.4;
}

.prediction-metric strong {
  font-size: 1.05rem;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
}

.prediction-alerts {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.prediction-alerts-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.prediction-alert-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.prediction-alert-table th,
.prediction-alert-table td {
  padding: 6px 0;
  text-align: left;
  border-bottom: 1px solid rgba(108, 98, 88, 0.12);
}

.prediction-alert-table th:last-child,
.prediction-alert-table td:last-child {
  text-align: right;
}

.prediction-alert-table tr:last-child td {
  border-bottom: 0;
}

.prediction-alert-empty {
  color: var(--muted);
  font-size: 0.92rem;
}

.prediction-times {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 12px;
}

.prediction-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 12px;
}

.prediction-points-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.prediction-summary-card {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.prediction-summary-card span {
  display: block;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 4px;
}

.prediction-summary-card strong {
  font-size: 0.98rem;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
  line-height: 1.35;
}

.rsi-status-grid {
  margin: 10px 0 12px;
}

.prediction-time-card {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.prediction-time-card span {
  display: block;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 4px;
}

.prediction-time-card strong {
  font-size: 0.98rem;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
}

.prediction-callout p:last-child {
  margin: 0;
  color: var(--muted);
}

.indicator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.indicator-card,
.recommendation-card,
.decision-card,
.risk-card,
.condition-card,
.window-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(108, 98, 88, 0.14);
  background: rgba(255, 255, 255, 0.62);
}

.indicator-card p,
.window-card p {
  margin: 0 0 6px;
  color: var(--muted);
}

.indicator-card strong,
.window-card strong {
  display: block;
  font-size: 2rem;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
}

.recommendation-card h3 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.decision-card h3 {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.risk-card h3 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.condition-card h3 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.window-list {
  display: grid;
  gap: 12px;
}

.window-card {
  display: grid;
  gap: 8px;
}

.window-topline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.badge {
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
}

.prompt-panel pre {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
  color: #2f2822;
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .dashboard-header-row {
    flex-direction: column;
  }

  .dashboard-clock {
    text-align: left;
  }

  .trend-header {
    flex-direction: column;
    align-items: stretch;
  }

  .trend-custom-range {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1160px);
    margin: 10px auto;
  }

  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .indicator-grid,
  .brief-grid,
  .summary-strip,
  .market-grid,
  .decision-row,
  .prediction-summary-grid,
  .prediction-points-grid,
  .prediction-times {
    grid-template-columns: 1fr;
  }
}
