/* 4. Positions Screen */
.positions-summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.summary-metrics-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.metric-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.metric-col.right {
  align-items: flex-end;
}

.summary-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.summary-val {
  font-size: 15px;
  font-weight: 900;
  font-family: var(--font-mono);
  margin-top: 2px;
}

.summary-val.large {
  font-size: 18px;
}

.summary-val.green {
  color: #089981;
}

.summary-val.red {
  color: #f23645;
}

.metric-header-group {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.sort-triangles-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 17px;
  margin-bottom: 4px;
  width: 100%;
}

.sort-triangles-spacer {
  height: 13px;
  margin-bottom: 4px;
}

.sort-triangles-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.pos-sort-btn {
  background: var(--input-bg, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--sub-border, rgba(255, 255, 255, 0.1));
  color: var(--text-muted, #787b86);
  font-size: 8px;
  width: 17px;
  height: 13px;
  min-width: unset;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  line-height: 1;
  transition: all 0.15s ease;
  user-select: none;
  outline: none;
}

.pos-sort-btn:hover {
  color: var(--text-primary, #f8fafc);
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border, rgba(255, 255, 255, 0.2));
}

.pos-sort-btn.active {
  color: #ffffff !important;
  background: #2962ff !important;
  border-color: #2962ff !important;
  font-weight: 900;
  box-shadow: 0 0 6px rgba(41, 98, 255, 0.5);
}

.pos-search-wrap input:focus {
  border-color: #2962ff !important;
}

.win-rate-fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 900;
  line-height: 1;
}

.filter-tabs-row {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  box-sizing: border-box;
}

.filter-tabs-row:not(.filter-subtabs-row) {
  margin-bottom: 5px;
}

.filter-tabs-row.filter-subtabs-row {
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.filter-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 6px 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  min-width: 0;
  box-sizing: border-box;
  transition: all 0.15s ease;
  user-select: none;
}

.filter-pill.orders-tab {
  flex: 1.1;
}

.filter-pill.open-tab {
  flex: 1.0;
}

.filter-pill.closed-tab {
  flex: 1.2;
}

.filter-pill.all-tab {
  flex: 0.95;
}

.filter-pill.cancelled-tab {
  flex: 0.8;
  min-width: 68px;
  padding: 4px 6px;
}

.filter-pill.deleted-tab {
  flex: 0.8;
  min-width: 62px;
  padding: 4px 6px;
}

/* Instrument Filter Divider Section (Left-aligned Longs vs Right-aligned Shorts) */
.inst-filter-divider-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 0 8px 0;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
  gap: 8px;
}

.inst-filter-group-left,
.inst-filter-group-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.inst-filter-group-left {
  justify-content: flex-start;
}

.inst-filter-group-right {
  justify-content: flex-end;
}

.filter-pill.inst-pill {
  flex: 0 0 auto;
  padding: 3px 5px;
  height: auto;
  min-height: 33px;
  min-width: 44px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 6px;
  background: var(--card-bg, #1e222d);
  border: 1px solid var(--sub-border, #2a2e39);
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.filter-pill.inst-pill:hover {
  background: var(--input-bg, #2a2e39);
  color: var(--text-primary, #ffffff);
  border-color: #3b82f6;
}

.filter-pill.inst-pill.active,
.filter-pill.inst-pill#pillInst_LUN.active,
.filter-pill.inst-pill#pillInst_LFU.active,
.filter-pill.inst-pill#pillInst_LCE.active,
.filter-pill.inst-pill#pillInst_LPE.active,
.filter-pill.inst-pill#pillInst_SUN.active,
.filter-pill.inst-pill#pillInst_SFU.active,
.filter-pill.inst-pill#pillInst_SCE.active,
.filter-pill.inst-pill#pillInst_SPE.active,
.filter-pill.inst-pill#pillInstUN.active,
.filter-pill.inst-pill#pillInstFU.active,
.filter-pill.inst-pill#pillInstCE.active,
.filter-pill.inst-pill#pillInstPE.active {
  background: rgba(59, 130, 246, 0.2) !important;
  border-color: #3b82f6 !important;
  color: #60a5fa !important;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.4) !important;
}

@media (max-width: 520px) {
  .inst-filter-group-left,
  .inst-filter-group-right {
    gap: 3px;
  }
  .filter-pill.inst-pill {
    padding: 2px 3px;
    min-height: 29px;
    min-width: 36px;
    gap: 1.5px;
  }
  .filter-pill.inst-pill .inst-pill-label {
    font-size: 8.5px;
  }
  .filter-pill.inst-pill .inst-badge {
    font-size: 8.5px;
    padding: 1px 3px;
    min-width: 12px;
  }
}

.filter-pill.inst-pill .inst-pill-label {
  font-family: var(--font-mono, monospace);
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.5px;
  color: var(--text-secondary, #cbd5e1);
}

.filter-pill.inst-pill .inst-badge {
  font-family: var(--font-mono, monospace);
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
  min-width: 14px;
  text-align: center;
  line-height: 1.1;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted, #94a3b8);
}

.filter-pill.inst-pill .inst-badge.has-count {
  background: #2563eb;
  color: #ffffff;
}

.filter-pill.inst-pill.active .inst-badge {
  background: rgba(255, 255, 255, 0.35);
  color: #ffffff;
}

/* Center Capital Blocked Pill (Open Positions Only) */
.filter-pill.inst-pill.center-capital-pill {
  min-width: 58px;
  cursor: default;
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.08);
}

.filter-pill.inst-pill.center-capital-pill .capital-badge {
  color: #38bdf8;
  font-weight: 800;
  font-size: 11px;
  background: transparent;
  padding: 1px 5px;
}

.filter-pill.inst-pill.center-capital-pill .capital-badge.has-count {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}

.filter-pill.inst-pill.center-capital-pill .capital-label {
  color: var(--text-muted, #94a3b8);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* Alert Names Filter Box (Separate border box) */
.pos-alert-filter-box {
  background: rgba(13, 17, 23, 0.45);
  border: 1px solid var(--sub-border, #2a2e39);
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 8px;
  display: flex;
  box-sizing: border-box;
}

.pos-alert-buttons-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.pos-alert-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 8px;
  height: 24px;
  font-size: 10px;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  border-radius: 6px;
  background: var(--card-bg, #1e222d);
  border: 1px solid var(--sub-border, #2a2e39);
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  line-height: 1;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.pos-alert-pill span:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: left;
}

.pos-alert-pill:hover {
  background: var(--input-bg, #2a2e39);
  border-color: #3b82f6;
  color: var(--text-primary, #ffffff);
}

.pos-alert-pill.active {
  background: rgba(59, 130, 246, 0.2) !important;
  border-color: #3b82f6 !important;
  color: #60a5fa !important;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.4) !important;
}

.pos-alert-pill .pos-alert-badge {
  font-size: 9px;
  font-weight: 800;
  font-family: var(--font-mono, monospace);
  padding: 1px 4px;
  border-radius: 4px;
  background: #2563eb;
  color: #ffffff;
  line-height: 1.1;
}

.pos-alert-pill.active .pos-alert-badge {
  background: rgba(255, 255, 255, 0.35);
  color: #ffffff;
}

.pos-alert-pill .pos-alert-clear {
  color: #f87171;
  font-size: 10px;
  margin-left: 2px;
  opacity: 0.85;
  pointer-events: none;
}

.pos-alert-pill:hover .pos-alert-clear {
  opacity: 1;
}

body.light-theme .pos-alert-filter-box {
  background: #f8fafc;
  border-color: #cbd5e1;
}

body.light-theme .pos-alert-pill {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

body.light-theme .pos-alert-pill.active {
  background: #eff6ff !important;
  border-color: #3b82f6 !important;
  color: #1d4ed8 !important;
}

body.light-theme .filter-pill.inst-pill {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #64748b;
}

body.light-theme .filter-pill.inst-pill .inst-badge {
  background: rgba(0, 0, 0, 0.08);
  color: #475569;
}

.subtabs-spacer {
  flex: 2.15;
}

.filter-pill .portfolio-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.filter-pill .portfolio-tab-name {
  flex: 1;
  min-width: 0;
  text-align: left;
  overflow: visible;
  white-space: nowrap;
  font-size: 10.5px;
}

.filter-pill .portfolio-tab-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
  min-width: 12px;
  text-align: center;
  transition: all 0.2s ease;
}

body.light-theme .filter-pill .portfolio-tab-badge {
  background: rgba(0, 0, 0, 0.08);
  color: #94a3b8;
}

.filter-pill:hover {
  background: var(--input-bg);
  color: var(--text-primary);
  border-color: var(--sub-border);
}

.filter-pill.active {
  background: rgba(41, 98, 255, 0.14);
  border-color: #2962ff;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(41, 98, 255, 0.25);
}

/* Badges with positions > 0: Bold White on Vibrant Blue (matching All) */
.filter-pill .portfolio-tab-badge.has-count,
.filter-pill .portfolio-tab-badge[data-count]:not([data-count="0"]) {
  background: #2962ff !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  box-shadow: 0 1px 4px rgba(41, 98, 255, 0.45);
}

/* Badges with 0: Muted even when filter pill is active */
.filter-pill .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])),
.filter-pill.active .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])) {
  background: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-muted) !important;
  box-shadow: none !important;
}

body.light-theme .filter-pill .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])),
body.light-theme .filter-pill.active .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])) {
  background: rgba(0, 0, 0, 0.08) !important;
  color: #94a3b8 !important;
  box-shadow: none !important;
}

@media (max-width: 380px) {
  .filter-tabs-row {
    gap: 3px;
  }

  .filter-pill {
    padding: 5px 4px;
    font-size: 10px;
    gap: 3px;
  }

  .filter-pill .portfolio-tab-name {
    font-size: 9.5px;
  }

  .filter-pill .portfolio-tab-badge {
    padding: 1px 3px;
    font-size: 8px;
    min-width: 10px;
  }
}

.clear-broom-btn {
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--sell-red);
  background: var(--sell-red-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.clear-broom-btn:hover {
  background: rgba(242, 54, 69, 0.3);
}

.positions-empty-box {
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.positions-empty-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.positions-empty-sub {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 18px;
  max-width: 320px;
  text-align: center;
}

.position-item-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  content-visibility: auto;
  contain-intrinsic-size: auto 120px;
  contain: layout style paint;
  transform: translateZ(0);
}

.position-item-card.pending {
  border: 1.5px solid #2962ff !important;
}

.pos-detail-val.blue {
  color: #2962ff !important;
  font-weight: 800;
}

.pos-trade-id-badge {
  font-size: 10px;
  font-weight: 800;
  color: #2962ff;
  background: rgba(41, 98, 255, 0.14);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(41, 98, 255, 0.35);
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
  user-select: text !important;
  -webkit-user-select: text !important;
  cursor: text;
}

.pos-row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  width: 100%;
}

.pos-symbol-col {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.pos-sym-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 100%;
}

.pos-sym-name {
  font-size: 14.5px;
  font-weight: 900;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: block;
  user-select: text !important;
  -webkit-user-select: text !important;
  cursor: text;
}

.pos-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  max-width: 100%;
  flex-wrap: nowrap;
}

.pos-tv-sym {
  user-select: text !important;
  -webkit-user-select: text !important;
  cursor: text;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.pos-pnl-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
  margin-top: 6px;
}

.pos-pnl-pct {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1.2;
}

.pos-pnl-pct.green {
  color: #089981;
}

.pos-pnl-pct.red {
  color: #f23645;
}

.pos-pnl-val {
  font-size: 15px;
  font-weight: 900;
  font-family: var(--font-mono);
  margin-top: 2px;
  line-height: 1.2;
}

.pos-pnl-val.green {
  color: #089981;
}

.pos-pnl-val.red {
  color: #f23645;
}

.badge-side {
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-side.buy {
  background: rgba(56, 189, 248, 0.14);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-side.sell {
  background: rgba(251, 146, 60, 0.14);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.35);
}

.badge-status {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-status.open {
  background: rgba(167, 139, 250, 0.14);
  color: #a78bfa;
  border: 1px solid rgba(167, 139, 250, 0.35);
}

.badge-status.closed {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.badge-status.pending {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-status.cancelled {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-status.deleted {
  background: rgba(220, 38, 38, 0.14);
  color: #f87171;
  border: 1px solid rgba(220, 38, 38, 0.4);
}

.pos-details-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}

.pos-detail-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.pos-detail-lbl {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.pos-detail-val {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.pos-detail-val.symbol-price {
  font-size: 13.5px !important;
  font-family: var(--font-mono) !important;
  margin-top: 2px;
}

.tick-time {
  font-size: 8.5px;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.85;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  user-select: none;
  margin-right: 4px;
}

.tick-time.replay-time {
  color: #f59e0b;
  font-family: inherit;
  font-size: 8px;
  letter-spacing: 0px;
  font-weight: 700;
  opacity: 0.95;
}

/* Suppress tick timestamp and tick arrows on closed & deleted positions */
.position-item-card.closed .tick-time,
.position-item-card.closed .tick-arrow,
.position-item-card.deleted .tick-time,
.position-item-card.deleted .tick-arrow,
[data-status="CLOSED"] .tick-time,
[data-status="CLOSED"] .tick-arrow,
[data-status="DELETED"] .tick-time,
[data-status="DELETED"] .tick-arrow {
  display: none !important;
}

.pos-targets-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  font-weight: 800;
  width: 100%;
  box-sizing: border-box;
}

.pos-targets-row > :nth-child(1) {
  justify-self: start;
}

.pos-targets-row > :nth-child(2) {
  justify-self: center;
}

.pos-targets-row > :nth-child(3) {
  justify-self: end;
}

.pos-targets-badges-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
  width: 100%;
  box-sizing: border-box;
}

.pos-target-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.pos-timestamp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
}

.pos-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  width: 100%;
  box-sizing: border-box;
}

.pos-actions-row .tool-btn {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--input-bg);
  border: 1px solid var(--sub-border);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
  line-height: 1.2;
}

.pos-btn-modify {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.08);
  transition: all 0.2s ease;
}

.pos-btn-modify.green {
  color: var(--buy-green) !important;
  border-color: rgba(8, 153, 129, 0.45) !important;
  background: var(--buy-green-bg) !important;
}

.pos-btn-modify.green:hover {
  background: rgba(8, 153, 129, 0.25) !important;
  border-color: var(--buy-green) !important;
}

.pos-btn-modify.red {
  color: var(--sell-red) !important;
  border-color: rgba(242, 54, 69, 0.45) !important;
  background: var(--sell-red-bg) !important;
}

.pos-btn-modify.red:hover {
  background: rgba(242, 54, 69, 0.25) !important;
  border-color: var(--sell-red) !important;
}

.pos-btn-close {
  color: var(--sell-red);
  border-color: rgba(242, 54, 69, 0.45);
  background: var(--sell-red-bg);
  transition: all 0.2s ease;
}

.pos-btn-close.green {
  color: var(--buy-green) !important;
  border-color: rgba(8, 153, 129, 0.45) !important;
  background: var(--buy-green-bg) !important;
}

.pos-btn-close.green:hover {
  background: rgba(8, 153, 129, 0.25) !important;
  border-color: var(--buy-green) !important;
}

.pos-btn-close.red {
  color: var(--sell-red) !important;
  border-color: rgba(242, 54, 69, 0.45) !important;
  background: var(--sell-red-bg) !important;
}

.pos-btn-close.red:hover {
  background: rgba(242, 54, 69, 0.25) !important;
  border-color: var(--sell-red) !important;
}

.pos-btn-reopen {
  color: var(--buy-green);
  border-color: rgba(8, 153, 129, 0.45);
  background: var(--buy-green-bg);
  transition: all 0.2s ease;
}

.pos-btn-reopen.green {
  color: var(--buy-green) !important;
  border-color: rgba(8, 153, 129, 0.45) !important;
  background: var(--buy-green-bg) !important;
}

.pos-btn-reopen.green:hover {
  background: rgba(8, 153, 129, 0.25) !important;
  border-color: var(--buy-green) !important;
}

.pos-btn-reopen.red {
  color: var(--sell-red) !important;
  border-color: rgba(242, 54, 69, 0.45) !important;
  background: var(--sell-red-bg) !important;
}

.pos-btn-reopen.red:hover {
  background: rgba(242, 54, 69, 0.25) !important;
  border-color: var(--sell-red) !important;
}

.pos-btn-delete {
  color: var(--sell-red);
  border-color: rgba(242, 54, 69, 0.45);
  background: var(--sell-red-bg);
  transition: all 0.2s ease;
}

.pos-btn-delete.green {
  color: var(--buy-green) !important;
  border-color: rgba(8, 153, 129, 0.45) !important;
  background: var(--buy-green-bg) !important;
}

.pos-btn-delete.green:hover {
  background: rgba(8, 153, 129, 0.25) !important;
  border-color: var(--buy-green) !important;
}

.pos-btn-delete.red {
  color: var(--sell-red) !important;
  border-color: rgba(242, 54, 69, 0.45) !important;
  background: var(--sell-red-bg) !important;
}

.pos-btn-delete.red:hover {
  background: rgba(242, 54, 69, 0.25) !important;
  border-color: var(--sell-red) !important;
}

.pos-btn-history {
  color: var(--text-secondary);
  border-color: var(--sub-border);
  background: var(--input-bg);
  transition: all 0.2s ease;
}

.pos-btn-history:hover {
  color: var(--accent-blue) !important;
  border-color: rgba(56, 189, 248, 0.45) !important;
  background: rgba(56, 189, 248, 0.12) !important;
}

/* Portfolio Switcher Styles (3 Columns x 2 Rows Grid) */
.portfolio-switcher-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  padding: 0 2px;
  width: 100%;
  box-sizing: border-box;
}

.portfolio-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1px;
}

.portfolio-header-label {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Standalone iOS Toggle Switch for SEBI PnL Deduction */
.sebi-toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 38px;
  height: 20px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  margin: 0 8px;
  flex-shrink: 0;
}

.sebi-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.sebi-toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #d1d5db;
  border-radius: 20px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.sebi-toggle-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #475569;
  border-radius: 50%;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.sebi-toggle-switch input:checked + .sebi-toggle-slider {
  background-color: #089981;
}

.sebi-toggle-switch input:checked + .sebi-toggle-slider::before {
  transform: translateX(18px);
  background-color: #ffffff;
}

.portfolio-tabs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.portfolio-tab-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 7px 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.portfolio-tab-pill:hover {
  background: var(--input-bg);
  color: var(--text-primary);
  border-color: var(--sub-border);
}

.portfolio-tab-pill.active {
  background: rgba(41, 98, 255, 0.14);
  border-color: #2962ff;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(41, 98, 255, 0.25);
}

.portfolio-tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  background: var(--text-muted) !important;
}

.portfolio-tab-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.portfolio-tab-badge {
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
  min-width: 14px;
  text-align: center;
  transition: all 0.2s ease;
}

.portfolio-export-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  padding-right: 2px;
}

.portfolio-winrate-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--sub-border, rgba(255, 255, 255, 0.12));
  user-select: none;
  height: 24px;
  box-sizing: border-box;
  cursor: default;
}

.portfolio-winrate-badge .winrate-num {
  color: #089981;
  font-weight: 800;
}

.portfolio-winrate-badge .winrate-slash {
  color: #f23645;
  font-weight: 800;
  margin: 0 4px;
}

.portfolio-winrate-badge .winrate-den {
  color: var(--text-primary, #f8fafc);
  font-weight: 800;
}

.portfolio-export-xlsx-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #10b981;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  height: 24px;
}

.portfolio-export-xlsx-badge:hover {
  background: rgba(16, 185, 129, 0.28);
  border-color: #10b981;
  color: #ffffff;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

.portfolio-export-xlsx-badge:active {
  transform: translateY(0);
}

body.light-theme .portfolio-tab-badge {
  background: rgba(0, 0, 0, 0.08);
  color: #94a3b8;
}

/* Badges with positions > 0: Bold White on Vibrant Blue (matching All) */
.portfolio-tab-badge.has-count,
.portfolio-tab-pill .portfolio-tab-badge.has-count,
#pillPortfolioAll .portfolio-tab-badge.has-count,
.portfolio-tab-badge[data-count]:not([data-count="0"]),
.portfolio-tab-pill .portfolio-tab-badge[data-count]:not([data-count="0"]),
#pillPortfolioAll .portfolio-tab-badge[data-count]:not([data-count="0"]) {
  background: #2962ff !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  box-shadow: 0 1px 4px rgba(41, 98, 255, 0.45);
}

/* Badges with 0 positions: Muted even when pill is active */
.portfolio-tab-pill .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])),
.portfolio-tab-pill.active .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])),
#pillPortfolioAll .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])),
#pillPortfolioAll.active .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])) {
  background: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-muted) !important;
  box-shadow: none !important;
}

body.light-theme .portfolio-tab-pill .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])),
body.light-theme .portfolio-tab-pill.active .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])),
body.light-theme #pillPortfolioAll .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])),
body.light-theme #pillPortfolioAll.active .portfolio-tab-badge:not(.has-count):not([data-count]:not([data-count="0"])) {
  background: rgba(0, 0, 0, 0.08) !important;
  color: #94a3b8 !important;
  box-shadow: none !important;
}

#pillPortfolioAll {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 800;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

#pillPortfolioAll .portfolio-tab-dot {
  width: 6px;
  height: 6px;
}

#pillPortfolioAll .portfolio-tab-name {
  font-size: 10.5px;
  font-weight: 800;
  margin-right: 2px;
}

#pillPortfolioAll .portfolio-tab-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 12px;
}

#pillPortfolioAll.active {
  background: rgba(41, 98, 255, 0.14);
  border-color: #2962ff;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(41, 98, 255, 0.25);
}

.portfolio-manage-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--input-bg);
  border: 1px solid var(--sub-border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.portfolio-manage-btn:hover {
  background: var(--card-bg);
  color: var(--text-primary);
  border-color: var(--accent);
}

.portfolio-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--sub-border);
  border-radius: 8px;
  margin-bottom: 8px;
  gap: 8px;
}

.portfolio-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.portfolio-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Modal Reset Action Buttons */
.modal-reset-action-btn {
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.modal-reset-action-btn * {
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .modal-reset-action-btn:hover:not(:disabled) {
    filter: brightness(1.15);
    transform: translateY(-1px);
  }
}

.modal-reset-action-btn:active:not(:disabled) {
  transform: scale(0.98);
  filter: brightness(1.2);
}

.modal-reset-action-btn:disabled {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  filter: grayscale(0.5);
  pointer-events: none;
}


