:root {
  --bg: #0a0b0d;
  --bg-elevated: rgba(18, 20, 24, 0.72);
  --border: rgba(201, 169, 98, 0.18);
  --gold: #c9a962;
  --gold-soft: rgba(201, 169, 98, 0.12);
  --text: #f4f1ea;
  --warn: #e8b86d;
  --text-muted: rgba(244, 241, 234, 0.55);
  --profit: #6ecf9a;
  --loss: #e8847a;
  --neutral: rgba(244, 241, 234, 0.35);
  --radius: 18px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --font-display: "Songti SC", "STSong", serif;
  --font-body: "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}

.ambient-a {
  width: 42vw;
  height: 42vw;
  top: -12vw;
  right: -8vw;
  background: radial-gradient(circle, rgba(201, 169, 98, 0.16), transparent 70%);
}

.ambient-b {
  width: 36vw;
  height: 36vw;
  bottom: -10vw;
  left: -6vw;
  background: radial-gradient(circle, rgba(80, 110, 160, 0.12), transparent 70%);
}

.grain {
  position: fixed;
  inset: 0;
  opacity: 0.035;
  pointer-events: none;
  z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page {
  position: relative;
  z-index: 2;
  max-width: 1480px;
  margin: 0 auto;
  padding: 48px 24px 32px;
}

.hero {
  text-align: center;
  margin-bottom: 32px;
  animation: fadeUp 0.8s ease both;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.75rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.subtitle {
  margin: 14px 0 0;
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-muted);
}

.upload-section {
  max-width: 560px;
  margin: 0 auto 32px;
  animation: fadeUp 0.8s 0.12s ease both;
}

.upload-panel {
  padding: 0;
  overflow: hidden;
}

.upload-zone {
  padding: 48px 32px;
  text-align: center;
  border: 2px dashed rgba(201, 169, 98, 0.28);
  border-radius: var(--radius);
  margin: 4px;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: rgba(201, 169, 98, 0.55);
  background: rgba(201, 169, 98, 0.04);
}

.upload-zone.loading {
  pointer-events: none;
  opacity: 0.7;
}

.upload-icon {
  font-size: 2.4rem;
  margin-bottom: 16px;
  filter: grayscale(0.2);
}

.upload-zone h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 500;
}

.upload-desc {
  margin: 0 0 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.upload-btn {
  display: inline-block;
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(201, 169, 98, 0.9), rgba(201, 169, 98, 0.65));
  color: #0a0b0d;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.upload-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(201, 169, 98, 0.25);
}

.upload-btn:disabled {
  cursor: wait;
  opacity: 0.8;
}

.upload-hint {
  margin: 16px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.upload-status {
  margin: 0;
  padding: 14px 20px;
  font-size: 0.88rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.upload-status.success {
  color: var(--profit);
}

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

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: fadeUp 0.5s ease both;
}

.policy-section {
  margin-bottom: 48px;
  animation: fadeUp 0.6s ease both;
}

.section-heading,
.calculator-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 18px;
}

.section-heading h2,
.calculator-heading h2 {
  margin: 3px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  font-weight: 600;
}

.section-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
}

.data-badge {
  padding: 7px 12px;
  border: 1px solid rgba(201, 169, 98, 0.3);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.78rem;
  white-space: nowrap;
}

.table-tools {
  display: grid;
  grid-template-columns: minmax(220px, 420px) 180px;
  gap: 12px;
  margin-bottom: 12px;
}

.table-tools input,
.table-tools select {
  min-height: 44px;
  padding: 10px 14px;
}

.policy-table-wrap {
  position: relative;
  max-height: min(68vh, 760px);
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 14px;
}

.table-loading {
  padding: 72px 24px;
  text-align: center;
  color: var(--text-muted);
}

.policy-table {
  width: 100%;
  min-width: 1340px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.policy-table th,
.policy-table td {
  padding: 12px 13px;
  border-right: 1px solid rgba(255, 255, 255, 0.045);
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  white-space: nowrap;
}

.policy-table th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #1a1b1e;
  color: rgba(244, 241, 234, 0.72);
  text-align: right;
  font-weight: 500;
  box-shadow: 0 1px 0 rgba(201, 169, 98, 0.18);
}

.policy-table th:first-child,
.policy-table th:nth-child(2),
.policy-table td:first-child,
.policy-table td:nth-child(2) {
  text-align: left;
}

.policy-table th:first-child,
.policy-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 92px;
  min-width: 92px;
  background: #121316;
}

.policy-table th:nth-child(2),
.policy-table td:nth-child(2) {
  position: sticky;
  left: 92px;
  z-index: 3;
  width: 220px;
  min-width: 220px;
  background: #121316;
  box-shadow: 1px 0 0 rgba(201, 169, 98, 0.16);
}

.policy-table th:first-child,
.policy-table th:nth-child(2) {
  z-index: 6;
  background: #1a1b1e;
}

.policy-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.policy-table tbody tr:hover,
.policy-table tbody tr:focus,
.policy-table tbody tr.selected {
  outline: none;
  background: rgba(201, 169, 98, 0.09);
}

.policy-table tbody tr:hover td:first-child,
.policy-table tbody tr:hover td:nth-child(2),
.policy-table tbody tr:focus td:first-child,
.policy-table tbody tr:focus td:nth-child(2),
.policy-table tbody tr.selected td:first-child,
.policy-table tbody tr.selected td:nth-child(2) {
  background: #211f1b;
}

.policy-table tbody tr.selected td:first-child {
  box-shadow: inset 3px 0 var(--gold);
}

.model-cell {
  color: var(--text);
  font-weight: 500;
}

.category-cell {
  color: var(--gold);
}

.number-cell {
  text-align: right;
}

.period-2025 { background-color: rgba(119, 119, 119, 0.10); }
.period-jan { background-color: rgba(109, 141, 178, 0.08); }
.period-feb { background-color: rgba(201, 145, 96, 0.08); }
.period-current { background-color: rgba(227, 211, 63, 0.09); }

.policy-table th.period-current {
  color: #f0d77c;
}

.table-tip,
.empty-state {
  margin: 10px 2px 0;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.empty-state {
  padding: 24px;
  text-align: center;
}

.calculator-heading {
  display: block;
}

.toolbar-info {
  min-width: 0;
}

.toolbar-file {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-meta {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--profit);
}

.toolbar-error {
  margin: 0 0 20px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.88rem;
  background: rgba(232, 132, 122, 0.12);
  border: 1px solid rgba(232, 132, 122, 0.35);
  color: var(--loss);
  animation: fadeUp 0.4s ease both;
}

.upload-zone:focus-visible {
  outline: none;
  border-color: rgba(201, 169, 98, 0.55);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.toolbar-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border: 1px solid rgba(201, 169, 98, 0.35);
  border-radius: 8px;
  background: transparent;
  color: var(--gold);
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s;
}

.toolbar-btn:hover {
  background: rgba(201, 169, 98, 0.1);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  animation: fadeUp 0.8s 0.12s ease both;
}

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

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-index {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--gold);
  opacity: 0.7;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 500;
}

.field {
  margin-bottom: 20px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label,
.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.field-hint {
  margin: 8px 0 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.field-hint.warn,
.meta-value.warn {
  color: var(--warn);
}

.sync-row {
  margin-bottom: 16px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  width: auto;
  accent-color: var(--gold);
}

.input-narrow {
  max-width: 240px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.select-wrap,
.input-wrap {
  position: relative;
}

select,
input {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

select {
  padding: 14px 40px 14px 16px;
  cursor: pointer;
}

select option {
  background: #121418;
  color: var(--text);
}

select:focus,
input:focus {
  outline: none;
  border-color: rgba(201, 169, 98, 0.45);
  box-shadow: 0 0 0 3px var(--gold-soft);
  background: rgba(255, 255, 255, 0.05);
}

.input-wrap input {
  padding: 14px 16px 14px 36px;
}

.prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  font-weight: 500;
}

.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  pointer-events: none;
  font-size: 0.85rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.segmented button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}

.segmented button:hover {
  border-color: rgba(201, 169, 98, 0.3);
  color: var(--text);
}

.segmented button.active {
  background: linear-gradient(135deg, rgba(201, 169, 98, 0.22), rgba(201, 169, 98, 0.08));
  border-color: rgba(201, 169, 98, 0.5);
  color: var(--gold);
  box-shadow: inset 0 0 20px rgba(201, 169, 98, 0.08);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: -4px 0 20px;
}

.meta-item {
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.meta-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.meta-value {
  font-size: 1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.result-cards {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.result-card {
  padding: 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  transition: transform 0.25s, border-color 0.25s;
}

.result-card.highlight {
  transform: translateY(-2px);
}

.result-card.profit {
  border-color: rgba(110, 207, 154, 0.35);
  box-shadow: 0 0 40px rgba(110, 207, 154, 0.08);
}

.result-card.loss {
  border-color: rgba(232, 132, 122, 0.35);
  box-shadow: 0 0 40px rgba(232, 132, 122, 0.08);
}

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.result-tag {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.result-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.result-label {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.result-value.profit {
  color: var(--profit);
}

.result-value.loss {
  color: var(--loss);
}

.result-value.neutral {
  color: var(--neutral);
}

.result-detail {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.88rem;
  color: var(--text-muted);
}

.result-detail strong {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.formula-note {
  padding: 16px 18px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.formula-note p {
  margin: 0 0 6px;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.formula-tip {
  margin-top: 10px !important;
  color: var(--gold) !important;
  opacity: 0.85;
}

.footer {
  margin-top: 32px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  animation: fadeUp 0.8s 0.2s ease both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

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

  .field-row,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .page {
    padding-top: 32px;
  }

  .table-tools {
    grid-template-columns: 1fr;
  }

  .policy-table-wrap {
    max-height: 64vh;
  }
}
