:root {
  --bg: #f6f7fb; --surface: #fff; --border: #e2e8f0;
  --text: #1e293b; --muted: #64748b; --accent: #f6465d;
  --green: #0ecb81; --red: #f6465d; --amber: #e8b923;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
code { background: #eef2f7; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* Login */
.login-body { display:flex; align-items:center; justify-content:center; min-height:100vh; background: linear-gradient(135deg,#1e293b 0%,#334155 100%); }
.login-card { background:var(--surface); padding:40px 36px; border-radius:14px; box-shadow:0 20px 50px rgba(0,0,0,.25); width:380px; max-width:90vw; }
.brand { font-size:1.6rem; font-weight:800; margin:0 0 4px; letter-spacing:-.5px; }
.brand-sub { color:var(--muted); font-size:.78rem; margin:0 0 28px; text-transform:uppercase; letter-spacing:1.2px; }
.login-card form label { display:block; font-size:.8rem; color:var(--muted); text-transform:uppercase; letter-spacing:.5px; margin-bottom:14px; font-weight:600; }
.login-card input { display:block; width:100%; padding:11px 14px; margin-top:6px; border:1px solid var(--border); border-radius:8px; font-size:.95rem; background:#f8fafc; transition:border-color .15s; }
.login-card input:focus { outline:none; border-color:var(--accent); background:#fff; }
.login-card button { width:100%; padding:12px; margin-top:10px; background:var(--accent); color:#fff; border:none; border-radius:8px; font-weight:700; font-size:.95rem; cursor:pointer; transition:background .15s; }
.login-card button:hover { background:#e23548; }
.err { color:var(--red); font-size:.85rem; margin:14px 0 0; padding:10px; background:#ffeaea; border-radius:6px; }

/* Top bar */
.topbar { background:var(--surface); border-bottom:1px solid var(--border); padding:14px 24px; display:flex; justify-content:space-between; align-items:center; box-shadow:var(--shadow); }
.brand-row, .wallet-row { display:flex; align-items:center; gap:14px; }
.brand-mini { font-weight:800; font-size:1.05rem; }
.user-chip { background:#eef2f7; color:var(--muted); padding:4px 10px; border-radius:6px; font-size:.78rem; font-weight:600; }
.src-chip { background:#fef3c7; color:#92400e; padding:3px 8px; border-radius:4px; font-size:.7rem; font-weight:600; text-transform:uppercase; letter-spacing:.5px; }
.wallet-label { color:var(--muted); font-size:.72rem; text-transform:uppercase; font-weight:700; letter-spacing:.5px; }
.wallet-value { color:var(--green); font-weight:800; font-size:1.05rem; }
.btn-mini { background:#fff; border:1px solid var(--border); padding:6px 12px; border-radius:6px; font-size:.82rem; font-weight:600; cursor:pointer; color:var(--text); transition:all .15s; }
.btn-mini:hover { border-color:var(--accent); color:var(--accent); }
.btn-logout:hover { border-color:var(--red); color:var(--red); }

/* Indices Strip (Market Tracker Cards) */
.indices-strip { 
    display: flex; gap: 20px; padding: 24px; 
    background: var(--bg); border-bottom: 1px solid var(--border); 
    overflow-x: auto; white-space: nowrap; 
    justify-content: center; 
}
.idx-card { 
    display: flex; flex-direction: column; gap: 4px; 
    min-width: 180px; 
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease-in-out;
}
.idx-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    border-color: #cbd5e1;
}
.idx-name { font-size: 0.75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; }
.idx-px { font-size: 1.4rem; font-weight: 800; color: var(--text); margin-top: 2px;}
.idx-chg { font-size: 0.85rem; font-weight: 700; }
.idx-chg.pos { color: var(--green); }
.idx-chg.neg { color: var(--red); }

/* News strip with Marquee Scroll */
.news-strip { 
    background: #f8fafc; border-bottom: 1px solid var(--border); 
    display: flex; align-items: center; padding: 10px 24px; 
    font-size: .85rem; gap: 14px; overflow: hidden; 
}
.news-tag { 
    color: var(--accent); font-weight: 800; flex-shrink: 0; 
    text-transform: uppercase; letter-spacing: .5px; font-size: .75rem; 
    z-index: 2; background: #f8fafc; padding-right: 12px; 
}
.news-track { 
    color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; 
    flex: 1; position: relative; 
}
#news-text { 
    display: inline-block; 
    padding-left: 100%; 
    animation: marquee 80s linear infinite; /* Slowed down from 35s to 80s */
}
#news-text:hover { animation-play-state: paused; } /* Pauses if you hover over it to read */
@keyframes marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }

/* Tabs */
.tabs { background:var(--surface); border-bottom:1px solid var(--border); padding:0 24px; display:flex; gap:0; overflow-x:auto; }
.tab { background:none; border:none; padding:14px 18px; font-weight:600; font-size:.88rem; color:var(--muted); cursor:pointer; border-bottom:2px solid transparent; transition:all .15s; white-space:nowrap; }
.tab:hover { color:var(--text); }
.tab.active { color:var(--accent); border-bottom-color:var(--accent); }

/* Panels & Cards */
.panel { padding:24px; max-width:1400px; margin:0 auto; }
.panel.hidden { display:none; }
.panel h2 { margin:0 0 16px; font-size:1.2rem; font-weight:700; }
.panel h2 small { color:var(--muted); font-weight:500; font-size:.8rem; margin-left:8px; }
.muted { color:var(--muted); }
.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr)); gap:14px; }
.card { background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:16px; box-shadow:var(--shadow); position:relative; transition:transform .12s; }
.card:hover { transform:translateY(-1px); }
.card-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.card-ticker { font-weight:800; font-size:1.05rem; }
.action-pill { padding:3px 11px; border-radius:14px; font-size:.72rem; font-weight:800; letter-spacing:.5px; }
.pill-buy  { background:#dcfce7; color:#15803d; }
.pill-sell { background:#fee2e2; color:#b91c1c; }
.stat { display:flex; justify-content:space-between; padding:5px 0; font-size:.85rem; border-bottom:1px dashed #f1f5f9; }
.stat:last-child { border:none; }
.stat-label { color:var(--muted); }
.stat-val { font-weight:600; }
.stat-pos { color:var(--green); }
.stat-neg { color:var(--red); }
.card-actions { display:flex; gap:8px; margin-top:12px; }
.card-actions button { flex:1; padding:8px; border:1px solid var(--border); border-radius:6px; background:#fff; font-weight:600; font-size:.82rem; cursor:pointer; }
.card-actions .btn-buy  { background:var(--green); color:#fff; border-color:var(--green); }
.card-actions .btn-sell { background:var(--red);   color:#fff; border-color:var(--red);   }
.card-actions .btn-close{ background:#fff; color:var(--text); }
button[disabled] { opacity:.4; cursor:not-allowed; }

/* Holdings extra */
.hcard { background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:14px; margin-bottom:10px; box-shadow:var(--shadow); }
.hcard-head { display:flex; justify-content:space-between; margin-bottom:8px; }
.hcard-pnl { font-weight:800; font-size:1.05rem; }

/* Standard Tables */
.trade-table { width:100%; border-collapse:collapse; background:var(--surface); border-radius:8px; overflow:hidden; box-shadow:var(--shadow); font-size:.85rem; }
.trade-table th, .trade-table td { padding:10px 12px; text-align:left; border-bottom:1px solid var(--border); }
.trade-table th { background:#f8fafc; font-weight:700; color:var(--muted); text-transform:uppercase; font-size:.72rem; letter-spacing:.5px; }
.trade-table tr:last-child td { border-bottom:none; }

/* 🌟 AESTHETIC EXPLORE TABLE (Floating Card Rows) 🌟 */
.explore-table { border-collapse: separate; border-spacing: 0 10px; background: transparent; box-shadow: none; border: none; }
.explore-table th { background: transparent; padding: 0 16px 8px; border-bottom: none; color: var(--muted); }
.explore-table tbody tr { background: var(--surface); box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: transform 0.2s, box-shadow 0.2s; }
.explore-table tbody tr:hover { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(0,0,0,0.1); }
.explore-table td { padding: 16px; border-bottom: none; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.explore-table td:first-child { border-left: 1px solid var(--border); border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
.explore-table td:last-child { border-right: 1px solid var(--border); border-top-right-radius: 10px; border-bottom-right-radius: 10px; }

/* 🌟 MOMENTUM SPARKLINE SVG 🌟 */
.spark-svg { width: 120px; height: 32px; overflow: visible; display: block; margin: auto 0; }
.spark-past { fill: none; stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.spark-future { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 4,4; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; }
.spark-dot { stroke: #fff; stroke-width: 1.5; }
.spark-dot.buy-dot { fill: var(--green); }
.spark-dot.sell-dot { fill: var(--red); }

/* Stats & Charts */
.stats-row { display:flex; gap:14px; margin-bottom:14px; flex-wrap:wrap; }
.stat-box { background:var(--surface); padding:12px 18px; border-radius:8px; border:1px solid var(--border); flex:1; min-width:140px; }
.stat-box-label { color:var(--muted); font-size:.72rem; font-weight:600; text-transform:uppercase; letter-spacing:.5px; }
.stat-box-val { font-size:1.4rem; font-weight:800; margin-top:4px; }
.chart-wrap { background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:16px; box-shadow:var(--shadow); }
.eq-svg { width:100%; height:280px; }
.sub { color:var(--muted); font-size:.95rem; font-weight:700; margin:24px 0 10px; }

/* Modal */
.modal { position:fixed; inset:0; background:rgba(15,23,42,.55); display:flex; align-items:center; justify-content:center; z-index:50; backdrop-filter:blur(4px); }
.modal.hidden { display:none; }
.modal-card { background:var(--surface); border-radius:12px; padding:28px; width:420px; max-width:90vw; box-shadow:0 20px 60px rgba(0,0,0,.3); }
.modal-card h3 { margin:0 0 8px; }
.modal-card label { display:block; font-size:.8rem; color:var(--muted); margin-top:14px; font-weight:600; }
.modal-card input, .modal-card select { width:100%; padding:9px 12px; margin-top:6px; border:1px solid var(--border); border-radius:6px; font-size:.95rem; }
.modal-actions { margin-top:20px; display:flex; gap:10px; }
.btn-primary { flex:1; padding:11px; background:var(--accent); color:#fff; border:none; border-radius:6px; font-weight:700; cursor:pointer; }
.btn-secondary { flex:1; padding:11px; background:#fff; color:var(--text); border:1px solid var(--border); border-radius:6px; font-weight:600; cursor:pointer; }
.result { margin-top:14px; font-size:.85rem; padding:8px; border-radius:6px; }
.result.ok  { background:#dcfce7; color:#15803d; }
.result.err { background:#fee2e2; color:#b91c1c; }
.toast { position:fixed; bottom:24px; right:24px; background:var(--text); color:#fff; padding:12px 18px; border-radius:8px; font-size:.85rem; box-shadow:0 8px 24px rgba(0,0,0,.2); z-index:60; max-width:340px; }
.toast.hidden { display:none; }
.toast.err { background:var(--red); }
.toast.ok  { background:var(--green); }
.filters { display:flex; gap:18px; margin-bottom:16px; }
.inline-form { display:flex; gap:10px; margin-bottom:18px; }
.inline-form input { flex:1; padding:9px 12px; border:1px solid var(--border); border-radius:6px; font-size:.9rem; }
.inline-form button { background:var(--accent); color:#fff; border:none; padding:9px 18px; border-radius:6px; font-weight:600; cursor:pointer; }
.actions-row { display:flex; gap:10px; margin-bottom:14px; flex-wrap:wrap; }
.actions-row .btn-primary { width:auto; padding:9px 18px; }

/* Bot Cards */
.bot-card { border-left:3px solid var(--accent); }
.bot-status { padding:3px 10px; border-radius:14px; font-size:.7rem; font-weight:800; letter-spacing:.5px; text-transform:uppercase; }
.status-running { background:#dcfce7; color:#15803d; }
.status-paused  { background:#fef3c7; color:#92400e; }
.status-stopped { background:#e2e8f0; color:#475569; }
.bot-badge { background:#eef2f7; color:var(--muted); padding:2px 8px; border-radius:4px; font-size:.65rem; font-weight:600; margin-left:6px; }

/* ============ AUTO-TRADER PANEL (3-COLUMN UI) ============ */
.autotrade-grid { display: grid; grid-template-columns: 1.1fr 1fr 0.9fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .autotrade-grid { grid-template-columns: 1fr; } }
.at-col { min-width: 0; }
.at-section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding-left: 2px; }
.at-section-bar { width: 4px; height: 18px; background: var(--accent); border-radius: 2px; display: inline-block; }
.bar-amber { background: var(--amber); }
.bar-red   { background: var(--red); }
.at-section-title { font-weight: 700; font-size: 0.92rem; color: var(--text); }
.at-section-title small { color: var(--muted); margin-left: 6px; font-weight: 500; }
.at-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }

.trade-ref { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 10px 14px; }
.trade-ref-label { font-size: .68rem; color: #3b82f6; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; margin-bottom: 2px; }
.trade-ref-val { font-size: 1.15rem; font-weight: 800; color: #1d4ed8; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace; }

.cfg-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cfg-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.at-card fieldset { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.at-card fieldset legend { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; margin-bottom: 4px; padding: 0; }
.at-card fieldset label { display: flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 500; cursor: pointer; margin: 0; }
.at-card fieldset input[type="radio"] { margin: 0; }

.at-field { display: flex; flex-direction: column; gap: 4px; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; margin: 0; min-width: 0; }
.at-field input, .at-field select { width: 100%; min-width: 0; margin-top: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: .9rem; font-weight: 500; color: var(--text); background: #fff; text-transform: none; letter-spacing: 0; }
.at-field input:focus, .at-field select:focus { outline: none; border-color: var(--accent); }

.at-note { font-size: .78rem; color: var(--muted); margin: 0; }
.at-btn-wide { width: 100%; padding: 10px; }
.callout-info { background: #fff8e6; border: 1px solid #fde68a; color: #92400e; padding: 10px 12px; border-radius: 6px; font-size: .82rem; margin: 0; }
.at-divider { height: 1px; background: var(--border); margin: 4px 0; }

.feas-empty { padding: 18px; text-align: center; background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; border-radius: 8px; font-size: .9rem; }
.feas-result { display: flex; flex-direction: column; gap: 10px; }
.feas-verdict { padding: 12px 14px; border-radius: 8px; font-size: .9rem; font-weight: 600; line-height: 1.45; }
.feas-verdict.ok   { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.feas-verdict.fail { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.feas-row { display: flex; justify-content: space-between; font-size: .85rem; padding: 6px 0; border-bottom: 1px dashed #f1f5f9; }
.feas-row:last-of-type { border: none; }
.feas-row .label { color: var(--muted); }
.feas-row .val { font-weight: 700; }

.sched-status { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 6px; background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; font-weight: 600; font-size: .88rem; }
.sched-status.stopped { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.sched-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 8px #10b981; animation: pulse 1.6s ease-in-out infinite; }
.sched-status.stopped .sched-dot { background: #d97706; box-shadow: none; animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.sched-logs { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace; font-size: .72rem; color: var(--muted); background: #f8fafc; border-radius: 6px; padding: 8px; max-height: 140px; overflow-y: auto; border: 1px solid var(--border); white-space: pre-wrap; line-height: 1.4; }
.sched-logs:empty { display: none; }