.modal,
.modal *,
.app-shell,
.app-shell * {
  box-sizing: border-box;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.input,
.toggle,
.calculator-card,
.strategy-card,
.modal-panel,
.tab-panel {
  min-width: 0;
}

.modal-panel,
.strategy-card,
.calculator-card,
.risk-copy,
.calculator-detail-body,
.calculator-step-footer,
.field,
.toggle,
pre,
td {
  overflow-wrap: anywhere;
}

.field {
  display: grid;
  gap: 0.45rem;
  color: #344054;
  font-size: 0.875rem;
  font-weight: 750;
}

.field.hidden {
  display: none;
}

.input {
  min-height: 2.75rem;
  width: 100%;
  border: 1px solid #d9e2ec;
  border-radius: 0.5rem;
  background: #fff;
  padding: 0.62rem 0.8rem;
  color: #101828;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.14);
}

.toggle {
  display: flex;
  min-height: 3rem;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid #d9e2ec;
  border-radius: 0.5rem;
  background: #f8fafc;
  padding: 0.72rem 0.85rem;
  color: #344054;
  font-size: 0.875rem;
  font-weight: 750;
}

.toggle input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: #10b981;
}

.toggle.compact {
  min-height: 2.4rem;
  padding: 0.45rem 0.7rem;
}

.strategy-form-stack {
  display: grid;
  gap: 1rem;
}

.form-section {
  display: grid;
  gap: 0.9rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #101828;
  font-size: 0.95rem;
  font-weight: 900;
}

.market-type-block {
  display: grid;
  gap: 0.65rem;
}

.market-type-title {
  color: #344054;
  font-size: 0.875rem;
  font-weight: 850;
}

.market-type-options {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

.market-type-option {
  cursor: pointer;
}

.market-type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.market-type-option span {
  display: grid;
  min-height: 4.25rem;
  gap: 0.25rem;
  border: 1px solid #d9e2ec;
  border-radius: 0.65rem;
  background: #f8fafc;
  padding: 0.9rem 1rem;
  color: #344054;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease, transform 160ms ease;
}

.market-type-option strong {
  color: #101828;
  font-size: 1rem;
  font-weight: 950;
}

.market-type-option small {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 750;
}

.market-type-option input:checked + span {
  border-color: #10b981;
  background: #ecfdf5;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

.market-type-option input:focus-visible + span {
  outline: 3px solid rgba(16, 185, 129, 0.26);
  outline-offset: 2px;
}

.market-type-option input:disabled + span {
  cursor: not-allowed;
  opacity: 0.72;
}

.form-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

.freshness-pill {
  display: inline-flex;
  min-height: 2.35rem;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid #d9e2ec;
  border-radius: 999px;
  background: #f8fafc;
  padding: 0.45rem 0.75rem;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.freshness-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(100, 116, 139, 0.12);
}

.freshness-pill.fresh {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}

.freshness-pill.warn {
  border-color: #fde68a;
  background: #fffbeb;
  color: #b45309;
}

.freshness-pill.stale {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #be123c;
}

.add-records-chart-wrap {
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem;
}

.add-records-chart {
  min-height: 320px;
  width: 100%;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #ffffff;
}

.add-records-chart-message {
  margin-top: 0.75rem;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 800;
}

.partial-tp-head,
.partial-tp-row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

.partial-tp-head {
  display: none;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.partial-tp-estimate {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.55;
  padding: 0 0.15rem;
}

.calculator-results {
  display: grid;
  gap: 0.9rem;
}

.calc-mode-options {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
}

.strategy-metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr));
}

.strategy-metrics-grid > div {
  min-width: 0;
}

.strategy-metrics-grid .text-lg {
  font-size: clamp(0.98rem, 3.2vw, 1.125rem);
  line-height: 1.22;
}

.calculator-summary-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13.5rem), 1fr));
}

.calculator-card {
  border: 1px solid #d9e2ec;
  border-radius: 0.5rem;
  background: #f8fafc;
  padding: 1rem;
}

.calculator-card strong {
  display: block;
  margin-top: 0.45rem;
  color: #101828;
  font-size: clamp(1.05rem, 4.5vw, 1.45rem);
  font-weight: 950;
  line-height: 1.12;
}

.calculator-card .positive {
  color: #059669;
}

.calculator-card .negative {
  color: #e11d48;
}

.calculator-detail {
  border: 1px solid #d9e2ec;
  border-radius: 0.5rem;
  background: #ffffff;
}

.calculator-detail summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1rem;
  color: #344054;
  font-size: 0.9rem;
  font-weight: 900;
}

.calculator-detail summary::-webkit-details-marker {
  display: none;
}

.calculator-detail summary::after {
  float: right;
  color: #64748b;
  content: "展開";
  font-size: 0.78rem;
  font-weight: 900;
}

.calculator-detail[open] summary {
  border-bottom: 1px solid #edf2f7;
}

.calculator-detail[open] summary::after {
  content: "收起";
}

.calculator-detail-body {
  color: #64748b;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.8;
  padding: 0.85rem 1rem 1rem;
}

.calculator-risk-note {
  display: grid;
  gap: 0.45rem;
  border: 1px solid #fecdd3;
  border-radius: 0.5rem;
  background: #fff1f2;
  color: #9f1239;
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.65;
  padding: 0.95rem 1rem;
}

.calculator-risk-note strong {
  color: #be123c;
  font-size: 0.9rem;
  font-weight: 950;
}

.risk-copy {
  display: grid;
  gap: 0.85rem;
  color: #344054;
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.85;
}

.risk-copy p {
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #f8fafc;
  padding: 0.9rem 1rem;
}

.risk-good,
.risk-hot,
.risk-warn,
.risk-danger,
.risk-example {
  font-weight: 950;
}

.risk-good {
  color: #047857;
}

.risk-hot {
  color: #0369a1;
}

.risk-warn {
  color: #b45309;
}

.risk-danger {
  color: #be123c;
}

.risk-example {
  color: #6d28d9;
}

.admin-suppressed {
  display: none !important;
}

.hero-title-row {
  display: flex;
  align-items: flex-start;
  gap: 1.35rem;
  margin-top: 0.45rem;
}

.hero-title {
  line-height: 1.04;
}

.beta-badge {
  position: relative;
  display: inline-flex;
  min-height: 1.65rem;
  align-items: center;
  gap: 0.38rem;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid rgba(52, 211, 153, 0.45);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.24), rgba(14, 165, 233, 0.16));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 28px rgba(16, 185, 129, 0.28);
  color: #d1fae5;
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  padding: 0.38rem 0.68rem;
  text-shadow: 0 0 14px rgba(52, 211, 153, 0.7);
  margin-top: 0.18rem;
}

.mobile-bottom-nav {
  display: none;
}

/* 手機浮動新增選單：桌面版一律隱藏（樣式只在手機 media query 內定義，桌面沒規則會外露）。 */
.mobile-add-sheet {
  display: none;
}

/* 標頭的「風險」按鈕只給手機用（手機隱藏了 app-nav 選單裡的「風險提示」）；桌面版 app-nav
   已有「風險提示」，故桌面隱藏這顆避免重複。手機顯示規則在 max-width:640 media query 內。 */
.risk-header-btn {
  display: none;
}

.initial-loader {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(248, 250, 252, 0.82);
  padding: 1.25rem;
  backdrop-filter: blur(18px);
}

.initial-loader.hidden {
  display: none;
}

.initial-loader-card {
  display: grid;
  width: min(100%, 25rem);
  gap: 1rem;
  border: 1px solid rgba(217, 226, 236, 0.9);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.18);
  padding: 1.25rem;
}

.loader-mark {
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  border-radius: 0.9rem;
  background: #101828;
  color: #a7f3d0;
  font-size: 1.35rem;
  box-shadow: 0 18px 38px rgba(16, 24, 40, 0.22);
}

.loader-title {
  color: #101828;
  font-size: 1.05rem;
  font-weight: 950;
}

.loader-copy {
  margin-top: 0.25rem;
  color: #64748b;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.65;
}

.loader-bar {
  overflow: hidden;
  height: 0.45rem;
  border-radius: 999px;
  background: #e2e8f0;
}

.loader-bar span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #10b981, #38bdf8);
  animation: loader-slide 1.05s ease-in-out infinite;
}

.metric-loading {
  display: inline-block;
  min-width: 3rem;
  color: transparent !important;
  border-radius: 0.45rem;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.12));
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.05s ease-in-out infinite;
}

.loading-card {
  min-height: 7rem;
}

.loading-line {
  height: 0.85rem;
  max-width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #e2e8f0, #f8fafc, #e2e8f0);
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.05s ease-in-out infinite;
}

.quick-action-icon {
  display: inline-grid;
  width: 2.3rem;
  height: 2.3rem;
  margin-bottom: 0.7rem;
  place-items: center;
  border-radius: 0.7rem;
  background: #ecfdf5;
  color: #047857;
  font-size: 1rem;
}

#openRiskModal .quick-action-icon {
  background: #ffe4e6;
  color: #be123c;
}

.app-nav {
  position: sticky;
  top: 0.75rem;
  z-index: 35;
  overflow: hidden;
}

.app-nav-head {
  display: none;
}

.app-nav-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem;
}

.app-nav-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
}

.app-nav-divider {
  align-self: stretch;
  width: 1px;
  min-height: 2.25rem;
  background: #e2e8f0;
}

.app-nav-item {
  display: inline-flex;
  min-height: 2.7rem;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  background: #f8fafc;
  color: #475569;
  padding: 0.58rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1.15;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.app-nav-item:hover {
  transform: translateY(-1px);
}

.app-nav-item.active {
  border-color: #101828;
  background: #101828;
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.14);
}

.app-nav-item.primary {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}

.app-nav-item.danger {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #be123c;
}

@keyframes loader-slide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(250%);
  }
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

.beta-badge::before {
  position: absolute;
  inset: -30% auto -30% -70%;
  width: 55%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.52), transparent);
  content: "";
  transform: skewX(-18deg);
  animation: beta-shine 2.6s ease-in-out infinite;
}

.beta-badge::after {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: #34d399;
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.95);
  content: "";
  animation: beta-pulse 1.65s ease-in-out infinite;
}

@keyframes beta-shine {
  0%,
  42% {
    left: -70%;
  }
  72%,
  100% {
    left: 118%;
  }
}

@keyframes beta-pulse {
  0%,
  100% {
    opacity: 0.5;
    transform: scale(0.84);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: calc(5.65rem + env(safe-area-inset-bottom));
    background: #eef4f8;
    -webkit-tap-highlight-color: transparent;
  }

  body > .fixed.inset-x-0.top-0 {
    height: 15rem;
  }

  .app-shell {
    gap: 0.8rem !important;
    padding: 0.7rem 0.7rem 1rem !important;
  }

  .app-shell > header {
    margin: -0.75rem -0.75rem 0;
    border-radius: 0 0 1.25rem 1.25rem;
    box-shadow: 0 22px 52px rgba(15, 23, 42, 0.2);
  }

  .app-shell > header > div {
    gap: 0.75rem;
    padding: 1rem 0.85rem 0.85rem;
  }

  .hero-title-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }

  .hero-title {
    font-size: 1.75rem !important;
    line-height: 1.08;
  }

  .beta-badge {
    margin-top: 0;
    min-height: 1.45rem;
    padding: 0.32rem 0.55rem;
    font-size: 0.62rem;
  }

  .app-shell > header p.mt-3 {
    margin-top: 0.55rem !important;
    font-size: 0.82rem !important;
    line-height: 1.55 !important;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.45rem !important;
  }

  .hero-stats > div {
    min-height: 4.25rem;
    border-radius: 0.85rem !important;
    padding: 0.7rem 0.65rem !important;
  }

  .hero-stats span {
    display: block;
    overflow: hidden;
    font-size: 0.58rem !important;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hero-stats strong {
    margin-top: 0.35rem !important;
    font-size: 1.45rem !important;
    line-height: 1;
  }

  .hero-user-panel {
    padding: 0.85rem !important;
    border-radius: 1rem !important;
  }

  .hero-user-panel > .flex {
    align-items: flex-start;
    gap: 0.75rem;
  }

  .hero-user-panel .text-lg {
    font-size: 1rem !important;
  }

  .hero-user-panel .flex.flex-wrap {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem !important;
    min-width: 9rem;
  }

  .hero-user-panel .flex.flex-wrap button,
  .hero-user-panel .flex.flex-wrap form,
  .hero-user-panel .flex.flex-wrap form button {
    width: 100%;
  }

  .hero-user-panel .flex.flex-wrap button {
    min-height: 2.35rem;
    padding: 0.48rem 0.55rem !important;
    border-radius: 0.75rem !important;
    font-size: 0.78rem !important;
  }

  .hero-warning {
    margin-top: 0.75rem !important;
    padding: 0.7rem 0.8rem !important;
    font-size: 0.78rem !important;
    line-height: 1.55 !important;
  }

  /* 手機版隱藏整個「選單」：頁面切換走底部導覽、新增走底部＋浮動選單、風險移到標頭，選單已多餘。 */
  .app-nav {
    display: none;
  }

  /* 手機沒有 app-nav，標頭的「風險」按鈕在手機才顯示 */
  .risk-header-btn {
    display: inline-flex;
    align-items: center;
  }

  .app-nav-head {
    display: flex;
    min-height: 3.35rem;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.55rem 0.65rem 0.55rem 0.85rem;
  }

  .app-nav-head .btn-ghost {
    min-height: 2.35rem;
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
  }

  .app-nav-body {
    display: none;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    border-top: 1px solid #edf2f7;
    padding: 0.7rem;
  }

  .app-nav.open .app-nav-body {
    display: grid;
  }

  .app-nav-item[data-mobile-bottom="true"] {
    display: none;
  }

  .app-nav-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .app-nav-divider {
    display: none;
  }

  .app-nav-item {
    min-height: 2.85rem;
    border-radius: 0.85rem;
    padding: 0.62rem 0.7rem;
    font-size: 0.82rem;
  }

  .app-nav-item:hover {
    transform: none;
  }

  .tab-panel {
    border-radius: 1rem !important;
    padding: 0.9rem !important;
    scroll-margin-top: 4.75rem;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08) !important;
  }

  .tab-panel > .mb-4 {
    align-items: flex-start;
    flex-direction: column;
  }

  .strategy-card {
    margin-inline: -0.15rem;
    border-radius: 1rem !important;
    overflow: hidden;
  }

  .strategy-card > div:first-child {
    padding: 0.95rem !important;
  }

  .strategy-actions {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(6.8rem, 1fr));
    width: 100%;
  }

  .strategy-actions button {
    width: 100%;
  }

  .strategy-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.4rem !important;
    padding: 0.55rem !important;
  }

  /* 比照手機交易所：資訊緊湊，區塊不要留一堆空白（原本 min-height 5.9rem 太高） */
  .strategy-metrics-grid > div {
    min-height: 0 !important;
    border-radius: 0.6rem !important;
    padding: 0.4rem 0.55rem !important;
  }

  .freshness-pill {
    min-height: 2rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.72rem;
  }

  /* 手機 modal 改「交易所 App」式：置中、上下留空、不佔滿全版，按鈕不再沉到畫面底 */
  .modal {
    align-items: center;
    justify-items: center;
    padding: 1.5rem 0.75rem;
    place-items: center;
  }

  .modal-panel,
  .modal-panel.max-w-3xl,
  .modal-panel.max-w-4xl {
    width: 100%;
    max-height: 82dvh;
    border-width: 1px;
    border-radius: 1.15rem;
    padding: 0.9rem;
    scrollbar-gutter: stable;
  }

  .modal-panel > .mb-5 {
    position: sticky;
    top: -0.9rem;
    z-index: 3;
    margin: -0.9rem -0.9rem 0.9rem;
    border-bottom: 1px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.96);
    padding: 0.85rem 0.9rem;
    backdrop-filter: blur(12px);
  }

  .modal-panel > .mb-5 h2 {
    font-size: 1.1rem !important;
    line-height: 1.25;
  }

  .modal-panel > .mb-5 .btn-ghost {
    min-height: 2.25rem;
    padding: 0.45rem 0.7rem;
    font-size: 0.78rem;
  }

  .modal-panel > button[type="submit"] {
    position: sticky;
    bottom: -0.9rem;
    z-index: 2;
    min-height: 2.9rem;
    margin: 1rem -0.9rem -0.9rem !important;
    border-radius: 0 0 1.15rem 1.15rem;
    box-shadow: 0 -12px 28px rgba(15, 23, 42, 0.12);
  }

  .form-section {
    gap: 0.7rem;
    padding-top: 0.85rem;
  }

  .section-heading {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 0.65rem;
  }

  .section-heading > span {
    min-width: 0;
  }

  .section-heading .btn-secondary,
  .section-heading .toggle {
    flex: 1 1 8.5rem;
  }

  .market-type-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .market-type-option span {
    min-height: 4rem;
    padding: 0.75rem;
  }

  .market-type-option small {
    display: none;
  }

  .field,
  .toggle {
    font-size: 0.82rem;
  }

  .field {
    gap: 0.38rem;
  }

  .input {
    min-height: 2.5rem;
    border-radius: 0.6rem;
    padding: 0.5rem 0.65rem;
    font-size: 0.85rem;
  }

  /* 交易所 App 式緊湊操作：按鈕與文字縮小，一排塞得下更多動作 */
  .btn-primary,
  .btn-secondary,
  .btn-danger,
  .btn-ghost {
    min-height: 2.35rem;
    border-radius: 0.6rem;
    padding-inline: 0.6rem;
    font-size: 0.74rem;
  }

  .strategy-actions .btn-primary,
  .strategy-actions .btn-secondary,
  .strategy-actions .btn-danger,
  .strategy-actions .btn-ghost {
    min-height: 2.1rem;
    padding-inline: 0.55rem;
    font-size: 0.72rem;
  }

  .partial-tp-row {
    gap: 0.55rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.85rem;
    background: #f8fafc;
    padding: 0.75rem;
  }

  .partial-tp-row .btn-danger {
    width: 100%;
  }

  .calculator-card,
  .calculator-detail,
  .calculator-risk-note,
  .risk-copy p,
  .calculator-step-footer {
    border-radius: 0.85rem;
  }

  .calculator-card {
    padding: 0.85rem;
  }

  .calculator-card strong {
    font-size: clamp(1rem, 6vw, 1.35rem);
  }

  .calculator-detail summary {
    padding: 0.78rem 0.85rem;
  }

  .calculator-detail-body,
  .calculator-risk-note,
  .risk-copy {
    font-size: 0.82rem;
    line-height: 1.68;
  }

  .add-records-chart-wrap {
    padding: 0.75rem;
  }

  .add-records-chart {
    min-height: 240px;
    border-radius: 0.85rem;
  }

  .modal-panel table {
    min-width: 0 !important;
    width: 100%;
  }

  .modal-panel thead {
    display: none;
  }

  .modal-panel tbody,
  .modal-panel tr,
  .modal-panel td {
    display: block;
    width: 100%;
  }

  .modal-panel tr {
    margin: 0.65rem;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 0.85rem;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
  }

  .modal-panel td {
    display: grid;
    grid-template-columns: minmax(5.5rem, 0.42fr) minmax(0, 1fr);
    gap: 0.65rem;
    align-items: start;
    border-bottom: 1px solid #edf2f7 !important;
    padding: 0.7rem 0.8rem !important;
    text-align: left !important;
    white-space: normal !important;
  }

  .modal-panel td:last-child {
    border-bottom: 0 !important;
  }

  .modal-panel td::before {
    content: attr(data-label);
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 950;
  }

  .modal-panel td:not([data-label])::before {
    content: "";
  }

  .modal-panel td .btn-danger,
  .modal-panel td .btn-secondary,
  .modal-panel td .btn-primary,
  .modal-panel td .btn-ghost {
    width: 100%;
  }

  .mobile-bottom-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.28rem;
    border-top: 1px solid rgba(217, 226, 236, 0.78);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 -18px 42px rgba(15, 23, 42, 0.16);
    padding: 0.48rem 0.55rem calc(0.5rem + env(safe-area-inset-bottom));
    backdrop-filter: blur(18px);
  }

  .mobile-nav-item {
    display: grid;
    min-height: 3.4rem;
    align-items: center;
    align-content: center;
    justify-content: center;
    gap: 0.2rem;
    border: 1px solid transparent;
    border-radius: 1rem;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 950;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease, border-color 160ms ease;
  }

  .mobile-nav-item i {
    font-size: 1rem;
    line-height: 1;
  }

  .mobile-nav-item.active {
    border-color: #a7f3d0;
    background: #ecfdf5;
    color: #047857;
  }

  .mobile-nav-item.primary {
    min-height: 3.65rem;
    margin-top: -0.35rem;
    background: linear-gradient(135deg, #101828, #047857);
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(16, 24, 40, 0.24);
  }

  .mobile-nav-item.danger {
    color: #be123c;
  }

  .mobile-nav-item:active {
    transform: scale(0.96);
  }

  .mobile-add-sheet {
    position: fixed;
    left: 50%;
    transform: translateX(-50%) translateY(0.4rem);
    bottom: calc(4.9rem + env(safe-area-inset-bottom));
    z-index: 46;
    display: grid;
    gap: 0.4rem;
    min-width: 13rem;
    padding: 0.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(217, 226, 236, 0.9);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -12px 44px rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(18px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease, transform 150ms ease;
  }

  .mobile-add-sheet.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
  }

  .mobile-add-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 0.9rem;
    border-radius: 0.8rem;
    font-size: 0.92rem;
    font-weight: 850;
    color: #0f172a;
    background: #f1f5f9;
  }

  .mobile-add-option i {
    width: 1.15rem;
    text-align: center;
    color: #059669;
  }

  .mobile-add-option:active {
    transform: scale(0.97);
  }

}

body.exchange-dark .mobile-add-sheet {
  background: rgba(16, 20, 28, 0.98);
  border-color: #252c3a;
}
body.exchange-dark .mobile-add-option {
  background: #1c2330;
  color: #eaecef;
}
body.exchange-dark .mobile-add-option i { color: #2ebd85; }

.calculator-table-wrap {
  overflow-x: auto;
  border-top: 1px solid #edf2f7;
  background: #ffffff;
  padding: 1rem;
}

.calculator-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-weight: 800;
}

.calculator-table th {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid #d9e2ec;
  color: #64748b;
  text-align: left;
  text-transform: uppercase;
}

.calculator-table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid #edf2f7;
  color: #101828;
  white-space: nowrap;
}

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

.calculator-table td.calc-profit {
  color: #059669;
}

.calculator-step-truncate {
  margin: 0.75rem 1rem 0;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #b45309;
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.5;
}

.calculator-step-footer {
  border: 1px solid #d9e2ec;
  border-radius: 0.5rem;
  background: #f8fafc;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.6;
  padding: 0.8rem 1rem;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 0.5rem;
  padding: 0.58rem 0.95rem;
  font-size: 0.875rem;
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, opacity 160ms ease;
}

.btn-primary {
  background: #101828;
  color: #fff;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.16);
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover,
.btn-ghost:hover {
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ecfdf5;
  color: #047857;
}

.btn-danger {
  background: #fff1f2;
  color: #be123c;
}

.btn-ghost {
  background: #f1f5f9;
  color: #334155;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none !important;
}

.tab-button {
  min-height: 2.75rem;
  border-radius: 0.5rem;
  background: transparent;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 900;
}

.tab-button.active {
  background: #101828;
  color: #fff;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.14);
}

pre {
  scrollbar-width: thin;
  scrollbar-color: #475569 #0f172a;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 2vw, 1.25rem);
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(calc(100vw - 1.5rem), 36rem);
  max-height: min(92dvh, 52rem);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #d9e2ec;
  border-radius: 0.75rem;
  background: #fff;
  padding: clamp(1rem, 2vw, 1.5rem);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.25);
}

.modal-panel.max-w-3xl {
  width: min(calc(100vw - 1.5rem), 48rem);
}

.modal-panel.max-w-4xl {
  width: min(calc(100vw - 1.5rem), 60rem);
}

@media (min-width: 640px) {
  .modal-panel {
    padding: 1.5rem;
  }
}

@media (min-width: 768px) {
  .market-type-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  }

  .calculator-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
  }

  .partial-tp-head,
  .partial-tp-row {
    grid-template-columns: minmax(0, 1fr) minmax(9rem, 0.55fr) auto;
    align-items: end;
  }

  .partial-tp-head {
    display: grid;
  }
}

/* ============================================================
   交易所深色主題（OKX App 風格）
   掛在 body.exchange-dark 上；用高特異度蓋過 Tailwind CDN 產生的 utility
   色票：底 #0b0e14 / 面板 #151a23 / 浮層 #1c2330 / 線 #252c3a
        文字 #eaecef / 次要 #9aa3b8 / 弱 #636d84
        多/漲 #2ebd85、空/跌 #f0616d、警示 #f0b90b
   ============================================================ */

body.exchange-dark {
  background: #0b0e14;
  color: #eaecef;
  color-scheme: dark;
  font-variant-numeric: tabular-nums; /* 交易所式等寬數字 */
}

/* ---- Tailwind 背景 utility ---- */
body.exchange-dark .bg-white { background-color: #151a23; }
body.exchange-dark .bg-slate-50 { background-color: #10151d; }
body.exchange-dark .bg-slate-50\/80 { background-color: rgba(16, 21, 29, 0.85); }
body.exchange-dark .bg-slate-100 { background-color: #1c2330; }
body.exchange-dark .bg-slate-900,
body.exchange-dark .bg-slate-950 { background-color: #1e2634; }
body.exchange-dark .bg-slate-400 { background-color: #636d84; }
body.exchange-dark .bg-emerald-50 { background-color: rgba(46, 189, 133, 0.14); }
body.exchange-dark .bg-emerald-500 { background-color: #2ebd85; }
body.exchange-dark .bg-emerald-400\/10 { background-color: rgba(46, 189, 133, 0.12); }
body.exchange-dark .bg-rose-50 { background-color: rgba(240, 97, 109, 0.14); }
body.exchange-dark .bg-amber-50 { background-color: rgba(240, 185, 11, 0.14); }
body.exchange-dark .from-slate-50 { --tw-gradient-from: #10151d; --tw-gradient-to: rgba(16, 21, 29, 0); --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }

/* ---- 文字 utility ---- */
body.exchange-dark .text-slate-950 { color: #eaecef; }
body.exchange-dark .text-slate-700 { color: #c3c9d5; }
body.exchange-dark .text-slate-600 { color: #9aa3b8; }
body.exchange-dark .text-slate-500 { color: #8b93a7; }
body.exchange-dark .text-slate-400 { color: #8b93a7; }
body.exchange-dark .text-slate-300 { color: #aab2c4; }
body.exchange-dark .text-slate-200 { color: #c3c9d5; }
body.exchange-dark .text-emerald-600,
body.exchange-dark .text-emerald-700,
body.exchange-dark .text-emerald-800 { color: #2ebd85; }
body.exchange-dark .text-rose-600,
body.exchange-dark .text-rose-700 { color: #f0616d; }
body.exchange-dark .text-amber-700,
body.exchange-dark .text-amber-800 { color: #f0b90b; }

/* ---- 邊框 / 分隔線 utility ---- */
body.exchange-dark .border-slate-200,
body.exchange-dark .border-slate-300 { border-color: #252c3a; }
body.exchange-dark .border-white { border-color: rgba(255, 255, 255, 0.16); }
body.exchange-dark .border-emerald-200 { border-color: rgba(46, 189, 133, 0.35); }
body.exchange-dark .border-rose-200 { border-color: rgba(240, 97, 109, 0.35); }
body.exchange-dark .border-amber-200 { border-color: rgba(240, 185, 11, 0.35); }
body.exchange-dark .divide-slate-200 > :not([hidden]) ~ :not([hidden]),
body.exchange-dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: #252c3a; }
body.exchange-dark .shadow-soft { box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5); }

/* ---- 表單元件 ---- */
body.exchange-dark .input {
  background: #10151d;
  border-color: #2a3241;
  color: #eaecef;
}
body.exchange-dark .input:focus {
  border-color: #2ebd85;
  box-shadow: 0 0 0 3px rgba(46, 189, 133, 0.18);
}
body.exchange-dark .input::placeholder { color: #5e677b; }
body.exchange-dark .input:disabled,
body.exchange-dark .input[readonly] { background: #171d28; color: #8b93a7; }
body.exchange-dark .field,
body.exchange-dark .toggle { color: #9aa3b8; }

/* ---- 按鈕（交易所式：主動作綠、危險紅、其餘低調）---- */
body.exchange-dark .btn-primary {
  background: #2ebd85;
  color: #06130d;
  box-shadow: 0 8px 22px rgba(46, 189, 133, 0.25);
}
body.exchange-dark .btn-primary:disabled { background: #1d3a30; color: #6fa08c; box-shadow: none; }
body.exchange-dark .btn-secondary { background: rgba(46, 189, 133, 0.14); color: #2ebd85; }
body.exchange-dark .btn-secondary:disabled { color: #55917a; }
body.exchange-dark .btn-danger { background: rgba(240, 97, 109, 0.14); color: #f0616d; }
body.exchange-dark .btn-danger:disabled { color: #a86e75; }
body.exchange-dark .btn-ghost { background: #1c2330; color: #9aa3b8; }
body.exchange-dark .btn-ghost:disabled { color: #7b869c; }

/* ---- Modal ---- */
body.exchange-dark .modal-backdrop { background: rgba(0, 0, 0, 0.68); }
body.exchange-dark .modal-panel { background: #151a23; border-color: #252c3a; color: #eaecef; }
body.exchange-dark .modal-panel > .mb-5 { background: rgba(21, 26, 35, 0.96); border-color: #252c3a; }

/* ---- 導覽 / 卡片 / 骨架 ---- */
body.exchange-dark .app-nav { background: #10141c; border-color: #252c3a; }
body.exchange-dark .app-nav-item { color: #9aa3b8; }
body.exchange-dark .app-nav-item:hover { background: #1c2330; color: #eaecef; }
body.exchange-dark .app-nav-item.active { background: rgba(46, 189, 133, 0.14); color: #2ebd85; }
body.exchange-dark .app-nav-divider { background: #252c3a; }
body.exchange-dark .mobile-bottom-nav { background: rgba(16, 20, 28, 0.96); border-color: #252c3a; }
body.exchange-dark .mobile-bottom-nav .mobile-nav-item { color: #8b93a7; }
body.exchange-dark .mobile-bottom-nav .mobile-nav-item.primary { background: #2ebd85; color: #06130d; }
body.exchange-dark .strategy-card { background: #151a23; border-color: #252c3a; }
body.exchange-dark .loading-card { background: #10151d; border-color: #252c3a; }
body.exchange-dark .loading-line { background: linear-gradient(90deg, #1c2330, #252c3a, #1c2330); }
body.exchange-dark .metric-loading { background: #1c2330; }
body.exchange-dark .initial-loader { background: rgba(11, 14, 20, 0.94); }
body.exchange-dark .initial-loader-card { background: #151a23; border-color: #252c3a; color: #eaecef; }
body.exchange-dark .loader-bar { background: #1c2330; }

/* ---- 狀態小元件 ---- */
body.exchange-dark .freshness-pill { background: #1c2330; color: #9aa3b8; border-color: #252c3a; }
body.exchange-dark .freshness-pill.fresh { background: rgba(46, 189, 133, 0.14); color: #2ebd85; border-color: rgba(46, 189, 133, 0.35); }
body.exchange-dark .freshness-pill.warn { background: rgba(240, 185, 11, 0.14); color: #f0b90b; border-color: rgba(240, 185, 11, 0.35); }
body.exchange-dark .freshness-pill.stale { background: rgba(240, 97, 109, 0.14); color: #f0616d; border-color: rgba(240, 97, 109, 0.35); }
body.exchange-dark .beta-badge { background: rgba(46, 189, 133, 0.14); color: #2ebd85; }

/* ---- 表單區塊 / 選項 ---- */
body.exchange-dark .form-section { border-color: #252c3a; }
body.exchange-dark .market-type-option { background: #10151d; border-color: #2a3241; color: #9aa3b8; }
body.exchange-dark .market-type-option:has(input:checked) { background: rgba(46, 189, 133, 0.12); border-color: rgba(46, 189, 133, 0.45); color: #2ebd85; }
body.exchange-dark .tab-button { background: #1c2330; color: #9aa3b8; }
body.exchange-dark .tab-button.active { background: #2ebd85; color: #06130d; }
body.exchange-dark .partial-tp-row { background: #10151d !important; border-color: #252c3a !important; }
body.exchange-dark .partial-tp-estimate { color: #8b93a7; }

/* ---- 風險提示框 ---- */
body.exchange-dark .risk-copy { color: #9aa3b8; }
body.exchange-dark .risk-good { background: rgba(46, 189, 133, 0.12); color: #2ebd85; }
body.exchange-dark .risk-warn { background: rgba(240, 185, 11, 0.12); color: #f0b90b; }
body.exchange-dark .risk-danger,
body.exchange-dark .risk-hot { background: rgba(240, 97, 109, 0.12); color: #f0616d; }
body.exchange-dark .risk-example { background: #10151d; border-color: #252c3a; }

/* ---- 計算機 / 表格 ---- */
body.exchange-dark .calculator-card,
body.exchange-dark .calculator-detail,
body.exchange-dark .calculator-risk-note { background: #10151d; border-color: #252c3a; }
body.exchange-dark .calculator-table-wrap { background: #10151d; border-color: #252c3a; }
body.exchange-dark .calculator-table th { background: #1c2330; color: #9aa3b8; }
body.exchange-dark .calculator-table td { border-color: #252c3a; }
body.exchange-dark .calculator-table td.calc-profit { color: #2ebd85; }
body.exchange-dark .calculator-step-truncate { border-color: #3a2f12; background: rgba(245, 158, 11, 0.12); color: #f5c451; }
body.exchange-dark .modal-panel table { color: #c3c9d5; }
body.exchange-dark .modal-panel thead { color: #8b93a7; }

/* ---- 手機版表格卡片化的邊框（原本是淺灰）---- */
@media (max-width: 640px) {
  body.exchange-dark .modal-panel tr { border-color: #252c3a; background: #10151d; }
  body.exchange-dark .modal-panel td { border-color: #1c2330; }
  body.exchange-dark .modal-panel > .mb-5 { border-color: #252c3a; }
}

/* ---- 捲軸 ---- */
body.exchange-dark ::-webkit-scrollbar { width: 8px; height: 8px; }
body.exchange-dark ::-webkit-scrollbar-thumb { background: #2a3241; border-radius: 4px; }
body.exchange-dark ::-webkit-scrollbar-track { background: transparent; }

/* ---- 深色主題補漏：hover 變體與快速動作圖示 ---- */
body.exchange-dark .hover\:bg-emerald-50:hover { background-color: rgba(46, 189, 133, 0.16); }
body.exchange-dark .hover\:bg-emerald-300:hover { background-color: #27a374; }
body.exchange-dark .quick-action-icon { background: rgba(46, 189, 133, 0.14); color: #2ebd85; }
body.exchange-dark #openRiskModal .quick-action-icon { background: rgba(240, 97, 109, 0.14); color: #f0616d; }

/* ---- 深色主題補漏 2：tailwind.config 具名色票（panel/line/ink/mint/okx）---- */
body.exchange-dark .bg-panel { background-color: #151a23; }
body.exchange-dark .bg-ink,
body.exchange-dark .bg-okx { background-color: #1e2634; }
body.exchange-dark .bg-mint { background-color: #2ebd85; }
body.exchange-dark .text-ink { color: #eaecef; }
body.exchange-dark .text-mint { color: #2ebd85; }
body.exchange-dark .border-line { border-color: #252c3a; }
body.exchange-dark .divide-line > :not([hidden]) ~ :not([hidden]) { border-color: #252c3a; }
body.exchange-dark .shadow-lift { box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); }

/* ---- 深色主題補漏 3：導覽項目底色 ---- */
body.exchange-dark .app-nav-item { background: #1c2330; }
body.exchange-dark .app-nav-item:hover { background: #232b3a; }
body.exchange-dark .app-nav-item.active { background: rgba(46, 189, 133, 0.16); }

/* ---- 深色主題補漏 4：手機收合導覽（原規則帶 !important）與底部 tab active ---- */
@media (max-width: 640px) {
  body.exchange-dark .app-nav { background: rgba(16, 20, 28, 0.96) !important; }
  body.exchange-dark .mobile-nav-item.active {
    border-color: rgba(46, 189, 133, 0.4);
    background: rgba(46, 189, 133, 0.16);
    color: #2ebd85;
  }
}

/* ---- 深色主題補漏 5：base 元件內寫死的深色文字/淺色底（對比度全面修正）---- */
/* 表單區塊標題與說明 */
body.exchange-dark .section-heading { color: #eaecef; }
body.exchange-dark .market-type-title { color: #9aa3b8; }
body.exchange-dark .market-type-option span { background: #10151d; border-color: #2a3241; color: #9aa3b8; }
body.exchange-dark .market-type-option strong { color: #eaecef; }
body.exchange-dark .market-type-option small { color: #8b93a7; }
body.exchange-dark .market-type-option input:checked + span {
  background: rgba(46, 189, 133, 0.12);
  border-color: rgba(46, 189, 133, 0.45);
  box-shadow: 0 0 0 4px rgba(46, 189, 133, 0.1);
}
body.exchange-dark .toggle { background: #10151d; border-color: #2a3241; }
body.exchange-dark .partial-tp-head { color: #8b93a7; }
body.exchange-dark .add-records-chart-message { color: #8b93a7; }
body.exchange-dark .add-records-chart { border-color: #252c3a; } /* 圖表畫布保持白底可讀 */

/* 計算機 */
body.exchange-dark .calculator-card strong { color: #eaecef; }
body.exchange-dark .calculator-card .positive { color: #2ebd85; }
body.exchange-dark .calculator-card .negative { color: #f0616d; }
body.exchange-dark .calculator-detail summary { color: #c3c9d5; }
body.exchange-dark .calculator-detail summary::after { color: #8b93a7; }
body.exchange-dark .calculator-detail[open] summary { border-color: #252c3a; }
body.exchange-dark .calculator-detail-body { color: #9aa3b8; }
body.exchange-dark .calculator-risk-note { background: rgba(240, 97, 109, 0.1); border-color: rgba(240, 97, 109, 0.35); color: #e39aa2; }
body.exchange-dark .calculator-risk-note strong { color: #f0616d; }
body.exchange-dark .calculator-table th { border-color: #252c3a; }
body.exchange-dark .calculator-table td { color: #eaecef; border-color: #1c2330; }
body.exchange-dark .calculator-step-footer { background: #10151d; border-color: #252c3a; color: #9aa3b8; }

/* 風險提示文案框 */
body.exchange-dark .risk-copy p { background: #10151d; border-color: #252c3a; }
body.exchange-dark .risk-good { color: #2ebd85; }
body.exchange-dark .risk-hot { color: #58a6ff; }
body.exchange-dark .risk-warn { color: #f0b90b; }
body.exchange-dark .risk-danger { color: #f0616d; }
body.exchange-dark .risk-example { color: #b795ff; }

/* 初始載入畫面 */
body.exchange-dark .loader-title { color: #eaecef; }
body.exchange-dark .loader-copy { color: #9aa3b8; }

/* 桌面側欄的 primary/danger 導覽項 */
body.exchange-dark .app-nav-item.primary { background: rgba(46, 189, 133, 0.14); border-color: rgba(46, 189, 133, 0.35); color: #2ebd85; }
body.exchange-dark .app-nav-item.danger { background: rgba(240, 97, 109, 0.12); border-color: rgba(240, 97, 109, 0.3); color: #f0616d; }

/* 手機版表格卡片化的欄位標籤 */
@media (max-width: 640px) {
  body.exchange-dark .modal-panel td::before { color: #8b93a7; }
}

/* ---- 深色主題：禁用按鈕整體透明度放寬（0.48 在深底上幾乎隱形）---- */
body.exchange-dark button:disabled { opacity: 0.65; }

/* ============ 加入主畫面（A2HS）提示橫幅 ============ */
.a2hs-banner {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translate(-50%, 140%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(30rem, calc(100vw - 1.5rem));
  padding: 0.7rem 0.8rem;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: #0b1220;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1), opacity 260ms ease;
}
.a2hs-banner.a2hs-in { transform: translate(-50%, 0); opacity: 1; }
.a2hs-banner.hidden { display: none; }
.a2hs-icon {
  width: 2.6rem;
  height: 2.6rem;
  flex: 0 0 auto;
  border-radius: 0.7rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.a2hs-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.a2hs-text strong { color: #f1f5f9; font-size: 0.92rem; font-weight: 850; }
.a2hs-text span { color: #94a3b8; font-size: 0.76rem; margin-top: 0.1rem; }
.a2hs-actions { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; flex: 0 0 auto; }
.a2hs-install {
  min-height: 2.2rem;
  padding: 0 0.9rem;
  border-radius: 0.6rem;
  background: #10b981;
  color: #05231a;
  font-weight: 850;
  font-size: 0.82rem;
  white-space: nowrap;
}
.a2hs-install:active { transform: translateY(1px); }
.a2hs-close {
  width: 2rem;
  height: 2.2rem;
  border-radius: 0.55rem;
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  font-size: 0.9rem;
}

/* iOS 加入教學底部彈窗 */
.a2hs-ios-sheet { position: fixed; inset: 0; z-index: 70; display: grid; place-items: end center; }
.a2hs-ios-sheet.hidden { display: none; }
.a2hs-ios-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 23, 0.62); backdrop-filter: blur(2px); }
.a2hs-ios-card {
  position: relative;
  width: min(30rem, calc(100vw - 1rem));
  margin-bottom: max(0.6rem, env(safe-area-inset-bottom));
  padding: 1.1rem 1.15rem 1.15rem;
  border-radius: 1.15rem;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: #0b1220;
  color: #e2e8f0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
}
.a2hs-ios-card ol { color: #cbd5e1; }
.a2hs-ios-card b { color: #f1f5f9; }
.a2hs-share-glyph { display: inline-block; padding: 0 0.15rem; }

@media (max-width: 640px) {
  .a2hs-text strong { font-size: 0.86rem; }
  .a2hs-text span { font-size: 0.72rem; }
}
