:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f5;
  --ink: #172126;
  --muted: #68757d;
  --line: #d8e0e5;
  --blue: #2f6f9f;
  --green: #217a58;
  --amber: #af7518;
  --red: #b14444;
  --teal: #2d7d8a;
  --shadow: 0 18px 44px rgba(29, 44, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

button {
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

button.primary {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #132026;
  color: #e9f0f2;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #20333a;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.panel h3,
.section-title h3 {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
}

.brand p {
  margin-top: 3px;
  color: #adc0c7;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  color: #d9e5e9;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
}

.nav-item.active,
.nav-item:hover {
  background: #20343d;
}

.disclaimer {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #c5d4da;
  line-height: 1.45;
}

.main {
  padding: 28px;
  display: grid;
  gap: 22px;
}

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

.topbar h2 {
  font-size: 28px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0;
}

.section-grid {
  display: grid;
  gap: 18px;
}

.overview-grid {
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
}

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

.panel,
.table-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.panel-header,
.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header.compact {
  margin-bottom: 14px;
}

.panel h3,
.section-title h3 {
  font-size: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.calm {
  color: var(--green);
  background: #e5f3ed;
}

.status-pill.warning {
  color: var(--amber);
  background: #fff2d7;
}

.status-pill.hot,
.status-pill.rich {
  color: var(--red);
  background: #fae7e7;
}

.status-pill.review {
  color: var(--blue);
  background: #e1edf5;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.panel-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.metric-row div,
.discipline-grid div,
.source-grid div,
.rule-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.metric-row div {
  padding: 13px;
}

.metric-row span,
.cash-cost span,
.rule-list span,
.discipline-grid span,
.source-grid span,
.macro-number span {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.metric-row strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.allocation-wrap {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.allocation-list {
  display: grid;
  gap: 9px;
}

.allocation-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.cash-cost {
  margin: 8px 0 18px;
}

.cash-cost strong {
  display: block;
  font-size: 30px;
}

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

.rule-list div,
.discipline-grid div,
.source-grid div {
  padding: 12px;
}

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

.theme-thesis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.theme-thesis div,
.china-sleeve-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.theme-thesis strong,
.theme-thesis span,
.china-sleeve-card strong,
.china-sleeve-card b,
.china-sleeve-card span {
  display: block;
}

.theme-thesis span,
.china-sleeve-card span {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.45;
}

.china-sleeve-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.china-sleeve-card {
  min-height: 132px;
}

.china-sleeve-card .swatch {
  display: block;
  margin-bottom: 10px;
}

.china-sleeve-card b {
  margin-top: 8px;
  font-size: 24px;
}

.playbook-section {
  display: grid;
  gap: 18px;
}

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

.playbook-card,
.bucket-plan div,
.playbook-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.playbook-card {
  padding: 14px;
}

.playbook-card strong,
.bucket-plan b,
.bucket-plan strong {
  display: block;
}

.playbook-card span,
.bucket-plan span {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 7px;
}

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

.bucket-plan div {
  padding: 14px;
}

.bucket-plan strong {
  margin-top: 8px;
  font-size: 24px;
}

.playbook-note {
  padding: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.field-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8e8;
  margin: 0 0 14px;
}

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

.valuation-method div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 13px;
}

.valuation-method b,
.valuation-method span {
  display: block;
}

.valuation-method b {
  margin-bottom: 6px;
}

.valuation-method span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.scenario-allocation {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 18px;
}

.anchor-chart-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.anchor-chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.anchor-chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.anchor-chart-header strong,
.anchor-chart-header span,
.anchor-chart-header b {
  display: block;
}

.anchor-chart-header span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.anchor-chart-header b {
  font-size: 20px;
}

.anchor-chart-card svg {
  display: block;
  width: 100%;
  height: auto;
}

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

.last-point {
  fill: var(--ink);
}

.watch-line,
.stress-line {
  stroke-width: 1.4;
  stroke-dasharray: 5 5;
}

.watch-line {
  stroke: var(--amber);
}

.stress-line {
  stroke: var(--red);
}

.axis-label,
.watch-text,
.stress-text {
  font-size: 10px;
  fill: var(--muted);
}

.watch-text {
  fill: var(--amber);
}

.stress-text {
  fill: var(--red);
}

.principles-section {
  display: grid;
  gap: 18px;
}

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

.principle-card,
.compound-demo {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.principle-card {
  padding: 16px;
}

.principle-card span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-weight: 800;
  margin-bottom: 12px;
}

.principle-card strong {
  display: block;
  line-height: 1.3;
}

.principle-card em,
.playbook-card em {
  display: block;
  margin-top: 8px;
  color: var(--blue);
  font-style: normal;
  font-weight: 700;
  line-height: 1.4;
}

.principle-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.compound-demo {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 16px;
}

.compound-demo h4 {
  margin: 0;
  font-size: 18px;
}

.compound-caption {
  display: block;
  margin-top: 6px;
  color: var(--blue);
  font-weight: 700;
  line-height: 1.4;
}

.compound-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.compound-row div {
  padding: 12px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
}

.compound-row b,
.compound-row span {
  display: block;
}

.compound-row span {
  margin-top: 4px;
  color: var(--muted);
}

.gauge {
  padding: 12px 0 14px;
}

.indicator-reading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 4px;
}

.indicator-reading span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.indicator-reading strong {
  display: block;
  margin-top: 4px;
  font-size: 34px;
}

.gauge-track {
  position: relative;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #dcefe6 0 38%, #fff1d1 38% 62%, #ffdcae 62% 82%, #f7d7d7 82% 100%);
}

.gauge-fill {
  height: 100%;
  background: rgba(23, 33, 38, 0.18);
}

.gauge-marker {
  position: absolute;
  top: -5px;
  width: 4px;
  height: 26px;
  background: var(--ink);
  border-radius: 3px;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.macro-number strong {
  display: block;
  font-size: 36px;
}

.indicator-guide {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.indicator-guide div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.indicator-guide b,
.indicator-guide span,
.indicator-note {
  display: block;
}

.indicator-guide b {
  font-size: 13px;
}

.indicator-guide span,
.indicator-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.indicator-note {
  margin-top: 12px;
}

.table-section {
  padding: 20px;
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

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

.field-guide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.field-guide div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.field-guide b,
.field-guide strong,
.field-guide span {
  display: block;
}

.field-guide b {
  color: var(--muted);
  font-size: 12px;
}

.field-guide strong {
  margin-top: 5px;
  font-size: 16px;
}

.field-guide span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

select,
input[type="search"] {
  min-height: 36px;
  padding: 0 10px;
}

input[type="search"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  margin-right: 5px;
}

.dot.review {
  background: var(--blue);
}

.dot.wait {
  background: var(--amber);
}

.dot.rich {
  background: var(--red);
}

.table-wrap {
  overflow-x: auto;
}

.compact-table-wrap table {
  min-width: 720px;
}

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

th,
td {
  padding: 13px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td strong {
  display: block;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.editable {
  width: 96px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.margin-bar {
  width: 150px;
  height: 8px;
  border-radius: 999px;
  background: #eef1f3;
  overflow: hidden;
  margin-top: 6px;
}

.margin-bar span {
  display: block;
  height: 100%;
  max-width: 100%;
}

.bar-review {
  background: var(--blue);
}

.bar-wait {
  background: var(--amber);
}

.bar-rich {
  background: var(--red);
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.tag.review {
  color: var(--blue);
  background: #e1edf5;
}

.tag.wait {
  color: var(--amber);
  background: #fff2d7;
}

.tag.rich {
  color: var(--red);
  background: #fae7e7;
}

.tag.neutral {
  color: var(--teal);
  background: #e2f1f3;
}

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

.alert-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: var(--surface-soft);
}

.alert-item strong {
  display: block;
}

.alert-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

/* Tablet: 2-column grids instead of jumping straight to 1 column */
@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .overview-grid {
    grid-template-columns: 1fr;
  }

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

  .playbook-grid,
  .bucket-plan,
  .principles-grid,
  .compound-row,
  .indicator-guide,
  .valuation-method,
  .theme-thesis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .compound-demo {
    grid-template-columns: 1fr;
  }

  .allocation-wrap {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

/* Mobile: further collapse to 1 column */
@media (max-width: 720px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .panel-header,
  .section-title {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar h2 {
    font-size: 22px;
  }

  .metric-row,
  .discipline-grid,
  .source-grid,
  .allocation-wrap,
  .macro-grid,
  .alerts-grid,
  .anchor-chart-grid,
  .theme-thesis,
  .indicator-guide,
  .valuation-method {
    grid-template-columns: 1fr;
  }

  .playbook-grid,
  .bucket-plan,
  .principles-grid,
  .compound-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }
}

/* Small mobile: single column everything, scrollable nav */
@media (max-width: 480px) {
  .main {
    padding: 12px;
  }

  .topbar h2 {
    font-size: 18px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 13px;
    padding: 9px 10px;
  }

  .playbook-grid,
  .bucket-plan,
  .principles-grid,
  .china-sleeve-grid,
  .compound-row {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
  }

  .toolbar label {
    width: 100%;
  }

  .toolbar select,
  .toolbar input[type="search"] {
    width: 100%;
  }

  .panel,
  .table-section {
    padding: 14px;
  }

  .panel h3,
  .section-title h3 {
    font-size: 16px;
  }
}
