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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(
    circle at top left,
    #0f172a,
    #020617 55%,
    #000000
  );
  color: #e5e7eb;
  min-height: 100vh;
}

.positions-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.positions-header {
  margin-bottom: 28px;
}

.positions-header h1 {
  margin: 0;
  font-size: 26px;
  color: #f1f5f9;
  font-weight: 600;
}

.positions-subtitle {
  margin: 8px 0 0;
  font-size: 14px;
  color: #94a3b8;
}

.positions-query-card {
  padding: 22px 26px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.5);
  margin-bottom: 28px;
}

.positions-current-account-bar .positions-query-desc {
  margin-bottom: 12px;
}

.account-tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.account-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(51, 65, 85, 0.8);
  background: rgba(30, 41, 59, 0.5);
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.account-tab-btn:hover {
  background: rgba(51, 65, 85, 0.6);
  color: #e2e8f0;
  border-color: rgba(100, 116, 139, 0.8);
}

.account-tab-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.6);
  color: #a5b4fc;
}

.account-tab-key-icon {
  font-size: 12px;
  opacity: 0.9;
}

.account-tab-label {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.positions-list-current-account {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 12px;
}

.positions-list-current-account strong {
  color: #e2e8f0;
}

.positions-query-desc {
  margin: 0 0 18px;
  font-size: 14px;
  color: #94a3b8;
  line-height: 1.5;
}

.positions-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.positions-form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.positions-label {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 500;
}

.positions-input {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(51, 65, 85, 0.8);
  background: rgba(30, 41, 59, 0.6);
  color: #e2e8f0;
  font-size: 14px;
  max-width: 480px;
}

.positions-input::placeholder {
  color: #64748b;
}

.positions-input:focus {
  outline: none;
  border-color: rgba(148, 163, 184, 0.5);
}

.positions-input-address {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.positions-form-actions {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.positions-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #94a3b8;
  cursor: pointer;
}

.positions-checkbox-label input {
  cursor: pointer;
}

.positions-telegram-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-top: 4px;
}

.positions-query-btn {
  padding: 10px 24px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.positions-query-btn:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.4);
  border-color: rgba(99, 102, 241, 0.6);
  color: #c7d2fe;
}

.positions-query-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.positions-poll-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(51, 65, 85, 0.5);
}

.positions-poll-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(51, 65, 85, 0.8);
  background: rgba(30, 41, 59, 0.6);
  color: #e2e8f0;
  font-size: 14px;
  max-width: 160px;
}

.positions-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
}

.positions-tab {
  padding: 10px 20px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.positions-tab:hover {
  color: #e2e8f0;
}

.positions-tab.active {
  color: #a5b4fc;
  border-bottom-color: #a5b4fc;
}

.positions-orders-error {
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
  font-size: 14px;
  margin-bottom: 16px;
}

.orders-error-hint {
  color: #94a3b8;
  font-size: 12px;
  margin-left: 8px;
}

/* Open Orders：依市場分組 */
.orders-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.orders-market-block {
  border: 1px solid rgba(51, 65, 85, 0.5);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(30, 41, 59, 0.3);
}

.orders-market-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.orders-market-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(51, 65, 85, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.orders-market-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.orders-market-icon-placeholder {
  font-size: 16px;
  font-weight: 600;
  color: #64748b;
}

.orders-market-question {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orders-boost-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #1e293b;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.orders-boost-badge-clickable {
  cursor: pointer;
}

.orders-boost-badge-clickable:hover {
  filter: brightness(1.1);
}

.boost-orders-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 16px;
}

.boost-market-card {
  background: rgba(30, 41, 59, 0.5);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid rgba(51, 65, 85, 0.5);
}

.boost-market-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.boost-market-question {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.boost-orderbook-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.boost-orderbook-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.boost-orderbook-title {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 4px;
}

.boost-orderbook-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.boost-orderbook-table th,
.boost-orderbook-table td {
  padding: 4px 8px;
  text-align: left;
}

.boost-orderbook-table thead th {
  color: #64748b;
  font-weight: 600;
}

.boost-ask-row td {
  color: #f87171;
}

.boost-bid-row td {
  color: #34d399;
}

.boost-empty {
  color: #64748b;
  font-style: italic;
}

.boost-orders-summary {
  font-size: 11px;
  color: #64748b;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(51, 65, 85, 0.3);
}

.orders-table-wrap {
  overflow-x: auto;
}

/* Predict / Polymarket 買一／賣一（掛單列表下方，上賣一下買一，左到右：標籤、價格、shares） */
.predict-best-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 10px 14px;
  margin: 0 12px 12px;
  background: rgba(30, 41, 59, 0.5);
  border-radius: 10px;
  border: 1px solid rgba(51, 65, 85, 0.5);
}
.predict-best-col {
  flex: 1;
  min-width: 0;
}
.predict-best-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.predict-best-row .predict-best-label {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 8px;
}
.predict-best-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.predict-best-tr {
  display: flex;
  align-items: center;
  gap: 16px 24px;
  font-size: 13px;
}
.predict-best-td-label {
  min-width: 36px;
  font-weight: 500;
}
.predict-best-td-price {
  min-width: 48px;
  font-weight: 700;
  font-size: 14px;
}
.predict-best-td-shares {
  color: #e2e8f0;
}
.predict-best-ask .predict-best-td-label,
.predict-best-ask .predict-best-td-price { color: #f87171; }
.predict-best-bid .predict-best-td-label,
.predict-best-bid .predict-best-td-price { color: #60a5fa; }

.predict-best-status {
  margin-left: 8px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.predict-best-status-safe {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.6);
}
.predict-best-status-danger {
  color: #f97373;
  border-color: rgba(248, 113, 113, 0.6);
}
.predict-best-status-balanced {
  color: #9ca3af;
  border-color: rgba(156, 163, 175, 0.5);
}
.predict-best-force-btns {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.predict-force-sep {
  margin: 0 2px;
  color: #64748b;
  font-size: 11px;
}
.predict-force-btn {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid rgba(100, 116, 139, 0.6);
  background: rgba(51, 65, 85, 0.6);
  color: #94a3b8;
  cursor: pointer;
}
.predict-force-btn:hover {
  background: rgba(71, 85, 105, 0.8);
  color: #e2e8f0;
}
.predict-force-btn.active {
  background: rgba(34, 197, 94, 0.3);
  border-color: rgba(34, 197, 94, 0.6);
  color: #4ade80;
}

.orders-status-floating {
  position: fixed;
  z-index: 40;
  max-width: 260px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.6);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.7);
  font-size: 12px;
  cursor: move;
}

.orders-status-title {
  font-size: 12px;
  font-weight: 600;
  color: #e5e7eb;
  margin-bottom: 6px;
}

.orders-status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.orders-status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.orders-status-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: #e5e7eb;
  background: rgba(30, 41, 59, 0.8);
}

.orders-status-pill-safe {
  border-color: rgba(74, 222, 128, 0.6);
  color: #4ade80;
  background: rgba(22, 163, 74, 0.12);
}

.orders-status-pill-danger {
  border-color: rgba(248, 113, 113, 0.6);
  color: #f97373;
  background: rgba(185, 28, 28, 0.18);
}

.orders-status-pill-balanced {
  border-color: rgba(156, 163, 175, 0.6);
  color: #e5e7eb;
  background: rgba(55, 65, 81, 0.8);
}

.orders-status-outcome {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
}

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

.orders-table th,
.orders-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
}

.orders-table th {
  background: rgba(30, 41, 59, 0.6);
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.03em;
}

.orders-table tbody tr:hover {
  background: rgba(30, 41, 59, 0.25);
}

.orders-cell-side {
  color: #e2e8f0;
  font-weight: 500;
}

.orders-cell-outcome {
  font-weight: 600;
}

.orders-cell-outcome.outcome-yes {
  color: #60a5fa;
}

.orders-cell-outcome.outcome-no {
  color: #f87171;
}

.orders-cell-price,
.orders-cell-shares,
.orders-cell-filled,
.orders-cell-value,
.orders-cell-expiry {
  font-variant-numeric: tabular-nums;
  color: #cbd5e1;
}

.orders-cell-value {
  color: #86efac;
  font-weight: 500;
}

.orders-cell-action {
  text-align: right;
}

.orders-cancel-link {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(51, 65, 85, 0.5);
  color: #94a3b8;
  font-size: 12px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.orders-replace-btn {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #34d399;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 6px;
  cursor: pointer;
  margin-right: 8px;
  white-space: nowrap;
}

.orders-replace-btn:hover {
  background: rgba(52, 211, 153, 0.22);
  color: #6ee7b7;
}

.orders-replace-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.orders-remove-btn {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 6px;
  cursor: pointer;
  margin-right: 6px;
}

.orders-remove-btn:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.22);
  color: #fca5a5;
}

.orders-remove-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.orders-cancel-link:hover {
  background: rgba(71, 85, 105, 0.6);
  color: #f87171;
}

/* 不在買一/賣一的掛單高亮 */
.orders-row-not-best {
  background: rgba(251, 191, 36, 0.15) !important;
}

.orders-row-not-best:hover {
  background: rgba(251, 191, 36, 0.25) !important;
}

.orders-not-best-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #f59e0b;
  color: #1e293b;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

.positions-loading,
.positions-empty {
  padding: 40px;
  text-align: center;
  color: #94a3b8;
  font-size: 15px;
}

.positions-error {
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.positions-retry-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(248, 113, 113, 0.5);
  background: rgba(185, 28, 28, 0.3);
  color: #fecaca;
  font-size: 13px;
  cursor: pointer;
}

.positions-retry-btn:hover {
  background: rgba(185, 28, 28, 0.5);
}

.positions-account-card {
  padding: 22px 26px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.5);
  margin-bottom: 28px;
}

.positions-account-note-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(96, 165, 250, 0.2);
  color: #60a5fa;
  font-size: 12px;
  font-weight: 500;
}

/* 多帳戶管理樣式 */
.account-manager {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.account-manager-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.account-manager-title {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 500;
}

.account-add-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid rgba(96, 165, 250, 0.4);
  background: rgba(96, 165, 250, 0.1);
  color: #60a5fa;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.account-add-btn:hover {
  background: rgba(96, 165, 250, 0.2);
}

.account-add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.account-input {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(30, 41, 59, 0.6);
  color: #e2e8f0;
  font-size: 13px;
}

.account-input::placeholder {
  color: #64748b;
}

.account-input-note {
  min-width: 120px;
  flex: 0.5;
}

.account-input-key {
  min-width: 200px;
}

.account-save-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: #3b82f6;
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.account-save-btn:hover:not(:disabled) {
  background: #2563eb;
}

.account-save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.account-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.account-list-empty {
  padding: 16px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}

.account-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.account-item:hover {
  background: rgba(30, 41, 59, 0.7);
}

.account-item-active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
}

.account-item-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.account-item-address {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 13px;
  color: #e2e8f0;
  white-space: nowrap;
}

.account-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.account-item-note {
  font-size: 12px;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-item-key-badge {
  font-size: 12px;
  flex-shrink: 0;
  opacity: 0.9;
}

.account-edit-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.account-edit-key {
  font-size: 11px;
}

.account-edit-input {
  flex: 1;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
  font-size: 12px;
}

.account-item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.account-alert-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #94a3b8;
  cursor: pointer;
}

.account-alert-toggle input {
  cursor: pointer;
}

.account-action-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.account-action-btn:hover {
  background: rgba(148, 163, 184, 0.3);
  color: #e2e8f0;
}

.account-action-delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.positions-section-title {
  margin: 0 0 16px;
  font-size: 16px;
  color: #94a3b8;
  font-weight: 600;
}

.positions-account-row {
  display: flex;
  align-items: center;
  gap: 18px;
}

.positions-account-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
}

.positions-account-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.positions-account-name {
  font-size: 17px;
  color: #f1f5f9;
  font-weight: 500;
}

.positions-account-address {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: #94a3b8;
}

.positions-account-points,
.positions-account-referral {
  font-size: 12px;
  color: #64748b;
}

.positions-list-section {
  position: relative;
  padding: 22px 26px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.5);
  margin-bottom: 28px;
}

.positions-list-section.positions-list-loading {
  pointer-events: none;
}

.positions-list-section.positions-list-loading .positions-tabs,
.positions-list-section.positions-list-loading .positions-section-title,
.positions-list-section.positions-list-loading .positions-cards-header,
.positions-list-section.positions-list-loading .positions-cards-list,
.positions-list-section.positions-list-loading .orders-list {
  opacity: 0.5;
}

.positions-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.7);
  z-index: 10;
  border-radius: 12px;
}

.positions-loading-overlay span {
  color: var(--color-text-dim, #94a3b8);
  font-size: 14px;
}

.positions-list-section .positions-section-title {
  margin-bottom: 18px;
}

/* 官方風格：表頭列（Outcome, Shares, Value, To Win, Action） */
.positions-cards-header {
  display: grid;
  grid-template-columns: 80px 1fr 1fr 1fr auto;
  gap: 12px 16px;
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
  align-items: center;
}

.positions-ch-outcome { min-width: 72px; }
.positions-ch-shares { text-align: right; }
.positions-ch-value { text-align: right; }
.positions-ch-towin { text-align: right; }
.positions-ch-action { min-width: 100px; }

/* 持倉卡片列表 */
.positions-cards-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.position-card {
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  padding: 20px;
  transition: background 0.15s ease;
}

.position-card:hover {
  background: rgba(30, 41, 59, 0.25);
}

.position-card:last-child {
  border-bottom: none;
}

/* 市場標題區塊：圖示 + 問題 */
.position-card-market {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.position-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(51, 65, 85, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.position-card-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.position-card-icon-placeholder {
  font-size: 18px;
  font-weight: 600;
  color: #64748b;
}

.position-card-question {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* 持倉明細：Outcome, Shares, Value, To Win, Sell */
.position-card-details {
  display: grid;
  grid-template-columns: 80px 1fr 1fr 1fr auto;
  gap: 12px 16px;
  align-items: center;
  font-size: 14px;
}

.position-outcome {
  font-weight: 600;
  min-width: 72px;
}

.outcome-yes {
  color: #60a5fa;
}

.outcome-no {
  color: #f87171;
}

.position-shares,
.position-value,
.position-towin {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #e2e8f0;
}

.position-value,
.position-towin {
  color: #86efac;
  font-weight: 500;
}

.position-return {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.return-amount {
  font-variant-numeric: tabular-nums;
}

.return-pct {
  font-size: 12px;
}

/* Return positive (green) / negative (red) */
.return-pos {
  color: #22c55e;
}
.return-neg {
  color: #f87171;
}

.position-sell-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(51, 65, 85, 0.5);
  color: #e2e8f0;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.position-sell-btn:hover {
  background: rgba(71, 85, 105, 0.7);
  border-color: rgba(148, 163, 184, 0.6);
  color: #f1f5f9;
}

@media (max-width: 768px) {
  .positions-cards-header {
    grid-template-columns: 1fr 1fr 1fr;
    font-size: 11px;
  }
  .positions-ch-towin,
  .positions-ch-action {
    display: none;
  }
  .position-card-details {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px 12px;
  }
  .position-avg,
  .position-return,
  .position-towin {
    display: none;
  }
  .position-sell-btn {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

.positions-load-more {
  margin-top: 22px;
  text-align: center;
}

.positions-load-more-btn {
  min-width: 120px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(51, 65, 85, 0.6);
  color: #e2e8f0;
  font-size: 14px;
  cursor: pointer;
}

.positions-load-more-btn:hover:not(:disabled) {
  background: rgba(71, 85, 105, 0.7);
  border-color: rgba(148, 163, 184, 0.5);
}

.positions-load-more-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Polymarket 買一賣一（掛單下方） */
.polymarket-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}

.polymarket-section-title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  color: #94a3b8;
}

.polymarket-loading {
  padding: 24px;
  text-align: center;
  color: #94a3b8;
}

.polymarket-error,
.polymarket-empty {
  padding: 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
}

.polymarket-error {
  color: #f87171;
}

.polymarket-market-block {
  margin-top: 16px;
}

.polymarket-market-block:first-of-type {
  margin-top: 0;
}

/* Polymarket 買一賣一（每個掛單市場區塊下方內嵌） */
.polymarket-inline {
  margin-top: 12px;
  margin-left: 0;
  padding: 12px 14px;
  background: rgba(30, 41, 59, 0.6);
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.polymarket-inline-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
}

.polymarket-inline-orderbook {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .polymarket-inline-orderbook {
    grid-template-columns: 1fr;
  }
}

.polymarket-inline-table {
  margin: 0;
  font-size: 13px;
}

.polymarket-inline-table thead th {
  padding: 6px 10px 6px 0;
}

.polymarket-inline-table tbody td {
  padding: 4px 10px 4px 0;
}

.polymarket-inline-table .orders-cell-label {
  color: #94a3b8;
  font-size: 12px;
}

.polymarket-inline-loading {
  padding: 8px 0;
  font-size: 13px;
  color: #94a3b8;
}

.polymarket-inline-error {
  margin-top: 12px;
  padding: 12px;
  font-size: 13px;
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
  border-radius: 8px;
}

/* Polymarket 市場連結輸入（掛單區塊內，僅有掛單時顯示） */
.orders-poly-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.orders-poly-link-label {
  font-size: 12px;
  color: #94a3b8;
  flex-shrink: 0;
}

.orders-poly-link-input {
  flex: 1;
  min-width: 180px;
  padding: 6px 10px;
  font-size: 13px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  color: #e2e8f0;
}

.orders-poly-link-input::placeholder {
  color: #64748b;
}

.orders-poly-link-save {
  padding: 6px 12px;
  font-size: 12px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 6px;
  color: #93c5fd;
  cursor: pointer;
}

.orders-poly-link-save:hover {
  background: rgba(59, 130, 246, 0.3);
}

.orders-poly-link-saved {
  font-size: 12px;
  color: #4ade80;
  margin-left: 4px;
}

.orders-poly-link-delete {
  padding: 6px 10px;
  font-size: 12px;
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 6px;
  color: #fca5a5;
  cursor: pointer;
}

.orders-poly-link-delete:hover {
  background: rgba(248, 113, 113, 0.25);
}

/* 與 Poly 比較的安全/危險標示 */
.orders-poly-status {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  margin-right: 8px;
}

.orders-poly-status-safe {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.35);
}

.orders-poly-status-danger {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.orders-auto-btn {
  display: inline-block;
  padding: 4px 8px;
  font-size: 11px;
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 4px;
  cursor: pointer;
  margin-right: 8px;
}

.orders-auto-btn:hover {
  background: rgba(167, 139, 250, 0.22);
}

.auto-trading-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.auto-trading-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  color: #94a3b8;
}

.auto-trading-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
}

.auto-trading-blacklist {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
}

.main-page-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.main-page-tab {
  padding: 10px 20px;
  font-size: 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #94a3b8;
  cursor: pointer;
}

.main-page-tab:hover {
  color: #e2e8f0;
}

.main-page-tab.active {
  color: #a78bfa;
  border-bottom-color: #a78bfa;
}

.score-grinding-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.score-grinding-add-row input,
.score-grinding-add-row select {
  padding: 8px 10px;
  font-size: 13px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  color: #e2e8f0;
}
