/* Trade Log — a right-side slide-over drawer showing one position's full
   lifecycle as a vertical timeline (entry → fill → SL → GT → L2 → exit).
   Minimalist: hairline rail + coloured status dots, no heavy per-item boxes
   (anh 2026-06-06). Reuses the app colour tokens; nothing hard-coded. */

/* ── Overlay + drawer shell ─────────────────────────────────────────────── */
.tl-overlay {
    position: fixed;
    inset: 0;
    z-index: 1300;                 /* above the row-menu (1200) */
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}
.tl-overlay.open { opacity: 1; pointer-events: auto; }

.tl-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: clamp(360px, 460px, 96vw);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    box-shadow: -16px 0 40px rgba(0, 0, 0, .45);
    transform: translateX(100%);
    transition: transform .22s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    z-index: 1301;
}
.tl-overlay.open .tl-drawer { transform: translateX(0); }

/* ── Header ─────────────────────────────────────────────────────────────── */
.tl-head {
    flex: none;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
}
.tl-head .tl-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.tl-head .tl-sym {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: .01em;
}
.tl-head .tl-sub {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-muted);
}
.tl-head .tl-spacer { flex: 1; }
.tl-close {
    flex: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 5px;
    transition: color .12s, background .12s;
}
.tl-close:hover { color: var(--text-primary); background: var(--bg-tertiary); }

/* Side / mode tags — share the table language (▲/▼ + LIVE/DRY/MANUAL). */
.tl-tag {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .03em;
    white-space: nowrap;
}
.tl-tag.long  { color: var(--green); }
.tl-tag.short { color: var(--red); }
.tl-tag.live  { color: var(--live, #36c98a); }
.tl-tag.dry   { color: var(--dry, #8b93a7); }
.tl-tag.manual{ color: #e0a23b; }
.tl-tag.auto  { color: var(--accent); }
.tl-tag .dot  { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 4px; vertical-align: middle; }

/* ── Summary strip (hairline-separated stat cells, no boxes) ────────────── */
.tl-summary {
    flex: none;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border);          /* hairline grid via 1px gap */
    border-bottom: 1px solid var(--border);
}
.tl-stat {
    background: var(--bg-secondary);
    padding: 9px 14px;
}
.tl-stat .k {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
}
.tl-stat .v {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
.tl-stat .v.pos { color: var(--green); }
.tl-stat .v.neg { color: var(--red); }

/* ── Body / timeline ────────────────────────────────────────────────────── */
.tl-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.tl-body::-webkit-scrollbar { width: 7px; }
.tl-body::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }

.tl-section-h {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin: 4px 0 10px;
}

.tl-timeline { position: relative; }
.tl-node {
    position: relative;
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 10px;
    padding-bottom: 16px;
}
.tl-node:last-child { padding-bottom: 2px; }
/* The rail line connecting the dots. */
.tl-rail {
    position: relative;
    display: flex;
    justify-content: center;
}
.tl-node:not(:last-child) .tl-rail::after {
    content: "";
    position: absolute;
    top: 14px;
    bottom: -16px;
    width: 1px;
    background: var(--border);
}
.tl-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    margin-top: 2px;
    background: var(--text-muted);
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 0 1px var(--border);
    z-index: 1;
}
.tl-dot.ok      { background: var(--green); box-shadow: 0 0 0 1px var(--green); }
.tl-dot.info    { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tl-dot.win     { background: var(--green); box-shadow: 0 0 0 1px var(--green); }
.tl-dot.fail    { background: var(--red); box-shadow: 0 0 0 1px var(--red); }
.tl-dot.warn    { background: #e0a23b; box-shadow: 0 0 0 1px #e0a23b; }
.tl-dot.pending,
.tl-dot.skipped { background: transparent; box-shadow: 0 0 0 1px var(--text-muted); }
.tl-dot.open    { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); animation: tl-pulse 1.6s ease-in-out infinite; }
@keyframes tl-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.tl-content { min-width: 0; }
.tl-line1 {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}
.tl-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
}
.tl-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .05em;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
}
.tl-badge.ok, .tl-badge.win  { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.tl-badge.fail { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.tl-badge.warn { color: #e0a23b; border-color: color-mix(in srgb, #e0a23b 45%, transparent); }
.tl-badge.info { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.tl-badge.pending, .tl-badge.skipped, .tl-badge.open { color: var(--text-muted); }
.tl-time {
    margin-left: auto;
    font-size: 10.5px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tl-detail {
    margin: 6px 0 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
    font-size: 11px;
}
.tl-detail dt { color: var(--text-muted); white-space: nowrap; }
.tl-detail dd { color: var(--text-secondary); margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.tl-detail dd.pos { color: var(--green); }
.tl-detail dd.neg { color: var(--red); }
.tl-note {
    margin-top: 6px;
    font-size: 10.5px;
    font-style: italic;
    color: var(--text-muted);
    line-height: 1.4;
    border-left: 2px solid var(--border);
    padding-left: 8px;
}

/* ── Orders table ───────────────────────────────────────────────────────── */
.tl-orders { width: 100%; border-collapse: collapse; margin-top: 4px; font-size: 11px; }
.tl-orders th {
    text-align: right;
    font-weight: 600;
    color: var(--text-muted);
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    font-size: 9.5px;
    letter-spacing: .04em;
}
.tl-orders th:first-child, .tl-orders td:first-child { text-align: left; }
.tl-orders td {
    padding: 5px 8px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.tl-orders .ob { color: var(--green); font-weight: 600; }
.tl-orders .os { color: var(--red); font-weight: 600; }
.tl-orders .err { color: var(--red); font-style: italic; }

/* ── Loading / error states ─────────────────────────────────────────────── */
.tl-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 160px;
    color: var(--text-muted);
    font-size: 12px;
}

/* ── The per-row trigger icon (in both market tables' action cell) ──────── */
.tl-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    vertical-align: middle;
    margin-right: 4px;
    transition: color .12s, border-color .12s, background .12s;
}
.tl-icon:hover { color: var(--accent); border-color: var(--border); background: var(--bg-tertiary); }
