/* app/assets/stylesheets/trades.css */

/* ============================================================
   TRADES · INDEX · SHOW · NEW/EDIT
   Dense, information-first design. Pairs with dashboard.css.
   ============================================================ */

   .trades-page,
   .trade-show-page,
   .trade-entry-page {
     --t-surface:       #ffffff;
     --t-surface-2:     #f8fafc;
     --t-surface-3:     #f1f5f9;
     --t-border:        #e5e7eb;
     --t-border-soft:   #eef2f6;
     --t-text-1:        #0f172a;
     --t-text-2:        #475569;
     --t-text-3:        #94a3b8;
     --t-accent:        #2563eb;
     --t-accent-strong: #1d4ed8;
     --t-accent-soft:   #eff6ff;
     --t-accent-border: #93c5fd;
     --t-profit:        #059669;
     --t-profit-strong: #047857;
     --t-profit-soft:   #ecfdf5;
     --t-profit-border: #a7f3d0;
     --t-loss:          #dc2626;
     --t-loss-strong:   #b91c1c;
     --t-loss-soft:     #fef2f2;
     --t-loss-border:   #fecaca;
     --t-shadow-card:   0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
     --t-shadow-lift:   0 12px 24px -12px rgba(15, 23, 42, .18);
     --t-radius-xs:     8px;
     --t-radius-sm:     10px;
     --t-radius:        14px;
     --t-radius-lg:     18px;
     --t-mono:          ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
     --t-ease:          cubic-bezier(0.16, 1, 0.3, 1);
   }
   
   .trades-page, .trade-show-page, .trade-entry-page {
     font-variant-numeric: tabular-nums;
     -webkit-font-smoothing: antialiased;
   }
   
   /* ============================================================
      SHARED PAGE HEADER
      ============================================================ */
   .trades-header,
   .entry-header,
   .show-topbar {
     display: flex;
     justify-content: space-between;
     align-items: center;
     gap: 20px;
     flex-wrap: wrap;
   }
   
   .trades-header { margin-bottom: 20px; }
   
   .trades-heading { min-width: 0; }
   .trades-title-row { display: flex; align-items: center; gap: 10px; }
   
   .trades-heading h1,
   .entry-header h1 {
     font-size: 26px;
     font-weight: 800;
     letter-spacing: -0.02em;
     color: var(--t-text-1);
     margin: 0;
     line-height: 1.15;
   }
   
   .trades-count-pill {
     display: inline-flex;
     align-items: center;
     padding: 3px 9px;
     border-radius: 999px;
     background: var(--t-surface-3);
     color: var(--t-text-2);
     font-size: 11.5px;
     font-weight: 700;
     letter-spacing: 0.02em;
   }
   
   .trades-subtitle {
     margin: 6px 0 0;
     font-size: 13.5px;
     color: var(--t-text-2);
     font-weight: 500;
   }
   
   .header-actions,
   .trades-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
   
   /* ============================================================
      BUTTONS (scoped so we don't clobber the dashboard's .btn)
      ============================================================ */
   .trades-page .btn,
   .trade-show-page .btn,
   .trade-entry-page .btn {
     display: inline-flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
     padding: 9px 16px;
     border-radius: var(--t-radius-sm);
     font-size: 13.5px;
     font-weight: 600;
     cursor: pointer;
     text-decoration: none;
     border: 1px solid transparent;
     transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
     white-space: nowrap;
     line-height: 1;
   }
   .trades-page .btn:active,
   .trade-show-page .btn:active,
   .trade-entry-page .btn:active { transform: translateY(1px); }
   .trades-page .btn:focus-visible,
   .trade-show-page .btn:focus-visible,
   .trade-entry-page .btn:focus-visible {
     outline: 2px solid var(--t-accent);
     outline-offset: 2px;
   }
   
   /* .btn-primary { background: var(--t-text-1); color: #fff; }
   .btn-primary:hover { background: var(--t-accent-strong); color: #fff; }
    */
   .btn-ghost {
     background: var(--t-surface);
     color: var(--t-text-2);
     border-color: var(--t-border);
   }
   .btn-ghost:hover { background: var(--t-surface-2); color: var(--t-text-1); border-color: #cbd5e1; }
   
   .btn-danger { background: var(--t-loss-soft); color: var(--t-loss-strong); border-color: var(--t-loss-border); }
   .btn-danger:hover { background: #fee2e2; }
   
   .btn-lg { padding: 12px 22px; font-size: 14.5px; }
   
   /* ============================================================
      INDEX · KPI STRIP
      ============================================================ */
   .trades-kpis {
     display: grid;
     grid-template-columns: repeat(5, minmax(0, 1fr));
     gap: 1px;
     background: var(--t-border-soft);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius);
     overflow: hidden;
     margin-bottom: 16px;
     box-shadow: var(--t-shadow-card);
   }
   
   .kpi {
     background: var(--t-surface);
     padding: 14px 16px;
     display: flex;
     flex-direction: column;
     gap: 4px;
     min-width: 0;
   }
   
   .kpi-label {
     font-size: 10px;
     font-weight: 700;
     text-transform: uppercase;
     letter-spacing: 0.07em;
     color: var(--t-text-3);
     white-space: nowrap;
     overflow: hidden;
     text-overflow: ellipsis;
   }
   .kpi-value {
     font-size: 20px;
     font-weight: 800;
     letter-spacing: -0.02em;
     color: var(--t-text-1);
     line-height: 1.1;
     white-space: nowrap;
   }
   .kpi-value.is-positive { color: var(--t-profit-strong); }
   .kpi-value.is-negative { color: var(--t-loss-strong); }
   
   .kpi-sub {
     font-size: 10.5px;
     font-weight: 600;
     color: var(--t-text-3);
     white-space: nowrap;
     overflow: hidden;
     text-overflow: ellipsis;
   }
   
   .kpi-bar {
     height: 4px;
     border-radius: 999px;
     background: var(--t-surface-3);
     overflow: hidden;
     margin-top: 4px;
   }
   .kpi-bar > span {
     display: block;
     height: 100%;
     border-radius: 999px;
     background: linear-gradient(90deg, #34d399, var(--t-profit));
   }
   
   /* ============================================================
      INDEX · TOOLBAR (filters)
      ============================================================ */
   .trades-toolbar {
     display: flex;
     align-items: center;
     gap: 10px;
     padding: 10px 12px;
     background: var(--t-surface);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius);
     margin-bottom: 12px;
     box-shadow: var(--t-shadow-card);
     flex-wrap: wrap;
   }
   
   .toolbar-search {
     position: relative;
     display: flex;
     align-items: center;
     gap: 8px;
     padding: 0 12px;
     background: var(--t-surface-2);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius-sm);
     flex: 1 1 260px;
     min-width: 200px;
     transition: border-color .15s, background .15s, box-shadow .15s;
   }
   .toolbar-search:focus-within {
     border-color: var(--t-accent-border);
     background: #fff;
     box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
   }
   .toolbar-search svg { color: var(--t-text-3); flex-shrink: 0; }
   .toolbar-search input {
     border: 0;
     background: transparent;
     outline: none;
     width: 100%;
     padding: 8px 0;
     font-size: 13.5px;
     color: var(--t-text-1);
     font-family: inherit;
   }
   .toolbar-search input::placeholder { color: var(--t-text-3); }
   
   .search-count-pill {
     font-size: 11px;
     font-weight: 700;
     color: var(--t-accent);
     background: var(--t-accent-soft);
     padding: 3px 8px;
     border-radius: 999px;
     white-space: nowrap;
   }

   /* Toolbar account dropdown */
  .toolbar-account {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    background: var(--t-surface-2);
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius-sm);
    color: var(--t-text-3);
    height: 38px;
    flex: 0 0 auto;
    transition: border-color .15s, background .15s, box-shadow .15s;
  }
  .toolbar-account:focus-within {
    background: #fff;
    border-color: var(--t-accent-border);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
  }
  .toolbar-account select {
    border: 0;
    outline: 0;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--t-text-1);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 4px;
    max-width: 180px;
    text-overflow: ellipsis;
  }
  .toolbar-account select:focus { outline: none; }

   
   .filter-tabs {
     display: inline-flex;
     align-items: center;
     gap: 2px;
     background: var(--t-surface-2);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius-sm);
     padding: 3px;
   }
   
   .filter-tab {
     padding: 7px 12px;
     border-radius: 8px;
     border: 0;
     background: transparent;
     color: var(--t-text-2);
     font-size: 12.5px;
     font-weight: 600;
     cursor: pointer;
     transition: background .15s, color .15s;
     font-family: inherit;
     white-space: nowrap;
   }
   .filter-tab:hover { color: var(--t-text-1); }
   .filter-tab.is-active {
     background: var(--t-surface);
     color: var(--t-text-1);
     box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
   }
   
   .toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--t-text-3); font-size: 12px; font-weight: 600; }
   
   /* ============================================================
      INDEX · TABLE
      ============================================================ */
   .trades-table-card {
     background: var(--t-surface);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius);
     overflow: hidden;
     box-shadow: var(--t-shadow-card);
   }
   
   .trades-scroll { overflow-x: auto; max-height: calc(100vh - 320px); overflow-y: auto; }
   
   .trades-table {
     width: 100%;
     border-collapse: separate;
     border-spacing: 0;
     min-width: 900px;
   }
   
   .trades-table thead th {
     position: sticky;
     top: 0;
     z-index: 2;
     background: var(--t-surface-2);
     padding: 10px 14px;
     text-align: left;
     font-size: 10.5px;
     font-weight: 700;
     letter-spacing: 0.07em;
     text-transform: uppercase;
     color: var(--t-text-3);
     border-bottom: 1px solid var(--t-border);
     white-space: nowrap;
     user-select: none;
   }
   
   .trades-table th[data-sort] { cursor: pointer; }
   .trades-table th[data-sort]::after {
     content: "";
     display: inline-block;
     margin-left: 6px;
     opacity: 0;
     color: var(--t-text-3);
     font-size: 10px;
     vertical-align: 1px;
     transition: opacity .15s;
   }
   .trades-table th[data-sort]:hover::after { content: "↕"; opacity: .6; }
   .trades-table th[data-dir="asc"]::after  { content: "↑"; opacity: 1; color: var(--t-accent); }
   .trades-table th[data-dir="desc"]::after { content: "↓"; opacity: 1; color: var(--t-accent); }
   
   .trades-table tbody td {
     padding: 11px 14px;
     font-size: 13px;
     color: var(--t-text-1);
     border-bottom: 1px solid var(--t-border-soft);
     white-space: nowrap;
     vertical-align: middle;
   }
   .trades-table tbody tr:last-child td { border-bottom: 0; }
   
   .trades-table tbody tr.trade-row {
     cursor: pointer;
     transition: background .1s;
     position: relative;
   }
   .trades-table tbody tr.trade-row:hover { background: #f0f9ff; }
   
   /* P&L accent bar on the row's left edge */
   .trades-table tbody tr.trade-row > td:first-child { position: relative; }
   .trades-table tbody tr.trade-row > td:first-child::before {
     content: "";
     position: absolute;
     left: 0; top: 6px; bottom: 6px;
     width: 3px;
     border-radius: 0 3px 3px 0;
     background: transparent;
   }
   .trades-table tbody tr.trade-row[data-outcome="win"]  > td:first-child::before { background: var(--t-profit); }
   .trades-table tbody tr.trade-row[data-outcome="loss"] > td:first-child::before { background: var(--t-loss); }
   .trades-table tbody tr.trade-row[data-outcome="open"] > td:first-child::before { background: #f59e0b; }
   
   .col-num, .col-price, .col-qty { font-family: var(--t-mono); font-feature-settings: "tnum"; font-size: 12.5px; }
   .col-muted { color: var(--t-text-3); }
   
   .symbol-cell { display: flex; align-items: center; gap: 8px; }
   .symbol-sym {
     font-family: var(--t-mono);
     font-size: 13px;
     font-weight: 700;
     letter-spacing: -0.01em;
     color: var(--t-text-1);
   }
   
   .side-pill {
     display: inline-flex;
     align-items: center;
     gap: 4px;
     padding: 3px 8px;
     border-radius: 6px;
     font-size: 11px;
     font-weight: 700;
     letter-spacing: 0.01em;
   }
   .side-pill.long  { background: var(--t-profit-soft); color: var(--t-profit-strong); border: 1px solid var(--t-profit-border); }
   .side-pill.short { background: var(--t-loss-soft);   color: var(--t-loss-strong);   border: 1px solid var(--t-loss-border); }
   
   .status-pill {
     display: inline-flex;
     align-items: center;
     gap: 5px;
     font-size: 11px;
     font-weight: 600;
     color: var(--t-text-3);
   }
   .status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; }
   .status-pill.closed .dot { background: var(--t-text-3); }
   
   .pnl { font-family: var(--t-mono); font-weight: 700; font-size: 13px; }
   .pnl.profit { color: var(--t-profit-strong); }
   .pnl.loss   { color: var(--t-loss-strong); }
   .pnl.flat   { color: var(--t-text-3); }
   
   .date-cell { color: var(--t-text-2); font-size: 12.5px; font-weight: 500; }
   .date-cell strong { color: var(--t-text-1); font-weight: 600; }
   
   .row-actions { display: flex; gap: 6px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
   .trade-row:hover .row-actions { opacity: 1; }
   .row-action {
     width: 30px; height: 30px;
     display: inline-flex;
     align-items: center;
     justify-content: center;
     border-radius: 8px;
     border: 1px solid transparent;
     background: transparent;
     color: var(--t-text-3);
     cursor: pointer;
     text-decoration: none;
     transition: background .12s, color .12s, border-color .12s;
   }
   .row-action:hover { background: var(--t-surface-3); color: var(--t-text-1); }
   .row-action.danger:hover { background: var(--t-loss-soft); color: var(--t-loss-strong); border-color: var(--t-loss-border); }
   
   .row-actions form { display: inline-flex; margin: 0; }
   
   .no-results-cell {
     text-align: center;
     padding: 60px 20px;
     color: var(--t-text-3);
     font-size: 13px;
     font-weight: 500;
   }
   
   /* ============================================================
      EMPTY STATE
      ============================================================ */
   .trades-page .empty-state {
     background: var(--t-surface);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius);
     padding: 70px 32px;
     text-align: center;
     box-shadow: var(--t-shadow-card);
   }
   .empty-icon {
     width: 64px; height: 64px;
     border-radius: 18px;
     background: linear-gradient(135deg, #eff6ff, #dbeafe);
     color: var(--t-accent);
     display: inline-flex;
     align-items: center;
     justify-content: center;
     margin-bottom: 20px;
   }
   .empty-icon svg { width: 32px; height: 32px; }
   .trades-page .empty-state h3 {
     margin: 0 0 8px;
     font-size: 20px;
     font-weight: 800;
     color: var(--t-text-1);
     letter-spacing: -0.01em;
   }
   .trades-page .empty-state p {
     margin: 0 auto 24px;
     font-size: 14px;
     color: var(--t-text-2);
     max-width: 420px;
     line-height: 1.6;
   }
   .empty-actions { display: flex; gap: 10px; justify-content: center; }
   
/* ============================================================
   SHOW PAGE
   ============================================================ */
   .trade-show-page { max-width: 1180px; }

   .show-topbar { margin-bottom: 16px; }
   .show-back {
     display: inline-flex; align-items: center; gap: 6px;
     font-size: 13px; font-weight: 600; color: var(--t-text-2);
     text-decoration: none;
   }
   .show-back:hover { color: var(--t-text-1); }
   
   .show-pager { display: flex; align-items: center; gap: 6px; }
   .pager-btn {
     width: 30px; height: 30px; border-radius: 8px;
     border: 1px solid var(--t-border); background: var(--t-surface);
     color: var(--t-text-2); display: inline-flex; align-items: center;
     justify-content: center; text-decoration: none; font-size: 15px; line-height: 1;
   }
   .pager-btn:hover { background: var(--t-surface-2); color: var(--t-text-1); }
   .pager-label { font-size: 12px; font-weight: 600; color: var(--t-text-3); padding: 0 6px; font-variant-numeric: tabular-nums; }
   
   /* Hero */
   .show-hero {
     background: var(--t-surface);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius-lg);
     padding: 22px 26px;
     margin-bottom: 12px;
     box-shadow: var(--t-shadow-card);
     display: grid;
     grid-template-columns: minmax(0, 1fr) auto;
     gap: 24px;
     align-items: start;
   }
   
   .show-symbol-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
   .show-symbol-line h1 {
     margin: 0;
     font-family: var(--t-mono);
     font-size: 30px; font-weight: 800; letter-spacing: -0.02em;
     color: var(--t-text-1); line-height: 1;
   }
   
   .state-pill {
     display: inline-flex; align-items: center; gap: 6px;
     padding: 3px 9px; border-radius: 6px;
     border: 1px solid var(--t-border);
     background: var(--t-surface-2); color: var(--t-text-2);
     font-size: 11px; font-weight: 700;
   }
   .state-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--t-text-3); }
   .state-pill.open { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
   .state-pill.open .dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
   
   .strategy-chip {
     display: inline-flex; align-items: center; gap: 6px;
     padding: 3px 10px; border-radius: 6px;
     border: 1px solid var(--t-border);
     background: var(--t-surface-2);
     color: var(--t-text-2); font-size: 11px; font-weight: 700;
     text-decoration: none;
     transition: color .15s, border-color .15s;
   }
   .strategy-chip:hover { color: var(--t-text-1); border-color: #cbd5e1; }
   .strategy-chip i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
   
   .show-broker-pill {
     padding: 3px 9px; border-radius: 999px;
     background: var(--t-surface-3); color: var(--t-text-2);
     font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
   }
   
   .show-timeline {
     display: flex; align-items: center; gap: 10px;
     font-size: 12.5px; color: var(--t-text-2); flex-wrap: wrap;
   }
   .show-timeline strong { color: var(--t-text-1); font-weight: 600; }
   .show-timeline .arrow { color: var(--t-text-3); }
   .show-timeline .hold {
     font-family: var(--t-mono);
     padding: 2px 8px; border-radius: 6px;
     background: var(--t-surface-2); color: var(--t-text-2);
     font-size: 11px; font-weight: 600;
   }
   
   .show-hero-note {
     margin-top: 10px;
     font-size: 12.5px; color: var(--t-text-2); line-height: 1.6;
   }
   .show-hero-note strong { color: var(--t-text-1); font-weight: 700; }
   .show-hero-note strong.is-positive { color: var(--t-profit-strong); }
   .show-hero-note strong.is-negative { color: var(--t-loss-strong); }
   
   .show-hero-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
   .show-hero-tags .label {
     font-size: 10px; font-weight: 700; text-transform: uppercase;
     letter-spacing: 0.07em; color: var(--t-text-3);
   }
   .tag-chip {
     display: inline-flex; align-items: center;
     padding: 4px 11px; border-radius: 999px;
     background: var(--t-surface-2); border: 1px solid var(--t-border);
     color: var(--t-text-2); font-size: 11.5px; font-weight: 600;
   }
   
   .show-pnl-block { text-align: right; }
   .show-pnl {
     display: block;
     font-family: var(--t-mono);
     font-size: 30px; font-weight: 800; letter-spacing: -0.02em;
     line-height: 1; white-space: nowrap;
   }
   .show-pnl.is-positive { color: var(--t-profit-strong); }
   .show-pnl.is-negative { color: var(--t-loss-strong); }
   .show-pnl.is-open { color: var(--t-text-3); }
   .show-return {
     display: block; margin-top: 6px;
     font-family: var(--t-mono); font-size: 14px; font-weight: 700;
   }
   .show-return.is-positive { color: var(--t-profit); }
   .show-return.is-negative { color: var(--t-loss); }
   .show-return-hint { display: block; margin-top: 4px; font-size: 10.5px; font-weight: 600; color: var(--t-text-3); }
   
   /* Metric rail — auto-fit so it never strands a half row */
   .metric-rail {
     display: grid;
     grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
     gap: 1px; background: var(--t-border-soft);
     border: 1px solid var(--t-border); border-radius: var(--t-radius);
     overflow: hidden; margin-bottom: 12px; box-shadow: var(--t-shadow-card);
   }
   .metric-cell { background: var(--t-surface); padding: 12px 14px; min-width: 0; }
   .metric-cell-label {
     display: block; font-size: 10px; font-weight: 700;
     text-transform: uppercase; letter-spacing: 0.07em;
     color: var(--t-text-3); margin-bottom: 4px;
     white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
   }
   .metric-cell-value {
     font-family: var(--t-mono); font-size: 15px; font-weight: 700; color: var(--t-text-1);
     white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
   }
   .metric-cell-value.is-positive { color: var(--t-profit-strong); }
   .metric-cell-value.is-negative { color: var(--t-loss-strong); }
   .metric-cell-value.is-muted { color: var(--t-text-3); }
   .metric-cell-sub {
     display: block; margin-top: 4px;
     font-size: 10px; font-weight: 600; color: var(--t-text-3);
     white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
   }
   
   /* ---------- Price path ---------- */
   .move-card {
     background: var(--t-surface);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius);
     padding: 18px 22px 16px;
     margin-bottom: 12px;
     box-shadow: var(--t-shadow-card);
   }
   .move-head {
     display: flex; align-items: flex-start; justify-content: space-between;
     gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
   }
   .move-head h3 {
     margin: 0; font-size: 12px; font-weight: 700;
     text-transform: uppercase; letter-spacing: 0.07em; color: var(--t-text-3);
   }
   .move-sub { margin: 5px 0 0; font-size: 11.5px; color: var(--t-text-3); font-weight: 500; }
   
   .move-delta {
     display: inline-flex; align-items: baseline; gap: 6px;
     font-family: var(--t-mono); font-size: 13.5px; font-weight: 700;
   }
   .move-delta em {
     font-style: normal; font-family: inherit;
     font-size: 9px; font-weight: 800; letter-spacing: 0.08em;
     text-transform: uppercase; color: var(--t-text-3);
   }
   .move-delta.is-positive { color: var(--t-profit-strong); }
   .move-delta.is-negative { color: var(--t-loss-strong); }
   
   .move-body {
     display: grid;
     grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
     gap: 10px 40px;
     align-items: center;
   }
   
   .move-viz { min-width: 0; }
   
   .move-tagrow { position: relative; height: 24px; }
   .move-tag {
     position: absolute; top: 2px; transform: translateX(-50%);
     display: inline-flex; align-items: center; gap: 5px;
     padding: 2px 8px; border-radius: 6px;
     border: 1px solid var(--t-border);
     background: var(--t-surface-2); color: var(--t-text-1);
     font-family: var(--t-mono); font-size: 11px; font-weight: 700;
     white-space: nowrap;
   }
   .move-tag em {
     font-style: normal; font-size: 8.5px; font-weight: 800;
     letter-spacing: 0.08em; color: var(--t-text-3);
   }
   .move-tag.is-exit.win  { background: var(--t-profit-soft); border-color: var(--t-profit-border); color: var(--t-profit-strong); }
   .move-tag.is-exit.loss { background: var(--t-loss-soft);   border-color: var(--t-loss-border);   color: var(--t-loss-strong); }
   .move-tag.is-exit.flat { background: var(--t-surface-3); color: var(--t-text-2); }
   .move-tag.is-exit em { color: inherit; opacity: .7; }
   
   .move-track {
     position: relative; height: 10px;
     margin: 6px 8px;
     background: var(--t-surface-3);
     border-radius: 999px;
   }
   .move-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; min-width: 2px; }
   .move-fill.profit { background: linear-gradient(90deg, #86efac, var(--t-profit)); }
   .move-fill.loss   { background: linear-gradient(90deg, var(--t-loss), #fca5a5); }
   .move-fill.flat   { background: var(--t-text-3); }
   
   .move-marker {
     position: absolute; top: 50%;
     width: 16px; height: 16px; border-radius: 50%;
     background: var(--t-text-2); border: 3px solid #fff;
     box-shadow: 0 1px 4px rgba(15, 23, 42, .2);
     transform: translate(-50%, -50%);
     z-index: 2;
   }
   .move-marker.is-entry { background: var(--t-text-1); }
   .move-marker.is-exit.win  { background: var(--t-profit); }
   .move-marker.is-exit.loss { background: var(--t-loss); }
   .move-marker.is-exit.flat { background: var(--t-text-3); }
   
   .move-axis {
     position: relative; display: flex; justify-content: space-between;
     margin: 8px 8px 0;
     font-family: var(--t-mono); font-size: 10.5px; font-weight: 600;
     color: var(--t-text-3);
   }
   .move-axis span:nth-child(2) { position: absolute; left: 50%; transform: translateX(-50%); }
   .move-axis-note { margin: 10px 8px 0; font-size: 11px; color: var(--t-text-3); font-weight: 500; }
   
   /* ---------- P&L math ---------- */
   .move-math { min-width: 0; }
   .move-math-head {
     font-size: 10px; font-weight: 700; text-transform: uppercase;
     letter-spacing: 0.07em; color: var(--t-text-3); margin-bottom: 8px;
   }
   .move-math-row {
     display: flex; justify-content: space-between; align-items: baseline;
     gap: 12px; padding: 5px 0;
     font-size: 12px; color: var(--t-text-2);
     border-bottom: 1px dashed var(--t-border-soft);
   }
   .move-math-row span { font-weight: 600; }
   .move-math-row strong {
     font-family: var(--t-mono); font-size: 12.5px; font-weight: 700;
     color: var(--t-text-1); white-space: nowrap;
   }
   .move-math-row strong small { font-size: 10.5px; font-weight: 600; color: var(--t-text-3); margin-left: 4px; }
   .move-math-row strong.is-positive { color: var(--t-profit-strong); }
   .move-math-row strong.is-negative { color: var(--t-loss-strong); }
   .move-math-row.total {
     border-top: 1px solid var(--t-border); border-bottom: 0;
     margin-top: 3px; padding-top: 9px;
   }
   .move-math-row.total strong { font-size: 14.5px; }
   
   .move-math-note { margin: 10px 0 0; font-size: 11px; line-height: 1.55; color: var(--t-text-2); font-weight: 500; }
   .move-math-note strong { font-weight: 700; }
   .move-math-note.is-ok {
     display: inline-block;
     background: var(--t-profit-soft); border: 1px solid var(--t-profit-border);
     color: var(--t-profit-strong); font-weight: 700;
     padding: 5px 10px; border-radius: 8px;
   }
   .move-math-note.is-warn {
     background: var(--t-surface-2); border: 1px solid var(--t-border);
     padding: 7px 11px; border-radius: 8px;
   }
   
   /* ---------- Related history ---------- */
   .related-card {
     background: var(--t-surface);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius);
     margin-bottom: 12px;
     box-shadow: var(--t-shadow-card);
     overflow: hidden;
   }
   .related-head {
     display: flex; justify-content: space-between; align-items: center;
     gap: 12px 16px; padding: 14px 18px;
     border-bottom: 1px solid var(--t-border-soft);
     flex-wrap: wrap;
   }
   .related-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
   .related-head h3 { margin: 0; font-size: 13px; font-weight: 700; color: var(--t-text-1); }
   .related-head h3 span { color: var(--t-text-3); font-weight: 600; font-family: var(--t-mono); }
   .related-vs {
     font-size: 11px; font-weight: 700;
     padding: 3px 9px; border-radius: 999px;
     background: var(--t-surface-3); color: var(--t-text-2);
   }
   .related-vs.is-positive { background: var(--t-profit-soft); color: var(--t-profit-strong); }
   .related-vs.is-negative { background: var(--t-loss-soft); color: var(--t-loss-strong); }
   .related-stats { display: flex; gap: 16px; font-size: 12px; color: var(--t-text-2); font-weight: 600; flex-wrap: wrap; }
   .related-stats strong { font-family: var(--t-mono); color: var(--t-text-1); }
   .related-stats .is-positive strong { color: var(--t-profit-strong); }
   .related-stats .is-negative strong { color: var(--t-loss-strong); }
   
   .related-list { display: flex; flex-direction: column; }
   .related-row {
     display: grid;
     grid-template-columns: 110px 74px minmax(0, 1fr) 104px;
     align-items: center; gap: 12px;
     padding: 10px 18px;
     border-bottom: 1px solid var(--t-border-soft);
     font-size: 12.5px; text-decoration: none; color: var(--t-text-1);
     transition: background .1s;
   }
   .related-row:last-child { border-bottom: 0; }
   .related-row:hover { background: var(--t-surface-2); }
   .related-row .date { color: var(--t-text-2); font-weight: 500; white-space: nowrap; }
   .related-row .px {
     font-family: var(--t-mono); font-size: 12px; color: var(--t-text-2);
     overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
   }
   .related-row .pnl { font-family: var(--t-mono); font-weight: 700; text-align: right; }
   
   .related-foot { padding: 10px 18px; border-top: 1px solid var(--t-border-soft); }
   .related-foot a { font-size: 12px; font-weight: 700; color: var(--t-accent); text-decoration: none; }
   .related-foot a:hover { color: var(--t-accent-strong); }
   
   /* ---------- Notes ---------- */
   .notes-card {
     background: var(--t-surface);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius);
     padding: 16px 20px;
     margin-bottom: 12px;
     box-shadow: var(--t-shadow-card);
   }
   .notes-card h3 {
     margin: 0 0 8px;
     font-size: 11px; font-weight: 700; text-transform: uppercase;
     letter-spacing: 0.07em; color: var(--t-text-3);
   }
   .notes-body { font-size: 13.5px; color: var(--t-text-1); line-height: 1.65; white-space: pre-wrap; }
   .notes-card.is-empty { display: flex; flex-direction: column; gap: 10px; }
   .notes-empty-row {
     display: flex; align-items: center; justify-content: space-between;
     gap: 16px; flex-wrap: wrap;
   }
   .notes-card.is-empty p { margin: 0; font-size: 13px; color: var(--t-text-2); line-height: 1.6; }
   .notes-card.is-empty p strong { color: var(--t-text-1); }
   
   /* ---------- Actions ---------- */
   .show-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
   .show-actions form { display: inline-flex; margin: 0; }
   .show-actions .danger-push { margin-left: auto; }
   .trade-show-page .btn.btn-sm { padding: 6px 12px; font-size: 12px; }
   
   /* ============================================================
      ENTRY FORM (NEW / EDIT)
      ============================================================ */
   .trade-entry-page { max-width: 780px; margin: 0 auto; }
   
   .entry-header { margin-bottom: 22px; }
   .entry-header .trades-back {
     display: inline-flex;
     align-items: center;
     gap: 6px;
     font-size: 13px;
     font-weight: 600;
     color: var(--t-text-2);
     text-decoration: none;
     margin-bottom: 12px;
   }
   .entry-header .trades-back:hover { color: var(--t-text-1); }
   
   .form-section {
     background: var(--t-surface);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius);
     margin-bottom: 14px;
     box-shadow: var(--t-shadow-card);
     overflow: hidden;
   }
   .form-section-head {
     padding: 12px 20px;
     background: var(--t-surface-2);
     border-bottom: 1px solid var(--t-border-soft);
     font-size: 11px;
     font-weight: 700;
     text-transform: uppercase;
     letter-spacing: 0.07em;
     color: var(--t-text-3);
   }
   .form-section-body { padding: 20px; }
   
   .form-grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
   .form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
   .form-grid .full { grid-column: 1 / -1; }
   
   .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
   .field label {
     font-size: 11.5px;
     font-weight: 600;
     color: var(--t-text-2);
     letter-spacing: 0.01em;
   }
   .field .hint { font-size: 11px; color: var(--t-text-3); font-weight: 500; }
   
   .field input[type="text"],
   .field input[type="number"],
   .field input[type="datetime-local"],
   .field select,
   .field textarea {
     width: 100%;
     padding: 10px 12px;
     background: var(--t-surface-2);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius-sm);
     font-size: 14px;
     color: var(--t-text-1);
     font-family: inherit;
     outline: none;
     box-sizing: border-box;
     transition: border-color .15s, background .15s, box-shadow .15s;
   }
   .field input:focus,
   .field select:focus,
   .field textarea:focus {
     border-color: var(--t-accent-border);
     background: #fff;
     box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
   }
   .field textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
   
   .field-money { position: relative; }
   .field-money .prefix {
     position: absolute;
     left: 12px;
     top: 50%;
     transform: translateY(-50%);
     color: var(--t-text-3);
     font-size: 13px;
     font-weight: 600;
     pointer-events: none;
   }
   .field-money input { padding-left: 26px; }
   
   /* Direction toggle */
   .direction-toggle {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 6px;
     padding: 3px;
     background: var(--t-surface-2);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius-sm);
   }
   .direction-toggle input { display: none; }
   .direction-toggle label {
     display: flex;
     align-items: center;
     justify-content: center;
     gap: 5px;
     padding: 8px 12px;
     border-radius: 7px;
     font-size: 13px;
     font-weight: 600;
     color: var(--t-text-2);
     cursor: pointer;
     transition: background .15s, color .15s, box-shadow .15s;
   }
   .direction-toggle label:hover { color: var(--t-text-1); }
   .direction-toggle input:checked + label {
     background: var(--t-surface);
     color: var(--t-text-1);
     box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
   }
   .direction-toggle input[value="long"]:checked + label  { color: var(--t-profit-strong); }
   .direction-toggle input[value="short"]:checked + label { color: var(--t-loss-strong); }
   
   /* Live P&L preview */
   .pnl-preview-grid {
     display: grid;
     grid-template-columns: repeat(4, minmax(0, 1fr));
     gap: 1px;
     background: var(--t-border-soft);
     border-top: 1px solid var(--t-border-soft);
   }
   .pnl-preview-cell { background: var(--t-surface); padding: 14px 18px; }
   .pnl-preview-label {
     display: block;
     font-size: 10px;
     font-weight: 700;
     text-transform: uppercase;
     letter-spacing: 0.07em;
     color: var(--t-text-3);
     margin-bottom: 4px;
   }
   .pnl-preview-value {
     font-family: var(--t-mono);
     font-size: 17px;
     font-weight: 800;
     color: var(--t-text-1);
     letter-spacing: -0.01em;
   }
   .pnl-preview-value.is-positive { color: var(--t-profit-strong); }
   .pnl-preview-value.is-negative { color: var(--t-loss-strong); }
   .pnl-preview-value.is-muted    { color: var(--t-text-3); font-weight: 600; }
   
   .pnl-preview-note {
     padding: 10px 18px;
     font-size: 11px;
     color: var(--t-text-3);
     border-top: 1px solid var(--t-border-soft);
     background: var(--t-surface-2);
   }
   .pnl-preview-note strong { color: var(--t-text-2); font-weight: 600; }
   
   /* Tags input */
   .tag-input-wrap {
     display: flex;
     align-items: center;
     gap: 6px;
     flex-wrap: wrap;
     padding: 8px 10px;
     background: var(--t-surface-2);
     border: 1px solid var(--t-border);
     border-radius: var(--t-radius-sm);
     min-height: 42px;
     transition: border-color .15s, background .15s, box-shadow .15s;
   }
   .tag-input-wrap:focus-within {
     border-color: var(--t-accent-border);
     background: #fff;
     box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
   }
   .tag-input-wrap input {
     flex: 1;
     min-width: 120px;
     border: 0;
     background: transparent;
     outline: none;
     padding: 4px 0;
     font-size: 13px;
     font-family: inherit;
     color: var(--t-text-1);
   }
   .tag-pill {
     display: inline-flex;
     align-items: center;
     gap: 5px;
     padding: 3px 8px 3px 10px;
     background: var(--t-accent-soft);
     color: var(--t-accent-strong);
     border: 1px solid var(--t-accent-border);
     border-radius: 999px;
     font-size: 11.5px;
     font-weight: 600;
   }
   .tag-pill button {
     background: transparent;
     border: 0;
     color: inherit;
     cursor: pointer;
     font-size: 13px;
     line-height: 1;
     padding: 0 2px;
     opacity: .7;
   }
   .tag-pill button:hover { opacity: 1; }
   
   .tag-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
   .tag-suggestion {
     padding: 4px 10px;
     border-radius: 999px;
     background: var(--t-surface-2);
     border: 1px solid var(--t-border);
     color: var(--t-text-2);
     font-size: 11.5px;
     font-weight: 600;
     cursor: pointer;
     font-family: inherit;
     transition: background .15s, color .15s, border-color .15s;
   }
   .tag-suggestion:hover { background: var(--t-accent-soft); color: var(--t-accent-strong); border-color: var(--t-accent-border); }
   
   /* Form actions */
   .form-actions {
     display: flex;
     justify-content: flex-end;
     gap: 10px;
     margin-top: 20px;
   }
   
   /* Form errors */
   .form-errors {
     background: var(--t-loss-soft);
     border: 1px solid var(--t-loss-border);
     border-radius: var(--t-radius-sm);
     padding: 12px 16px;
     margin-bottom: 14px;
     color: var(--t-loss-strong);
     font-size: 13px;
     line-height: 1.5;
   }
   .form-errors strong { font-weight: 700; }
   
   /* ============================================================
      RESPONSIVE
      ============================================================ */
      @media (max-width: 1180px) {
        .trades-kpis      { grid-template-columns: repeat(3, minmax(0, 1fr)); }
        .pnl-preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        /* metric-rail is auto-fit now — no override needed */
      }
      
      @media (max-width: 960px) {
        .show-hero { grid-template-columns: 1fr; }
        .show-pnl-block { text-align: left; }
        .move-body { grid-template-columns: 1fr; }
        .related-row { grid-template-columns: 104px 68px minmax(0, 1fr) 96px; }
      }
      
      @media (max-width: 768px) {
        .trades-header { align-items: flex-start; flex-direction: column; }
        .header-actions, .trades-header-actions { width: 100%; }
        .header-actions .btn, .trades-header-actions .btn { flex: 1; }
      
        .trades-toolbar { padding: 8px; }
        .toolbar-search  { flex-basis: 100%; }
      
        .trades-kpis      { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .form-grid,
        .form-grid--3     { grid-template-columns: 1fr; }
      
        .related-row .side-pill { display: none; }
        .related-row { grid-template-columns: 96px minmax(0, 1fr) 90px; }
      
        .trade-show-page,
        .trade-entry-page { max-width: 100%; }
      }
      
      @media (max-width: 520px) {
        .trades-kpis      { grid-template-columns: 1fr; }
        .pnl-preview-grid { grid-template-columns: 1fr; }
        .show-symbol-line h1 { font-size: 24px; }
        .show-pnl { font-size: 24px; }
        .show-actions .danger-push { margin-left: 0; }
      }
      
   

   .kpi-bar > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #34d399, var(--t-profit));
    transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .kpi-value.is-muted { color: var(--t-text-3); font-weight: 700; }
