/* ==========================================================================
   WebTrader v2

   Scroll architecture (the thing that was broken before): the app shell is one
   viewport tall and never scrolls. On desktop each panel owns its own scroller.
   On mobile .wt-body is the single scroller and every inner scroller is turned
   off, so there is never a nested-overflow trap.
   ========================================================================== */

:root {
    --wt-header-h:     52px;
    --wt-side-w:       300px;
    --wt-gap:          8px;
    --wt-radius:       10px;
    --wt-radius-lg:    14px;

    --wt-safe-top:     env(safe-area-inset-top, 0px);
    --wt-safe-bottom:  env(safe-area-inset-bottom, 0px);
}

/* Dark is the default. The brand hue is shared; greens and reds are lifted a
   little on dark so they keep the same perceived weight. */
[data-theme="dark"] {
    --wt-brand:        #25c4ee;
    --wt-brand-ink:    #123b52;
    --wt-brand-soft:   rgba(37, 196, 238, .14);

    --wt-text:         #e6ebf2;
    --wt-text-2:       #8b98ad;
    --wt-text-3:       #5a6678;
    --wt-caption:      #7c8899;

    --wt-green:        #16a394;
    --wt-green-soft:   rgba(22, 163, 148, .18);
    --wt-red:          #ef4560;
    --wt-red-soft:     rgba(239, 69, 96, .18);
    --wt-warning:      #fda522;
    --wt-yellow:       rgba(253, 165, 34, .12);
    --wt-warning-ink:  #ffce85;

    --wt-app-bg:       #0d1219;
    --wt-card:         #151b24;
    --wt-surface:      #1a212c;
    --wt-surface-2:    #232c3a;
    --wt-surface-3:    #38424f;
    --wt-line:         #242c38;
}

[data-theme="light"] {
    --wt-brand:        #25c4ee;
    --wt-brand-ink:    #082e44;
    --wt-brand-soft:   #e6f8fd;

    --wt-text:         #1a2028;
    --wt-text-2:       #64748c;
    --wt-text-3:       #bbc4d3;
    --wt-caption:      #95a4bb;

    --wt-green:        #0b827b;
    --wt-green-soft:   #e3f4f2;
    --wt-red:          #de3550;
    --wt-red-soft:     #fce8ec;
    --wt-warning:      #fda522;
    --wt-yellow:       #fff8e1;
    --wt-warning-ink:  #7a5200;

    --wt-app-bg:       #eaeef4;
    --wt-card:         #ffffff;
    --wt-surface:      #f9fafb;
    --wt-surface-2:    #eaeef4;
    --wt-surface-3:    #bbc4d3;
    --wt-line:         #e4e9f0;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--wt-app-bg);
    color: var(--wt-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; }

.wt-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.wt-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    min-height: 0;
}

.wt-up   { color: var(--wt-green); }
.wt-down { color: var(--wt-red); }
.wt-flat { color: var(--wt-text-2); }
.wt-num  { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Header
   ========================================================================== */
.wt-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    height: calc(var(--wt-header-h) + var(--wt-safe-top));
    padding: var(--wt-safe-top) 14px 0;
    background: var(--wt-card);
    border-bottom: 1px solid var(--wt-line);
}

.wt-logo { height: 22px; width: auto; flex: 0 0 auto; }
/* The wordmark is near-white, so it needs its own backing on a light header */
[data-theme="light"] .wt-logo {
    height: 30px;
    padding: 4px 8px;
    background: #0b1b3d;
    border-radius: 6px;
}

.wt-account {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px;
    background: var(--wt-surface);
    border: 1px solid var(--wt-line);
    border-radius: 20px;
    white-space: nowrap;
}
.wt-account-tag {
    padding: 1px 6px;
    background: var(--wt-green);
    border-radius: 4px;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .5px;
}
.wt-account-value { font-weight: 700; font-size: 13px; }

/* Account strip. Eight figures never fit a phone, so it scrolls sideways and
   the divider only appears between visible items. */
.wt-metrics {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 0;
    margin-left: auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.wt-metrics::-webkit-scrollbar { display: none; }

.wt-metric {
    flex: 0 0 auto;
    padding: 0 10px;
    text-align: right;
    white-space: nowrap;
    border-left: 1px solid var(--wt-line);
}
.wt-metric:first-child { border-left: none; }
.wt-metric-label { display: block; font-size: 10px; color: var(--wt-caption); }
.wt-metric-value { display: block; font-size: 13px; font-weight: 700; }
.wt-metric-value small { font-size: 9px; color: var(--wt-caption); font-weight: 600; }

.wt-iconbtn {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    background: var(--wt-surface);
    border: 1px solid var(--wt-line);
    border-radius: 50%;
    color: var(--wt-text-2);
    text-decoration: none;
    cursor: pointer;
}
.wt-iconbtn:hover { background: var(--wt-surface-2); color: var(--wt-text); }

.wt-deposit {
    flex: 0 0 auto;
    padding: 7px 18px;
    background: var(--wt-brand);
    border: none;
    border-radius: var(--wt-radius);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.wt-deposit:hover { filter: brightness(.94); color: #fff; }

.wt-back {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: none; /* only shown on the mobile symbol screen */
    place-items: center;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--wt-text);
    font-size: 16px;
    cursor: pointer;
}
.wt-back:hover { background: var(--wt-surface-2); }

/* ==========================================================================
   Body
   ========================================================================== */
.wt-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: var(--wt-side-w) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 240px;
    gap: var(--wt-gap);
    padding: var(--wt-gap);
    overflow: hidden;
}

.wt-card {
    background: var(--wt-card);
    border: 1px solid var(--wt-line);
    border-radius: var(--wt-radius-lg);
    overflow: hidden;
}

.wt-sidebar {
    grid-column: 1;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.wt-chart-panel {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.wt-positions {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ==========================================================================
   Watchlist
   ========================================================================== */
.wt-segment {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid var(--wt-line);
}
.wt-seg-btn {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 6px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--wt-text-2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.wt-seg-btn.is-active { background: var(--wt-surface-2); color: var(--wt-text); }
.wt-seg-btn i { font-size: 11px; }
.wt-seg-btn.is-active i { color: var(--wt-brand); }

.wt-searchbtn {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--wt-text-2);
    cursor: pointer;
}
.wt-searchbtn:hover { background: var(--wt-surface-2); }

.wt-searchbar {
    flex: 0 0 auto;
    display: none;
    padding: 0 8px 8px;
    border-bottom: 1px solid var(--wt-line);
}
.wt-searchbar.is-open { display: block; }
.wt-searchbar input {
    width: 100%;
    padding: 7px 11px;
    background: var(--wt-surface);
    border: 1px solid var(--wt-line);
    border-radius: 8px;
    color: var(--wt-text);
    font-size: 13px;
}
.wt-searchbar input:focus { outline: none; border-color: var(--wt-brand); }

.wt-list-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: var(--wt-surface);
    border-bottom: 1px solid var(--wt-line);
    font-size: 10px;
    color: var(--wt-caption);
}
.wt-col-symbol { flex: 1 1 auto; }
.wt-col-price  { flex: 0 0 76px; text-align: right; }
.wt-col-daily  { flex: 0 0 58px; text-align: right; }

.wt-symbols { flex: 1 1 auto; }

/* Asset class groups. The default watchlist is a flat price list; the search
   button switches it into browse-by-category mode, where the groups collapse
   a few hundred rows into a short menu. */
.wt-group { border-bottom: 1px solid var(--wt-line); }
.wt-group-head {
    width: 100%;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 13px 12px;
    background: transparent;
    border: none;
    color: var(--wt-text);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.wt-group-head:hover { background: var(--wt-surface); }
.wt-group-icon { flex: 0 0 16px; color: var(--wt-text-2); font-size: 13px; }
.wt-group-name { flex: 0 0 auto; }
.wt-group-count {
    flex: 0 0 auto;
    padding: 1px 7px;
    background: var(--wt-surface-2);
    border-radius: 10px;
    color: var(--wt-text-2);
    font-size: 11px;
    font-weight: 600;
}
.wt-group-caret {
    margin-left: auto;
    color: var(--wt-text-2);
    font-size: 11px;
    transition: transform .18s ease;
}
.wt-group.is-open .wt-group-caret { transform: rotate(180deg); }

.wt-app.is-browsing .wt-group-head { display: flex; }
.wt-app.is-browsing .wt-group-body { display: none; }
.wt-app.is-browsing .wt-group.is-open .wt-group-body { display: block; }

.wt-symbol { border-bottom: 1px solid var(--wt-line); }
.wt-group-body .wt-symbol:last-child { border-bottom: none; }
.wt-symbol-row {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    cursor: pointer;
}
.wt-symbol-row:hover { background: var(--wt-surface); }
.wt-symbol.is-open .wt-symbol-row { background: var(--wt-surface); }

.wt-symbol-badge {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin-right: 9px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--wt-brand-ink);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
}

.wt-symbol-id { flex: 1 1 auto; min-width: 0; }
.wt-symbol-name {
    display: block;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wt-symbol-sub {
    display: block;
    font-size: 10px;
    color: var(--wt-caption);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wt-symbol-price { flex: 0 0 76px; text-align: right; font-size: 12px; font-weight: 700; }
.wt-symbol-daily { flex: 0 0 58px; text-align: right; font-size: 11px; font-weight: 600; }

/* Quick ticket, expands under the tapped row */
.wt-quick {
    display: none;
    padding: 0 10px 10px;
    background: var(--wt-surface);
}
.wt-symbol.is-open .wt-quick { display: block; }

.wt-stepper { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.wt-step {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    background: var(--wt-card);
    border: 1px solid var(--wt-line);
    border-radius: 7px;
    color: var(--wt-brand);
    font-size: 14px;
    cursor: pointer;
}
.wt-step:hover { background: var(--wt-brand-soft); }
.wt-stepper-mid { flex: 1 1 auto; text-align: center; min-width: 0; }
.wt-stepper-vol { display: block; font-size: 13px; font-weight: 700; }
.wt-stepper-eq  { display: block; font-size: 10px; color: var(--wt-caption); }

.wt-sides { display: flex; gap: 7px; }
.wt-sidebtn {
    flex: 1 1 0;
    padding: 9px 6px;
    border: none;
    border-radius: 9px;
    color: #fff;
    cursor: pointer;
    line-height: 1.2;
    text-align: center;
}
.wt-sidebtn small { display: block; font-size: 10px; font-weight: 700; letter-spacing: .5px; opacity: .9; }
.wt-sidebtn b { display: block; font-size: 13px; font-weight: 700; }
.wt-sidebtn-sell { background: var(--wt-red); }
.wt-sidebtn-buy  { background: var(--wt-green); }
.wt-sidebtn:disabled { background: var(--wt-surface-3); cursor: not-allowed; }

.wt-quick-foot { display: flex; align-items: center; gap: 6px; }
.wt-advanced {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    margin-top: 8px;
    padding: 6px;
    background: transparent;
    border: none;
    color: var(--wt-text-2);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.wt-advanced:hover { color: var(--wt-brand); }

.wt-info {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    margin-top: 8px;
    display: grid;
    place-items: center;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: var(--wt-text-3);
    font-size: 13px;
    cursor: pointer;
}
.wt-info:hover,
.wt-info.is-on { background: var(--wt-surface-2); color: var(--wt-brand); }
/* The chart header has its own rhythm */
.wt-info-chart { margin-top: 0; }

/* ==========================================================================
   Account summary drop-down
   ========================================================================== */
.wt-metricspop {
    position: fixed;
    left: 10px;
    right: 10px;
    z-index: 55;
    padding: 13px 14px 15px;
    background: var(--wt-card);
    border: 1px solid var(--wt-line);
    border-radius: 12px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, .45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .14s ease, transform .14s ease, visibility .14s;
}
.wt-metricspop.is-open { opacity: 1; visibility: visible; transform: none; }

.wt-metricspop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
    margin: 0;
}
.wt-metricspop-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.wt-metricspop-item dt { font-size: 10px; font-weight: 600; color: var(--wt-caption); }
.wt-metricspop-item dd { margin: 0; font-size: 14px; font-weight: 700; color: var(--wt-text); }

/* ==========================================================================
   Symbol details popup
   ========================================================================== */
.wt-infopop {
    position: fixed;
    z-index: 60;
    width: 300px;
    padding: 12px 14px 14px;
    background: var(--wt-card);
    border: 1px solid var(--wt-line);
    border-radius: 12px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, .45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity .13s ease, transform .13s ease, visibility .13s;
    pointer-events: none;
}
.wt-infopop.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.wt-infopop-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding-bottom: 9px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--wt-line);
}
.wt-infopop-symbol { font-size: 13px; font-weight: 700; }
.wt-infopop-class { margin-left: auto; font-size: 10px; color: var(--wt-caption); }

.wt-infopop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px 12px;
    margin: 0;
}
.wt-infopop-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
/* Long values read better across the full width */
.wt-infopop-item.is-wide { grid-column: 1 / -1; }
.wt-infopop-item dt {
    font-size: 10px;
    font-weight: 600;
    color: var(--wt-caption);
}
.wt-infopop-item dd {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--wt-text);
    word-break: break-word;
}

/* ==========================================================================
   Chart
   ========================================================================== */
.wt-chart-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--wt-line);
}
.wt-tf {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--wt-line);
    overflow-x: auto;
    scrollbar-width: none;
}
.wt-tf::-webkit-scrollbar { display: none; }
.wt-tf-btn {
    flex: 0 0 auto;
    padding: 5px 11px;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: var(--wt-text-2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.wt-tf-btn.is-active { background: var(--wt-surface-2); color: var(--wt-text); }

.wt-chart-symbol { font-size: 14px; font-weight: 700; }
.wt-chart-quote { margin-left: auto; display: flex; align-items: baseline; gap: 8px; }
.wt-chart-price { font-size: 15px; font-weight: 700; }
.wt-chart-change { font-size: 12px; font-weight: 600; }

.wt-chart-box { flex: 1 1 auto; min-height: 0; position: relative; }
#wt-chart { width: 100%; height: 100%; }

/* Shown while candles load, and for the few instruments whose feed has no
   history endpoint, where the chart fills in from live ticks instead. */
.wt-chart-empty {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--wt-muted);
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
}
.wt-chart-empty.is-shown { display: flex; }

/* ==========================================================================
   Positions
   ========================================================================== */
.wt-tabs {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
    padding: 7px 8px;
    border-bottom: 1px solid var(--wt-line);
    overflow-x: auto;
    scrollbar-width: none;
}
.wt-tabs::-webkit-scrollbar { display: none; }
.wt-tab {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--wt-text-2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.wt-tab.is-active { background: var(--wt-surface-2); color: var(--wt-text); }
.wt-tab-dot { width: 7px; height: 7px; border-radius: 2px; background: var(--wt-text-3); }
.wt-tab.is-active .wt-tab-dot { background: var(--wt-brand); }
/* Narrow screens use the one-word label, so three tabs fit without scrolling */
.wt-tab-short { display: none; }

.wt-panels { flex: 1 1 auto; min-height: 0; }
.wt-panel { display: none; }
.wt-panel.is-active { display: block; }

.wt-ptable { width: 100%; border-collapse: collapse; }
.wt-ptable th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 7px 12px;
    background: var(--wt-surface);
    border-bottom: 1px solid var(--wt-line);
    color: var(--wt-caption);
    font-size: 10px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}
.wt-ptable td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--wt-line);
    font-size: 12px;
    white-space: nowrap;
}
.wt-ptable tbody tr:hover { background: var(--wt-surface); }
.wt-reason { color: var(--wt-text-2); }
.wt-opened { color: var(--wt-text-2); white-space: nowrap; }

/* Closed positions: period filter above the history table */
.wt-histbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 7px 12px;
    border-bottom: 1px solid var(--wt-line);
}
.wt-histranges { display: flex; flex-wrap: wrap; gap: 4px; }
.wt-histdates { display: flex; flex-wrap: wrap; gap: 10px; }
.wt-histdates label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--wt-caption); font-size: 11px; font-weight: 600; }
.wt-histdates input {
    padding: 4px 8px;
    background: var(--wt-surface);
    border: 1px solid var(--wt-line);
    border-radius: 7px;
    color: var(--wt-text);
    font-size: 12px;
}
[data-theme="dark"] .wt-histdates input { color-scheme: dark; }
.wt-histsum { margin-left: auto; display: flex; gap: 14px; color: var(--wt-caption); font-size: 12px; white-space: nowrap; }
.wt-histsum b { font-weight: 700; }
.wt-hist-empty td { padding: 22px 12px; color: var(--wt-caption); text-align: center; }
/* Row cards set display:block on narrow screens, which would override [hidden] */
.wt-histdates[hidden], .wt-ptable tr[hidden] { display: none !important; }

.wt-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.wt-pill-buy  { background: var(--wt-green-soft); color: var(--wt-green); }
.wt-pill-sell { background: var(--wt-red-soft);   color: var(--wt-red); }

.wt-rowbtn {
    padding: 5px 12px;
    background: var(--wt-card);
    border: 1px solid var(--wt-line);
    border-radius: 7px;
    color: var(--wt-text-2);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.wt-rowbtn:hover { background: var(--wt-red); border-color: var(--wt-red); color: #fff; }
.wt-rowbtn-edit:hover { background: var(--wt-brand); border-color: var(--wt-brand); color: var(--wt-brand-ink); }
.wt-rowactions { display: flex; gap: 6px; justify-content: flex-end; }
.wt-rowactions form { margin: 0; }

/* SL / TP cell: shows the level; the row's SL / TP button edits it */
.wt-level { padding: 2px 4px; border-radius: 5px; color: var(--wt-caption); font-variant-numeric: tabular-nums; }
.wt-level.is-set { color: var(--wt-text); }
.wt-level.is-flash { animation: wt-level-flash 1.2s ease; }
@keyframes wt-level-flash {
    0%   { background: var(--wt-brand-soft); }
    100% { background: transparent; }
}

/* Modal used to edit the protective levels of an open position */
.wt-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.wt-modal.is-open { display: flex; }
.wt-modal-backdrop { position: absolute; inset: 0; background: rgba(5, 9, 14, .62); }
.wt-modal-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--wt-card);
    border: 1px solid var(--wt-line);
    border-radius: var(--wt-radius-lg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    color: var(--wt-text);
    overflow: hidden;
}
.wt-modal-head {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--wt-line);
}
.wt-modal-title { display: block; font-size: 14px; font-weight: 700; }
.wt-modal-sub { display: block; margin-top: 2px; font-size: 11px; color: var(--wt-caption); }
.wt-modal-body { padding: 14px; overflow-y: auto; }
.wt-modal-foot {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--wt-line);
}

.wt-pm-quote {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 16px;
    padding: 10px;
    background: var(--wt-surface);
    border-radius: 9px;
}
.wt-pm-quote span { display: block; font-size: 10px; color: var(--wt-caption); }
.wt-pm-quote b { display: block; margin-top: 2px; font-size: 13px; }

.wt-pm-units {
    display: none;
    margin-left: auto;
    padding: 2px;
    background: var(--wt-surface);
    border-radius: 7px;
}
.wt-pm-field.is-on .wt-pm-units { display: flex; }
.wt-pm-unit {
    padding: 3px 10px;
    background: transparent;
    border: none;
    border-radius: 5px;
    color: var(--wt-text-2);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.wt-pm-unit.is-active { background: var(--wt-card); color: var(--wt-text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }

.wt-pm-hint { display: block; min-height: 15px; margin-top: 5px; font-size: 11px; color: var(--wt-caption); }
.wt-pm-hint.is-error { color: var(--wt-red); }

.wt-pm-error {
    padding: 9px 11px;
    background: var(--wt-red-soft);
    border-radius: 8px;
    color: var(--wt-red);
    font-size: 12px;
    font-weight: 600;
}

.wt-pm-btn {
    flex: 1 1 0;
    padding: 10px;
    background: var(--wt-surface);
    border: 1px solid var(--wt-line);
    border-radius: 9px;
    color: var(--wt-text);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.wt-pm-btn-primary { background: var(--wt-brand); border-color: var(--wt-brand); color: var(--wt-brand-ink); }
.wt-pm-btn:disabled { opacity: .5; cursor: not-allowed; }

.wt-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 30px 20px;
    text-align: center;
}
.wt-empty-icon {
    width: 54px;
    height: 54px;
    margin-bottom: 6px;
    display: grid;
    place-items: center;
    background: var(--wt-brand-soft);
    border-radius: 50%;
    color: var(--wt-brand);
    font-size: 21px;
}
.wt-empty-title { font-size: 13px; font-weight: 700; }
.wt-empty-text { font-size: 11px; color: var(--wt-caption); }

/* ==========================================================================
   Full order ticket
   Desktop: absolutely positioned over the sidebar box.
   Mobile: a normal block inside the scrolling body.
   ========================================================================== */
.wt-ticket {
    position: absolute;
    left: var(--wt-gap);
    top: var(--wt-gap);
    width: var(--wt-side-w);
    height: calc(100% - (var(--wt-gap) * 2));
    z-index: 20;
    display: none;
    flex-direction: column;
    background: var(--wt-card);
    border: 1px solid var(--wt-line);
    border-radius: var(--wt-radius-lg);
    overflow: hidden;
}
.wt-ticket.is-open { display: flex; }

.wt-ticket-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--wt-line);
}
.wt-ticket-title { font-size: 14px; font-weight: 700; }
.wt-ticket-sub { display: block; font-size: 10px; color: var(--wt-caption); }
.wt-ticket-close {
    margin-left: auto;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--wt-text-2);
    cursor: pointer;
}
.wt-ticket-close:hover { background: var(--wt-surface-2); }

/* The ticket is taller than a laptop viewport once both protective levels are
   open, so the fields scroll and the buy/sell buttons stay pinned in view. */
.wt-ticket-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
}

.wt-mode {
    display: flex;
    margin-bottom: 14px;
    padding: 3px;
    background: var(--wt-surface);
    border-radius: 9px;
}
.wt-mode-btn {
    flex: 1 1 0;
    padding: 7px;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: var(--wt-text-2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.wt-mode-btn.is-active { background: var(--wt-card); color: var(--wt-text); box-shadow: 0 1px 3px rgba(26,32,40,.1); }

.wt-field { margin-bottom: 14px; }
.wt-field-head { display: flex; align-items: center; min-height: 22px; }
.wt-field-head + .wt-inline-stepper,
.wt-field-head + .wt-collapse { margin-top: 8px; }
.wt-field-label { font-size: 11px; font-weight: 600; color: var(--wt-text-2); }

.wt-input {
    width: 100%;
    padding: 9px 11px;
    background: var(--wt-surface);
    border: 1px solid var(--wt-line);
    border-radius: 8px;
    color: var(--wt-text);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    -moz-appearance: textfield;
}
.wt-input::-webkit-outer-spin-button,
.wt-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.wt-input:focus { outline: none; border-color: var(--wt-brand); background: var(--wt-card); }

.wt-eq { display: block; margin-top: 4px; text-align: center; font-size: 10px; color: var(--wt-caption); }

.wt-range {
    width: 100%;
    margin: 10px 0 0;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--wt-surface-2);
}
.wt-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px; height: 15px;
    border-radius: 50%;
    background: var(--wt-brand);
    cursor: pointer;
}
.wt-range::-moz-range-thumb {
    width: 15px; height: 15px;
    border: none;
    border-radius: 50%;
    background: var(--wt-brand);
    cursor: pointer;
}

.wt-toggle { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.wt-toggle input { display: none; }
.wt-toggle-track {
    position: relative;
    flex: 0 0 auto;
    width: 34px;
    height: 19px;
    background: var(--wt-surface-3);
    border-radius: 10px;
    transition: background .18s ease;
}
.wt-toggle-track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 15px; height: 15px;
    background: #fff;
    border-radius: 50%;
    transition: transform .18s ease;
}
.wt-toggle input:checked + .wt-toggle-track { background: var(--wt-brand); }
.wt-toggle input:checked + .wt-toggle-track::after { transform: translateX(15px); }
.wt-toggle-label { font-size: 12px; font-weight: 600; }

.wt-collapse { display: none; margin-top: 4px; }
.wt-collapse.is-open { display: block; }

/* Minus / value / plus row used by the protective levels */
.wt-inline-stepper { display: flex; align-items: center; gap: 7px; }
.wt-inline-stepper .wt-input {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    text-align: center;
}
.wt-inline-stepper .wt-step {
    width: 32px;
    height: 32px;
    font-size: 16px;
    color: var(--wt-brand);
}

/* Unit picker — a text button, not a native select (those look broken on Windows).
   Hidden until the protective level is actually on. */
.wt-unit {
    display: none;
    margin-left: auto;
    padding: 0 14px 0 0;
    background: transparent;
    border: none;
    color: var(--wt-text-2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
}
.wt-field.is-on .wt-unit { display: inline-block; }
.wt-unit::after {
    content: '';
    position: absolute;
    right: 2px;
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -4px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
}
.wt-unit:hover,
.wt-unit:focus { outline: none; color: var(--wt-brand); }

/* Live consequence of the chosen SL/TP level */
.wt-impact {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 7px;
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.wt-impact.is-empty { display: none; }
.wt-impact-arrow { font-size: 9px; }
.wt-impact-pct,
.wt-impact-points { color: var(--wt-text-2); font-weight: 500; }

/* Side picker — one segmented bar, matching Market / Pending */
.wt-sidepick {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 2px;
}
.wt-sidepick-label { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--wt-text-2); }
.wt-sidepick-seg {
    flex: 1 1 auto;
    display: flex;
    padding: 3px;
    background: var(--wt-surface);
    border-radius: 9px;
}
.wt-sidepick-btn {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 6px;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: var(--wt-text-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.wt-side-ico { width: 14px; height: 14px; flex: 0 0 auto; }
.wt-sidepick-btn[data-side-pick="sell"].is-active {
    background: var(--wt-card);
    color: var(--wt-red);
    box-shadow: 0 1px 3px rgba(26,32,40,.12);
}
.wt-sidepick-btn[data-side-pick="buy"].is-active {
    background: var(--wt-card);
    color: var(--wt-green);
    box-shadow: 0 1px 3px rgba(26,32,40,.12);
}

.wt-summary { margin: 14px 0; padding-top: 12px; border-top: 1px solid var(--wt-line); }
.wt-summary-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 12px; }
.wt-summary-row span:first-child { color: var(--wt-text-2); }
.wt-summary-row span:last-child { font-weight: 600; }

.wt-ticket-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: 8px;
    margin: 0 -12px -12px;
    padding: 10px 12px 12px;
    background: var(--wt-card);
}
.wt-action {
    flex: 1 1 0;
    padding: 12px 6px;
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    line-height: 1.2;
}
.wt-action small { display: block; font-size: 10px; font-weight: 700; letter-spacing: .5px; opacity: .9; }
.wt-action b { display: block; font-size: 14px; font-weight: 700; }
.wt-action-sell { background: var(--wt-red); }
.wt-action-buy  { background: var(--wt-green); }
.wt-action.is-dim { opacity: .4; }
.wt-action:disabled { background: var(--wt-surface-3); cursor: not-allowed; opacity: 1; }

.wt-notice {
    display: flex;
    gap: 8px;
    padding: 9px 11px;
    margin-bottom: 13px;
    background: var(--wt-yellow);
    border: 1px solid var(--wt-warning);
    border-radius: 8px;
    color: var(--wt-warning-ink);
    font-size: 11px;
    line-height: 1.4;
}

.wt-section-title {
    padding: 12px 12px 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--wt-text-2);
}

/* ==========================================================================
   Mobile — drill-down, single scroller
   ========================================================================== */
.wt-mobile-only { display: none; }

/* Bottom tab bar. A flex child of .wt-app rather than a fixed overlay, so it
   can never end up sitting on top of the scrolling content. */
.wt-tabbar {
    flex: 0 0 auto;
    background: var(--wt-card);
    border-top: 1px solid var(--wt-line);
    padding-bottom: var(--wt-safe-bottom);
}
.wt-tabbar-btn {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 54px;
    padding: 7px 0;
    background: transparent;
    border: none;
    color: var(--wt-text-3);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.wt-tabbar-btn i { font-size: 17px; }
.wt-tabbar-btn.is-active { color: var(--wt-brand); }

@media (max-width: 991px) {
    .wt-mobile-only { display: flex; }
    .wt-desktop-only { display: none !important; }

    /* .wt-body becomes the one and only scroller */
    .wt-body {
        display: block;
        grid-template-columns: none;
        grid-template-rows: none;
        gap: 0;
        padding: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Inner scrollers off, or they trap the gesture */
    .wt-symbols,
    .wt-panels,
    .wt-ticket-body { overflow: visible; min-height: 0; }
    /* The page itself scrolls here, so pinning would follow the whole document */
    .wt-ticket-actions { position: static; margin: 0; padding: 0; }

    .wt-card { border: none; border-radius: 0; }

    .wt-sidebar,
    .wt-chart-panel,
    .wt-positions {
        display: block;
        min-height: 0;
    }

    /* Trade tab: markets list is the default screen, the symbol screen
       replaces it. Positions live on the Portfolio tab instead. */
    .wt-chart-panel,
    .wt-positions,
    .wt-ticket { display: none; }

    .wt-app.show-symbol .wt-sidebar { display: none; }
    .wt-app.show-symbol .wt-chart-panel { display: block; }
    .wt-app.show-symbol .wt-ticket { display: block; }
    .wt-app.show-symbol .wt-back { display: grid; }

    /* Portfolio tab replaces the whole trade stack. Declared after the
       show-symbol rules so it wins at equal specificity. */
    .wt-app[data-mtab="portfolio"] .wt-sidebar,
    .wt-app[data-mtab="portfolio"] .wt-chart-panel,
    .wt-app[data-mtab="portfolio"] .wt-ticket { display: none; }
    .wt-app[data-mtab="portfolio"] .wt-positions { display: block; }
    .wt-app[data-mtab="portfolio"] .wt-back { display: none; }

    .wt-tab-long { display: none; }
    .wt-tab-short { display: block; }
    .wt-tabs { position: sticky; top: 0; z-index: 10; background: var(--wt-card); }

    /* Ticket flows inline between chart and positions */
    .wt-ticket {
        position: static;
        width: auto;
        height: auto;
        border: none;
        border-radius: 0;
        border-top: 8px solid var(--wt-app-bg);
    }
    .wt-ticket-head { display: none; }

    .wt-positions { border-top: 8px solid var(--wt-app-bg); }
    .wt-app[data-mtab="portfolio"] .wt-positions { border-top: none; }

    .wt-header { gap: 10px; padding-left: 12px; padding-right: 12px; }
    .wt-logo, .wt-account { display: none; }
    .wt-metrics { margin-left: 0; min-width: 0; cursor: pointer; }
    .wt-metric { text-align: left; padding: 0 10px; }
    .wt-deposit { flex: 0 0 auto; padding: 7px 14px; }
    .wt-metric-value { font-size: 12px; }
    .wt-metric-value small { font-size: 9px; color: var(--wt-caption); }

    .wt-segment { position: sticky; top: 0; z-index: 10; background: var(--wt-card); }
    .wt-chart-box { height: 240px; }

    /* Position rows become cards */
    .wt-ptable, .wt-ptable tbody, .wt-ptable tr, .wt-ptable td { display: block; width: 100%; }
    .wt-ptable thead { display: none; }
    .wt-ptable tr { padding: 11px 12px; border-bottom: 1px solid var(--wt-line); }
    .wt-ptable td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 3px 0;
        border: none;
    }
    .wt-ptable td::before {
        content: attr(data-label);
        color: var(--wt-caption);
        font-size: 11px;
        font-weight: 600;
    }
    .wt-ptable td.wt-td-full { display: block; }
    .wt-ptable td.wt-td-full::before { content: none; }
    .wt-ptable .wt-hist-empty td { display: block; }
    .wt-ptable .wt-hist-empty td::before { content: none; }
    .wt-histsum { margin-left: 0; }
    .wt-rowbtn { width: 100%; padding: 9px; margin-top: 7px; }
    .wt-rowactions > * { flex: 1 1 0; }
    .wt-modal { align-items: flex-end; padding: 0; }
    .wt-modal-card { max-width: none; border-radius: var(--wt-radius-lg) var(--wt-radius-lg) 0 0; padding-bottom: var(--wt-safe-bottom); }

    .wt-input { font-size: 16px; } /* below 16px iOS zooms the page on focus */

    /* The tab bar carries the safe-area inset now */
    .wt-body { padding-bottom: 16px; }
}

@media (min-width: 992px) {
    .wt-back { display: none; }

    /* Real scrollbars — hiding them everywhere is part of why the old UI felt
       like it wasn't scrollable */
    .wt-scroll::-webkit-scrollbar { width: 9px; }
    .wt-scroll::-webkit-scrollbar-track { background: transparent; }
    .wt-scroll::-webkit-scrollbar-thumb { background: var(--wt-surface-3); border-radius: 5px; border: 2px solid var(--wt-card); }
    .wt-scroll::-webkit-scrollbar-thumb:hover { background: var(--wt-text-3); }
}
