:root {
    color-scheme: dark;
    --bg: #0d1117;
    --panel: #11151d;
    --panel-raised: #171c25;
    --text: #c9d1d9;
    --muted: #8b949e;
    --border: #303640;
    --buy: #238636;
    --sell: #c83e3a;
    --blue: #58a6ff;
    --amber: #d29922;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 13px;
}

* {
    box-sizing: border-box;
}

html:not(.security-unlocked) body> :not(#pin-gate) {
    display: none !important;
}

.pin-gate {
    position: fixed;
    z-index: 10000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(ellipse at top, #172233 0, var(--bg) 58%);
}

html.security-unlocked .pin-gate {
    display: none;
}

.pin-card {
    display: flex;
    width: min(360px, 100%);
    flex-direction: column;
    gap: 12px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 20px 70px #0008;
}

.pin-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 10px;
    background: #193a29;
    color: #71d18b;
    font-size: 22px;
    font-weight: 800;
}

.pin-card h1 {
    margin: 4px 0 0;
    font-size: 22px;
}

.pin-card p {
    margin: 0 0 8px;
    color: var(--muted);
}

.pin-card label {
    color: var(--text);
}

.pin-card input {
    height: 44px !important;
    font-size: 20px;
    letter-spacing: .35em;
    text-align: center;
}

.pin-card button {
    min-height: 40px;
}

#pin-error {
    min-height: 18px;
    color: #f85149;
}

body {
    margin: 0;
    min-width: 940px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 1px;
}

.topbar {
    min-height: 48px;
    display: grid;
    grid-template-columns: 76px minmax(240px, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 8px 17px;
}

.user-name {
    overflow: hidden;
    color: #c9d1d9;
    font-size: 20px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 42px;
    color: var(--muted);
    white-space: nowrap;
}

.connection-status {
    font-weight: 700;
}

.connection-status.connected {
    color: #4caf50;
}

.connection-status.disconnected {
    color: #f85149;
}

.dashboard {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    padding: 4px 17px 18px;
}

.dashboard-headers-sticky {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 12px;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr .88fr .88fr .6fr 1.38fr 1.08fr;
    align-items: end;
    gap: 10px;
}

.input-group {
    position: relative;
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
}

.input-group>label,
.inline-options legend {
    min-height: 18px;
    color: var(--text);
    text-align: center;
}

select,
input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    height: 27px;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    padding: 3px 8px;
}

.strike-group select {
    padding-right: 28px;
}

.strike-group .info-button {
    position: absolute;
    right: -25px;
    bottom: 2px;
}

.quantity-group {
    margin-left: 12px;
}

.quantity-group select {
    border-color: var(--blue) !important;
}

.inline-options {
    position: relative;
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 2px 2px 3px;
}

.group-title {
    position: absolute;
    top: -21px;
    left: 0;
    width: 100%;
    color: var(--text);
    text-align: center;
}

.inline-options label,
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    white-space: nowrap;
}

.inline-options input,
.toggle input {
    margin: 0;
    accent-color: var(--blue);
}

.secondary-controls,
.account-row {
    display: flex;
    min-height: 31px;
    align-items: center;
    gap: 9px;
}

.compact-field {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    white-space: nowrap;
}

.compact-field input {
    width: 80px !important;
    height: 27px !important;
}

.flex-spacer {
    flex: 1;
}

.one-click {
    color: var(--amber);
    font-weight: 700;
}

.info-button {
    width: 21px;
    height: 21px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #555b62;
    color: #fff;
    font-weight: 700;
}

.monitor-panel {
    display: grid;
    min-height: 104px;
    grid-template-columns: 1fr 1px 1fr 1px 1fr;
    align-items: stretch;
    margin: 2px 10px 5px;
    padding: 10px 16px;
    border: 1px solid #d8dee4;
    border-radius: 5px;
    background: #0c1016;
}

.monitor {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.monitor-divider {
    align-self: stretch;
    margin: 4px 0;
    background: var(--border);
}

.monitor-title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.monitor-price {
    color: #f5f7fa;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
}

.monitor-price.price-up {
    color: #f5f7fa;
}

.monitor-change {
    color: #4caf50;
    font-size: 14px;
    font-weight: 700;
}

.monitor-extra {
    min-height: 15px;
    color: var(--blue);
    font-size: 12px;
}

.action-row {
    display: grid;
    grid-template-columns: .9fr .86fr .8fr 1.18fr 1fr 1fr 1.2fr .9fr .86fr .86fr;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}

.action-row.spread-action-row {
    display: flex;
    width: 100%;
}

.spread-action-row > button {
    flex: 1 1 20%;
    max-width: 200px;
}

.button {
    min-height: 29px;
    padding: 4px 11px;
    border: 1px solid rgba(240, 246, 252, .1);
    border-radius: 4px;
    color: var(--text);
    font-weight: 650;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover:not(:disabled) {
    filter: brightness(1.12);
}

.button:disabled {
    cursor: not-allowed;
    opacity: .64;
}

.button-neutral {
    background: #21262d;
}

.button-buy {
    background: var(--buy);
    color: #fff;
}

.button-sell {
    background: var(--sell);
    color: #fff;
}

.button-warning {
    background: #c66b16;
    color: #111;
}

.mtm {
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

.mtm output {
    margin-left: 8px;
    font-size: 20px;
}

.live-toggle {
    margin-left: auto;
}

.risk-summary {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 4px 14px;
    background: #242526;
    border: 1px solid #3a3b3c;
    border-radius: 20px;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}

.risk-tgt {
    color: #4caf50;
}

.risk-tgt.off {
    color: var(--muted);
}

.risk-sl {
    color: #f44336;
}

.risk-sl.off {
    color: var(--muted);
}

.risk-sep {
    color: #555;
}

.modal-note {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.risk-heading {
    margin: 0;
    color: #ffb74d;
    font-size: 16px;
}

.risk-thresholds {
    display: grid;
    gap: 9px;
}

.risk-thresholds label,
.risk-inline {
    display: grid;
    grid-template-columns: minmax(135px, 1fr) minmax(90px, 1fr);
    align-items: center;
    gap: 8px;
    color: var(--text);
    white-space: nowrap;
}

.risk-action-group {
    display: grid;
    gap: 7px;
}

.risk-action-group strong {
    margin-bottom: 1px;
}

.risk-action-group label,
.risk-check {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    white-space: nowrap;
}

.risk-action-group input,
.risk-check input[type="checkbox"] {
    flex: 0 0 auto;
    accent-color: #f2994a;
}

.risk-separator {
    width: 100%;
    margin: 0;
    border: 0;
    border-top: 1px solid #444;
}

.modal-content h3 {
    margin: 0;
    color: #ff9800;
    font-size: 14px;
}

.risk-inline {
    grid-template-columns: minmax(120px, 1fr) minmax(90px, .8fr) auto;
}

.risk-check input[type="number"] {
    width: 96px;
    margin-left: auto;
}

.button-risk-set {
    background: #ffb74d;
    color: #111;
    font-weight: 750;
}

.modal#risk-modal {
    width: min(330px, calc(100vw - 28px));
}

.modal-content>.risk-check {
    flex-direction: row;
    align-items: center;
}

.modal-content>.risk-inline {
    flex-direction: row;
}

.risk-check input[type="number"]:disabled {
    opacity: .55;
}

.modal#risk-modal .modal-content {
    gap: 10px;
    padding: 18px;
}

.alert-modal-content h2 {
    margin: 0 0 20px 0;
    color: #e5e7eb;
    font-size: 15px;
    text-align: center;
    font-weight: 700;
}

.alert-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
}

.alert-row:has(> input[hidden]) {
    display: none !important;
}

.alert-row > label {
    width: 80px;
    flex-shrink: 0;
    color: var(--text);
    font-weight: 700;
    font-size: 13px;
    line-height: 1.2;
}

.alert-row.checkbox-row > label {
    width: auto;
    flex-shrink: 1;
    white-space: nowrap;
}

.alert-row > input,
.alert-row > select {
    flex: 1;
    height: 28px;
    padding: 0 8px;
    line-height: 26px;
    background: #11141a;
    border: 1px solid #303640;
    color: #e5e7eb;
    border-radius: 4px;
}

.alert-row > input:focus,
.alert-row > select:focus {
    border-color: #3b82f6;
    outline: none;
}

.alert-row.checkbox-row {
    justify-content: flex-start;
}

.alert-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #e5e7eb;
    cursor: pointer;
}

.alert-checkbox-label input[type="checkbox"] {
    accent-color: #3b82f6;
    width: 14px;
    height: 14px;
    margin: 0;
}

.modal#add-alert-modal {
    width: min(380px, calc(100vw - 28px));
}

.limit-order-content h2 {
    margin: 0;
    color: #aaa;
    font-size: 15px;
    text-align: center;
    font-weight: 600;
}

.limit-desc {
    font-weight: 700;
    color: #fff;
    margin-top: 10px;
    font-size: 14px;
}

.limit-ltp {
    color: #fff;
    margin-bottom: 12px;
    font-size: 14px;
}

.limit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 12px;
}

.limit-row>label {
    color: var(--text);
    font-weight: 500;
    font-size: 13px;
}

.limit-row>input,
.limit-row>select {
    width: 140px;
    height: 26px;
    padding: 0 8px;
    line-height: 24px;
}

.limit-radios {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 140px;
}

.limit-radios label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
}

.limit-radios input {
    accent-color: #f2994a;
    margin: 0;
}

.modal#limit-order-modal {
    width: min(320px, calc(100vw - 28px));
}

.workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(7, minmax(90px, 1fr));
    gap: 4px;
    padding: 0 10%;
}

.tab {
    min-height: 35px;
    border: 1px solid #252b35;
    border-bottom: 0;
    border-radius: 5px 5px 0 0;
    background: var(--panel-raised);
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
}

.tab.active {
    border-top: 2px solid var(--blue);
    background: var(--bg);
    color: var(--blue);
}

.settings-panel {
    flex: 1;
    min-height: 0;
    overflow: auto;
    background: var(--panel);
}

.settings-layout {
    display: grid;
    grid-template-columns: 45% 55%;
    gap: 20px;
    padding: 0;
}

.settings-panel[hidden] {
    display: none !important;
}

.settings-left {
    padding: 18px 20px;
    border-right: 1px solid #252b35;
}

.settings-right {
    padding: 18px 20px 18px 0;
}

.settings-panel h2 {
    margin: 0 0 8px;
    font-size: 15px;
    color: #fff;
    font-weight: 700;
}

.settings-panel p {
    color: var(--muted);
    font-size: 12px;
    margin: 0 0 15px;
}

.active-strategies-box {
    margin-top: 20px;
    margin-bottom: 15px;
}

.active-strategies-box h3 {
    margin: 0 0 8px;
    font-size: 13px;
    color: #fff;
}

.strategy-list {
    background: #1e2229;
    border: 1px solid #303640;
    border-radius: 6px;
    padding: 12px;
}

.strategy-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}

.strategy-radio input[type="radio"] {
    accent-color: #f2994a;
}

.strategy-status {
    color: #4caf50;
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 12px;
}

.strategy-log-box {
    background: #1e2229;
    border: 1px solid #303640;
    border-radius: 4px;
    height: 150px;
    width: 100%;
}

.settings-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.mt-4 {
    margin-top: 25px !important;
}

.sound-alerts-row {
    display: flex;
    gap: 25px;
    margin-top: 10px;
}

.sound-alerts-row .toggle {
    color: var(--text);
    font-size: 12px;
}

.desktop-alert-table {
    border: 1px solid #303640;
    border-radius: 4px;
}

.desktop-alert-table th {
    background: #1e2229;
    border-bottom: 1px solid #303640;
    font-size: 11px;
    font-weight: 700;
}

.alert-list {
    max-height: 220px;
    overflow: auto;
    color: var(--muted);
    font-size: 12px;
}

.alert-list .data-table {
    min-width: 0;
}

.alert-list .data-table th,
.alert-list .data-table td {
    padding: 6px 8px;
}

.alert-history {
    max-height: 90px;
    overflow: auto;
    color: var(--muted);
    font-size: 11px;

}

.strategy-panel {
    display: flex;
    min-height: 0;
    flex-direction: column;
}

.strategy-panel[hidden] {
    display: none;
}

.dashboard.is-strategy>.workspace {
    min-height: calc(100vh - 8px);
}

body.is-strategy>.topbar {
    display: none;
}

.dashboard.is-strategy {
    gap: 0;
    padding: 0 8px 8px;
}

.dashboard.is-strategy>.config-grid,
.dashboard.is-strategy>.secondary-controls,
.dashboard.is-strategy>.monitor-panel,
.dashboard.is-strategy>.action-row,
.dashboard.is-strategy>.account-row {
    display: none;
}

.dashboard.is-strategy .workspace {
    flex: 1;
    min-height: 0;
    gap: 0;
}

.dashboard.is-strategy .tabs {
    flex: 0 0 auto;
}

.dashboard.is-strategy .tab {
    min-width: 0;
    flex: 1;
}

.dashboard.is-strategy .strategy-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding-top: 8px;
}

.builder-layout {
    display: grid;
    flex: 1;
    min-height: 0;
    grid-template-columns: minmax(540px, 58%) minmax(390px, 42%);
    gap: 8px;
}

.builder-left,
.builder-right {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    gap: 8px;
}

.builder-topbar,
.builder-bottom-bar {
    display: flex;
    min-height: 38px;
    align-items: center;
    gap: 6px;
}

.builder-topbar {
    padding: 0 4px;
}

.builder-topbar label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text);
    white-space: nowrap;
}

.builder-topbar select {
    width: auto;
    max-width: 112px;
}

.builder-topbar label:nth-child(1) select {
    width: 94px;
}

.builder-topbar label:nth-child(2) select {
    width: 104px;
}

.builder-topbar label:nth-child(3) select {
    width: 104px;
}

.builder-topbar>#builder-preset {
    width: 135px;
    max-width: 135px;
}

.builder-spacer {
    flex: 1;
}

.builder-icon-button {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    color: #fff;
    font-size: 17px;
    font-weight: 800;
    cursor: pointer;
}

.builder-link {
    background: #1688e6;
}

.builder-trash {
    background: #df4949;
}

.builder-close,
.button-execute {
    background: #f29b3d;
    color: #111;
}

.builder-table-scroll {
    position: relative;
    flex: 1;
    min-height: 180px;
    overflow: auto;
    border-radius: 5px;
}

.builder-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.builder-table thead {
    position: sticky;
    z-index: 1;
    top: 0;
    background: #292929;
}

.builder-table th {
    height: 29px;
    padding: 4px 3px;
    color: #aaa;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

.builder-table td {
    padding: 3px 2px;
    text-align: center;
}

.builder-table th:nth-child(1) {
    width: 8%;
}

.builder-table th:nth-child(2) {
    width: 14%;
}

.builder-table th:nth-child(3) {
    width: 14%;
}

.builder-table th:nth-child(4) {
    width: 9%;
}

.builder-table th:nth-child(5) {
    width: 8%;
}

.builder-table th:nth-child(6),
.builder-table th:nth-child(7),
.builder-table th:nth-child(8) {
    width: 11%;
}

.builder-table th:nth-child(9),
.builder-table th:nth-child(10) {
    width: 6%;
}

.builder-table input,
.builder-table select {
    width: 100%;
    height: 26px !important;
    padding: 2px 4px !important;
    text-align: center;
}

.builder-table .builder-side {
    font-weight: 700;
}

.builder-side.buy {
    color: #55bf75;
}

.builder-side.sell {
    color: #f26464;
}

.builder-live-price {
    font-variant-numeric: tabular-nums;
}

.builder-pnl.positive {
    color: #55bf75;
}

.builder-pnl.negative {
    color: #f26464;
}

.builder-row-button {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: #3c424a;
    color: #eee;
    cursor: pointer;
}

.builder-empty {
    position: absolute;
    inset: 34px 0 0;
    display: grid;
    place-items: center;
    color: #666;
    pointer-events: none;
}

.builder-empty[hidden],
#builder-chart-empty[hidden] {
    display: none;
}

.builder-bottom-bar {
    min-height: 48px;
    padding: 6px 8px;
    border-radius: 6px;
    background: #2a2a2a;
}

.builder-bottom-bar>select:first-child {
    width: 96px;
}

.builder-bottom-bar .button {
    min-height: 31px;
    padding: 5px 10px;
    white-space: nowrap;
}

.builder-bottom-bar #builder-saved {
    max-width: 135px;
}

.button-primary {
    background: #2684e9;
    color: #fff;
}

.button-execute {
    font-weight: 700;
}

.builder-status {
    min-height: 16px;
    color: var(--muted);
    font-size: 11px;
}

.builder-summary {
    display: grid;
    min-height: 84px;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    gap: 5px 2px;
    padding: 8px 10px;
    border-radius: 6px;
    background: #2a2a2a;
}

.summary-metric {
    color: var(--text);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}

.summary-metric strong {
    display: block;
    margin-top: 2px;
    color: #ddd;
    font-size: 13px;
}

.metric-profit {
    color: #4caf50;
}

.metric-loss {
    color: #f44336;
}

.metric-pop {
    color: #2196f3;
}

.metric-risk {
    color: #ff9800;
}

.metric-mtm {
    color: #fff;
}

.builder-summary-sub {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #ffc107;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.builder-summary-sub span:nth-child(2) {
    color: #00bcd4;
}

.builder-summary-sub button {
    width: 22px;
    height: 22px;
    border: 0;
    background: transparent;
    color: #ffc107;
    font-size: 19px;
    cursor: pointer;
}

.builder-greeks {
    display: flex;
    min-height: 34px;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    border-radius: 5px;
    background: #252525;
    color: #aeb3b9;
    font-size: 11px;
}

.builder-greeks b {
    font-weight: 500;
}

.builder-more {
    color: #777;
}

.payoff-chart-wrap {
    position: relative;
    flex: 1;
    min-height: 230px;
    overflow: hidden;
    border-radius: 6px;
    background: #333;
}

#builder-payoff-chart {
    display: block;
    width: 100%;
    height: 100%;
}

.builder-chart-spot-label {
    position: absolute;
    z-index: 2;
    top: 3px;
    left: 50%;
    display: flex;
    gap: 7px;
    transform: translateX(-50%);
    padding: 2px 6px;
    background: #171717;
    color: #ffc400;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
}

.chart-label-divider {
    color: #777;
}

.builder-chart-tools {
    position: absolute;
    z-index: 2;
    top: 4px;
    right: 4px;
    display: flex;
}

.builder-chart-tools button {
    width: 39px;
    height: 27px;
    padding: 0;
    border: 1px solid #bd5555;
    background: #252525;
    color: #080808;
    font-size: 18px;
    cursor: pointer;
}

.builder-chart-tools button[aria-pressed="true"] {
    background: #929292;
}

.payoff-chart-wrap.pan-enabled #builder-payoff-chart {
    cursor: grab;
}

.payoff-chart-wrap.pan-enabled #builder-payoff-chart:active {
    cursor: grabbing;
}

#builder-chart-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #666;
    pointer-events: none;
}

@media (max-width: 1100px) {
    .builder-layout {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
    }

    .builder-left {
        min-height: 360px;
    }

    .builder-right {
        min-height: 460px;
    }

    .builder-topbar,
    .builder-bottom-bar {
        flex-wrap: wrap;
    }
}

#builder-status {
    display: block;
    margin-top: 10px;
    color: var(--muted);
}

.table-wrap {
    position: relative;
    flex: 1;
    min-height: 400px;
    overflow: auto;
    border: 1px solid #252b35;
    border-radius: 5px 5px 0 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th,
.data-table td {
    padding: 6px 8px;
    height: 32px;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--panel);
    color: var(--muted);
}

.data-table[data-tab="positions"] {
    min-width: 1420px;
}

.data-table[data-tab="orders"] {
    min-width: 1380px;
    text-align: center;
}

.data-table[data-tab="trades"] {
    min-width: 1348px;
    text-align: center;
}

.data-table[data-tab="trades"] th {
    text-transform: uppercase;
    font-size: 11px;
    white-space: nowrap;
}

.data-table[data-tab="trades"] td {
    white-space: nowrap;
    font-size: 12px;
}

.data-table[data-tab="trades"] th:first-child,
.data-table[data-tab="trades"] td:first-child {
    width: 26px;
    padding-left: 6px;
    padding-right: 6px;
    color: var(--muted);
}

.data-table[data-tab="trades"] td:nth-child(3) {
    text-align: left;
}

.data-table[data-tab="trades"] td:nth-child(6),
.data-table[data-tab="trades"] td:nth-child(10),
.data-table[data-tab="trades"] td:nth-child(11),
.data-table[data-tab="trades"] td:nth-child(12) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table[data-tab="orders"] th {
    text-transform: uppercase;
    font-size: 11px;
    white-space: nowrap;
}

.data-table[data-tab="orders"] td {
    white-space: nowrap;
    font-size: 12px;
}

.data-table[data-tab="orders"] td:nth-child(2) {
    text-align: left;
}

.data-table[data-tab="orders"] td:nth-child(5),
.data-table[data-tab="orders"] td:nth-child(9),
.data-table[data-tab="orders"] td:nth-child(10) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.order-history-button {
    width: 21px;
    height: 21px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    color: #dce9ff;
    background: #3979dc;
    font-weight: 700;
    cursor: pointer;
}

.order-actions {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.order-actions .button {
    min-height: 19px;
    padding: 1px 9px;
    font-size: 11px;
}

.order-modify {
    background: var(--blue);
    color: #fff;
}

.order-cancel {
    background: var(--sell);
    color: #ff7777;
    border-color: var(--sell);
}

.order-history-dialog {
    width: min(1100px, 94vw);
    max-height: 82vh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
}

.order-history-dialog::backdrop {
    background: rgb(0 0 0 / 65%);
}

.order-history-dialog>h2 {
    font-size: 16px;
}

.order-history-dialog>.button {
    margin-top: 14px;
}

.data-table[data-tab="positions"] th,
.data-table[data-tab="positions"] td {
    text-align: center;
    white-space: nowrap;
    font-size: 11px;
}

.data-table[data-tab="positions"] th {
    text-transform: uppercase;
}

.data-table[data-tab="positions"] th[data-column="symbol"],
.data-table[data-tab="positions"] td:first-child {
    text-align: left;
}

.position-stop-level {
    color: var(--sell);
}

.position-target-level {
    color: var(--buy);
}

.position-level-button,
.position-close-button {
    min-height: 19px;
    padding: 1px 9px;
    font-size: 11px;
}

.position-level-button.active {
    color: var(--buy);
    border-color: var(--buy);
}

.position-close-button {
    color: #ff7777;
    border-color: var(--sell);
}

.data-table[data-tab="holdings"] th,
.data-table[data-tab="holdings"] td {
    text-align: center;
}

.data-table[data-tab="holdings"] th {
    font-size: 11px;
    text-transform: uppercase;
}

.data-table td.positive {
    color: var(--buy);
}

.data-table td.negative {
    color: var(--sell);
}

.holding-actions {
    white-space: nowrap;
    padding: 3px 6px !important;
}

.holding-actions .button {
    min-height: 19px;
    padding: 1px 8px;
    margin-right: 4px;
    font-size: 11px;
}

.empty-state {
    padding: 24px;
    color: var(--muted);
    text-align: center;
}

.funds-actions {
    min-height: 38px;
    padding-top: 12px;
}

.funds-actions [hidden] {
    display: none;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 5;
    max-width: min(420px, calc(100vw - 36px));
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--panel-raised);
    box-shadow: 0 8px 24px #0008;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .15s ease, transform .15s ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    border-color: var(--sell);
}

.modal {
    width: min(420px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-raised);
    color: var(--text);
}

.modal::backdrop {
    background: #000b;
}

.modal-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px;
}

.modal-content h2 {
    margin: 0 0 4px;
}

.modal-content>label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: var(--muted);
}

.modal-content>label[hidden] {
    display: none;
}

.modal-content>.risk-check {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.modal-content>.risk-inline {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(90px, .8fr) auto;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 5px;
}

@media (max-width: 1150px) {
    .config-grid {
        grid-template-columns: repeat(4, minmax(130px, 1fr));
    }

    .action-row {
        grid-template-columns: repeat(5, minmax(120px, 1fr));
    }

    .secondary-controls,
    .account-row {
        flex-wrap: wrap;
    }

    .tabs {
        padding: 0;
    }
}

@media (max-width: 700px) {
    body {
        min-width: 320px;
    }

    .topbar {
        grid-template-columns: auto 1fr;
        gap: 10px;
        padding: 10px;
    }

    .dashboard-headers-sticky {
        position: static;
    }

    .user-name {
        font-size: 16px;
    }

    .header-right {
        grid-column: 1 / -1;
        justify-content: space-between;
        font-size: 12px;
    }

    .config-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px 8px;
    }

    .inline-options {
        min-height: 44px;
        margin-top: 10px;
    }

    .secondary-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 8px;
    }
    
    .secondary-controls .compact-field {
        justify-content: space-between;
    }
    
    .secondary-controls .flex-spacer {
        display: none;
    }

    .account-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 8px;
        align-items: center;
    }

    .account-row .mtm {
        grid-column: 1 / -1;
        text-align: center;
        font-size: 18px;
    }
    
    .account-row .risk-summary {
        grid-column: 1 / -1;
        justify-content: center;
    }
    
    .account-row .flex-spacer {
        display: none;
    }
    
    .account-row .live-toggle {
        margin: 0;
    }

    .secondary-controls label, .account-row label {
        font-size: 12px;
    }
    
    .compact-field input {
        width: 60px !important;
    }

    .monitor-panel {
        margin: 12px 0;
        padding: 10px;
        grid-template-columns: 1fr;
        gap: 10px;
        border-color: #252b35;
        background: transparent;
        border: none;
    }

    .monitor-divider {
        display: none;
    }

    .monitor {
        display: grid;
        grid-template-areas: 
            "title price"
            "change price"
            "extra extra";
        grid-template-columns: 1fr auto;
        gap: 4px 8px;
        padding: 10px 12px;
        background: #11151d;
        border: 1px solid #252b35;
        border-radius: 8px;
        align-items: center;
    }

    .monitor-title {
        grid-area: title;
        font-size: 11px;
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .monitor-price {
        grid-area: price;
        font-size: 24px;
        text-align: right;
    }
    
    .monitor-change {
        grid-area: change;
        font-size: 11px;
        text-align: left;
    }
    
    .monitor-extra {
        grid-area: extra;
        font-size: 10px;
        text-align: left;
        padding-top: 4px;
        border-top: 1px solid #252b35;
    }

    .action-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-top: 8px;
    }
    
    .action-row > .button {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .button-sell[id="btn-close-all"], 
    .button-warning[id="btn-cancel-all"] {
        grid-column: 1 / -1;
    }

    .tabs {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
    }

    .tab {
        font-size: 11px;
        min-height: 32px;
        padding: 0 4px;
    }
    
    .settings-layout {
        grid-template-columns: 1fr;
    }
    
    .settings-left {
        border-right: none;
        border-bottom: 1px solid #252b35;
    }

    .table-wrap {
        width: 100%;
        max-width: 100vw;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}