:root {
  --bg: #f2f6fc;
  --panel: #ffffff;
  --line: #d7e0ed;
  --text: #0d223f;
  --muted: #5b6f8d;
  --primary: #005bd4;
  --primary-strong: #0f9d58;
  --danger: #c62828;
  --shadow: 0 12px 28px rgba(16, 35, 61, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 16px;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 5% -15%, #dbe9ff 0%, transparent 35%),
    radial-gradient(circle at 100% 0%, #d9f5ee 0%, transparent 30%),
    linear-gradient(135deg, #f7faff 0%, #eef4fb 50%, #f3f7fc 100%);
}

.page-shell {
  max-width: 1280px;
  margin: 0 auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #0f62fe, #00a3a3);
  font-weight: 800;
}

.eyebrow {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.12em;
}

h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #ffffffd9;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary-strong);
}

.status,
.status-sep,
.mode-badge {
  font-size: 12px;
}

.status {
  color: #1f3d66;
  font-weight: 700;
}

.status.error {
  color: var(--danger);
}

.muted {
  color: var(--muted);
}

.mode-badge {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #b8cae7;
  color: #1d4f99;
  background: #edf3ff;
  font-weight: 700;
}

.mode-badge.auto {
  color: #0a7a46;
  background: #e8f8ef;
  border-color: #95d9b2;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.compact-intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.compact-intro p {
  color: var(--muted);
  margin-top: 4px;
}

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

.controls,
.chart-wide,
.table-panel,
.insights,
.add-panel,
#kpiBox,
#decisionBox,
#newsKpiBox {
  grid-column: span 12;
}

.chart-half {
  grid-column: span 6;
}

h2 {
  font-size: 1.05rem;
  margin-bottom: 10px;
}

.grid-4,
.grid-5,
.grid-6 {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-5 {
  grid-template-columns: 1.3fr 1fr 1fr 1.3fr auto auto;
}

.grid-6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.runtime-grid {
  align-items: end;
}

.runtime-grid label {
  grid-column: span 3;
}

.runtime-status {
  margin: 0;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus {
  outline: none;
  border-color: #74a1f8;
  box-shadow: 0 0 0 2px #dce9ff;
}

.btn-row {
  display: flex;
  align-items: end;
}

.cta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #0b67e8, #1b80ff);
  color: #fff;
}

button:hover {
  filter: brightness(1.03);
}

button.secondary {
  background: #fff;
  color: #22426e;
  border: 1px solid #bcd0ef;
}

button:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: #edf3ff;
  color: #1e4f97;
  border: 1px solid #c8d9f4;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.primary-link:hover {
  background: #dfeafc;
}

.kpi-grid,
.decision-grid {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.kpi-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.decision-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.kpi-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(180deg, #f8fbff 0%, #f4f8ff 100%);
}

.kpi-item h3 {
  color: var(--muted);
  font-size: 12px;
}

.kpi-item strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
}

.decision-verdict {
  display: inline-block;
  padding: 7px 9px;
  border-radius: 9px;
  font-weight: 800;
}

.verdict-strong-buy-bias,
.verdict-buy-bias {
  background: #d9f5e5;
  color: #0d6b3e;
}

.verdict-neutral {
  background: #ecf1f8;
  color: #304a6e;
}

.verdict-sell-bias,
.verdict-strong-sell-bias {
  background: #fde7dd;
  color: #8d2b1f;
}

.signal-tag {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
}

.signal-strong-bullish,
.signal-bullish {
  color: #0f6d40;
  background: #def6e9;
}

.signal-neutral {
  color: #3f5678;
  background: #ebf0f8;
}

.signal-bearish,
.signal-strong-bearish {
  color: #8a4a00;
  background: #fff2db;
}

canvas {
  width: 100% !important;
  height: 280px !important;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  max-height: 360px;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #e5edf8;
  text-align: left;
  padding: 8px 7px;
  font-size: 12px;
}

th {
  position: sticky;
  top: 0;
  background: #eef4ff;
  color: #385983;
}

#insightList {
  margin: 6px 0 0;
  padding-left: 18px;
  color: #2f4c72;
  line-height: 1.7;
}

#methodContent p {
  margin: 2px 0 8px;
  color: #274668;
}

#methodContent ul {
  margin: 0;
  padding-left: 18px;
  color: #37567d;
  line-height: 1.7;
}

.sentiment-positive {
  color: #0f6d40;
  font-weight: 700;
}

.sentiment-negative {
  color: #a62f20;
  font-weight: 700;
}

.sentiment-neutral {
  color: #4a6183;
  font-weight: 700;
}

.secondary-section {
  display: none;
}

body.show-advanced .secondary-section {
  display: block;
}

.ghost-hidden {
  display: none;
}

@media (max-width: 1050px) {
  .chart-half {
    grid-column: span 12;
  }

  .kpi-grid,
  .decision-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid-4,
  .grid-5,
  .grid-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .runtime-grid label {
    grid-column: span 2;
  }
}

@media (max-width: 700px) {
  body {
    padding: 10px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .compact-intro {
    flex-direction: column;
    align-items: flex-start;
  }

  .kpi-grid,
  .decision-grid,
  .grid-4,
  .grid-5,
  .grid-6 {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 560px;
  }
}
