/* ===========================
   DESIGN TOKENS
   =========================== */
:root {
    /* Surfaces — from the Claude "MERIDIAN DEALER TERMINAL" design */
    --bg-base: #080b14;          /* app / page background */
    --bg-sidebar: #0b0f1a;       /* sidebar + header */
    --bg-surface: #0f1422;       /* cards / panels / tables / modals */
    --bg-recessed: #0b101c;      /* inner tiles, table row hover, list rows */
    --bg-elevated: #121829;      /* secondary buttons / icon buttons / chips */

    /* Accent (brand purple) */
    --accent-primary: #7c6cff;
    --accent-primary-hover: #8b7bff;
    --accent-primary-light: #9d8cff;
    --accent-primary-subtle: rgba(124, 108, 255, 0.13);

    /* Semantic */
    --color-success: #34d399;
    --color-success-subtle: rgba(52, 211, 153, 0.12);
    --color-warning: #f5a524;
    --color-warning-subtle: rgba(245, 165, 36, 0.16);
    --color-danger: #f87171;
    --color-danger-solid: #d9434f;    /* destructive button fill (SELL / Square-off) */
    --color-danger-subtle: rgba(248, 113, 113, 0.13);
    --color-info: #5b8def;            /* group-scope accents */
    --color-buy: #1f9d5e;             /* BUY button fill */

    /* Text */
    --color-text-primary: #e6eaf3;
    --color-text-secondary: #8b93a7;
    --color-text-muted: #5a6178;
    --color-text-faint: #4d556b;      /* sidebar section headers */

    /* Borders / dividers (white alpha, per design) */
    --color-border: rgba(255, 255, 255, 0.06);
    --color-border-subtle: rgba(255, 255, 255, 0.04);
    --color-border-strong: rgba(255, 255, 255, 0.10);

    /* Fonts: Plus Jakarta Sans (body and numbers) · Space Grotesk (display) · JetBrains Mono (code boxes only).
       CR-37 (2026-10-19): numbers were JetBrains Mono, whose zero carries a centre dot — at 13-14 px "0.00" read as
       "8.88". Plus Jakarta Sans has a plain zero and tabular figures (the body sets tabular-nums), so columns still
       line up. --font-mono is kept as a name and now means the numbers font. */
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-display: 'Space Grotesk', system-ui, sans-serif;
    --font-num: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: var(--font-num);
    --font-code: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    --radius-sm: 4px;
    --radius-md: 9px;
    --radius-lg: 14px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --sidebar-width: 248px;
    --sidebar-collapsed-width: 56px;
    --topbar-height: 62px;
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
}

/* ===========================
   MUDBLAZOR THEME OVERRIDES
   =========================== */
:root {
    --mud-palette-background: var(--bg-base);
    --mud-palette-background-grey: var(--bg-recessed);
    --mud-palette-surface: var(--bg-surface);
    --mud-palette-drawer-background: var(--bg-sidebar);
    --mud-palette-appbar-background: var(--bg-sidebar);
    --mud-palette-primary: var(--accent-primary);
    --mud-palette-primary-hover: var(--accent-primary-hover);
    --mud-palette-secondary: var(--accent-primary-light);
    --mud-palette-info: var(--color-info);
    --mud-palette-success: var(--color-success);
    --mud-palette-warning: var(--color-warning);
    --mud-palette-error: var(--color-danger);
    --mud-palette-text-primary: var(--color-text-primary);
    --mud-palette-text-secondary: var(--color-text-secondary);
    --mud-palette-text-disabled: var(--color-text-faint);
    --mud-palette-action-default: var(--color-text-secondary);
    --mud-palette-lines-default: var(--color-border);
    --mud-palette-lines-inputs: var(--color-border-strong);
    --mud-palette-divider: var(--color-border);
    --mud-default-borderradius: var(--radius-md);
    --mud-typography-default-family: var(--font-sans);
}

/* ===========================
   BASE RESET
   =========================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg-base);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;   /* CR-37: equal-width digits, so numbers line up in every column */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    height: 100%;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===========================
   TYPOGRAPHY UTILITIES
   =========================== */
.font-mono { font-family: var(--font-mono) !important; }
.text-primary { color: var(--color-text-primary) !important; }
.text-secondary { color: var(--color-text-secondary) !important; }
.text-muted { color: var(--color-text-muted) !important; }
.text-success { color: var(--color-success) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-accent { color: var(--accent-primary) !important; }
.text-sm { font-size: 12px !important; }
.text-xs { font-size: 11px !important; }
.text-lg { font-size: 16px !important; }
.font-semibold { font-weight: 600 !important; }
.font-medium { font-weight: 500 !important; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===========================
   LAYOUT UTILITIES
   =========================== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.p-4 { padding: 16px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }

/* ===========================
   SURFACE CARDS
   =========================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.card-elevated {
    background: var(--bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

/* ===========================
   SKELETON LOADING
   =========================== */
@keyframes skeleton-shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        #232c3d 50%,
        var(--bg-elevated) 75%
    );
    background-size: 800px 100%;
    animation: skeleton-shimmer 1.4s infinite linear;
    border-radius: var(--radius-sm);
    display: inline-block;
}

.skeleton-text {
    height: 14px;
    width: 100%;
    margin-bottom: 6px;
}

.skeleton-text-sm {
    height: 12px;
    width: 60%;
}

/* ===========================
   DATA TABLE
   =========================== */
.meridian-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.meridian-table th {
    background: var(--bg-elevated);
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.meridian-table th:hover {
    color: var(--color-text-primary);
}

.meridian-table th.sorted {
    color: var(--accent-primary);
}

.meridian-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border-subtle);
    color: var(--color-text-primary);
    vertical-align: middle;
    /* Single-line rows like the broker terminal (ANT): the instrument name and its tags stay on one line and
       the column sizes to fit. The table wrapper is overflow-x:auto, so a wide row scrolls rather than wrapping.
       Cells that deliberately wrap (e.g. a rejection reason) set white-space:normal + a max-width inline, which
       overrides this. */
    white-space: nowrap;
}

.meridian-table tr:last-child td {
    border-bottom: none;
}

.meridian-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.table-container {
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--color-border);
    background: var(--bg-elevated);
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* DataGrid header layout — label + sort icon vertically centered */
.grid-th-inner {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* DataGrid sort indicator */
.grid-sort-icon {
    display: inline-flex;
    align-items: center;
    margin-left: 5px;
    font-size: 16px;
    line-height: 1;
    color: #9d8cff;
    opacity: 1;
}

.meridian-table th:hover .grid-sort-icon {
    color: #b9acff;
}

.grid-sort-icon.grid-sort-active {
    color: var(--accent-primary, #7c6cff);
    font-weight: 700;
}

/* DataGrid per-column filter row */
.meridian-table tr.grid-filter-row td {
    padding: 6px 12px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--color-border);
}

.meridian-table tr.grid-filter-row:hover td {
    background: var(--bg-elevated);
}

.grid-filter-input {
    width: 100%;
    min-width: 60px;
    background: var(--bg-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    color: var(--color-text-primary);
    font-size: 11.5px;
    outline: none;
}

.grid-filter-input:focus {
    border-color: var(--accent-primary);
}

.grid-page-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg-base);
    border: 1px solid var(--color-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text-secondary);
}

.grid-page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Date inputs, app-wide: NO visible calendar icon. Clicking anywhere in the box
   opens the native date picker (the picker indicator is stretched invisibly over
   the whole field), while manual typing in the field still works. */
input[type="date"] {
    position: relative;
    cursor: pointer;
    text-transform: uppercase;
    color-scheme: dark;   /* native picker chrome; flipped to light under [data-theme="light"] */
}

input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    background: transparent;
    color: transparent;
    cursor: pointer;
    opacity: 0;
}

/* ===========================
   STATUS CHIPS
   =========================== */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chip-success { background: var(--color-success-subtle); color: var(--color-success); }
.chip-danger  { background: var(--color-danger-subtle);  color: var(--color-danger); }
.chip-warning { background: var(--color-warning-subtle); color: var(--color-warning); }
.chip-info    { background: var(--accent-primary-subtle); color: var(--accent-primary); }
.chip-neutral { background: rgba(255,255,255,0.06); color: var(--color-text-secondary); }

/* ===========================
   FORM INPUTS (MudBlazor overrides)
   =========================== */
.mud-input-root {
    color: var(--color-text-primary) !important;
}

.mud-input-outlined .mud-input-outlined-border {
    border-color: var(--color-border) !important;
}

/* ===========================
   SCROLLBAR (WebKit)
   =========================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #222a3d;
    border-radius: 8px;
    border: 2px solid var(--bg-base);
}

::-webkit-scrollbar-thumb:hover {
    background: #2e3650;
}

::selection {
    background: rgba(124, 108, 255, 0.35);
}

/* ===========================
   CONNECTIVITY BANNER
   =========================== */
/* Pinned to the very top of the viewport and full-width, so a server outage is an unmistakable bar across
   the top of every screen (above the sidebar and header) rather than an inline strip that scrolls away.
   Red because a lost server connection is critical, not a soft warning. It only appears after 3 consecutive
   failed calls, so it signals a real outage, not a single blip. */
.connectivity-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5000;
    background: #d9434f;
    border-bottom: 1px solid rgba(0, 0, 0, .25);
    color: #fff;
    padding: 9px 20px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}

/* ===========================
   TOAST NOTIFICATIONS
   =========================== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
    pointer-events: none;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    pointer-events: all;
    box-shadow: var(--shadow-md);
    animation: toast-in 200ms ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast-success { border-left: 3px solid var(--color-success); }
.toast-error   { border-left: 3px solid var(--color-danger); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-info    { border-left: 3px solid var(--accent-primary); }

/* ===========================
   BOOT / APP LOADING SCREEN
   Branded splash while the WebAssembly app downloads and starts. Themed via
   tokens (index.html sets data-theme before paint); the app replaces it on boot.
   =========================== */
.boot {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
    background: var(--bg-base);
    z-index: 10;
}

.boot-brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* The full logo (images/brand/); the theme shows one: white wordmark on dark, navy on light. */
.boot-logo {
    display: block;
    width: 230px;
    height: auto;
    animation: boot-pulse 1.8s ease-in-out infinite;
}

.boot-logo-on-light { display: none; }
:root[data-theme="light"] .boot-logo-on-dark { display: none; }
:root[data-theme="light"] .boot-logo-on-light { display: block; }

.boot-progress {
    position: relative;
    width: 230px;
    height: 4px;
    border-radius: 4px;
    background: var(--color-border);
    overflow: hidden;
}

.boot-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    border-radius: 4px;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    animation: boot-sweep 1.25s ease-in-out infinite;
}

.boot-status {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--color-text-secondary);
    font-family: var(--font-sans);
}

/* Plain label, not the download %: the Blazor runtime's --blazor-load-percentage-text only tracks
   resource DOWNLOAD, which hits 100% almost at once (localhost / cached) and then sits at "100%"
   for the whole WASM-init phase — a number that reads as stuck. The sweeping bar shows progress. */
.boot-status::after {
    content: "Loading terminal…";
}

@keyframes boot-pulse {
    0%, 100% { transform: translateY(0) scale(1); }
    50%      { transform: translateY(-3px) scale(1.03); }
}

@keyframes boot-sweep {
    0%   { transform: translateX(-120%); }
    100% { transform: translateX(330%); }
}

@media (prefers-reduced-motion: reduce) {
    .boot-logo { animation: none; }
    .boot-progress::after { animation-duration: 2.4s; }
}

/* ===========================
   PAGE LAYOUT
   =========================== */
.page-header {
    display: flex;
    align-items: center;
    /* Screen title now lives in the top header bar (AppHeader); the page-header
       keeps only the action buttons, right-aligned. */
    justify-content: flex-end;
    margin-bottom: 18px;
}

/* Title is rendered by the header bar — suppress the duplicate per-page title. */
.page-content .page-title {
    display: none;
}

.page-content {
    padding: 26px;
    overflow-y: auto;
}

/* ===========================
   STAT CARDS (Dashboard)
   =========================== */
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-card-label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

.stat-card-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--color-text-primary);
    font-family: var(--font-display);
    font-variant-numeric: tabular-nums;
}

.stat-card-sublabel {
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* ===========================
   DESIGN MODAL FORM CONTROLS
   =========================== */
.dm-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin: 14px 0 6px;
}
.dm-label:first-child { margin-top: 0; }

.dm-input, .dm-select {
    width: 100%;
    background: var(--bg-recessed);
    border: 1px solid var(--color-border-strong);
    border-radius: 10px;
    padding: 11px 13px;
    color: var(--color-text-primary);
    font-size: 13.5px;
    outline: none;
    box-sizing: border-box;
}
.dm-input:focus, .dm-select:focus { border-color: var(--accent-primary); }
.dm-select { appearance: none; cursor: pointer; }
/* 29 Oct 2026 ("It not look like DROPDOWN option"): appearance:none took away the browser's arrow, so every select read
   as a text box. A chevron on the right, in the muted grey both themes use, with room for it. select.dm-select outranks
   the phone padding in responsive.css (.dm-select), so the text never runs under the arrow. */
select.dm-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 12px;
    padding-right: 36px;
}

.dm-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.dm-btn-cancel {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--color-border-strong);
    color: var(--color-text-primary);
    font-weight: 600;
    font-size: 13.5px;
    padding: 11px;
    border-radius: 10px;
    cursor: pointer;
}

.dm-btn-primary {
    flex: 1;
    background: var(--accent-primary);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 13.5px;
    padding: 11px;
    border-radius: 10px;
    cursor: pointer;
}
.dm-btn-primary:hover:not(:disabled) { background: var(--accent-primary-hover); }
.dm-btn-primary:disabled { opacity: .7; cursor: default; }

.dm-btn-danger {
    flex: 1;
    background: var(--color-danger-solid);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 13.5px;
    padding: 11px;
    border-radius: 10px;
    cursor: pointer;
}

.dm-error {
    margin-top: 12px;
    padding: 9px 12px;
    border-radius: 9px;
    background: var(--color-danger-subtle);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--color-danger);
    font-size: 13px;
}

/* ===========================
   AUTH / LOGIN
   =========================== */
.auth-shell {
    min-height: 100vh;
    background: var(--bg-base);
}

.login-page {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    min-height: 100vh;
}

/* Brand panel (left) */
.login-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px 48px;
    background:
        radial-gradient(1200px 500px at -10% -10%, rgba(124, 108, 255, 0.22), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(91, 70, 230, 0.18), transparent 55%),
        var(--bg-sidebar);
    border-right: 1px solid var(--color-border);
    overflow: hidden;
}

.login-brand-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* The full logo (images/brand/); the theme shows one: white wordmark on the dark panel, navy on the light one. */
.login-logo {
    display: block;
    width: 210px;
    height: auto;
}

.login-logo-on-light { display: none; }
:root[data-theme="light"] .login-logo-on-dark { display: none; }
:root[data-theme="light"] .login-logo-on-light { display: block; }

.login-headline {
    font-family: var(--font-display);
    font-size: 34px;
    line-height: 1.2;
    font-weight: 700;
    color: #fff;
    margin: 0 0 16px;
}

.login-sub {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--color-text-secondary);
    max-width: 460px;
    margin: 0 0 26px;
}

.login-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-features li {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 13.5px;
    color: var(--color-text-primary);
}

.login-tick {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: var(--accent-primary-subtle);
    color: var(--accent-primary-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex: none;
}

.login-brand-foot {
    font-size: 12px;
    color: var(--color-text-faint);
}

/* Item 35 (29 Oct 2026): "a new version is available", above the sign-in form, when the server runs another release. */
.login-update {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(124, 108, 255, 0.10);
    border: 1px solid rgba(124, 108, 255, 0.35);
    color: var(--color-text-primary);
    font-size: 13px;
    line-height: 1.4;
}

.login-update button {
    flex: none;
    background: var(--accent-primary);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 12.5px;
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
}

/* CR-29: "Supported brokers" — each broker's logo, in its own colours, on a white tile of one size. */
.login-brokers {
    margin-top: 28px;
    max-width: 460px;   /* the text column's width (.login-sub), so the tiles line up under it */
}
.login-brokers-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}
.login-brokers-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));   /* five fit one row; more flow on evenly */
    gap: 8px;
}
.login-broker-tile {
    height: 44px;
    padding: 7px 9px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.login-broker-tile img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.login-broker-name {
    font-size: 11.5px;
    font-weight: 600;
    color: #1f2937;
    text-align: center;
    line-height: 1.2;
}

/* Form panel (right) */
.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--bg-base);
}

.login-card {
    width: 100%;
    max-width: 380px;
}

.login-card-head {
    margin-bottom: 24px;
}

.login-card-head h2 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 6px;
}

.login-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin: 16px 0 6px;
}

.login-input {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--color-text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.login-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-subtle);
}

.login-error {
    margin-top: 14px;
    padding: 9px 12px;
    border-radius: 9px;
    background: var(--color-danger-subtle);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--color-danger);
    font-size: 13px;
}

.login-submit {
    width: 100%;
    margin-top: 22px;
    background: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-size: 14.5px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background var(--transition-fast), filter var(--transition-fast);
}

.login-submit:hover:not(:disabled) {
    background: var(--accent-primary-hover);
}

.login-submit:disabled {
    opacity: 0.7;
    cursor: default;
}

/* Stack on narrow screens; hide the brand panel on small viewports. */
@media (max-width: 860px) {
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }
}

/* ===========================
   GROUPS PAGE
   =========================== */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.group-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent-primary-subtle);
    color: var(--accent-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.group-tile {
    background: var(--bg-recessed);
    border-radius: 9px;
    padding: 9px 11px;
}

/* ===========================
   SETTINGS PAGE
   =========================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
    max-width: 860px;
}

.settings-card-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

.settings-avatar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.settings-avatar {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2a3350, #1a2138);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: #b9c2da;
    flex: none;
}

.settings-field {
    margin-bottom: 14px;
}

.settings-field label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    font-weight: 600;
    margin-bottom: 5px;
}

.settings-value {
    background: var(--bg-recessed);
    border: 1px solid var(--color-border);
    border-radius: 9px;
    padding: 9px 12px;
    color: var(--color-text-primary);
}

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

/* ===========================
   SIDEBAR (MERIDIAN DEALER TERMINAL)
   =========================== */
.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-sidebar);
}

/* Brand / logo block */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 22px 22px 18px;
}

/* The Meridian mark (Shared/MeridianMark.razor), on its own — no tile. Its M is white on the dark theme and navy on
   the light one; the arrow and the bars keep their teal. */
:root {
    --mrd-m-top: #ffffff;
    --mrd-m-mid: #eef2f8;
    --mrd-m-bottom: #d9e1ee;
}

:root[data-theme="light"] {
    --mrd-m-top: #13579f;
    --mrd-m-mid: #08244e;
    --mrd-m-bottom: #0c3672;
}

.sidebar-logo-mark {
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.meridian-mark { display: block; }

.sidebar-brand {
    line-height: 1;
}

.sidebar-brand .logo-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.04em;
    color: #fff;
}

.sidebar-brand .logo-sub {
    display: block;
    font-size: 9.5px;
    letter-spacing: 0.18em;
    color: #5a6178;
    font-weight: 600;
    margin-top: 3px;
}

.sidebar-logo .logo-icon {
    font-family: var(--font-display);
    font-weight: 700;
    color: #fff;
    font-size: 16px;
}

/* Nav */
.sidebar-nav {
    padding: 0 14px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-section {
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--color-text-faint);
    font-weight: 700;
    padding: 16px 10px 8px;
    text-transform: uppercase;
}

.sidebar-section:first-child {
    padding-top: 6px;
}

/* Links */
.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    cursor: pointer;
    color: #9aa3b8;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 1px;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--color-text-primary);
    text-decoration: none;
}

.sidebar-link .mud-icon-root {
    position: relative;
    font-size: 18px;
    flex: none;
}

.sidebar-link-label {
    position: relative;
    flex: 1;
}

.sidebar-link-active {
    color: var(--color-text-primary);
    background: var(--accent-primary-subtle);
}

.sidebar-link-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 3px;
    background: var(--accent-primary);
}

.sidebar-link-badge {
    position: relative;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    background: var(--color-warning-subtle);
    color: var(--color-warning);
    padding: 1px 6px;
    border-radius: 6px;
}

/* Count badge for pending items (e.g. IP Requests) — expanded rail */
.sidebar-count-badge {
    flex: none;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--color-danger);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Collapsed rail: a dot on the icon instead of a number */
.sidebar-count-dot {
    position: absolute;
    top: 5px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-danger);
    border: 2px solid var(--bg-sidebar);
}

/* Collapsed */
.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 9px 0;
}

/* Footer / user card */
.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.sidebar-user .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.sidebar-user .user-role {
    font-size: 11px;
    color: var(--color-text-muted);
}

/* ===========================
   HEADER BAR (screen title + notifications)
   =========================== */
.app-header {
    height: var(--topbar-height);
    flex: none;
    background: rgba(11, 15, 26, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 26px;
    gap: 18px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.app-header-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.app-header-sub {
    font-size: 12.5px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header-spacer {
    flex: 1;
}

.app-header-bell {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--color-border-strong);
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.app-header-bell:hover {
    color: var(--color-text-primary);
    border-color: rgba(255, 255, 255, 0.16);
}

.app-header-bell-dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-warning);
    border: 2px solid var(--bg-sidebar);
}

/* Logout — the same 38px shell as the icon buttons beside it, widened for its label so the top bar keeps one
   consistent control height. Deliberately NOT styled as a primary or filled danger button: it sits next to
   Place Order on the group desk, and a red block there competes with the action a dealer is actually aiming
   for. Restrained by default, danger-tinted only on hover, so the intent is confirmed at the moment of the
   press rather than shouted the whole time the screen is open. */
.app-header-logout {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 13px;
    border-radius: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--color-border-strong);
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    flex: none;
    white-space: nowrap;
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

/* --color-danger-subtle rather than a color-mix(): the token already exists for exactly this, and it is
   defined per theme, so the tint stays right in light mode instead of being mixed against the wrong ground. */
.app-header-logout:hover:not(:disabled) {
    color: var(--color-danger);
    border-color: var(--color-danger);
    background: var(--color-danger-subtle);
}

.app-header-logout:disabled {
    opacity: .6;
    cursor: default;
}

/* Keyboard parity with the mouse. Without this the button is reachable by Tab and gives no indication it
   has focus, which on the one control that ends the session is the wrong thing to leave to guesswork. */
.app-header-logout:focus-visible {
    outline: 2px solid var(--color-danger);
    outline-offset: 2px;
}

/* Below ~560px the label is dropped and the button collapses to its icon, so a phone header still fits the
   title, theme, bell and logout without wrapping. The accessible name comes from aria-label on the button,
   which is why hiding the text costs nothing to a screen reader. */
@media (max-width: 560px) {
    .app-header-logout {
        width: 38px;
        padding: 0;
        justify-content: center;
        gap: 0;
    }

    .app-header-logout-label {
        display: none;
    }
}

/* =====================================================================
   COLOURFUL THEME ENHANCEMENTS  (design-only; additive, appended last)
   ===================================================================== */

/* Ambient depth behind the whole app */
body {
    background-color: var(--bg-base);
    background-image:
        radial-gradient(900px 480px at 8% -6%, rgba(124, 108, 255, 0.12), transparent 60%),
        radial-gradient(760px 460px at 102% 4%, rgba(34, 211, 238, 0.08), transparent 55%),
        radial-gradient(820px 520px at 60% 108%, rgba(52, 211, 153, 0.07), transparent 55%);
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* Sidebar: subtle vertical depth + brighter brand glow */
.sidebar-inner {
    background:
        linear-gradient(180deg, rgba(124, 108, 255, 0.06), transparent 220px),
        var(--bg-sidebar);
}

/* Colourful nav icons — each item gets its own accent (CSS only, by order).
   Links are <a>; section headings are <div>, so :nth-of-type counts anchors. */
.sidebar-nav a.sidebar-link .mud-icon-root { transition: transform var(--transition-fast); }
.sidebar-nav a.sidebar-link:hover .mud-icon-root { transform: scale(1.12); }

.sidebar-nav a.sidebar-link:nth-of-type(1)  .mud-icon-root { color: #5b8def; } /* Dashboard */
.sidebar-nav a.sidebar-link:nth-of-type(2)  .mud-icon-root { color: #22d3ee; } /* Static IP */
.sidebar-nav a.sidebar-link:nth-of-type(3)  .mud-icon-root { color: #34d399; } /* Demat Accounts */
.sidebar-nav a.sidebar-link:nth-of-type(4)  .mud-icon-root { color: #9d8cff; } /* Groups */
.sidebar-nav a.sidebar-link:nth-of-type(5)  .mud-icon-root { color: #f5a524; } /* Positions */
.sidebar-nav a.sidebar-link:nth-of-type(6)  .mud-icon-root { color: #f472b6; } /* Watchlist */
.sidebar-nav a.sidebar-link:nth-of-type(7)  .mud-icon-root { color: #2dd4bf; } /* Order Manager */
.sidebar-nav a.sidebar-link:nth-of-type(8)  .mud-icon-root { color: #fb923c; } /* Order History */
.sidebar-nav a.sidebar-link:nth-of-type(9)  .mud-icon-root { color: #a78bfa; } /* Activity Log */
.sidebar-nav a.sidebar-link:nth-of-type(10) .mud-icon-root { color: #94a3b8; } /* Settings */
.sidebar-nav a.sidebar-link:nth-of-type(11) .mud-icon-root { color: #f87171; } /* Dealers */

/* Active nav item — glowing gradient pill + gradient accent bar */
.sidebar-link-active {
    background: linear-gradient(90deg, rgba(124, 108, 255, 0.20), rgba(124, 108, 255, 0.06));
    box-shadow: inset 0 0 0 1px rgba(124, 108, 255, 0.22);
}

.sidebar-link-active::before {
    background: linear-gradient(180deg, #9d8cff, #7c6cff);
    box-shadow: 0 0 10px rgba(124, 108, 255, 0.8);
}

/* Table header — subtle gradient sheen */
.meridian-table th {
    background: linear-gradient(180deg, #161e33, var(--bg-elevated));
}

/* Status chips — add a hairline border so colours pop */
.chip { border: 1px solid currentColor; }
.chip-success { border-color: rgba(52, 211, 153, 0.35); }
.chip-danger  { border-color: rgba(248, 113, 113, 0.35); }
.chip-warning { border-color: rgba(245, 165, 36, 0.35); }
.chip-info    { border-color: rgba(124, 108, 255, 0.35); }
.chip-neutral { border-color: rgba(255, 255, 255, 0.10); }

/* Primary / danger buttons — gradient fill + soft glow + hover lift */
.dm-btn-primary {
    background: linear-gradient(135deg, #8b7bff, #6a58f0);
    box-shadow: 0 4px 14px rgba(124, 108, 255, 0.35);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
}
.dm-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #9d8cff, #7c6cff);
    box-shadow: 0 6px 20px rgba(124, 108, 255, 0.5);
    transform: translateY(-1px);
}
.dm-btn-danger {
    background: linear-gradient(135deg, #f2545f, #d9434f);
    box-shadow: 0 4px 14px rgba(217, 67, 79, 0.32);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.dm-btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(217, 67, 79, 0.45);
}

/* Stat / KPI cards — gradient surface, colour accent strip, hover lift */
.stat-card, .card {
    background: linear-gradient(180deg, #131a2b, var(--bg-surface));
    transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}
.stat-card {
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, #9d8cff, #22d3ee);
}
.stat-card:hover, .card:hover {
    transform: translateY(-2px);
    border-color: rgba(124, 108, 255, 0.28);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

/* Inputs — accent focus glow */
.dm-input:focus, .dm-select:focus, .grid-filter-input:focus {
    box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.22);
}

/* Scrollbar thumb — brand-tinted */
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #3a3570, #2a2f52);
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4a43a0, #363c6b);
}

/* Top header — faint gradient underlay */
.app-header {
    background:
        linear-gradient(90deg, rgba(124, 108, 255, 0.06), transparent 40%),
        rgba(11, 15, 26, 0.85);
}

/* =====================================================================
   GRID VISIBILITY / HIGHLIGHT  (design-only)
   ===================================================================== */

/* Framed, elevated table with an accent hairline */
.table-container {
    border: 1px solid rgba(124, 108, 255, 0.16);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    background:
        linear-gradient(180deg, rgba(124, 108, 255, 0.05), transparent 90px),
        var(--bg-surface);
}

/* Louder, accent-tinted header row */
.meridian-table thead th {
    color: #c7ccff;
    font-weight: 700;
    font-size: 11.5px;
    letter-spacing: 0.07em;
    background: linear-gradient(180deg, #1a2440, #131a2e);
    border-bottom: 2px solid rgba(124, 108, 255, 0.38);
}

/* Zebra striping so rows are easy to scan */
.meridian-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.018);
}

/* Clear, colourful row hover with a left accent edge */
.meridian-table tbody tr:hover td {
    background: rgba(124, 108, 255, 0.12);
}
.meridian-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--accent-primary);
}

/* Slightly stronger row separators */
.meridian-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Sorted column: tint the whole column header cell for visibility */
.meridian-table th.sorted {
    background: linear-gradient(180deg, rgba(124, 108, 255, 0.22), rgba(124, 108, 255, 0.10));
    color: #fff;
}

/* Pagination footer picks up the accent frame */
.table-pagination {
    border-top: 1px solid rgba(124, 108, 255, 0.16);
}

/* KPI value numbers in a lively accent-gradient (dashboard/detail tiles use .stat-card-value) */
.stat-card-value {
    background: linear-gradient(135deg, #c7ccff, #8b7bff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── Unhandled-error banner ───────────────────────────────────────────────────
   Blazor toggles #blazor-error-ui to visible when an exception escapes a
   component. Hidden by default; styled dark to match the app rather than the
   default template's lightyellow strip. */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    padding: 12px 20px;
    background: #2a1216;
    border-top: 1px solid #f87171;
    color: #ffd9dd;
    font-size: 13.5px;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, .45);
}

#blazor-error-ui .reload {
    margin-left: 14px;
    color: #fff;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

#blazor-error-ui .dismiss {
    float: right;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: #ffd9dd;
}

/* =====================================================================
   SIDEBAR — COLLAPSED (icon-rail) FIXES
   In the 56px collapsed rail the logo block (padding 22px + 34px mark)
   and the two footer icon buttons in a row were both wider than the rail
   — which forced a horizontal scrollbar and shoved content off-centre.
   Contain the overflow, and centre / stack instead of overflowing.
   ===================================================================== */
.sidebar-inner,
.sidebar-nav {
    overflow-x: hidden;
}

.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    padding: 20px 0 16px;
}

.sidebar-collapsed .sidebar-nav {
    padding: 0 8px;
}

.sidebar-collapsed .sidebar-footer {
    flex-direction: column;
    gap: 8px;
    padding: 12px 6px;
}

/* =====================================================================
   HEADER NOTIFICATIONS PANEL (bell dropdown)
   ===================================================================== */
.notif-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 340px;
    max-width: 86vw;
    background: var(--bg-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 50;
    overflow: hidden;
}

.notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-primary);
}

.notif-clear {
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 6px;
}

.notif-clear:hover {
    color: var(--color-text-primary);
    background: var(--bg-elevated);
}

.notif-list {
    max-height: 360px;
    overflow-y: auto;
}

.notif-empty {
    padding: 28px 18px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.notif-item {
    display: flex;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--color-border-subtle);
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 5px;
    flex: none;
}

.notif-msg {
    font-size: 13px;
    color: var(--color-text-primary);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.notif-time {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 3px;
}

/* =====================================================================
   LIGHT THEME
   The whole UI is driven by the design tokens at the top of this file, so
   flipping their values under :root[data-theme="light"] re-themes every
   class-based surface (sidebar, header, cards, tables, modals, inputs…).
   The override block that follows fixes the handful of rules that hardcode
   dark hex/gradients (mostly the "colourful enhancements") which a token
   swap alone can't reach. The data-theme attribute is set on <html> in
   index.html before first paint.
   ===================================================================== */
:root[data-theme="light"] {
    --bg-base: #eef1f7;
    --bg-sidebar: #ffffff;
    --bg-surface: #ffffff;
    --bg-recessed: #f2f4f9;
    --bg-elevated: #e8ecf4;

    --accent-primary: #6d5cf0;
    --accent-primary-hover: #5b46e6;
    --accent-primary-light: #6d5cf0;
    --accent-primary-subtle: rgba(109, 92, 240, 0.10);

    --color-success: #0f9463;
    --color-success-subtle: rgba(15, 148, 99, 0.12);
    --color-warning: #b7791f;
    --color-warning-subtle: rgba(183, 121, 31, 0.14);
    --color-danger: #dc2626;
    --color-danger-solid: #dc2626;
    --color-danger-subtle: rgba(220, 38, 38, 0.10);
    --color-info: #2563eb;
    --color-buy: #128a4e;

    --color-text-primary: #1a2033;
    --color-text-secondary: #566079;
    --color-text-muted: #7b8499;
    --color-text-faint: #98a1b5;

    --color-border: rgba(15, 23, 42, 0.10);
    --color-border-subtle: rgba(15, 23, 42, 0.06);
    --color-border-strong: rgba(15, 23, 42, 0.16);

    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.12);

    color-scheme: light;
}

/* ---- Overrides for rules that hardcode dark values ---- */

/* Ambient page wash — soft coloured tints over a light base instead of the dark version. */
:root[data-theme="light"] body {
    background-image:
        radial-gradient(900px 480px at 8% -6%, rgba(124, 108, 255, 0.10), transparent 60%),
        radial-gradient(760px 460px at 102% 4%, rgba(34, 211, 238, 0.08), transparent 55%),
        radial-gradient(820px 520px at 60% 108%, rgba(52, 211, 153, 0.07), transparent 55%);
}

/* Sidebar links + brand text (were tuned for a dark rail) */
:root[data-theme="light"] .sidebar-link { color: var(--color-text-secondary); }
:root[data-theme="light"] .sidebar-brand .logo-text,
:root[data-theme="light"] .sidebar-logo .logo-icon { color: var(--color-text-primary); }

/* Header bar — was a translucent near-black; make it translucent white */
:root[data-theme="light"] .app-header {
    background:
        linear-gradient(90deg, rgba(124, 108, 255, 0.06), transparent 40%),
        rgba(255, 255, 255, 0.85);
}
:root[data-theme="light"] .app-header-title { color: var(--color-text-primary); }

/* Cards / stat tiles — kill the dark-topped gradient, use a flat surface */
:root[data-theme="light"] .stat-card,
:root[data-theme="light"] .card {
    background: var(--bg-surface);
}

/* KPI numbers used a very light gradient clipped to text — invisible on white */
:root[data-theme="light"] .stat-card-value {
    background: none;
    -webkit-text-fill-color: var(--color-text-primary);
    color: var(--color-text-primary);
}

/* Tables — dark gradient header + frame → light surface */
:root[data-theme="light"] .table-container {
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
}
:root[data-theme="light"] .meridian-table th,
:root[data-theme="light"] .meridian-table thead th {
    background: var(--bg-elevated);
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border-strong);
}
:root[data-theme="light"] .meridian-table th.sorted {
    background: linear-gradient(180deg, rgba(109, 92, 240, 0.16), rgba(109, 92, 240, 0.08));
    color: var(--accent-primary);
}
:root[data-theme="light"] .meridian-table td {
    border-bottom: 1px solid var(--color-border-subtle);
}
:root[data-theme="light"] .meridian-table tbody tr:nth-child(even) td {
    background: rgba(15, 23, 42, 0.025);
}
:root[data-theme="light"] .meridian-table tbody tr:hover td {
    background: rgba(109, 92, 240, 0.10);
}

/* Skeleton shimmer + scrollbar were dark-on-dark */
:root[data-theme="light"] .skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, #d8deea 50%, var(--bg-elevated) 75%);
    background-size: 800px 100%;
}
:root[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #c4cbdb;
}
:root[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: #aeb7cb;
}

/* Login — the form/brand panels flip to light, so their white text needs darkening */
:root[data-theme="light"] .login-headline,
:root[data-theme="light"] .login-card-head h2 {
    color: var(--color-text-primary);
}

/* Settings avatar tile was a dark gradient */
:root[data-theme="light"] .settings-avatar {
    background: linear-gradient(135deg, #e6e9f5, #d3d9ec);
    color: var(--accent-primary);
}

/* Native date picker chrome should match the theme (was forced dark inline) */
:root[data-theme="light"] input[type="date"] {
    color-scheme: light;
}

/* =====================================================================
   MARKET INDEX RIBBON (top of shell — Nifty, Sensex, sectoral, …)
   ===================================================================== */
.indices-bar {
    display: flex;
    align-items: center;
    height: 40px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--color-border);
    overflow: hidden;
    white-space: nowrap;
}

/* Continuously scrolling ticker tape. The track holds two identical copies, so animating it
   from 0 to -50% moves exactly one copy width and loops with no visible seam. */
.indices-track {
    display: inline-flex;
    align-items: center;
    flex: none;
    animation: indices-scroll 35s linear infinite;
    will-change: transform;
}

.indices-bar:hover .indices-track {
    animation-play-state: paused;   /* pause so a dealer can read a value */
}

.indices-copy {
    display: inline-flex;
    align-items: center;
}

@keyframes indices-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    .indices-track { animation: none; }
    .indices-bar { overflow-x: auto; }   /* let it be scrolled by hand instead */
}

.index-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    margin-right: 24px;             /* spacing lives on the chip so the two copies tile seamlessly */
    flex: none;
}

.index-name {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--color-text-secondary);
    letter-spacing: 0.02em;
}

.index-ltp {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.index-chg {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
}

/* ── Login bot challenge (CR-17) ───────────────────────────────────────────── */

/* Written against the app's OWN tokens. These rules previously named --border-default, --border-strong,
   --text-primary and --text-secondary, none of which are defined anywhere in this file, so every one of them
   silently took its hardcoded light-mode fallback: #1f2933 label text and white tiles inside a card that is
   #0f1422 in the default palette. The captcha was styled for a light app living inside a dark one. */

.captcha-gate {
    margin-top: 16px;
}

/* Matches .login-label exactly — the gate is a field the dealer must complete, and it is labelled like one
   rather than appearing unannounced in the gap above the button. */
.captcha-field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin: 0 0 6px;
}

/* Google's widget is a fixed 304px inside an iframe: it cannot be widened or restyled from out here, so the
   slot carries the alignment instead. Full card width, so the block lines up with the inputs above it;
   centred, so the 76px the widget does not use is split evenly rather than left as a hole down one side; and
   tall enough for the widget before it loads, so nothing below it jumps when it arrives. */
.captcha-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 98px;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--bg-recessed);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

/* Meridian's own confirmation around Google's tick. The tick lives inside the iframe, so without this the
   only signal that the gate is passed is 16px of green the page cannot see or reach. */
.captcha-slot.is-verified {
    border-color: var(--color-success);
    background: var(--color-success-subtle);
}

.captcha-google {
    display: flex;
    justify-content: center;
    max-width: 100%;
}

.captcha-google iframe {
    max-width: 100%;
}

/* Occupies the reserved slot until the widget exists. Google's script is a cross-origin fetch that can take a
   moment on a cold browser, and an empty box beside a disabled Sign In button reads as a broken page. */
.captcha-google-wait {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font-size: 12.5px;
    color: var(--color-text-secondary);
    pointer-events: none;
}

/* ── Built-in challenge (used when the server reports provider "builtin") ───── */

/* Deliberately the same shape as .login-input, so on a deployment running the built-in challenge the row
   belongs to the same form as the two boxes above it. */
.captcha-check-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 13px;
    border: 1px solid var(--color-border-strong);
    border-radius: 10px;
    background: var(--bg-surface);
    cursor: pointer;
    user-select: none;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.captcha-check-row:hover {
    border-color: var(--accent-primary);
}

.captcha-check-row:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.captcha-check-row.is-verified {
    border-color: var(--color-success);
    background: var(--color-success-subtle);
    cursor: default;
}

.captcha-box {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-border-strong);
    border-radius: 4px;
    background: var(--bg-base);
}

/* The tick itself is stroke="currentColor", so it follows this rather than one fixed green that only suited
   the light palette. */
.captcha-check-row.is-verified .captcha-box {
    border-color: var(--color-success);
    color: var(--color-success);
}

.captcha-label {
    font-size: 13.5px;
    color: var(--color-text-primary);
}

.captcha-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid var(--color-border-strong);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: captcha-spin 0.7s linear infinite;
}

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

.captcha-panel {
    margin-top: 10px;
    padding: 13px;
    border: 1px solid var(--color-border-strong);
    border-radius: 10px;
    background: var(--bg-surface);
}

.captcha-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.captcha-prompt {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.captcha-refresh {
    border: 1px solid var(--color-border-strong);
    background: var(--bg-elevated);
    border-radius: 7px;
    width: 26px;
    height: 26px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: border-color var(--transition-fast), color var(--transition-fast);
}

.captcha-refresh:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* The tiles arrive as opaque near-white plates baked into the PNG, so they read the same on either palette —
   this only frames them. */
.captcha-reference {
    padding: 7px;
    border: 1px dashed var(--color-border-strong);
    border-radius: 8px;
    background: var(--bg-recessed);
    text-align: center;
    margin-bottom: 11px;
}

.captcha-reference img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Three across. Six square tiles read as a picture board rather than a list of rows, which is the whole
   point of matching one image instead of comparing sequences of small shapes. */
.captcha-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.captcha-option {
    padding: 6px;
    border: 1px solid var(--color-border-strong);
    border-radius: 8px;
    background: var(--bg-recessed);
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.captcha-option:hover:not(:disabled) {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-subtle);
}

.captcha-option:disabled {
    opacity: 0.55;
    cursor: default;
}

.captcha-option img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* One column for the options where the card itself is narrow, so the patterns stay readable. */
@media (max-width: 420px) {
    .captcha-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Messages ──────────────────────────────────────────────────────────────── */

/* Shaped like .login-error, because the two stack directly on top of each other when a sign-in fails and two
   different shapes of red would read as two different kinds of problem.

   Split by tone. An expired token is not a failure — reCAPTCHA retires one about every two minutes whether
   or not anything is wrong, and a dealer who types their password slowly will meet it on a perfectly healthy
   system. Colouring that the same red as "could not reach Google" sends them to check their network. */
.captcha-message {
    margin-top: 10px;
    padding: 8px 11px;
    border-radius: 9px;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.captcha-message.is-error {
    background: var(--color-danger-subtle);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--color-danger);
}

.captcha-message.is-notice {
    background: var(--color-warning-subtle);
    border: 1px solid rgba(245, 165, 36, 0.32);
    color: var(--color-warning);
}

.captcha-message-icon {
    flex: none;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 1px solid currentColor;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
}

/* Recovery without losing the typed password. A cold start can fail the first challenge fetch, and
   "refresh the page" is a poor answer when the form is already filled in. */
.captcha-retry {
    margin-left: auto;
    border: 1px solid currentColor;
    background: transparent;
    border-radius: 7px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    color: inherit;
    transition: background var(--transition-fast);
}

.captcha-retry:hover:not(:disabled) {
    background: var(--bg-elevated);
}

.captcha-retry:disabled {
    opacity: 0.6;
    cursor: default;
}

/* CR-38 (simple PWA): "You are offline" covers the whole app while the server cannot be reached
   (ConnectivityBanner, rendered in App.razor). Nothing from before is shown; it reloads when back. */
.offline-screen {
    position: fixed;
    inset: 0;
    z-index: 7000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-base);
}

.offline-screen-card {
    max-width: 380px;
    text-align: center;
    color: var(--color-text-secondary);
}

.offline-screen-title {
    margin: 12px 0 8px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.offline-screen-text {
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.55;
}

.offline-screen-retry {
    min-width: 160px;
    min-height: 44px;
    padding: 0 22px;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* ===========================
   INDEX VIEW (item 36, 30 Oct 2026)
   The header's live indices (Nifty 50, Sensex, Nifty Bank) and the floating Index View panel. Up is the app's green,
   down its red; a value the feed is not streaming is dimmed and says so on hover.
   =========================== */
/* On the right, beside the buttons ("in header show indices from right alignment"). One row of a fixed height: an index
   that does not fit beside the title wraps to a second row, which is hidden, so a whole index goes rather than part of
   one (Nifty Bank first, then Sensex). It gives way before the title (flex-shrink 1000 against the title's 1), but never
   below its widest index (min-content), so Nifty 50 — first, and so never wrapped — always shows; a long subtitle ends
   in "…" instead. */
.mrd-header-indices {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    height: 28px;
    flex: 0 1000 auto;
    min-width: min-content;
    overflow: hidden;
}

.mrd-header-index {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    box-sizing: border-box;
    padding: 0 10px;
    border-radius: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--color-border);
    font-size: 12px;
    white-space: nowrap;
}

.mrd-header-index-name {
    color: var(--color-text-secondary);
    font-weight: 600;
}

.mrd-header-index-value {
    color: var(--color-text-primary);
    font-family: var(--font-num);
    font-weight: 700;
}

.mrd-index-move {
    font-family: var(--font-num);
    font-weight: 600;
}
.mrd-index-move-short { display: none; }   /* a phone's: the % alone (responsive.css) */
.mrd-index-move.up   { color: var(--color-success); }
.mrd-index-move.down { color: var(--color-danger); }
.mrd-index-move.flat { color: var(--color-text-secondary); }

.mrd-header-index.stale,
.mrd-index-view-table tr.stale { opacity: 0.55; }

/* On a tablet or phone, Nifty 50 and Nifty Bank go in a strip under the title row (responsive.css, section 4). */

/* The panel: fixed, bottom right by default; js/indexview.js moves it and remembers where. Above the page and the
   header; below dialogs, menus and toasts, and on a tablet or phone below the side menu and the phone bar. No margin:
   the script places it by left / top, and a margin (MudBlazor gives one beside the sidebar) would put it that far from
   where it was dropped. */
.mrd-index-view {
    position: fixed;
    right: 16px;
    bottom: 16px;
    margin: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    width: 340px;
    min-width: 230px;
    max-width: calc(100vw - 16px);
    min-height: 36px;
    max-height: calc(100vh - 16px);
    overflow: hidden;
    resize: both;
    background: var(--bg-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

.mrd-index-view.minimised {
    width: auto !important;
    min-width: 0;
    height: auto !important;
    resize: none;
}

.mrd-index-view-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex: none;
    height: 36px;
    padding: 0 6px 0 12px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--color-border);
    cursor: move;
    touch-action: none;
    user-select: none;
}
.mrd-index-view.minimised .mrd-index-view-head { border-bottom: none; }

.mrd-index-view-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-text-primary);
}

.mrd-index-view-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
}
.mrd-index-view-toggle:hover { background: var(--bg-recessed); color: var(--color-text-primary); }

.mrd-index-view-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.mrd-index-view-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}
.mrd-index-view-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.mrd-index-view-table tr:last-child td { border-bottom: none; }

.mrd-index-view-name {
    font-weight: 600;
    color: var(--color-text-primary);
}

.mrd-index-view-value { text-align: right; }
.mrd-index-view-value span { font-weight: 500; }

.mrd-index-view-arrow {
    width: 18px;
    text-align: center;
}

/* A wide screen keeps the side menu open beside the page (MudBlazor's drawer, layer 1100): the panel goes over it, not
   under it, when dragged to the left. Still below MudBlazor's menus (1200) and dialogs (1400), the app's dialogs (2000)
   and toasts. Up to 1024 px the side menu opens over the page (1300) and stays above the panel. */
@media (min-width: 1025px) {
    .mrd-index-view { z-index: 1150; }
}

/* A phone: above the bottom bar, and narrower. */
@media (max-width: 640px) {
    .mrd-index-view {
        right: 8px;
        bottom: calc(var(--mrd-phone-nav-h, 58px) + env(safe-area-inset-bottom, 0px) + 8px);
        width: calc(100vw - 16px);
    }
}
