/* tradelog.css -- Trade Log redesign styles (.tlr-* prefix)
   Scoped to #view-tradelog. All variables from tokens.css.
   Generated from mockups/tradelog-redesign-mockup.html (Frame 1-5 styles only). */

/* ── Section layout spacing ─────────────────────────────────────── */
#view-tradelog { padding-top: 0.25rem; }
#view-tradelog > .tlr-panel { margin-top: 1rem; }

/* ── Section header (Trade Log title + tools) ───────────────────── */
.tlr-section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 0.25rem;
  margin-bottom: 0.25rem;
}
.tlr-section-title { font-size: 1.125rem; font-weight: 700; color: var(--text-primary); margin: 0; display: inline-flex; align-items: center; gap: 0.5rem; }
.tlr-section-tools { display: flex; gap: 0.4rem; align-items: center; }

/* ── Buttons / inputs base ──────────────────────────────────────── */
.tlr-btn {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-secondary);
  font-size: 0.8125rem; font-weight: 500;
  padding: 0.4rem 0.75rem; border-radius: var(--rm);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.tlr-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
.tlr-btn--primary {
  background: var(--btn-primary-bg); border-color: var(--btn-primary-border);
  color: #ecfdf5; font-weight: 600;
}
.tlr-btn--primary:hover { background: var(--btn-primary-hover); color: var(--btn-primary-text-hover); }
.tlr-btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.tlr-btn--ghost:hover { color: var(--text-primary); background: var(--bg-surface); }

/* ── ADD TRADE PANEL ────────────────────────────────────────────── */
.tlr-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.tlr-panel-head {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.tlr-panel-head-title { font-size: 0.8125rem; font-weight: 600; color: var(--text-primary); display: inline-flex; align-items: center; gap: 0.4rem; }
.tlr-panel-head-tools { display: flex; gap: 0.3rem; align-items: center; }

.tlr-panel-body { padding: 0.85rem 0.85rem; display: flex; flex-direction: column; gap: 0.85rem; }
.tlr-panel-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 0.85rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}
.tlr-panel-foot-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ── Row 1: detail field row (10 columns: + Stop, + P&L) ────────────── */
/* Same tray treatment as .tlr-class-tray — Symbol/Side/Qty/etc. group as
   one cluster inside an --bg-surface container. Grid layout for the
   columns sits inside the tray. */
.tlr-detail-row {
  position: relative;   /* anchor for the absolute lock-indicator badge */
  display: grid;
  /* 9 columns. Symbol, Side, Qty, Date, Entry, Exit, EntryTime, ExitTime, P&L.
     Time columns are 6.75rem to fit "10:11:56 AM" with the 0.55rem input
     padding on each side. */
  grid-template-columns: 6.5rem 7rem 4.5rem 8rem 5rem 5rem 6.75rem 6.75rem 5.5rem;
  gap: 0.5rem;
  white-space: nowrap;
  padding: 0.65rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-sub);
  border-radius: var(--rm);
}

/* Lock indicator badge — sits in the top-right corner of the detail row.
   Visible only when the row carries .is-locked (toggled by JS in
   _applyModeFieldLocks based on Uploaded mode). The icon ships with a
   tooltip explaining why fields are read-only. */
.tlr-detail-lock {
  position: absolute;
  top: 0.4rem;
  right: 0.55rem;
  display: none;
  align-items: center; justify-content: center;
  color: var(--text-muted);
  pointer-events: auto;   /* re-enable for tooltip hover */
}
/* Indicator-only icon (not clickable) — per STYLE-GUIDE §8, smaller than
   the 14px gear so it reads as a passive badge rather than an action. */
.tlr-detail-lock i,
.tlr-detail-lock svg { width: 0.6875rem; height: 0.6875rem; }
.tlr-detail-row.is-locked .tlr-detail-lock { display: inline-flex; }
.tlr-field { display: flex; flex-direction: column; gap: 0.18rem; min-width: 0; }
.tlr-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  /* Match the input's internal text indent (0.55rem padding + 1px border)
     so label text aligns visually with the value below it. */
  padding-left: calc(0.55rem + 1px);
}
.tlr-input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--rm);
  padding: 0.4rem 0.55rem;
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  width: 100%;
}
.tlr-input::placeholder { color: var(--text-ph); }
.tlr-input.empty { color: var(--text-ph); }
/* P&L input takes a green/red tint based on sign — paint logic in
   trades.js _paintPnlInput. The classes mirror the chart-metric ones so
   the same color tokens drive both surfaces. */
.tlr-input.tlr-pos { color: var(--green); }
.tlr-input.tlr-neg { color: var(--red); }

/* Read-only state for trade fields locked in Uploaded mode. Inputs render at
   full opacity so the data stays clearly readable; the lock indicator badge
   in the top-right corner of the row signals the locked state. Cursor still
   shifts to default + side-toggle blocks pointer events to prevent stealth
   interaction. */
.tlr-input[readonly] { cursor: default; }
#ti-date-btn[disabled] { cursor: default; }
#view-tradelog .tlr-side-toggle button[disabled] { cursor: default; pointer-events: none; }

/* Hide native time picker indicator on Trade Log time inputs (we open our own).
   Force width:0 so the input doesn't reserve space for the icon on the right edge. */
.tlr-detail-row input[type="time"]::-webkit-calendar-picker-indicator {
  display: none;
  -webkit-appearance: none;
  width: 0;
  height: 0;
  padding: 0;
  margin: 0;
  opacity: 0;
}
.tlr-detail-row input[type="time"]::-webkit-inner-spin-button,
.tlr-detail-row input[type="time"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tlr-detail-row input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
}

/* ── Custom time picker (replaces native dropdown for HH:MM:AM/PM) ─── */
.tlr-time-picker {
  position: fixed;
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  z-index: 50;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.tlr-tp-col {
  width: 3.5rem;
  max-height: 13rem;
  overflow-y: auto;
  border-right: 1px solid var(--border-sub);
  scroll-behavior: smooth;
  /* Hide visible scrollbar — user scrolls via mouse wheel or touchpad. */
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;         /* legacy Edge/IE */
}
.tlr-tp-col::-webkit-scrollbar { display: none; } /* Chromium / Safari */
.tlr-tp-col:last-child { border-right: none; }
.tlr-tp-col-ampm { width: 3rem; }
.tlr-tp-cell {
  padding: 0.4rem 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  user-select: none;
}
.tlr-tp-cell:hover { background: var(--bg-surface); color: var(--text-primary); }
.tlr-tp-cell.selected {
  background: var(--green);
  color: var(--bg-base);
  font-weight: 700;
}

/* Chart toggle — lives in the panel head actions cluster, sized to match
   the reset/settings icon buttons. Active state keeps the green tint so
   the user can tell at a glance whether the chart is open. Disabled state
   follows the standard 0.4 opacity convention (Style Guide §7 disabled). */
.tlr-chart-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: var(--rm);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.tlr-chart-toggle:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--bg-surface);
  border-color: var(--border);
}
.tlr-chart-toggle.active {
  background: rgba(74,222,128,0.1);
  border-color: rgba(74,222,128,0.4);
  color: var(--green);
}
.tlr-chart-toggle:disabled { opacity: 0.4; cursor: default; }
.tlr-chart-toggle svg { width: 1rem; height: 1rem; }

/* Chart panel (slides in below detail row when toggle is active) */
.tlr-chart-panel {
  /* Use --bg-surface so the panel matches the timeframe strip above it
     (`.tlr-side-tabs`, also --bg-surface) — the two render as one
     continuous surface. The LightweightCharts canvas color is read from
     the same token in add-trade-chart.js so the canvas bg matches the
     panel chrome with no visible seam. */
  background: var(--bg-surface);
  border: 1px solid var(--border-sub);
  border-radius: var(--rm);
  height: 25.5rem;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
/* The class above wins over the UA [hidden] rule due to specificity, so the
   `hidden` HTML attribute would have no effect. Force display:none when the
   attribute is present so the JS toggle (`hidden` attr) hides the panel. */
.tlr-chart-panel[hidden] { display: none; }
.tlr-chart-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.75rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-sub);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.tlr-chart-panel-head strong { color: var(--text-primary); font-weight: 600; }
.tlr-chart-panel-tools { display: flex; gap: 0.3rem; align-items: center; }
.tlr-chart-tf {
  font-size: 0.6875rem;
  color: var(--text-muted);
  padding: 0.15rem 0.5rem;
  border-radius: var(--rm);
  cursor: pointer;
  border: 1px solid transparent;
}
.tlr-chart-tf:hover { color: var(--text-primary); }
.tlr-chart-tf.active { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border); }

/* TF strip — pinned timeframes render here as pills (sorted ascending by
   minutes). Strip contents are dynamic; user manages which TFs appear via
   the settings gear. */
.tlr-chart-tf-strip {
  display: inline-flex; align-items: center; gap: 0.3rem;
}

/* Settings gear — opens a checkbox menu for toggling which TFs are pinned
   to the strip. Mirrors the pill visual size so it sits naturally in the
   row, but uses an icon instead of text. */
.tlr-chart-tf-settings {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.tlr-chart-tf-settings-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--rm);
  padding: 0.2rem 0.35rem;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex; align-items: center;
  font-family: inherit;
  line-height: 1;
}
.tlr-chart-tf-settings-btn:hover { color: var(--text-primary); }
.tlr-chart-tf-settings-btn[aria-expanded="true"] {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}
.tlr-chart-tf-settings-btn i,
.tlr-chart-tf-settings-btn svg { width: 0.875rem; height: 0.875rem; }

/* Settings popover — checkbox row per TF, sorted ascending by minutes.
   Right-aligned to the gear, drops downward, never clips the right column. */
.tlr-chart-tf-settings-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  z-index: 10;
  min-width: 7rem;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}
.tlr-chart-tf-settings-menu[hidden] { display: none; }

.tlr-chart-tf-settings-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.55rem;
  border-radius: var(--rm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.75rem;
  user-select: none;
}
.tlr-chart-tf-settings-row:hover { background: var(--bg-base); color: var(--text-primary); }
.tlr-chart-tf-settings-row input[type="checkbox"] {
  margin: 0;
  accent-color: var(--green);
  cursor: pointer;
}
.tlr-chart-tf-settings-row-label {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.tlr-chart-body {
  flex: 1;
  position: relative;
  min-height: 0;
}
#ti-chart-container { position: absolute; inset: 0; }
.tlr-chart-body svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Overlay text shown when the chart has no data driver (no symbol yet).
   Hidden when _loadChart populates real candles, re-shown by _clearChart. */
.tlr-chart-empty-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-style: italic;
  pointer-events: none;
  letter-spacing: 0.02em;
}
.tlr-chart-empty-msg[hidden] { display: none; }
.tlr-chart-phase {
  font-size: 0.6875rem;
  color: var(--text-faint);
  font-style: italic;
  margin: 0 0.75rem;
  flex: 1;
  text-align: center;
}
/* Live metrics (P&L / R / Risk) shown left of the Entry|Exit|Stop toggle */
.tlr-chart-metrics {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin-right: 0.6rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.tlr-chart-metrics:empty,
.tlr-chart-metrics:has(> :only-child[hidden]) { margin-right: 0; }
.tlr-chart-metric { color: var(--text-secondary); }
.tlr-chart-metric--muted { color: var(--text-faint); font-weight: 500; }
.tlr-chart-metric.tlr-pos { color: var(--green); }
.tlr-chart-metric.tlr-neg { color: var(--red); }

.tlr-chart-mode-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  align-items: center;
}
.tlr-chart-mode-pill {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  letter-spacing: 0.02em;
  font-family: inherit;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.tlr-chart-mode-pill:hover { color: var(--text-primary); }
.tlr-chart-mode-pill.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}
.tlr-chart-mode-pill:disabled {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}
.tlr-chart-marker {
  position: absolute;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem;
  border-radius: var(--rm);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.tlr-chart-marker--entry { background: var(--green-tint); color: var(--green); border: 1px solid rgba(74,222,128,0.5); }
.tlr-chart-marker--stop  { background: var(--red-pill-bg); color: var(--red); border: 1px solid rgba(248,113,113,0.5); }
.tlr-chart-marker--exit  { background: rgba(59,130,246,0.18); color: #93c5fd; border: 1px solid rgba(59,130,246,0.5); }

/* Side toggle */
.tlr-side-toggle {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--rm);
  overflow: hidden;
  height: 2.05rem;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em;
}
.tlr-side-toggle button {
  background: transparent; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: none;
  padding: 0 0.5rem;
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
  height: 100%;
  min-width: 0;
}
.tlr-side-toggle .tlr-side-active--long  { background: var(--green-tint); color: var(--green); }
.tlr-side-toggle .tlr-side-active--short { background: var(--red-pill-bg); color: var(--red); }

/* ── Row 2: classification rows ─────────────────────────────────── */
.tlr-class-row {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.1rem;
}
/* Tags row carries an extra Reset button on the right edge. */
.tlr-class-row#tlr-tags-row { grid-template-columns: 3.25rem 1fr auto; }
.tlr-class-label {
  font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
}

/* TAGS label is also the inline-panel toggle (chevron + label) */
.tlr-tags-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  font-family: inherit;
  /* Inherit the label font/color via .tlr-class-label */
}
.tlr-tags-toggle:hover { color: var(--text-primary); }
.tlr-tags-toggle .tlr-chev {
  width: 0.7rem; height: 0.7rem;
  transition: transform 0.15s ease;
}
.tlr-tags-toggle[aria-expanded="true"] .tlr-chev { transform: rotate(180deg); }
.tlr-tags-toggle[aria-expanded="true"] { color: var(--text-primary); }

.tlr-pills { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.tlr-pill {
  font-size: 0.75rem; padding: 0.28rem 0.6rem; border-radius: var(--rm);
  background: var(--bg-base); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.tlr-pill:hover { background: var(--bg-surface); color: var(--text-primary); }
.tlr-pill--add { border-style: dashed; color: var(--text-muted); }
.tlr-pill--add:hover { color: var(--text-primary); border-color: var(--text-muted); }
.tlr-pill-input {
  font-size: 0.75rem; padding: 0.28rem 0.6rem; border-radius: var(--rm);
  background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  width: 9rem;
  height: calc(0.28rem * 2 + 1.125rem + 2px);
  box-sizing: border-box;
}
.tlr-pill-input:focus { border-color: var(--input-border); }
.tlr-pill-input::placeholder { color: var(--text-ph); }
.tlr-pill.selected {
  background: rgba(59,130,246,0.12); color: #93c5fd; border-color: rgba(59,130,246,0.4);
}

.tlr-grade-row { display: flex; gap: 0.3rem; }

/* Collective tray that groups Setup / Grade / Tags Recent in the side
   layout's left column. Surface hierarchy. panel (--bg-elevated) > tray
   (--bg-surface) > buttons inside (--bg-base). Same micro radius as the
   buttons it contains. */
.tlr-class-tray {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-sub);
  border-radius: var(--rm);
}
.tlr-grade-btn {
  width: 2.4rem; height: 2.1rem;
  border-radius: var(--rm);
  background: var(--bg-base); border: 1px solid var(--border);
  font-size: 0.875rem; font-weight: 700;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
/* Letter color always reflects grade (Variant B) */
.tlr-grade-btn[data-grade="A+"],
.tlr-grade-btn[data-grade="A"]  { color: var(--green); }
.tlr-grade-btn[data-grade="B"]  { color: #f97316; }
.tlr-grade-btn[data-grade="C"],
.tlr-grade-btn[data-grade="D"]  { color: var(--red); }

/* Hover: subtle background lift, letter stays its grade color */
.tlr-grade-btn:hover { background: var(--bg-surface); }

/* Selected: tinted background + matching border */
.tlr-grade-btn.selected[data-grade="A+"],
.tlr-grade-btn.selected[data-grade="A"] {
  background: rgba(74,222,128,0.18); border-color: var(--green);
}
.tlr-grade-btn.selected[data-grade="B"] {
  background: rgba(249,115,22,0.18); border-color: #f97316;
}
.tlr-grade-btn.selected[data-grade="C"],
.tlr-grade-btn.selected[data-grade="D"] {
  background: rgba(248,113,113,0.18); border-color: var(--red);
}


/* ── Notes & Screenshots collapsible ─────────────────────────────── */
.tlr-collapsible {
  background: var(--bg-surface); border: 1px solid var(--border-sub); border-radius: var(--rm);
  overflow: hidden;
}
.tlr-collapsible-trigger {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.7rem;
  font-size: 0.75rem; color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.tlr-collapsible-trigger:hover { color: var(--text-primary); }
.tlr-collapsible-trigger .tlr-chev {
  width: 0.85rem; height: 0.85rem; display: inline-block;
  transition: transform 0.15s ease;
}
.tlr-collapsible.open .tlr-chev { transform: rotate(180deg); }
.tlr-collapsible-body { padding: 0.85rem 0.85rem 1rem; border-top: 1px dashed var(--border-sub); display: none; }
.tlr-collapsible.open .tlr-collapsible-body { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; align-items: stretch; }

.tlr-collapsible.open .tlr-collapsible-body > div {
  display: flex; flex-direction: column; min-height: 0;
}
.tlr-collapsible.open .tlr-collapsible-body #quill-wrap {
  flex: 1; min-height: 14rem;
  display: flex; flex-direction: column;
  /* One step deeper than the surface container — keeps the surface
     hierarchy. card (--bg-surface) > input/editor (--bg-base). */
  background: var(--bg-base); border: 1px solid var(--border-sub); border-radius: var(--rm);
  overflow: hidden;
}
/* Override the Tailwind .bg-base class that index.html applies to #viewer-wrap */
.tlr-collapsible.open .tlr-collapsible-body #viewer-wrap {
  background: var(--bg-base) !important;
  border-color: var(--border-sub) !important;
}
.tlr-collapsible.open .tlr-collapsible-body #quill-editor,
.tlr-collapsible.open .tlr-collapsible-body .ql-container {
  flex: 1; min-height: 0;
  border: none;
}
.tlr-collapsible.open .tlr-collapsible-body .ql-toolbar {
  border: none; border-bottom: 1px solid var(--border-sub);
}

.tlr-journal {
  background: var(--input-bg); border: 1px solid var(--input-border); border-radius: var(--rm);
  padding: 0.5rem 0.65rem; min-height: 5rem;
  color: var(--text-muted); font-size: 0.8125rem; line-height: 1.5;
}
.tlr-screenshots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.tlr-screenshot {
  aspect-ratio: 16/10;
  background: var(--bg-base); border: 1px dashed var(--border); border-radius: var(--rm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; color: var(--text-faint);
}

/* ── Tags row stack ──────────────────────────────────────────────── */
.tlr-tags-stack { display: flex; flex-direction: column; gap: 0.4rem; }

.tlr-most-used { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }

.tlr-add-tag {
  font-size: 0.75rem; font-weight: 600;
  padding: 0.2em 0.6em;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--text-faint);
  cursor: pointer;
  line-height: 1.4;
  display: inline-block;
  white-space: nowrap;
}
.tlr-add-tag:hover { color: var(--text-primary); border-color: var(--text-secondary); }

/* ── Tags inline panel (sits below the TAGS row in the form) ──────── */
/* Background follows STYLE-GUIDE.md §7 surface hierarchy: the Add Trade card
   is --bg-surface, sub-panels inside cards step up to --bg-elevated. Same
   token used by .tlr-collapsible (Notes & Screenshots) so the two siblings
   read as the same kind of inline panel. */
.tlr-tags-inline-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-sub);
  border-radius: var(--rm);
  display: flex; flex-direction: column;
  margin-top: 0.4rem;
}
.tlr-tags-inline-panel[hidden] { display: none; }
.tlr-tags-modal-head {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-sub);
}
.tlr-tags-modal-head-search { flex: 1; min-width: 0; }
.tlr-tags-modal-head-search .tlr-tags-modal-search { padding-top: 0.35rem; padding-bottom: 0.35rem; }
.tlr-tags-modal-close {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem;
  padding: 0.15rem 0.45rem; border-radius: var(--rm);
}
.tlr-tags-modal-close:hover { color: var(--text-primary); background: var(--bg-surface); }

.tlr-tags-modal-search-wrap { padding: 0.65rem 1rem; border-bottom: 1px solid var(--border-sub); }
.tlr-tags-modal-search {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--rm);
  padding: 0.45rem 0.6rem 0.45rem 1.85rem;
  font-size: 0.8125rem;
  color: var(--text-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 0.6rem center;
  box-sizing: border-box;
  outline: none;
}
.tlr-tags-modal-search:focus { border-color: var(--input-border); }
.tlr-tags-modal-search::placeholder { color: var(--text-ph); }

.tlr-tags-modal-body {
  /* Auto-grow inside the inline panel; no internal scroll cap. */
  padding: 0.6rem 0.85rem 0.85rem;
  position: relative;
}
/* Section is a 3-column grid: [name | chips | kebab]. Chips column wraps if
   it overflows; the title stays anchored to the top-left. The column-gap is
   larger than the row-gap so the title reads as visually separated from
   its chips. */
.tlr-cat-section {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  row-gap: 0.4rem;
  column-gap: 0.75rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border-sub);
}
.tlr-cat-section:last-of-type { border-bottom: none; }
/* Tag pills inside the modal are drag-reorderable; show grab affordance. */
.tlr-tags-modal-body .tag-pill[data-val] { cursor: grab; }
.tlr-tags-modal-body .tag-pill[data-val]:active { cursor: grabbing; }
.tlr-cat-name {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  cursor: grab;
  align-self: start;          /* anchor title to first row when chips wrap */
}
.tlr-cat-name:active { cursor: grabbing; }
.tlr-cat-kebab {
  background: transparent; border: none; cursor: pointer !important;
  color: var(--text-faint); font-size: 0.95rem;
  padding: 0.05rem 0.45rem; border-radius: var(--rm);
  line-height: 1;
  align-self: start;          /* anchor kebab to first row when chips wrap */
}
.tlr-cat-kebab:hover { color: var(--text-primary); background: var(--bg-surface); }

.tlr-cat-tags {
  display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center;
  /* Subtle vertical divider between the category label and its chips —
     stretches naturally across wrapped rows because it's the flex
     container's left border. */
  border-left: 1px solid var(--border-sub);
  padding-left: 0.75rem;
}
.tlr-cat-add {
  font-size: 0.75rem; font-weight: 600;
  padding: 0.2em 0.55em;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--text-faint);
  cursor: pointer;
  line-height: 1.4;
}
.tlr-cat-add:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.tlr-add-cat {
  margin-top: 0.4rem;
  width: 100%;
  padding: 0.5rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--rm);
  font-size: 0.8125rem;
  cursor: pointer;
}
.tlr-add-cat:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.tlr-cat-kebab-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  padding: 0.4rem;
  width: 16rem;
  z-index: 70;
}

/* Per-tag right-click context menu (Rename / Remove) */
.tlr-tag-ctx-menu {
  position: fixed;
  z-index: 70;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  box-shadow: var(--shadow-md);
  padding: 0.25rem 0;
  min-width: 9rem;
  display: flex; flex-direction: column;
}
.tlr-tag-ctx-item {
  display: flex; align-items: center; gap: 0.5rem;
  background: transparent; border: none; cursor: pointer;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem; color: var(--text-secondary);
  text-align: left; font-family: inherit;
}
.tlr-tag-ctx-item:hover { background: var(--bg-surface); color: var(--text-primary); }
.tlr-tag-ctx-item svg { width: 0.85rem; height: 0.85rem; flex-shrink: 0; }
.tlr-tag-ctx-item--danger { color: var(--red); }
.tlr-tag-ctx-item--danger:hover { background: var(--red-bg); color: var(--red); }
.tlr-tag-ctx-item--confirm,
.tlr-tag-ctx-item--confirm:hover {
  background: var(--red-bg);
  color: var(--red);
  font-weight: 700;
}

/* Inline rename input for a single tag pill (replaces the pill in-place).
   Per STYLE-GUIDE.md §7, inputs always use var(--bg-base) regardless of
   surface; per §15 rule 4, no green focus highlight (would read as "valid"
   signal). The .tag-pill.tag-pill-rename-input compound selector outranks
   the .tag-pill[data-cat=…] category-color rule on specificity ties so the
   neutral background can't be overridden by an accidental data-cat attr. */
.tag-pill.tag-pill-rename-input {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.2em 0.5em;
  font: inherit;
  font-size: 0.75rem;
  border-radius: 0.25rem;
  outline: none;
  width: 8rem;
  min-height: 0;
}
.tag-pill.tag-pill-rename-input:focus { border-color: var(--border); }
.tlr-cat-kebab-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  font-size: 0.8125rem; color: var(--text-secondary);
  border-radius: var(--rm);
  cursor: pointer;
}
.tlr-cat-kebab-item:hover { background: var(--bg-surface); color: var(--text-primary); }
.tlr-cat-kebab-item--danger { color: var(--red); }
.tlr-cat-kebab-item--danger:hover { background: var(--red-bg); color: var(--red); }
.tlr-cat-kebab-divider { height: 1px; background: var(--border-sub); margin: 0.25rem 0; }

.tlr-cat-recolor-section { padding: 0.45rem 0.55rem 0.55rem; }
.tlr-cat-recolor-label {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-faint);
  margin-bottom: 0.35rem;
}
.tlr-swatch-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tlr-swatch {
  width: 1.5rem; height: 1.5rem;
  border-radius: var(--rm);
  border: 1px solid var(--border);
  cursor: pointer;
}
.tlr-swatch.active { box-shadow: 0 0 0 2px var(--green); }

/* ── Task 9: Kebab v2 ────────────────────────────────────────────── */

/* Rename input pinned at top of kebab menu. Follows STYLE-GUIDE.md §7
   inline-input-in-menu pattern (matches .ctx-layout-rename-input). */
.tlr-cat-rename-input {
  display: block;
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: inherit;
  padding: 0.3rem 0.5rem;
  outline: none;
  box-sizing: border-box;
  margin-bottom: 0.25rem;
}
.tlr-cat-rename-input:focus { border-color: var(--border); }

/* Custom-color 9th swatch */
.tlr-swatch--custom {
  position: relative;
  background: linear-gradient(135deg, #f87171 0%, #fbbf24 25%, #4ade80 50%, #38bdf8 75%, #c084fc 100%);
  border-color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0d0d0d;
}

/* Two-step delete confirm state */
.tlr-cat-kebab-item--confirm {
  background: var(--red-bg);
  color: var(--red);
  font-weight: 700;
}
.tlr-cat-kebab-item--confirm:hover { background: var(--red-bg); color: var(--red); }

/* ── Modal-header right-side action cluster ─────────────────────── */
.tlr-tags-modal-head-actions {
  display: inline-flex; align-items: center; gap: 0.4rem;
}

/* Tags modal "Reset" — clears the form's selected tags only (non-destructive) */
.tlr-tags-modal-clear {
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.75rem; font-weight: 600;
  padding: 0.3rem 0.55rem;
  border-radius: var(--rm);
  display: inline-flex; align-items: center; gap: 0.35rem;
  line-height: 1;
  font-family: inherit;
}
.tlr-tags-modal-clear:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--bg-surface);
  border-color: var(--text-muted);
}
.tlr-tags-modal-clear svg { width: 0.875rem; height: 0.875rem; }
.tlr-tags-modal-clear:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── Add Trade panel head right-side action cluster ───────────────
   margin-left:auto pushes this cluster (and everything after it —
   head-sep, queue control, save button) to the far right of the bar.
   Title + mode toggle hold their natural left position. */
.tlr-panel-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

/* ── Mode toggle (Manual / Uploaded inside Add Trade head) ──────── */
.tlr-mode-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  align-items: center;
  /* Sit immediately to the right of the panel title. The hint span (or the
     toggle itself when hint is hidden) carries margin-right: auto to push
     queue control + action icons to the far right. */
  margin-left: 0.75rem;
}
/* (.tlr-mode-hint and its layout-bridge :has() rule were removed —
   the right cluster is now pushed via margin-left:auto on
   .tlr-panel-head-actions instead.) */
.tlr-mode-pill {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.1s, color 0.1s;
}
.tlr-mode-pill:hover { color: var(--text-primary); }
.tlr-mode-pill.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}
.tlr-mode-pill:disabled { opacity: 0.5; cursor: default; }
.tlr-mode-pill-count {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-faint);
  background: var(--bg-elevated);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  min-width: 1.25rem;
  text-align: center;
}
.tlr-mode-pill.active .tlr-mode-pill-count { background: var(--bg-base); }
/* Highlight the badge in green when there's queued work and mode is not "uploaded" */
.tlr-mode-pill[data-mode="uploaded"]:not(.active) .tlr-mode-pill-count.has-work {
  background: var(--green-bg);
  color: var(--green);
}

/* ── Queue pagination (CSV review queue inside Add Trade head) ──── */
.tlr-queue-control {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 0.6rem;
  padding: 0.15rem 0.35rem;
  /* Transparent background + border so the control reads as a flush
     part of the panel-head bar (var(--bg-surface)) rather than a
     darker pill sitting on top of it. Padding/border-width retained
     so the surrounding flex layout doesn't reflow. */
  border: 1px solid transparent;
  border-radius: var(--rm);
  background: transparent;
}
.tlr-queue-control[hidden] { display: none; }
.tlr-queue-arrow {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--rm);
}
/* Hover one shade lighter than --bg-surface (the panel-head bar) so the
   affordance is visible now that the parent pill is transparent. */
.tlr-queue-arrow:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-elevated); }
.tlr-queue-arrow:disabled { opacity: 0.3; cursor: default; }
.tlr-queue-arrow svg { width: 0.95rem; height: 0.95rem; }
.tlr-queue-pos {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 6rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* ── Add Trade settings gear button (and reset icon button — shared style) ─────────────────────────────── */
.tlr-settings-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: var(--rm);
  display: inline-flex; align-items: center; justify-content: center;
}
.tlr-settings-btn:hover { color: var(--text-primary); background: var(--bg-surface); border-color: var(--border); }
.tlr-settings-btn[aria-expanded="true"] { color: var(--text-primary); background: var(--bg-surface); border-color: var(--border); }
.tlr-settings-btn svg { width: 1rem; height: 1rem; }

/* ── Settings dropdown (anchored under the gear) ────────────────── */
.tlr-settings-dropdown {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  z-index: 40;
  min-width: 18rem;
  padding: 0.4rem 0;
}
.tlr-settings-dropdown[hidden] { display: none; }

.tlr-settings-section { padding: 0.25rem 0; }
.tlr-settings-section + .tlr-settings-section {
  border-top: 1px solid var(--border-sub);
  margin-top: 0.25rem;
  padding-top: 0.5rem;
}
.tlr-settings-section-title {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 0.85rem 0.3rem;
}
.tlr-settings-item {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%;
  background: transparent; border: none; cursor: pointer;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: left;
  font-family: inherit;
}
.tlr-settings-item:hover { background: var(--bg-surface); color: var(--text-primary); }
.tlr-settings-item svg { width: 0.875rem; height: 0.875rem; flex-shrink: 0; }
.tlr-settings-item--danger { color: var(--red); }

/* Risk section form rows in the settings dropdown */
.tlr-settings-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.4rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.tlr-settings-form-row > span:first-child { flex-shrink: 0; }
.tlr-settings-input-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.tlr-settings-input-prefix {
  position: absolute;
  left: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  pointer-events: none;
}
.tlr-settings-input-wrap input {
  width: 6rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: inherit;
  padding: 0.3rem 0.5rem 0.3rem 1.1rem;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.tlr-settings-input-wrap input:disabled { opacity: 0.5; cursor: default; }
.tlr-settings-input-wrap input::-webkit-outer-spin-button,
.tlr-settings-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tlr-settings-risk-input {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.tlr-settings-risk-input input {
  width: 4rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: inherit;
  padding: 0.3rem 0.5rem;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.tlr-settings-risk-input input::-webkit-outer-spin-button,
.tlr-settings-risk-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tlr-settings-risk-type {
  display: inline-flex;
  gap: 1px;
  padding: 1px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--rm);
}
.tlr-settings-risk-type-btn {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  font-family: inherit;
  min-width: 1.6rem;
}
.tlr-settings-risk-type-btn:hover { color: var(--text-primary); }
.tlr-settings-risk-type-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}

/* Toggle switch (Auto adjust shares) inside the settings dropdown */
.tlr-settings-switch {
  position: relative;
  width: 2.25rem;
  height: 1.15rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
}
.tlr-settings-switch-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 0.85rem;
  height: 0.85rem;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.15s, background 0.12s;
}
.tlr-settings-switch[aria-checked="true"] {
  background: var(--green-bg);
  border-color: var(--green);
}
.tlr-settings-switch[aria-checked="true"] .tlr-settings-switch-thumb {
  transform: translateX(1.05rem);
  background: var(--green);
}
.tlr-settings-switch[aria-disabled="true"] {
  cursor: default;
  opacity: 0.5;
}
.tlr-settings-switch[aria-disabled="true"]:hover { background: var(--bg-base); }
.tlr-settings-item--danger:hover { background: var(--red-bg); color: var(--red); }

/* ── Reset confirmation panel (now a centered overlay, not in-modal) ── */
.tlr-tags-modal-confirm {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(28rem, calc(100vw - 3rem));
  background: var(--bg-elevated);
  border: 1px solid var(--red);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 1.1rem 1.1rem;
  z-index: 70;
}
.tlr-tags-modal-confirm[hidden] { display: none; }
.tlr-tags-modal-confirm-head {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.875rem; font-weight: 700;
  color: var(--red);
  margin-bottom: 0.5rem;
}
.tlr-tags-modal-confirm-head svg { width: 1rem; height: 1rem; }
.tlr-tags-modal-confirm-list {
  margin: 0 0 0.75rem 1.25rem;
  padding: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.55;
}
.tlr-tags-modal-confirm-list li { margin-bottom: 0.15rem; }
.tlr-tags-modal-confirm-actions {
  display: flex; justify-content: flex-end; gap: 0.5rem;
}
.tlr-tags-modal-confirm-cancel,
.tlr-tags-modal-confirm-go {
  font-size: 0.8125rem; font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: var(--rm);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}
.tlr-tags-modal-confirm-cancel:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}
.tlr-tags-modal-confirm-go {
  background: var(--red);
  border-color: var(--red);
  color: var(--bg-base);
}
.tlr-tags-modal-confirm-go:hover {
  filter: brightness(1.1);
}

/* ── Side enrichment layout ──────────────────────────────────────── */

/* Default: all three wrappers are transparent to layout — their children
   flow into .tlr-panel-body's flex column as if the wrappers weren't there.
   The order properties below control visual sequence in that flat flow. */
.tlr-trade-content,
.tlr-side-left,
.tlr-side-right { display: contents; }

/* Flow order for .tlr-panel-body flex children.
   In below layout (.tlr-trade-content / .tlr-side-left / .tlr-side-right are
   display:contents) these inner elements become direct flex children and their
   order controls visual sequence. In side layout .tlr-trade-content is a grid
   so only the outermost items (detail row, trade-content, notes collapsible)
   need order values.

   Below-layout visual sequence:
     detail row → (tabs hidden) → chart → setup → grade → tags row →
     tags panel → save bar → notes collapsible */
.tlr-detail-row              { order: 1; }
/* .tlr-trade-content is display:grid in side layout — give it order:2 so it
   sits correctly between .tlr-detail-row and #ti-notes-collapsible in the
   .tlr-panel-body flex column. Ignored when display:contents (below layout). */
.tlr-trade-content           { order: 2; }
.tlr-side-tabs               { order: 2; }   /* hidden in below layout */
#ti-chart-panel              { order: 3; }
.tlr-class-tray              { order: 4; }   /* tray replaces individual setup/grade/tags-row orders */
#tlr-tags-panel              { order: 7; }
#ti-notes-collapsible        { order: 9; }

/* Side layout active: 30/70 grid. Two grid items — the side-left wrapper
   (column 1) and the new side-right wrapper (column 2). Each column has
   its own intrinsic height; rows don't get stretched by row-spanning. */
.tlr-panel.tlr-side-layout .tlr-trade-content {
  display: grid;
  grid-template-columns: 30% 70%;
  align-items: stretch;
  gap: 0;
}

.tlr-panel.tlr-side-layout .tlr-side-left {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  grid-column: 1;
  grid-row: 1;               /* sit beside the right column, not below it */
  min-height: 25.5rem;       /* matches chart's natural height so the */
                             /* two columns visually balance */
  padding-right: 0.85rem;
}

.tlr-panel.tlr-side-layout .tlr-side-right {
  display: flex;
  flex-direction: column;
  grid-column: 2;
  grid-row: 1;               /* explicit row so auto-flow doesn't push */
                             /* the left wrapper to row 2 */
  min-height: 25.5rem;
  overflow: hidden;
}

.tlr-panel.tlr-side-layout .tlr-chart-panel {
  flex: 1;
  height: auto;              /* fill the right column via flex stretch */
  margin: 0;
  min-height: 0;             /* flex child — parent provides min-height */
}

/* In the narrow 30% column, stack label on top of content. Flex column
   keeps content tight under the label — no auto row stretching. */
.tlr-panel.tlr-side-layout .tlr-class-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  min-height: 0;             /* override the 2.1rem default */
}

/* Tags row keeps the Reset button inline with the label on the first line,
   chips stack on a second line below. */
.tlr-panel.tlr-side-layout .tlr-class-row#tlr-tags-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "label reset"
    "chips chips";
  align-items: center;
  row-gap: 0.4rem;
}
.tlr-panel.tlr-side-layout #tlr-tags-row > .tlr-tags-toggle      { grid-area: label; }
.tlr-panel.tlr-side-layout #tlr-tags-row > .tlr-tags-stack       { grid-area: chips; }
.tlr-panel.tlr-side-layout #tlr-tags-row > .tlr-tags-modal-clear { grid-area: reset; }

/* Top-bar Save & Next button — sits next to the queue control inside the
   panel head. Sized to match the .tlr-mode-toggle (Manual / Uploaded) so
   the head bar reads as one row of consistently-sized controls. */
.tlr-head-save-btn {
  margin-left: 0.4rem;
  padding: 0.25rem 0.6rem;
  min-height: 0;
  height: 1.65rem;
  font-size: 0.75rem;
  line-height: 1;
}

/* (.tlr-head-sep was removed when queue control moved next to the mode
   toggle — the separator was paired with the queue's old right-cluster
   position and is no longer meaningful.) */

/* When the top-bar save is showing (Uploaded mode), hide the footer save
   row to avoid a duplicate affordance. JS toggles .tlr-has-top-save on the
   panel via _renderQueueControl. */
.tlr-panel.tlr-has-top-save .tlr-panel-foot { display: none; }

/* ── Side-panel tab strip ────────────────────────────────────────── */

/* Hidden by default. Shown whenever the chart panel is open (in either
   layout) so the chart-tools cluster — Entry/Exit pills, TF strip,
   settings gear — is always reachable when the user has the chart up.
   Hidden when chart panel is closed since the tools have nothing to act on. */
.tlr-side-tabs { display: none; }

/* Show whenever the sibling chart panel is visible (i.e. not [hidden]). */
.tlr-side-right:has(#ti-chart-panel:not([hidden])) .tlr-side-tabs {
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  min-height: 2.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-sub);
  flex-shrink: 0;
}

/* In below-layout the Chart/Tags tab BUTTONS themselves don't do anything
   useful (the chart and tags panels can coexist, no tab-switching needed),
   so hide them — but keep the chart-tools cluster visible. */
.tlr-panel:not(.tlr-side-layout) .tlr-side-tabs > .tlr-side-tab { display: none; }

/* Below-layout. close the gap between the strip and the chart panel and
   visually merge them. The strip becomes the chart panel's head bar. */
.tlr-panel:not(.tlr-side-layout) .tlr-side-right:has(#ti-chart-panel:not([hidden])) .tlr-side-tabs {
  margin-bottom: -0.85rem;
  border: 1px solid var(--border-sub);
  border-radius: var(--rm) var(--rm) 0 0;
  position: relative;
  z-index: 1;
}

/* Square the chart panel's top corners when the strip sits above so the
   shared edge is flush with no rounded peek-through. */
.tlr-panel:not(.tlr-side-layout) .tlr-side-tabs + #ti-chart-panel {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.tlr-side-tab {
  padding: 0.3rem 0.85rem;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.tlr-side-tab:hover { color: var(--text-primary); }
.tlr-side-tab i,
.tlr-side-tab svg { width: 0.875rem; height: 0.875rem; }
.tlr-side-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--green);
}

/* ── Side-tabs inline tools clusters ────────────────────────────────
   The tabs strip now hosts both the Chart-tab tools (symbol/phase/metrics/
   mode pills/TF pills) and the Tags-tab tools (search + close). Visibility
   is gated by .tlr-tab-chart / .tlr-tab-tags on the parent panel — those
   classes are toggled by _setTabState() in trades.js.

   Layout. tabs sit left, the active cluster fills the remaining row width.
   Chart cluster pushes its right-side tools (.tlr-chart-panel-tools) to
   the far right via margin-left:auto. Tags cluster lets the search input
   flex-grow with the close button pinned right. */
.tlr-side-tabs-tools {
  flex: 1;
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: nowrap; white-space: nowrap;
  padding: 0 0.6rem;
  font-size: 0.75rem; color: var(--text-muted);
  min-width: 0;
}
.tlr-side-tabs-tools--chart strong {
  color: var(--text-primary); font-weight: 600;
}
/* Phase hint sits next to the symbol now (no flex-grow + no centering) — the
   old centered/grow layout was for the standalone .tlr-chart-panel-head.
   Allow it to truncate if the panel is squeezed so the right-side tools
   never get pushed off-screen. */
.tlr-side-tabs-tools--chart .tlr-chart-phase {
  flex: 0 1 auto; margin: 0; text-align: left;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.tlr-side-tabs-tools--chart .tlr-chart-panel-tools {
  margin-left: auto;
  display: flex; gap: 0.3rem; align-items: center;
  flex-wrap: nowrap; flex-shrink: 0;
}
/* Tighter metrics inside the combined row — original 0.8125rem font + 0.65rem
   gap was sized for a standalone wide head row. Inside the locked side-tabs
   width it pushed the cluster past the column edge. */
.tlr-side-tabs-tools--chart .tlr-chart-metrics {
  gap: 0.4rem;
  margin-right: 0.3rem;
  font-size: 0.75rem;
  flex-shrink: 0;
}
/* Tags cluster shares the locked 2.5rem row. Input sized at 2rem (32px) per
   the desktop search-input best-practice floor, with body font (13px) so it
   matches the surrounding text hierarchy. Close button bumps proportionally. */
.tlr-side-tabs-tools--tags { padding: 0 0.5rem 0 0.6rem; gap: 0.4rem; }
.tlr-side-tabs-tools--tags .tlr-tags-modal-search {
  flex: 1; min-width: 0;
  height: 2rem;
  padding-top: 0.35rem; padding-bottom: 0.35rem;
  font-size: 0.8125rem;
}
.tlr-side-tabs-tools--tags .tlr-tags-modal-close {
  font-size: 1.15rem;
  padding: 0.25rem 0.5rem;
  line-height: 1;
}

/* Tab-active visibility — only one cluster shows at a time */
.tlr-panel.tlr-tab-tags  .tlr-side-tabs-tools--chart { display: none; }
.tlr-panel.tlr-tab-chart .tlr-side-tabs-tools--tags  { display: none; }

/* ── Tab-state: Tags tab active ──────────────────────────────────── */

/* When Tags tab is active, hide the chart panel */
.tlr-panel.tlr-side-layout.tlr-tab-tags #ti-chart-panel {
  display: none;
}

/* Tags panel fills the right column height in side layout when visible.
   This applies whether the panel was opened (hidden=false) or in the edge
   case where [hidden] is still set but the tab-tags CSS forces display. */
.tlr-panel.tlr-side-layout .tlr-tags-inline-panel:not([hidden]) {
  flex: 1;
  min-height: 25.5rem;
  /* Drop the below-layout margin so the panel sits flush under the tab
     strip — matches the chart panel's flush placement on the Chart tab. */
  margin-top: 0;
}

/* Fallback: show panel even if [hidden] is still set on Tags tab (covers
   the rare race where CSS renders before JS removes the attribute). */
.tlr-panel.tlr-side-layout.tlr-tab-tags .tlr-tags-inline-panel[hidden] {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 25.5rem;
  margin-top: 0;
}
