/* ============================================
   QUIET LUXURY DESIGN SYSTEM
   Apple-inspired minimalist aesthetic
   ============================================ */

:root {
    /* Neutral Foundation */
    --q-bg: #f5f6f8;
    --q-surface: rgba(255, 255, 255, 0.92);
    --q-surface-2: rgba(255, 255, 255, 0.98);
    --q-white: #ffffff;

    /* Text Colors */
    --q-text: rgba(17, 24, 39, 0.96);
    --q-text-secondary: rgba(17, 24, 39, 0.72);
    --q-muted: rgba(17, 24, 39, 0.60);

    /* Apple-inspired Accent Colors */
    --q-accent: #0a84ff;
    --q-accent-hover: #0070e0;
    --q-accent-2: #5e5ce6;
    --q-accent-subtle: rgba(10, 132, 255, 0.08);
    --q-accent-muted: rgba(10, 132, 255, 0.12);

    /* Semantic Colors */
    --q-success: #34c759;
    --q-success-bg: rgba(52, 199, 89, 0.10);
    --q-success-border: rgba(52, 199, 89, 0.25);

    --q-warning: #ff9f0a;
    --q-warning-bg: rgba(255, 159, 10, 0.10);
    --q-warning-border: rgba(255, 159, 10, 0.25);

    --q-danger: #ff3b30;
    --q-danger-bg: rgba(255, 59, 48, 0.10);
    --q-danger-border: rgba(255, 59, 48, 0.25);

    --q-info: #5e5ce6;
    --q-info-bg: rgba(94, 92, 230, 0.10);
    --q-info-border: rgba(94, 92, 230, 0.25);

    /* Borders */
    --q-border: rgba(15, 23, 42, 0.10);
    --q-border-subtle: rgba(15, 23, 42, 0.06);

    /* Elevation Shadows - Soft and refined */
    --q-shadow-xs: 0 1px 3px rgba(15, 23, 42, 0.04);
    --q-shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
    --q-shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --q-shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.10);
    --q-shadow-xl: 0 16px 40px rgba(15, 23, 42, 0.12);

    /* Accent shadow for primary buttons */
    --q-shadow-accent: 0 4px 14px rgba(10, 132, 255, 0.30);
    --q-shadow-accent-hover: 0 6px 20px rgba(10, 132, 255, 0.35);

    /* Spacing Scale */
    --q-space-xs: 0.25rem;
    --q-space-sm: 0.5rem;
    --q-space-md: 1rem;
    --q-space-lg: 1.5rem;
    --q-space-xl: 2rem;

    /* Border Radius */
    --q-radius-sm: 8px;
    --q-radius-md: 12px;
    --q-radius-lg: 14px;
    --q-radius-xl: 16px;
    --q-radius-full: 9999px;

    /* Transitions */
    --q-transition-fast: 0.15s ease;
    --q-transition-base: 0.2s ease;
    --q-transition-slow: 0.3s ease-in-out;
}

/* ============================================
   BASE STYLES
   ============================================ */
html, body {
    height: 100%;
}

body {
    background:
        radial-gradient(1200px 600px at 20% 0%, rgba(10, 132, 255, 0.08), transparent 60%),
        radial-gradient(900px 500px at 90% 10%, rgba(94, 92, 230, 0.06), transparent 60%),
        var(--q-bg);
    color: var(--q-text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    letter-spacing: -0.01em;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--q-text);
    line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
    line-height: 1.65;
    color: var(--q-text-secondary);
}

label, .form-label {
    font-weight: 550;
    font-size: 0.875rem;
    color: rgba(17, 24, 39, 0.78);
}

.small, small {
    color: var(--q-muted);
    font-size: 0.8125rem;
}

a {
    color: var(--q-accent);
    text-decoration: none;
    transition: color var(--q-transition-fast);
}

a:hover {
    color: var(--q-accent-hover);
    text-decoration: underline;
}

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

a, p, span, div, th, td, li {
    font-kerning: normal;
}

/* ============================================
   LAYOUT
   ============================================ */
.container, .container-fluid {
    max-width: 1200px;
}

#app-wrapper {
    min-height: calc(100vh - 120px);
}

/* ============================================
   NAVBAR - Frosted Glass
   ============================================ */
.navbar-qtrade {
    background: rgba(255, 255, 255, 0.78);
    border-bottom: 1px solid var(--q-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
}

.navbar-qtrade .navbar-brand {
    font-weight: 700;
    letter-spacing: 0.2px;
    color: var(--q-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-qtrade .navbar-brand:hover {
    color: var(--q-text);
    text-decoration: none;
}

.q-brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: radial-gradient(circle at 30% 20%, rgba(10, 132, 255, 0.95), rgba(94, 92, 230, 0.85));
    box-shadow: 0 8px 20px rgba(10, 132, 255, 0.22);
    display: inline-block;
}

.q-brand-text {
    font-weight: 750;
    letter-spacing: -0.01em;
}

.q-brand-sub {
    font-size: 0.85rem;
    color: var(--q-muted);
    font-weight: 600;
}

.navbar-qtrade .nav-link,
.navbar-qtrade .dropdown-item {
    font-weight: 550;
}

.navbar-qtrade .nav-link {
    color: rgba(17, 24, 39, 0.78);
    border-radius: var(--q-radius-full);
    padding: 0.5rem 0.75rem;
    margin: 0.125rem 0.15rem;
    transition: all var(--q-transition-fast);
}

.navbar-qtrade .nav-link:hover,
.navbar-qtrade .nav-link:focus {
    color: rgba(17, 24, 39, 0.95);
    background: rgba(10, 132, 255, 0.06);
}

.navbar-qtrade .nav-link.active {
    color: rgba(10, 132, 255, 0.95);
    background: rgba(10, 132, 255, 0.12);
}

.navbar-qtrade .navbar-toggler {
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: var(--q-radius-md);
    padding: 0.4rem 0.55rem;
}

.navbar-qtrade .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(10, 132, 255, 0.18);
}

/* User Chip */
.q-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.4rem;
    border-radius: var(--q-radius-full);
    border: 1px solid rgba(15, 23, 42, 0.10);
    background: rgba(255, 255, 255, 0.70);
    transition: background var(--q-transition-fast);
}

.q-user-chip:hover {
    background: rgba(255, 255, 255, 0.90);
}

.q-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: var(--q-radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: rgba(17, 24, 39, 0.92);
    background: rgba(10, 132, 255, 0.12);
}

.q-user-name {
    max-width: 16ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(17, 24, 39, 0.88);
    font-size: 0.8125rem;
}

/* ============================================
   DROPDOWN MENUS
   ============================================ */
.dropdown-menu {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--q-border);
    box-shadow: var(--q-shadow-lg);
    border-radius: var(--q-radius-lg);
    padding: 0.4rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.dropdown-item {
    color: rgba(17, 24, 39, 0.90);
    border-radius: 10px;
    padding: 0.5rem 0.7rem;
    font-size: 0.875rem;
    transition: background var(--q-transition-fast);
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: rgba(17, 24, 39, 0.95);
    background: rgba(10, 132, 255, 0.08);
}

.dropdown-item.active,
.dropdown-item:active {
    color: rgba(10, 132, 255, 0.95);
    background: rgba(10, 132, 255, 0.12);
}

.dropdown-divider {
    border-color: var(--q-border);
    opacity: 0.6;
}

/* ============================================
   SIDEBAR
   ============================================ */
.trading-sidebar {
    width: 220px;
    min-height: calc(100vh - 120px);
    position: sticky;
    top: 56px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.70);
    border-right: 1px solid var(--q-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: var(--q-space-lg);
}

.sidebar-header {
    margin-bottom: var(--q-space-md);
}

.sidebar-header h6 {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--q-muted);
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--q-radius-sm);
    color: rgba(11, 16, 33, 0.9);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--q-transition-fast);
    text-decoration: none;
}

.sidebar-link:hover {
    background: rgba(10, 132, 255, 0.08);
    color: var(--q-accent);
    text-decoration: none;
}

.sidebar-link.active {
    background: rgba(10, 132, 255, 0.12);
    color: var(--q-accent);
}

.sidebar-link .q-icon {
    opacity: 0.72;
}

.sidebar-link:hover .q-icon,
.sidebar-link.active .q-icon {
    opacity: 1;
}

/* ============================================
   CARDS - Borderless with subtle shadow
   ============================================ */
.card, .modal-content {
    background: var(--q-surface);
    border: 1px solid var(--q-border);
    box-shadow: var(--q-shadow-sm);
    border-radius: var(--q-radius-xl);
    overflow: hidden;
    transition: box-shadow var(--q-transition-base);
}

.card:hover {
    box-shadow: var(--q-shadow-md);
}

.card-header {
    background: rgba(255, 255, 255, 0.65);
    border-bottom: 1px solid var(--q-border);
    padding: var(--q-space-lg);
    font-weight: 650;
    letter-spacing: -0.01em;
}

.card-body {
    padding: 1.25rem;
}

.card-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--q-text);
    margin-bottom: 0.125rem;
    letter-spacing: -0.01em;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    letter-spacing: -0.005em;
    transition: all var(--q-transition-base);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--q-accent);
    border-color: var(--q-accent);
    color: var(--q-white);
    box-shadow: var(--q-shadow-accent);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--q-accent-hover);
    border-color: var(--q-accent-hover);
    box-shadow: var(--q-shadow-accent-hover);
    transform: translateY(-1px);
}

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

.btn-outline-primary {
    border-color: rgba(10, 132, 255, 0.45);
    color: rgba(17, 24, 39, 0.90);
    background: transparent;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background: rgba(10, 132, 255, 0.10);
    border-color: rgba(10, 132, 255, 0.65);
    color: var(--q-accent);
}

.btn-outline-secondary {
    border-color: rgba(94, 92, 230, 0.5);
    color: rgba(17, 24, 39, 0.88);
    background: transparent;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    background: rgba(94, 92, 230, 0.12);
    border-color: rgba(94, 92, 230, 0.7);
    color: var(--q-accent-2);
}

.btn-outline-danger {
    border-color: var(--q-danger-border);
    color: var(--q-danger);
    background: transparent;
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
    background: var(--q-danger-bg);
    border-color: var(--q-danger);
    color: var(--q-danger);
}

.btn-outline-success {
    border-color: var(--q-success-border);
    color: var(--q-success);
    background: transparent;
}

.btn-outline-success:hover,
.btn-outline-success:focus {
    background: var(--q-success-bg);
    border-color: var(--q-success);
    color: var(--q-success);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-custom-size {
    padding: 6px 10px;
    font-size: 0.85rem;
    width: auto;
    transition: background-color var(--q-transition-fast), color var(--q-transition-fast), transform 0.1s ease;
}

.btn-custom-size:hover,
.btn-custom-size:focus {
    transform: translateY(-1px);
}

/* ============================================
   BADGES - Professional Pill Style
   ============================================ */
.badge {
    border-radius: var(--q-radius-full);
    padding: 0.35rem 0.7rem;
    font-weight: 650;
    font-size: 0.75rem;
    letter-spacing: 0.01em;
}

.badge.text-bg-primary {
    background: var(--q-accent-muted) !important;
    color: var(--q-accent) !important;
}

.badge.text-bg-success {
    background: var(--q-success-bg) !important;
    color: var(--q-success) !important;
}

.badge.text-bg-warning {
    background: var(--q-warning-bg) !important;
    color: var(--q-warning) !important;
}

.badge.text-bg-danger {
    background: var(--q-danger-bg) !important;
    color: var(--q-danger) !important;
}

.badge.text-bg-secondary {
    background: rgba(15, 23, 42, 0.10) !important;
    color: rgba(17, 24, 39, 0.78) !important;
}

.badge.text-bg-info {
    background: var(--q-info-bg) !important;
    color: var(--q-info) !important;
}

/* Custom Q-badges */
.q-badge {
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: var(--q-radius-full);
    padding: 0.35rem 0.6rem;
    border: 1px solid transparent;
}

.q-badge-success {
    background: var(--q-success-bg);
    color: var(--q-success);
    border-color: var(--q-success-border);
}

.q-badge-muted {
    background: rgba(148, 163, 184, 0.14);
    color: rgba(71, 85, 105, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.28);
}

.q-badge-warning {
    background: var(--q-warning-bg);
    color: #92400e;
    border-color: var(--q-warning-border);
}

.q-badge-danger {
    background: var(--q-danger-bg);
    color: var(--q-danger);
    border-color: var(--q-danger-border);
}

.q-badge-info {
    background: var(--q-info-bg);
    color: var(--q-info);
    border-color: var(--q-info-border);
}

/* ============================================
   FORMS
   ============================================ */
.form-control,
.form-select,
.input-group-text {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(15, 23, 42, 0.12);
    color: rgba(17, 24, 39, 0.95);
    border-radius: 10px;
}

.form-control,
.form-select {
    font-size: 0.95rem;
    font-weight: 550;
    letter-spacing: -0.005em;
    min-height: 44px;
    font-variant-numeric: tabular-nums;
    transition: border-color var(--q-transition-fast), box-shadow var(--q-transition-fast);
}

.form-control::placeholder {
    color: rgba(17, 24, 39, 0.45);
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(10, 132, 255, 0.55);
    box-shadow: 0 0 0 0.2rem rgba(10, 132, 255, 0.14);
    outline: none;
}

.q-icon {
    width: 18px;
    height: 18px;
    opacity: 0.72;
}

.q-date-input {
    cursor: pointer;
}

.q-input-group .input-group-text {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.q-input-group .form-control,
.q-input-group .form-select {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.form-text {
    color: var(--q-muted);
    font-size: 0.8125rem;
}

/* ============================================
   TABLES
   ============================================ */
.table {
    color: var(--q-text);
    background: rgba(255, 255, 255, 0.80);
    border-radius: var(--q-radius-lg);
    overflow: hidden;
    font-size: 0.95rem;
}

.q-table {
    margin-bottom: 0;
}

.q-table th,
.q-table td {
    padding: 0.75rem 0.95rem;
    vertical-align: middle;
}

.q-table thead th {
    background: rgba(2, 6, 23, 0.04);
    color: rgba(17, 24, 39, 0.72);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.q-table tbody tr {
    transition: background var(--q-transition-fast);
}

.q-table tbody tr:hover {
    background: rgba(10, 132, 255, 0.05);
}

.table-responsive {
    border-radius: var(--q-radius-lg);
}

.table thead th {
    color: rgba(17, 24, 39, 0.88);
    border-bottom: 1px solid var(--q-border);
}

.table td, .table th {
    border-color: rgba(15, 23, 42, 0.10);
}

.table-hover tbody tr:hover {
    background: rgba(10, 132, 255, 0.05);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background: rgba(10, 132, 255, 0.03);
}

.table-bordered {
    border-color: rgba(15, 23, 42, 0.10);
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    border: 1px solid var(--q-border);
    background: var(--q-surface-2);
    color: var(--q-text);
    border-radius: var(--q-radius-lg);
    box-shadow: var(--q-shadow-sm);
}

.alert-success {
    border-left: 3px solid var(--q-success);
    background: var(--q-success-bg);
}

.alert-danger {
    border-left: 3px solid var(--q-danger);
    background: var(--q-danger-bg);
}

.alert-warning {
    border-left: 3px solid var(--q-warning);
    background: var(--q-warning-bg);
}

.alert-info {
    border-left: 3px solid var(--q-info);
    background: var(--q-info-bg);
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination .page-link {
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.10);
    color: rgba(17, 24, 39, 0.80);
    transition: all var(--q-transition-fast);
}

.pagination .page-link:hover {
    background: rgba(10, 132, 255, 0.08);
    border-color: rgba(10, 132, 255, 0.30);
    color: var(--q-accent);
}

.pagination .page-item.active .page-link {
    background: var(--q-accent);
    border-color: transparent;
    box-shadow: var(--q-shadow-accent);
    color: #fff;
}

/* ============================================
   KPI CARDS
   ============================================ */
.kpi-card {
    border-radius: var(--q-radius-xl);
}

.kpi-label {
    color: var(--q-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--q-text);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.kpi-sub {
    margin-top: 6px;
    color: var(--q-muted);
    font-size: 0.85rem;
}

.kv {
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.65);
    border-radius: var(--q-radius-md);
    padding: 10px 12px;
}

.kv .k {
    color: var(--q-muted);
    font-size: 0.78rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.kv .v {
    font-size: 0.95rem;
    font-weight: 650;
    margin-top: 2px;
}

.kv .v.sig-metric-small {
    font-size: 0.82rem;
    font-weight: 600;
}

.kv .v.sig-message {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
}

/* ============================================
   CHARTS
   ============================================ */
.chart-container {
    position: relative;
    width: 100%;
    height: clamp(280px, 40vh, 520px);
    border-radius: var(--q-radius-md);
    background: transparent;
    overflow: hidden;
}

.chart-container canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

/* ============================================
   SECTION TITLE
   ============================================ */
.section-title {
    font-weight: 650;
    letter-spacing: -0.01em;
}

/* ============================================
   LOG CONTENT
   ============================================ */
.log-line {
    white-space: pre-line;
    font-size: 12px;
}

.log-content {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "SF Mono", "Liberation Mono", "Courier New", monospace;
    overflow-x: auto;
    background: rgba(2, 6, 23, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.10);
    border-radius: var(--q-radius-md);
    padding: 12px;
}

/* ============================================
   TRADING COMPONENTS
   ============================================ */
.ticker-card {
    border-radius: var(--q-radius-md);
}

.ticker-symbol {
    font-size: 1.1rem;
}

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

.ticker-change {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Order Book */
.order-book-container .card {
    overflow: hidden;
}

.order-book-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.order-row {
    position: relative;
    font-size: 0.85rem;
    transition: background var(--q-transition-fast);
}

.order-row:hover {
    background: rgba(0, 0, 0, 0.02);
}

.depth-bar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
}

.order-row .row {
    position: relative;
    z-index: 1;
}

.spread-indicator {
    font-weight: 500;
}

/* Trade Form */
.trade-form-container .card {
    overflow: visible;
}

.trade-form-container .btn-group .btn {
    font-size: 0.8rem;
}

.trade-form-container .btn-check:checked + .btn-outline-success {
    background: var(--q-success-bg);
    border-color: var(--q-success-border);
    color: var(--q-success);
}

.trade-form-container .btn-check:checked + .btn-outline-danger {
    background: var(--q-danger-bg);
    border-color: var(--q-danger-border);
    color: var(--q-danger);
}

#trade-preview {
    border: 1px solid var(--q-border);
}

/* Market Status */
.market-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.market-status .status-dot.bg-success {
    background: var(--q-success);
    box-shadow: 0 0 8px rgba(52, 199, 89, 0.5);
}

/* Quick Trade Buttons */
.quick-trade-buttons .btn {
    font-weight: 600;
}

/* ============================================
   HTMX INDICATORS
   ============================================ */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

.htmx-settling {
    opacity: 0.8;
}

/* ============================================
   SKELETON LOADING
   ============================================ */
@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

.placeholder-glow .placeholder {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ============================================
   UTILITIES
   ============================================ */
.font-monospace {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "SF Mono", "Liberation Mono", "Courier New", monospace !important;
    font-variant-numeric: tabular-nums;
}

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

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

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

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

.transition-opacity {
    transition: opacity var(--q-transition-base);
}

.transition-all {
    transition: all var(--q-transition-base);
}

.focus-ring:focus {
    outline: 2px solid var(--q-accent);
    outline-offset: 2px;
}

/**
 * Frosted glass effect utility (DRY extraction)
 * Apply to elements needing the Apple-style blur effect.
 */
.q-glass {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    background: rgba(255, 255, 255, 0.70);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ============================================
   LEGACY BOOTSTRAP 4 COMPATIBILITY
   ============================================ */
.form-group { margin-bottom: 1rem; }
.font-weight-bold { font-weight: 700 !important; }
.custom-select { display: block; width: auto; padding: .375rem 2.25rem .375rem .75rem; }
.thead-light th { background: rgba(255, 255, 255, 0.06); }
.thead-dark th { background: rgba(2, 6, 23, 0.06); color: rgba(17, 24, 39, 0.88); }
.ml-auto { margin-left: auto !important; }

.jumbotron {
    padding: 2rem;
    border-radius: var(--q-radius-xl);
    background: var(--q-surface);
    border: 1px solid var(--q-border);
    box-shadow: var(--q-shadow-lg);
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.checkbox-inline input[type="checkbox"] {
    margin-right: 10px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 991.98px) {
    .trading-sidebar {
        display: none !important;
    }

    #main-content {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .chart-container {
        height: 320px;
    }
}

@media (max-width: 767.98px) {
    .kpi-value {
        font-size: 1.3rem;
    }

    .ticker-card .card-body {
        flex-direction: column;
        gap: 0.75rem;
    }

    .ticker-card .d-flex {
        flex-wrap: wrap;
    }

    .order-book-container .col-6 {
        font-size: 0.8rem;
    }
}

/* ============================================
   EQUAL HEIGHT ROWS
   ============================================ */
.row.align-items-stretch > [class*="col-"] {
    display: flex;
}

.row.align-items-stretch > [class*="col-"] > .card {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.row.align-items-stretch .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */
.card.is-hovered {
    transform: translateY(-3px);
    box-shadow: var(--q-shadow-lg);
}

.btn.is-hovered {
    transform: translateY(-1px);
    box-shadow: var(--q-shadow-sm);
}

*:focus-visible {
    outline: 2px solid var(--q-accent);
    outline-offset: 2px;
}

/* ============================================
   ENGINE CONSOLE: PIPELINE STRIP, SPARKLINE, KEY/VALUE LISTS
   ============================================ */
.q-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .5rem; }
.q-flow-step { position: relative; background: var(--q-surface); border: 1px solid var(--q-border); border-left-width: 4px; border-radius: var(--q-radius-md); padding: .55rem .75rem; box-shadow: var(--q-shadow-xs); min-width: 0; }
.q-flow-step .q-flow-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--q-muted); font-weight: 600; }
.q-flow-step .q-flow-value { font-weight: 600; font-size: .95rem; line-height: 1.3; overflow-wrap: anywhere; }
.q-flow-step .q-flow-sub { font-size: .76rem; color: var(--q-text-secondary); overflow-wrap: anywhere; }
.q-flow-step.is-ok { border-left-color: var(--q-success); }
.q-flow-step.is-warn { border-left-color: var(--q-warning); }
.q-flow-step.is-bad { border-left-color: var(--q-danger); }
.q-flow-step.is-idle { border-left-color: var(--q-border); }
.q-flow-step .q-flow-index { position: absolute; top: .35rem; right: .5rem; font-size: .65rem; color: var(--q-muted); }
.q-spark { width: 100%; height: 56px; display: block; }
.q-spark polyline { fill: none; stroke: var(--q-accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.q-kv { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: .15rem .75rem; font-size: .82rem; margin: 0; }
.q-kv dt { color: var(--q-muted); font-weight: 500; margin: 0; white-space: nowrap; }
.q-kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.q-num { font-variant-numeric: tabular-nums; }
.q-cell-sub { display: block; font-size: .72rem; color: var(--q-muted); line-height: 1.2; }
.q-table-dense td, .q-table-dense th { padding: .3rem .45rem; font-size: .8rem; vertical-align: top; }
.q-table-dense th { white-space: nowrap; }
.q-section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--q-muted); font-weight: 600; margin: 1.25rem 0 .5rem; }

/* Engine console tabs */
.q-tabs { border-bottom: 1px solid var(--q-border); gap: .25rem; }
.q-tabs .nav-link { color: var(--q-text-secondary); font-weight: 500; padding: .5rem .9rem; border: 0; border-bottom: 2px solid transparent; background: transparent; }
.q-tabs .nav-link:hover { color: var(--q-text); border-bottom-color: var(--q-border); }
.q-tabs .nav-link.active { color: var(--q-accent); border-bottom-color: var(--q-accent); background: transparent; }
.q-tab-count { font-size: .72rem; color: var(--q-muted); font-weight: 400; margin-left: .35rem; }
.q-subtabs .nav-link { font-size: .85rem; padding: .35rem .8rem; }
.q-group-tabs .nav-link { font-size: .82rem; padding: .35rem .7rem; }
.tab-pane .q-section-title:first-child { margin-top: 0; }
/* Scroll inside a panel instead of the page */
.q-scroll-panel { max-height: calc(100vh - 250px); overflow: auto; }
/* Signed-in user menu */
.q-user-role { font-size: .7rem; color: var(--q-muted); margin-left: .35rem; }
.q-user-menu { min-width: 18rem; }
.q-user-menu-header { padding: .5rem 1rem .25rem; }
.q-user-avatar-lg { width: 2.4rem; height: 2.4rem; font-size: 1rem; }

/* Engine status pill (navbar) and status line (engine page) */
.q-status-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .65rem; border-radius: var(--q-radius-full); font-size: .78rem; font-weight: 600; text-decoration: none; border: 1px solid var(--q-border); background: var(--q-surface); color: var(--q-text-secondary); white-space: nowrap; }
.q-status-pill:hover { text-decoration: none; }
.q-status-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--q-muted); }
.q-status-pill.is-ok { color: #166534; background: var(--q-success-bg); border-color: var(--q-success-border); }
.q-status-pill.is-ok .q-status-dot { background: var(--q-success); box-shadow: 0 0 0 3px rgba(52, 199, 89, .18); }
.q-status-pill.is-live { color: #7f1d1d; background: var(--q-danger-bg); border-color: var(--q-danger-border); }
.q-status-pill.is-live .q-status-dot { background: var(--q-danger); box-shadow: 0 0 0 3px rgba(255, 59, 48, .18); }
.q-status-pill.is-warn { color: #92400e; background: var(--q-warning-bg); border-color: var(--q-warning-border); }
.q-status-pill.is-warn .q-status-dot { background: var(--q-warning); }
.q-status-pill.is-bad { color: var(--q-danger); background: var(--q-danger-bg); border-color: var(--q-danger-border); }
.q-status-pill.is-bad .q-status-dot { background: var(--q-danger); }
.q-status-pill.is-idle .q-status-dot { background: var(--q-muted); }
.q-status-mode { font-weight: 400; color: var(--q-muted); }
.q-status-line { padding: .6rem .85rem; border-radius: var(--q-radius-md); border: 1px solid var(--q-border); border-left-width: 4px; background: var(--q-surface); }
.q-status-line.is-ok { border-left-color: var(--q-success); }
.q-status-line.is-live { border-left-color: var(--q-danger); }
.q-status-line.is-warn { border-left-color: var(--q-warning); }
.q-status-line.is-bad { border-left-color: var(--q-danger); }
.q-status-line.is-idle { border-left-color: var(--q-border); }
