/* Mohit Sharma Market Console — bold editorial dashboard */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root,
[data-theme="light"] {
    color-scheme: light;
    --canvas: #ffffff;
    --surface: #ffffff;
    --surface-muted: #f5f5f3;
    --surface-raised: #ffffff;
    --surface-accent: #f5f5f3;
    --surface-positive: #f3f7f4;
    --surface-warning: #faf6ed;
    --surface-inverse: #10100f;
    --border: #e5e3de;
    --border-strong: #d0cdc6;
    --text: #10100f;
    --text-secondary: #3c3b38;
    --text-muted: #6b6963;
    --text-dim: #9c9991;
    --accent: #82632f;
    --accent-soft: #b99b67;
    --positive: #27654b;
    --negative: #a13c3c;
    --warning: #82632f;
    --header-bg: rgba(255, 255, 255, 0.94);
    --shadow-card: none;
    --shadow-control: none;

    /* JS updates these PnL values directly. */
    --pnl-positive: var(--positive);
    --pnl-negative: var(--negative);
}

[data-theme="dark"] {
    color-scheme: dark;
    --canvas: #0b0b0a;
    --surface: #121210;
    --surface-muted: #1a1916;
    --surface-raised: #121210;
    --surface-accent: #1a1916;
    --surface-positive: #14231c;
    --surface-warning: #211c14;
    --surface-inverse: #f4f1e9;
    --border: #2d2b26;
    --border-strong: #454138;
    --text: #f4f1e9;
    --text-secondary: #c4c0b7;
    --text-muted: #938e83;
    --text-dim: #625f58;
    --accent: #c6a15d;
    --accent-soft: #866f45;
    --positive: #72b997;
    --negative: #dc7d7d;
    --warning: #c6a15d;
    --header-bg: rgba(11, 11, 10, 0.92);
    --shadow-card: none;
    --shadow-control: none;
}

[data-theme="read"] {
    color-scheme: light;
    --canvas: #ede6d8;
    --surface: #f6efe3;
    --surface-muted: #e5dbc9;
    --surface-raised: #f6efe3;
    --surface-accent: #e5dbc9;
    --surface-positive: #e4ebdf;
    --surface-warning: #eee2cf;
    --surface-inverse: #30291f;
    --border: #cec2ae;
    --border-strong: #b7a78e;
    --text: #30291f;
    --text-secondary: #574c3d;
    --text-muted: #746754;
    --text-dim: #9a8c76;
    --accent: #74542b;
    --accent-soft: #aa8b61;
    --positive: #386b50;
    --negative: #9d4a42;
    --warning: #74542b;
    --header-bg: rgba(237, 230, 216, 0.92);
    --shadow-card: none;
    --shadow-control: none;
}

html {
    min-width: 320px;
    min-height: 100%;
    background: var(--canvas);
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--canvas);
    color: var(--text);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 17px;
    line-height: 1.68;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
}

button,
[href] {
    touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

::selection {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.hidden {
    display: none !important;
}

.skip-link {
    position: fixed;
    z-index: 100;
    top: 10px;
    left: 12px;
    padding: 10px 14px;
    border: 1px solid var(--text);
    border-radius: 0;
    background: var(--surface-inverse);
    color: var(--canvas);
    font-size: 11px;
    font-weight: 760;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

#app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

/* App shell */
.app-header {
    position: relative;
    z-index: 20;
    flex-shrink: 0;
    padding: 0 max(28px, env(safe-area-inset-right)) 0 max(28px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--border-strong);
    background: var(--header-bg);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
}

.header-top,
.workspace-bar,
.price-details {
    width: min(100%, 1120px);
    margin-inline: auto;
}

.header-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    padding: 17px 0 14px;
}

.website-link {
    width: fit-content;
    padding: 0 0 3px;
    border-bottom: 1px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-decoration: none;
    text-transform: uppercase;
    transition: border-color 140ms ease, color 140ms ease;
}

.website-link:hover {
    border-bottom-color: var(--accent);
    color: var(--text);
}

.site-name {
    justify-self: center;
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-decoration: none;
    transition: color 140ms ease;
}

.site-name:hover {
    color: var(--accent);
}

.header-right {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-self: end;
    gap: 10px;
}

.header-right .theme-toggle {
    margin: 0;
    padding-left: 0;
    border-left: 0;
}

.theme-toggle,
.segmented-control {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 0 0 18px;
    border: 0;
    border-left: 1px solid var(--border-strong);
    border-radius: 0;
    background: transparent;
}

.theme-btn,
.logout-link {
    display: inline-flex;
    min-width: 0;
    min-height: 28px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 760;
    letter-spacing: 0.09em;
    text-decoration: none;
    text-transform: uppercase;
    transition: color 140ms ease, border-color 140ms ease;
}

.theme-btn:hover,
.logout-link:hover {
    color: var(--text);
}

.theme-btn.active {
    border-bottom-color: var(--accent);
    background: transparent;
    color: var(--text);
    box-shadow: none;
}

.logout-link {
    min-width: auto;
    margin-left: 6px;
    padding: 0 0 2px 16px;
    border-left: 1px solid var(--border-strong);
    color: var(--text);
}

.workspace-bar {
    display: flex;
    min-width: 0;
    align-items: stretch;
    justify-content: space-between;
    gap: 28px;
    border-top: 1px solid var(--border);
}

.tab-nav {
    display: flex;
    min-width: 0;
    align-items: flex-end;
    gap: clamp(18px, 2.4vw, 34px);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-color: var(--border-strong) transparent;
    scrollbar-width: thin;
}

.tab-btn {
    position: relative;
    min-height: 48px;
    flex: 0 0 auto;
    padding: 0 0 2px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 780;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: color 140ms ease;
}

.tab-btn::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 1px;
    border-radius: 0;
    background: var(--accent);
    content: "";
    opacity: 0;
    transform: scaleX(0.55);
    transition: opacity 140ms ease, transform 140ms ease;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--text);
}

.tab-btn.active::after {
    opacity: 1;
    transform: scaleX(1);
}

.live-value {
    display: flex;
    min-width: 126px;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    padding: 0 0 7px 14px;
}

.live-value-label {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 780;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    white-space: nowrap;
}

.main-price {
    color: var(--text);
    font-size: 23px;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1;
    white-space: nowrap;
}

.main-price.positive,
.sr-positive {
    color: var(--positive);
}

.main-price.negative,
.sr-negative {
    color: var(--negative);
}

.price-details {
    display: flex;
    min-height: 52px;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 0;
    border-top: 1px solid var(--border);
    scrollbar-width: thin;
}

.detail-item {
    display: grid;
    min-width: 84px;
    flex: 0 0 auto;
    gap: 3px;
    padding: 11px 16px 12px 0;
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    font-weight: 760;
    line-height: 1.2;
}

.detail-label {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 780;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.detail-time {
    min-width: auto;
    margin-left: auto;
    padding-left: 16px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

/* Main views */
main {
    min-height: 0;
    flex: 1;
    padding: 28px max(28px, env(safe-area-inset-right)) max(30px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
    overflow: hidden;
}

.tab-content {
    display: none;
    height: 100%;
    min-height: 0;
}

.tab-content[hidden] {
    display: none !important;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.page-shell,
.strategy-page {
    width: min(100%, 1120px);
    margin-inline: auto;
}

.page-shell {
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    padding: 2px 0 38px;
    scrollbar-color: var(--border-strong) transparent;
    scrollbar-width: thin;
}

.page-heading,
.scmc-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border-strong);
}

.page-heading h1,
.scmc-title {
    margin: 7px 0 8px;
    color: var(--text);
    font-size: clamp(42px, 5.4vw, 62px);
    font-weight: 820;
    letter-spacing: -0.055em;
    line-height: 0.98;
}

.page-heading p,
.scmc-subtitle {
    max-width: 760px;
    color: var(--text-secondary);
    font-size: 17px;
    line-height: 1.62;
}

.eyebrow,
.metric-label {
    display: block;
    color: var(--accent);
    font-size: 12px;
    font-weight: 780;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.panel-card,
.sr-chart-box,
.chart-box {
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
}

.panel-card {
    padding: 22px;
}

.chart-panel {
    padding-top: 19px;
}

.metric-headline {
    display: grid;
    gap: 7px;
    padding: 2px 2px 20px;
}

.metric-headline > div {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.metric-headline strong {
    color: var(--text);
    font-size: clamp(34px, 4vw, 48px);
    font-variant-numeric: tabular-nums;
    font-weight: 820;
    letter-spacing: -0.055em;
    line-height: 1;
}

.metric-headline strong.sr-positive {
    color: var(--positive);
}

.metric-headline strong.sr-negative {
    color: var(--negative);
}

.metric-headline span:last-child {
    color: var(--text-secondary);
    font-size: 12px;
}

.embedded-chart,
.sr-chart-box {
    position: relative;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    touch-action: pan-y;
}

.embedded-chart {
    border-top: 1px solid var(--border-strong);
    padding-top: 18px;
}

.chart-loading-overlay {
    position: absolute;
    z-index: 2;
    inset: 18px 0 0;
    display: grid;
    place-items: center;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 720;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.chart-loading-overlay.hidden {
    display: none;
}

.chart-large {
    height: 390px;
}

.chart-medium {
    height: 315px;
}

.returns-page {
    display: grid;
    width: min(100%, 1440px);
    align-content: start;
    gap: 20px;
}

.returns-page .page-heading {
    margin-bottom: 0;
}

.returns-summary {
    display: grid;
    grid-template-columns: minmax(260px, 1.2fr) minmax(420px, 1fr);
    align-items: end;
    gap: 30px;
    background: var(--surface-inverse);
    color: var(--canvas);
}

.returns-summary .metric-label {
    color: var(--accent-soft);
}

.returns-summary strong {
    display: block;
    margin: 9px 0 6px;
    font-size: clamp(42px, 5vw, 62px);
    font-variant-numeric: tabular-nums;
    font-weight: 820;
    letter-spacing: -0.055em;
    line-height: 1;
}

.returns-summary > div > span:last-child {
    color: color-mix(in srgb, var(--canvas) 66%, transparent);
    font-size: 13px;
}

.returns-summary dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
    border-left: 1px solid color-mix(in srgb, var(--canvas) 18%, transparent);
}

.returns-summary dl div {
    padding-left: 18px;
}

.returns-summary dt {
    color: color-mix(in srgb, var(--canvas) 52%, transparent);
    font-size: 9px;
    font-weight: 780;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.returns-summary dd {
    margin: 6px 0 0;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    font-weight: 740;
}

.returns-sleeves {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--border-strong);
    border-left: 1px solid var(--border-strong);
}

.returns-sleeves > .overview-loading {
    grid-column: 1 / -1;
    border-right: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border-strong);
}

.return-sleeve-card {
    min-width: 0;
    padding: 18px;
    border-right: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border-strong);
    background: var(--surface);
}

.return-sleeve-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 18px;
}

.return-sleeve-head span {
    color: var(--text);
    font-size: 16px;
    font-weight: 790;
}

.return-sleeve-head small,
.return-sleeve-label {
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 760;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.return-sleeve-label {
    display: block;
}

.return-sleeve-card > strong {
    display: block;
    margin: 7px 0 3px;
    font-size: 31px;
    font-variant-numeric: tabular-nums;
    font-weight: 820;
    letter-spacing: -.045em;
}

.return-sleeve-card > p {
    margin: 0;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.return-sleeve-meta {
    display: grid;
    gap: 5px;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.35;
}

.return-sleeve-meta b {
    color: var(--text-secondary);
    font-weight: 720;
}

.returns-chart {
    height: clamp(520px, 72vh, 760px);
}

.returns-method {
    margin: 12px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.55;
}

.returns-tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.returns-table {
    min-width: 560px;
}

.chart-box {
    position: relative;
    min-height: 330px;
    flex: 1;
    padding: 16px;
}

.chart-box canvas {
    position: absolute;
    inset: 16px;
}

.pnl-page {
    display: flex;
    flex-direction: column;
}

.us-pnl-page {
    gap: 20px;
}

.us-pnl-page .page-heading,
.pnl-page .page-heading {
    flex: 0 0 auto;
}

.us-pnl-page .chart-box {
    min-height: 300px;
}

.current-position-panel {
    padding: 18px 22px 20px;
    border: 1px solid var(--border-strong);
    background: var(--surface-inverse);
    color: var(--canvas);
}

.current-position-panel .eyebrow {
    color: var(--accent-soft);
}

.current-position-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 17px;
    padding-bottom: 14px;
    border-bottom: 1px solid color-mix(in srgb, var(--canvas) 18%, transparent);
}

.current-position-heading h2 {
    margin-top: 3px;
    color: inherit;
    font-size: 20px;
    font-weight: 780;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.position-refresh-note {
    color: color-mix(in srgb, var(--canvas) 62%, transparent);
    font-size: 10px;
    font-weight: 680;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.current-position-grid {
    display: grid;
    grid-template-columns: 1.1fr repeat(5, minmax(0, 1fr));
}

.current-position-grid .overview-loading {
    grid-column: 1 / -1;
    color: color-mix(in srgb, var(--canvas) 72%, transparent);
}

.position-metric {
    min-width: 0;
    padding: 3px 16px 2px;
    border-left: 1px solid color-mix(in srgb, var(--canvas) 16%, transparent);
}

.position-metric:first-child {
    padding-left: 0;
    border-left: 0;
}

.position-metric:last-child {
    padding-right: 0;
}

.position-metric-label {
    display: block;
    margin-bottom: 5px;
    color: color-mix(in srgb, var(--canvas) 56%, transparent);
    font-size: 9px;
    font-weight: 760;
    letter-spacing: 0.12em;
    line-height: 1.2;
    text-transform: uppercase;
}

.position-metric-value {
    display: block;
    overflow: hidden;
    color: inherit;
    font-size: 18px;
    font-weight: 760;
    letter-spacing: -0.025em;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.position-ticker .position-metric-value {
    font-size: 25px;
    font-weight: 820;
}

.position-pnl.positive .position-metric-value {
    color: #72b997;
}

.position-pnl.negative .position-metric-value {
    color: #dc7d7d;
}

.us-chart-panel {
    padding: 20px 22px 16px;
}

.us-chart-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.us-chart-toolbar h2 {
    margin-top: 4px;
    color: var(--text);
    font-size: 22px;
    font-weight: 790;
    letter-spacing: -0.035em;
    line-height: 1.15;
}

.us-range-selector {
    display: flex;
    align-items: center;
    gap: 16px;
}

.us-range-btn {
    min-height: 30px;
    padding: 4px 0 3px;
    border: 0;
    border-bottom: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 10px;
    font-weight: 780;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.us-range-btn:hover,
.us-range-btn.active {
    border-bottom-color: var(--accent);
    color: var(--text);
}

.us-chart-legend {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 18px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1;
}

.us-chart-legend span,
.us-chart-footer span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.legend-line {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--accent);
}

.legend-qqq {
    height: 0;
    border-top: 2px dashed var(--text);
    background: transparent;
}

.legend-spy {
    height: 0;
    border-top: 1px solid var(--text-muted);
    background: transparent;
}

.us-chart-frame {
    position: relative;
    height: 350px;
    margin-top: 14px;
}

.us-chart-frame canvas {
    position: absolute;
    inset: 0;
}

.us-chart-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 31px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.2;
}

.trade-dot {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.trade-buy {
    background: var(--positive);
}

.trade-sell {
    background: var(--negative);
}

.us-chart-method {
    margin-left: auto;
}

.holdings-panel {
    flex: 0 0 auto;
}

.panel-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 17px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
    margin-top: 3px;
    color: var(--text);
    font-size: 20px;
    font-weight: 780;
    letter-spacing: -0.03em;
}

/* Controls */
.date-selector {
    display: flex;
    min-height: 39px;
    flex: 0 0 auto;
    gap: 18px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding: 1px 1px 5px;
    scrollbar-color: var(--border-strong) transparent;
    scrollbar-width: thin;
}

.date-btn,
.sr-btn {
    min-height: 32px;
    flex: 0 0 auto;
    padding: 6px 0 4px;
    border: 0;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 780;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: border-color 140ms ease, color 140ms ease;
}

.date-btn:hover,
.sr-btn:hover {
    border-color: var(--accent-soft);
    color: var(--accent);
}

.date-btn.active,
.sr-btn.active {
    border-color: var(--accent);
    background: transparent;
    color: var(--text);
    box-shadow: none;
}

.segmented-control {
    gap: 15px;
    padding: 0;
    border-left: 0;
}

.segmented-control .sr-btn {
    min-height: 30px;
    padding-inline: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.segmented-control .sr-btn.active {
    border-bottom: 1px solid var(--accent);
    background: transparent;
    box-shadow: none;
}

/* Strategy views */
#scmc-content,
#fno-content,
#nasdaq100-content {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding: 2px 0;
    scrollbar-color: var(--border-strong) transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.strategy-page {
    padding-bottom: 44px;
}

.scmc-header {
    padding: 0;
}

.strategy-kicker {
    display: block;
    margin-bottom: 5px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.scmc-title {
    margin: 0 0 5px;
}

.fno-header-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 14px;
}

.fno-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
    border-top: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border-strong);
}

.fno-stat {
    display: grid;
    min-width: 0;
    gap: 7px;
    padding: 15px 18px;
    border-right: 1px solid var(--border);
}

.fno-stat:last-child {
    border-right: 0;
}

.fno-stat strong {
    color: var(--text);
    font-size: 24px;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.fno-stat strong.sr-positive {
    color: var(--positive);
}

.fno-stat-meta {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.04em;
}

.fno-method {
    margin-top: 14px;
}

.fno-results-header > div:first-child {
    display: grid;
    gap: 4px;
}

.fno-sort-description {
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 620;
    letter-spacing: 0.03em;
}

.fno-sort-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.fno-sort-control {
    flex-wrap: nowrap;
}

.fno-sort-control .fno-sort-btn {
    min-height: 38px;
}

.fno-table {
    min-width: 1040px;
}

.fno-symbol-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fno-setup-badge {
    display: inline-flex;
    min-height: 20px;
    align-items: center;
    padding: 2px 6px;
    border: 1px solid color-mix(in srgb, var(--positive) 35%, var(--border));
    background: var(--surface-positive);
    color: var(--positive);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.07em;
    line-height: 1;
    text-transform: uppercase;
}

.fno-cell-meta {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 620;
    line-height: 1.35;
}

/* Live FNO premium-to-margin scanner */
.live-fno-page {
    width: min(100%, 1500px);
}

.live-fno-heading-actions {
    display: grid;
    flex: 0 0 auto;
    justify-items: end;
    gap: 9px;
}

.live-fno-market {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 16px;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    background: var(--surface-warning);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.45;
}

.live-fno-market strong {
    flex: 0 0 auto;
    color: var(--text);
}

.live-fno-market-open {
    border-left-color: var(--positive);
    background: var(--surface-positive);
}

.live-fno-market-stale {
    border-left-color: var(--negative);
}

.live-fno-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
}

.live-fno-stat {
    display: grid;
    min-width: 0;
    gap: 3px;
    padding: 14px 17px;
    border-right: 1px solid var(--border);
}

.live-fno-stat:last-child {
    border-right: 0;
}

.live-fno-stat > span {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 780;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.live-fno-stat strong {
    overflow: hidden;
    color: var(--text);
    font-size: 23px;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-fno-stat small {
    overflow: hidden;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-fno-results {
    padding: 0;
    overflow: hidden;
}

.live-fno-results-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.live-fno-results-heading h2 {
    margin-top: 3px;
    color: var(--text);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.live-fno-results-heading p {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
}

.live-fno-results-heading > strong {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    font-weight: 720;
}

.live-fno-filters {
    display: grid;
    grid-template-columns: repeat(6, minmax(125px, 1fr));
    align-items: end;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-strong);
    background: var(--surface-muted);
}

.live-fno-field {
    display: grid;
    min-width: 0;
    gap: 5px;
}

.live-fno-field > span,
.live-fno-check > span {
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 780;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.live-fno-field input,
.live-fno-field select {
    width: 100%;
    min-height: 39px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    outline: 0;
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
}

.live-fno-field input:focus,
.live-fno-field select:focus {
    border-color: var(--accent);
}

.live-fno-check {
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.live-fno-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.live-fno-table-shell {
    max-height: min(62vh, 720px);
    border: 0;
}

.live-fno-table {
    min-width: 1530px;
}

.live-fno-table th:nth-child(5),
.live-fno-table td:nth-child(5),
.live-fno-table th:nth-child(8),
.live-fno-table td:nth-child(8) {
    border-left: 1px solid var(--border-strong);
}

.live-fno-table td {
    vertical-align: top;
}

.live-fno-table td:first-child b,
.live-fno-yield b {
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
}

.live-fno-yield-best {
    background: var(--surface-positive);
}

.live-fno-yield-best b {
    color: var(--positive);
}

.live-fno-leg-stale {
    background: var(--surface-warning);
}

.live-fno-leg-stale b {
    color: var(--warning);
}

.live-fno-method {
    margin-top: 14px;
    border-top: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border-strong);
}

.live-fno-method summary {
    padding: 13px 2px;
    color: var(--text);
    cursor: pointer;
    font-size: 11px;
    font-weight: 780;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.live-fno-method > div {
    display: grid;
    gap: 8px;
    max-width: 1050px;
    padding: 0 2px 17px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
}

.scmc-setup-details {
    margin-bottom: 18px;
    overflow: clip;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
}

.scmc-setup-details summary {
    display: flex;
    min-height: 52px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    font-weight: 780;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    list-style: none;
}

.scmc-setup-details summary::-webkit-details-marker {
    display: none;
}

.scmc-setup-details summary::after {
    color: var(--text-muted);
    content: "+";
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
}

.scmc-setup-details[open] summary::after {
    content: "−";
}

.details-hint {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

.strategy-details-body {
    padding: 0 15px 15px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.7;
}

.strategy-details-body p {
    margin-top: 12px;
}

.strategy-details-body ul {
    margin: 8px 0 0 18px;
}

.strategy-details-body li + li {
    margin-top: 3px;
}

.strategy-details-body b {
    color: var(--text);
}

.scmc-bt-bar {
    display: grid;
    grid-template-columns: 1.35fr repeat(4, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 30px;
    border-top: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border-strong);
}

.scmc-bt-item {
    display: grid;
    min-width: 0;
    gap: 7px;
    padding: 15px 18px;
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-size: 22px;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    letter-spacing: -0.04em;
    box-shadow: none;
}

.scmc-bt-item:last-child {
    border-right: 0;
}

.scmc-bt-label {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 780;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.sr-section {
    margin-top: 32px;
}

.sr-section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.sr-section-title {
    color: var(--text);
    font-size: 16px;
    font-weight: 780;
    letter-spacing: -0.02em;
}

.section-meta {
    max-width: 760px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-align: right;
}

.status-warning {
    color: var(--warning);
    font-weight: 700;
}

.status-negative {
    color: var(--negative);
    font-weight: 700;
}

.status-positive {
    color: var(--positive);
    font-weight: 700;
}

.status-info {
    color: var(--accent);
    font-weight: 700;
}

.sr-chart-box {
    height: 280px;
    padding: 14px;
}

.sr-chart-box.chart-primary {
    height: 360px;
}

.notice {
    margin-top: 14px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.55;
}

.notice strong {
    color: var(--text);
}

.notice-info {
    border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
    background: var(--surface-accent);
}

.notice-success {
    border-color: color-mix(in srgb, var(--positive) 28%, var(--border));
    background: var(--surface-positive);
    color: var(--positive);
    font-weight: 680;
}

.notice-warning {
    border-color: color-mix(in srgb, var(--warning) 30%, var(--border));
    background: var(--surface-warning);
    color: var(--warning);
    font-weight: 680;
}

.rebalance-notice {
    display: grid;
    gap: 7px;
}

.rebalance-execute,
.rebalance-cash {
    color: var(--text-secondary);
    font-weight: 650;
}

.rebalance-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
}

.rebalance-action {
    letter-spacing: 0.02em;
}

.scmc-execution {
    display: grid;
    gap: 14px;
    margin: 18px 0 24px;
    padding: 18px;
    border: 2px solid var(--border-strong);
    background: var(--surface);
}

.scmc-execution--wait {
    border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
    background: var(--surface-accent);
}

.scmc-execution--action {
    border-color: color-mix(in srgb, var(--positive) 55%, var(--border));
    background: var(--surface-positive);
}

.scmc-execution--blocked {
    border-color: color-mix(in srgb, var(--negative) 58%, var(--border));
    background: color-mix(in srgb, var(--negative) 7%, var(--surface));
}

.scmc-execution--review {
    border-color: color-mix(in srgb, var(--warning) 55%, var(--border));
    background: var(--surface-warning);
}

.scmc-execution-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.scmc-execution-label,
.scmc-start-kicker {
    display: block;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.scmc-execution h2 {
    margin: 5px 0 0;
    color: var(--text);
    font-size: clamp(22px, 3vw, 32px);
    letter-spacing: -0.04em;
}

.scmc-refresh-btn {
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 780;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.scmc-execution-message,
.scmc-execution-foot,
.scmc-start-box p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.55;
}

.scmc-execution-dates,
.scmc-order-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.scmc-execution-dates span,
.scmc-order-grid > div {
    display: grid;
    gap: 5px;
    min-height: 66px;
    padding: 12px 14px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
}

.scmc-execution-dates b,
.scmc-order-grid span {
    color: var(--text-muted);
    font-size: 10px;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.scmc-order-grid b {
    font-size: 17px;
}

.scmc-start-box {
    display: grid;
    gap: 10px;
    padding: 15px;
    border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border));
    background: var(--surface);
}

.scmc-start-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.scmc-start-grid span {
    display: grid;
    gap: 3px;
    padding: 10px 11px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.scmc-start-grid small {
    color: var(--accent);
    font-weight: 750;
}

.scmc-off-cycle,
.scmc-trim-check {
    padding: 10px 12px;
    border-left: 3px solid var(--warning);
    background: var(--surface-warning);
    color: var(--warning);
    font-size: 13px;
    line-height: 1.5;
}

.scmc-execution-foot {
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.holding-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    border-top: 1px solid var(--border-strong);
    border-left: 1px solid var(--border-strong);
}

.holding-card {
    display: grid;
    min-height: 88px;
    place-content: center;
    gap: 4px;
    border: 0;
    border-right: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border-strong);
    border-radius: 0;
    background: transparent;
    text-align: center;
    box-shadow: none;
}

.holding-rank {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 780;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.holding-symbol {
    color: var(--text);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.04em;
}

/* Tables */
.table-shell {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
    scrollbar-color: var(--border-strong) transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.sr-table {
    width: 100%;
    min-width: 680px;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.sr-table th {
    position: sticky;
    z-index: 1;
    top: 0;
    padding: 11px 13px;
    border-bottom: 1px solid var(--border-strong);
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 780;
    letter-spacing: 0.1em;
    text-align: right;
    text-transform: uppercase;
    white-space: nowrap;
}

.sr-table td {
    padding: 11px 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
}

.sr-table th:first-child,
.sr-table td:first-child {
    text-align: left;
}

.sr-table td b {
    color: var(--text);
    font-weight: 720;
}

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

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

.sr-table td.section-meta {
    color: var(--text-muted);
    font-size: 10.5px;
}

.sr-table tbody tr:last-child td {
    border-bottom: 0;
}

.sr-table tbody tr:hover td {
    background: var(--surface-muted);
}

.sr-table .row-index {
    color: var(--text-muted);
}

.is-held td:first-child {
    box-shadow: inset 2px 0 var(--accent);
}

.is-held td {
    background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}

.is-watchlist td {
    background: color-mix(in srgb, var(--warning) 2.5%, var(--surface));
}

.us-holdings-table {
    min-width: 640px;
}

.scmc-year-block {
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
}

.scmc-year-header {
    display: flex;
    min-height: 54px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-strong);
    background: transparent;
}

.scmc-year-label {
    color: var(--text);
    font-size: 17px;
    font-weight: 800;
}

.year-return {
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

.year-equity {
    margin-left: 10px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}

.year-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
}

.year-metrics span {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.year-metrics b {
    color: var(--text);
    font-size: 13px;
}

.scmc-year-block .table-shell {
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.scmc-year-block .sr-table th {
    top: auto;
}

/* Summary metrics and UI states */
.position-summary {
    display: grid;
    grid-template-columns: 1.25fr repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--border-strong);
}

.position-metric {
    display: grid;
    min-width: 0;
    gap: 4px;
    padding: 14px 15px;
    background: var(--surface);
}

.position-metric strong {
    overflow: hidden;
    color: var(--text);
    font-size: 17px;
    font-variant-numeric: tabular-nums;
    font-weight: 780;
    letter-spacing: -0.035em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.position-metric.primary strong {
    font-size: 26px;
}

.position-metric strong.sr-positive {
    color: var(--positive);
}

.position-metric strong.sr-negative {
    color: var(--negative);
}

.position-metric .section-meta {
    max-width: none;
    text-align: left;
}

.overview-loading {
    display: flex;
    min-height: 160px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    padding: 34px 16px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 650;
    letter-spacing: 0.03em;
    text-align: center;
}

.overview-loading::before {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    content: "";
    animation: console-spin 800ms linear infinite;
}

.overview-loading.compact-loading {
    min-height: 76px;
}

.empty-state {
    min-height: 110px;
    padding: 28px 16px;
    color: var(--text-muted);
    text-align: center;
}

@keyframes console-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Live positions */
.positions-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.positions-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    padding: 2px 0 19px;
    border-bottom: 1px solid var(--border-strong);
}

.positions-toolbar h1 {
    margin: 6px 0 5px;
    color: var(--text);
    font-size: clamp(36px, 4.8vw, 54px);
    font-weight: 820;
    letter-spacing: -0.055em;
    line-height: 1;
}

.positions-toolbar h1 span {
    color: var(--text-muted);
    font-weight: 520;
}

.positions-toolbar p {
    color: var(--text-secondary);
    font-size: 14px;
}

.positions-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.positions-search {
    display: flex;
    width: 245px;
    min-height: 42px;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-muted);
}

.positions-search input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 13px;
}

.positions-search input::placeholder {
    color: var(--text-dim);
}

.console-btn {
    min-height: 42px;
    padding: 0 15px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 11px;
    font-weight: 780;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.console-btn:hover {
    border-color: var(--accent);
}

.console-btn:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.console-btn-primary {
    border-color: var(--surface-inverse);
    background: var(--surface-inverse);
    color: var(--canvas);
}

.console-btn-muted {
    color: var(--text-muted);
}

.positions-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--border-strong);
    background: var(--surface);
}

.positions-stat {
    min-width: 0;
    padding: 14px 17px;
    border-right: 1px solid var(--border);
}

.positions-stat:last-child {
    border-right: 0;
}

.positions-stat span {
    display: block;
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 780;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.positions-stat strong {
    display: block;
    overflow: hidden;
    color: var(--text);
    font-size: 20px;
    font-variant-numeric: tabular-nums;
    font-weight: 780;
    letter-spacing: -0.025em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.positions-stat strong.positive,
.position-value.positive {
    color: var(--positive);
}

.positions-stat strong.negative,
.position-value.negative {
    color: var(--negative);
}

.positions-safety {
    padding: 9px 12px;
    border-left: 2px solid var(--accent);
    background: var(--surface-accent);
    color: var(--text-secondary);
    font-size: 11px;
}

.positions-table-shell {
    min-height: 190px;
    overflow-x: auto;
    border: 1px solid var(--border-strong);
    background: var(--surface);
}

.positions-table {
    width: 100%;
    min-width: 1080px;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.positions-table th {
    position: sticky;
    z-index: 2;
    top: 0;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-strong);
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 780;
    letter-spacing: 0.09em;
    text-align: right;
    text-transform: uppercase;
    white-space: nowrap;
}

.positions-table th:nth-child(1),
.positions-table th:nth-child(2),
.positions-table td:nth-child(1),
.positions-table td:nth-child(2) {
    text-align: left;
}

.positions-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
}

.positions-table tr:last-child td {
    border-bottom: 0;
}

.position-group-row td {
    padding-top: 10px;
    padding-bottom: 10px;
    background: var(--surface-muted);
    color: var(--text);
    font-weight: 780;
}

.position-group-row td:not(:first-child) {
    color: var(--text-muted);
}

.position-group-count {
    margin-left: 7px;
    color: var(--text-dim);
    font-weight: 600;
}

.position-product {
    display: inline-block;
    min-width: 48px;
    padding: 3px 7px;
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    color: var(--accent);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-align: center;
}

.position-symbol {
    color: var(--text);
    font-weight: 720;
}

.position-exchange {
    margin-left: 5px;
    color: var(--text-dim);
    font-size: 10px;
}

.position-closed td {
    color: var(--text-dim);
}

.position-stop-cell {
    min-width: 180px;
}

.position-stop-button {
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.position-stop-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.position-stop-state {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
}

.stop-status-pill {
    display: inline-flex;
    min-height: 25px;
    align-items: center;
    padding: 0 8px;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
    background: var(--surface-accent);
    color: var(--accent);
    font-size: 8px;
    font-weight: 820;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.stop-status-pill.triggered,
.stop-status-pill.exited {
    border-color: color-mix(in srgb, var(--positive) 35%, var(--border));
    color: var(--positive);
}

.stop-status-pill.error,
.stop-status-pill.stale {
    border-color: color-mix(in srgb, var(--negative) 35%, var(--border));
    color: var(--negative);
}

.stop-inline-detail {
    color: var(--text-muted);
    font-size: 9px;
}

.stop-cancel-button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 10px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.positions-total-row td {
    border-top: 1px solid var(--border-strong);
    border-bottom: 0;
    background: var(--surface);
    color: var(--text);
    font-weight: 800;
}

/* Stop configuration dialog */
.stop-modal {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
}

.stop-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(3px);
}

.stop-modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 560px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 25px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.stop-modal-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 17px;
    border-bottom: 1px solid var(--border-strong);
}

.stop-modal-heading h2 {
    margin: 4px 0 2px;
    color: var(--text);
    font-size: 29px;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.stop-modal-heading p {
    color: var(--text-muted);
    font-size: 12px;
}

.stop-modal-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.stop-reference-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.stop-choice {
    position: relative;
    display: block;
    cursor: pointer;
}

.stop-choice input {
    position: absolute;
    opacity: 0;
}

.stop-choice span {
    display: grid;
    gap: 2px;
    min-height: 68px;
    align-content: center;
    padding: 10px 13px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
}

.stop-choice input:checked + span {
    border-color: var(--accent);
    background: var(--surface-accent);
}

.stop-choice input:disabled + span {
    cursor: not-allowed;
    opacity: 0.45;
}

.stop-choice b {
    color: var(--text);
    font-size: 12px;
}

.stop-choice small {
    color: var(--text-muted);
    font-size: 10px;
}

.stop-field {
    display: grid;
    gap: 6px;
    margin-top: 15px;
}

.stop-field > span {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 760;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stop-field input,
.stop-field select {
    width: 100%;
    min-height: 44px;
    padding: 8px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    outline: 0;
    background: var(--surface);
    color: var(--text);
}

.stop-field input:focus,
.stop-field select:focus {
    border-color: var(--accent);
}

.stop-field small {
    color: var(--text-muted);
    font-size: 10px;
}

.stop-error {
    margin-top: 17px;
    padding: 10px 12px;
    border-left: 2px solid var(--negative);
    background: color-mix(in srgb, var(--negative) 8%, var(--surface));
    color: var(--negative);
    font-size: 11px;
}

.stop-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 22px;
    padding-top: 17px;
    border-top: 1px solid var(--border);
}

/* Tablet */
@media (max-width: 1024px) {
    body {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow: auto;
    }

    #app {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .app-header {
        position: sticky;
        top: 0;
    }

    main {
        overflow: visible;
    }

    .tab-content.active,
    .page-shell {
        height: auto;
    }

    .page-shell,
    #scmc-content,
    #fno-content,
    #nasdaq100-content {
        overflow: visible;
    }

    .chart-box {
        min-height: 400px;
    }

    .positions-page {
        overflow: visible;
    }

    .returns-sleeves,
    .returns-tables {
        grid-template-columns: 1fr 1fr;
    }

    .live-fno-filters {
        grid-template-columns: repeat(3, minmax(140px, 1fr));
    }
}

/* Phone */
@media (max-width: 720px) {
    .app-header {
        padding: 0 14px;
    }

    .returns-summary {
        grid-template-columns: 1fr;
        align-items: start;
        gap: 22px;
    }

    .returns-summary dl {
        border-top: 1px solid color-mix(in srgb, var(--canvas) 18%, transparent);
        border-left: 0;
        padding-top: 17px;
    }

    .returns-summary dl div {
        padding-right: 12px;
        padding-left: 0;
    }

    .returns-sleeves,
    .returns-tables {
        grid-template-columns: 1fr;
    }

    .returns-chart {
        height: 410px;
    }

    .header-top {
        gap: 10px;
        padding: 15px 0 13px;
    }

    .theme-btn {
        min-width: 0;
        min-height: 28px;
        font-size: 10px;
    }

    .logout-link {
        min-height: 28px;
        font-size: 11px;
    }

    .workspace-bar {
        display: grid;
        gap: 0;
    }

    .tab-nav {
        grid-row: 1;
        gap: 20px;
        padding-right: 18px;
        scroll-snap-type: x proximity;
    }

    .tab-btn {
        min-height: 44px;
        padding-inline: 0;
        font-size: 12px;
        scroll-snap-align: start;
    }

    .live-value {
        grid-row: 2;
        min-height: 39px;
        justify-content: flex-start;
        padding: 8px 2px;
        border-top: 1px solid var(--border);
    }

    .main-price {
        font-size: 18px;
    }

    .price-details {
        padding-top: 0;
    }

    .detail-time {
        margin-left: 0;
    }

    main {
        padding: 22px 14px max(24px, env(safe-area-inset-bottom));
    }

    .page-heading,
    .scmc-header {
        display: grid;
        gap: 12px;
        margin-bottom: 22px;
        padding-bottom: 18px;
    }

    .fno-header-actions {
        display: grid;
        width: 100%;
        gap: 10px;
    }

    .fno-header-actions .section-meta {
        text-align: left;
    }

    .fno-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .fno-stat {
        min-height: 70px;
        padding: 11px 12px;
        border-bottom: 1px solid var(--border);
    }

    .fno-stat:nth-child(2n) {
        border-right: 0;
    }

    .fno-stat:nth-last-child(-n + 2) {
        border-bottom: 0;
    }

    .fno-stat strong {
        font-size: 19px;
    }

    .fno-sort-wrap {
        display: grid;
        width: 100%;
        gap: 5px;
    }

    .fno-sort-control {
        width: 100%;
    }

    .live-fno-heading-actions {
        width: 100%;
        justify-items: stretch;
    }

    .live-fno-heading-actions .section-meta {
        text-align: left;
    }

    .live-fno-market {
        display: grid;
        gap: 4px;
    }

    .live-fno-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .live-fno-stat:nth-child(2) {
        border-right: 0;
    }

    .live-fno-stat:nth-child(-n + 2) {
        border-bottom: 1px solid var(--border);
    }

    .live-fno-stat strong {
        font-size: 18px;
    }

    .live-fno-results-heading {
        align-items: flex-start;
        padding: 16px 14px 14px;
    }

    .live-fno-results-heading > strong {
        padding-top: 3px;
    }

    .live-fno-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 12px 14px;
    }

    .live-fno-search {
        grid-column: span 2;
    }

    .live-fno-table-shell {
        max-height: 68vh;
    }

    .positions-toolbar {
        display: grid;
        align-items: stretch;
        gap: 16px;
    }

    .positions-toolbar h1 {
        font-size: 40px;
    }

    .positions-actions,
    .positions-search {
        width: 100%;
    }

    .positions-search {
        flex: 1;
    }

    .positions-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .positions-stat:nth-child(2) {
        border-right: 0;
    }

    .positions-stat:nth-child(-n + 2) {
        border-bottom: 1px solid var(--border);
    }

    .positions-stat strong {
        font-size: 17px;
    }

    .stop-modal-card {
        padding: 20px 16px;
    }

    .stop-reference-grid {
        grid-template-columns: 1fr;
    }

    .page-heading h1,
    .scmc-title {
        font-size: clamp(39px, 12vw, 52px);
    }

    .segmented-control {
        width: 100%;
        overflow-x: auto;
        gap: 17px;
    }

    .segmented-control .sr-btn {
        min-height: 36px;
    }

    .fno-sort-control .fno-sort-btn {
        min-height: 44px;
    }

    .panel-card {
        padding: 14px;
        border-radius: 0;
    }

    .chart-large,
    .chart-medium {
        height: 275px;
    }

    .chart-box,
    .us-pnl-page .chart-box {
        min-height: 290px;
    }

    .us-pnl-page .page-heading h1 {
        font-size: clamp(36px, 10.5vw, 46px);
        letter-spacing: -0.045em;
        word-spacing: 0.06em;
    }

    .us-chart-panel {
        padding: 16px 14px 12px;
    }

    .current-position-panel {
        padding: 16px 14px;
    }

    .current-position-heading {
        align-items: flex-start;
        margin-bottom: 12px;
        padding-bottom: 12px;
    }

    .position-refresh-note {
        max-width: 145px;
        text-align: right;
    }

    .current-position-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .position-metric {
        min-height: 63px;
        padding: 12px;
        border-left: 0;
        border-bottom: 1px solid color-mix(in srgb, var(--canvas) 16%, transparent);
    }

    .position-metric:nth-child(odd) {
        padding-left: 0;
        border-right: 1px solid color-mix(in srgb, var(--canvas) 16%, transparent);
    }

    .position-metric:nth-child(even) {
        padding-right: 0;
    }

    .position-metric:nth-last-child(-n + 2) {
        border-bottom: 0;
    }

    .position-metric-value {
        font-size: 17px;
    }

    .position-ticker .position-metric-value {
        font-size: 22px;
    }

    .us-chart-toolbar {
        align-items: flex-start;
        gap: 14px;
    }

    .us-chart-toolbar h2 {
        font-size: 19px;
    }

    .us-range-selector {
        gap: 12px;
    }

    .us-range-btn {
        min-height: 28px;
        font-size: 9px;
    }

    .us-chart-legend {
        gap: 14px;
        margin-top: 16px;
        font-size: 11px;
    }

    .legend-line {
        width: 19px;
    }

    .us-chart-frame {
        height: 310px;
        margin-top: 10px;
    }

    .us-chart-footer {
        gap: 14px;
        font-size: 10px;
    }

    .us-chart-method {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .date-btn,
    .sr-btn {
        min-height: 38px;
    }

    .scmc-bt-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0;
        margin-bottom: 20px;
    }

    .scmc-execution {
        margin-top: 0;
        padding: 14px;
    }

    .scmc-execution-head {
        display: grid;
        gap: 12px;
    }

    .scmc-refresh-btn {
        width: 100%;
    }

    .scmc-execution-dates,
    .scmc-order-grid,
    .scmc-start-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scmc-bt-item {
        min-height: 70px;
        padding: 11px 12px;
        font-size: 17px;
        border-right: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
    }

    .scmc-bt-item:nth-child(2n) {
        border-right: 0;
    }

    .scmc-bt-item:last-child {
        grid-column: 1 / -1;
        border-right: 0;
        border-bottom: 0;
    }

    .sr-section {
        margin-top: 20px;
    }

    .sr-section-header {
        display: grid;
        gap: 5px;
    }

    .section-meta {
        text-align: left;
    }

    .sr-chart-box,
    .sr-chart-box.chart-primary {
        height: 270px;
        padding: 10px;
    }

    .holding-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0;
    }

    .holding-card {
        min-height: 76px;
    }

    .holding-symbol {
        font-size: 17px;
    }

    .position-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .position-metric.primary {
        grid-column: 1 / -1;
    }

    .scmc-year-header {
        align-items: flex-start;
    }

    .year-equity {
        display: block;
        margin: 2px 0 0;
    }

    .sr-table {
        font-size: 12px;
    }
}

@media (max-width: 430px) {
    .header-top {
        grid-template-columns: auto 1fr;
    }

    .site-name {
        justify-self: end;
        font-size: 14px;
    }

    .website-link {
        font-size: 11px;
    }

    .header-right {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: space-between;
        padding-top: 9px;
        border-top: 1px solid var(--border);
    }

    .theme-toggle {
        gap: 10px;
    }

    .theme-btn {
        min-width: 0;
        padding-inline: 0;
        font-size: 10px;
    }

    .logout-link {
        margin-left: auto;
        padding-left: 14px;
    }

    .position-summary {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 360px) {
    .header-top,
    .header-right {
        gap: 5px;
    }

    .theme-btn {
        min-width: 36px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
