/*============================================
   MEANX — Fintech SaaS Design System
   Linear / Vercel / Stripe dashboard quality
   ============================================ */

/* ---------- 1. Design Tokens ---------- */
:root {
    /* Backgrounds — deep navy-black */
    --bg: #080b11;
    --bg-2: #0a0e14;
    --surface-1: #0d1117;
    --surface-2: #11161f;
    --surface-3: #161c28;
    --surface-hover: #1a2230;

    /* Cards */
    --card: #0d1117;
    --card-2: #11161f;
    --card-elevated: #141b27;

    /* Borders */
    --border: #1c2330;
    --border-strong: #2a3344;
    --border-hover: #354155;
    --border-subtle: rgba(255, 255, 255, 0.04);

    /* Text */
    --text: #e6edf3;
    --text-dim: #9ba8b8;
    --text-muted: #5c6670;
    --text-bright: #ffffff;

    /* Accents — refined palette */
    --blue: #3b82f6;
    --blue-bright: #60a5fa;
    --green: #10b981;
    --green-bright: #34d399;
    --red: #ef4444;
    --red-bright: #f87171;
    --orange: #f59e0b;
    --orange-bright: #fbbf24;
    --purple: #a855f7;
    --teal: #14b8a6;
    --pink: #ec4899;

    /* Glow tokens */
    --glow-blue: rgba(59, 130, 246, 0.18);
    --glow-green: rgba(16, 185, 129, 0.18);
    --glow-red: rgba(239, 68, 68, 0.18);
    --glow-orange: rgba(245, 158, 11, 0.18);
    --glow-purple: rgba(168, 85, 247, 0.18);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'SF Mono', monospace;

    /* Radii */
    --radius: 14px;
    --radius-md: 10px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --radius-pill: 999px;

    /* Motion */
    --transition: 0.15s ease;
    --transition-slow: 0.25s ease;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
    --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.55);
    --shadow-glow-blue: 0 0 0 3px var(--glow-blue);

    /* Layout */
    --navbar-h: 60px;
    --content-max: 1480px;
}

/* ---------- 2. Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

* {
    transition: all 0.15s ease;
}

html {
    font-size: 14px;
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(59, 130, 246, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(168, 85, 247, 0.04) 0%, transparent 50%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'ss01';
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--blue-bright);
    text-decoration: none;
}

a:hover {
    color: var(--blue);
}

/* ---------- 3. Typography Hierarchy ---------- */
h1,
.display {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-bright);
}

h2,
.section-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--text-bright);
}

h3,
.card-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}

h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

body,
.body {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
}

.caption,
.label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    letter-spacing: 0.01em;
}

.eyebrow {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.text-mono,
.mono {
    font-family: var(--font-mono);
    font-feature-settings: 'tnum' 1;
    font-variant-numeric: tabular-nums;
}

/* ---------- 4. Navbar ---------- */
.navbar {
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: var(--navbar-h);
    background: rgba(8, 11, 17, 0.72);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 1000;
    gap: 20px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 100%);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 17px;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.logo-text {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-bright);
    letter-spacing: -0.01em;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--text-dim);
    margin-left: 4px;
    font-weight: 500;
}

.navbar-tabs {
    display: flex;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}

.navbar-tabs::-webkit-scrollbar {
    display: none;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
    position: relative;
}

.nav-tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}

.nav-tab.active {
    color: var(--blue-bright);
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.25);
    box-shadow: inset 0 -2px 0 var(--blue), 0 0 12px rgba(59, 130, 246, 0.15);
}

.tab-icon {
    font-size: 15px;
    line-height: 1;
}

.navbar-end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Live connection indicator */
.live-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
}

.live-status .status-label {
    color: var(--text);
    font-weight: 500;
}

/* User avatar */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.user-avatar:hover {
    box-shadow: 0 0 0 3px var(--glow-blue);
}

/* ---------- 5. Status Indicators ---------- */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.status-dot.live {
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background: var(--red);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    animation: pulse 1.5s infinite;
}

.status-dot.warning {
    background: var(--orange);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5);
    animation: pulse 2s infinite;
}

/* ---------- 6. Main Content ---------- */
.main-content {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 24px;
    min-height: calc(100vh - var(--navbar-h));
}

/* Page header */
.page-header {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-bright);
}

.page-desc {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
}

/* ---------- 7. Cards ---------- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025) 0%, transparent 100%),
        linear-gradient(135deg, var(--card) 0%, var(--card-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    padding: 1px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 50%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.6;
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card:active {
    transform: scale(0.99);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 8px;
}

.card-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 500;
}

.card-body {
    position: relative;
}

.card-footer {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Value boxes (KPI tiles) */
.value-box {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%),
        var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}

.value-box:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.value-box-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.value-box-value {
    font-size: 28px;
    font-weight: 700;
    margin: 6px 0 2px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--text-bright);
    letter-spacing: -0.02em;
}

.value-box-delta {
    font-size: 12px;
    font-family: var(--font-mono);
    font-weight: 500;
}

.value-box-delta.positive {
    color: var(--green-bright);
}

.value-box-delta.negative {
    color: var(--red-bright);
}

/* ---------- 8. Skeleton Loaders ---------- */
.skeleton {
    background: linear-gradient(90deg,
        var(--surface-1) 0%,
        var(--surface-2) 50%,
        var(--surface-1) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-xs);
    display: block;
}

.skeleton-line {
    height: 12px;
    margin-bottom: 8px;
    border-radius: var(--radius-xs);
}

.skeleton-line:last-child {
    margin-bottom: 0;
    width: 70%;
}

.skeleton-line.title {
    height: 18px;
    width: 45%;
    margin-bottom: 14px;
}

.skeleton-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    background: var(--card);
}

.skeleton-card .skeleton-line {
    margin-bottom: 10px;
}

.skeleton-block {
    height: 80px;
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

.skeleton-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-block;
}

.skeleton-sparkline {
    height: 40px;
    border-radius: var(--radius-xs);
}

/* Legacy loading (kept for compat) */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: var(--text-dim);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

.loading-cell {
    text-align: center;
    padding: 32px !important;
}

/* ---------- 9. Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    user-select: none;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--glow-blue);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.1) inset,
        0 2px 4px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.15) inset,
        0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

.btn-secondary:active {
    transform: translateY(1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-dim);
    border-color: var(--border);
}

.btn-outline:hover {
    color: var(--text);
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.02);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 2px 4px rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-danger:active {
    transform: translateY(1px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 2px 4px rgba(5, 150, 105, 0.3);
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-success:active {
    transform: translateY(1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border-color: transparent;
}

.btn-ghost:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.btn-sm {
    padding: 5px 11px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn-icon {
    padding: 8px;
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
}

/* ---------- 10. Form Elements ---------- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.form-input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-sans);
}

.form-input:hover {
    border-color: var(--border-hover);
}

.form-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--glow-blue), 0 0 20px rgba(59, 130, 246, 0.1);
    background: var(--bg-2);
}

.form-input-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.form-range {
    width: 100%;
    accent-color: var(--blue);
    height: 4px;
}

.form-select {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}

.form-select:hover {
    border-color: var(--border-hover);
}

.form-select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--glow-blue);
}

/* Segmented controls */
.mode-switcher,
.market-selector-bar,
.scanner-mode-bar {
    display: inline-flex;
    gap: 2px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
}

.mode-btn,
.market-btn,
.scanner-btn {
    padding: 7px 16px;
    border-radius: calc(var(--radius) - 4px);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-sans);
}

.mode-btn:hover,
.market-btn:hover,
.scanner-btn:hover {
    color: var(--text);
}

.mode-btn.active,
.market-btn.active,
.scanner-btn.active {
    background: var(--surface-3);
    color: var(--blue-bright);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.3),
        inset 0 0 0 1px rgba(59, 130, 246, 0.2);
}

/* ---------- 11. Data Tables ---------- */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
        var(--card);
}

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

.data-table th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border-strong);
    background: var(--surface-1);
    position: sticky;
    top: 0;
    z-index: 2;
    backdrop-filter: blur(8px);
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    color: var(--text);
}

.data-table th.sortable::after {
    content: '↕';
    margin-left: 6px;
    opacity: 0.35;
    font-size: 11px;
}

.data-table th.sortable.sort-asc::after {
    content: '↑';
    opacity: 1;
    color: var(--blue-bright);
}

.data-table th.sortable.sort-desc::after {
    content: '↓';
    opacity: 1;
    color: var(--blue-bright);
}

.data-table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.012);
}

.data-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

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

.data-table .text-mono,
.data-table .mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* Color-coded cells */
.cell-positive {
    color: var(--green-bright);
    font-weight: 500;
}

.cell-negative {
    color: var(--red-bright);
    font-weight: 500;
}

.cell-neutral {
    color: var(--text-dim);
}

/* Heatmap intensity cells */
.cell-heat-1 {
    background: rgba(16, 185, 129, 0.08);
    color: var(--green-bright);
}
.cell-heat-2 {
    background: rgba(16, 185, 129, 0.16);
    color: var(--green-bright);
}
.cell-heat-3 {
    background: rgba(16, 185, 129, 0.24);
    color: var(--green-bright);
    font-weight: 600;
}
.cell-heat-4 {
    background: rgba(239, 68, 68, 0.16);
    color: var(--red-bright);
}
.cell-heat-5 {
    background: rgba(239, 68, 68, 0.28);
    color: var(--red-bright);
    font-weight: 600;
}

.cell-heat-1-neg { background: rgba(239, 68, 68, 0.08); color: var(--red-bright); }
.cell-heat-2-neg { background: rgba(239, 68, 68, 0.16); color: var(--red-bright); }

/* ---------- 12. Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
}

.badge-blue {
    background: rgba(59, 130, 246, 0.12);
    color: var(--blue-bright);
    border-color: rgba(59, 130, 246, 0.25);
}
.badge-green {
    background: rgba(16, 185, 129, 0.12);
    color: var(--green-bright);
    border-color: rgba(16, 185, 129, 0.25);
}
.badge-red {
    background: rgba(239, 68, 68, 0.12);
    color: var(--red-bright);
    border-color: rgba(239, 68, 68, 0.25);
}
.badge-orange {
    background: rgba(245, 158, 11, 0.12);
    color: var(--orange-bright);
    border-color: rgba(245, 158, 11, 0.25);
}
.badge-purple {
    background: rgba(168, 85, 247, 0.12);
    color: var(--purple);
    border-color: rgba(168, 85, 247, 0.25);
}
.badge-gray {
    background: rgba(155, 168, 184, 0.08);
    color: var(--text-dim);
    border-color: var(--border);
}

/* ---------- 13. Modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
}

.modal-content {
    position: relative;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 80px),
        var(--card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 440px;
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    box-shadow: var(--shadow-xl), 0 0 40px rgba(0, 0, 0, 0.4);
    animation: scaleIn 0.2s ease;
    margin: auto;
}

body.modal-open {
    overflow: hidden;
}

.modal-lg {
    max-width: 560px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-bright);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    color: var(--text-dim);
    font-size: 22px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

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

.modal-body {
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* ---------- 14. Toast ---------- */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 14px 18px;
    font-size: 13px;
    min-width: 280px;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
}

.toast::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background: var(--blue);
    animation: toast-progress 4s linear forwards;
    transform-origin: left;
}

.toast.success {
    border-color: rgba(16, 185, 129, 0.4);
}
.toast.success::before {
    background: var(--green);
}
.toast.success::after {
    background: var(--green);
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.4);
}
.toast.error::before {
    background: var(--red);
}
.toast.error::after {
    background: var(--red);
}

.toast.info::before {
    background: var(--blue);
}

/* ---------- 15. Signals Page ---------- */
.signals-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.signals-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    padding: 20px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
        linear-gradient(135deg, var(--card) 0%, var(--card-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.dashboard-stat {
    text-align: center;
    padding: 8px 12px;
}

.dashboard-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.dashboard-stat-value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 6px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--text-bright);
}

.dashboard-stat-sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}

.signals-mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.signal-filters {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: var(--text-dim);
    flex-wrap: wrap;
}

.filter-check {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.filter-check input[type='checkbox'] {
    accent-color: var(--blue);
    cursor: pointer;
}

.filter-slider {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- 16. Signal Cards (redesigned) ---------- */
.signal-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
        linear-gradient(135deg, var(--card) 0%, var(--card-2) 100%);
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);
    border-radius: var(--radius);
    padding: 18px;
    position: relative;
    overflow: hidden;
}

.signal-card.long_a,
.signal-card.long {
    border-left-color: var(--green);
}

.signal-card.short_a,
.signal-card.short {
    border-left-color: var(--orange);
}

.signal-card.wait {
    border-left-color: var(--text-muted);
}

.signal-card:hover {
    border-color: var(--border-hover);
    border-left-color: var(--blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.signal-card.long_a:hover,
.signal-card.long:hover {
    border-left-color: var(--green);
}

.signal-card.short_a:hover,
.signal-card.short:hover {
    border-left-color: var(--orange);
}

.signal-card:active {
    transform: scale(0.99);
}

.signal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 8px;
}

.signal-ticker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ticker-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
    border: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: var(--text);
    flex-shrink: 0;
}

.signal-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-bright);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.signal-name.short_a,
.signal-name.short {
    color: var(--orange-bright);
}
.signal-name.long_a,
.signal-name.long {
    color: var(--green-bright);
}
.signal-name.wait {
    color: var(--text-dim);
}

/* Sparkline top */
.signal-sparkline {
    height: 40px;
    margin: 4px 0 12px;
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.signal-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.signal-stat {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.signal-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.signal-stat-value {
    font-size: 14px;
    font-family: var(--font-mono);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
    color: var(--text-bright);
}

.fav-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-dim);
    font-size: 15px;
}

.fav-btn:hover {
    border-color: var(--orange);
    color: var(--orange);
    background: var(--surface-3);
}

.fav-btn.favorited {
    color: var(--orange-bright);
    border-color: var(--orange);
    background: rgba(245, 158, 11, 0.1);
}

/* Inline fav button (in table rows) */
.fav-btn-inline {
    display: inline-flex;
    position: static;
    width: 24px;
    height: 24px;
    margin-right: 6px;
    vertical-align: middle;
    font-size: 14px;
    background: transparent;
    border: none;
    padding: 0;
}

/* ---------- 17. Sparkline Container ---------- */
.sparkline-container {
    height: 40px;
    width: 100%;
    background: transparent;
    border: none;
    padding: 0;
    display: block;
    overflow: hidden;
}

.sparkline-container svg {
    display: block;
    width: 100%;
    height: 100%;
}

.sparkline-up {
    color: var(--green-bright);
}
.sparkline-down {
    color: var(--red-bright);
}

/* ---------- 18. P&L Calculator Block ---------- */
.calc-block {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-top: 12px;
}

.calc-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.calc-block-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.calc-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.calc-field {
}

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

.calc-field input {
    width: 100%;
    padding: 7px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.calc-field input:hover {
    border-color: var(--border-hover);
}

.calc-field input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--glow-blue), 0 0 16px rgba(59, 130, 246, 0.15);
}

.calc-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 12px 0;
}

.calc-value {
    font-size: 15px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.calc-value.positive {
    color: var(--green-bright);
}
.calc-value.negative {
    color: var(--red-bright);
}
.calc-value.neutral {
    color: var(--text);
}

.calc-result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.calc-result-label {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 500;
}

/* Calculator settings bar */
.calc-settings-bar {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
        var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.calc-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

.range-value {
    font-size: 12px;
    color: var(--blue-bright);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ---------- 19. Charts ---------- */
.chart-container {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
        var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-top: 12px;
    min-height: 300px;
}

/* ---------- 20. Page Layout ---------- */
.tab-page {
    animation: fadeInUp 0.3s ease;
}

.section {
    margin-bottom: 24px;
}

.section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-dim);
}

.pair-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-dim);
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* AI result */
.ai-result {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
        var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-top: 16px;
    min-height: 200px;
}

.ai-result pre {
    white-space: pre-wrap;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.65;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* ---------- 21. Favorites / Position Cards ---------- */
.position-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
        var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 12px;
}

.position-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.position-pnl {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.position-pnl.positive {
    color: var(--green-bright);
}
.position-pnl.negative {
    color: var(--red-bright);
}

.position-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    font-size: 12px;
    color: var(--text-dim);
}

.position-details span {
    color: var(--text);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* ---------- 22. Onboarding ---------- */
.onboarding-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--navbar-h));
    padding: 24px;
}

.onboarding-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 120px),
        linear-gradient(135deg, var(--card), var(--card-2));
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 540px;
    width: 100%;
    box-shadow: var(--shadow-xl);
}

.onboarding-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 32px;
}

.step {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-dim);
}

.step.active {
    background: linear-gradient(135deg, var(--blue), #2563eb);
    border-color: var(--blue);
    color: white;
    box-shadow: 0 0 0 4px var(--glow-blue);
}

.step.completed {
    background: var(--green);
    border-color: var(--green);
    color: white;
}

.step-line {
    width: 60px;
    height: 2px;
    background: var(--border);
}

.step-line.completed {
    background: var(--green);
}

.onboarding-step {
    display: none;
    text-align: center;
}

.onboarding-step.active {
    display: block;
    animation: fadeInUp 0.3s ease;
}

.onboarding-step h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-bright);
}

.onboarding-step p {
    color: var(--text-dim);
    margin-bottom: 16px;
    line-height: 1.65;
}

.onboarding-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.onboarding-features {
    list-style: none;
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
}

.onboarding-features li {
    padding: 10px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 10px;
}

.onboarding-features li::before {
    content: '✓';
    color: var(--green-bright);
    font-weight: 700;
}

.onboarding-features li:last-child {
    border-bottom: none;
}

.explanation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    text-align: left;
}

.explain-card {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 14px;
}

.explain-card h4 {
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--text-bright);
}

.explain-card p {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 0;
}

.onboarding-tips {
    list-style: none;
    text-align: left;
}

.onboarding-tips li {
    padding: 6px 0;
    font-size: 14px;
    color: var(--text-dim);
}

.onboarding-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

/* Onboarding modal slides */
.onboard-slide {
    display: none;
    text-align: center;
    padding: 16px;
}

.onboard-slide.active {
    display: block;
    animation: fadeInUp 0.3s ease;
}

.onboard-center-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.onboard-slide h4 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-bright);
}

.onboard-slide p {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.feature-list {
    list-style: none;
    text-align: left;
    max-width: 320px;
    margin: 0 auto;
}

.feature-list li {
    padding: 5px 0;
    font-size: 13px;
    color: var(--text-dim);
}

.feature-list li::before {
    content: '• ';
    color: var(--blue-bright);
}

.signal-example {
    margin: 12px 0;
}

.sig-row {
    padding: 6px 12px;
    font-size: 13px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.sig-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    font-size: 11px;
    margin-right: 8px;
    font-weight: 600;
}

.step-dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-strong);
}

.dot.active {
    background: var(--blue);
    box-shadow: 0 0 8px var(--glow-blue);
}

.onboard-actions {
    display: flex;
    gap: 8px;
}

/* ---------- 23. Error & HTMX states ---------- */
.error-msg {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--red-bright);
    font-size: 12px;
    margin-top: 8px;
}

.error-msg.hidden {
    display: none;
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 0.2s;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}

/* Auth bar */
.auth-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-email {
    color: var(--text-secondary);
    font-size: 13px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-hint {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
    margin: -2px 0 16px;
}

.auth-message {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
    margin-top: 14px;
    padding: 10px 12px;
}

.auth-message.success {
    background: rgba(52, 211, 153, 0.08);
    border-color: rgba(52, 211, 153, 0.35);
    color: var(--green);
}

.auth-message.error {
    background: rgba(248, 113, 113, 0.08);
    border-color: rgba(248, 113, 113, 0.35);
    color: var(--red);
}

/* Market selector */
.market-selector {
    margin-bottom: 0;
}

.market-label {
    font-size: 12px;
    color: var(--text-dim);
    margin-right: 8px;
    font-weight: 500;
}

/* Scanner */
.scanner-results {
}

/* ---------- 24. Scrollbars ---------- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-pill);
    border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

::-webkit-scrollbar-corner {
    background: var(--bg);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) var(--bg);
}

/* ---------- 25. Utilities ---------- */
.text-mono,
.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.text-dim {
    color: var(--text-dim);
}
.text-muted {
    color: var(--text-muted);
}
.text-bright {
    color: var(--text-bright);
}
.text-green {
    color: var(--green-bright);
}
.text-red {
    color: var(--red-bright);
}
.text-blue {
    color: var(--blue-bright);
}
.text-orange {
    color: var(--orange-bright);
}
.text-purple {
    color: var(--purple);
}

.text-positive {
    color: var(--green-bright);
}
.text-negative {
    color: var(--red-bright);
}
.text-neutral {
    color: var(--text-dim);
}

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.flex {
    display: flex;
}
.flex-col {
    display: flex;
    flex-direction: column;
}
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}
.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.flex-1 {
    flex: 1;
    min-width: 0;
}
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.uppercase { text-transform: uppercase; }

.w-full { width: 100%; }

.hidden {
    display: none !important;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.numeric {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* Tabular numbers everywhere for data */
.data-table td,
.data-table th,
.value-box-value,
.calc-value,
.calc-field input,
.position-pnl,
.dashboard-stat-value,
.signal-stat-value,
.form-input,
.text-mono,
.mono,
.numeric {
    font-variant-numeric: tabular-nums;
}

/* ---------- 26. Animations ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 1;
    }
    70% {
        box-shadow: 0 0 0 6px transparent;
        opacity: 0.85;
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
        opacity: 1;
    }
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--glow-blue);
    }
    50% {
        box-shadow: 0 0 0 8px transparent;
    }
}

@keyframes toast-progress {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast.dismissing {
    animation: toast-out 0.3s ease forwards;
}

/* ---------- 27. Responsive ---------- */
/* Desktop >1200px: full grid (default) */
@media (min-width: 1201px) {
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    }
}

/* Tablet 768–1200px: 2-col grid */
@media (max-width: 1200px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .main-content {
        padding: 20px;
    }
}

@media (max-width: 1024px) {
    .navbar {
        padding: 0 16px;
        gap: 12px;
    }
    .logo-subtitle {
        display: none;
    }
}

/* Mobile <768px: 1-col, condensed navbar */
@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
    .navbar {
        padding: 0 12px;
        height: 52px;
    }
    .navbar-tabs {
        gap: 0;
    }
    .nav-tab {
        padding: 6px 10px;
        font-size: 12px;
    }
    .tab-icon {
        display: none;
    }
    .main-content {
        padding: 12px;
    }
    .onboarding-card {
        padding: 20px;
    }
    .explanation {
        grid-template-columns: 1fr;
    }
    .signals-dashboard {
        grid-template-columns: repeat(2, 1fr);
    }
    .live-status {
        padding: 4px 8px;
    }
    .live-status .status-label {
        display: none;
    }
    .modal {
        padding: 12px;
    }
    .modal-content {
        padding: 18px;
        width: 100%;
        max-height: calc(100dvh - 24px);
    }
    #toast-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }
    .toast {
        min-width: 0;
        max-width: 100%;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .signal-stats {
        grid-template-columns: 1fr 1fr;
    }
    .calc-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .signals-dashboard {
        grid-template-columns: 1fr;
    }
    .signal-stats,
    .calc-row {
        grid-template-columns: 1fr;
    }
    .data-table th,
    .data-table td {
        padding: 9px 10px;
    }
}

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

:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

button:focus-visible,
.btn:focus-visible,
.nav-tab:focus-visible,
.modal-close:focus-visible {
    outline: none;
}

/* ============================================
   16. PRO SAAS — Additional Component Classes
   ============================================ */

/* Signal card left-border accents */
.signal-card.signal-long_a {
    border-left: 4px solid var(--green);
}
.signal-card.signal-short_a {
    border-left: 4px solid var(--orange);
}
.signal-card.signal-wait {
    border-left: 4px solid var(--border);
}

/* Best signal highlight */
.signal-best {
    box-shadow: 0 0 0 1px var(--blue), 0 8px 32px rgba(59, 130, 246, 0.15);
}

/* Z-score heatmap cells */
.cell-heat-orange {
    background: rgba(245, 158, 11, 0.12);
    color: var(--orange) !important;
    font-weight: 600;
}
.cell-heat-green {
    background: rgba(16, 185, 129, 0.12);
    color: var(--green) !important;
    font-weight: 600;
}

/* Glass card (dashboard stat cards) */
.glass-card {
    background: linear-gradient(135deg, rgba(15, 20, 25, 0.9), rgba(19, 25, 34, 0.8));
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    backdrop-filter: blur(20px);
    transition: all 0.2s ease;
}
.glass-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

/* Dashboard banner */
.dashboard-banner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

/* Stat card (dashboard) */
.stat-card {
    background: linear-gradient(135deg, rgba(15, 20, 25, 0.9), rgba(19, 25, 34, 0.8));
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 20px;
}
.stat-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.stat-card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}
.stat-card-icon {
    font-size: 16px;
    opacity: 0.6;
}
.stat-card-value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
    margin-bottom: 2px;
}
.stat-card-sub {
    font-size: 12px;
    color: var(--text-dim);
}

/* Live status dot (navbar) */
.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    margin-right: 6px;
    transition: all 0.3s;
}
.live-dot.live {
    background: var(--green);
    animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

/* Ticker pair (card header) */
.ticker-pair {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Signals table */
.signals-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.signals-table th {
    text-align: left;
    padding: 10px 14px;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 1;
}
.signals-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.signals-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Positions grid (favorites) */
.favorites-section-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 12px;
}

.section .favorites-section-toolbar h3 {
    margin-bottom: 0;
}

.ru-refresh-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.ru-refresh-btn {
    gap: 7px;
    padding: 8px 13px;
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.45);
    color: var(--green);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.ru-refresh-btn:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.7);
    color: var(--text-bright);
}

.ru-refresh-btn:disabled {
    cursor: wait;
    opacity: 0.7;
}

.ru-refresh-btn.is-loading .refresh-icon {
    animation: spin 0.8s linear infinite;
}

.refresh-icon {
    display: inline-block;
    font-size: 16px;
    line-height: 1;
}

.ru-refresh-time {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}

.favorites-pnl-settings {
    display: grid;
    grid-template-columns: repeat(4, minmax(110px, 1fr)) auto;
    align-items: end;
    gap: 10px;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0d141b;
}

.favorite-pnl-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.favorite-pnl-field label {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.favorite-pnl-field .form-input {
    min-height: 34px;
}

.favorites-pnl-note {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 10px;
}

.positions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

/* Position P&L display (favorites) */
.position-pnl-caption {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
}

.position-pnl-display {
    font-size: 32px;
    font-weight: 700;
    font-family: var(--font-mono);
    margin: 4px 0 12px;
    text-align: center;
}
.position-pnl-display.positive {
    color: var(--green);
}
.position-pnl-display.negative {
    color: var(--red);
}

.position-pnl-breakdown {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #0b1117;
}

.position-pnl-breakdown > div {
    min-width: 0;
    padding: 9px;
    border-right: 1px solid var(--border);
}

.position-pnl-breakdown > div:last-child {
    border-right: 0;
}

.position-pnl-breakdown span,
.position-pnl-breakdown small,
.position-pnl-breakdown strong {
    display: block;
}

.position-pnl-breakdown span {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.position-pnl-breakdown strong {
    overflow: hidden;
    font-family: var(--font-mono);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.position-pnl-breakdown small {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 9px;
    line-height: 1.3;
}

.position-pnl-breakdown .net-pnl-cell {
    background: rgba(53, 214, 160, 0.04);
}

/* Spread chart stats */
.spread-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
    padding: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.spread-stats .stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.spread-stats .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.spread-stats .stat-value {
    font-size: 16px;
    font-weight: 600;
}

/* Scanner button text */
.scanner-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.scanner-desc {
    font-size: 11px;
    color: var(--text-dim);
}
.scanner-btn .scanner-icon {
    font-size: 20px;
}
.scanner-btn {
    display: flex !important;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 10px 16px !important;
}

/* Position details (favorites) */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
}
.detail-label {
    color: var(--text-muted);
}
.detail-value {
    color: var(--text);
    font-weight: 500;
}
.position-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* Position badges */
.position-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Forecast status banner */
.forecast-status {
    border-radius: 10px;
    padding: 10px 14px;
    margin: 12px 0;
    border: 1px solid;
}
.forecast-green {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
}
.forecast-orange {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
}
.forecast-red {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
}
.forecast-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    margin-bottom: 2px;
}
.forecast-icon {
    font-size: 16px;
}
.forecast-detail {
    font-size: 12px;
    color: var(--text-dim);
    margin-left: 22px;
}

/* Progress bar */
.progress-bar-container {
    position: relative;
    height: 24px;
    background: var(--card2);
    border-radius: 12px;
    overflow: hidden;
    margin: 8px 0;
    border: 1px solid var(--border);
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--blue));
    border-radius: 12px;
    transition: width 0.5s ease;
    opacity: 0.6;
}
.progress-bar-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

/* Chart container */
.chart-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-top: 12px;
}

/* ---------- 30. Modern Trading Terminal Theme ---------- */
:root {
    --bg: #080a0d;
    --bg-2: #0b0f14;
    --surface-1: #0f141a;
    --surface-2: #131a22;
    --surface-3: #18212b;
    --surface-hover: #1d2733;
    --card: #10161d;
    --card-2: #121922;
    --card-elevated: #151e28;
    --border: #24303d;
    --border-strong: #344454;
    --border-hover: #4b6175;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --text: #d9e2ec;
    --text-dim: #91a0af;
    --text-muted: #657382;
    --text-bright: #f5f8fb;
    --blue: #4f8cff;
    --blue-bright: #7aabff;
    --green: #2fd08f;
    --green-bright: #55e0aa;
    --red: #ff5d5d;
    --red-bright: #ff8080;
    --orange: #f6b849;
    --orange-bright: #ffd071;
    --teal: #24c7c0;
    --purple: #6f7cff;
    --radius: 8px;
    --radius-md: 8px;
    --radius-sm: 6px;
    --radius-xs: 4px;
    --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.03);
    --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.26);
    --shadow-lg: 0 18px 42px rgba(0, 0, 0, 0.34);
    --shadow-xl: 0 24px 56px rgba(0, 0, 0, 0.42);
    --content-max: 1680px;
    --navbar-h: 64px;
}

* {
    letter-spacing: 0 !important;
}

html {
    background: var(--bg);
}

body {
    background:
        linear-gradient(180deg, #090c10 0%, #0c1117 34%, #080a0d 100%);
    color: var(--text);
}

h1,
.display,
h2,
.section-title,
h3,
.card-title,
.logo-text,
.signal-name {
    letter-spacing: 0 !important;
}

.navbar {
    height: var(--navbar-h);
    padding: 0 18px;
    background: rgba(9, 12, 16, 0.94);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 12px 32px rgba(0, 0, 0, 0.24);
    gap: 16px;
}

.navbar-brand {
    min-width: 232px;
    gap: 9px;
}

.logo-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--green-bright);
    border: 1px solid var(--green-bright);
    color: #052018;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.1);
}

.logo-text {
    font-size: 15px;
    font-weight: 700;
}

.logo-subtitle {
    color: var(--text-muted);
    font-size: 11px;
}

.navbar-tabs {
    gap: 4px;
    padding: 0 4px;
}

.nav-tab {
    height: 36px;
    padding: 0 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    color: var(--text-dim);
    background: transparent;
}

.nav-tab:hover {
    color: var(--text-bright);
    background: var(--surface-2);
    border-color: var(--border);
}

.nav-tab.active {
    color: var(--text-bright);
    background: #17212b;
    border-color: #395063;
    box-shadow: inset 0 -2px 0 var(--teal);
}

.tab-icon {
    opacity: 0.82;
}

.navbar-end {
    gap: 10px;
}

.locale-switcher {
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    padding: 3px;
}

.locale-btn {
    background: transparent;
    border: 0;
    border-radius: 4px;
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    min-height: 26px;
    padding: 0 8px;
}

.locale-btn.active {
    background: var(--surface-2);
    color: var(--teal-bright);
}

.live-status,
.auth-bar,
#auth-status .auth-bar {
    min-height: 34px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #0e141a;
}

.main-content {
    max-width: var(--content-max);
    padding: 18px;
}

.signals-page {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    grid-template-areas:
        "market modes"
        "calc content";
    align-items: start;
    gap: 12px;
}

.market-selector {
    grid-area: market;
}

.calc-settings-bar {
    grid-area: calc;
    position: sticky;
    top: calc(var(--navbar-h) + 14px);
}

.signals-mode-bar {
    grid-area: modes;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(14, 20, 26, 0.92);
    box-shadow: var(--shadow-sm);
}

.signals-content {
    grid-area: content;
    min-width: 0;
}

.market-selector-bar,
.calculator-settings,
.mode-switcher {
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0f151c;
    box-shadow: var(--shadow-sm);
}

.market-selector-bar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
}

.market-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.market-btn,
.mode-btn {
    min-height: 36px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-dim);
    font-weight: 600;
}

.market-btn:hover,
.mode-btn:hover {
    color: var(--text-bright);
    background: var(--surface-2);
    border-color: var(--border);
}

.market-btn.active,
.mode-btn.active {
    color: var(--text-bright);
    background: #14212a;
    border-color: rgba(36, 199, 192, 0.45);
    box-shadow: inset 3px 0 0 var(--teal);
}

.mode-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.mode-filters {
    margin-top: 10px;
}

.calculator-settings {
    padding: 12px;
}

.calculator-settings .calc-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.calc-field label,
.signal-stat-label,
.stat-card-label,
.dashboard-stat-label,
.detail-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.form-input,
.form-input-sm,
.form-range {
    border-radius: 6px;
    border-color: var(--border);
    background: #0a0f14;
}

.form-input:focus,
.form-input-sm:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(36, 199, 192, 0.12);
}

.calc-hint {
    margin-top: 10px;
    color: var(--text-muted);
    line-height: 1.4;
}

.dashboard-banner,
.signals-dashboard {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.glass-card,
.dashboard-stat,
.stat-card {
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #101720;
    box-shadow: var(--shadow-sm);
}

.glass-card:hover,
.dashboard-stat:hover,
.stat-card:hover {
    border-color: var(--border-hover);
    transform: none;
    box-shadow: var(--shadow-md);
}

.stat-card,
.dashboard-stat {
    min-height: 96px;
    padding: 14px;
}

.stat-card-value,
.dashboard-stat-value {
    margin-top: 8px;
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
}

.stat-card-sub,
.dashboard-stat-sub {
    color: var(--text-muted);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0 10px;
    padding: 0;
    border: 0;
}

.section-header h3 {
    color: var(--text-bright);
    font-size: 14px;
    text-transform: uppercase;
}

.cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 10px;
}

.signal-card {
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #101720;
    box-shadow: var(--shadow-sm);
    padding: 14px;
}

.signal-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.signal-card.signal-long_a,
.signal-card.long_a,
.signal-card.long {
    border-left: 3px solid var(--green);
}

.signal-card.signal-short_a,
.signal-card.short_a,
.signal-card.short {
    border-left: 3px solid var(--orange);
}

.signal-card.signal-wait,
.signal-card.wait {
    border-left: 3px solid var(--border-strong);
}

.signal-card-header {
    min-height: 36px;
    padding-right: 38px;
    gap: 10px;
}

.signal-name {
    font-size: 14px;
    font-weight: 750;
}

.ticker-logo {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background-color: #0a0f14;
}

.fav-btn {
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border-color: var(--border);
    background: #0a0f14;
}

.fav-btn:hover,
.fav-btn.favorited {
    color: var(--orange-bright);
    border-color: var(--orange);
    background: rgba(246, 184, 73, 0.1);
}

.fav-btn-inline {
    width: 26px;
    height: 26px;
    margin-right: 8px;
}

.signal-stats {
    gap: 8px;
}

.signal-stat,
.calc-field,
.calc-block {
    border-radius: 6px;
    border-color: var(--border);
    background: rgba(8, 12, 16, 0.58);
}

.signal-stat {
    min-height: 64px;
}

.signal-stat-value,
.calc-value {
    color: var(--text-bright);
    font-family: var(--font-mono);
}

.calc-block {
    margin-top: 12px;
    padding: 10px;
}

.badge {
    min-height: 22px;
    border-radius: 5px;
    font-weight: 700;
}

.badge-blue {
    color: #a9c5ff;
    background: rgba(79, 140, 255, 0.12);
    border-color: rgba(79, 140, 255, 0.28);
}

.badge-green {
    color: #8cf0c4;
    background: rgba(47, 208, 143, 0.11);
    border-color: rgba(47, 208, 143, 0.28);
}

.badge-orange {
    color: #ffd58b;
    background: rgba(246, 184, 73, 0.12);
    border-color: rgba(246, 184, 73, 0.3);
}

.badge-red {
    color: #ff9d9d;
    background: rgba(255, 93, 93, 0.12);
    border-color: rgba(255, 93, 93, 0.28);
}

.badge-gray {
    color: var(--text-dim);
    background: rgba(145, 160, 175, 0.08);
    border-color: rgba(145, 160, 175, 0.16);
}

.sparkline {
    width: 100%;
    height: 44px;
    margin: 10px 0;
    border-radius: 6px;
    background: #0a0f14;
    border: 1px solid var(--border);
}

.table-container {
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0f151c;
    box-shadow: var(--shadow-sm);
}

.data-table,
.signals-table {
    font-size: 12px;
}

.data-table th,
.signals-table th {
    height: 38px;
    padding: 8px 12px;
    color: var(--text-muted);
    background: #0a0f14;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.data-table td,
.signals-table td {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(36, 48, 61, 0.72);
}

.data-table tbody tr:nth-child(even),
.signals-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

.data-table tbody tr:hover,
.signals-table tbody tr:hover {
    background: rgba(36, 199, 192, 0.06);
}

.signal-stat-tomorrow {
    border-color: rgba(36, 199, 192, 0.28);
    background: rgba(36, 199, 192, 0.055);
}

.signal-timing {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 8px 0 12px;
    border: 1px solid rgba(36, 199, 192, 0.28);
    border-radius: 6px;
    overflow: hidden;
    background: rgba(36, 199, 192, 0.055);
}

.signal-timing-item {
    min-width: 0;
    padding: 8px 9px;
}

.signal-timing-item + .signal-timing-item {
    border-left: 1px solid var(--border);
}

.signal-timing-item span {
    display: block;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: uppercase;
}

.signal-timing-item strong {
    display: block;
    margin-top: 3px;
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.signal-timing-remaining strong {
    color: var(--teal);
}

.signal-timing.is-overdue {
    border-color: rgba(255, 95, 115, 0.34);
    background: rgba(255, 95, 115, 0.06);
}

.signal-timing.is-overdue .signal-timing-remaining strong {
    color: var(--red-bright);
}

.signal-stat-sub {
    margin-top: 3px;
    font-size: 11px;
    line-height: 1.25;
    color: var(--text-muted);
}

.tomorrow-cell {
    white-space: nowrap;
}

.tomorrow-delta {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    color: var(--teal);
    font-size: 11px;
    font-weight: 700;
}

.market-risk-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(245, 158, 11, 0.34);
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.07);
    color: var(--text);
    font-size: 12px;
}

.market-risk-banner strong {
    color: var(--orange);
    white-space: nowrap;
}

.market-risk-banner.is-stress {
    border-color: rgba(255, 95, 115, 0.42);
    background: rgba(255, 95, 115, 0.08);
}

.market-risk-banner.is-stress strong {
    color: var(--red-bright);
}

.market-risk-value {
    margin-left: auto;
    color: var(--text-bright);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.pair-risk-note {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    margin: 8px 0;
    padding: 8px 9px;
    border-left: 2px solid var(--orange);
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.07);
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.35;
}

.pair-risk-note strong {
    color: var(--orange);
    white-space: nowrap;
}

.pair-risk-note.is-stress {
    border-left-color: var(--red-bright);
    background: rgba(255, 95, 115, 0.07);
}

.pair-risk-note.is-stress strong {
    color: var(--red-bright);
}

.fav-btn:disabled {
    cursor: not-allowed;
    opacity: 0.35;
}

.empty-state,
.loading-container,
.error-msg {
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #101720;
}

.toast {
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #101720;
}

.positions-grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 10px;
}

.position-card,
.portfolio-card,
.scanner-btn,
.chart-container,
.spread-stats {
    border-radius: 8px;
    border-color: var(--border);
    background: #101720;
}

.progress-bar-container,
.progress-bar-fill,
.forecast-status {
    border-radius: 6px;
}

@media (max-width: 1180px) {
    .signals-page {
        grid-template-columns: 1fr;
        grid-template-areas:
            "market"
            "calc"
            "modes"
            "content";
    }

    .calc-settings-bar {
        position: static;
    }

    .market-selector-bar {
        grid-template-columns: auto repeat(auto-fit, minmax(80px, 1fr));
        align-items: center;
    }

    .calculator-settings .calc-row {
        grid-template-columns: repeat(4, minmax(120px, 1fr));
    }
}

@media (max-width: 780px) {
    .navbar {
        height: auto;
        min-height: var(--navbar-h);
        align-items: flex-start;
        flex-wrap: wrap;
        padding: 10px 12px;
    }

    .navbar-brand {
        min-width: 0;
        width: 100%;
    }

    .navbar-tabs {
        order: 3;
        width: 100%;
    }

    .navbar-end {
        margin-left: auto;
    }

    .main-content {
        padding: 12px;
    }

    .market-selector-bar,
    .calculator-settings .calc-row,
    .dashboard-banner,
    .signals-dashboard {
        grid-template-columns: 1fr;
    }

    .cards-grid,
    .positions-grid {
        grid-template-columns: 1fr;
    }

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

    .favorites-pnl-settings .btn {
        grid-column: 1 / -1;
    }

    .signals-mode-bar {
        overflow-x: auto;
    }

    .market-risk-banner {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .market-risk-value {
        margin-left: 0;
    }
}

/* ---------- Polymarket direction terminal ---------- */
.polymarket-page {
    width: 100%;
}

.polymarket-header {
    align-items: flex-end;
}

.page-kicker {
    display: block;
    margin-bottom: 5px;
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
}

.polymarket-window {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    padding-left: 18px;
    border-left: 2px solid rgba(16, 185, 129, 0.5);
}

.window-label,
.summary-label {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: uppercase;
}

.polymarket-window strong {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
}

.polymarket-loading {
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    border: 1px solid var(--border);
    background: #0d131b;
}

.polymarket-loading > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.polymarket-loading strong {
    color: var(--text-bright);
}

.polymarket-loading span {
    color: var(--text-muted);
    font-size: 12px;
}

.polymarket-summary {
    display: grid;
    grid-template-columns: minmax(260px, 1.6fr) minmax(110px, 0.55fr) minmax(190px, 0.8fr) auto;
    align-items: stretch;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    background: #0d131b;
}

.poly-leader,
.summary-stat {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
    padding: 13px 16px;
    border-right: 1px solid var(--border);
}

.summary-stat strong {
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0;
}

.leader-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.leader-line > strong {
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 18px;
}

.leader-probability {
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
}

.poly-refresh-btn {
    align-self: center;
    margin: 0 14px;
    gap: 7px;
    white-space: nowrap;
}

.polymarket-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.poly-filter {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border: 1px solid var(--border);
    background: #0b1017;
}

.poly-filter-btn {
    min-height: 30px;
    padding: 5px 11px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

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

.poly-filter-btn.active {
    background: #1a2531;
    color: var(--text-bright);
    box-shadow: inset 0 -2px 0 var(--green);
}

.poly-model-note {
    color: var(--text-muted);
    font-size: 11px;
}

.poly-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    background: #0b1017;
}

.poly-table {
    width: 100%;
    min-width: 1180px;
    border-collapse: collapse;
    font-size: 12px;
}

.poly-table th {
    height: 38px;
    padding: 8px 11px;
    border-bottom: 1px solid var(--border);
    background: #0d141c;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.poly-table td {
    height: 66px;
    padding: 9px 11px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text);
    vertical-align: middle;
    white-space: nowrap;
}

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

.poly-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

.poly-table tr[hidden] {
    display: none;
}

.poly-asset,
.poly-direction,
.poly-price,
.poly-accuracy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.poly-asset {
    min-width: 145px;
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 8px;
}

.poly-symbol {
    grid-row: 1 / span 2;
    align-self: center;
    min-width: 48px;
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
}

.poly-asset > span:not(.poly-symbol) {
    color: var(--text);
    font-weight: 600;
}

.poly-asset small,
.poly-direction small,
.poly-price small,
.poly-accuracy small {
    color: var(--text-muted);
    font-size: 10px;
}

.poly-accuracy {
    min-width: 164px;
    white-space: normal;
}

.poly-accuracy-unvalidated > strong {
    color: var(--text-muted);
}

.poly-edge-warning {
    color: var(--orange);
    font-size: 9px;
    font-weight: 600;
    line-height: 1.25;
}

.poly-direction {
    min-width: 82px;
}

.poly-direction strong,
.poly-price strong,
.poly-accuracy strong {
    color: var(--text-bright);
    font-family: var(--font-mono);
}

.direction-pill {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 8px;
    border: 1px solid;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}

.direction-up {
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.1);
    color: var(--green);
}

.direction-down {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
}

.probability-pair {
    width: 154px;
}

.probability-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 10px;
}

.probability-labels span:first-child {
    color: var(--green);
}

.probability-labels span:last-child {
    color: var(--red);
}

.probability-track {
    position: relative;
    width: 100%;
    height: 5px;
    overflow: hidden;
    background: rgba(239, 68, 68, 0.45);
}

.probability-track::after {
    content: "";
    position: absolute;
    top: -2px;
    bottom: -2px;
    left: 50%;
    width: 1px;
    background: var(--text-bright);
    opacity: 0.6;
}

.probability-up {
    display: block;
    height: 100%;
    background: var(--green);
}

.source-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 700;
}

.source-pyth {
    border-color: rgba(34, 211, 238, 0.35);
    background: rgba(34, 211, 238, 0.08);
    color: #67e8f9;
}

.source-proxy {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
    color: var(--orange);
}

.poly-row-unavailable {
    opacity: 0.65;
}

.poly-unavailable {
    color: var(--text-muted);
    white-space: normal;
}

.polymarket-error {
    min-height: 220px;
}

.tab-icon-text {
    min-width: 18px;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    text-align: center;
}

@media (max-width: 980px) {
    .polymarket-summary {
        grid-template-columns: 1fr 1fr;
    }

    .poly-leader,
    .summary-stat {
        border-bottom: 1px solid var(--border);
    }

    .poly-refresh-btn {
        justify-self: start;
        margin: 12px 14px;
    }
}

@media (max-width: 780px) {
    .polymarket-header {
        align-items: flex-start;
    }

    .polymarket-window {
        align-items: flex-start;
        padding-left: 12px;
    }

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

    .poly-leader,
    .summary-stat {
        border-right: 0;
    }

    .polymarket-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .poly-filter {
        max-width: 100%;
        overflow-x: auto;
    }
}
