/* ═══════════════════════════════════════════════════════════
   TeleTrader Admin Dashboard — Premium Dark Theme
   ═══════════════════════════════════════════════════════════ */

:root {
    /* Core Palette */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(24, 34, 56, 0.85);
    --bg-sidebar: rgba(10, 14, 23, 0.95);

    /* Accent */
    --gold: #F0B90B;
    --gold-dim: rgba(240, 185, 11, 0.15);
    --gold-glow: rgba(240, 185, 11, 0.3);

    /* Text */
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    /* Status */
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.15);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.15);
    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.15);
    --orange: #f59e0b;

    /* Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    /* Spacing */
    --sidebar-width: 220px;
    --header-height: 60px;
    --radius: 12px;
    --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

.hidden { display: none !important; }

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ─── Login Overlay ─────────────────────────────────────── */
.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(240, 185, 11, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.04) 0%, transparent 50%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    width: 380px;
    backdrop-filter: blur(20px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
    animation: fadeInUp 0.5s ease;
}

.login-logo {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 16px rgba(240, 185, 11, 0.3));
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 32px;
}

.login-form label {
    display: block;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'JetBrains Mono', monospace;
    transition: border-color 0.2s;
    outline: none;
}

.login-form input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-dim);
}

.login-form button {
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    background: linear-gradient(135deg, var(--gold), #d4a00a);
    border: none;
    border-radius: var(--radius-sm);
    color: #0a0e17;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.login-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--gold-glow);
}

.login-error {
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 12px;
    min-height: 1.2em;
}

/* ─── App Layout ────────────────────────────────────────── */
.app {
    display: flex;
    height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    backdrop-filter: blur(20px);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 24px;
    border-bottom: 1px solid var(--border);
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.brand-text {
    font-size: 1.05rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gold), #ffd54f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s;
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--gold-dim);
    color: var(--gold);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--gold);
    border-radius: 0 3px 3px 0;
}

.nav-icon { font-size: 1.1rem; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: pulse 2s infinite;
}

.status-dot.offline { background: var(--red); }

/* ─── Main Content ──────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: var(--header-height);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    flex-shrink: 0;
    background: rgba(10, 14, 23, 0.5);
    backdrop-filter: blur(10px);
}

.top-bar-left h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.live-price {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.price-symbol {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.price-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gold);
}

.price-spread {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.market-status-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.market-status-badge.market-open {
    background: var(--green-dim);
    color: var(--green);
}

.market-status-badge.market-break {
    background: rgba(245, 158, 11, 0.15);
    color: var(--orange);
}

.market-status-badge.market-closed {
    background: var(--red-dim);
    color: var(--red);
}

.clock {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ─── Panels ────────────────────────────────────────────── */
.panels-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    background-image:
        radial-gradient(ellipse at 70% 10%, rgba(240, 185, 11, 0.02) 0%, transparent 40%);
}

.panel { display: none; animation: fadeIn 0.3s ease; }
.panel.active { display: block; }

/* ─── Cards ─────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    backdrop-filter: blur(10px);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.card-accent {
    border-color: rgba(240, 185, 11, 0.15);
    background: linear-gradient(135deg, rgba(240, 185, 11, 0.05), var(--bg-card));
}

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

.card-icon { font-size: 1.1rem; }

.card-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.2;
}

.card-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.card-large {
    min-height: 300px;
}

/* ─── Grid ──────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.mt-20 { margin-top: 20px; }

/* ─── Tables ────────────────────────────────────────────── */
.table-container { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-size: 0.72rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    white-space: nowrap;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

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

/* ─── Utility Classes ───────────────────────────────────── */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-gold { color: var(--gold); }
.text-blue { color: var(--blue); }
.text-mono { font-family: 'JetBrains Mono', monospace; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--gold-dim);
    color: var(--gold);
    margin-left: auto;
}

.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }
.badge-gold { background: var(--gold-dim); color: var(--gold); }
.badge-muted { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); }
.badge-ws {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
    border: 1px solid rgba(6, 182, 212, 0.25);
    animation: wsPulse 2s infinite;
}
.badge-poll {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

@keyframes wsPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
    50% { box-shadow: 0 0 8px rgba(6, 182, 212, 0.3); }
}

/* ─── Role Select Dropdown ──────────────────────────────── */
.role-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 4px 24px 4px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-secondary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E") no-repeat right 8px center;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}
.role-select:hover { border-color: var(--border-hover); }
.role-select:focus { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-dim); }
.role-select.role-primary { border-color: var(--gold); color: var(--gold); }
.role-select.role-backup { border-color: var(--blue); color: var(--blue); }
.role-select.role-disabled { border-color: var(--text-muted); color: var(--text-muted); }

.empty-state {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 40px 20px;
}

.scrollable {
    max-height: 500px;
    overflow-y: auto;
}

/* ─── Markdown Content ──────────────────────────────────── */
.markdown-content {
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.markdown-content h1, .markdown-content h2, .markdown-content h3 {
    color: var(--text-primary);
    margin: 16px 0 8px;
    font-weight: 600;
}

.markdown-content h1 { font-size: 1.2rem; }
.markdown-content h2 { font-size: 1.05rem; }
.markdown-content h3 { font-size: 0.95rem; }

.markdown-content ul, .markdown-content ol {
    padding-left: 20px;
    margin: 8px 0;
}

.markdown-content li { margin: 4px 0; }

.markdown-content strong { color: var(--gold); font-weight: 600; }

.markdown-content code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
}

/* ─── Instance Card ─────────────────────────────────────── */
.instance-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.instance-card:hover { background: rgba(255, 255, 255, 0.02); }
.instance-card:last-child { border-bottom: none; }

.instance-avatar {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--gold-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.instance-info { flex: 1; }

.instance-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.instance-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.instance-stats {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ─── Log Entry ─────────────────────────────────────────── */
.log-entry {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

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

.log-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.log-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.log-trigger {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--blue-dim);
    color: var(--blue);
}

.log-duration {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: auto;
}

.log-body {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    font-family: 'JetBrains Mono', monospace;
}

.log-body.collapsed {
    max-height: 80px;
    overflow: hidden;
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.log-body.expanded {
    max-height: none;
}

.log-toggle {
    display: inline-block;
    padding: 3px 12px;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--gold);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.log-toggle:hover {
    background: var(--gold-dim);
    border-color: var(--gold);
}

.log-error {
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 4px;
}

/* ─── News Card ─────────────────────────────────────────── */
.news-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

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

.news-query {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.news-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.news-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ─── Review Card ───────────────────────────────────────── */
.review-card {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.review-card:last-child { border-bottom: none; }

.review-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.review-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
}

.review-body {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    font-family: 'JetBrains Mono', monospace;
}

.review-body.collapsed {
    max-height: 80px;
    overflow: hidden;
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.review-body.expanded {
    max-height: none;
}

.review-strategy-badge {
    font-size: 0.78rem;
    color: var(--gold);
    background: var(--gold-dim);
    border: 1px solid rgba(240, 185, 11, 0.2);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 8px;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* ─── Canvas Charts ─────────────────────────────────────── */
canvas {
    width: 100%;
    height: 450px;
    display: block;
    border-radius: var(--radius-sm);
}

/* ─── Chart Controls ────────────────────────────────────── */
.chart-controls {
    display: flex;
    gap: 12px;
    margin-left: auto;
}

.btn-group {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
}

.btn-sm {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'JetBrains Mono', monospace;
}

.btn-sm:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-sm.active {
    background: var(--gold-dim);
    color: var(--gold);
}

/* ─── Chart Overlay Toggles ─────────────────────────────── */
.chart-overlays {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
    flex-wrap: wrap;
}

.overlay-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: 4px;
}

.overlay-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: all 0.15s;
}

.overlay-btn::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dot-color, var(--text-muted));
    opacity: 0.4;
    transition: opacity 0.15s, box-shadow 0.15s;
}

.overlay-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-secondary);
}

.overlay-btn.active {
    border-color: var(--dot-color, var(--text-muted));
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.overlay-btn.active::before {
    opacity: 1;
    box-shadow: 0 0 6px var(--dot-color, var(--text-muted));
}


/* ─── Action Buttons ────────────────────────────────────── */
.btn-action {
    margin-left: auto;
    padding: 6px 16px;
    border: 1px solid var(--gold);
    border-radius: 6px;
    background: var(--gold-dim);
    color: var(--gold);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action:hover {
    background: rgba(240, 185, 11, 0.25);
    box-shadow: 0 2px 12px var(--gold-dim);
    transform: translateY(-1px);
}

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

.btn-action.loading {
    opacity: 0.6;
    cursor: wait;
}

/* ─── Toast Notification ────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    padding: 12px 24px;
    background: var(--bg-card);
    border: 1px solid var(--gold);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 2000;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: slideInUp 0.3s ease;
}

.toast.toast-error {
    border-color: var(--red);
}

.toast.toast-success {
    border-color: var(--green);
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── News Cards (improved) ─────────────────────────────── */
.news-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    margin-bottom: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.news-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.news-card:last-child { margin-bottom: 0; }

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

.news-time-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.news-headline {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.4;
}

.news-body {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.news-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ─── Intel Text Content ────────────────────────────────── */
.intel-text-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.7;
    transition: max-height 0.4s ease;
}

.intel-text-content.collapsed {
    max-height: 200px;
    overflow: hidden;
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

.intel-text-content strong {
    color: var(--gold);
    font-weight: 600;
}

.intel-text-content em {
    color: var(--text-primary);
    font-style: italic;
}

.intel-h {
    color: var(--text-primary);
    font-weight: 700;
    margin: 12px 0 6px;
}

h2.intel-h { font-size: 1.05rem; }
h3.intel-h { font-size: 0.95rem; }
h4.intel-h { font-size: 0.88rem; color: var(--text-secondary); }

.intel-bullet {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    line-height: 1.5;
}

.intel-bullet-dot {
    color: var(--gold);
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.intel-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    margin-top: 2px;
}

.intel-tag.high { background: var(--red-dim); color: var(--red); }
.intel-tag.medium { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.intel-tag.low { background: var(--green-dim); color: var(--green); }
.intel-tag.ongoing { background: var(--blue-dim); color: var(--blue); }

.intel-toggle-btn {
    display: block;
    width: 100%;
    padding: 8px;
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--gold);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.intel-toggle-btn:hover {
    background: var(--gold-dim);
    border-color: var(--gold);
}

/* ─── Calendar Events (legacy flat) ─────────────────────── */
.cal-event {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.cal-event:last-child { border-bottom: none; }

.cal-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 50px;
}

.cal-currency {
    font-weight: 700;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 36px;
    text-align: center;
}

.cal-currency.high { background: var(--red-dim); color: var(--red); }
.cal-currency.medium { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.cal-currency.low { background: var(--green-dim); color: var(--green); }

.cal-title {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.cal-values {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
}

/* ─── Calendar Event Cards (structured) ─────────────────── */
.cal-event-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, background 0.15s;
}

.cal-event-card:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.03);
}

.cal-event-card:last-child { margin-bottom: 0; }

.cal-event-card.cal-ongoing {
    border-left: 3px solid var(--blue);
    background: rgba(59, 130, 246, 0.04);
}

.cal-event-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    flex-shrink: 0;
}

.cal-impact-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-muted);
}

.cal-impact-dot.high { background: var(--red); box-shadow: 0 0 6px var(--red); }
.cal-impact-dot.medium { background: var(--orange); }
.cal-impact-dot.low { background: var(--green); }
.cal-impact-dot.ongoing { background: var(--blue); box-shadow: 0 0 6px var(--blue); }

.cal-country {
    font-weight: 700;
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.cal-event-center {
    flex: 1;
    min-width: 0;
}

.cal-event-name {
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.cal-event-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.cal-event-right {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.cal-data {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
}

.cal-data-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: 4px;
    opacity: 0.7;
}

.cal-data-actual {
    color: var(--text-primary);
    font-weight: 600;
}

.cal-impact-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    min-width: 50px;
    text-align: center;
}

.cal-impact-badge.high { background: var(--red-dim); color: var(--red); }
.cal-impact-badge.medium { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.cal-impact-badge.low { background: var(--green-dim); color: var(--green); }
.cal-impact-badge.ongoing { background: var(--blue-dim); color: var(--blue); }

/* ─── Animations ────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* ─── Prompt Editor ─────────────────────────────────────── */
.prompt-editor {
    width: 100%;
    min-height: 300px;
    max-height: 600px;
    padding: 16px;
    margin-top: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.prompt-editor:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-dim);
}

/* ─── Indicators Grid ───────────────────────────────────── */
.indicators-grid {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 8px 0;
}

.indicator-group {
    flex: 1;
    min-width: 160px;
}

.indicator-group-title {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.indicator-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.indicator-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    font-size: 0.78rem;
}

.indicator-label {
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    font-size: 0.7rem;
}

.indicator-value {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

/* ─── Instance Cards ────────────────────────────────────── */
.instance-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    transition: all 0.2s;
}

.instance-card:hover {
    border-color: var(--gold-dim);
}

.instance-card.instance-blocked {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.03);
}

.instance-card.instance-blocked:hover {
    border-color: rgba(239, 68, 68, 0.6);
}

.instance-avatar {
    font-size: 1.8rem;
    min-width: 42px;
    text-align: center;
}

.instance-info {
    flex: 1;
    min-width: 0;
}

.instance-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.instance-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.instance-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ─── Hamburger Button (hidden on desktop) ──────────────── */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s;
}
.hamburger-btn:hover { border-color: var(--gold); }
.hamburger-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: all 0.3s;
}
.hamburger-btn.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; }
.hamburger-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ─── Sidebar Backdrop (mobile overlay) ─────────────────── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* ─── Mobile Bottom Navigation ──────────────────────────── */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(10, 14, 23, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border);
    padding: 4px 0;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 2px;
    padding: 6px 4px 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    transition: color 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    min-height: 48px;
}
.mobile-nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 32px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--gold);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.mobile-nav-item.active {
    color: var(--gold);
}
.mobile-nav-item.active::before {
    transform: translateX(-50%) scaleX(1);
}
.mobile-nav-item:active {
    transform: scale(0.92);
}
.mobile-nav-icon {
    font-size: 1.2rem;
    line-height: 1;
}
.mobile-nav-label {
    font-size: 0.62rem;
    letter-spacing: 0.2px;
}

/* ─── More Sheet ────────────────────────────────────────── */
.more-sheet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.more-sheet-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}
.more-sheet {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 210;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    padding: 12px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
.more-sheet.active {
    transform: translateY(0);
}
.more-sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--text-muted);
    margin: 0 auto 12px;
    opacity: 0.4;
}
.more-sheet-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}
.more-sheet-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.more-sheet-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 8px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}
.more-sheet-item:active {
    background: var(--gold-dim);
    border-color: var(--gold);
    color: var(--gold);
    transform: scale(0.96);
}
.more-sheet-icon {
    font-size: 1.5rem;
}

/* ─── Pull-to-Refresh Indicator ─────────────────────────── */
.ptr-indicator {
    display: none;
    text-align: center;
    padding: 12px;
    font-size: 0.78rem;
    color: var(--gold);
    font-weight: 500;
}
.ptr-indicator.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ─── Responsive ────────────────────────────────────────── */

/* Tablets */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .panels-container { padding: 16px; }
    .chart-controls { flex-wrap: wrap; }

    /* Sidebar: hidden by default, overlay when toggled */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--sidebar-width);
        z-index: 95;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
    }
    .sidebar-backdrop { display: block; }
    .hamburger-btn { display: flex; }

    /* Main content takes full width */
    .main-content {
        width: 100%;
    }
}

/* Phones */
@media (max-width: 768px) {
    :root {
        --header-height: 52px;
    }

    body {
        overflow: hidden;
        overscroll-behavior: contain;
    }

    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    /* Hide desktop sidebar nav on mobile, show bottom nav */
    .mobile-nav {
        display: flex;
    }
    .more-sheet-backdrop, .more-sheet {
        display: block;
    }

    /* Top bar adjustments */
    .top-bar {
        padding: 0 12px;
        height: var(--header-height);
    }
    .top-bar-left {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .top-bar-left h2 { font-size: 1rem; }
    .top-bar-right .live-price {
        padding: 4px 8px;
        gap: 6px;
    }
    .top-bar-right .live-price .price-symbol { font-size: 0.65rem; }
    .top-bar-right .live-price .price-value { font-size: 0.82rem; }
    .top-bar-right .live-price .price-spread { display: none; }
    .top-bar-right .clock { font-size: 0.75rem; }

    /* Panels container */
    .panels-container {
        padding: 12px;
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    /* Cards */
    .card {
        padding: 14px 16px;
        border-radius: var(--radius-sm);
    }
    .card-large { min-height: 200px; }
    .card-value { font-size: 1.4rem; }
    .card-header {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Chart section */
    canvas {
        height: 280px;
    }

    /* Chart controls — scrollable instead of hidden */
    .chart-controls {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 8px;
        padding-bottom: 4px;
    }
    .chart-controls::-webkit-scrollbar { display: none; }
    .chart-overlays {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }
    .chart-overlays::-webkit-scrollbar { display: none; }

    .btn-group {
        flex-shrink: 0;
    }
    .btn-sm {
        padding: 6px 12px;
        font-size: 0.72rem;
        min-height: 32px;
    }

    /* Tables — horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    .data-table {
        min-width: 600px;
    }
    .data-table th, .data-table td {
        padding: 8px 10px;
        font-size: 0.72rem;
    }

    /* Forms — stacked */
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    .form-group {
        min-width: 100%;
    }
    .form-group input,
    .form-group select {
        padding: 10px 12px;
        font-size: 0.9rem;
        min-height: 44px;
    }

    /* Trade buttons — full width touch targets */
    .trade-buttons {
        gap: 10px;
    }
    .btn-buy, .btn-sell {
        padding: 14px 16px;
        font-size: 1rem;
        min-height: 50px;
        border-radius: var(--radius);
    }

    /* Action buttons */
    .btn-action {
        padding: 8px 14px;
        font-size: 0.78rem;
        min-height: 36px;
    }

    /* Prompt editor */
    .prompt-editor {
        min-height: 200px;
        max-height: 400px;
        font-size: 0.78rem;
    }

    /* Toast — centered top, above bottom nav */
    .toast {
        left: 12px;
        right: 12px;
        bottom: auto;
        top: calc(var(--header-height) + 8px);
        text-align: center;
        border-radius: var(--radius);
    }

    /* Login card — full width on small screens */
    .login-card {
        width: calc(100% - 32px);
        max-width: 380px;
        padding: 32px 24px;
    }
    .login-logo { width: 56px; height: 56px; }

    /* Instance cards — stacked layout */
    .instance-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .instance-stats {
        width: 100%;
        justify-content: flex-start;
    }

    /* Trade position cards */
    .trade-pos-info {
        flex-wrap: wrap;
        gap: 8px;
    }
    .trade-pos-details {
        flex-wrap: wrap;
        gap: 8px;
    }
    .trade-pos-actions {
        gap: 6px;
    }
    .trade-pos-actions .btn-sm {
        padding: 8px 12px;
        min-height: 36px;
    }

    /* Log entries */
    .log-header {
        flex-wrap: wrap;
        gap: 6px;
    }
    .log-body {
        font-size: 0.75rem;
    }

    /* Review cards */
    .review-header {
        flex-wrap: wrap;
    }

    /* Calendar events */
    .cal-event-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .cal-event-left {
        min-width: auto;
    }
    .cal-event-right {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* News cards */
    .news-card {
        padding: 12px 14px;
    }

    /* Indicator groups — 2 columns on mobile */
    .indicators-grid {
        gap: 12px;
    }
    .indicator-group {
        min-width: 140px;
    }

    /* Markdown content */
    .markdown-content {
        font-size: 0.82rem;
    }

    /* Scrollable sections */
    .scrollable {
        max-height: 400px;
    }

    /* History range selector */
    #history-range-selector {
        margin-left: 0 !important;
        margin-top: 8px;
    }

    /* Badge */
    .badge {
        font-size: 0.65rem;
    }

    /* Empty state */
    .empty-state {
        padding: 24px 16px;
    }

    .mt-20 { margin-top: 14px; }
}

/* Extra small phones */
@media (max-width: 380px) {
    .panels-container { padding: 8px; }
    .card { padding: 12px; }
    .more-sheet-grid { grid-template-columns: repeat(2, 1fr); }
    .mobile-nav-label { font-size: 0.58rem; }
    .card-value { font-size: 1.2rem; }
    canvas { height: 220px; }
}

/* ─── Login Switch Link ─────────────────────────────────── */
.login-switch {
    margin-top: 16px;
    font-size: 0.78rem;
}
.login-switch a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.login-switch a:hover { color: var(--gold); }

/* ─── User Info (Sidebar Footer) ────────────────────────── */
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}
.user-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-role {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.role-admin { background: var(--gold-dim); color: var(--gold); }
.role-user { background: var(--blue-dim); color: var(--blue); }
.btn-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    margin-left: auto;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }
.sidebar-footer {
    flex-direction: column;
    align-items: flex-start;
}

/* ─── Form Elements ─────────────────────────────────────── */
.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.form-group {
    flex: 1;
    min-width: 120px;
}
.form-group label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold-dim);
}
.connect-bot-form { padding: 4px 0; }

/* ─── Trade Form & Buttons ──────────────────────────────── */
.trade-form { padding: 8px 0; }
.trade-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}
.btn-buy, .btn-sell {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-buy {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}
.btn-buy:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
}
.btn-sell {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}
.btn-sell:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

/* ─── Trade Position Card ───────────────────────────────── */
.trade-position-card {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.trade-position-card:hover { background: rgba(255, 255, 255, 0.02); }
.trade-position-card:last-child { border-bottom: none; }
.trade-pos-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}
.trade-pos-ticket {
    font-weight: 600;
    color: var(--text-muted);
}
.trade-pos-details {
    display: flex;
    gap: 16px;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.trade-pos-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.trade-pos-actions .btn-sm {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    background: transparent;
    transition: all 0.15s;
}
.trade-pos-actions .btn-sm:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-dim);
}
.trade-pos-actions .btn-danger {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--red);
}
.trade-pos-actions .btn-danger:hover {
    border-color: var(--red);
    background: var(--red-dim);
}

/* ─── Blocked Instance ──────────────────────────────────── */
.instance-blocked { opacity: 0.5; }

/* ═══════════════════════════════════════════════════════════
   Telegram Feed Panel
   ═══════════════════════════════════════════════════════════ */

.tg-feed {
    max-height: 70vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px;
}

.tg-message {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    transition: all 0.2s;
    position: relative;
}

.tg-message:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.05);
}

.tg-message.has-signal {
    border-left: 3px solid var(--gold);
}

.tg-message.has-ai {
    border-left: 3px solid var(--blue);
}

.tg-msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.tg-channel-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gold);
}

.tg-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}

.tg-msg-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 8px;
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.tg-msg-text.expanded {
    max-height: none;
}

.tg-msg-text.truncated::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to bottom, transparent, rgba(17, 24, 39, 0.95));
}

.tg-msg-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.signal-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.signal-badge.signal-buy {
    background: var(--green-dim);
    color: var(--green);
}

.signal-badge.signal-sell {
    background: var(--red-dim);
    color: var(--red);
}

.signal-badge.signal-close {
    background: var(--blue-dim);
    color: var(--blue);
}

.signal-badge.signal-none {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-muted);
}

.rule-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(240, 185, 11, 0.1);
    color: var(--gold);
    border: 1px solid rgba(240, 185, 11, 0.2);
}

.trades-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ─── AI Analysis Accordion ────────────────────────────── */
.ai-analysis-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--blue-dim);
    color: var(--blue);
    border: 1px solid rgba(59, 130, 246, 0.2);
    margin-left: auto;
}

.ai-analysis-toggle:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: var(--blue);
}

.ai-analysis-panel {
    display: none;
    margin-top: 10px;
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: var(--radius-sm);
    animation: fadeIn 0.3s ease;
}

.ai-analysis-panel.open {
    display: block;
}

.ai-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 12px;
    border-radius: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 700;
}

.ai-score-badge.score-high {
    background: var(--green-dim);
    color: var(--green);
}

.ai-score-badge.score-mid {
    background: rgba(245, 158, 11, 0.15);
    color: var(--orange);
}

.ai-score-badge.score-low {
    background: var(--red-dim);
    color: var(--red);
}

.ai-summary-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-top: 8px;
}

.ai-suggestions-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
}

.ai-suggestions-list li {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 2px 0 2px 16px;
    position: relative;
}

.ai-suggestions-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--blue);
    font-weight: bold;
}

.ai-risk-text {
    font-size: 0.78rem;
    color: var(--orange);
    margin-top: 6px;
    padding-left: 4px;
}

.ai-model-info {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-family: 'JetBrains Mono', monospace;
}
