/* XAUUSD spread comparison — panel table UI + history chart.
   Scoped under .xsc-panel / .xsc-chart. SWELL theme unchanged outside. */

/* ---- Panel shell ---- */
.xsc-panel {
  background: #fff;
  border: 1px solid rgba(15, 26, 46, 0.1);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 26, 46, 0.08);
  margin: 1.25rem 0 1.75rem;
  overflow: hidden;
  padding: 0;
}

.xsc-panel__head {
  align-items: flex-start;
  background: linear-gradient(135deg, #fffaf0 0%, #fff 100%);
  border-bottom: 1px solid rgba(184, 137, 45, 0.22);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
  padding: 16px 20px;
}

.xsc-panel__head-text {
  margin: 0;
  min-width: 0;
}

/* Beat SWELL theme h3 margins (.post_content h3 etc.) */
.xsc-panel h3.xsc-panel__title,
.xsc-panel .xsc-panel__title {
  color: #0f1a2e;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.3;
  margin: 0 !important;
  padding: 0;
}

.xsc-panel .xsc-panel__lead {
  color: #4b5563;
  font-size: 14px;
  line-height: 1.5;
  margin: 6px 0 0;
}

.xsc-panel .xsc-panel__updated {
  color: #6b7280;
  font-size: 12px;
  font-weight: 650;
  margin: 0;
  white-space: nowrap;
}

/* ---- Toolbar ---- */
.xsc-toolbar {
  align-items: flex-end;
  background: #f8fafc;
  border-bottom: 1px solid rgba(15, 26, 46, 0.08);
  display: none;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding: 14px 20px;
}

.xsc-toolbar.is-ready {
  display: flex;
}

.xsc-toolbar__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.xsc-toolbar__group--search {
  flex: 1 1 180px;
  min-width: 160px;
}

.xsc-toolbar__row {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: nowrap;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.xsc-toolbar__row .xsc-toolbar__group {
  flex: 1 1 0;
  min-width: 0;
}

.xsc-toolbar__row .xsc-select {
  min-width: 0;
  width: 100%;
}

.xsc-toolbar__label {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.xsc-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.xsc-seg__btn,
.xsc-mode__btn {
  appearance: none;
  -webkit-appearance: none;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #334155;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  padding: 7px 12px;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.xsc-seg__btn.is-active,
.xsc-mode__btn.is-active {
  background: #1e3a8a;
  border-color: #1e3a8a;
  color: #fff;
}

.xsc-seg__btn:focus-visible,
.xsc-mode__btn:focus-visible,
.xsc-select:focus-visible,
.xsc-search:focus-visible,
.xsc-lot-custom:focus-visible {
  outline: 2px solid #b8892d;
  outline-offset: 2px;
}

.xsc-select,
.xsc-search,
.xsc-lot-custom {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-sizing: border-box;
  color: #0f1a2e;
  font-size: 14px;
  line-height: 1.4;
  min-height: 38px;
  padding: 8px 12px;
}

.xsc-select {
  min-width: 160px;
}

.xsc-search {
  width: 100%;
}

.xsc-lot-custom {
  margin-top: 4px;
  max-width: 120px;
}

.xsc-lot-custom[hidden] {
  display: none !important;
}

/* ---- Summary cards ---- */
.xsc-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 16px 20px 8px;
}

.xsc-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  position: relative;
}

.xsc-card--cheap {
  border-color: rgba(21, 128, 61, 0.28);
  background: linear-gradient(180deg, #f0fdf4 0%, #fff 70%);
}

.xsc-card--spread {
  border-color: rgba(37, 99, 235, 0.28);
  background: linear-gradient(180deg, #eff6ff 0%, #fff 70%);
}

.xsc-card--median {
  border-color: rgba(124, 58, 237, 0.22);
  background: linear-gradient(180deg, #f5f3ff 0%, #fff 70%);
}

.xsc-card__label {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.xsc-card__value {
  color: #0f1a2e;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}

.xsc-card__meta {
  color: #475569;
  font-size: 13px;
  font-weight: 650;
  margin: 6px 0 0;
}

/* ---- Table ---- */
.xsc-table-wrap {
  overflow-x: auto;
  padding: 8px 12px 4px;
}

/* Reset SWELL post-table borders (separate + white th borders break column lines). */
.xsc-panel table.xsc-table {
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: fixed;
  width: 100%;
}

.xsc-panel table.xsc-table th,
.xsc-panel table.xsc-table td {
  border: 0;
  border-bottom: 1px solid #e2e8f0;
  box-sizing: border-box;
  vertical-align: middle;
}

.xsc-panel table.xsc-table thead th {
  background: #0f1a2e;
  border-bottom-color: #0f1a2e;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.xsc-panel table.xsc-table tbody td {
  background: #fff;
  border-bottom-color: #f1f5f9;
  color: #0f1a2e;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  padding: 12px;
}

.xsc-panel table.xsc-table tbody tr:hover td {
  background: #f8fafc;
}

/* Desktop: hide SP-only breaks (fallback if theme rule is missing). */
.xsc-panel br.sp_ {
  display: none;
}

.xsc-table tbody tr[hidden] {
  display: none;
}

.xsc-broker {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.xsc-logo {
  border-radius: 6px;
  flex-shrink: 0;
  height: 28px;
  object-fit: contain;
  width: 28px;
}

.xsc-logo--text {
  align-items: center;
  background: #e2e8f0;
  color: #334155;
  display: inline-flex;
  font-size: 10px;
  font-weight: 800;
  justify-content: center;
  letter-spacing: 0.04em;
}

.xsc-label {
  font-weight: 700;
  line-height: 1.35;
}

.xsc-total-cell {
  width: 18%;
}

.xsc-avg,
.xsc-comm {
  white-space: nowrap;
}

.xsc-total {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
}

.xsc-bar {
  background: #e2e8f0;
  border-radius: 999px;
  container-type: inline-size;
  display: block;
  height: 6px;
  overflow: hidden;
  width: 100%;
}

/* Gradient is sized to the full track; fill width reveals the low→high scale. */
.xsc-bar__fill {
  background-color: #16a34a;
  background-image: linear-gradient(90deg, #16a34a 0%, #eab308 55%, #dc2626 100%);
  background-repeat: no-repeat;
  background-size: 100cqw 100%;
  border-radius: 999px;
  display: block;
  height: 100%;
  max-width: 100%;
  transition: width 0.2s ease;
}

.xsc-filter-empty {
  color: #9ca3af;
  font-size: 14px;
  margin: 12px;
  text-align: center;
}

.xsc-asof-line {
  border-top: 1px solid rgba(15, 26, 46, 0.08);
  color: #6b7280;
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  padding: 12px 20px 16px;
}

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

/* ---- History chart (unchanged structure) ---- */
.xsc-chart {
  background-color: #f6f6f6;
  border-radius: 8px;
  box-sizing: border-box;
  margin: 1em 0;
  padding: 0.75rem 1rem;
}

.xsc-chart__head {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.xsc-chart__title {
  color: #1f2937;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
}

.xsc-chart__brokers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 12px;
}

.xsc-chart__broker {
  align-items: center;
  color: #374151;
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  gap: 6px;
  user-select: none;
}

.xsc-chart__broker input {
  height: 0;
  opacity: 0;
  position: absolute;
  width: 0;
}

.xsc-chart__swatch {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  flex-shrink: 0;
  height: 14px;
  transition: opacity 0.2s;
  width: 14px;
}

.xsc-chart__broker input:not(:checked) + .xsc-chart__swatch {
  opacity: 0.25;
}

.xsc-chart__broker input:not(:checked) ~ .xsc-chart__broker-name {
  opacity: 0.45;
}

.xsc-chart__broker input:focus-visible + .xsc-chart__swatch {
  outline: 2px solid var(--color_main, #2f6fed);
  outline-offset: 2px;
}

.xsc-chart__canvas-wrap {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px 8px 4px;
}

.xsc-chart__canvas-wrap canvas {
  display: block;
  max-height: 420px;
  width: 100% !important;
}

.xsc-chart__foot {
  color: #6b7280;
  font-size: 13px;
  line-height: 1.45;
  margin: 10px 0 0;
}

.xsc-chart__note {
  color: #9ca3af;
  font-size: 12px;
  margin: 6px 0 0;
}

@media screen and (max-width: 768px) {
  .xsc-panel__head,
  .xsc-toolbar,
  .xsc-summary,
  .xsc-asof-line {
    padding-left: 14px;
    padding-right: 14px;
  }

  .xsc-summary {
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-top: 12px;
    padding-bottom: 6px;
  }

  .xsc-card {
    padding: 10px 6px;
  }

  .xsc-card__label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
  }

  .xsc-card__value {
    font-size: 0.95rem;
    letter-spacing: -0.02em;
  }

  .xsc-card__meta {
    font-size: 11px;
    line-height: 1.3;
    margin-top: 4px;
  }

  .xsc-toolbar__row {
    gap: 8px;
  }

  .xsc-toolbar__row .xsc-toolbar__label {
    font-size: 10px;
  }

  .xsc-toolbar__row .xsc-select {
    font-size: 13px;
    min-height: 36px;
    padding: 6px 8px;
  }

  .xsc-panel br.sp_ {
    display: inline;
  }

  .xsc-table {
    table-layout: fixed;
  }

  .xsc-panel table.xsc-table thead th {
    font-size: 10px;
    letter-spacing: 0.02em;
    line-height: 1.25;
    padding: 8px 4px;
    white-space: normal;
  }

  .xsc-panel table.xsc-table tbody td {
    font-size: 12px;
    padding: 8px 4px;
  }

  .xsc-panel table.xsc-table th:nth-child(1),
  .xsc-panel table.xsc-table td:nth-child(1) {
    width: 44%;
  }

  .xsc-panel table.xsc-table th:nth-child(2),
  .xsc-panel table.xsc-table td:nth-child(2),
  .xsc-panel table.xsc-table th:nth-child(3),
  .xsc-panel table.xsc-table td:nth-child(3) {
    width: 18%;
  }

  .xsc-panel table.xsc-table th:nth-child(4),
  .xsc-panel table.xsc-table td:nth-child(4) {
    width: 20%;
  }

  .xsc-broker {
    gap: 6px;
    min-width: 0;
  }

  .xsc-avg,
  .xsc-comm,
  .xsc-total {
    white-space: nowrap;
  }

  .xsc-total-cell {
    width: 20%;
  }

  .xsc-logo,
  .xsc-logo--text {
    height: 22px;
    width: 22px;
  }

  .xsc-label {
    font-size: 12px;
    line-height: 1.25;
    overflow-wrap: break-word;
    word-break: normal;
  }

  .xsc-table-wrap {
    padding: 4px 6px 0;
  }

  .xsc-chart {
    padding: 0.65rem 0.75rem;
  }

  .xsc-chart__title {
    font-size: 0.95rem;
  }

  .xsc-chart__brokers {
    gap: 6px 10px;
  }

  .xsc-chart__broker {
    font-size: 13px;
  }
}
