/* Shared design tokens keep platform pages visually consistent. */
:root {
    --page-bg: #f3f7f9;
    --surface: #ffffff;
    --surface-soft: #f7fafb;
    --surface-teal: #edf8f8;
    --surface-deep: #0d2e33;
    --text: #173137;
    --text-strong: #092429;
    /* Higher-contrast secondary tones keep compact labels readable on light surfaces. */
    --text-muted: #566e73;
    --text-faint: #62797e;
    --border: #dce8ea;
    --border-strong: #c5dadd;
    --primary: #087f83;
    --primary-dark: #06676b;
    --primary-soft: #dff3f2;
    --primary-rgb: 8, 127, 131;
    --cyan: #20b8bf;
    --blue: #3468d4;
    --purple: #7558d8;
    --success: #16825d;
    --success-soft: #e4f5ed;
    --danger: #d84b58;
    --danger-soft: #fcebed;
    --warning: #b77815;
    --warning-soft: #fff3d9;
    --shadow-sm: 0 2px 8px rgba(22, 63, 70, 0.05);
    --shadow: 0 10px 28px rgba(22, 63, 70, 0.08);
    --shadow-lg: 0 22px 60px rgba(14, 44, 50, 0.17);
    --sidebar-width: 264px;
    --sidebar-collapsed-width: 78px;
    --topbar-height: 76px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 17px;
    --transition: 180ms ease;
}

/* Dark theme variables preserve hierarchy without changing component rules. */
body.theme-dark {
    --page-bg: #101716;
    --surface: #17211f;
    --surface-soft: #1c2825;
    --surface-teal: #1b302e;
    --surface-deep: #091715;
    --text: #d8e5e2;
    --text-strong: #f1f7f5;
    --text-muted: #9aafaa;
    --text-faint: #768d88;
    --border: #2b3c39;
    --border-strong: #3b504b;
    --primary: #4bc4c1;
    --primary-dark: #68d6d2;
    --primary-soft: #193d3a;
    --primary-rgb: 75, 196, 193;
    --success: #69c99d;
    --success-soft: #19372b;
    --danger: #ef7b84;
    --danger-soft: #3a2024;
    --warning: #e1ae58;
    --warning-soft: #3c301b;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.12);
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.35);
}

/* Base rules normalize the layout and typography. */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

/* Hidden permission controls, tabs, and badges stay hidden despite component display rules. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--page-bg);
    color: var(--text);
    font-family: "Manrope", sans-serif;
    font-size: 15px;
    /* A medium base weight keeps body copy and data labels readable without flattening heading hierarchy. */
    font-weight: 500;
    line-height: 1.5;
    transition: background var(--transition), color var(--transition);
}

button,
input,
select,
textarea {
    color: inherit;
    font: inherit;
}

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

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3,
strong {
    color: var(--text-strong);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(var(--primary-rgb), 0.2);
    outline-offset: 2px;
}

.hidden {
    display: none !important;
}

.positive {
    color: var(--success) !important;
}

.negative {
    color: var(--danger) !important;
}

.warning-text {
    color: var(--warning) !important;
}

/* The main shell reserves fixed navigation space on desktop. */
.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    padding: 22px 15px 14px;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transition: width var(--transition), padding var(--transition), transform var(--transition), background var(--transition);
}

.brand {
    display: flex;
    min-height: 45px;
    align-items: center;
    gap: 11px;
    padding: 0 10px;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    flex: 0 0 auto;
    color: #fff;
    background: linear-gradient(145deg, var(--primary), var(--cyan));
    border-radius: 11px;
    box-shadow: 0 8px 18px rgba(var(--primary-rgb), 0.2);
}

.brand-mark i {
    font-size: 17px;
}

.brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.12;
}

.brand-copy strong {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.4px;
}

.brand-copy small {
    margin-top: 4px;
    color: var(--primary);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 1.7px;
}

.sidebar-nav {
    margin-top: 27px;
}

.nav-label {
    margin: 20px 11px 8px;
    color: var(--text-faint);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 1.35px;
    text-transform: uppercase;
}

.nav-link {
    position: relative;
    display: flex;
    min-height: 46px;
    align-items: center;
    gap: 12px;
    margin: 3px 0;
    padding: 0 12px;
    color: var(--text-muted);
    border-radius: 10px;
    font-size: 13.5px;
    /* Stronger navigation labels remain easy to scan beside compact sidebar icons. */
    font-weight: 700;
    transition: color var(--transition), background var(--transition);
}

.nav-link i {
    width: 18px;
    color: var(--text-faint);
    font-size: 14px;
    text-align: center;
}

.nav-link:hover {
    color: var(--text-strong);
    background: var(--surface-soft);
}

.nav-link.active {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.nav-link.active::before {
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: -15px;
    width: 3px;
    content: "";
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.nav-link.active i {
    color: var(--primary);
}

.nav-count {
    min-width: 21px;
    margin-left: auto;
    padding: 2px 6px;
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}

.nav-count.warning {
    color: var(--warning);
    background: var(--warning-soft);
}

.workspace-switcher {
    margin-top: auto;
    padding-top: 18px;
}

.workspace-link {
    display: flex;
    min-height: 51px;
    align-items: center;
    gap: 10px;
    margin: 4px 0;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    transition: background var(--transition), border var(--transition);
}

.workspace-link:hover,
.workspace-link.active {
    background: var(--surface-soft);
    border-color: var(--border);
}

.workspace-icon {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 9px;
    font-size: 12px;
}

.workspace-icon.client {
    color: var(--primary);
    background: var(--primary-soft);
}

.workspace-link > span:last-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.workspace-link strong {
    font-size: 12.5px;
    font-weight: 700;
}

.workspace-link small {
    margin-top: 1px;
    color: var(--text-faint);
    font-size: 10.5px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 9px;
    /* The account avatar and logout stay anchored at the bottom of every sidebar. */
    margin-top: auto;
    padding: 12px 7px 3px;
    border-top: 1px solid var(--border);
}

.avatar,
.large-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: #fff;
    background: linear-gradient(145deg, #1a7780, #34a9a8);
    border-radius: 50%;
    font-weight: 800;
}

.avatar {
    width: 34px;
    height: 34px;
    font-size: 11px;
}

.user-copy {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.user-copy strong {
    overflow: hidden;
    font-size: 12.5px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-copy small {
    overflow: hidden;
    color: var(--text-faint);
    font-size: 10.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition);
}

/* The sticky top bar keeps market state visible while scrolling. */
.topbar {
    position: sticky;
    z-index: 40;
    top: 0;
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 30px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
}

body.theme-dark .topbar {
    background: rgba(23, 33, 31, 0.92);
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.market-session {
    display: flex;
    align-items: center;
    gap: 9px;
}

.market-session > span:last-child {
    display: flex;
    flex-direction: column;
}

.market-session strong {
    font-size: 12.5px;
    line-height: 1.3;
}

.market-session small {
    color: var(--text-faint);
    font-size: 10.5px;
}

.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    background: var(--text-faint);
    border-radius: 50%;
}

.status-dot.live {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(22, 130, 93, 0.11);
}

.icon-button,
.theme-toggle {
    position: relative;
    display: inline-grid;
    width: 38px;
    height: 38px;
    padding: 0;
    place-items: center;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: 9px;
    transition: color var(--transition), background var(--transition), border var(--transition);
}

.icon-button:hover,
.theme-toggle:hover {
    color: var(--primary);
    background: var(--surface-soft);
}

.icon-button.subtle {
    width: 35px;
    height: 35px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    font-size: 12px;
}

.icon-button.subtle.active {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: rgba(var(--primary-rgb), 0.2);
}

.icon-button.outlined {
    background: var(--surface);
    border: 1px solid var(--border-strong);
}

.notification-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 6px;
    height: 6px;
    background: var(--danger);
    border: 1.5px solid var(--surface);
    border-radius: 50%;
}

/* The shared notification center keeps account updates available without leaving the page. */
.notification-center {
    position: relative;
}

.notification-toggle[aria-expanded="true"] {
    color: var(--primary);
    background: var(--primary-soft);
}

.notification-dropdown {
    position: absolute;
    z-index: 90;
    top: calc(100% + 12px);
    right: 0;
    width: min(380px, calc(100vw - 28px));
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 15px;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    transform: translateY(-7px) scale(0.985);
    transform-origin: top right;
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}

.notification-dropdown.open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.notification-header {
    display: flex;
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.notification-header div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.notification-header strong {
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 800;
}

.notification-header small {
    color: var(--text-faint);
    font-size: 10.5px;
}

.notification-count {
    min-width: 27px;
    padding: 4px 7px;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    text-align: center;
}

/* Uncached navigation badges reserve their space without flashing a false zero. */
.nav-count.is-loading {
    visibility: hidden;
}

.notification-list {
    max-height: min(410px, calc(100vh - 190px));
    overflow-y: auto;
    overscroll-behavior: contain;
}

.notification-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    min-height: 72px;
    padding: 11px 16px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.notification-item:hover {
    background: var(--surface-soft);
}

.notification-item.unread {
    background: rgba(var(--primary-rgb), 0.045);
}

.notification-item-icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 11px;
    font-size: 13px;
}

.notification-item-icon.warning {
    color: var(--warning);
    background: var(--warning-soft);
}

.notification-item-icon.success {
    color: var(--success);
    background: var(--success-soft);
}

.notification-item-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.notification-item-copy strong,
.notification-item-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-item-copy strong {
    color: var(--text-strong);
    font-size: 12px;
    font-weight: 800;
}

.notification-item-copy small,
.notification-item time {
    color: var(--text-faint);
    font-size: 10px;
}

.notification-item time {
    white-space: nowrap;
}

.notification-empty {
    display: grid;
    min-height: 180px;
    place-items: center;
    align-content: center;
    gap: 9px;
    padding: 28px;
    color: var(--text-faint);
    text-align: center;
}

.notification-empty i {
    color: var(--primary);
    font-size: 22px;
}

.notification-empty strong {
    color: var(--text-strong);
    font-size: 12px;
}

.notification-empty small {
    font-size: 10.5px;
    line-height: 1.55;
}

.notification-footer {
    display: flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    color: var(--primary);
    background: var(--surface-soft);
    font-size: 11px;
    font-weight: 800;
}

.notification-footer:hover {
    color: var(--primary-dark);
}

.mobile-menu-button {
    display: none;
}

/* The desktop collapse arrow sits halfway down and overlaps the sidebar's right boundary. */
.sidebar-collapse-button {
    position: fixed;
    z-index: 55;
    top: 50%;
    left: calc(var(--sidebar-width) - 15px);
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: 9px;
    box-shadow: var(--shadow-sm);
    transform: translateY(-50%);
    transition: left var(--transition), color var(--transition), background var(--transition), border var(--transition);
}

.sidebar-collapse-button i {
    font-size: 11px;
}

.mobile-backdrop {
    position: fixed;
    z-index: 45;
    inset: 0;
    display: none;
    background: rgba(8, 28, 31, 0.46);
    backdrop-filter: blur(2px);
}

/* Page-level spacing gives every workspace the same reading rhythm. */
.page-content {
    width: 100%;
    max-width: 1540px;
    margin: 0 auto;
    padding: 34px 36px 48px;
}

/* The directory total sits beside its navigation title without needing a second heading. */
.topbar-page-count {
    display: inline-flex;
    min-width: 23px;
    min-height: 21px;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
    padding: 2px 6px;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid rgba(var(--primary-rgb), 0.13);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    vertical-align: middle;
}

.topbar-page-count.is-loading {
    color: var(--text-faint);
}

/* Compact controls leave the page title in the top navigation. */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.eyebrow,
.panel-kicker {
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.45px;
}

.toolbar-actions,
.panel-actions {
    display: flex;
    align-items: center;
    gap: 9px;
}

/* Save is always the final right-aligned action inside its local page, panel, or dialog. */
.save-action {
    margin-left: auto;
}

.account-pill,
.market-open-label {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    gap: 8px;
    padding: 0 11px;
    color: var(--success);
    background: var(--success-soft);
    border: 1px solid rgba(22, 130, 93, 0.13);
    border-radius: 9px;
    font-size: 11.5px;
    font-weight: 800;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 12.5px;
    font-weight: 800;
    transition: transform var(--transition), background var(--transition), border var(--transition), color var(--transition);
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 7px 16px rgba(var(--primary-rgb), 0.16);
}

.button-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.button-secondary {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border-strong);
}

.button-secondary:hover {
    color: var(--primary);
    background: var(--surface-teal);
    border-color: var(--primary);
}

/* Refresh actions keep a stable width and clearly communicate progress and completion. */
.button.refresh-control,
.button[id^="refresh-"] {
    min-width: 116px;
}

.button.refresh-control:disabled {
    opacity: 1;
    transform: none;
}

.refresh-control.is-refreshing {
    color: var(--primary);
    background: var(--surface-teal);
    border-color: rgba(var(--primary-rgb), 0.3);
    cursor: wait;
    pointer-events: none;
}

.button.refresh-control.is-complete {
    color: var(--success);
    background: var(--success-soft);
    border-color: rgba(22, 130, 93, 0.24);
}

/* Reduced-motion users retain the state text without a rotating animation. */
@media (prefers-reduced-motion: reduce) {
    .refresh-control .fa-spin {
        animation: none;
    }
}

.button-ai {
    color: #fff;
    background: linear-gradient(100deg, #6153ce, #4c83db);
    box-shadow: 0 8px 20px rgba(97, 83, 206, 0.2);
}

.button-call {
    color: #fff;
    background: var(--success);
    border-color: var(--success);
}

.button-small {
    min-height: 36px;
    padding: 0 12px;
    font-size: 11.5px;
}

.button-block {
    width: 100%;
}

.text-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    color: var(--primary);
    background: transparent;
    border: 0;
    font-size: 12px;
    font-weight: 800;
}

/* Shared cards and metrics form the visual foundation. */
.panel,
.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.panel {
    border-radius: var(--radius-lg);
}

/* Table actions live inside their panel instead of occupying a separate page row. */
.panel-action-bar {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 9px;
    padding: 18px;
    border-bottom: 1px solid var(--border);
}

/* History filters and refresh buttons wrap together when panel width is limited. */
.panel-header.has-panel-actions,
.panel-header.has-panel-actions > .panel-actions {
    flex-wrap: wrap;
}

.panel-header.has-panel-actions > .panel-actions {
    max-width: 100%;
}

.panel-header.has-panel-actions .compact-select {
    max-width: 100%;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.panel-header h2,
.section-title-row h2 {
    margin: 2px 0 0;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.35px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.metric-card {
    min-width: 0;
    padding: 18px 19px 17px;
    border-radius: var(--radius);
}

.metric-card.primary-metric {
    background: linear-gradient(145deg, var(--surface), var(--surface-teal));
    border-color: rgba(var(--primary-rgb), 0.22);
}

.metric-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 9px;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 700;
}

.metric-label i {
    color: var(--text-faint);
}

.metric-card > strong {
    display: block;
    overflow: hidden;
    margin-bottom: 5px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.55px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-card > small {
    display: block;
    overflow: hidden;
    color: var(--text-faint);
    font-size: 10.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-card > small i {
    margin-right: 3px;
    color: var(--success);
}

.metric-card > small b {
    color: var(--success);
}

/* Shared search controls support market and client filtering. */
.search-field,
.global-search {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 12px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.search-field {
    margin: 13px 14px 10px;
}

.search-field i,
.global-search i {
    color: var(--text-faint);
    font-size: 13px;
}

.search-field input,
.global-search input {
    min-width: 0;
    flex: 1;
    background: transparent;
    border: 0;
    outline: none;
    font-size: 13px;
}

.search-field input::placeholder,
.global-search input::placeholder {
    color: var(--text-faint);
}

kbd {
    padding: 2px 5px;
    color: var(--text-faint);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 1px 0 var(--border);
    font-family: inherit;
    font-size: 10px;
}

/* Shared filter chips provide compact list filtering across workspaces. */
.filter-chip {
    min-height: 34px;
    padding: 0 11px;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.filter-chip:hover,
.filter-chip.active {
    color: var(--primary-dark);
    background: var(--primary-soft);
    border-color: rgba(var(--primary-rgb), 0.24);
}

/* Shared asset avatars identify instrument categories in lists and tables. */
.asset-avatar {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    flex: 0 0 auto;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 9px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: -0.1px;
}

.asset-avatar.stocks {
    color: var(--blue);
    background: rgba(52, 104, 212, 0.11);
}

.asset-avatar.indices {
    color: var(--purple);
    background: rgba(117, 88, 216, 0.11);
}

.asset-avatar.commodities {
    color: var(--warning);
    background: var(--warning-soft);
}

.asset-avatar.crypto {
    color: #c26a1b;
    background: #fff0de;
}

body.theme-dark .asset-avatar.crypto {
    background: #392b1c;
}

/* Shared form controls keep every editable field consistent. */
.field-label {
    display: block;
    margin: 10px 0 5px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
}

.form-control {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    color: var(--text);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    font-size: 12.5px;
    transition: border var(--transition), box-shadow var(--transition), background var(--transition);
}

textarea.form-control {
    min-height: 74px;
    padding-top: 9px;
    resize: vertical;
}

.form-control:focus {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

/* Shared custom checkboxes provide one clear checked, hover, focus, and disabled state across the system. */
input[type="checkbox"] {
    display: inline-grid;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    place-content: center;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    color: #fff;
    background: var(--surface);
    border: 1.5px solid var(--border-strong);
    border-radius: 5px;
    box-shadow: inset 0 1px 1px rgba(9, 36, 41, 0.04);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
}

input[type="checkbox"]::before {
    width: 5px;
    height: 9px;
    content: "";
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    opacity: 0;
    transform: translateY(-1px) rotate(45deg) scale(0.7);
    transition: opacity var(--transition), transform var(--transition);
}

input[type="checkbox"]:hover:not(:disabled) {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.08);
}

input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 3px 8px rgba(var(--primary-rgb), 0.2);
}

input[type="checkbox"]:checked::before {
    opacity: 1;
    transform: translateY(-1px) rotate(45deg) scale(1);
}

input[type="checkbox"]:indeterminate {
    background: var(--primary);
    border-color: var(--primary);
}

input[type="checkbox"]:indeterminate::before {
    width: 8px;
    height: 2px;
    background: currentColor;
    border: 0;
    opacity: 1;
    transform: none;
}

input[type="checkbox"]:focus-visible {
    outline: 3px solid rgba(var(--primary-rgb), 0.2);
    outline-offset: 2px;
}

input[type="checkbox"]:disabled {
    background: var(--surface-soft);
    border-color: var(--border);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.55;
}

input[type="checkbox"]:disabled:checked {
    color: var(--text-faint);
    background: var(--border-strong);
}

.number-field {
    position: relative;
}

.suffix-field .form-control {
    padding-right: 38px;
}

.suffix-field > span {
    position: absolute;
    top: 50%;
    right: 9px;
    color: var(--text-faint);
    font-size: 10px;
    font-weight: 800;
    transform: translateY(-50%);
}

/* Shared tabs and tables present positions, requests, documents, and trades. */
.positions-tabs button,
.account-tabs button {
    position: relative;
    min-height: 48px;
    padding: 0 13px;
    color: var(--text-faint);
    background: transparent;
    border: 0;
    font-size: 12px;
    font-weight: 800;
}

.positions-tabs button.active,
.account-tabs button.active {
    color: var(--primary);
}

.positions-tabs button.active::after,
.account-tabs button.active::after {
    position: absolute;
    right: 8px;
    bottom: -1px;
    left: 8px;
    height: 2px;
    content: "";
    background: var(--primary);
    border-radius: 5px 5px 0 0;
}

.positions-tabs button span,
.account-tabs button > span {
    margin-left: 5px;
    padding: 2px 5px;
    color: var(--text-muted);
    background: var(--surface-soft);
    border-radius: 10px;
    font-size: 10px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

.data-table th {
    height: 44px;
    padding: 0 14px;
    color: var(--text-faint);
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.25px;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    height: 54px;
    padding: 9px 14px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

.data-table tbody tr:hover td {
    background: rgba(var(--primary-rgb), 0.025);
}

.data-table td strong {
    font-size: 11.5px;
    font-weight: 800;
}

.table-symbol {
    display: flex;
    align-items: center;
    gap: 7px;
}

.table-symbol .asset-avatar {
    width: 25px;
    height: 25px;
    border-radius: 7px;
    font-size: 9px;
}

.side-badge,
.status-badge,
.table-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 800;
}

.side-badge.buy,
.table-status.approved,
.table-status.open,
.status-badge.active {
    color: var(--success);
    background: var(--success-soft);
}

.side-badge.sell,
.table-status.rejected {
    color: var(--danger);
    background: var(--danger-soft);
}

.table-status.pending,
.table-status.review {
    color: var(--warning);
    background: var(--warning-soft);
}

.table-status.closed {
    color: var(--text-muted);
    background: var(--surface-soft);
}

.table-action {
    min-height: 32px;
    padding: 0 10px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 11px;
    font-weight: 800;
}

.table-action:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.table-action.danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.empty-table-cell {
    height: 100px !important;
    color: var(--text-faint) !important;
    text-align: center;
}

.empty-table-cell i {
    display: block;
    margin-bottom: 7px;
    font-size: 18px;
}

/* Shared compact selectors and calculators support the Client trading tools. */
.compact-select {
    min-height: 40px;
    padding: 0 28px 0 9px;
    color: var(--text-muted);
    background-color: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    font-size: 12px;
    font-weight: 700;
}
.calculator-panel {
    min-height: 315px;
    padding: 17px;
}

.calculator-icon {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 9px;
}

.calculator-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px 8px;
    margin-top: 11px;
}

.calculator-result {
    display: flex;
    min-height: 66px;
    flex-direction: column;
    justify-content: center;
    margin-top: 12px;
    padding: 9px 14px;
    background: var(--success-soft);
    border: 1px solid rgba(22, 130, 93, 0.18);
    border-radius: 10px;
}

.calculator-result > span {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
}

.calculator-result > strong {
    color: var(--success);
    font-size: 23px;
    font-weight: 800;
}

.calculator-result > small {
    color: var(--text-muted);
    font-size: 10.5px;
}

/* Shared modal layers provide consistent information, confirmation, and deletion dialogs. */
.platform-modal-layer {
    position: fixed;
    z-index: 2000;
    inset: 0;
    display: grid;
    padding: 20px;
    place-items: center;
    overflow-y: auto;
    background: rgba(6, 29, 33, 0.5);
    opacity: 0;
    transition: opacity 160ms ease;
}

.platform-modal-layer.visible {
    opacity: 1;
}

.platform-modal {
    position: relative;
    display: grid;
    width: min(440px, 100%);
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 0 15px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    transition: opacity 160ms ease, transform 160ms ease;
}

.platform-modal-layer.visible .platform-modal {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.platform-modal-large {
    width: min(960px, 100%);
}

.platform-modal-icon {
    display: grid;
    width: 48px;
    height: 48px;
    grid-row: 1;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 13px;
    font-size: 19px;
}

.platform-modal-danger .platform-modal-icon {
    color: var(--danger);
    background: var(--danger-soft);
}

.platform-modal-copy {
    min-width: 0;
    padding-right: 20px;
}

.platform-modal-copy h2 {
    margin: 0 0 6px;
    font-size: 19px;
}

.platform-modal-copy p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.platform-modal-copy p:empty {
    display: none;
}

.platform-modal-copy > small {
    display: block;
    margin-top: 9px;
    color: var(--text-faint);
    font-size: 11px;
}

.platform-modal-content {
    margin-top: 18px;
}

.platform-modal-content:empty {
    display: none;
}

.platform-modal-actions {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 22px;
}

.platform-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    color: var(--text-faint);
    background: transparent;
    border: 0;
    border-radius: 7px;
}

.platform-modal-close:hover {
    color: var(--text);
    background: var(--surface-soft);
}

.button-danger {
    color: #ffffff;
    background: var(--danger);
    border-color: var(--danger);
    box-shadow: 0 7px 16px rgba(216, 75, 88, 0.16);
}

.button-danger:hover {
    filter: brightness(0.94);
}

body.platform-modal-open {
    overflow: hidden;
}

@media (max-width: 560px) {
    .platform-modal-layer {
        align-items: end;
        padding: 10px;
    }

    .platform-modal {
        grid-template-columns: 40px minmax(0, 1fr);
        gap: 0 11px;
        padding: 20px;
        border-radius: 15px;
    }

    .platform-modal-icon {
        width: 40px;
        height: 40px;
    }

    .platform-modal-actions .button {
        flex: 1;
    }
}

/* AI field help stays available beside labels, including when the associated input is locked. */
.ai-field-help { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-left: 6px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 800; vertical-align: middle; cursor: pointer; }
.ai-field-help:hover { color: var(--primary); border-color: var(--primary); }
.ai-field-help:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ai-unit-label { display: block; margin-top: 8px; }

/* Toasts report transient actions without stopping the user. */
.toast-region {
    position: fixed;
    /* Keep notifications above the live chat launcher and floating panel. */
    z-index: 900;
    right: 18px;
    bottom: 18px;
    display: flex;
    width: min(360px, calc(100vw - 30px));
    max-height: calc(100vh - 36px);
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    pointer-events: none;
}

.toast-message {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 9px;
    min-height: 55px;
    padding: 9px 11px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 11px;
    box-shadow: var(--shadow-lg);
    animation: toast-in 220ms ease;
    pointer-events: auto;
}

.toast-message.removing {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast-icon {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 8px;
}

.toast-message.success .toast-icon {
    color: var(--success);
    background: var(--success-soft);
}

.toast-message.warning .toast-icon {
    color: var(--warning);
    background: var(--warning-soft);
}

/* Error feedback uses the stronger danger palette while warnings stay amber. */
.toast-message.error .toast-icon {
    color: var(--danger);
    background: var(--danger-soft);
}

/* Repeated feedback pulses the existing item instead of adding another toast. */
.toast-message.is-repeated {
    animation: toast-repeat 180ms ease;
}

.toast-copy {
    display: flex;
    flex-direction: column;
}

.toast-copy strong {
    font-size: 12px;
}

.toast-copy small {
    color: var(--text-muted);
    font-size: 10.5px;
}

.toast-close {
    width: 25px;
    height: 25px;
    color: var(--text-faint);
    background: transparent;
    border: 0;
}

.toast-close:hover,
.toast-close:focus-visible {
    color: var(--text);
    background: var(--surface-soft);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Shared responsive rules collapse the application shell and common components. */
@media (max-width: 1380px) {
    :root {
        --sidebar-width: 240px;
    }

    .page-content {
        padding-right: 20px;
        padding-left: 20px;
    }

    .topbar {
        padding-right: 20px;
        padding-left: 20px;
    }
}

@keyframes toast-repeat {
    50% {
        transform: translateX(-4px);
    }
}

/* Small screens keep the toast stack clear of both viewport edges. */
@media (max-width: 470px) {
    .toast-region {
        right: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
    }
}

/* Reduced-motion users receive the same feedback without toast movement. */
@media (prefers-reduced-motion: reduce) {
    .toast-message,
    .toast-message.is-repeated,
    .toast-message.removing {
        animation: none;
        transition: opacity 180ms ease;
    }
}

/* Desktop compact mode preserves icon access while returning page width to the workspace. */
@media (min-width: 1121px) {
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width);
        padding-right: 10px;
        padding-left: 10px;
    }

    body.sidebar-collapsed .app-main {
        margin-left: var(--sidebar-collapsed-width);
    }

    body.sidebar-collapsed .brand,
    body.sidebar-collapsed .nav-link,
    body.sidebar-collapsed .workspace-link {
        justify-content: center;
    }

    body.sidebar-collapsed .brand {
        padding-right: 0;
        padding-left: 0;
    }

    body.sidebar-collapsed .brand-copy,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .nav-link > span:not(.nav-count),
    body.sidebar-collapsed .workspace-link > span:last-child,
    body.sidebar-collapsed .user-copy {
        display: none;
    }

    body.sidebar-collapsed .sidebar-nav {
        width: 100%;
    }

    body.sidebar-collapsed .nav-link {
        gap: 0;
        padding-right: 0;
        padding-left: 0;
    }

    body.sidebar-collapsed .nav-link i {
        width: 22px;
        font-size: 16px;
    }

    body.sidebar-collapsed .nav-link.active::before {
        left: -10px;
    }

    body.sidebar-collapsed .nav-count {
        position: absolute;
        top: 2px;
        right: 1px;
        min-width: 17px;
        margin-left: 0;
        padding: 1px 4px;
        font-size: 9px;
    }

    body.sidebar-collapsed .workspace-link {
        padding-right: 0;
        padding-left: 0;
    }

    body.sidebar-collapsed .sidebar-user {
        flex-direction: column;
        justify-content: center;
        gap: 8px;
        padding-right: 0;
        padding-left: 0;
    }

    /* The edge control follows the compact sidebar width after collapsing. */
    body.sidebar-collapsed .sidebar-collapse-button {
        left: calc(var(--sidebar-collapsed-width) - 15px);
    }
}

@media (max-width: 1120px) {
    /* An open navigation drawer prevents the underlying page from scrolling. */
    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar {
        width: 260px;
        transform: translateX(-102%);
        box-shadow: var(--shadow-lg);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .mobile-backdrop {
        display: block;
    }

    .app-main {
        margin-left: 0;
    }

    .mobile-menu-button {
        display: inline-grid;
    }

    .sidebar-collapse-button {
        display: none;
    }

    /* Mobile navigation keeps the signed-in user footer at the bottom when collapse is unavailable. */
    .sidebar-user {
        margin-top: auto;
    }
}

@media (max-width: 760px) {
    :root {
        --topbar-height: 61px;
    }

    .topbar {
        padding: 0 12px;
    }

    .topbar-actions {
        gap: 4px;
    }

    /* Mobile notifications use the viewport so the menu never clips past the screen edge. */
    .notification-dropdown {
        position: fixed;
        top: calc(var(--topbar-height) + 8px);
        right: 12px;
        left: 12px;
        width: auto;
    }

    body.client-view-active .notification-dropdown {
        top: calc(var(--topbar-height) + 50px);
    }

    .market-session small {
        display: none;
    }

    .page-content {
        padding: 20px 12px 32px;
    }

    .page-toolbar {
        align-items: center;
        gap: 10px;
    }

    .toolbar-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .toolbar-actions .button {
        flex: 1;
    }

    .account-pill {
        display: none;
    }

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

    .metric-card:last-child {
        grid-column: 1 / -1;
    }

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

@media (max-width: 470px) {
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .metric-card:last-child {
        grid-column: auto;
    }

    .calculator-fields {
        grid-template-columns: 1fr;
    }
}

/* The selected landing profile supplies the portal logo. */
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
