.trade-section { display:flex; gap:14px; align-items:flex-start; padding-top:18px; margin-top:8px; border-top:1px solid var(--line); }
.trade-section > span { background:var(--brand-soft); color:var(--brand); border-radius:12px; padding:8px 11px; font-weight:700; }
.trade-section h3 { margin:0 0 5px; font-size:17px; }
.trade-section p { margin:0; color:var(--muted); font-size:13px; }
.trade-multi { border:1px solid var(--line); border-radius:16px; padding:14px; min-width:0; margin:0; }
.trade-multi legend { color:var(--foreground); font-weight:600; font-size:13px; padding:0 5px; }
.trade-chips { display:flex; flex-wrap:wrap; gap:7px; margin-bottom:12px; }
.trade-chips label { position:relative; cursor:pointer; }
.trade-chips input { position:absolute; opacity:0; width:1px; height:1px; }
.trade-chips span { display:block; border:1px solid var(--line); background:var(--surface-soft); border-radius:8px; padding:7px 10px; color:var(--muted); font-size:12px; }
.trade-chips input:checked + span { color:var(--brand-strong); background:var(--brand-soft); border-color:var(--brand); }
.trade-chips input:focus-visible + span { outline:3px solid var(--brand); outline-offset:3px; }
.trade-computed { background:var(--surface-soft); border:1px solid var(--line); border-radius:18px; padding:18px; min-width:0; }
.trade-computed-title { font-weight:700; margin-bottom:14px; }
.trade-computed-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.trade-computed-grid span { display:block; font-size:11px; color:var(--muted); margin-bottom:5px; }
.trade-computed-grid b { font-size:14px; overflow-wrap:anywhere; }
.trade-computed p,.trade-computed small { color:var(--muted); font-size:12px; overflow-wrap:anywhere; }
.trade-multi > input { width:100%; min-height:40px; border:1px solid var(--line); border-radius:10px; padding:9px 11px; background:var(--surface); color:var(--foreground); font:inherit; font-size:12px; }
.trade-multi > input:focus-visible { outline:3px solid var(--brand); outline-offset:3px; }
@media(max-width:600px) { .trade-computed-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
.modal:has(form[data-collection="trade"]) { width:min(920px,calc(100vw - 32px)); max-height:90vh; }
.trade-section,.trade-computed,.trade-multi.full { grid-column:1 / -1; }
.trade-session-context { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; grid-column:1 / -1; }
.trade-session-context > [hidden] { display:none; }
.trade-session-context > div { min-width:0; }
@media(max-width:600px) { .trade-session-context { grid-template-columns:1fr; } }

.trade-image-section { grid-column:1/-1; min-width:0; border:1px solid var(--line); border-radius:16px; padding:16px; background:var(--surface); }
.trade-image-section:focus-visible { outline:3px solid var(--brand); outline-offset:3px; }
.trade-image-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; }
.trade-image-header h3 { font-size:16px; margin:0; }
.trade-image-header > div { display:flex; gap:8px; flex-wrap:wrap; }
.trade-image-section > p { font-size:12px; line-height:1.6; }
.trade-image-upload { position:relative; cursor:pointer; overflow:hidden; }
.trade-image-upload input { position:absolute; inset:0; opacity:0; width:100%; cursor:pointer; }
.trade-image-upload:focus-within { outline:3px solid var(--brand); outline-offset:3px; }
.trade-image-gallery { display:grid; gap:16px; min-width:0; }
.trade-image-gallery figure { margin:0; min-width:0; border:1px solid var(--line); border-radius:12px; overflow:hidden; }
.trade-image-gallery figure > a { display:block; background:var(--surface-soft); }
.trade-image-gallery img { display:block; width:100%; height:clamp(260px,45vw,480px); object-fit:contain; }
.trade-image-gallery figcaption { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; padding:10px 14px; font-size:12px; }
.trade-image-gallery figcaption > span { overflow-wrap:anywhere; min-width:0; }
.trade-image-empty { display:grid; place-items:center; min-height:180px; text-align:center; padding:20px; background:var(--surface-soft); border:1px dashed var(--line); border-radius:12px; color:var(--muted); }
.trade-image-message { color:var(--brand-strong); margin-bottom:0; }

.trade-choice { position:relative; min-width:0; width:100%; }
.trade-choice-field-header { display:flex; align-items:center; justify-content:space-between; gap:10px; min-height:32px; margin-bottom:5px; }
.trade-choice-field-header > label { margin:0; }
.trade-choice-pin { display:inline-flex; align-items:center; justify-content:center; width:34px; height:34px; flex-shrink:0; border:1px solid var(--line); border-radius:9px; color:var(--muted); background:var(--surface); }
.trade-choice-pin svg { width:18px; height:18px; }
.trade-choice-pin[aria-pressed="true"] { color:var(--brand-strong); background:var(--brand-soft); border-color:var(--brand); }
.trade-choice-pin:focus-visible { outline:3px solid var(--brand); outline-offset:3px; }
.trade-choice-trigger:disabled { opacity:1; cursor:default; background:var(--surface-soft); }
.trade-choice-trigger,.trade-choice-option { display:flex; align-items:center; gap:9px; text-align:left; width:100%; min-width:0; color:var(--foreground); font:inherit; font-size:13px; }
.trade-choice-trigger { min-height:46px; border:1px solid var(--line); border-radius:12px; padding:10px 12px; background:var(--surface); }
.trade-choice-trigger[aria-expanded="true"] { border-color:var(--brand); }
.trade-choice-label { flex:1; min-width:0; overflow-wrap:anywhere; }
.trade-choice-icon { flex:0 0 24px; width:24px; height:24px; display:grid; place-items:center; border-radius:8px; background:var(--surface-soft); color:var(--brand-strong); }
.trade-choice-icon svg { width:17px; height:17px; }
.trade-choice-session-icon svg { width:21px; height:21px; }
.trade-choice-tone-1 { color:#9b641a; } .trade-choice-tone-2 { color:#6750a4; } .trade-choice-tone-3 { color:#b44949; } .trade-choice-tone-4 { color:#27708f; } .trade-choice-tone-5 { color:#397b61; }
.trade-choice-direction-bearish { color:#bd3037; }
.trade-choice-direction-bullish { color:var(--brand-strong); }
.trade-choice-direction-flat,.trade-choice-direction-neutral { color:var(--muted); }
:root[data-theme="Oscuro"] .trade-choice-direction-bearish { color:#ff9299; }
:root[data-theme="Oscuro"] .trade-choice-tone-1 { color:#efc06a; } :root[data-theme="Oscuro"] .trade-choice-tone-2 { color:#c4b0f0; } :root[data-theme="Oscuro"] .trade-choice-tone-3 { color:#f1a2a2; } :root[data-theme="Oscuro"] .trade-choice-tone-4 { color:#8ccbe5; } :root[data-theme="Oscuro"] .trade-choice-tone-5 { color:#8bd5b4; }
.trade-choice-metrics { display:inline-flex; align-items:center; gap:6px; flex-shrink:0; font-size:11px; font-variant-numeric:tabular-nums; white-space:nowrap; color:var(--muted); }
.trade-choice-ring { width:20px; height:20px; flex-shrink:0; fill:none; stroke:var(--line); stroke-width:3; transform:rotate(-90deg); }
.trade-choice-ring .trade-choice-progress { stroke:var(--brand); }
.trade-choice-count { min-width:14px; text-align:right; }
.trade-choice-panel { margin-top:7px; padding:10px; border:1px solid var(--line); border-radius:14px; background:var(--surface); box-shadow:0 12px 30px #00000014; }
.trade-choice-panel[hidden] { display:none; }
.trade-choice-panel input { width:100%; min-width:0; }
.trade-choice-help { margin:9px 2px; font-size:11px; color:var(--muted); line-height:1.5; }
.trade-choice-options { max-height:280px; overflow-y:auto; overscroll-behavior:contain; }
.trade-choice-option { min-height:42px; padding:8px 7px; border:0; border-radius:8px; background:transparent; }
.trade-choice-option:hover,.trade-choice-option[aria-selected="true"] { background:var(--surface-soft); }
.trade-choice :is(button,input):focus-visible { outline:3px solid var(--brand); outline-offset:2px; }
@media(max-width:600px) { .trade-choice-trigger,.trade-choice-option { gap:6px; padding-inline:8px; } .trade-choice-metrics { gap:4px; } }
.trade-risk-heading { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.trade-risk-heading > label { margin:0; }
.trade-risk-info { position:relative; }
.trade-risk-info > summary { list-style:none; display:grid; place-items:center; width:19px; height:19px; border:1px solid var(--muted); border-radius:50%; color:var(--muted); cursor:pointer; font:600 12px Georgia,serif; }
.trade-risk-info > summary::-webkit-details-marker { display:none; }
.trade-risk-info > div { position:absolute; left:0; bottom:28px; z-index:20; width:min(340px,65vw); padding:14px; border:1px solid var(--line); border-radius:12px; background:var(--surface); color:var(--foreground); box-shadow:0 8px 30px #0003; font-size:12px; line-height:1.6; }
.trade-risk-info > summary:focus-visible { outline:2px solid var(--brand); outline-offset:3px; }
.trade-risk-low { color:#a97708!important; background:#fff4d8!important; }
.trade-risk-medium { color:#2563eb!important; background:#e8f0ff!important; }
.trade-risk-high { color:#c63737!important; background:#fff0ef!important; }
:root[data-theme="Oscuro"] .trade-risk-low { color:#f5c344!important; background:#59451d!important; }
:root[data-theme="Oscuro"] .trade-risk-medium { color:#83b4ff!important; background:#183458!important; }
:root[data-theme="Oscuro"] .trade-risk-high { color:#ff9292!important; background:#542929!important; }
.trade-choice-option:has(.trade-risk-low) .trade-choice-label,.trade-choice-trigger:has(.trade-risk-low) .trade-choice-label { color:#a97708; }
.trade-choice-option:has(.trade-risk-medium) .trade-choice-label,.trade-choice-trigger:has(.trade-risk-medium) .trade-choice-label { color:#3878df; }
.trade-choice-option:has(.trade-risk-high) .trade-choice-label,.trade-choice-trigger:has(.trade-risk-high) .trade-choice-label { color:#d34949; }
:root[data-theme="Oscuro"] :is(.trade-choice-option,.trade-choice-trigger):has(.trade-risk-low) .trade-choice-label { color:#f5c344; }
:root[data-theme="Oscuro"] :is(.trade-choice-option,.trade-choice-trigger):has(.trade-risk-medium) .trade-choice-label { color:#83b4ff; }
:root[data-theme="Oscuro"] :is(.trade-choice-option,.trade-choice-trigger):has(.trade-risk-high) .trade-choice-label { color:#ff9292; }
.trade-trend-with { color:var(--positive)!important; background:var(--brand-soft)!important; }
.trade-trend-counter { color:var(--negative)!important; background:var(--danger-soft)!important; }
:is(.trade-choice-option,.trade-choice-trigger):has(.trade-trend-with) .trade-choice-label { color:var(--positive); }
:is(.trade-choice-option,.trade-choice-trigger):has(.trade-trend-counter) .trade-choice-label { color:var(--negative); }
/* Spacious, grouped trade editor. No fields are hidden or removed. */
:root #modalRoot .modal:has(#recordForm[data-collection="trade"]) { width:min(1180px,calc(100vw - 40px)); max-height:calc(100dvh - 40px); display:flex; flex-direction:column; overflow:hidden; }
:root #modalRoot .modal:has(#recordForm[data-collection="trade"]) > .modal-header { flex:none; padding:18px 24px; }
:root #modalRoot #recordForm[data-collection="trade"] { display:flex; flex-direction:column; min-height:0; }
:root #modalRoot #recordForm[data-collection="trade"] > .modal-body { display:flex; flex-direction:column; padding:0; min-height:0; overflow:hidden; }
:root #modalRoot #recordForm[data-collection="trade"] > .modal-body > .form-grid { display:block; min-height:0; overflow-y:auto; padding:0 24px 24px; scroll-behavior:smooth; scroll-padding-top:76px; }
:root #modalRoot #recordForm[data-collection="trade"] .modal-footer { flex:none; padding:14px 24px; border-top:1px solid var(--line); background:var(--surface); }
.trade-editor-nav { position:sticky; top:0; z-index:5; display:flex; gap:6px; overflow-x:auto; padding:12px 0; background:var(--surface); border-bottom:1px solid var(--line); margin-bottom:20px; }
.trade-editor-nav button { display:flex; gap:6px; align-items:center; flex-shrink:0; border:1px solid var(--line); border-radius:9px; padding:8px 10px; background:var(--surface-soft); color:var(--foreground); font-size:11px; cursor:pointer; }
.trade-editor-nav button span { color:var(--brand); font-size:10px; font-weight:700; }
.trade-editor-nav button:hover { background:var(--brand-soft); border-color:var(--brand); }
.trade-editor-nav button:focus-visible { outline:2px solid var(--brand); outline-offset:2px; }
.trade-editor-block { border:1px solid var(--line); border-radius:17px; background:var(--surface); padding:20px; margin:0 0 20px; scroll-margin-top:76px; min-width:0; }
.trade-editor-heading { display:flex; align-items:center; gap:12px; padding-bottom:16px; margin-bottom:14px; border-bottom:1px solid var(--line); }
.trade-editor-heading > span { display:grid; place-items:center; width:36px; height:36px; flex-shrink:0; background:var(--brand-soft); color:var(--brand); border-radius:11px; font-weight:700; font-size:12px; }
.trade-editor-heading h3 { margin:0; font-size:16px; letter-spacing:-.02em; }
.trade-editor-heading p { margin:5px 0 0; color:var(--muted); font-size:11px; line-height:1.5; }
.trade-editor-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; align-items:start; }
:root #modalRoot .trade-editor-grid > .field { display:flex; flex-direction:column; gap:7px; min-width:0; margin:0; }
:root #modalRoot .trade-editor-grid > .field > :is(label,.field-label,.trade-choice-field-header,.trade-risk-heading) { margin:0; min-height:32px; display:flex; align-items:center; line-height:1.4; }
:root #modalRoot .trade-editor-grid .trade-choice-field-header { justify-content:space-between; }
:root #modalRoot .trade-editor-grid .trade-choice-field-header > label { margin:0; }
:root #modalRoot .trade-editor-grid .trade-risk-heading > label { margin:0; }
:root #modalRoot .trade-editor-grid :is(input:not([type="checkbox"]):not([type="file"]),select,.trade-choice-trigger) { min-height:44px; }
.trade-editor-grid > .full { grid-column:1 / -1; }
:root #modalRoot .trade-editor-grid > .field:has([name="pnl"]) { border-radius:12px; background:var(--brand-soft); padding:12px; }
:root #modalRoot .trade-editor-grid > .field:has([name="backtest"]) { grid-column:1 / -1; padding:10px 12px; background:var(--surface-soft); border:1px solid var(--line); border-radius:10px; }
:root #modalRoot .trade-editor-grid > .field:has([name="backtest"]) label { min-height:0; }
:root #modalRoot .trade-editor-grid .field-stack { gap:7px; }
:root #modalRoot .trade-editor-grid textarea { min-height:110px; }
.trade-editor-grid .trade-week-field small { font-size:10px; }
.trade-editor-grid .trade-image-section { background:var(--surface-soft); }
@media(max-width:950px) { .trade-editor-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:620px) {
 :root #modalRoot .modal:has(#recordForm[data-collection="trade"]) { width:calc(100vw - 16px); max-height:calc(100dvh - 20px); }
 :root #modalRoot .modal:has(#recordForm[data-collection="trade"]) > .modal-header { padding:13px 16px; }
 :root #modalRoot #recordForm[data-collection="trade"] > .modal-body > .form-grid { padding:0 12px 16px; }
 .trade-editor-block { padding:14px; margin-bottom:14px; }
 .trade-editor-grid { grid-template-columns:minmax(0,1fr); gap:14px; }
 .trade-editor-nav { padding:9px 0; margin-bottom:14px; }
 :root #modalRoot #recordForm[data-collection="trade"] .modal-footer { padding:12px 16px; }
}
@media(prefers-reduced-motion:reduce) { :root #modalRoot #recordForm[data-collection="trade"] > .modal-body > .form-grid { scroll-behavior:auto; } }
.trade-exit-behavior { min-width:0; margin:0; padding:14px; border:1px solid var(--line); border-radius:12px; }
.trade-exit-behavior legend { padding:0 6px; color:var(--foreground); font-size:12px; font-weight:600; }
.trade-exit-options { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.trade-exit-options label { position:relative; cursor:pointer; margin:0; }
.trade-exit-options input { position:absolute; opacity:0; width:1px; height:1px; }
.trade-exit-options span { display:flex; align-items:center; justify-content:center; min-height:44px; padding:10px; text-align:center; border:1px solid var(--line); border-radius:9px; background:var(--surface-soft); color:var(--muted); font-size:12px; font-weight:600; }
.trade-exit-options input:checked + span { color:var(--brand-strong); border-color:var(--brand); background:var(--brand-soft); }
.trade-exit-options input:focus-visible + span { outline:2px solid var(--brand); outline-offset:3px; }
.trade-exit-behavior > button { margin-top:10px; font-size:11px; }
@media(max-width:420px) { .trade-exit-options { grid-template-columns:1fr; } }

/* Signed P&L: the amount, result selector and field background agree. */
:root #modalRoot :is(.trade-editor-grid,.form-grid) > .field[data-pnl-tone] { border-radius:12px; padding:12px; }
:root #modalRoot :is(.trade-editor-grid,.form-grid) > .field[data-pnl-tone="loss"] { background:var(--danger-soft); }
:root #modalRoot :is(.trade-editor-grid,.form-grid) > .field[data-pnl-tone="gain"] { background:var(--brand-soft); }
:root #modalRoot :is(.trade-editor-grid,.form-grid) > .field[data-pnl-tone="neutral"] { background:var(--surface-soft); }
:root #modalRoot :is(.trade-editor-grid,.form-grid) > .field[data-pnl-tone="loss"] input { color:var(--red); }
:root #modalRoot :is(.trade-editor-grid,.form-grid) > .field[data-pnl-tone="gain"] input { color:var(--green); }

.edge-choice-field { border:0; margin:0; padding:0; min-width:0; }
.edge-choice-field legend { font-weight:650; margin-bottom:8px; }
.edge-choice-field > p { margin:0 0 12px; }
.edge-emotion-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.edge-emotion-option { position:relative; display:block; cursor:pointer; }
.edge-emotion-option:last-child:nth-child(odd) { grid-column:1/-1; }
.edge-emotion-option input { position:absolute; opacity:0; width:1px; height:1px; }
.edge-emotion-option > span { display:block; padding:14px; text-align:center; border:1px solid var(--line); border-radius:10px; background:var(--surface-soft); font-weight:650; }
.edge-emotion-option input:checked + span { border-color:var(--brand); color:var(--brand); box-shadow:inset 0 0 0 1px var(--brand); background:var(--brand-soft); }
.edge-emotion-option input:focus-visible + span { outline:2px solid var(--brand); outline-offset:3px; }
.edge-emotion-option > small { display:none; position:absolute; z-index:15; left:0; right:0; top:calc(100% + 5px); padding:12px; border:1px solid var(--line); border-radius:10px; background:var(--surface); color:var(--text); box-shadow:0 6px 20px #0003; line-height:1.5; }
.edge-emotion-option:hover > small,.edge-emotion-option:focus-within > small { display:block; }
.edge-neutral-options { grid-template-columns:repeat(2,minmax(0,1fr)); }
@media(max-width:560px) { .edge-emotion-options { grid-template-columns:1fr; } }
