@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&family=JetBrains+Mono:wght@400;600;700&display=swap');

:root {
    --bg: #05070a;
    --panel: #0d1117;
    --panel-alt: #131a23;
    --border: #1e2733;
    --text: #e8edf3;
    --text-dim: #7c8a9a;
    --gold: #d4a94a;
    --gold-dim: #8a733a;
    --call: #2ecc82;
    --put: #ef4b5f;
    --amber: #e8a33d;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    background:
        radial-gradient(ellipse 900px 500px at 15% -10%, rgba(212,169,74,0.07), transparent 60%),
        var(--bg);
    color: var(--text);
    font-family: 'Manrope', system-ui, sans-serif;
    line-height: 1.5;
}

.mono { font-family: 'JetBrains Mono', Consolas, monospace; }

/* ---------- Top bar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand .mark { font-size: 19px; font-weight: 800; letter-spacing: 0.2px; }
.brand .mark .accent { color: var(--gold); }
.brand .tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 3px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.pill {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 5px 11px;
    border-radius: 20px;
    background: var(--panel-alt);
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.pill.live { color: var(--call); border-color: rgba(46,204,130,0.4); background: rgba(46,204,130,0.08); }
.pill.dot::before { content: '●'; margin-right: 6px; font-size: 8px; vertical-align: middle; }

.ghost-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}
.ghost-btn:hover { border-color: var(--gold-dim); color: var(--text); }

/* ---------- Auth screens (login / admin login) ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 42px 42px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 34px 30px;
}
.auth-card .mark { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.auth-card .mark .accent { color: var(--gold); }
.auth-card p.sub { color: var(--text-dim); font-size: 13px; margin: 0 0 26px; }

label { display: block; font-size: 12px; color: var(--text-dim); margin: 16px 0 6px; }
input[type=text], input[type=password], textarea, select {
    width: 100%;
    background: #090c11;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 7px;
    padding: 11px 12px;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 13px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold-dim); }
textarea { min-height: 90px; resize: vertical; }

.primary-btn {
    margin-top: 22px;
    width: 100%;
    background: var(--gold);
    color: #12100a;
    border: none;
    border-radius: 7px;
    padding: 12px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    letter-spacing: 0.2px;
}
.primary-btn:hover { filter: brightness(1.07); }
.primary-btn:disabled { opacity: 0.5; cursor: default; }

.err-text { color: var(--put); font-size: 12.5px; margin-top: 10px; min-height: 16px; }
.hint { color: var(--text-dim); font-size: 11.5px; margin-top: 16px; }

/* ---------- Dashboard shell ---------- */
main { max-width: 980px; margin: 0 auto; padding: 28px; }

/* Hero subscribe toggle */
.hero {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 36px;
    text-align: center;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(ellipse 500px 200px at 50% 0%, rgba(212,169,74,0.08), transparent 70%);
    pointer-events: none;
}
.hero .state-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 14px;
}
.big-toggle {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 8px;
    cursor: pointer;
    user-select: none;
}
.big-toggle .switch {
    width: 56px; height: 32px;
    background: #1a222c;
    border-radius: 20px;
    position: relative;
    transition: background 0.2s;
}
.big-toggle .switch::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 26px; height: 26px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.big-toggle.on .switch { background: rgba(46,204,130,0.18); }
.big-toggle.on .switch::after { transform: translateX(24px); background: var(--call); }
.big-toggle .label { font-size: 16px; font-weight: 800; padding-right: 14px; }
.hero .desc { color: var(--text-dim); font-size: 13px; margin-top: 16px; max-width: 440px; margin-left: auto; margin-right: auto; }

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; text-align: center; }
.stat .num { font-family: 'JetBrains Mono', monospace; font-size: 25px; font-weight: 700; }
.stat .lbl { font-size: 10.5px; color: var(--text-dim); margin-top: 4px; letter-spacing: 0.5px; }
.stat.win .num { color: var(--call); }
.stat.mtg .num { color: var(--amber); }
.stat.loss .num { color: var(--put); }
.stat.rate .num { color: var(--gold); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.panel + .panel { margin-top: 20px; }
.panel h2 { font-size: 13px; color: var(--text-dim); margin: 0 0 14px; font-weight: 700; }

.chartHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.chartHead select { width: auto; font-size: 12px; padding: 7px 9px; }
#chartContainer {
    width: 100%;
    height: 320px;
    touch-action: none;      /* let the chart library own all pinch/pan gestures instead of the page scrolling underneath it */
    overscroll-behavior: contain;
}

/* Signal timeline (log-style, not generic cards) */
#feed { display: flex; flex-direction: column; }
.entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
    animation: slidein 0.25s ease-out;
}
.entry:last-child { border-bottom: none; }
.entry .rail { width: 3px; align-self: stretch; border-radius: 2px; background: var(--border); }
.entry.CALL .rail, .entry.WIN .rail { background: var(--call); }
.entry.PUT .rail, .entry.LOSS .rail { background: var(--put); }
.entry.MTG .rail { background: var(--amber); }
.entry .time { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-dim); width: 62px; flex-shrink: 0; }
.entry .asset { font-weight: 700; font-size: 13.5px; flex: 1; }
.entry .meta { font-size: 11px; color: var(--text-dim); }
@keyframes slidein { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: translateX(0); } }

.tag { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 4px; flex-shrink: 0; }
.tag.CALL { color: var(--call); background: rgba(46,204,130,0.14); }
.tag.PUT { color: var(--put); background: rgba(239,75,95,0.14); }
.tag.WIN { color: var(--call); background: rgba(46,204,130,0.14); }
.tag.MTG { color: var(--amber); background: rgba(232,163,61,0.14); }
.tag.LOSS { color: var(--put); background: rgba(239,75,95,0.14); }

/* ---------- Mobile-first app shell ---------- */
.app-shell { max-width: 480px; margin: 0 auto; padding: 0 16px 90px; }
.topbar { max-width: 480px; margin: 0 auto; padding: 16px; }
.bell-btn {
    position: relative;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 38px; height: 38px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text);
}
.bell-dot {
    position: absolute; top: -3px; right: -3px;
    width: 10px; height: 10px;
    background: var(--put);
    border-radius: 50%;
    border: 2px solid var(--bg);
}

.tab-content { display: none; padding-top: 18px; }
.tab-content.active { display: block; }

.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex;
    background: var(--panel);
    border-top: 1px solid var(--border);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    z-index: 20;
}
.nav-btn {
    flex: 1;
    background: none; border: none;
    color: var(--text-dim);
    font-family: 'Manrope', sans-serif;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 0;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    cursor: pointer;
}
.nav-btn .nav-ic { font-size: 18px; }
.nav-btn.active { color: var(--gold); }

/* ---------- Hero (mobile version) ---------- */
.hero { text-align: left; padding: 20px; }
.hero-top { display: flex; align-items: flex-start; gap: 12px; }
.hero-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(46,204,130,0.14);
    color: var(--call);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.hero.on .hero-icon { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(46,204,130,0.3);} 50% { box-shadow: 0 0 0 8px rgba(46,204,130,0);} }
.hero-copy { flex: 1; }
.hero .big-toggle { margin-top: 6px; padding: 6px 6px 6px 6px; }
.hero .label { font-size: 14px; }
.hero .pill { margin-left: auto; flex-shrink: 0; }
.hero .desc { text-align: left; margin: 14px 0 0; max-width: none; }

/* ---------- Stats (icon-badge version) ---------- */
.stats-row { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { padding: 12px 6px; }
.stat .ic {
    width: 28px; height: 28px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 8px;
    font-size: 13px;
    font-weight: 800;
}
.stat .ic.total { background: rgba(212,169,74,0.16); color: var(--gold); }
.stat .ic.win { background: rgba(46,204,130,0.16); color: var(--call); }
.stat .ic.loss { background: rgba(239,75,95,0.16); color: var(--put); }
.stat .ic.rate { background: rgba(61,142,248,0.16); color: #3d8ef8; }
.stat .num { font-size: 20px; }
.stat .lbl { font-size: 9px; }

/* ---------- Unified trade card (pending -> resolved) ---------- */
.brandcard.pending { border-color: rgba(61,142,248,0.4); }
.brandcard.mtgpending { border-color: rgba(232,163,61,0.5); }
.brandcard.win { border-color: rgba(46,204,130,0.4); }
.brandcard.mtgwin { border-color: rgba(232,163,61,0.4); }
.brandcard.loss { border-color: rgba(239,75,95,0.4); }
.bc-status-row { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 2px; }
.bc-status-pill {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px; font-weight: 700;
    padding: 4px 10px; border-radius: 20px;
}
.bc-status-pill.pending { color: #3d8ef8; background: rgba(61,142,248,0.14); }
.bc-status-pill.mtgpending { color: var(--amber); background: rgba(232,163,61,0.14); }
.bc-countdown { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-dim); }
.bc-pnl { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; text-align: right; }
.bc-pnl.pos { color: var(--call); }
.bc-pnl.neg { color: var(--put); }

.empty-state { text-align: center; color: var(--text-dim); font-size: 13px; padding: 30px 10px; }

/* Branded signal/result cards (Telegram-bot-style layout) */
.brandcard {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(212,169,74,0.06), transparent 45%), #0d1117;
    padding: 16px 18px;
    margin-bottom: 14px;
    animation: slidein 0.25s ease-out;
}
.brandcard .bc-header {
    text-align: center;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 1px;
    font-size: 12.5px;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 10px;
    margin-bottom: 10px;
}
.brandcard .bc-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    padding: 3px 0;
    font-family: 'JetBrains Mono', monospace;
}
.brandcard .bc-row .k { color: var(--text-dim); }
.brandcard .bc-row .v { text-align: right; }
.brandcard .bc-badge {
    text-align: center;
    font-weight: 800;
    font-size: 15px;
    margin: 10px 0;
    padding: 9px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}
.brandcard .bc-badge.win { color: var(--call); background: rgba(46,204,130,0.12); }
.brandcard .bc-badge.mtg { color: var(--amber); background: rgba(232,163,61,0.12); }
.brandcard .bc-badge.loss { color: var(--put); background: rgba(239,75,95,0.12); }
.brandcard .bc-owner { text-align: center; font-size: 11px; color: var(--gold-dim); margin-top: 8px; }
.brandcard img.bc-shot { width: 100%; border-radius: 6px; margin-top: 10px; border: 1px solid var(--border); display: block; }

/* ---------- Admin ---------- */
.admin-shell { max-width: 1180px; margin: 0 auto; padding: 26px 28px 50px; }
.admin-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
td.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.badge { font-size: 10.5px; padding: 2px 7px; border-radius: 10px; font-weight: 700; }
.badge.on { color: var(--call); background: rgba(46,204,130,0.14); }
.badge.off { color: var(--text-dim); background: rgba(124,138,154,0.14); }
.badge.revoked { color: var(--put); background: rgba(239,75,95,0.14); }
.small-btn {
    background: var(--panel-alt);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    margin-right: 6px;
}
.small-btn:hover { border-color: var(--gold-dim); }
.small-btn.danger:hover { border-color: var(--put); color: var(--put); }
#log {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-dim);
    max-height: 220px;
    overflow-y: auto;
    white-space: pre-wrap;
    margin-top: 16px;
}
.feed-drawer {
    background: #090c11;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    margin: 4px 0 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-dim);
    max-height: 160px;
    overflow-y: auto;
}

@media (max-width: 860px) {
    main, .admin-shell { padding: 18px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .admin-grid { grid-template-columns: 1fr; }
}

/* ---------- First-login walkthrough ---------- */
.walkthrough {
    display: none;
    position: fixed; inset: 0;
    background: rgba(5,7,10,0.92);
    align-items: center; justify-content: center;
    z-index: 50;
    padding: 20px;
}
.wt-card {
    width: 100%; max-width: 340px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 30px 24px 24px;
    text-align: center;
    position: relative;
}
.wt-skip {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none;
    color: var(--text-dim);
    font-size: 12px; font-weight: 700;
    cursor: pointer;
}
.wt-icon { font-size: 44px; margin-bottom: 14px; }
.wt-title { font-size: 17px; font-weight: 800; margin-bottom: 10px; }
.wt-desc { font-size: 13px; color: var(--text-dim); line-height: 1.6; min-height: 68px; }
.wt-dots { display: flex; justify-content: center; gap: 6px; margin: 18px 0 4px; }
.wdot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.wdot.active { background: var(--gold); width: 18px; border-radius: 4px; transition: all 0.2s; }
