
/* ── Trade Log widget order dropdown ───────────────────────────────── */
.tl-order-dropdown {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  z-index: 40;
  padding: 0.375rem 0;
  min-width: 14rem;
  max-height: 22rem;
  overflow-y: auto;
}

.tl-order-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: default;
  transition: background 0.1s;
}
.tl-order-row:hover { background: var(--bg-surface); }

.tl-order-grip {
  color: var(--text-faint);
  cursor: grab;
  flex-shrink: 0;
}
.tl-order-grip:active { cursor: grabbing; }

.tl-order-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-order-toggle {
  width: 2rem;
  height: 1.125rem;
  border-radius: 9999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-sub);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.tl-order-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.15s;
}
.tl-order-toggle--on {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-border);
}
.tl-order-toggle--on::after {
  transform: translateX(0.875rem);
  background: var(--green);
}
.tl-order-toggle:hover { border-color: rgba(255,255,255,0.12); }
.tl-order-toggle--on:hover { border-color: var(--btn-primary-border); }

.tl-order-ghost {
  opacity: 0.5;
}

/* ── Add Trade compact inputs ────────────────────────────────────────── */
.ti-inp {
  max-width: 10rem;
}

/* Vertical rhythm for trade log widget headers: 12px above the eyebrow label, 16px gap to first content row */
.tl-widget .widget-handle { padding-top: 0.75rem; padding-bottom: 0.5rem; }
.tl-widget .widget-body   { padding-top: 0.5rem; }

/* Inline single-row layout (V2 10-column bar) */
.ti-row {
  display: grid;
  grid-template-columns:
    110px
    minmax(90px, 1fr) auto
    130px
    90px
    78px
    78px
    110px
    110px
    90px;
  gap: 0.4rem;
  align-items: end;
}
/* 11-track grid when stop-mode is active */
.ti-row.stop-mode {
  grid-template-columns:
    110px
    minmax(90px, 1fr) auto
    130px
    80px
    90px
    78px
    78px
    110px
    110px
    90px;
}
.ti-row .ti-field { min-width: 0; }
.ti-row .trade-label { margin-bottom: 0.2rem; font-size: 0.6875rem; }
.ti-row .trade-inp { max-width: none; font-size: 0.8125rem; padding: 0.45rem 0.625rem; min-height: 2.25rem; }

/* Computed (read-only auto-calculated) input */
.ti-inp.computed {
  background: var(--bg-base);
  color: var(--text-faint);
  cursor: default;
  border-color: var(--border);
}

/* ── Add Trade gear button + settings panel ─────────────────────────────── */
.ti-gear-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.ti-gear-btn:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

.ti-clear-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-faint);
  cursor: pointer;
  padding: 0.15rem 0.55rem;
  border-radius: var(--rm);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.3;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.ti-clear-btn:hover {
  color: var(--text);
  border-color: var(--text-faint);
  background: var(--bg-elevated);
}

.ti-settings-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 280px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  padding: 0.75rem;
  z-index: 30;
}

/* Symbol + chart-toggle combo column */
.ti-field.combo {
  grid-column: span 2;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem;
  align-items: end;
}
.ti-field.combo > .field-inner {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

/* Chart toggle icon button */
.chart-toggle {
  height: 2.25rem;
  padding: 0 0.55rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  white-space: nowrap;
}
.chart-toggle:hover:not(:disabled) { color: var(--text-primary); border-color: var(--border-sub); }
.chart-toggle:disabled { opacity: 0.35; cursor: default; }
.chart-toggle.open {
  background: rgba(96,165,250,0.12);
  border-color: rgba(96,165,250,0.4);
  color: #60a5fa;
}
.chart-toggle.stale {
  background: rgba(245,158,11,0.10);
  border-color: rgba(245,158,11,0.4);
  color: var(--orange);
}
.chart-toggle svg,
.chart-toggle [data-lucide] { width: 14px; height: 14px; flex-shrink: 0; }
.chart-toggle-label { white-space: nowrap; }

/* Expandable chart panel */
.chart-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  margin-top: 0.5rem;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.22s ease, opacity 0.18s ease;
}
.chart-panel.open {
  max-height: 520px;
  opacity: 1;
}
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.chart-head .phase { flex: 1; display: flex; align-items: center; gap: 0.5rem; }
.chart-head .phase #ti-phase-text { display: flex; align-items: center; justify-content: flex-start; gap: 0.4rem; }
.ti-phase-group { display: inline-flex; align-items: center; gap: 0.35rem; }
#ti-phase-dot { display: none; }
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
.dot.entry { background: var(--green); }
.dot.exit  { background: var(--red); }
.dot.done  { background: #60a5fa; animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Phase prompt -- chronological stepper (Concept A) */
.ti-stepper { display: inline-flex; align-items: center; gap: 0.35rem; }
.ti-step {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.55rem 0.2rem 0.3rem;
  border-radius: var(--rm);
  border: 1px solid transparent;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; line-height: 1.2;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ti-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.1rem; height: 1.1rem;
  border-radius: var(--rm);
  font-size: 0.6875rem; font-weight: 700;
}
.ti-step-check { font-size: 0.75rem; margin-left: 0.1rem; }
.ti-step-sep { width: 0.5rem; height: 1px; background: var(--border); flex-shrink: 0; }
/* Pending: outlined gray, dimmed */
.ti-step--pending {
  background: transparent;
  border-color: var(--border);
  color: var(--text-faint);
  opacity: 0.65;
}
.ti-step--pending .ti-step-num { background: rgba(255,255,255,0.06); color: var(--text-faint); }
/* Active: blue tint with soft pulse */
.ti-step--active {
  background: rgba(96,165,250,0.12);
  border-color: rgba(96,165,250,0.35);
  color: #60a5fa;
  animation: ti-step-pulse 1.8s ease-in-out infinite;
}
.ti-step--active .ti-step-num { background: #60a5fa; color: #0a0a0a; }
/* Placed: solid colored by leg */
.ti-step--placed.ti-step--stop,
.ti-step--placed.ti-step--exit {
  background: rgba(239,68,68,0.14);
  border-color: rgba(239,68,68,0.3);
  color: var(--red);
}
.ti-step--placed.ti-step--stop  .ti-step-num,
.ti-step--placed.ti-step--exit  .ti-step-num { background: var(--red); color: #0a0a0a; }
.ti-step--placed.ti-step--entry {
  background: rgba(34,197,94,0.14);
  border-color: rgba(34,197,94,0.3);
  color: var(--green);
}
.ti-step--placed.ti-step--entry .ti-step-num { background: var(--green); color: #0a0a0a; }
@keyframes ti-step-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.75; } }
.chart-head-actions { display: flex; gap: 0.4rem; }
.text-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-faint);
  padding: 0.2rem 0.55rem;
  border-radius: var(--rm);
  font-size: 0.6875rem;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.12s, border-color 0.12s;
}
.text-btn:hover { color: var(--text-primary); border-color: var(--border-sub); }
.chart-body { height: 360px; position: relative; cursor: crosshair; }
.chart-body > div { width: 100% !important; height: 100% !important; }
.chart-warn {
  background: rgba(245,158,11,0.08);
  border-top: 1px solid rgba(245,158,11,0.3);
  color: var(--orange);
  font-size: 0.75rem;
  padding: 0.4rem 0.85rem;
}
.chart-warn.hidden { display: none; }

/* Save bar */
.save-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.ti-save-hint { font-size: 0.8125rem; color: var(--text-faint); }
.save-bar-left { font-size: 0.75rem; color: var(--text-faint); }
#ti-save-status { display: none; }
.save-bar-right { display: flex; gap: 0.4rem; }
#ti-btn-save { min-height: 2rem; padding: 0.35rem 0.9rem; font-size: 0.8125rem; }

.ti-dir-seg { display: flex; width: 100%; background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--rm); overflow: hidden; min-height: 2.25rem; }
.ti-dir-btn { flex: 1; background: transparent; border: none; color: var(--text-faint); padding: 0 0.5rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; cursor: pointer; transition: background 0.15s, color 0.15s; }
.ti-dir-btn:hover { color: var(--text-secondary); }
.ti-dir-btn.ti-dir-long.on { background: rgba(34,197,94,0.14); color: var(--green); }
.ti-dir-btn.ti-dir-short.on { background: rgba(239,68,68,0.14); color: var(--red); }

/* ── Date picker button + dropdown ───────────────────────────────────── */
.ti-date-btn {
  cursor: pointer;
  text-align: left;
  color: var(--text-secondary);
  width: 100%;
}

.tf-day--disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}
.ti-date-dropdown {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.75rem;
  z-index: 40;
  box-shadow: var(--shadow-md);
  width: 16rem;
}

/* ── Setup widget (add-trade form) ──────────────────────────────────── */
.ti-setup-handle-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 0.25rem;
  color: var(--text-faint);
  cursor: pointer;
  border-radius: var(--rm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.ti-setup-handle-btn:hover { color: var(--text-secondary); background: var(--bg-elevated); }
.ti-setup-handle-btn.active { color: var(--green); background: var(--green-tint); border-color: var(--green); }
.ti-setup-tag-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  padding-bottom: 0.5rem;
}
.ti-setup-add-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: var(--rm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.ti-setup-add-btn:hover {
  color: var(--green);
  border-color: var(--green);
  background: var(--bg-surface);
}
.ti-setup-manage-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text-faint);
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  font-family: inherit;
  border-radius: var(--rm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.ti-setup-manage-btn:hover {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-tint);
}
.ti-setup-manage-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  padding: 0.35rem 0.5rem 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}
.ti-setup-manage-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  padding: 2px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.ti-setup-manage-icon-btn:hover { color: var(--text-secondary); }
.ti-setup-manage-icon-btn--delete:hover { color: var(--red); }
.ti-setup-manage-icon-btn--confirm:hover { color: var(--green); }
/* Inline confirm-delete bar */
.ti-setup-confirm-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem; border-radius: var(--rm); background: var(--red-bg); border: 1px solid var(--red); width: 100%; }
.ti-setup-confirm-text { flex: 1; font-size: 0.8125rem; color: var(--text-primary); }
.ti-setup-confirm-text strong { font-weight: 600; }
.ti-setup-btn-sm { font-size: 0.75rem; padding: 0.25rem 0.65rem; border-radius: var(--rm); border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-secondary); cursor: pointer; font-family: inherit; }
.ti-setup-btn-sm:hover { border-color: var(--text-muted); color: var(--text-primary); }
.ti-setup-btn-sm.danger { border-color: var(--red); color: var(--red); }
.ti-setup-btn-sm.danger:hover { background: var(--red); color: #fff; }

.ti-setup-add-new-row { display: flex; align-items: center; gap: 0.6rem; flex: 0 0 100%; }

/* Right-click context menu for setup pills */
.ti-setup-ctx-menu { position: fixed; z-index: 100; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-md); padding: 0.25rem; display: flex; flex-direction: column; gap: 0.1rem; min-width: 11rem; }
.ti-setup-ctx-item { background: transparent; border: none; color: var(--text-secondary); font-size: 0.8125rem; font-family: inherit; padding: 0.4rem 0.6rem; cursor: pointer; border-radius: var(--rm); text-align: left; transition: background 0.1s, color 0.1s; }
.ti-setup-ctx-item:hover { background: var(--bg-surface); color: var(--text-primary); }
.ti-setup-ctx-item--danger:hover { color: var(--red); }
.ti-setup-ctx-separator { height: 1px; background: var(--border); margin: 0.2rem 0.25rem; }
.ti-setup-grade-cards-title {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  width: 100%;
  padding-bottom: 0.25rem;
}
.ti-setup-grade-cards {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-bottom: 0.5rem;
}
.ti-setup-grade-separator {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  flex-shrink: 0;
}
.ti-setup-grade-cards-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
.sg-add-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.625rem 0.875rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  cursor: pointer;
  min-width: 14rem;
  flex-shrink: 0;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.sg-add-card:hover { border-color: var(--text-muted); }
.sg-add-card--selected {
  /* no card-level highlight -- select button turns green instead */
}
.sg-add-card-header { display: flex; align-items: center; gap: 0.375rem; }
.sg-add-card-delete { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 1px; border-radius: 3px; display: flex; align-items: center; flex-shrink: 0; }
.sg-add-card-delete:hover { color: var(--red); }
.sg-add-card-tag { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9rem; }
.sg-add-card-param-list { display: flex; flex-direction: column; gap: 1px; padding-top: 0.25rem; border-top: 1px solid var(--border-sub); margin-top: 0.25rem; }
.sg-add-card-param-list .sg-trade-inline-param-row { padding: 1px 0; }
.sg-add-card-param-list .sg-param-label { font-size: 0.875rem; flex: 1; cursor: context-menu; }
.sg-add-card-param-remove { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 1px; border-radius: 3px; display: none; align-items: center; flex-shrink: 0; margin-left: auto; }
.sg-trade-inline-param-row:hover .sg-add-card-param-remove { display: flex; }
.sg-add-card-param-remove:hover { color: var(--red); }
.sg-add-card-add-param { padding-top: 0.25rem; }
.sg-add-card-add-param-btn { background: none; border: none; cursor: pointer; color: var(--text-faint); font-size: 0.75rem; padding: 2px 0; transition: color 0.15s; }
.sg-add-card-add-param-btn:hover { color: var(--green); }
.sg-add-card-select-btn {
  width: 100%;
  margin-top: 0.375rem;
  padding: 0.25rem 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.sg-add-card-select-btn:hover { border-color: var(--green); color: var(--green); }
.sg-add-card-select-btn--active {
  background: var(--bg-surface);
  border-color: var(--green);
  color: var(--green);
}
.ti-setup-grade-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-top: 0.375rem;
}
.sg-add-card-time { font-size: 0.8125rem; color: var(--text-muted); }
.sg-add-card-params { font-size: 0.8125rem; color: var(--text-muted); }

/* ── Column resize handles ────────────────────────────────────────────── */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  z-index: 1;
}
.col-resize-handle:hover,
.col-resize-handle--active {
  background: var(--green);
}

/* Table cell truncation for resizable columns */
#recent-trades-table td,
#rv-recent-trades-table td,
#recent-trades-table th,
#rv-recent-trades-table th {
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* Edge column inset -- overrides the base truncation padding */
#recent-trades-table td:first-child, #rv-recent-trades-table td:first-child,
#recent-trades-table th:first-child, #rv-recent-trades-table th:first-child { padding-left: 1rem; }
#recent-trades-table td:last-child, #rv-recent-trades-table td:last-child,
#recent-trades-table th:last-child, #rv-recent-trades-table th:last-child { padding-right: 1rem; }

/* Compact sizing: 11px header / 13px body, tight rows (Linear/Notion density) */
#recent-trades-table thead th,
#rv-recent-trades-table thead th {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  font-size: 0.6875rem;
  color: var(--text-faint);
}
#recent-trades-table tbody td,
#rv-recent-trades-table tbody td {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  font-size: 0.8125rem;
}

/* Sticky table header while scrolling */
#recent-trades-table thead th,
#rv-recent-trades-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-surface);
}

#recent-trades-table,
#rv-recent-trades-table {
  border-collapse: separate;
  border-spacing: 0;
}

/* Let tag pills wrap to a second row instead of clipping */
#recent-trades-table td.tag-cell,
#rv-recent-trades-table td.tag-cell {
  white-space: normal;
  overflow: hidden;
  min-width: 8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  align-content: flex-start;
}

/* Ensure table widget scrolls -- widget-body is the scroll container */
#widget-recent-trades .widget-body {
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
}
