/* ============================================================
   TRADING SYSTEM - GLOBAL CSS
   Modern dark theme with consistent styling across all pages
   ============================================================ */

/* ==================== CSS VARIABLES ==================== */
:root {
    /* Dark theme colors - inspired by modern trading apps */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #21262d;
    --bg-card-hover: #292e36;
    --bg-elevated: #30363d;

    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --accent: #e94560;
    --accent-hover: #ff6b8a;
    --accent-soft: rgba(233, 69, 96, 0.15);

    --success: #3fb950;
    --success-hover: #46c459;
    --success-soft: rgba(63, 185, 80, 0.15);

    --warning: #d29922;
    --warning-hover: #e0a82e;
    --warning-soft: rgba(210, 153, 34, 0.15);

    --error: #f85149;
    --error-hover: #ff6259;
    --error-soft: rgba(248, 81, 73, 0.15);

    --info: #58a6ff;
    --info-hover: #79b8ff;
    --info-soft: rgba(88, 166, 255, 0.15);

    --border: #30363d;
    --border-muted: #21262d;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* ==================== BASE/RESET STYLES ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

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

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-elevated) var(--bg-secondary);
}

/* ==================== TYPOGRAPHY ==================== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.25;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

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

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

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

code, pre, .mono {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Consolas', monospace;
}

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-info { color: var(--info); }

/* ==================== SKIP LINK (ACCESSIBILITY) ==================== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    z-index: 1000;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 0;
}

/* ==================== NAVIGATION ==================== */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.nav-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.125rem;
}

.nav-brand:hover {
    text-decoration: none;
    color: var(--text-primary);
}

.nav-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #ff8fab);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.3);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-card);
    text-decoration: none;
}

.nav-links a.active {
    color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Connection status indicator */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all var(--transition-normal);
}

.connection-status.connected {
    background: var(--success-soft);
    color: var(--success);
}

.connection-status.connecting {
    background: var(--warning-soft);
    color: var(--warning);
}

.connection-status.disconnected {
    background: var(--error-soft);
    color: var(--error);
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    position: relative;
}

.connection-status.connected .connection-dot::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.3;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.3); opacity: 0; }
}

/* Status indicator (simpler version) */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.status-dot.green { background: var(--success); }
.status-dot.yellow { background: var(--warning); }
.status-dot.red { background: var(--error); }

/* Mobile hamburger menu */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 5px;
    background: none;
    border: none;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition-fast);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    min-height: 40px;
}

.btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

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

.btn:disabled,
.btn.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.3);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 2px 8px rgba(63, 185, 80, 0.3);
}

.btn-success:hover {
    background: var(--success-hover);
    box-shadow: 0 4px 12px rgba(63, 185, 80, 0.4);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    color: #000;
    box-shadow: 0 2px 8px rgba(210, 153, 34, 0.3);
}

.btn-warning:hover {
    background: var(--warning-hover);
    box-shadow: 0 4px 12px rgba(210, 153, 34, 0.4);
    color: #000;
}

.btn-danger {
    background: var(--error);
    color: #fff;
    box-shadow: 0 2px 8px rgba(248, 81, 73, 0.3);
}

.btn-danger:hover {
    background: var(--error-hover);
    box-shadow: 0 4px 12px rgba(248, 81, 73, 0.4);
    color: #fff;
}

.btn-danger-dark {
    background: #8b0000;
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.3);
}

.btn-danger-dark:hover {
    background: #a00000;
    box-shadow: 0 4px 12px rgba(139, 0, 0, 0.4);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

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

.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 10px;
}

.btn-link:hover {
    color: var(--text-primary);
    transform: none;
}

/* Button sizes */
.btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
    min-height: 48px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
    min-height: 32px;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 0.7rem;
    min-height: 26px;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 40px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 32px;
}

.btn-full {
    width: 100%;
}

/* Button with loading spinner */
.btn.loading {
    pointer-events: none;
    position: relative;
}

.btn.loading .btn-text {
    opacity: 0;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Loading spinner (standalone) */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* ==================== FORM INPUTS ==================== */
.form-group {
    margin-bottom: 20px;
}

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

label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 500;
}

.label-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
    display: block;
    margin-top: 2px;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="time"],
input[type="search"],
input[type="tel"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:disabled,
textarea:disabled,
select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-card);
}

/* Checkbox group */
.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 15px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    min-width: 18px;
    min-height: 18px;
    margin-top: 3px;
    cursor: pointer;
}

.checkbox-group label {
    color: var(--text-primary);
    cursor: pointer;
    margin: 0;
}

/* Search box with icon */
.search-box {
    position: relative;
    width: 280px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

/* Password requirements hint */
.password-requirements {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Error text for form fields */
.error-text {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 8px;
}

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

.card:hover {
    border-color: var(--text-muted);
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card.danger {
    border-color: var(--error);
}

.card h2.danger {
    color: var(--error);
}

/* Summary cards (stats) */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-normal);
}

.summary-card:hover {
    border-color: var(--text-muted);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-card-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.summary-card-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.summary-card-value.positive { color: var(--success); }
.summary-card-value.negative { color: var(--error); }
.summary-card-value.neutral { color: var(--text-secondary); }

.summary-card-change {
    font-size: 0.8rem;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.summary-card-change.up { color: var(--success); }
.summary-card-change.down { color: var(--error); }

/* Quick stats (icon-based) */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.quick-stat {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
}

.quick-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.quick-stat-icon.green { background: var(--success-soft); color: var(--success); }
.quick-stat-icon.red { background: var(--error-soft); color: var(--error); }
.quick-stat-icon.yellow { background: var(--warning-soft); color: var(--warning); }
.quick-stat-icon.blue { background: var(--info-soft); color: var(--info); }

.quick-stat-content {
    flex: 1;
}

.quick-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.quick-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ==================== MODALS ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 440px;
    width: 90%;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

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

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

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

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

.modal-icon svg {
    width: 28px;
    height: 28px;
}

.modal h2 {
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 12px;
}

.modal p {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.6;
}

.modal-symbol {
    font-family: 'SF Mono', Monaco, monospace;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions .btn {
    flex: 1;
    max-width: 160px;
}

/* Simple modal (legacy support) */
.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    max-width: 450px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 20px;
}

.modal-content p {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.modal-content ul {
    margin: 0 0 20px 20px;
    color: var(--text-secondary);
}

.modal-content ul li {
    margin-bottom: 8px;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    transform: translateX(120%);
    transition: transform var(--transition-normal);
    max-width: 400px;
}

.toast.show {
    transform: translateX(0);
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-icon svg {
    width: 14px;
    height: 14px;
}

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

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

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

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

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.toast-message {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-primary);
}

/* ==================== ALERTS (Inline) ==================== */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success {
    background: var(--success-soft);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-error {
    background: var(--error-soft);
    border: 1px solid var(--error);
    color: var(--error);
}

.alert-warning {
    background: var(--warning-soft);
    border: 1px solid var(--warning);
    color: var(--warning);
}

.alert-info {
    background: var(--info-soft);
    border: 1px solid var(--info);
    color: var(--info);
}

.alert-dismiss {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
    margin-left: 10px;
    opacity: 0.7;
}

.alert-dismiss:hover {
    opacity: 1;
}

/* Error/Success messages (form style) */
.error-message {
    background: var(--error-soft);
    border: 1px solid var(--error);
    color: var(--error);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    display: none;
}

.success-message {
    background: var(--success-soft);
    border: 1px solid var(--success);
    color: var(--success);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    display: none;
}

/* Info box */
.info-box {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.info-box p {
    margin: 0;
    color: var(--text-secondary);
}

/* Warning banner */
.warning-banner {
    background: var(--error-soft);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 20px;
}

.warning-banner h3 {
    color: var(--error);
    margin-bottom: 10px;
    font-size: 1rem;
}

.warning-banner p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.85rem;
}

/* ==================== STATUS BADGES ==================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-active {
    background: var(--success-soft);
    color: var(--success);
}

.status-long {
    background: var(--success-soft);
    color: var(--success);
}

.status-short {
    background: var(--error-soft);
    color: var(--error);
}

.status-flat {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-secondary);
}

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

/* ==================== TABLES ==================== */
.table-wrapper {
    overflow-x: auto;
}

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

table th {
    text-align: left;
    padding: 14px 16px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}

table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-muted);
    vertical-align: middle;
}

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

table tbody tr:hover {
    background: var(--bg-card-hover);
}

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

/* P&L cells */
.pnl-positive {
    color: var(--success);
}

.pnl-negative {
    color: var(--error);
}

.pnl-neutral {
    color: var(--text-secondary);
}

/* Symbol cells */
.symbol-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.symbol-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--bg-elevated), var(--bg-card));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.symbol-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.symbol-name {
    font-weight: 700;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.95rem;
}

.symbol-exchange {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* ==================== SKELETON LOADING ==================== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
    color: transparent !important;
}

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

.skeleton-text {
    display: inline-block;
    min-width: 60px;
    height: 1.2em;
}

/* ==================== LOG BOX ==================== */
.log-box {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: var(--radius-md);
    font-family: monospace;
    font-size: 0.85rem;
    max-height: 400px;
    overflow-y: auto;
}

.log-entry {
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
    white-space: pre-wrap;
    word-break: break-all;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-secondary);
    margin-right: 10px;
}

.log-level-error { color: var(--error); }
.log-level-warning { color: var(--warning); }
.log-level-info { color: var(--success); }

/* ==================== MAIN CONTENT LAYOUT ==================== */
.main-content {
    padding: 24px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

.container-sm {
    max-width: 1000px;
    margin: 0 auto;
}

.container-xs {
    max-width: 500px;
    margin: 0 auto;
}

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

.page-header-left h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-header-left p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.global-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Grid layouts */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

.grid-wide {
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
}

/* Full-width grid items - responsive handling */
.grid > [style*="grid-column: span 2"] {
    grid-column: 1 / -1;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-icon svg {
    width: 40px;
    height: 40px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto;
}

/* ==================== ENVIRONMENT INFO ==================== */
.env-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.env-item {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: var(--radius-md);
}

.env-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.env-value {
    font-size: 1rem;
    font-weight: 600;
}

.env-value.mode-paper { color: var(--warning); }
.env-value.mode-live { color: var(--error); }
.env-value.connected { color: var(--success); }
.env-value.disconnected { color: var(--error); }

/* ==================== SETTINGS SECTIONS ==================== */
.settings-section {
    margin-bottom: 30px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 15px;
}

/* ==================== UTILITY CLASSES ==================== */
.hidden {
    display: none !important;
}

/* admin-only elements are shown/hidden via JavaScript based on user role */
/* Default: hidden. JS adds .admin-visible class when user is admin */
.admin-only:not(.admin-visible) {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

.d-flex { display: flex; }
.d-grid { display: grid; }
.d-block { display: block; }
.d-inline-block { display: inline-block; }

.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

/* ==================== AUTH PAGES (Login, Register, Setup) ==================== */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 450px;
    width: 100%;
    border: 1px solid var(--border);
}

.auth-card.wide {
    max-width: 500px;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 30px;
}

.auth-logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), #ff8fab);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.3);
}

.auth-logo-text {
    font-size: 1.5rem;
    font-weight: 700;
}

.auth-title {
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.auth-divider {
    text-align: center;
    color: var(--text-secondary);
    margin: 20px 0;
    font-size: 0.9rem;
}

.auth-link {
    text-align: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Step indicator for multi-step auth */
.step-indicator {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: background var(--transition-normal);
}

.step-dot.active {
    background: var(--accent);
}

.step-dot.complete {
    background: var(--success);
}

.step {
    display: none;
}

.step.active {
    display: block;
}

/* Two-factor section */
.two-fa-section {
    text-align: center;
}

.two-fa-icon {
    width: 64px;
    height: 64px;
    background: var(--accent-soft);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 1.8rem;
}

.otp-input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    font-family: monospace;
}

.otp-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 15px;
}

.countdown {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 15px;
}

.countdown.warning {
    color: var(--warning);
}

.countdown.expired {
    color: var(--error);
}

/* ==================== SYNC STATUS INDICATOR ==================== */
.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    transition: all var(--transition-normal);
}

.sync-status.syncing {
    color: var(--warning);
    background: var(--warning-soft);
}

.sync-status.syncing .sync-icon {
    animation: spin 1s linear infinite;
}

.sync-status.stale {
    color: var(--error);
    background: var(--error-soft);
}

.sync-status.synced {
    color: var(--success);
    background: var(--success-soft);
}

.sync-icon {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sync-icon svg {
    width: 100%;
    height: 100%;
}

/* Mobile: hide sync text on small screens */
@media (max-width: 768px) {
    .sync-status .sync-text {
        display: none;
    }

    .sync-status {
        padding: 6px 8px;
    }
}

/* ==================== ADDITIONAL FIXES ==================== */

/* Ensure tables are responsive */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Fix for modal symbols display */
.modal-symbol {
    font-family: 'SF Mono', Monaco, monospace;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Ensure buttons don't overflow their containers */
.btn {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==================== SESSION EXPIRY BANNER ==================== */
.session-expiry-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--warning-soft);
    border-bottom: 1px solid var(--warning);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--warning);
    z-index: 150;
    animation: sessionBannerSlide 0.3s ease-out;
}

@keyframes sessionBannerSlide {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.session-expiry-text {
    font-weight: 500;
}

.session-expiry-extend {
    padding: 4px 12px;
    background: var(--warning);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.session-expiry-extend:hover {
    background: var(--warning-hover);
}

.session-expiry-dismiss {
    padding: 2px 8px;
    background: transparent;
    color: var(--warning);
    border: 1px solid var(--warning);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    transition: all var(--transition-fast);
}

.session-expiry-dismiss:hover {
    background: rgba(210, 153, 34, 0.2);
}

/* Fix potential z-index stacking issues */
.navbar {
    z-index: 100;
}

.modal-overlay {
    z-index: 1000;
}

.toast-container {
    z-index: 2000;
}

/* Ensure cards have proper overflow handling */
.card {
    overflow: hidden;
}

.card > .table-wrapper {
    margin: 0 -20px;
    padding: 0 20px;
}

/* ==================== RESPONSIVE BREAKPOINTS ==================== */
@media (max-width: 1024px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .nav-links {
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 12px;
        display: none;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a {
        padding: 14px 16px;
        width: 100%;
    }

    .connection-status span:not(.connection-dot) {
        display: none;
    }

    .status-indicator span {
        display: none;
    }

    .page-header {
        flex-direction: column;
    }

    .global-actions {
        width: 100%;
    }

    .global-actions .btn {
        flex: 1;
    }

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

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

    .search-box {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        max-width: none;
    }

    .nav-right {
        gap: 10px;
    }

    .auth-card {
        padding: 30px 20px;
    }
}

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

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

    .main-content {
        padding: 16px;
    }

    .navbar {
        padding: 0 16px;
    }
}
