:root{
    --bg:#0b0a09;
    --panel:#12100e;
    --panel2:#151210;
    --border:#2a231d;
    --text:#f2eee9;
    --muted:#b6afa8;
    --gold:#e3c892;
    --ok:#2ecc71;
    --err:#ff5c5c;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
    --radius:18px;
    --radius2:14px;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --sans: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
    margin:0;
    background: radial-gradient(1200px 700px at 30% -10%, rgba(227,200,146,.08), transparent 60%),
    radial-gradient(900px 600px at 90% 10%, rgba(227,200,146,.06), transparent 55%),
    var(--bg);
    color:var(--text);
    font-family:var(--sans);
}

.topbar{
    position:sticky; top:0; z-index:20;
    background: rgba(10,9,8,.75);
    backdrop-filter: blur(10px);
    border-bottom:1px solid rgba(42,35,29,.8);
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:14px;
    padding:14px 16px;
}

.brand{display:flex; align-items:center; gap:12px}
.logo{
    width:42px; height:42px;
    border-radius:14px;
    background: linear-gradient(135deg, rgba(227,200,146,.35), rgba(227,200,146,.12));
    border:1px solid rgba(227,200,146,.35);
    display:grid; place-items:center;
    font-weight:900;
    color:var(--gold);
}
.brand-text .title{font-weight:900; font-size:16px; line-height:1.1}
.brand-text .subtitle{font-size:12px; color:var(--muted); margin-top:2px}

.container{
    max-width:1100px;
    margin:0 auto;
    padding:18px 14px 40px;
}

.toast{
    border-radius:14px;
    padding:12px 14px;
    border:1px solid rgba(227,200,146,.2);
    background: rgba(18,16,14,.75);
    box-shadow: var(--shadow);
    margin:10px 0 14px;
}
.toast.ok{border-color:rgba(46,204,113,.25)}
.toast.err{border-color:rgba(255,92,92,.25)}

.stats{
    display:grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap:12px;
    margin-bottom:14px;
}
@media (max-width: 720px){
    .stats{grid-template-columns: 1fr}
}
.card{
    border:1px solid rgba(227,200,146,.18);
    background: linear-gradient(180deg, rgba(18,16,14,.85), rgba(18,16,14,.65));
    border-radius: var(--radius);
    padding:14px 16px;
    box-shadow: var(--shadow);
}
.card-h{color:var(--muted); font-size:12px}
.card-v{font-size:26px; font-weight:900; margin:6px 0 2px; color:var(--gold)}
.card-f{color:var(--muted); font-size:12px}

.panel{
    border:1px solid rgba(227,200,146,.16);
    background: rgba(18,16,14,.65);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow:hidden;
    margin-top:14px;
}
.panel-head{
    display:flex; align-items:center; justify-content:space-between;
    padding:14px 16px;
    border-bottom:1px solid rgba(42,35,29,.9);
    background: rgba(18,16,14,.55);
}
.panel-head h2{margin:0; font-size:16px}
.panel-head-actions{display:flex; gap:10px; align-items:center; flex-wrap:wrap}
.panel-body{padding:14px 16px}

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

.card-lite{
    border:1px solid rgba(42,35,29,.9);
    background: rgba(21,18,16,.55);
    border-radius: var(--radius2);
    padding:14px;
}
.card-lite h3{margin:0 0 10px; font-size:14px}

.notice{
    border:1px dashed rgba(227,200,146,.25);
    background: rgba(227,200,146,.06);
    padding:12px 12px;
    border-radius: 14px;
    color: var(--muted);
}

.table-wrap{overflow:auto}
.table{
    width:100%;
    border-collapse:separate;
    border-spacing:0;
    min-width: 980px;
}
.table th, .table td{
    border-bottom:1px solid rgba(42,35,29,.9);
    padding:10px 10px;
    vertical-align:top;
}
.table th{
    text-align:left;
    font-size:12px;
    color:var(--muted);
    font-weight:800;
    position:sticky; top:0;
    background: rgba(18,16,14,.9);
    backdrop-filter: blur(8px);
    z-index:5;
}
.table td{font-size:13px}

input, select, textarea{
    width:100%;
    background: rgba(10,9,8,.55);
    border:1px solid rgba(42,35,29,.9);
    color:var(--text);
    border-radius:12px;
    padding:10px 10px;
    outline:none;
}
input[type="checkbox"], input[type="radio"]{
    width:auto;
    outline:none;
}
input[type="checkbox"]:focus, input[type="radio"]:focus{
    outline:none;
    box-shadow:none;
}
textarea{resize:vertical}
input:focus, select:focus, textarea:focus{
    border-color: rgba(227,200,146,.55);
    box-shadow: 0 0 0 3px rgba(227,200,146,.12);
}

.mono{font-family:var(--mono)}
.muted{color:var(--muted)}

.cond{display:flex; gap:8px; align-items:center}
.cond select{width:70px}
.cond input{flex:1}

.hint{margin-top:6px; font-size:11px; color:var(--muted)}

.btn{
    border:1px solid rgba(227,200,146,.25);
    background: rgba(18,16,14,.6);
    color: var(--text);
    padding:10px 12px;
    border-radius: 12px;
    cursor:pointer;
    font-weight:800;
}
.btn:hover{border-color: rgba(227,200,146,.45)}
.btn.primary{
    background: linear-gradient(180deg, rgba(227,200,146,.18), rgba(18,16,14,.5));
    border-color: rgba(227,200,146,.45);
    color: var(--gold);
}
.btn.secondary{background: rgba(21,18,16,.55)}
.btn.mini{padding:7px 10px; border-radius:10px; font-size:12px}
.btn.ok{border-color: rgba(46,204,113,.35); color: rgba(46,204,113,.95)}
.btn.danger{border-color: rgba(255,92,92,.35); color: rgba(255,92,92,.95)}
.btn.danger:hover{border-color: rgba(255,92,92,.55); background: rgba(255,92,92,.1)}
.btn.ghost{opacity:.85}

.inline{display:inline}
.stack{display:flex; flex-direction:column; gap:10px}

.field span{display:block; font-size:12px; color:var(--muted); margin-bottom:6px}
.row-inline{display:flex; gap:10px; align-items:center}
.row-inline input{flex:1}

.token-field{display:flex; gap:8px; align-items:center}
.token-field input{flex:1}

.switch{position:relative; display:inline-block; width:44px; height:26px}
.switch input{display:none}
.slider{
    position:absolute; cursor:pointer; inset:0;
    background: rgba(10,9,8,.6);
    border:1px solid rgba(42,35,29,.9);
    border-radius:999px;
    transition:.2s;
}
.slider:before{
    content:"";
    position:absolute; height:20px; width:20px; left:3px; top:2px;
    background: rgba(227,200,146,.35);
    border:1px solid rgba(227,200,146,.35);
    border-radius:999px;
    transition:.2s;
}
.switch input:checked + .slider{border-color: rgba(46,204,113,.35)}
.switch input:checked + .slider:before{
    transform: translateX(18px);
    background: rgba(46,204,113,.35);
    border-color: rgba(46,204,113,.35);
}

.check{
    display:flex; align-items:center; gap:8px;
    color:var(--muted);
    font-size:12px;
}
.check input{width:18px; height:18px}

.mini-table{margin-top:12px; display:flex; flex-direction:column; gap:8px}
.mini-row{
    display:flex; align-items:center; justify-content:space-between;
    gap:10px;
    padding:10px 12px;
    border:1px solid rgba(42,35,29,.9);
    background: rgba(10,9,8,.35);
    border-radius: 14px;
}

.pill{
    border:1px solid rgba(227,200,146,.25);
    background: rgba(18,16,14,.65);
    border-radius:999px;
    padding:8px 12px;
    display:flex; align-items:center; gap:10px;
}
.pill.small{padding:4px 8px; font-size:12px}
.pill.ok{border-color: rgba(46,204,113,.25)}
.pill.err{border-color: rgba(255,92,92,.25)}
.pill-label{color:var(--muted); font-size:12px}
.pill-value{font-family:var(--mono); font-size:12px}

.log{display:flex; flex-direction:column; gap:10px}
.log-row{
    border:1px solid rgba(42,35,29,.9);
    background: rgba(10,9,8,.35);
    border-radius: 14px;
    padding:10px 12px;
}
.log-top{display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:6px}
.log-msg{color: var(--muted); font-size:12px; line-height:1.35}

.footer{margin-top:16px; padding:14px 4px 0; text-align:center}

/* TRADE CONFIG PANEL */
.trade-config-row{background: rgba(227,200,146,.04)}
.trade-config-panel{padding:20px}
.trade-config-panel h4{margin:0 0 16px; color:var(--gold); font-size:16px}
.trade-config-panel h5{margin:16px 0 10px; color:var(--muted); font-size:14px; font-weight:800}
.trade-config-grid{
    display:grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap:14px;
}
.config-group{
    display:flex;
    flex-direction:column;
    gap:6px;
}
.config-group label{font-size:12px; color:var(--muted)}
.sltp-section{margin-top:20px}
.trade-config-row-compact{
    display:flex;
    align-items:center;
    gap:12px;
    margin-top:14px;
    flex-wrap:wrap;
}
.config-group-inline{
    min-width:120px;
}
.config-group-inline label{
    font-size:14px;
    color:var(--text);
    font-weight:600;
}
.auto-sl-params-inline, .auto-tp-params-inline{
    display:flex;
    gap:14px;
    flex:1;
    flex-wrap:wrap;
}
.param-with-label{
    display:flex;
    flex-direction:column;
    gap:6px;
    min-width:110px;
}
.param-label{
    font-size:11px;
    color:var(--muted);
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:0.5px;
}
.input-suffix{
    display:flex;
    align-items:center;
    gap:4px;
    position:relative;
}
.input-suffix input{
    flex:1;
    min-width:60px;
    max-width:90px;
    padding-right:24px;
}
.input-suffix .suffix{
    position:absolute;
    right:8px;
    font-size:12px;
    color:var(--muted);
    pointer-events:none;
    font-weight:600;
}
.manual-sl-input, .manual-tp-input{
    flex:1;
    min-width:150px;
}

/* POSITIONS GRID */
.positions-grid{
    display:grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap:14px;
}
.position-card{
    border:1px solid rgba(42,35,29,.9);
    background: rgba(10,9,8,.35);
    border-radius:var(--radius2);
    padding:14px;
}
.position-card.long{border-color: rgba(46,204,113,.25)}
.position-card.short{border-color: rgba(255,92,92,.25)}
.position-header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:12px;
}
.position-header h4{margin:0; font-size:16px}
.position-stats{
    display:grid;
    gap:8px;
    margin-bottom:12px;
}
.position-stats .stat{
    display:flex;
    justify-content:space-between;
    align-items:center;
    font-size:13px;
}
.position-stats label{color:var(--muted)}
.position-actions{
    display:flex;
    gap:8px;
    margin-top:12px;
}
.badge{
    display:inline-block;
    padding:4px 8px;
    border-radius:8px;
    font-size:11px;
    font-weight:800;
}
.badge.long{background: rgba(46,204,113,.18); color: rgba(46,204,113,.95); border:1px solid rgba(46,204,113,.35)}
.badge.short{background: rgba(255,92,92,.18); color: rgba(255,92,92,.95); border:1px solid rgba(255,92,92,.35)}
.badge-auto{
    display:inline-block;
    padding:4px 8px;
    border-radius:8px;
    font-size:10px;
    font-weight:800;
    background: rgba(227,200,146,.18);
    color: var(--gold);
    border:1px solid rgba(227,200,146,.35);
}

.badge-warning{
    display:inline-block;
    padding:4px 8px;
    border-radius:8px;
    font-size:10px;
    font-weight:800;
    background: rgba(255,165,0,.15);
    color: #ffa500;
    border:1px solid rgba(255,165,0,.35);
}
.badge-manual{
    display:inline-block;
    padding:4px 8px;
    border-radius:8px;
    font-size:10px;
    font-weight:800;
    background: rgba(255,159,64,.15);
    color: rgba(255,159,64,1);
    border:1px solid rgba(255,159,64,.35);
}
.leverage{
    font-size:12px;
    color:var(--gold);
    font-weight:800;
}
.positive{color: rgba(46,204,113,.95)}
.negative{color: rgba(255,92,92,.95)}
.loader{text-align:center; padding:20px; color:var(--muted)}

/* MOBILE: tabela jako karty */
@media (max-width: 920px){
    .stats{grid-template-columns: 1fr}
    .grid2{grid-template-columns: 1fr}
    .table{min-width: 0}
    .table thead{display:none}
    .table, .table tbody, .table tr, .table td{display:block; width:100%}
    .table tr{
        border:1px solid rgba(42,35,29,.9);
        background: rgba(10,9,8,.35);
        border-radius: 18px;
        margin-bottom:12px;
        overflow:hidden;
    }
    .table td{
        border-bottom:1px solid rgba(42,35,29,.7);
        padding:10px 12px;
    }
    .table td:last-child{border-bottom:none}
    .table td::before{
        content: attr(data-label);
        display:block;
        font-size:11px;
        color: var(--muted);
        margin-bottom:6px;
    }
    .panel-head{gap:10px; flex-wrap:wrap}
}
