:root {
  --bg: #faf8f3;
  --surface: #ffffff;
  --surface-alt: #f3efe6;
  --text: #1c2430;
  --text-muted: #5a6577;
  --primary: #1f4e79;
  --primary-light: #e8f0f8;
  --up: #1a7f4b;
  --up-bg: #e7f6ed;
  --down: #b42318;
  --down-bg: #fdeceb;
  --accent: #b76e14;
  --border: #e3decb;
  --border-strong: #cdc5ad;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* Sticky Top Header & Controls */
#top {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 248, 243, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-strong);
  box-shadow: 0 2px 8px rgba(28, 36, 48, 0.06);
  padding: 6px 12px;
}

.header-inner {
  max-width: 760px;
  margin: 0 auto;
}

.brand-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 5px;
}

.site-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.site-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ctl-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

#ctl-years {
  flex-wrap: nowrap;
}

.ctl-row-sub {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px;
}

.basis-short {
  display: none;
}

.controls button,
.sort-bar button,
.btn-more {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  min-height: 28px;
  padding: 3px 7px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.2;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}

#ctl-years button {
  flex: 1 1 0;
  padding: 4px 4px;
  min-width: 0;
  font-size: 13px;
  white-space: nowrap;
}

.controls button.on,
.sort-bar button.on {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 600;
}

.controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Main container */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 14px 32px;
}

@media (min-width: 900px) {
  .header-inner,
  .container {
    max-width: 880px;
  }
}

.chapter {
  padding: 18px 0 22px;
  border-bottom: 1px solid var(--border);
}

.chapter:last-child {
  border-bottom: none;
}

.chapter h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.ch-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.period-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 10px;
}

.ch-lead {
  font-size: 15px;
  color: var(--text);
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--surface-alt);
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
}

/* Highlights list */
.highlights-list {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 17px;
  line-height: 1.65;
}

.highlights-list li {
  margin-bottom: 10px;
}

.highlights-list li strong {
  color: #111827;
  font-weight: 650;
}

/* KPI Cards Grid (2x2 on mobile, 4x1 on wide screen) */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 900px) {
  .cards-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.card-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.25;
  margin-bottom: 4px;
  word-break: break-word;
}

.card-sub {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 4px;
}

.card-foot {
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 4px;
}

/* Chart & Panel Boxes */
.chart-box,
.panel-box,
.co-detail-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
  min-width: 0;
}

.box-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

.box-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.chart-foot {
  font-size: 13px;
  color: var(--text);
  margin: 6px 0 0;
}

.svg-chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

/* Scope Note */
.scope-note {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
}

.scope-note p {
  margin: 0 0 6px;
}

.scope-note p:last-child {
  margin-bottom: 0;
  color: var(--text-muted);
}

/* Competition List */
.sort-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.co-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.co-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}

.co-row.active {
  border-color: var(--primary);
  background: #f5f9fd;
}

.co-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.co-rank-name {
  font-weight: 600;
  font-size: 14.5px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.co-rank {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 18px;
}

.co-share-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  flex-shrink: 0;
}

.co-share-val {
  font-weight: 700;
  color: var(--primary);
}

.pp-tag {
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}

.pp-up {
  color: var(--up);
  background: var(--up-bg);
}

.pp-down {
  color: var(--down);
  background: var(--down-bg);
}

.pp-flat {
  color: var(--text-muted);
  background: var(--surface-alt);
}

.co-bar-track {
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 5px;
}

.co-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}

.co-row-bottom {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.more-wrap {
  margin-bottom: 12px;
  text-align: center;
}

.btn-more {
  width: 100%;
  padding: 7px 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--surface);
}

/* Company Detail Mini-charts */
.detail-header {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.detail-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 2px;
}

.detail-cnsf {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.detail-note {
  font-size: 12.5px;
  color: var(--accent);
  background: #fef7ec;
  border: 1px solid #f5dab2;
  border-radius: 6px;
  padding: 5px 8px;
  margin: 6px 0 0;
}

.mini-charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 600px) {
  .mini-charts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.mini-chart-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: #fdfcf9;
}

.mini-chart-card.wide {
  grid-column: 1 / -1;
}

.mini-title {
  font-size: 12.5px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text);
}

/* Profit Chapter Elements */
.notice-banner {
  background: #fef7ec;
  border: 1px solid #f2d0a0;
  color: #7c4a0d;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  margin: 0 0 12px;
}

.co-profit-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.co-profit-row:last-child {
  border-bottom: none;
}

.co-profit-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13.5px;
  margin-bottom: 4px;
}

.ratio-bar-wrap {
  position: relative;
  height: 10px;
  background: var(--surface-alt);
  border-radius: 4px;
  margin: 4px 0 6px;
  overflow: hidden;
}

.ratio-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
}

.ratio-bar-fill.over100 {
  background: var(--down);
}

.ratio-ref-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #111827;
  z-index: 2;
}

.tag-badge {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  margin-right: 4px;
}

.tag-warn {
  background: var(--down-bg);
  color: var(--down);
}

.tag-info {
  background: var(--primary-light);
  color: var(--primary);
}

/* Report Compare Cards */
.rc-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 10px;
  background: #fdfcf9;
  overflow: hidden;
}

.rc-card.current {
  border-color: var(--primary);
  background: #f6fafe;
}

.rc-period-head {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}

.rc-period-head::-webkit-details-marker {
  display: none;
}

.rc-period-head::marker {
  content: "";
}

.rc-period-head::after {
  content: "\25B8";
  flex-shrink: 0;
  font-weight: 400;
  line-height: 1.2;
}

.rc-card[open] .rc-period-head::after {
  content: "\25BE";
}

.rc-card[open] .rc-period-head {
  border-bottom: 1px dashed var(--border);
}

.rc-period-body {
  padding: 0 10px 10px;
}

.rc-current-line {
  margin: 8px 0 0;
}

.rc-group-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  margin: 8px 0 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.rc-group-title:first-of-type {
  border-top: none;
  padding-top: 0;
}

.rc-line {
  font-size: 12.5px;
  padding: 2px 0;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px;
}

.rc-official-line {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dotted var(--border);
}

/* Structure Chapter Elements */
.stacked-bar {
  display: flex;
  height: 16px;
  border-radius: 6px;
  overflow: hidden;
  margin: 8px 0 12px;
  background: var(--surface-alt);
}

.stacked-seg {
  height: 100%;
}

.line-row,
.kv-row {
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.line-row:last-child,
.kv-row:last-child {
  border-bottom: none;
}

.line-row-top,
.kv-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  font-weight: 600;
}

.line-row-sub,
.kv-row-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dual-bars {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.dual-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  margin-bottom: 5px;
}

.dual-bar-label {
  width: 130px;
  flex-shrink: 0;
}

.dual-bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
}

.dual-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
}

.sesa-subhead {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary);
  margin: 12px 0 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.foot {
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0 0;
  line-height: 1.5;
}

/* Site Footer */
@media (max-width: 560px) {
  .site-sub {
    display: none;
  }

  .basis-long {
    display: none;
  }

  .basis-short {
    display: inline;
  }
}

#site-foot {
  background: var(--surface-alt);
  border-top: 1px solid var(--border-strong);
  font-size: 12.5px;
  color: var(--text-muted);
}

.foot-inner {
  padding-top: 18px;
  padding-bottom: 28px;
}

.foot-title {
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}

.foot-sources {
  margin: 6px 0 10px;
  padding-left: 18px;
}

.foot-sources li {
  margin-bottom: 3px;
}
