:root{
    --bg:#020617;
    --bg-soft:#081121;
    --panel:#0f172a;
    --panel-2:#111c34;
    --line:rgba(148,163,184,0.14);
    --line-strong:rgba(148,163,184,0.24);
    --text:#e2e8f0;
    --muted:#94a3b8;
    --green:#22c55e;
    --green-soft:rgba(34,197,94,0.12);
    --red:#ef4444;
    --red-soft:rgba(239,68,68,0.12);
    --yellow:#f59e0b;
    --yellow-soft:rgba(245,158,11,0.12);
    --cyan:#22d3ee;
    --cyan-soft:rgba(34,211,238,0.12);
    --shadow:0 18px 60px rgba(0,0,0,0.34);
    --radius:20px;
    --radius-md:16px;
    --radius-sm:12px;
}

*{
    box-sizing:border-box;
}

html,
body{
    margin:0;
    padding:0;
    background:
        radial-gradient(circle at top left, rgba(34,211,238,0.08), transparent 28%),
        radial-gradient(circle at top right, rgba(59,130,246,0.08), transparent 30%),
        linear-gradient(180deg, #020617 0%, #07101f 100%);
    color:#e2e8f0;
    font-family:Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body{
    min-height:100vh;
}

.wrap{
    width:calc(100% - 28px);
    max-width:1600px;
    margin:20px auto;
}

.topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    background:linear-gradient(180deg, rgba(15,23,42,0.92), rgba(8,17,33,0.92));
    border:1px solid rgba(148,163,184,0.14);
    border-radius:24px;
    padding:20px 22px;
    box-shadow:0 18px 60px rgba(0,0,0,0.34);
    -webkit-backdrop-filter:blur(12px);
    backdrop-filter:blur(12px);
}

.topbar h1{
    margin:0;
    font-size:26px;
    line-height:1.15;
    letter-spacing:0.2px;
}

.topbar p{
    margin:6px 0 0;
    color:#94a3b8;
    font-size:13px;
}

.top-control-grid{
    display:grid;
    grid-template-columns:repeat(3, minmax(0, 1fr));
    gap:10px;
    width:100%;
    max-width:520px;
}

.top-control-grid select{
    width:100%;
    height:44px;
    border-radius:12px;
    border:1px solid rgba(148,163,184,0.14);
    background:rgba(15,23,42,0.94);
    color:#e2e8f0;
    padding:0 14px;
    font-size:14px;
    outline:none;
}

.top-control-grid select:focus{
    border-color:rgba(34,211,238,0.40);
    box-shadow:0 0 0 4px rgba(34,211,238,0.08);
}

.top-summary-grid{
    display:grid;
    grid-template-columns:repeat(4, minmax(0, 1fr));
    gap:14px;
    margin:16px 0 18px;
}

.mini-card{
    background:rgba(15,23,42,0.78);
    border:1px solid rgba(148,163,184,0.12);
    border-radius:16px;
    padding:14px 16px;
    box-shadow:0 8px 30px rgba(0,0,0,0.18);
}

.mini-card span{
    display:block;
    font-size:12px;
    opacity:0.72;
    margin-bottom:6px;
}

.mini-card strong{
    font-size:20px;
    font-weight:700;
    letter-spacing:0.2px;
}

.layout-3col{
    display:grid;
    grid-template-columns:340px minmax(0, 1fr) 360px;
    gap:18px;
    margin-top:18px;
    align-items:start;
}

.left-rail,
.center-rail,
.right-rail{
    display:grid;
    gap:18px;
    align-self:start;
}

.panel{
    background:linear-gradient(180deg, rgba(15,23,42,0.94), rgba(8,17,33,0.96));
    border:1px solid rgba(148,163,184,0.14);
    border-radius:24px;
    padding:18px;
    box-shadow:0 18px 60px rgba(0,0,0,0.34);
    -webkit-backdrop-filter:blur(10px);
    backdrop-filter:blur(10px);
}

.chart-panel{
    min-height:760px;
}

.chart-panel-fixed{
    display:grid;
    gap:12px;
}

.compact-top{
    margin-top:0;
}

.action-box{
    display:grid;
    gap:12px;
    margin-bottom:14px;
}

.section-label-mini{
    font-size:12px;
    color:#94a3b8;
    margin-bottom:8px;
    display:block;
}

.analyze-main-btn{
    width:100%;
    height:48px;
    border:none;
    border-radius:14px;
    font-size:15px;
    font-weight:800;
    letter-spacing:0.2px;
    cursor:pointer;
    color:#04111f;
    background:linear-gradient(180deg, #22d3ee, #06b6d4);
    box-shadow:0 12px 30px rgba(34,211,238,0.22);
    transition:0.2s ease;
}

.analyze-main-btn:hover{
    transform:translateY(-1px);
}

.panel-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    margin-bottom:12px;
}

.panel-head h2,
.output-card h2,
.trade-card h2,
.smart-history-head h2{
    margin:0;
    font-size:18px;
    line-height:1.2;
    letter-spacing:0.2px;
}

#chartStatus{
    font-size:12px;
    color:#94a3b8;
    padding:7px 10px;
    border:1px solid rgba(148,163,184,0.14);
    border-radius:999px;
    background:rgba(15,23,42,0.72);
}

.scanner-box{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    background:rgba(15,23,42,0.68);
    border:1px solid rgba(148,163,184,0.14);
    border-radius:16px;
    padding:12px 14px;
    margin-bottom:12px;
}

.scanner-left{
    display:flex;
    align-items:center;
    gap:10px;
    min-width:0;
}

.scanner-dot{
    width:10px;
    height:10px;
    border-radius:999px;
    background:#f59e0b;
    box-shadow:0 0 0 6px rgba(245,158,11,0.12);
    flex:0 0 auto;
}

.scanner-dot.live{
    background:#22c55e;
    box-shadow:0 0 0 6px rgba(34,197,94,0.12);
}

.scanner-dot.stop{
    background:#ef4444;
    box-shadow:0 0 0 6px rgba(239,68,68,0.12);
}

#scannerText{
    font-size:14px;
    font-weight:600;
    color:#e2e8f0;
}

.spinner{
    width:18px;
    height:18px;
    border:2px solid rgba(255,255,255,0.15);
    border-top-color:#22d3ee;
    border-radius:50%;
    animation:spin 0.8s linear infinite;
}

.spinner.hidden{
    display:none;
}

@keyframes spin{
    to{
        transform:rotate(360deg);
    }
}

.ohlc-bar{
    background:rgba(2,6,23,0.55);
    border:1px solid rgba(148,163,184,0.14);
    border-radius:14px;
    padding:10px 12px;
    color:#cbd5e1;
    font-size:13px;
    margin-bottom:12px;
    letter-spacing:0.2px;
}

.tv-chart{
    width:100%;
    min-height:560px;
    border-radius:18px;
    overflow:hidden;
    border:1px solid rgba(148,163,184,0.14);
    background:#0b1220;
}

.history-box{
    margin-top:14px;
    background:rgba(2,6,23,0.46);
    border:1px solid rgba(148,163,184,0.14);
    border-radius:14px;
    padding:14px;
    color:#cbd5e1;
    font-size:13px;
    line-height:1.6;
}

.history-full{
    margin-top:18px;
}

.trade-card,
.output-card,
.smart-history-panel{
    background:rgba(15,23,42,0.58);
    border:1px solid rgba(148,163,184,0.14);
    border-radius:20px;
    padding:16px;
}

.trade-card{
    background:
        radial-gradient(circle at top right, rgba(34,211,238,0.08), transparent 35%),
        rgba(15,23,42,0.62);
}

.trade-grid{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:12px;
    margin-top:12px;
}

.trade-grid > div{
    background:rgba(2,6,23,0.34);
    border:1px solid rgba(148,163,184,0.10);
    border-radius:14px;
    padding:12px;
    min-height:74px;
}

.trade-grid span{
    display:block;
    color:#94a3b8;
    font-size:12px;
    margin-bottom:7px;
}

.trade-grid strong{
    display:block;
    font-size:15px;
    line-height:1.35;
    color:#e2e8f0;
    word-break:break-word;
}

.stack{
    display:grid;
    gap:10px;
}

.stack-item{
    background:rgba(2,6,23,0.36);
    border:1px solid rgba(148,163,184,0.10);
    border-radius:14px;
    padding:12px 13px;
}

.stack-item .name{
    font-size:14px;
    font-weight:700;
    line-height:1.4;
    margin-bottom:4px;
    word-break:break-word;
}

.stack-item .meta{
    font-size:12px;
    line-height:1.5;
    color:#94a3b8;
}

.signal-call{
    color:#22c55e;
}

.signal-put{
    color:#ef4444;
}

.signal-none{
    color:#f59e0b;
}

.insight-list{
    display:grid;
    gap:10px;
}

.insight-item{
    background:rgba(15,23,42,0.55);
    border:1px solid rgba(148,163,184,0.10);
    border-radius:14px;
    padding:12px 14px;
}

.insight-item .label{
    display:block;
    font-size:12px;
    opacity:0.72;
    margin-bottom:4px;
}

.insight-item .value{
    font-size:14px;
    font-weight:600;
    word-break:break-word;
}

.section-title-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin-bottom:12px;
}

.section-title-row h2{
    margin:0;
}

.muted-note{
    font-size:12px;
    opacity:0.7;
}

.smart-history-panel{
    margin-top:16px;
}

.smart-history-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:14px;
    margin-bottom:14px;
}

.smart-history-head p{
    margin:6px 0 0;
    color:#94a3b8;
    font-size:13px;
}

.smart-history-actions{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}

.secondary-btn,
.danger-btn{
    height:40px;
    padding:0 14px;
    border-radius:12px;
    border:1px solid rgba(148,163,184,0.14);
    background:rgba(15,23,42,0.90);
    color:#e2e8f0;
    cursor:pointer;
    font-weight:600;
    transition:0.2s ease;
}

.secondary-btn:hover,
.danger-btn:hover{
    transform:translateY(-1px);
}

.danger-btn{
    border-color:rgba(239,68,68,0.20);
    background:rgba(239,68,68,0.08);
    color:#fecaca;
}

.trade-history-list{
    display:grid;
    gap:12px;
}

.trade-card-item{
    background:rgba(2,6,23,0.40);
    border:1px solid rgba(148,163,184,0.11);
    border-radius:16px;
    padding:14px;
}

.trade-card-top{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom:12px;
}

.trade-card-title{
    font-size:15px;
    font-weight:700;
    color:#e2e8f0;
    line-height:1.35;
}

.trade-card-sub{
    margin-top:4px;
    color:#94a3b8;
    font-size:12px;
    line-height:1.45;
}

.trade-badge{
    white-space:nowrap;
    border-radius:999px;
    padding:8px 11px;
    font-size:11px;
    font-weight:800;
    letter-spacing:0.3px;
    border:1px solid transparent;
}

.badge-open{
    background:rgba(34,211,238,0.12);
    color:#22d3ee;
    border-color:rgba(34,211,238,0.15);
}

.badge-target{
    background:rgba(34,197,94,0.12);
    color:#22c55e;
    border-color:rgba(34,197,94,0.15);
}

.badge-stop{
    background:rgba(239,68,68,0.12);
    color:#ef4444;
    border-color:rgba(239,68,68,0.15);
}

.badge-no-trade{
    background:rgba(245,158,11,0.12);
    color:#f59e0b;
    border-color:rgba(245,158,11,0.15);
}

.trade-info-grid{
    display:grid;
    grid-template-columns:repeat(4, minmax(0, 1fr));
    gap:10px;
}

.trade-info-box{
    background:rgba(15,23,42,0.46);
    border:1px solid rgba(148,163,184,0.10);
    border-radius:12px;
    padding:10px 11px;
}

.trade-info-box span{
    display:block;
    color:#94a3b8;
    font-size:11px;
    margin-bottom:6px;
}

.trade-info-box strong{
    display:block;
    font-size:13px;
    line-height:1.35;
    color:#e2e8f0;
    word-break:break-word;
}

.status-badge{
    display:inline-flex;
    align-items:center;
    gap:8px;
    border-radius:999px;
    padding:8px 12px;
    font-size:12px;
    font-weight:800;
    letter-spacing:0.2px;
    background:rgba(30,41,59,0.9);
    border:1px solid rgba(148,163,184,0.14);
    color:#cbd5e1;
}

.status-badge.good{
    color:#22c55e;
    background:rgba(34,197,94,0.08);
    border-color:rgba(34,197,94,0.18);
}

.status-badge.warn{
    color:#f59e0b;
    background:rgba(245,158,11,0.08);
    border-color:rgba(245,158,11,0.18);
}

.status-badge.bad{
    color:#ef4444;
    background:rgba(239,68,68,0.08);
    border-color:rgba(239,68,68,0.18);
}

*::-webkit-scrollbar{
    width:10px;
    height:10px;
}

*::-webkit-scrollbar-thumb{
    background:rgba(148,163,184,0.18);
    border-radius:999px;
}

*::-webkit-scrollbar-track{
    background:transparent;
}

@media (max-width: 1300px){
    .layout-3col{
        grid-template-columns:300px minmax(0, 1fr) 320px;
    }
}

@media (max-width: 1180px){
    .layout-3col{
        grid-template-columns:1fr;
    }

    .top-summary-grid{
        grid-template-columns:repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px){
    .topbar{
        flex-direction:column;
        align-items:stretch;
    }

    .top-control-grid{
        grid-template-columns:1fr;
        max-width:none;
    }

    .trade-info-grid{
        grid-template-columns:repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px){
    .wrap{
        width:calc(100% - 16px);
        margin:12px auto;
    }

    .panel,
    .topbar{
        border-radius:18px;
        padding:14px;
    }

    .tv-chart{
        min-height:360px;
    }

    .trade-grid{
        grid-template-columns:1fr;
    }

    .trade-info-grid{
        grid-template-columns:1fr;
    }

    .trade-card-top,
    .smart-history-head,
    .section-title-row{
        flex-direction:column;
        align-items:flex-start;
    }

    .top-summary-grid{
        grid-template-columns:1fr;
    }
}