/* ==========================================================================
   Capitally Trade Log Popover — Stylesheet & Design Tokens (Variant 1)
   Specification: TRADE_LOG_POPOVER_INTEGRATION_SPEC.md
   ========================================================================== */

/* ---------------- Design Tokens (Scoped to Popover & Calendar Layers) ---------------- */
.pop-backdrop,
.pop-layer,
.cal-layer {
  --bg: #ffffff;
  --surface: #ffffff;
  --fg: #0a0a0a;
  --muted: #8a8a8a;
  --muted-2: #adadad;
  --border: #e6e6e6;
  --border-strong: #d4d4d4;
  --field: #fafafa;
  --accent: #0a0a0a;
  --accent-fg: #ffffff;
  --ring: rgba(10, 10, 10, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 16px 40px -12px rgba(0, 0, 0, 0.18), 0 4px 12px -4px rgba(0, 0, 0, 0.08);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html[data-theme="dark"] .pop-backdrop,
html[data-theme="dark"] .pop-layer,
html[data-theme="dark"] .cal-layer,
body[data-theme="dark"] .pop-backdrop,
body[data-theme="dark"] .pop-layer,
body[data-theme="dark"] .cal-layer,
.dark .pop-backdrop,
.dark .pop-layer,
.dark .cal-layer {
  --bg: #0a0a0a;
  --surface: #0e0e0e;
  --fg: #fafafa;
  --muted: #8f8f8f;
  --muted-2: #6b6b6b;
  --border: #232323;
  --border-strong: #333333;
  --field: #161616;
  --accent: #fafafa;
  --accent-fg: #0a0a0a;
  --ring: rgba(250, 250, 250, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -12px rgba(0, 0, 0, 0.6), 0 4px 14px -4px rgba(0, 0, 0, 0.4);
}

/* ==================== BACKDROP & POPOVER CONTAINER ==================== */
.pop-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 49;
}
html[data-theme="dark"] .pop-backdrop,
.dark .pop-backdrop {
  background: rgba(0, 0, 0, 0.45);
}
.pop-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.pop-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
.pop-layer.open {
  pointer-events: auto;
}

.popover {
  position: absolute;
  width: 328px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transform-origin: top center;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.92) translateY(-6px);
  display: flex;
  flex-direction: column;
}

.popover.arrow-up::before {
  content: "";
  position: absolute;
  top: -7px;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%) rotate(45deg);
  width: 13px;
  height: 13px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-radius: 2px 0 0 0;
  transition: left 0.2s ease;
}
.popover.arrow-down::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%) rotate(45deg);
  width: 13px;
  height: 13px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 2px 0;
  transition: left 0.2s ease;
}

.popover.pop-in {
  visibility: visible;
  animation: popIn 0.38s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.popover.pop-out {
  visibility: visible;
  animation: popOut 0.16s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.9) translateY(-8px); }
  55% { opacity: 1; transform: scale(1.015) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes popOut {
  0% { opacity: 1; transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(0.95) translateY(-4px); }
}

/* ==================== HEADER & DOTS ==================== */
.pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.head-title-wrap { display: flex; flex-direction: column; }
.head-title { font-size: 12.5px; font-weight: 600; color: var(--fg); }
.head-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

.dots { display: flex; gap: 5px; align-items: center; }
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background 0.25s ease, transform 0.2s ease, width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.dot.done {
  background: var(--fg);
  cursor: pointer;
}
.dot.done:hover {
  transform: scale(1.4);
}
.dot.active {
  background: var(--fg);
  width: 18px;
  border-radius: 3px;
}

.icon-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--field); color: var(--fg); }
.icon-btn svg { width: 13px; height: 13px; }

/* ==================== BODY & STEP TRANSITIONS ==================== */
.pop-body-clip {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  flex: none;
}
.pop-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pop-body.leave-next { animation: leaveNext 0.16s ease forwards; }
.pop-body.leave-back { animation: leaveBack 0.16s ease forwards; }
.pop-body.enter-next { animation: enterNext 0.26s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.pop-body.enter-back { animation: enterBack 0.26s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes leaveNext { to { opacity: 0; transform: translateX(-14px); } }
@keyframes leaveBack { to { opacity: 0; transform: translateX(14px); } }
@keyframes enterNext { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: translateX(0); } }
@keyframes enterBack { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: translateX(0); } }

/* ==================== FORM FIELDS & CONTROLS ==================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.field input {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 13px;
  padding: 8.5px 10px;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}
.field input::placeholder { color: var(--muted-2); }
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
.field input.err {
  border-color: var(--fg);
  animation: shake 0.32s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
.err-text {
  font-size: 10.5px;
  color: var(--fg);
  display: none;
  align-items: center;
  gap: 4px;
}
.err-text.show { display: flex; }
.err-text svg { width: 10px; height: 10px; flex: none; }

/* ==================== SYMBOL AUTOCOMPLETE DROPDOWN ==================== */
.field-symbol { position: relative; }
.symbol-input-wrap {
  position: relative;
  width: 100%;
}
.symbol-input-wrap input {
  padding-right: 32px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.symbol-search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.symbol-search-icon svg { width: 13px; height: 13px; }
.symbol-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 190px;
  overflow-y: auto;
  z-index: 250;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
}
.symbol-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--fg);
  cursor: pointer;
  transition: background 0.12s ease;
  user-select: none;
}
.symbol-item:hover,
.symbol-item.selected {
  background: var(--field);
}
.symbol-item-name {
  font-weight: 600;
  letter-spacing: 0.02em;
}
.symbol-item-tag {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--field);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
}
.symbol-item.create-new {
  color: #10b981;
  font-weight: 500;
  border-top: 1px dashed var(--border);
  margin-top: 2px;
  padding-top: 8px;
}
.symbol-item.create-new:hover,
.symbol-item.create-new.selected {
  background: rgba(16, 185, 129, 0.1);
}
.symbol-dropdown-empty {
  padding: 10px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Segmented Control */
.seg {
  display: flex;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}
.seg button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.18s cubic-bezier(0.4, 0, 0.2, 1), color 0.18s ease, box-shadow 0.18s ease;
}
.seg button.active {
  background: var(--surface);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border);
}

/* Direction Cards */
.cards2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dir-card {
  border: 1px solid var(--border);
  background: var(--field);
  border-radius: 9px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}
.dir-card:active { transform: scale(0.98); }
.dir-card.active {
  border-color: var(--fg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--fg);
}
.dir-card svg { width: 15px; height: 15px; }
.dir-card span { font-size: 12px; font-weight: 600; }

/* Position Status Cards */
.status-cards { display: flex; flex-direction: column; gap: 9px; }
.status-card {
  border: 1px solid var(--border);
  background: var(--field);
  border-radius: 10px;
  padding: 11px 12px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.status-card:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}
.status-card:active { transform: scale(0.985); }
.status-card.active {
  border-color: var(--fg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--fg);
}
.status-card-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin-top: 1px;
  color: var(--fg);
}
.status-card.active .status-card-icon {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.status-card-icon svg { width: 13px; height: 13px; }
.live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulseGlow 2s infinite ease-in-out;
}
@keyframes pulseGlow {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.status-card-info { flex: 1; display: flex; flex-direction: column; gap: 2.5px; }
.status-card-title { font-size: 12px; font-weight: 600; color: var(--fg); }
.status-card-desc { font-size: 11px; color: var(--muted); line-height: 1.35; }
.status-radio {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  flex: none;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.status-card.active .status-radio {
  border-color: var(--fg);
  background: var(--fg);
}
.status-card.active .status-radio::after {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--bg);
}

/* Note Callout */
.note {
  display: flex;
  gap: 8px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}
.note svg { width: 13px; height: 13px; flex: none; margin-top: 1px; color: var(--muted); }

/* ==================== LIVE REALIZED P&L PREVIEW ==================== */
.pnl-preview {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  display: none;
  flex-direction: column;
  gap: 5px;
  transition: all 0.2s ease;
}
.pnl-preview.show { display: flex; }
.pnl-preview.profit {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.06);
}
.pnl-preview.loss {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.06);
}
html[data-theme="dark"] .pnl-preview.profit,
.dark .pnl-preview.profit { background: rgba(16, 185, 129, 0.1); }
html[data-theme="dark"] .pnl-preview.loss,
.dark .pnl-preview.loss { background: rgba(239, 68, 68, 0.1); }

.pnl-preview-head { display: flex; align-items: center; justify-content: space-between; }
.pnl-preview-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pnl-preview-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.pnl-preview-badge.long-badge { background: rgba(16, 185, 129, 0.14); color: #10b981; }
.pnl-preview-badge.short-badge { background: rgba(239, 68, 68, 0.14); color: #ef4444; }
html[data-theme="dark"] .pnl-preview-badge.long-badge,
.dark .pnl-preview-badge.long-badge { color: #34d399; }
html[data-theme="dark"] .pnl-preview-badge.short-badge,
.dark .pnl-preview-badge.short-badge { color: #f87171; }

.pnl-preview-row { display: flex; align-items: baseline; gap: 7px; }
.pnl-preview-amount {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.pnl-preview-amount.profit { color: #10b981; }
.pnl-preview-amount.loss { color: #ef4444; }
html[data-theme="dark"] .pnl-preview-amount.profit,
.dark .pnl-preview-amount.profit { color: #34d399; }
html[data-theme="dark"] .pnl-preview-amount.loss,
.dark .pnl-preview-amount.loss { color: #f87171; }

.pnl-preview-pct { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pnl-preview-pct.profit { color: #10b981; }
.pnl-preview-pct.loss { color: #ef4444; }
html[data-theme="dark"] .pnl-preview-pct.profit,
.dark .pnl-preview-pct.profit { color: #34d399; }
html[data-theme="dark"] .pnl-preview-pct.loss,
.dark .pnl-preview-pct.loss { color: #f87171; }

.pnl-preview-meta { font-size: 10.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }

/* ==================== TAGS CLOUD SECTION ==================== */
.tags-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1px; }
.tags-count-badge {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--field);
  border: 1px solid var(--border);
  padding: 2.5px 8px;
  border-radius: 100px;
  font-variant-numeric: tabular-nums;
  transition: all 0.15s ease;
}
.tags-count-badge.has-selected {
  color: var(--fg);
  border-color: var(--border-strong);
  background: var(--surface);
}
.tag-search-box { position: relative; display: flex; align-items: center; }
.tag-search-icon {
  position: absolute;
  left: 10px;
  width: 13px;
  height: 13px;
  color: var(--muted);
  pointer-events: none;
}
.tag-search-input {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 12.5px;
  padding: 8px 10px 8px 30px;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}
.tag-search-input::placeholder { color: var(--muted-2); }
.tag-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
.tags-catalog {
  display: flex;
  flex-direction: column;
  gap: 11px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}
.tag-group { display: flex; flex-direction: column; gap: 6px; }
.tag-group-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tag-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pill {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}
.tag-pill:hover { border-color: var(--border-strong); color: var(--fg); background: var(--surface); }
.tag-pill:active { transform: scale(0.96); }
.tag-pill.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.tag-pill svg { width: 11px; height: 11px; stroke-width: 2.5; }

.add-custom-tag-btn {
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--fg);
  font-size: 11.5px;
  font-weight: 500;
  padding: 6.5px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.add-custom-tag-btn:hover { background: var(--field); border-color: var(--fg); }

/* ==================== FOOTER & BUTTONS ==================== */
.pop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  flex: none;
}
.btn {
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8.5px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s ease, transform 0.12s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--fg); }
.btn-ghost:hover { background: var(--field); }
.btn-ghost:disabled { opacity: 0; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-fg); flex: 1; }
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.55; pointer-events: none; }
.btn-primary svg { width: 13px; height: 13px; }

.spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  animation: spin 0.6s linear infinite;
}
html[data-theme="dark"] .spinner,
.dark .spinner {
  border-color: rgba(10, 10, 10, 0.35);
  border-top-color: currentColor;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== CELEBRATION, CONFETTI & SUMMARY ==================== */
.success-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 34px 16px 28px;
  position: relative;
}
.confetti-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.check-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1.6px solid var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.check-ring svg { width: 24px; height: 24px; }
.check-ring circle {
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.6;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: drawRing 0.45s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.check-ring path {
  fill: none;
  stroke: var(--fg);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: drawCheck 0.28s ease forwards 0.42s;
}
@keyframes drawRing { to { stroke-dashoffset: 0; } }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }

.success-title {
  font-size: 13.5px;
  font-weight: 700;
  opacity: 0;
  animation: fadeUp 0.3s ease forwards 0.55s;
  z-index: 1;
}
.success-sub {
  font-size: 11.5px;
  color: var(--muted);
  opacity: 0;
  animation: fadeUp 0.3s ease forwards 0.62s;
  text-align: center;
  z-index: 1;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.success-summary {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  opacity: 0;
  animation: fadeUp 0.3s ease forwards 0.72s;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
}
.summary-left { display: flex; align-items: center; gap: 9px; }
.summary-symbol { font-size: 12.5px; font-weight: 700; }
.summary-dir {
  font-size: 9px;
  font-weight: 600;
  padding: 2.5px 7px;
  border-radius: 100px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.summary-dir.long-dir { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.summary-dir.short-dir { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
html[data-theme="dark"] .summary-dir.long-dir,
.dark .summary-dir.long-dir { background: rgba(16, 185, 129, 0.15); color: #34d399; }
html[data-theme="dark"] .summary-dir.short-dir,
.dark .summary-dir.short-dir { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.summary-pnl { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-pnl.profit-text { color: #10b981; }
.summary-pnl.loss-text { color: #ef4444; }
html[data-theme="dark"] .summary-pnl.profit-text,
.dark .summary-pnl.profit-text { color: #34d399; }
html[data-theme="dark"] .summary-pnl.loss-text,
.dark .summary-pnl.loss-text { color: #f87171; }

.summary-status-open {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 100px;
}
.summary-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* ==================== EMBEDDED CUSTOM CALENDAR ==================== */
.date-wrap { position: relative; }
.date-input { cursor: pointer; padding-right: 34px !important; }
.date-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}
.cal-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  transition: background-color 0.2s ease;
}
.cal-layer.open { pointer-events: auto; }
@media (max-width: 640px) {
  .cal-layer.open {
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
}
.cal-pop {
  position: absolute;
  width: 264px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.94) translateY(-6px);
  transform-origin: top left;
  box-sizing: border-box;
}
.cal-pop.pop-in { visibility: visible; animation: popIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.cal-pop.pop-out { visibility: visible; animation: popOut 0.14s cubic-bezier(0.4, 0, 1, 1) forwards; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--fg); }
.cal-nav {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--fg);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.cal-nav:hover { border-color: var(--border-strong); background: var(--surface); }
.cal-nav svg { width: 12px; height: 12px; }
.cal-banner {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.cal-banner strong { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px; }
.cal-week span { font-size: 10px; font-weight: 600; color: var(--muted-2); text-align: center; padding: 4px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
  width: 100%;
  aspect-ratio: 1;
  border: none;
  background: transparent;
  color: var(--fg);
  font-size: 11.5px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
  font-variant-numeric: tabular-nums;
}
.cal-day:hover { background: var(--field); }
.cal-day.muted { color: var(--muted-2); opacity: 0.45; }
.cal-day.today { box-shadow: inset 0 0 0 1px var(--border-strong); }
.cal-day.selected { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.cal-day:disabled, .cal-day.disabled {
  color: var(--muted-2) !important;
  opacity: 0.25 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  background: transparent !important;
}
.cal-day.in-range { font-weight: 600; }
.cal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.cal-link-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 6px;
  transition: background 0.12s ease, color 0.12s ease;
}
.cal-link-btn:hover { background: var(--field); color: var(--fg); }

/* ==================== MOBILE BOTTOM SHEET (≤640px) ==================== */
@media (max-width: 640px) {
  .popover {
    position: fixed !important;
    bottom: 0 !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    transform-origin: bottom center !important;
    max-height: 90vh !important;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .popover::before, .popover::after { display: none !important; }
  .popover.pop-in { animation: sheetIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
  .popover.pop-out { animation: sheetOut 0.18s ease forwards; }

  @keyframes sheetIn {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  @keyframes sheetOut {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(100%); opacity: 0; }
  }
  .drag-handle {
    display: flex;
    justify-content: center;
    padding: 9px 0 3px;
    flex: none;
    cursor: grab;
  }
  .drag-bar {
    width: 38px;
    height: 4.5px;
    border-radius: 100px;
    background: var(--border-strong);
  }
  .pop-head { padding: 12px 18px 12px; }
  .pop-body { padding: 16px 18px; }
  .pop-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0)); }
  .btn { padding: 12px 16px; font-size: 13.5px; }
  .status-card { padding: 13px 13px; }
}

@media (min-width: 641px) {
  .drag-handle { display: none; }
}
