:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #66736d;
  --paper: #f4f6f2;
  --panel: #ffffff;
  --soft: #f7f9f5;
  --line: #d8ded5;
  --green: #2c6e58;
  --red: #b24b42;
  --amber: #b37928;
  --blue: #315f8f;
  --shadow: 0 18px 46px rgba(30, 41, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "Avenir Next", Verdana, sans-serif;
}

button,
select,
input {
  font: inherit;
}

.shell {
  width: min(1320px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.header-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: stretch;
  min-height: 190px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kicker {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-family: Charter, "Iowan Old Style", Georgia, serif;
  font-size: 58px;
  line-height: 0.98;
}

h2 {
  font-size: 25px;
  line-height: 1.15;
}

h3 {
  margin-bottom: 12px;
  font-size: 14px;
  color: #34423a;
}

.summary {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.status-stack {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 142px;
  padding: 20px;
  border-radius: 6px;
  background: #17201c;
  color: white;
}

.status-label,
.status-stack span:last-child {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  line-height: 1.45;
}

.status-stack strong {
  font-size: 31px;
  line-height: 1.05;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(30, 41, 34, 0.05);
}

.events-panel,
.trend-panel,
.valuation-panel,
.rule-panel,
.price-panel,
.compounding-panel,
.discipline-panel,
.setup-panel {
  grid-column: 1 / -1;
}

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

#refreshButton {
  min-width: 92px;
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  color: white;
  background: var(--ink);
  cursor: pointer;
}

#refreshButton:disabled {
  cursor: wait;
  opacity: 0.6;
}

.state-line,
.source-line,
.context-summary,
.analysis-note,
.setup-panel p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.state-line {
  margin-top: 18px;
}

.source-line,
.setup-panel p {
  margin: 16px 0 0;
}

.analysis-note {
  margin: 14px 0;
  padding: 14px;
  border-left: 4px solid var(--blue);
  border-radius: 4px;
  background: var(--soft);
  color: #34423a;
}

.price-readout {
  display: flex;
  gap: 16px;
  align-items: baseline;
  margin: 10px 0 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.price-value {
  font-size: 62px;
  font-weight: 850;
  line-height: 0.95;
}

.price-change {
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

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

.quote-grid,
.metric-grid,
.decision-blocks,
.valuation-scale {
  display: grid;
  gap: 10px;
}

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

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

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

.decision-blocks {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.signal-bars {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fbfcfa;
}

.signal-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 86px;
  gap: 10px;
  align-items: center;
}

.signal-row span,
.signal-row strong {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.signal-row strong {
  overflow: hidden;
  color: #34423a;
  font-weight: 800;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-row div {
  height: 7px;
  border-radius: 999px;
  background: #e6ebe3;
  overflow: hidden;
}

.signal-row i {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.signal-row i.support {
  width: 78%;
  background: var(--green);
}

.signal-row i.neutral {
  width: 52%;
  background: var(--blue);
}

.signal-row i.watch {
  width: 66%;
  background: var(--amber);
}

.signal-row i.risk,
.signal-row i.weak {
  width: 86%;
  background: var(--red);
}

.valuation-scale {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 14px 0;
}

.quote-grid div,
.metric-card,
.decision-block,
.valuation-scale div,
.band-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--soft);
}

.quote-grid div,
.metric-card,
.decision-summary,
.valuation-scale div {
  padding: 14px;
}

dt,
.metric-card span,
.decision-summary span,
.valuation-scale span,
.band-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

dd,
.metric-card strong,
.decision-summary strong,
.valuation-scale strong,
.band-row strong {
  display: block;
  margin: 7px 0 0;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.22;
}

dd {
  font-size: 14px;
}

.metric-card {
  min-height: 92px;
  border-top: 5px solid var(--muted);
}

.metric-card strong {
  font-size: 18px;
}

.metric-card.favorable,
.valuation-scale .cheap {
  border-top-color: var(--green);
}

.metric-card.expensive,
.metric-card.high,
.valuation-scale .expensive {
  border-top-color: var(--red);
}

.metric-card.neutral,
.metric-card.latest_close,
.valuation-scale .fair {
  border-top-color: var(--blue);
}

.metric-card.unavailable {
  border-top-color: var(--amber);
}

.decision-block {
  padding: 14px;
  background: #f6fbf8;
}

.decision-summary {
  padding: 0;
  border: 0;
  background: transparent;
}

.decision-summary strong {
  font-size: 22px;
}

.decision-summary p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.metric-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.rule-panel {
  border-top: 6px solid var(--green);
}

.band-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.band-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 52px;
  padding: 12px 14px;
}

.band-row strong {
  margin: 0;
  text-align: right;
  white-space: nowrap;
}

.band-row.active {
  border-color: var(--green);
  background: #eef7f2;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: white;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: white;
}

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

.event-list-wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.event-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: 5px;
  background: var(--soft);
}

.event-item.high {
  border-left-color: var(--red);
}

.event-item.elevated {
  border-left-color: var(--amber);
}

.event-item.normal {
  border-left-color: var(--blue);
}

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

.event-item strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
}

.event-item p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.event-impact {
  color: #34423a;
}

.event-impact b {
  color: var(--ink);
}

.chart-box {
  margin: 16px 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  overflow: hidden;
}

.chart-box-large {
  min-height: 0;
}

#priceChart {
  display: block;
  width: 100%;
  height: 360px;
}

#externalChart {
  display: none;
  width: 100%;
  height: 430px;
  min-height: 430px;
  border: 0;
}

#externalChart .tradingview-widget-container__widget {
  width: 100%;
  height: 100%;
}

.chart-bg {
  fill: #fbfcfa;
}

.chart-grid {
  stroke: #dde5dc;
  stroke-width: 1;
}

.chart-area {
  fill: url(#priceFill);
}

.chart-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 3.2;
}

.chart-sma {
  stroke: var(--amber);
  stroke-width: 2;
  stroke-dasharray: 7 7;
}

.chart-dot {
  fill: white;
  stroke: var(--green);
  stroke-width: 3;
}

.chart-label,
.chart-empty,
.chart-price {
  fill: var(--muted);
  font-family: "Avenir Next", Verdana, sans-serif;
  font-size: 12px;
}

.chart-price {
  fill: var(--green);
  font-weight: 800;
}

.chart-empty {
  font-size: 16px;
}

.projection-layout {
  display: grid;
  grid-template-columns: minmax(250px, 0.42fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: stretch;
}

.projection-inputs {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.projection-output {
  min-width: 0;
}

.scenario-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 2px;
}

.scenario-control button {
  display: grid;
  gap: 2px;
  align-content: center;
  min-width: 0;
  min-height: 40px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: white;
  cursor: pointer;
}

.scenario-control button span,
.scenario-control button strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenario-control button strong {
  font-size: 12px;
}

.scenario-control button.active {
  border-color: var(--green);
  color: white;
  background: var(--green);
  font-weight: 700;
}

.projection-chart-box {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  overflow: hidden;
}

#projectionChart {
  display: block;
  width: 100%;
  height: 260px;
}

.projection-metrics {
  margin-top: 10px;
}

.projection-metrics strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.projection-metrics strong.value-long {
  font-size: 16px;
}

.projection-metrics strong.value-very-long {
  font-size: 14px;
}

.chart-principal {
  fill: none;
  stroke: #66736d;
  stroke-width: 2.4;
  stroke-dasharray: 7 7;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 22px;
  margin: 18px 0 0;
  padding-left: 18px;
  color: #34423a;
  line-height: 1.45;
}

code {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 16px;
  padding: 14px;
  border-radius: 5px;
  background: #17201c;
  color: #eef7f2;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
}

@media (max-width: 980px) {
  .header-band,
  .tool-grid,
  .decision-blocks,
  .quote-grid,
  .metric-grid,
  .metric-grid-four,
  .event-list-wide,
  .projection-layout,
  .checklist {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(100vw - 24px, 760px);
    padding: 18px 0 32px;
  }

  .header-band,
  .panel {
    padding: 20px;
  }

  h1 {
    font-size: 38px;
  }

  .price-value {
    font-size: 52px;
  }

  .price-readout {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .price-change {
    white-space: normal;
  }

  .signal-row {
    grid-template-columns: 82px minmax(0, 1fr) 76px;
    gap: 8px;
  }

  .chart-box-large {
    min-height: 0;
  }

  #priceChart,
  #externalChart {
    min-height: 0;
  }

  #priceChart {
    height: clamp(190px, 58vw, 240px);
  }

  #externalChart {
    height: 240px;
    min-height: 240px;
  }

  .projection-inputs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 14px;
  }

  .projection-chart-box {
    min-height: 190px;
  }

  #projectionChart {
    height: 190px;
  }

  .scenario-control {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .scenario-control button {
    min-height: 36px;
    padding: 7px 6px;
    font-size: 11px;
  }

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

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

  .valuation-scale div {
    padding: 10px 8px;
  }

  .valuation-scale strong {
    font-size: 13px;
  }

  .decision-block {
    padding: 12px;
  }

  .decision-summary strong {
    font-size: 18px;
  }

  .decision-summary p {
    font-size: 12px;
  }

  .band-row {
    display: block;
    min-height: 48px;
    padding: 10px;
  }

  .band-row strong {
    margin-top: 5px;
    text-align: left;
    white-space: normal;
  }
}
