:root {
  --page: #f5f7fa;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --cyan: #0891b2;
  --orange: #f59e0b;
  --purple: #7c3aed;
  --red: #dc2626;
  --green: #16a34a;
  --amber: #d97706;
  --radius: 14px;
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, rgba(37, 99, 235, 0.07), transparent 28rem),
    var(--page);
  font-variant-numeric: tabular-nums;
  font-size: clamp(13px, 0.35vw + 12px, 16px);
}

button,
select {
  font: inherit;
}

button,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}

.container {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
}

.site-header {
  height: 70px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.9);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  min-width: 42px;
  height: 38px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--blue);
  border-radius: 10px;
  padding: 0 7px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fafb;
}

.tab {
  border: 0;
  border-radius: 7px;
  padding: 7px 14px;
  color: var(--muted);
  background: transparent;
}

.tab.active {
  color: var(--blue);
  background: white;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.08);
  font-weight: 650;
}

.tab:disabled {
  opacity: 0.46;
}

.page {
  padding-top: 24px;
  padding-bottom: 28px;
}

.snapshot {
  display: grid;
  grid-template-columns: minmax(210px, 0.9fr) minmax(260px, 1fr) minmax(300px, 1.2fr);
  align-items: end;
  gap: 24px;
  padding: 20px 24px;
  margin-bottom: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.field-label,
.control label,
.control legend {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 7px;
}

.select {
  width: 100%;
  min-height: 40px;
  padding: 0 36px 0 12px;
  color: var(--text);
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 9px;
  outline: none;
}

.select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.index-point {
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1;
  letter-spacing: -0.035em;
}

.point-unit {
  margin-left: 3px;
  color: var(--muted);
  font-size: 14px;
}

.quote-meta {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.meta-pill {
  padding: 4px 8px;
  color: #1d4ed8;
  background: #eff6ff;
  border-radius: 999px;
  font-weight: 650;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status i {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
}

.status.delayed i {
  background: var(--amber);
}

.status.unsynced i,
.status.error i {
  background: var(--red);
}

.card {
  padding: 24px;
  margin-bottom: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.roll-card {
  border-top: 3px solid var(--blue);
}

.roll-card .roll-head h2 {
  font-size: clamp(22px, 1.2vw + 13px, 27px);
}

.roll-card .roll-head .subtitle {
  font-size: 14px;
}

.current-contracts {
  margin-bottom: 4px;
}

.compact-head {
  margin-bottom: 12px;
}

.section-divider {
  height: 1px;
  margin: 22px 0;
  background: var(--line);
}

.contracts-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.contracts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.contracts-mobile-list {
  display: none;
}

.contract-mobile-card {
  padding: 13px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
}

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

.contract-mobile-card dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
}

.contract-mobile-card dt {
  color: var(--muted);
  font-size: 10px;
}

.contract-mobile-card dd {
  margin: 3px 0 0;
  font-size: clamp(12px, 3.3vw, 14px);
}

.contracts-table th {
  padding: 10px 12px;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 650;
  text-align: right;
}

.contracts-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.contracts-table th:first-child,
.contracts-table td:first-child {
  text-align: left;
}

.contracts-table tbody tr:last-child td {
  border-bottom: 0;
}

.contract-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.contract-name i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

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

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

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 18px;
}

.card h1,
.card h2 {
  margin: 0;
  font-size: clamp(18px, 1vw + 12px, 21px);
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.legend {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.legend button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  color: #374151;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
}

.legend button:hover {
  background: #f3f4f6;
}

.legend button.off {
  opacity: 0.35;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.expiry-warning {
  padding: 1px 5px;
  color: #92400e;
  background: #fffbeb;
  border-radius: 999px;
  font-size: 9px;
}

.chart-wrap {
  position: relative;
  width: 100%;
}

.curve-wrap {
  height: 420px;
}

.chart {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  touch-action: pan-y;
}

.chart text {
  fill: var(--muted);
  font-family: inherit;
  font-size: 11px;
}

.chart .grid {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart .zero {
  stroke: #9ca3af;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.chart .series {
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart .hover-line {
  stroke: #9ca3af;
  stroke-width: 1;
  stroke-dasharray: 4 4;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.chart .hit-area {
  fill: transparent;
  cursor: crosshair;
}

.chart-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  z-index: 2;
}

.chart-tooltip {
  position: absolute;
  min-width: 164px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 8px 25px rgba(17, 24, 39, 0.13);
  pointer-events: none;
  z-index: 5;
  font-size: 12px;
}

.tooltip-date {
  margin-bottom: 6px;
  color: var(--muted);
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 4px;
}

.tooltip-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tooltip-name i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.chart-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.controls {
  display: flex;
  align-items: end;
  gap: 14px;
}

.control {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 168px;
}

.control legend {
  padding: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f9fafb;
}

.segmented button {
  min-width: 58px;
  height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.segmented button.active {
  color: white;
  background: var(--blue);
  font-weight: 650;
}

.roll-chart {
  display: grid;
  gap: 22px;
  min-height: 148px;
  padding: 12px 0 22px;
}

.roll-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(240px, 2.2fr) minmax(168px, 1fr);
  align-items: center;
  gap: 20px;
  padding: 4px 0;
}

.roll-target strong,
.roll-target span {
  display: block;
}

.roll-target strong {
  font-size: 17px;
}

.roll-mobile-value {
  display: none;
  color: var(--blue);
  font-size: 14px;
}

.roll-target span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.bar-track {
  height: 36px;
  position: relative;
  border-radius: 7px;
  background: #eff3f8;
  overflow: hidden;
}

.bar-zero {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #9ca3af;
  z-index: 2;
}

.bar {
  height: 100%;
  position: absolute;
  top: 0;
  display: flex;
  align-items: center;
  color: white;
  background: var(--blue);
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.bar.positive {
  justify-content: flex-end;
  padding-right: 9px;
}

.bar.negative {
  justify-content: flex-start;
  padding-left: 9px;
  background: var(--red);
}

.roll-history {
  font-size: 14px;
  line-height: 1.5;
}

.roll-history strong {
  color: var(--blue);
  font-size: 20px;
}

.roll-calculation {
  grid-column: 1 / -1;
  margin-top: -6px;
  color: var(--muted);
  font-size: 11px;
}

.roll-calculation summary {
  width: fit-content;
  color: var(--blue);
  cursor: pointer;
  user-select: none;
}

.roll-formula {
  margin: 10px 0 0;
  padding: 10px 12px;
  color: #1e3a8a;
  background: #eff6ff;
  border-radius: 8px;
  line-height: 1.65;
}

.roll-calculation-grid {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 7px 14px;
  margin-top: 10px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.roll-calculation-grid strong {
  color: var(--text);
  font-weight: 550;
  overflow-wrap: anywhere;
}

.roll-calculation-grid .roll-calculation-result {
  color: var(--blue);
  font-size: 15px;
  font-weight: 750;
}

.highest {
  display: inline-flex;
  width: auto;
  margin-left: 7px;
  padding: 2px 6px;
  color: #1d4ed8;
  background: #dbeafe;
  border-radius: 999px;
  font-size: 10px;
  vertical-align: 2px;
}

.reference {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 16px 18px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.reference-title {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.reference-values {
  display: flex;
  gap: 28px;
}

.reference-values div {
  text-align: center;
}

.reference-values span,
.reference-values strong {
  display: block;
}

.reference-values span {
  color: var(--muted);
  font-size: 11px;
}

.reference-values strong {
  margin-top: 2px;
  font-size: 15px;
}

.reference details {
  color: var(--muted);
  font-size: 11px;
  justify-self: end;
}

.reference summary {
  cursor: pointer;
}

.reference p {
  margin: 7px 0 0;
  max-width: 250px;
}

.empty-state {
  min-height: 148px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
}

.page-error {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px 14px;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  font-size: 13px;
}

.page-error button {
  margin-left: auto;
  padding: 5px 10px;
  color: #991b1b;
  background: white;
  border: 1px solid #fca5a5;
  border-radius: 7px;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 11px;
}

#feedback-contact {
  margin-right: auto;
  color: #374151;
}

#feedback-contact strong {
  color: var(--blue);
  font-size: 12px;
  user-select: all;
}

@media (max-width: 800px) {
  .container {
    width: min(100% - 32px, 1200px);
  }

  .site-header {
    height: 62px;
  }

  .brand small {
    display: none;
  }

  .brand strong {
    font-size: 14px;
  }

  .tabs .tab {
    padding: 6px 10px;
    font-size: 12px;
  }

  .snapshot {
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }

  .quote-meta {
    grid-column: 1 / -1;
    justify-content: flex-start;
    min-height: auto;
  }

  .card-head {
    display: block;
  }

  .legend {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .roll-head .controls {
    margin-top: 18px;
  }

  .curve-wrap {
    height: 300px;
  }

  .roll-row {
    grid-template-columns: minmax(120px, 0.85fr) minmax(190px, 1.5fr);
    gap: 12px 16px;
  }

  .roll-history {
    grid-column: 2;
  }

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

  .reference details {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 560px) {
  body {
    font-size: clamp(12px, 3.45vw, 14px);
    line-height: 1.45;
  }

  .container {
    width: calc(100% - 24px);
  }

  .header-inner {
    gap: 8px;
  }

  .brand-mark {
    min-width: 38px;
    height: 34px;
    border-radius: 9px;
  }

  .brand strong {
    max-width: 112px;
    line-height: 1.15;
  }

  .tabs {
    gap: 1px;
  }

  .tabs .tab:disabled {
    display: none;
  }

  .tabs .tab {
    padding: 6px 7px;
  }

  .page {
    padding-top: clamp(10px, 3.5vw, 14px);
    padding-bottom: clamp(18px, 5vw, 24px);
  }

  .snapshot,
  .card {
    padding: clamp(11px, 3.8vw, 16px);
    border-radius: 12px;
  }

  .snapshot {
    grid-template-columns: 1fr;
    gap: clamp(10px, 3.5vw, 14px);
    margin-bottom: clamp(12px, 4vw, 18px);
  }

  .quote-meta {
    grid-column: auto;
    gap: 6px 9px;
    font-size: clamp(11px, 3.2vw, 13px);
    line-height: 1.4;
  }

  .quote-meta .status {
    flex-basis: 100%;
  }

  .card h1,
  .card h2 {
    font-size: clamp(17px, 4.8vw, 19px);
    line-height: 1.3;
  }

  .roll-card .roll-head h2 {
    font-size: clamp(19px, 5.5vw, 22px);
    line-height: 1.3;
  }

  .roll-card .roll-head .subtitle {
    font-size: clamp(11px, 3.35vw, 13px);
    line-height: 1.45;
  }

  .curve-wrap {
    height: clamp(250px, 74vw, 290px);
    margin-left: -8px;
    width: calc(100% + 8px);
  }

  .contracts-table-wrap {
    display: none;
  }

  .contracts-mobile-list {
    display: grid;
    gap: clamp(7px, 2.7vw, 10px);
  }

  .contract-mobile-card {
    padding: clamp(10px, 3.3vw, 13px);
  }

  .contract-mobile-head {
    gap: 8px;
    margin-bottom: clamp(8px, 2.8vw, 12px);
    font-size: clamp(12px, 3.5vw, 14px);
    line-height: 1.3;
  }

  .contract-mobile-card dl {
    gap: clamp(7px, 2.8vw, 10px) clamp(8px, 3vw, 14px);
  }

  .contract-mobile-card dl > div {
    min-width: 0;
  }

  .contract-mobile-card dt,
  .contract-mobile-card dd {
    overflow-wrap: anywhere;
  }

  .contract-mobile-card dt {
    font-size: clamp(9px, 2.7vw, 10px);
    line-height: 1.3;
  }

  .contract-mobile-card dd {
    font-size: clamp(11px, 3.35vw, 14px);
    line-height: 1.3;
  }

  .roll-head .controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(9px, 3vw, 12px);
    margin-top: clamp(13px, 4vw, 18px);
  }

  .control {
    min-width: 0;
  }

  .roll-row {
    grid-template-columns: 1fr;
    gap: clamp(6px, 2.3vw, 9px);
    padding-bottom: clamp(12px, 4vw, 16px);
    border-bottom: 1px solid var(--line);
  }

  .roll-target {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 10px;
    line-height: 1.35;
  }

  .roll-target strong {
    min-width: 0;
    font-size: clamp(15px, 4.4vw, 17px);
  }

  .roll-target .highest {
    display: inline-flex;
    margin-left: 5px;
  }

  .roll-target > span {
    grid-column: 1 / -1;
  }

  .roll-mobile-value {
    display: block;
    font-size: clamp(16px, 5vw, 19px);
  }

  .roll-row:last-child {
    border-bottom: 0;
  }

  .roll-history {
    grid-column: auto;
  }

  .bar-track {
    height: clamp(30px, 9vw, 34px);
  }

  .bar {
    font-size: clamp(11px, 3.2vw, 14px);
  }

  .roll-history {
    font-size: clamp(12px, 3.45vw, 14px);
    line-height: 1.4;
  }

  .roll-history strong {
    font-size: clamp(17px, 5vw, 20px);
  }

  .roll-calculation {
    font-size: clamp(10px, 3vw, 11px);
    line-height: 1.5;
  }

  .roll-calculation-grid {
    grid-template-columns: clamp(62px, 20vw, 76px) minmax(0, 1fr);
    gap: 6px clamp(8px, 3vw, 14px);
    padding: clamp(9px, 3vw, 12px);
  }

  .reference {
    grid-template-columns: 1fr;
    gap: clamp(10px, 3.5vw, 14px);
    padding: clamp(12px, 4vw, 16px);
  }

  .reference-values {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    gap: clamp(5px, 2.3vw, 8px);
  }

  .reference-values strong {
    font-size: clamp(14px, 4vw, 16px);
  }

  .reference details {
    grid-column: auto;
  }

  footer {
    display: grid;
    gap: 3px;
    line-height: 1.35;
  }
}

@media (max-width: 359px) {
  .container {
    width: calc(100% - 16px);
  }

  .header-inner {
    gap: 5px;
  }

  .brand-mark {
    min-width: 34px;
    height: 32px;
    padding: 0 5px;
    font-size: 10px;
  }

  .brand strong {
    max-width: 102px;
    font-size: 12px;
  }

  .tabs .tab {
    padding: 5px 6px;
    font-size: 11px;
  }

  .snapshot,
  .card {
    padding: 10px;
  }

  .index-point {
    font-size: clamp(24px, 8vw, 27px);
  }

  .contract-mobile-card {
    padding: 11px;
  }

  .contract-mobile-card dl {
    gap: 7px 8px;
  }

  .curve-wrap {
    height: clamp(235px, 75vw, 270px);
  }

  .legend {
    gap: 3px 5px;
  }

  .legend button {
    gap: 5px;
    padding: 4px 5px;
    font-size: 10px;
  }

  .segmented button {
    min-width: 0;
    padding: 0 6px;
    font-size: 12px;
  }

  .roll-formula {
    padding: 8px 9px;
    line-height: 1.5;
  }
}
