:root {
  --mc-card-bg: linear-gradient(165deg, rgba(27, 32, 40, 0.96), rgba(16, 19, 24, 0.96));
  --mc-card-border: rgba(255, 255, 255, 0.06);
  --mc-card-shadow: 0 14px 32px rgba(0, 0, 0, 0.38);
  --mc-card-glow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

body.light {
  --mc-card-bg: linear-gradient(180deg, #ffffff, #f8fafc);
  --mc-card-border: #e5e7eb;
  --mc-card-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  --mc-card-glow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

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

.funding-mobile-empty {
  border: 1px dashed var(--border, #2b313a);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  text-align: center;
}

@media (max-width: 991.98px) {
  .funding-mobile-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .funding-mobile-card {
    border: 1px solid var(--mc-card-border);
    border-radius: 14px;
    background: var(--mc-card-bg);
    box-shadow: var(--mc-card-shadow), var(--mc-card-glow);
    padding: 10px;
  }

  .funding-mobile-card.token-group-row {
    background: var(--mc-card-bg);
  }

  .funding-mobile-card.token-group-row.is-collapsed {
    display: none;
  }

  .mobile-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .mobile-token-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .mobile-card-badges {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    flex: 0 0 auto;
    min-width: 0;
  }

  .mobile-card-badges .mobile-chip-apr {
    margin-left: auto;
  }

  .mobile-card-badges .mobile-chip-row {
    margin-top: 0;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 4px;
  }

  .mobile-card-badges .mobile-chip {
    white-space: nowrap;
  }

  .mobile-token-cell a,
  .mobile-token-cell .token-label {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #2f8cff;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
  }

  body.dark .mobile-token-cell a,
  body.dark .mobile-token-cell .token-label {
    color: #64b5ff;
  }

  .mobile-token-cell a:hover {
    text-decoration: underline;
  }

  .mobile-token-cell .group-toggle {
    min-width: 46px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.03);
  }

  .mobile-chip-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
  }

  .mobile-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid var(--border, #2b313a);
    background: rgba(255, 255, 255, 0.02);
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
  }

  .mobile-chip-apr {
    font-size: 12px;
    border: none;
    white-space: nowrap;
    font-weight: 800;
    letter-spacing: 0.01em;
  }

  .mobile-chip-open {
    font-weight: 700;
  }

  .mobile-exchange-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
  }

  .mobile-exchange-line {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border, #2b313a);
    border-radius: 10px;
    padding: 7px 8px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
  }

  body.light .mobile-exchange-line {
    background: #f8fafc;
  }

  .mobile-exchange-name {
    display: flex;
    align-items: center;
    width: auto;
    max-width: 112px;
    border-radius: 999px;
    padding: 2px 7px;
    border: 1px solid var(--border, #2b313a);
    flex: 0 1 auto;
    min-width: 0;
  }

  .mobile-exchange-name a {
    min-width: unset;
    max-width: 100%;
    display: flex !important;
    align-items: center;
    gap: 6px !important;
  }

  .mobile-exchange-name span {
    display: inline-block;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
  }

  .mobile-exchange-name.bg-long,
  .mobile-exchange-name.bg-short {
    background: rgba(255, 255, 255, 0.01);
  }

  .mobile-exchange-name.bg-long {
    border-left: 2px solid #22c55e;
  }

  .mobile-exchange-name.bg-short {
    border-left: 2px solid #ef4444;
  }

  .mobile-exchange-price {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--muted, #a0a6b2);
    text-align: left;
    white-space: nowrap;
    margin-left: 4px;
    margin-right: auto;
    min-width: 0;
    line-height: 1.15;
    flex: 0 0 auto;
  }

  .mobile-exchange-funding {
    width: auto;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
    flex: 0 0 auto;
  }

  .mobile-funding-rate-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .mobile-exchange-funding .fund-rate {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.1;
    min-width: 0;
    text-align: right;
    white-space: nowrap;
  }

  .mobile-exchange-funding .fund-interval {
    font-size: 10px;
    padding: 2px 5px;
    line-height: 1;
    flex: 0 0 auto;
  }

  .mobile-exchange-funding .timer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto !important;
    max-width: 100%;
    text-align: center;
    font-size: 11px;
    min-width: 58px;
    line-height: 1.1;
    border: 1px solid var(--border, #2b313a);
    border-radius: 999px;
    padding: 2px 6px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: rgba(255, 255, 255, 0.02);
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .mobile-exchange-funding .timer.is-empty {
    color: var(--muted, #a0a6b2);
    font-weight: 500;
  }

  .mobile-details {
    margin-top: 8px;
    border-top: 1px dashed var(--border, #2b313a);
    padding-top: 8px;
  }

  .mobile-details > summary {
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted, #a0a6b2);
    list-style: none;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 0;
  }

  .mobile-details > summary::after {
    content: "▾";
    font-size: 11px;
    line-height: 1;
    transition: transform 0.16s ease;
  }

  .mobile-details[open] > summary::after {
    transform: rotate(180deg);
  }

  .mobile-details > summary::-webkit-details-marker {
    display: none;
  }

  .mobile-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
  }

  .mobile-details-grid > div {
    min-width: 0;
  }

  .mobile-details-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted, #a0a6b2);
    margin-bottom: 4px;
  }

  .mobile-fh24-cell a.fh24-link {
    line-height: 1.45;
    font-size: 12px;
    font-weight: 500;
    color: inherit;
    opacity: 0.88;
  }

  .mobile-volume-col .vol-line {
    line-height: 1.45;
    font-size: 12px;
  }

  .mobile-spark {
    width: 100%;
    min-height: 22px;
  }

  .mobile-spark svg {
    width: 100%;
    height: 24px;
    display: block;
  }

  body.dark .mobile-chip {
    background: rgba(255, 255, 255, 0.04);
    border-color: #2f3846;
  }
}

@media (max-width: 991.98px) {
  body.table-mobile-ref .funding-mobile-list {
    gap: 8px;
  }

  body.table-mobile-ref .funding-mobile-card {
    padding: 8px;
    border-radius: 12px;
  }

  body.table-mobile-ref .mobile-card-top {
    gap: 6px;
  }

  body.table-mobile-ref .mobile-chip-row {
    margin-top: 4px;
    gap: 5px;
  }

  body.table-mobile-ref .mobile-chip {
    padding: 2px 7px;
    font-size: 10.5px;
  }

  body.table-mobile-ref .mobile-exchange-list {
    margin-top: 6px;
    gap: 6px;
  }

  body.table-mobile-ref .mobile-exchange-line {
    padding: 6px 7px;
  }

  body.table-mobile-ref .mobile-details summary {
    padding: 6px 0 0;
    font-size: 12px;
  }
}

/* Unified dark desktop table frame for all spread tables */
@media (min-width: 901px) {
  html[data-theme="dark"] body.table-mobile-ref .table-wrapper,
  body.table-mobile-ref.dark .table-wrapper {
    border: 1px solid #2a2a2a !important;
    border-radius: 14px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }

  html[data-theme="dark"] body.table-mobile-ref .table-wrapper > table,
  body.table-mobile-ref.dark .table-wrapper > table {
    border: 1px solid #2a2a2a !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
  }

  html[data-theme="dark"] body.table-mobile-ref .table-wrapper > table thead th:first-child,
  body.table-mobile-ref.dark .table-wrapper > table thead th:first-child {
    border-top-left-radius: 12px !important;
  }

  html[data-theme="dark"] body.table-mobile-ref .table-wrapper > table thead th:last-child,
  body.table-mobile-ref.dark .table-wrapper > table thead th:last-child {
    border-top-right-radius: 12px !important;
  }

  html[data-theme="dark"] body.table-mobile-ref .table-wrapper > table tbody tr:last-child td:first-child,
  body.table-mobile-ref.dark .table-wrapper > table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 12px !important;
  }

  html[data-theme="dark"] body.table-mobile-ref .table-wrapper > table tbody tr:last-child td:last-child,
  body.table-mobile-ref.dark .table-wrapper > table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 12px !important;
  }
}

/* Unified interval chips for mobile table cards */
.mobile-exchange-funding .fund-interval,
body.table-mobile-ref .fund-interval {
  box-sizing: border-box !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 28px !important;
  padding: 1px 5px !important;
  border-radius: 5px !important;
  border: 1px solid var(--interval-border, rgba(148, 163, 184, .28)) !important;
  background: var(--interval-bg, rgba(148, 163, 184, .14)) !important;
  color: var(--interval-fg, #cbd5e1) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 1.15 !important;
  text-align: center !important;
}

.mobile-exchange-funding .fund-interval.is-empty,
body.table-mobile-ref .fund-interval.is-empty {
  background: transparent !important;
  color: var(--muted) !important;
  border: 0 !important;
  padding: 0 !important;
  min-width: 0 !important;
}

.mobile-exchange-funding .interval-1h,
body.table-mobile-ref .interval-1h { --interval-bg: rgba(134, 239, 172, .18); --interval-border: rgba(134, 239, 172, .34); --interval-fg: #bbf7d0; }
.mobile-exchange-funding .interval-2h,
body.table-mobile-ref .interval-2h { --interval-bg: rgba(59, 130, 246, .14); --interval-border: rgba(59, 130, 246, .26); --interval-fg: #93c5fd; }
.mobile-exchange-funding .interval-3h,
body.table-mobile-ref .interval-3h { --interval-bg: rgba(132, 204, 22, .14); --interval-border: rgba(132, 204, 22, .26); --interval-fg: #bef264; }
.mobile-exchange-funding .interval-4h,
body.table-mobile-ref .interval-4h { --interval-bg: rgba(4, 120, 87, .22); --interval-border: rgba(4, 120, 87, .38); --interval-fg: #34d399; }
.mobile-exchange-funding .interval-6h,
body.table-mobile-ref .interval-6h { --interval-bg: rgba(234, 179, 8, .14); --interval-border: rgba(234, 179, 8, .28); --interval-fg: #fde68a; }
.mobile-exchange-funding .interval-8h,
body.table-mobile-ref .interval-8h { --interval-bg: rgba(249, 115, 22, .14); --interval-border: rgba(249, 115, 22, .28); --interval-fg: #fdba74; }
.mobile-exchange-funding .interval-default,
body.table-mobile-ref .interval-default { --interval-bg: rgba(148, 163, 184, .14); --interval-border: rgba(148, 163, 184, .26); --interval-fg: #cbd5e1; }

body.light .mobile-exchange-funding .interval-1h,
body[data-theme="light"] .mobile-exchange-funding .interval-1h,
html[data-theme="light"] body .mobile-exchange-funding .interval-1h,
body.light.table-mobile-ref .interval-1h,
body.table-mobile-ref[data-theme="light"] .interval-1h,
html[data-theme="light"] body.table-mobile-ref .interval-1h { --interval-bg: rgba(187, 247, 208, .55); --interval-border: rgba(74, 222, 128, .34); --interval-fg: #16a34a; }
body.light .mobile-exchange-funding .interval-2h,
body[data-theme="light"] .mobile-exchange-funding .interval-2h,
html[data-theme="light"] body .mobile-exchange-funding .interval-2h,
body.light.table-mobile-ref .interval-2h,
body.table-mobile-ref[data-theme="light"] .interval-2h,
html[data-theme="light"] body.table-mobile-ref .interval-2h { --interval-bg: rgba(37, 99, 235, .10); --interval-border: rgba(37, 99, 235, .20); --interval-fg: #2563eb; }
body.light .mobile-exchange-funding .interval-3h,
body[data-theme="light"] .mobile-exchange-funding .interval-3h,
html[data-theme="light"] body .mobile-exchange-funding .interval-3h,
body.light.table-mobile-ref .interval-3h,
body.table-mobile-ref[data-theme="light"] .interval-3h,
html[data-theme="light"] body.table-mobile-ref .interval-3h { --interval-bg: rgba(101, 163, 13, .10); --interval-border: rgba(101, 163, 13, .22); --interval-fg: #4d7c0f; }
body.light .mobile-exchange-funding .interval-4h,
body[data-theme="light"] .mobile-exchange-funding .interval-4h,
html[data-theme="light"] body .mobile-exchange-funding .interval-4h,
body.light.table-mobile-ref .interval-4h,
body.table-mobile-ref[data-theme="light"] .interval-4h,
html[data-theme="light"] body.table-mobile-ref .interval-4h { --interval-bg: rgba(4, 120, 87, .16); --interval-border: rgba(4, 120, 87, .28); --interval-fg: #065f46; }
body.light .mobile-exchange-funding .interval-6h,
body[data-theme="light"] .mobile-exchange-funding .interval-6h,
html[data-theme="light"] body .mobile-exchange-funding .interval-6h,
body.light.table-mobile-ref .interval-6h,
body.table-mobile-ref[data-theme="light"] .interval-6h,
html[data-theme="light"] body.table-mobile-ref .interval-6h { --interval-bg: rgba(202, 138, 4, .12); --interval-border: rgba(202, 138, 4, .22); --interval-fg: #a16207; }
body.light .mobile-exchange-funding .interval-8h,
body[data-theme="light"] .mobile-exchange-funding .interval-8h,
html[data-theme="light"] body .mobile-exchange-funding .interval-8h,
body.light.table-mobile-ref .interval-8h,
body.table-mobile-ref[data-theme="light"] .interval-8h,
html[data-theme="light"] body.table-mobile-ref .interval-8h { --interval-bg: rgba(234, 88, 12, .10); --interval-border: rgba(234, 88, 12, .22); --interval-fg: #c2410c; }
body.light .mobile-exchange-funding .interval-default,
body[data-theme="light"] .mobile-exchange-funding .interval-default,
html[data-theme="light"] body .mobile-exchange-funding .interval-default,
body.light.table-mobile-ref .interval-default,
body.table-mobile-ref[data-theme="light"] .interval-default,
html[data-theme="light"] body.table-mobile-ref .interval-default { --interval-bg: rgba(100, 116, 139, .10); --interval-border: rgba(100, 116, 139, .20); --interval-fg: #475569; }
