/* Toast Notification */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    opacity: 0;
    transform: translateY(-12px);
    animation: toastIn 0.3s ease forwards;
    pointer-events: auto;
    max-width: 90vw;
    text-align: center;
}
.toast.success { background: rgba(16,185,129,0.9); }
.toast.error   { background: rgba(239,68,68,0.9); }
.toast.warning { background: rgba(245,158,11,0.9); }
.toast.info    { background: rgba(96,165,250,0.9); }
.toast.fadeOut  { animation: toastOut 0.3s ease forwards; }
/* A left:50% box is only as wide as half the viewport, so a long English toast
   wrapped into a narrow column on phones; let it use up to 90vw. zh keeps its
   original width. */
html[lang="en"] .toast-container {
    width: max-content;
    max-width: 90vw;
}
@keyframes toastIn  { to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px); } }

/* Login Page */
.login-page {
    position: fixed;
    inset: 0;
    background: #121212;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 32px;
    width: 100%;
    max-width: 380px;
    background: #1e1e1e;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.06);
}

.login-title {
    font-size: 2.4rem;
    font-weight: 800;
    color: #f8fafc;
    margin-bottom: 6px;
    letter-spacing: -1px;
}

.login-title-accent {
    color: #2dd4bf;
}

.login-subtitle {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 36px;
    text-align: center;
}

.google-btn-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 16px;
}

.referral-input-wrap {
    width: 100%;
    margin-bottom: 12px;
}

.referral-input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: #f8fafc;
    font-size: 14px;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    box-sizing: border-box;
    transition: border-color 0.2s, background 0.2s;
}

.referral-input::placeholder {
    color: #4b5563;
    letter-spacing: 0;
    text-transform: none;
}

.referral-input:focus {
    outline: none;
    border-color: #2dd4bf;
    background: rgba(0,166,81,0.05);
}

.referral-input.has-value {
    border-color: #2dd4bf;
    background: rgba(0,166,81,0.08);
}

.login-error {
    background: #450a0a;
    border: 1px solid #ef4444;
    border-radius: 8px;
    color: #fca5a5;
    font-size: 0.85rem;
    padding: 10px 14px;
    margin-top: 8px;
    text-align: center;
    width: 100%;
}

/* User Menu in Header */
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    padding-left: 12px;
    border-left: 1px solid #475569;
}

.user-menu .fas.fa-user-circle {
    color: #94a3b8;
    font-size: 1.1rem;
}

.user-email {
    font-size: 0.8rem;
    color: #94a3b8;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-outline {
    background: transparent;
    border: 1px solid #475569;
    color: #94a3b8;
}

.btn-outline:hover {
    background: #334155;
    color: #f8fafc;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height: avoids iOS address bar layout shift */
    color: #f8fafc;
    line-height: 1.6;
    overscroll-behavior: none; /* Prevent iOS bounce/rubber-band that triggers layout shift */
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: #1e293b;
    border-radius: 10px;
    padding: 12px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid #475569;
}

.header h1 {
    font-size: 1.5rem;
    color: #f8fafc;
    font-weight: 700;
}

.header h1 i {
    color: #6d28d9;
    margin-right: 10px;
}

.version-tag {
    font-size: 0.8rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(109, 40, 217, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 10px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.frr-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #334155, #475569);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #64748b;
}

.frr-label {
    color: #cbd5e1;
    font-size: 0.9rem;
    font-weight: 500;
}

.frr-value {
    color: #10b981;
    font-weight: 700;
    font-size: 1rem;
}

/* FRR Section */
.frr-section {
    margin-bottom: 24px;
}

.frr-display-large {
    padding: 20px;
    background: linear-gradient(135deg, #1e293b, #334155);
    border-radius: 12px;
    border: 2px solid #10b981;
}

.frr-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.frr-label-main {
    color: #e2e8f0;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.frr-value-large {
    font-size: 2.5rem;
    font-weight: 800;
    color: #10b981;
    margin-bottom: 8px;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.frr-description {
    color: #cbd5e1;
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.9;
}

/* Inline FRR Display */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.frr-display-inline {
    background: linear-gradient(135deg, #334155, #475569);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #10b981;
}

.frr-text {
    color: #cbd5e1;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.frr-value-inline {
    color: #10b981;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

/* Special layout for offers section header */
.offers-section .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.offers-section .header-right {
    display: flex;
    justify-content: flex-end;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(34, 197, 94, 0.2);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #f8fafc;
}

.status-indicator.connected i {
    color: #2dd4bf;
    animation: pulse 2s infinite;
}

.status-indicator.disconnected {
    background: rgba(239, 68, 68, 0.2);
}

.status-indicator.disconnected i {
    color: #ef4444;
}

@keyframes pulse {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.5; }
}

/* Dashboard Grid - Fixed 2 columns per row */
.dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}


/* Card Styles */
.card {
    background: #1e293b;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid #475569;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 10px;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border-color: #64748b;
}

.card-header {
    background: linear-gradient(135deg, #1e1b4b, #0f172a);
    color: white;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.card-header i {
    margin-right: 10px;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Header Balance Display */
.header-balance {
    display: flex;
    align-items: center;
    gap: 8px;
}

.balance-label-header {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.balance-value-header {
    font-size: 1.2rem;
    font-weight: 700;
    color: #f1f5f9;
}

/* Mini Scheduler Controls in Header */
.scheduler-status-mini {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.status-label-mini {
    color: #cbd5e1;
    font-weight: 500;
}

.status-value-mini {
    color: #f1f5f9;
    font-weight: 600;
}

.scheduler-controls-mini {
    display: flex;
    gap: 4px;
}

.card-body {
    padding: 12px;
}

/* Account Summary */

/* Profit Summary - Horizontal Layout */
.profit-summary-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(71, 85, 105, 0.3);
}

.profit-item-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.profit-label-inline {
    font-size: 0.8rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profit-value-inline {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f8fafc;
}

.profit-change {
    font-size: 0.8rem;
    font-weight: 600;
}

.profit-change.positive {
    color: #10b981;
}

.profit-change.negative {
    color: #ef4444;
}

/* Currency tag in profit summary rows */
.profit-currency-tag {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 42px;
    text-align: center;
}

.profit-currency-usd {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.profit-currency-usdt {
    color: #10b981;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Rate Chart Card */
.rate-chart-card .chart-legend {
    display: flex;
    gap: 15px;
}

.rate-chart-card .legend-item {
    font-size: 0.85rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.rate-chart-card .legend-item i {
    font-size: 0.6rem;
}

.legend-item.legend-usd i {
    color: #3b82f6 !important;
}

.legend-item.legend-usdt i {
    color: #10b981 !important;
}

.chart-container {
    height: 250px;
    position: relative;
}

.chart-period-selector {
    display: flex;
    gap: 4px;
}

.period-btn {
    background: transparent;
    border: 1px solid #475569;
    color: #94a3b8;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.period-btn:hover {
    border-color: #94a3b8;
    color: #e2e8f0;
}

.period-btn.active {
    background: #475569;
    border-color: #64748b;
    color: #f1f5f9;
}

.balance-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.balance-item {
    text-align: center;
    padding: 12px;
    background: linear-gradient(135deg, #334155, #475569);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.balance-item:hover {
    background: linear-gradient(135deg, #475569, #64748b);
    transform: scale(1.05);
}

.balance-label {
    font-size: 0.9rem;
    color: #cbd5e1;
    margin-bottom: 8px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.balance-item .balance-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f8fafc;
    text-align: center;
}

.balance-item .balance-value.highlight {
    color: #f1f5f9;
    font-size: 1.4rem;
    text-align: center !important;
}

/* Scheduler Control */
.scheduler-status {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.status-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #334155;
    border-radius: 6px;
}

.status-label {
    font-weight: 600;
    color: #cbd5e1;
}

.status-value {
    font-weight: 500;
    color: #8b5cf6;
}

.scheduler-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 16px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
    box-shadow: none !important;
    background: #64748b !important;
}

.btn-primary {
    background: linear-gradient(135deg, #2dd4bf, #14b8a6);
    color: #0f172a;
    font-weight: 600;
}

.btn-success {
    background: linear-gradient(135deg, #2dd4bf, #14b8a6);
    color: white;
}

.btn-danger {
    background: transparent;
    color: #f87171;
    border: 1px solid #f87171;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn-info {
    background: transparent;
    color: #2dd4bf;
    border: 1px solid #2dd4bf;
}

.btn-secondary {
    background: transparent;
    color: #94a3b8;
    border: 1px solid #475569;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Offers Section */
.offers-container {
    height: 750px; /* Greatly increased height for 'full' look */
    overflow-y: auto;
    padding-right: 5px;
}

.offer-item {
    background: #334155;
    border-radius: 6px;
    padding: 6px 10px; /* Even tighter padding */
    padding-right: 28px; /* Space for corner cancel button */
    margin-bottom: 4px; /* Minimal margin */
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    border: 1px solid #475569;
    position: relative;
}

.offer-cancel-x {
    position: absolute;
    top: 4px;
    right: 6px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    z-index: 2;
}

.offer-cancel-x:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.offer-item:hover {
    background: #475569;
    transform: scale(1.02);
    border-color: #64748b;
}

.offer-info {
    display: flex;
    gap: 12px;
}

.offer-detail {
    text-align: center;
}

.offer-detail-label {
    font-size: 0.8rem;
    color: #cbd5e1;
    margin-bottom: 4px;
}

.offer-detail-value {
    font-weight: 600;
    color: #f8fafc;
}

/* Strategy List - Enhanced 2x2 Grid Layout with Analytics */
.strategy-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    min-height: 300px;
}

/* Enhanced Strategy Card with Analytics */
.strategy-card {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    border: 1px solid #475569;
    transition: all 0.3s ease;
    cursor: pointer;
    overflow: hidden;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.strategy-card:not(.active) {
    cursor: pointer;
}

.strategy-card.active {
    cursor: default;
}

.strategy-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: #64748b;
}

.strategy-card.active {
    background: linear-gradient(135deg, rgba(109, 40, 217, 0.3), rgba(67, 56, 202, 0.2));
    border: 2px solid #6d28d9;
    box-shadow: 0 0 20px rgba(109, 40, 217, 0.3);
}

.strategy-card.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #6d28d9, #8b5cf6);
}

/* Strategy Header */
.strategy-header {
    flex: 1;
}

.strategy-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.strategy-name {
    font-weight: 700;
    color: #f8fafc;
    font-size: 1.2rem;
    line-height: 1.3;
}

.strategy-badges {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
}

.strategy-rating-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.rating-display {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fbbf24;
    font-weight: 600;
}

.rating-score {
    color: #e2e8f0;
    font-size: 0.85rem;
}

.recommendation-allocation {
    color: #10b981;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Strategy Reasoning */
.strategy-reasoning {
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 6px;
    border-left: 3px solid #3b82f6;
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.strategy-reasoning i {
    color: #3b82f6;
    margin-top: 2px;
    flex-shrink: 0;
}

/* Strategy Description */
.strategy-description {
    margin-top: 12px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
}

.strategy-summary {
    color: #e2e8f0;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 10px 0;
}

.strategy-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 6px;
}

.strategy-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #94a3b8;
}

.strategy-features li i {
    color: #10b981;
    font-size: 0.75rem;
}

/* Strategy Config Controls */
.strategy-config {
    margin-top: 16px;
    padding: 16px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    border: 1px solid #475569;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-label i {
    color: #f59e0b;
}

.config-hint {
    font-size: 0.75rem;
    font-weight: 400;
    color: #94a3b8;
}

.config-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.config-control input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #334155;
    outline: none;
    -webkit-appearance: none;
}

.config-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4);
}

.config-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    border: none;
}

.config-value {
    min-width: 50px;
    text-align: right;
    font-size: 1rem;
    font-weight: 700;
    color: #f59e0b;
}

/* Strategy Parameters Section */
.strategy-parameters {
    margin-top: 12px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
    border: 1px solid #334155;
}

.parameters-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.parameters-title i {
    color: #8b5cf6;
    font-size: 0.8rem;
}

.parameter-settings-btn {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 4px;
    padding: 4px 6px;
    color: #8b5cf6;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.parameter-settings-btn:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: #8b5cf6;
    transform: scale(1.05);
}

.parameters-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.param-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.8rem;
}

.param-label {
    color: #94a3b8;
    font-weight: 500;
}

.param-value {
    color: #f8fafc;
    font-weight: 600;
    text-align: right;
}

/* Badge Styles */
.risk-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.risk-badge.risk-low {
    background: rgba(34, 197, 94, 0.2);
    color: #2dd4bf;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.risk-badge.risk-moderate {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.risk-badge.risk-high {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.risk-badge.risk-very-high {
    background: rgba(147, 51, 234, 0.2);
    color: #9333ea;
    border: 1px solid rgba(147, 51, 234, 0.3);
}

.active-badge {
    padding: 4px 8px;
    background: rgba(34, 197, 94, 0.9);
    color: white;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* Multi-Currency Display */
.currency-group {
    margin-bottom: 24px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.5);
}

.currency-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(147, 51, 234, 0.1));
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.currency-icon {
    font-size: 1.2rem;
}

.currency-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e2e8f0;
}

.currency-count {
    font-size: 0.9rem;
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.2);
    padding: 4px 8px;
    border-radius: 12px;
}

.currency-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.currency-badge.currency-usd {
    background: rgba(34, 197, 94, 0.2);
    color: #2dd4bf;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.currency-badge.currency-usdt {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.currency-group .offer-item {
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    margin: 0;
    border-radius: 0;
}

.currency-group .offer-item:last-child {
    border-bottom: none;
}

/* Logs Section */
/* Modal */
.modal {
    display: none;
    position: fixed;
    /* Must exceed .mobile-bottom-nav z-index (1000) so modal covers the bottom
       tab bar when open — otherwise the 58px nav hides buttons at the bottom
       of the modal content. */
    z-index: 1100;
    inset: 0;
    /* JS sets display: flex when showing. These align props center the content
       and allow the backdrop itself to scroll if content is taller than viewport. */
    align-items: flex-start;
    justify-content: center;
    padding: 20px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #111827;
    margin: auto; /* vertical centering via flex; auto margins handle short content */
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    /* dvh accounts for mobile browser chrome that dynamically resizes; vh fallback for old browsers */
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
    border: 1px solid #1e293b;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Opacity-only variant for mobile — avoids creating a transform containing
   block that breaks position: fixed / sticky descendants. */
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-header {
    background: #0f172a;
    color: #e2e8f0;
    padding: 20px 25px;
    border-bottom: 1px solid #1e293b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 15px 15px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 25px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #f8fafc;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #1e293b;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: #0f172a;
    color: #e2e8f0;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2dd4bf;
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

.form-hint {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
}

/* Two-day-only switch card in the strategy modal */
.two-day-card {
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 14px;
    background: #0f172a;
}
.two-day-title { font-weight: 600; color: #f8fafc; margin-bottom: 6px; }
.two-day-desc { font-size: 12px; color: #9ca3af; line-height: 1.6; margin-bottom: 6px; }
.two-day-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid #1e293b;
}
.two-day-cur { width: 44px; font-weight: 600; color: #e2e8f0; line-height: 24px; }
.two-day-info { flex: 1; min-width: 0; font-size: 13px; line-height: 1.5; padding-top: 2px; }
.two-day-status.is-ok { color: #2dd4bf; }
.two-day-status.is-ok.cur-USD { color: #3b82f6; }
.two-day-status.is-ok.cur-UST { color: #26A17B; }
.two-day-status.is-warn { color: #fbbf24; }
.two-day-status.is-bad { color: #f87171; }
.two-day-status.is-muted { color: #9ca3af; }
.two-day-locked { font-size: 12px; color: #9ca3af; }
.two-day-rules { border-top: 1px solid #1e293b; padding-top: 8px; font-size: 12px; color: #9ca3af; }
.two-day-rules summary { cursor: pointer; color: #cbd5e1; }
.two-day-rules ul { margin: 6px 0 0; padding-left: 18px; line-height: 1.6; }
.two-day-note { margin-top: 8px; font-size: 12px; color: #fbbf24; }
/* Home-page pill next to the scheduler controls while two-day-only is on */
.two-day-badge {
    display: inline-block;
    align-self: center;
    padding: 2px 8px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1.4;
    white-space: nowrap;
}
.m-sched-row .two-day-badge { margin: 0 10px 0 8px; }
.two-day-badge.is-ok { color: #2dd4bf; background: rgba(45, 212, 191, 0.08); }
/* Applied: match the scheduler row's currency colour (app.js curColor) */
.two-day-badge.is-ok.cur-USD { color: #3b82f6; background: rgba(59, 130, 246, 0.1); }
.two-day-badge.is-ok.cur-UST { color: #26A17B; background: rgba(38, 161, 123, 0.1); }
.two-day-badge.is-warn { color: #fbbf24; background: rgba(251, 191, 36, 0.08); }
.two-day-badge.is-bad { color: #f87171; background: rgba(248, 113, 113, 0.08); }
/* Undo the generic .form-group label/input rules for the switch */
.two-day-card .m-switch { display: block; margin: 0; }
.two-day-card .m-switch input { position: absolute; padding: 0; border: 0; }
/* Switch colours follow the scheduler row's currency colour (app.js curColor) */
.two-day-card #twoDayModeUSD:checked + .m-slider { background: #3b82f6; }
.two-day-card #twoDayModeUST:checked + .m-slider { background: #26A17B; }
.two-day-card .m-switch input:focus-visible + .m-slider { outline: 2px solid #94a3b8; outline-offset: 2px; }

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
    /* Provide a tinted footer bar so the buttons read as a distinct action zone */
    background-color: #111827;
    padding: 12px 16px;
    border-top: 1px solid #1e293b;
}

/* Loading Animation */
.loading {
    text-align: center;
    padding: 40px;
    color: #cbd5e1;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #475569;
    border-radius: 50%;
    border-top-color: #6d28d9;
    animation: spin 1s ease-in-out infinite;
    margin-left: 10px;
}

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

/* Form Error Styles */
.form-error {
    background: #fee;
    border: 1px solid #ef4444;
    border-radius: 6px;
    padding: 12px;
    margin: 16px 0;
    animation: shake 0.5s ease-in-out;
}

.form-error .error-message {
    color: #dc2626;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Form Success Styles */
.form-success {
    background: #dcfce7;
    border: 1px solid #2dd4bf;
    border-radius: 6px;
    padding: 12px;
    margin: 16px 0;
    animation: slideInDown 0.3s ease-in-out;
}

.form-success .error-message {
    color: #166534;
    font-size: 0.9rem;
    font-weight: 500;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Button Loading State */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive Design */
/* Tablet responsive */
@media (max-width: 1024px) and (min-width: 769px) {
    .balance-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ═══ Global mobile card component styles (used by both desktop and mobile) ═══ */
.m-appbar {
    padding: 16px 4px 8px;
    /* display:flex is applied further down to the appbars that carry a toggle
       (tab show/hide uses !important) */
    align-items: baseline;
}

.m-appbar-title {
    font-size: 20px;
    font-weight: 600;
    color: #f8fafc;
    flex-shrink: 0;
}

.m-last-update {
    font-size: 11px;
    color: #6b7280;
    margin-left: 8px;
    min-width: 0; /* a long timestamp wraps instead of pushing the toggle off-screen */
}
/* On desktop the home appbar is a flex row (it carries the language toggle),
   which drops the whitespace that used to separate title and timestamp. Put
   one back at the appbar's font size (a no-break space has the same advance as
   the space it replaces) so the Chinese layout stays pixel-identical in any
   font. The phone layout is not flex and turns this off (see max-width 768). */
.m-appbar[data-tab="home"] .m-last-update::before {
    content: "\00a0";
    font-size: 16px;
    line-height: 0;
}

/* Capture/event rows put a label and its value in bare spans. An English label
   ends in a colon and sat flush against the value ("Basis:model estimate");
   give it a gap. zh keeps its original look. */
html[lang="en"] .history-item .detail-label {
    margin-right: 6px;
}

/* Language toggle: small grey pill, label is set by i18n.js */
.lang-toggle {
    flex-shrink: 0;
    padding: 3px 10px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    background: rgba(255,255,255,0.05);
    color: #9ca3af;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.lang-toggle:hover {
    background: rgba(255,255,255,0.1);
    color: #d1d5db;
}
.m-appbar .lang-toggle {
    margin-left: auto;
    align-self: center;
}
.login-card .lang-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
}

/* ── Mobile Flutter-clone card base ── */
.m-card {
    background: #1e1e1e;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.m-label {
    font-size: 14px;
    font-weight: 700;
    color: #9ca3af;
    margin-bottom: 10px;
}

.m-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 0;
}

/* ── Scheduler card ── */
.m-sched-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
}

.m-sched-row + .m-sched-row {
    border-top: 1px solid rgba(255,255,255,0.06);
}

svg.m-dot {
    flex-shrink: 0;
    margin-right: 8px;
}

.m-loading {
    color: #4b5563 !important;
}

.m-sched-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
}

.m-sched-text.on { color: #2dd4bf; }

/* Toggle switch (matches Flutter Switch) */
.m-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.m-switch input { opacity: 0; width: 0; height: 0; }

.m-slider {
    position: absolute;
    inset: 0;
    background: #4b5563;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.m-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.m-switch input:checked + .m-slider {
    background: #3b82f6; /* Default; overridden per-currency by JS */
}

.m-switch input:checked + .m-slider::before {
    transform: translateX(20px);
}

.m-switch input:disabled + .m-slider {
    opacity: 0.3;
    cursor: default;
}

/* ── Balance card ── */
.m-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.m-row span:first-child {
    color: #9ca3af;
    font-size: 14px;
}

.m-row span:last-child {
    font-weight: 700;
    font-size: 14px;
}

.m-row-lg span:last-child {
    font-size: 18px;
}

.m-idle {
    color: #9ca3af;
}

.m-idle.warn {
    color: #f97316 !important;
}

.m-cols-2, .m-cols-3 {
    display: flex;
    gap: 8px;
}

.m-cols-2 .m-mini { flex: 1; }
.m-cols-3 .m-mini { flex: 1; }

.m-mini-l {
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 2px;
}

.m-mini-v {
    font-size: 13px;
    font-weight: 700;
}

/* ── Interest card ── */
.m-interest-hero {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.m-interest-val {
    font-size: 24px;
    font-weight: 700;
    color: #2dd4bf;
}

.m-interest-apr {
    font-size: 13px;
    color: #9ca3af;
}

/* ── Mobile Settings Menu ── */
.m-settings-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
}

.m-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 16px;
    flex-shrink: 0;
}

.m-user-email {
    font-size: 14px;
    font-weight: 600;
}

.m-user-sub {
    font-size: 12px;
    color: #9ca3af;
}

.m-settings-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 4px 0;
}

.m-settings-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.m-settings-item:active {
    opacity: 0.6;
}

.m-settings-item > i:first-child {
    font-size: 18px;
    color: #9ca3af;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.m-item-text {
    flex: 1;
    min-width: 0;
}

.m-item-title {
    font-size: 15px;
    font-weight: 500;
}

.m-item-sub {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 1px;
}

.m-chevron {
    font-size: 12px;
    color: #4b5563;
}

.m-copy-btn {
    background: none;
    border: 1px solid #4b5563;
    border-radius: 6px;
    color: #9ca3af;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
}

.m-copy-btn:active {
    background: #334155;
}

.m-copy-btn.copied {
    color: #2dd4bf;
    border-color: #2dd4bf;
}

.m-danger > i:first-child,
.m-danger .m-item-title {
    color: #ef4444;
}

.m-settings-version {
    text-align: center;
    font-size: 12px;
    color: #6b7280;
    padding: 16px 0 4px;
}

/* Hide desktop cards on mobile */
.strategy-section,
.offers-section,
.credits-section,
.strategy-analytics-section {
    display: none !important;
}

/* Hide profit summary rows on mobile (replaced by interest table) */
.profit-summary-row {
    display: none !important;
}

/* Override all desktop .card styles on mobile */
.card {
    background: #1e1e1e !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 12px;
    margin-bottom: 12px;
}

.card .card-header {
    background: none !important;
    padding: 14px 16px 4px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    border-bottom: none;
}

.card .card-header h2 {
    font-size: 14px;
    font-weight: 700;
    color: #9ca3af;
}

.card .card-body {
    padding: 8px 12px 12px;
}

/* ── Mobile Interest Table (Flutter clone) ── */
.m-rev-table {
    width: 100%;
}

.m-rev-header {
    display: flex;
}

.m-rev-header .m-rev-col {
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}

.m-rev-header .m-rev-col:first-child {
    flex: none;
    width: 44px;
}

.m-rev-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 0;
}

.m-rev-row {
    display: flex;
}

.m-rev-cur {
    width: 44px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    padding-top: 2px;
}

.m-rev-cell {
    flex: 1;
    text-align: center;
}

.m-rv {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #2dd4bf;
}

.m-ra {
    display: block;
    font-size: 10px;
    color: #9ca3af;
}

/* ── Mobile Orders ── */
.m-orders-tabs-card {
    padding: 0 !important;
    overflow: hidden;
    background: #121212 !important;
}
/* Bottom nav: mobile only */
.mobile-bottom-nav {
    display: none;
}
/* m-only: hidden by default, shown by desktop and mobile overrides */
.m-only {
    display: none;
}

/* ═══ Global order card styles ═══ */
.m-order-empty,
.m-order-loading {
    text-align: center;
    color: #6b7280;
    padding: 32px 0;
    font-size: 14px;
}

.m-order-loading i {
    margin-right: 6px;
}

/* Offer / Credit card */
.m-ocard {
    background: #1e1e1e;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
}

.m-ocard.offer-usd { background: #1e1e1e; background: linear-gradient(90deg, rgba(59,130,246,0.12) 0%, #1e1e1e 60%); }
.m-ocard.offer-usdt { background: #1e1e1e; background: linear-gradient(90deg, rgba(38,161,123,0.12) 0%, #1e1e1e 60%); }

/* Credit card: dark base + progress bar + overlay */
.m-ocard.credit {
    background: #1e1e1e;
}

.m-ocard-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
}

.m-ocard-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.m-cur-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.m-cur-badge.usd {
    background: rgba(59,130,246,0.3);
    color: #3b82f6;
}

.m-cur-badge.usdt {
    background: rgba(38,161,123,0.3);
    color: #26A17B;
}

.m-ocard-amount {
    font-size: 16px;
    font-weight: 700;
    flex: 1;
}

.m-ocard-apr {
    font-size: 15px;
    font-weight: 700;
    color: #2dd4bf;
}
.m-ocard-apr.frr-rate {
    color: #b91c1c;
}

.m-ocard-bottom {
    display: flex;
    align-items: center;
    margin-top: 8px;
    font-size: 11px;
    color: #9ca3af;
    gap: 4px;
}

.m-ocard-bottom .spacer {
    flex: 1;
}

.m-pending-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f97316;
    margin-right: 4px;
}

.m-pending-text {
    color: #f97316;
}

.m-expiry-urgent {
    color: #ef4444;
    font-weight: 700;
}

/* Credit progress bar background */
.m-ocard-progress {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    opacity: 0.30;
}

.m-ocard-progress.sniper { background: #8b5cf6; }
.m-ocard-progress.ambush { background: #f97316; }
.m-ocard-progress.normal { background: #6b7280; }

.m-strategy-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.m-strategy-tag.normal { background: rgba(107,114,128,0.2); color: #9ca3af; }
.m-strategy-tag.ambush { background: rgba(245,158,11,0.2); color: #f59e0b; }
.m-strategy-tag.sniper { background: rgba(139,92,246,0.2); color: #a78bfa; }

/* Sort buttons — refined style */
.m-sort-bar {
    display: flex;
    gap: 4px;
    padding: 0;
}
.m-sort-btn {
    padding: 5px 14px;
    border-radius: 6px;
    border: none;
    background: rgba(255,255,255,0.05);
    color: #6b7280;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.3px;
}
.m-sort-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #d1d5db;
}
.m-sort-btn.active {
    background: rgba(0,166,81,0.15);
    color: #2dd4bf;
    font-weight: 600;
}

.m-credits-summary {
    display: flex;
    justify-content: space-between;
    padding: 8px 4px;
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 4px;
}

.m-credits-summary strong {
    color: #f8fafc;
}

/* Tab sections: hidden by default on mobile, shown when active */
.card[data-tab],
.m-card[data-tab],
.m-appbar[data-tab] {
    display: none;
}

/* ═══ Desktop overrides: use mobile card UI in two-column grid ═══ */
@media (min-width: 769px) {
    body { background: #121212; }
    .container { background: #121212; max-width: 1200px; margin: 0 auto; padding: 20px; }
    .dashboard { display: block !important; column-count: 2; column-gap: 16px; }
    .dashboard > [data-tab] { break-inside: avoid; margin-bottom: 16px; }
    .header { display: none !important; }
    .account-summary { display: none !important; }
    .offers-section { display: none !important; }
    .credits-section { display: none !important; }
    .m-only { display: block !important; }
    [data-tab] { display: block !important; }
    .m-appbar { padding: 8px 4px 4px !important; }
    .m-appbar[data-tab="orders"] { display: none !important; }
    /* Rows that carry the language toggle: flex, so the toggle sits at the right edge */
    .m-appbar[data-tab="home"],
    .m-appbar[data-tab="settings"] { display: flex !important; }
    /* Keep appbar glued to its following card in the multi-column flow so
       the title never orphans at the bottom of one column while its content
       jumps to the next (observed with 設定 tab). */
    .m-appbar { break-after: avoid !important; }
    .card { background: #1e1e1e !important; border: none !important; box-shadow: none !important; border-radius: 12px; margin-bottom: 12px; }
    .card .card-header { background: none !important; border-bottom: none; }
    .card .card-header h2 { font-size: 14px; font-weight: 700; color: #9ca3af; }
    /* Desktop: hide order tab switcher and sort bar — show both sections inline */
    .m-order-tabs { display: none !important; }
    .m-sort-bar { display: none !important; }
    .m-orders-tabs-card { background: transparent !important; overflow: visible !important; padding: 0 !important; }
}

@media (max-width: 768px) {
    .container {
        padding: 12px;
        padding-bottom: 72px; /* space for bottom nav */
        background: #121212;
    }

    body {
        background: #121212;
    }

    .header {
        display: none;
    }

    .dashboard {
        grid-template-columns: 1fr;
    }

    .scheduler-status {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

    /* Mobile modal: override JS's inline `display: flex` back to block.
       Flex + overflow-y: auto has multiple iOS Safari scroll bugs. Pure
       block scroll is bulletproof. Matches both "display:flex" and
       "display: flex" variants of inline style. */
    .modal[style*="display:flex"],
    .modal[style*="display: flex"] {
        display: block !important;
    }
    .modal {
        padding: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* backdrop-filter can freeze scroll on iOS — drop it on mobile */
        backdrop-filter: none;
    }
    .modal-content {
        width: 100%;
        max-width: none;
        max-height: none;
        min-height: 100%;
        margin: 0;
        border-radius: 0;
        border: none;
        overflow: visible;
        /* Opacity-only animation — no transform containing block trap */
        animation: modalFadeIn 0.2s ease;
    }
    .modal-header {
        border-radius: 0;
    }
    .form-actions {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    /* ── Hide desktop account-summary on mobile (even when tab-visible) ── */
    .account-summary,
    .account-summary.tab-visible {
        display: none !important;
    }

    .m-only {
        display: block !important;
    }

    /* ── Mobile AppBar ── */
    .m-appbar {
        padding: 16px 4px 8px;
    }

    .m-appbar-title {
        font-size: 20px;
        font-weight: 600;
        color: #f8fafc;
    }

    /* ── Mobile Flutter-clone card base ── */
    .m-card {
        background: #1e1e1e;
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
    }

    .m-label {
        font-size: 14px;
        font-weight: 700;
        color: #9ca3af;
        margin-bottom: 10px;
    }

    .m-divider {
        height: 1px;
        background: rgba(255,255,255,0.08);
        margin: 8px 0;
    }

    /* ── Scheduler card ── */
    .m-sched-row {
        display: flex;
        align-items: center;
        padding: 8px 0;
    }

    .m-sched-row + .m-sched-row {
        border-top: 1px solid rgba(255,255,255,0.06);
    }

    svg.m-dot {
        flex-shrink: 0;
        margin-right: 8px;
    }

    .m-loading {
        color: #4b5563 !important;
    }

    .m-sched-text {
        flex: 1;
        font-size: 14px;
        font-weight: 500;
        color: #6b7280;
    }

    .m-sched-text.on { color: #2dd4bf; }

    /* Toggle switch (matches Flutter Switch) */
    .m-switch {
        position: relative;
        width: 44px;
        height: 24px;
        flex-shrink: 0;
    }

    .m-switch input { opacity: 0; width: 0; height: 0; }

    .m-slider {
        position: absolute;
        inset: 0;
        background: #4b5563;
        border-radius: 12px;
        cursor: pointer;
        transition: background 0.2s;
    }

    .m-slider::before {
        content: '';
        position: absolute;
        width: 18px;
        height: 18px;
        left: 3px;
        top: 3px;
        background: #fff;
        border-radius: 50%;
        transition: transform 0.2s;
    }

    .m-switch input:checked + .m-slider {
        background: #3b82f6; /* Default; overridden per-currency by JS */
    }

    .m-switch input:checked + .m-slider::before {
        transform: translateX(20px);
    }

    .m-switch input:disabled + .m-slider {
        opacity: 0.3;
        cursor: default;
    }

    /* ── Balance card ── */
    .m-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
    }

    .m-row span:first-child {
        color: #9ca3af;
        font-size: 14px;
    }

    .m-row span:last-child {
        font-weight: 700;
        font-size: 14px;
    }

    .m-row-lg span:last-child {
        font-size: 18px;
    }

    .m-idle {
        color: #9ca3af;
    }

    .m-idle.warn {
        color: #f97316 !important;
    }

    .m-cols-2, .m-cols-3 {
        display: flex;
        gap: 8px;
    }

    .m-cols-2 .m-mini { flex: 1; }
    .m-cols-3 .m-mini { flex: 1; }

    .m-mini-l {
        font-size: 11px;
        color: #9ca3af;
        margin-bottom: 2px;
    }

    .m-mini-v {
        font-size: 13px;
        font-weight: 700;
    }

    /* ── Interest card ── */
    .m-interest-hero {
        display: flex;
        align-items: baseline;
        gap: 8px;
        margin-bottom: 8px;
    }

    .m-interest-val {
        font-size: 24px;
        font-weight: 700;
        color: #2dd4bf;
    }

    .m-interest-apr {
        font-size: 13px;
        color: #9ca3af;
    }

    /* ── Mobile Settings Menu ── */
    .m-settings-user {
        display: flex;
        align-items: center;
        gap: 12px;
        padding-bottom: 12px;
    }

    .m-avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: #334155;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #94a3b8;
        font-size: 16px;
        flex-shrink: 0;
    }

    .m-user-email {
        font-size: 14px;
        font-weight: 600;
    }

    .m-user-sub {
        font-size: 12px;
        color: #9ca3af;
    }

    .m-settings-divider {
        height: 1px;
        background: rgba(255,255,255,0.08);
        margin: 4px 0;
    }

    .m-settings-item {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .m-settings-item:active {
        opacity: 0.6;
    }

    .m-settings-item > i:first-child {
        font-size: 18px;
        color: #9ca3af;
        width: 24px;
        text-align: center;
        flex-shrink: 0;
    }

    .m-item-text {
        flex: 1;
        min-width: 0;
    }

    .m-item-title {
        font-size: 15px;
        font-weight: 500;
    }

    .m-item-sub {
        font-size: 12px;
        color: #9ca3af;
        margin-top: 1px;
    }

    .m-chevron {
        font-size: 12px;
        color: #4b5563;
    }

    .m-copy-btn {
        background: none;
        border: 1px solid #4b5563;
        border-radius: 6px;
        color: #9ca3af;
        padding: 6px 10px;
        cursor: pointer;
        font-size: 14px;
        -webkit-tap-highlight-color: transparent;
    }

    .m-copy-btn:active {
        background: #334155;
    }

    .m-copy-btn.copied {
        color: #2dd4bf;
        border-color: #2dd4bf;
    }

    .m-danger > i:first-child,
    .m-danger .m-item-title {
        color: #ef4444;
    }

    .m-settings-version {
        text-align: center;
        font-size: 12px;
        color: #6b7280;
        padding: 16px 0 4px;
    }

    /* Hide desktop cards on mobile */
    .strategy-section,
    .offers-section,
    .credits-section,
    .strategy-analytics-section {
        display: none !important;
    }

    /* Hide profit summary rows on mobile (replaced by interest table) */
    .profit-summary-row {
        display: none !important;
    }

    /* Override all desktop .card styles on mobile */
    .card {
        background: #1e1e1e !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 12px;
        margin-bottom: 12px;
    }

    .card .card-header {
        background: none !important;
        padding: 14px 16px 4px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        border-bottom: none;
    }

    .card .card-header h2 {
        font-size: 14px;
        font-weight: 700;
        color: #9ca3af;
    }

    .card .card-body {
        padding: 8px 12px 12px;
    }

    /* ── Mobile Interest Table (Flutter clone) ── */
    .m-rev-table {
        width: 100%;
    }

    .m-rev-header {
        display: flex;
    }

    .m-rev-header .m-rev-col {
        flex: 1;
        text-align: center;
        font-size: 12px;
        color: #9ca3af;
    }

    .m-rev-header .m-rev-col:first-child {
        flex: none;
        width: 44px;
    }

    .m-rev-divider {
        height: 1px;
        background: rgba(255,255,255,0.08);
        margin: 8px 0;
    }

    .m-rev-row {
        display: flex;
    }

    .m-rev-cur {
        width: 44px;
        flex-shrink: 0;
        font-size: 13px;
        font-weight: 700;
        padding-top: 2px;
    }

    .m-rev-cell {
        flex: 1;
        text-align: center;
    }

    .m-rv {
        display: block;
        font-size: 14px;
        font-weight: 700;
        color: #2dd4bf;
    }

    .m-ra {
        display: block;
        font-size: 10px;
        color: #9ca3af;
    }

    /* ── Mobile Orders ── */
    .m-orders-tabs-card {
        padding: 0 !important;
        overflow: hidden;
        background: #121212 !important;
    }

    .m-order-tabs {
        display: flex;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    .m-order-tab {
        flex: 1;
        padding: 12px 0;
        text-align: center;
        background: none;
        border: none;
        color: #9ca3af;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
    }

    .m-order-tab.active {
        color: #b8d8c8;
        font-weight: 700;
        box-shadow: inset 0 -2px 0 #b8d8c8;
    }

    .m-sort-bar {
        display: flex;
        gap: 6px;
        padding: 6px 12px;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    .m-sort-btn {
        padding: 4px 12px;
        border-radius: 12px;
        border: 1px solid rgba(255,255,255,0.15);
        background: none;
        color: #9ca3af;
        font-size: 12px;
        cursor: pointer;
    }
    .m-sort-btn.active {
        background: rgba(184,216,200,0.15);
        color: #b8d8c8;
        border-color: #b8d8c8;
    }

    .m-security-notice {
        display: flex;
        gap: 10px;
        align-items: flex-start;
        background: rgba(45,212,191,0.08);
        border: 1px solid rgba(45,212,191,0.2);
        border-radius: 8px;
        padding: 10px 12px;
        margin-bottom: 16px;
        font-size: 12px;
        color: #94a3b8;
    }
    .m-security-notice i { margin-top: 2px; flex-shrink: 0; }
    .m-toggle-secret {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        color: #9ca3af;
        cursor: pointer;
        padding: 4px;
    }
    .m-perms-card {
        background: rgba(255,255,255,0.05);
        border-radius: 8px;
        padding: 10px 12px;
        margin-bottom: 16px;
    }
    .m-perms-title {
        font-size: 13px;
        font-weight: 600;
        margin-bottom: 8px;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .m-perms-title.ok { color: #2dd4bf; }
    .m-perms-title.danger { color: #ef4444; }
    .m-perm-chip {
        display: inline-block;
        font-size: 11px;
        padding: 2px 8px;
        border-radius: 10px;
        margin: 2px;
        border: 1px solid #1e293b;
        color: #94a3b8;
        background: #0f172a;
    }
    .m-perm-chip.danger {
        color: #f87171;
        border-color: rgba(248,113,113,0.3);
        background: rgba(248,113,113,0.1);
    }
    .m-perm-chip.danger {
        border-color: #ef4444;
        color: #ef4444;
        background: rgba(239,68,68,0.1);
    }

    #mOrdersContainer {
        padding: 8px 12px 12px;
        min-height: 100px;
    }

    .m-order-empty,
    .m-order-loading {
        text-align: center;
        color: #6b7280;
        padding: 32px 0;
        font-size: 14px;
    }

    .m-order-loading i {
        margin-right: 6px;
    }

    /* Offer / Credit card */
    .m-ocard {
        background: #1e1e1e;
        border-radius: 10px;
        padding: 12px 16px;
        margin-bottom: 8px;
        position: relative;
        overflow: hidden;
    }

    .m-ocard.offer-usd { background: #1e1e1e; background: linear-gradient(90deg, rgba(59,130,246,0.12) 0%, #1e1e1e 60%); }
    .m-ocard.offer-usdt { background: #1e1e1e; background: linear-gradient(90deg, rgba(38,161,123,0.12) 0%, #1e1e1e 60%); }

    /* Credit card: dark base + progress bar + overlay */
    .m-ocard.credit {
        background: #1e1e1e;
    }

    .m-ocard-overlay {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,0.35);
    }

    .m-ocard-top {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .m-cur-badge {
        font-size: 11px;
        font-weight: 700;
        padding: 2px 6px;
        border-radius: 4px;
    }

    .m-cur-badge.usd {
        background: rgba(59,130,246,0.3);
        color: #3b82f6;
    }

    .m-cur-badge.usdt {
        background: rgba(38,161,123,0.3);
        color: #26A17B;
    }

    .m-ocard-amount {
        font-size: 16px;
        font-weight: 700;
        flex: 1;
    }

    .m-ocard-apr {
        font-size: 15px;
        font-weight: 700;
        color: #2dd4bf;
    }

    .m-ocard-bottom {
        display: flex;
        align-items: center;
        margin-top: 8px;
        font-size: 11px;
        color: #9ca3af;
        gap: 4px;
    }

    .m-ocard-bottom .spacer {
        flex: 1;
    }

    .m-pending-dot {
        display: inline-block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #f97316;
        margin-right: 4px;
    }

    .m-pending-text {
        color: #f97316;
    }

    .m-expiry-urgent {
        color: #ef4444;
        font-weight: 700;
    }

    /* Credit progress bar background */
    .m-ocard-progress {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        opacity: 0.30;
    }

    .m-ocard-progress.sniper { background: #8b5cf6; }
    .m-ocard-progress.ambush { background: #f97316; }
    .m-ocard-progress.normal { background: #6b7280; }

    .m-credits-summary {
        display: flex;
        justify-content: space-between;
        padding: 8px 4px;
        font-size: 12px;
        color: #9ca3af;
        margin-bottom: 4px;
    }

    .m-credits-summary strong {
        color: #f8fafc;
    }

    /* Tab sections: hidden by default on mobile, shown when active */
    .card[data-tab],
    .m-card[data-tab],
    .m-appbar[data-tab] {
        display: none !important;
        opacity: 0;
        transition: opacity 0.15s ease;
    }

    .card[data-tab].tab-visible,
    .m-card[data-tab].tab-visible,
    .m-appbar[data-tab].tab-visible {
        display: block !important;
        opacity: 1;
    }

    /* The settings appbar carries a language toggle: flex (same specificity as
       the rule above, so keep it after). */
    .m-appbar[data-tab="settings"].tab-visible {
        display: flex !important;
    }

    /* No language toggle on the phone home appbar (owner decision; it stays on
       the settings appbar, the sign-in card and desktop). With it gone the
       home appbar goes back to its original inline layout, so the Chinese
       phone page is identical at every width, including a timestamp that
       wraps under the title on very narrow screens. That layout already has a
       real space between title and timestamp, so drop the flex-only spacer. */
    .m-appbar[data-tab="home"] .lang-toggle {
        display: none;
    }
    .m-appbar[data-tab="home"] .m-last-update::before {
        content: none;
    }

    /* Bottom navigation */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 58px;
        background: #1e1e1e;
        border-top: 1px solid rgba(255,255,255,0.08);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
    }
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    padding: 6px 0;
    transition: color 0.15s;
}

.nav-tab i {
    font-size: 1.1rem;
    padding: 4px 16px;
    border-radius: 14px;
    transition: background 0.2s, color 0.2s;
}

.nav-tab span {
    font-size: 0.68rem;
    font-weight: 500;
}

.nav-tab.active {
    color: #b8d8c8;
}

.nav-tab.active i {
    background: rgba(200,230,210,0.12);
    color: #b8d8c8;
}

/* Active loans count inline display */
.active-loans-count {
    font-size: 0.85em;
    font-weight: normal;
    color: #94a3b8;
    margin-left: 0.5em;
}

/* Funding Credits Section */
.credits-container {
    height: 750px; /* Greatly increased height matching offers-container */
    overflow-y: auto;
}

.credit-summary {
    background: linear-gradient(135deg, #14532d, #052e16);
    color: white;
    border-radius: 8px;
    padding: 10px 14px; /* More compact summary */
    margin-bottom: 8px; /* Minimal margin */
    box-shadow: 0 4px 15px rgba(20, 83, 45, 0.4);
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* More compact stats */
    gap: 8px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.75rem; /* Smaller labels */
    opacity: 0.9;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.1rem; /* Slightly smaller values to save space */
    font-weight: 700;
    color: #fff;
}

.credits-sort-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    padding: 4px 0;
    border-bottom: 1px solid #334155;
}

.sort-btn {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 4px;
    color: #94a3b8;
    font-size: 0.75rem;
    padding: 3px 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sort-btn:hover {
    background: #334155;
    color: #f1f5f9;
    border-color: #64748b;
}

.sort-btn.sort-active {
    background: #0f4c81;
    border-color: #3b82f6;
    color: #f1f5f9;
}

.sort-ind {
    font-size: 0.65rem;
    opacity: 0.5;
    margin-left: 2px;
}

.sort-ind.active {
    opacity: 1;
    color: #60a5fa;
}


.strategy-badge { padding: 2px 8px; border-radius: 4px; font-size: 0.8em; font-weight: bold; }
.label-normal  { background: #1e3a2f; color: #4ade80; }
.label-ambush  { background: #3b2200; color: #fb923c; }
.label-sniper  { background: #1e1b4b; color: #a78bfa; }

.credit-item {
    background: #334155;
    border-radius: 6px;
    padding: 5px 8px;
    margin-bottom: 4px; /* Minimal margin */
    border-left: 3px solid #2dd4bf;
    transition: all 0.3s ease;
    border: 1px solid #475569;
    border-left: 3px solid #2dd4bf;
}

.credit-item:hover {
    background: #475569;
    transform: translateX(5px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border-color: #64748b;
    border-left: 3px solid #2dd4bf;
}

.credit-info {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}

.credit-detail {
    text-align: center;
    min-width: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

.credit-detail-label {
    font-size: 0.72rem;
    color: #cbd5e1;
    margin-bottom: 2px;
    white-space: nowrap;
}

.credit-detail-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: #f8fafc;
    white-space: nowrap;
}

.timestamp-text {
    font-size: 0.68rem;
    font-family: 'SFMono-Regular', 'Roboto Mono', monospace;
    letter-spacing: 0.04em;
    color: #cbd5e1;
    font-weight: 500;
}

.credit-status {
    background: #28a745;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.remaining-time {
    color: #3b82f6;
    font-weight: 600;
    font-size: 1em;
}

.remaining-time:contains("已到期") {
    color: #ef4444;
    font-weight: 700;
}

.start-time {
    color: #64748b;
    font-size: 0.9em;
}

.version-info {
    color: #cbd5e1;
    font-size: 0.7rem;
    margin: 0 5px;
}

.version-info small {
    background: rgba(109, 40, 217, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
    color: #8b5cf6;
}

/* Tab Buttons */
.tab-buttons {
    display: flex;
    gap: 8px;
}

.tab-btn {
    padding: 6px 12px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #1e293b;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.tab-btn:hover {
    background: #334155;
    border-color: #64748b;
}

.tab-btn.active {
    background: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}

.tab-btn i {
    font-size: 0.75rem;
}

/* History Items */
.history-item {
    opacity: 0.9;
    border-left: 3px solid #64748b;
}

.status-cancelled {
    background: #ef4444;
    color: white;
}

.status-pending {
    background: #f59e0b;
    color: white;
}

/* Market Analysis Styles */
.market-analysis .card-body {
    padding: 0;
}

.market-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding: 20px;
    background: rgba(15, 23, 42, 0.5);
}

.market-metric {
    background: #1e293b;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #475569;
    transition: all 0.3s ease;
}

.market-metric:hover {
    background: #334155;
    transform: translateY(-2px);
}

.metric-icon {
    font-size: 1.5rem;
    min-width: 32px;
    text-align: center;
}

.metric-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f8fafc;
}

.metric-value.opportunity-active {
    color: #f97316;
}

.metric-value.opportunity-none {
    color: #94a3b8;
}

.position-assessment {
    margin: 20px;
    padding: 16px;
    border-radius: 8px;
    border: 2px solid #475569;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.5);
}

.position-assessment.excellent {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.position-assessment.good {
    border-color: #06b6d4;
    background: rgba(6, 182, 212, 0.1);
}

.position-assessment.fair {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.position-assessment.poor {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.assessment-icon {
    font-size: 1.5rem;
    min-width: 32px;
}

.assessment-text {
    font-weight: 600;
    color: #f8fafc;
}

.competitive-rates {
    margin: 20px;
}

.competitive-rates h3 {
    color: #f8fafc;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.rates-table-container,
.trends-table-container,
.depth-table-container {
    background: #1e293b;
    border-radius: 8px;
    border: 1px solid #475569;
    overflow: hidden;
}

.rates-table,
.trends-table,
.depth-table {
    width: 100%;
    border-collapse: collapse;
}

.rates-table th,
.rates-table td,
.trends-table th,
.trends-table td,
.depth-table th,
.depth-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #374151;
}

.rates-table th,
.trends-table th,
.depth-table th {
    background: #0f172a;
    color: #f8fafc;
    font-weight: 600;
    font-size: 0.9rem;
}

.rates-table td,
.trends-table td,
.depth-table td {
    color: #d1d5db;
    font-size: 0.9rem;
}

.rates-table tbody tr:hover,
.trends-table tbody tr:hover,
.depth-table tbody tr:hover {
    background: #374151;
}

.market-tab {
    min-height: 400px;
}

.trends-container,
.depth-container {
    padding: 20px;
}

.trends-container h3,
.depth-container h3 {
    color: #f8fafc;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.collection-stats {
    margin-top: 24px;
    padding: 16px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    border: 1px solid #475569;
}

.collection-stats h4 {
    color: #f8fafc;
    margin-bottom: 16px;
    font-size: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.stat-label {
    font-size: 0.9rem;
    color: #94a3b8;
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #f8fafc;
}

/* Market view selector styling */
#marketViewSelect {
    background: #374151;
    color: #f8fafc;
    border: 1px solid #475569;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.8rem;
}

#marketViewSelect:focus {
    outline: none;
    border-color: #6d28d9;
}

/* Responsive design */
@media (max-width: 768px) {
    .market-summary-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 16px;
    }

    .rates-table-container,
    .trends-table-container,
    .depth-table-container {
        overflow-x: auto;
    }

    .rates-table,
    .trends-table,
    .depth-table {
        min-width: 600px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Parameter Settings Modal */
#parameterSettingsModal .modal-content {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h4 {
    color: #f8fafc;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    border-bottom: 1px solid #475569;
    padding-bottom: 8px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.setting-item {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: #e2e8f0;
    gap: 8px;
    width: 100%;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 16px;
    height: 16px;
    background: #334155;
    border: 2px solid #64748b;
    border-radius: 3px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 11px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.checkbox-label:hover .checkmark {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #475569;
}

/* Current strategy info in parameter settings */
.current-strategy-info {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    border: 1px solid #3b82f6;
}

.current-strategy-info p {
    margin: 4px 0;
    color: #e2e8f0;
}

.current-strategy-info p:first-child {
    color: #ffffff;
    font-weight: 600;
}

.current-strategy-info small {
    color: #cbd5e1;
    font-size: 0.85em;
}

/* Performance Analytics Styles */
.performance-analytics {
    margin-bottom: 20px;
}

.performance-tab {
    animation: fadeIn 0.3s ease-in;
}

/* Real-time Metrics Grid */
.realtime-metrics-grid,
.competitive-metrics-grid,
.profitability-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: linear-gradient(135deg, #1e293b, #334155);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #475569;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    border-color: #6d28d9;
}

.metric-icon {
    font-size: 2rem;
    margin-right: 12px;
    opacity: 0.9;
}

.metric-content {
    flex: 1;
}

.metric-label {
    font-size: 0.85rem;
    color: #cbd5e1;
    margin-bottom: 4px;
    display: block;
}

.metric-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f8fafc;
    display: block;
}

/* Alerts Section */
.alerts-section,
.recommendations-section {
    margin-top: 24px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #475569;
}

.alerts-section h3,
.recommendations-section h3 {
    color: #f8fafc;
    font-size: 1.1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alerts-container,
.recommendations-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-item {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    border-radius: 6px;
    padding: 8px 12px;
    color: #fecaca;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-item.warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: #f59e0b;
    color: #fcd34d;
}

.alert-item.info {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #93c5fd;
}

.recommendation-item {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid #2dd4bf;
    border-radius: 6px;
    padding: 8px 12px;
    color: #bbf7d0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Strategies Table */
.strategies-table-container {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    border: 1px solid #475569;
    overflow-x: auto;
}

.strategies-table {
    width: 100%;
    border-collapse: collapse;
}

.strategies-table th,
.strategies-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #475569;
    color: #f8fafc;
}

.strategies-table th {
    background: rgba(30, 41, 59, 0.8);
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.9rem;
}

.strategies-table tr:hover {
    background: rgba(51, 65, 85, 0.3);
}

/* Comprehensive Report */
.comprehensive-report {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    border: 1px solid #475569;
    padding: 20px;
}

.report-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #475569;
}

.report-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.report-section h4 {
    color: #f8fafc;
    font-size: 1.1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.report-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.report-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 41, 59, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #475569;
}

.report-metric-label {
    font-size: 0.85rem;
    color: #cbd5e1;
}

.report-metric-value {
    font-weight: 600;
    color: #f8fafc;
}

/* Loading States */
.loading-small {
    color: #cbd5e1;
    font-style: italic;
    font-size: 0.9rem;
    text-align: center;
    padding: 8px;
}

/* Tab switching animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Success/positive values */
.metric-value.positive,
.report-metric-value.positive {
    color: #4ade80;
}

/* Warning/neutral values */
.metric-value.neutral,
.report-metric-value.neutral {
    color: #facc15;
}

/* Error/negative values */
.metric-value.negative,
.report-metric-value.negative {
    color: #f87171;
}

/* Currency Level Controls */
.balance-value-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.currency-control {
    display: flex;
    gap: 5px;
    margin-left: 8px;
}

.btn-xs {
    padding: 2px 6px;
    font-size: 0.7rem;
    border-radius: 4px;
}

.currency-control .btn-start {
    background-color: #10b981;
    border-color: #059669;
    color: white;
}

.currency-control .btn-stop {
    background-color: #ef4444;
    border-color: #dc2626;
    color: white;
}

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

.reserve-info {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.reserve-value {
    color: #cbd5e1;
    font-weight: 500;
}

.edit-reserve {
    color: #6366f1;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.7rem;
}

.edit-reserve:hover {
    color: #818cf8;
}

/* Opportunities Timeline */
.border-sniper {
    border-left: 4px solid #ef4444 !important;
}

.border-presage {
    border-left: 4px solid #f59e0b !important;
}

.text-info {
    color: #3b82f6 !important;
}

.text-warning {
    color: #f59e0b !important;
}

/* Strategy Analytics Section */
.strategy-analytics-section .card-body {
    padding: 0;
}

.analytics-subsection {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color, #333);
}

.analytics-subsection:last-child {
    border-bottom: none;
}

.analytics-subsection h3 {
    font-size: 0.9rem;
    color: var(--text-secondary, #aaa);
    margin-bottom: 0.75rem;
}

.analytics-subsection h3 i {
    margin-right: 0.5rem;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.analytics-stat {
    background: var(--card-bg-secondary, #1a1a2e);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
}

.analytics-stat .stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
    margin-bottom: 0.25rem;
}

.analytics-stat .stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
}

.analytics-currency-select,
.analytics-days-select {
    background: var(--card-bg, #16213e);
    color: var(--text-primary, #fff);
    border: 1px solid var(--border-color, #333);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.suggestions-container {
    font-size: 0.85rem;
    line-height: 1.6;
}

.suggestions-container .suggestion-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color, #333);
}

.decisions-table-container {
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

.decisions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.decisions-table th,
.decisions-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color, #333);
}

.decisions-table th {
    background: var(--card-bg-secondary, #1a1a2e);
    position: sticky;
    top: 0;
    z-index: 1;
}

.decisions-table .type-SNIPER { color: #a78bfa; font-weight: 600; }
.decisions-table .type-PRESAGE_HOLD { color: #f59e0b; font-weight: 600; }
.decisions-table .type-AMBUSH_ONLY { color: #8b5cf6; font-weight: 600; }
.decisions-table .type-AMBUSH_MIXED { color: #a78bfa; }
.decisions-table .type-NORMAL { color: #10b981; }
