:root {
  --bg: #0d1016;
  --panel: #151a23;
  --panel-2: #1b2130;
  --line: #262e3f;
  --text: #e6e9ef;
  --muted: #8a93a6;
  --accent: #22c55e;
  --accent-ink: #06140b;
  --warn: #f5b041;
  --bad: #f05252;
  --blue: #5b9dff;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.2em; }
h1, h2, h3 { margin: 0 0 8px; }
h2 { font-size: 16px; }
a { color: var(--blue); text-decoration: none; }

.sticky-top { position: sticky; top: 0; z-index: 5; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: rgba(13,16,22,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .2px; }
.wallet { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bal b { font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); display: inline-block; }
.dot.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 14px 16px 60px; display: grid; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.grow { flex: 1 1 220px; min-width: 0; }

input, select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font: inherit; outline: none; }
input:focus, select:focus { border-color: var(--blue); }
.small-input { width: 90px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.btn { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 9px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a4560; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.danger { border-color: #5a2630; color: #ff8b8b; }
.btn.opt { padding: 7px 10px; font-size: 13px; }
.btn.opt.single { border-color: #2c4a7a; }
.btn.opt.double { border-color: #2b5a3c; }

.controls { margin-top: 12px; align-items: flex-start; }
.ctl { display: flex; flex-direction: column; }
.chips { display: flex; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 999px; padding: 7px 12px; cursor: pointer; font-weight: 600; }
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip-input { width: 90px; border-radius: 999px; padding: 7px 10px; }
.chip-input.active { border-color: var(--blue); }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

.switch { position: relative; width: 42px; height: 24px; display: inline-block; margin: 6px 0 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: #173a26; border-color: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); background: var(--accent); }

.token-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.token-head .sym { font-size: 18px; font-weight: 700; }
.pool { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 8px; background: var(--panel-2); }
.pool.best { border-color: var(--accent); }
.pool.off { opacity: .55; }
.pool-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 8px; }
.pool-head .t { font-weight: 700; }
.kv { color: var(--muted); }
.kv b { color: var(--text); font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); }
.badge.good { background: #143321; color: #62e39a; border-color: #1f5a37; }
.badge.warn { background: #3a2c10; color: var(--warn); border-color: #5c4516; }
.badge.bad { background: #3a1418; color: #ff8b8b; border-color: #5a2630; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }

.positions { display: grid; gap: 10px; margin-top: 8px; }
.pos { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--panel-2); }
.pos-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 14px; margin: 8px 0; }
.pos-grid div span { display: block; font-size: 12px; color: var(--muted); }
.pos-grid div b { font-variant-numeric: tabular-nums; }
.pos-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.neg { color: #ff8b8b !important; }
.plus { color: #62e39a !important; }

.range { position: relative; height: 26px; margin: 6px 0 2px; }
.range .track { position: absolute; left: 0; right: 0; top: 11px; height: 4px; background: #2a3246; border-radius: 4px; }
.range .band { position: absolute; top: 9px; height: 8px; background: #2c4a7a; border-radius: 4px; }
.range .band.in { background: #1f7a45; }
.range .mark { position: absolute; top: 3px; width: 2px; height: 20px; background: var(--warn); }
.range-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.swap-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: end; margin-bottom: 8px; }
.swap-grid select, .swap-grid input { width: 100%; margin-top: 4px; }
.flip { height: 40px; }
.swap-info { margin-top: 8px; min-height: 1.3em; }

.logs { max-height: 260px; overflow: auto; font-size: 12px; background: #0a0d12; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.logs .l { white-space: pre-wrap; word-break: break-word; }
.logs .error { color: #ff8b8b; }
.logs .warn { color: var(--warn); }
.logs .ok { color: #62e39a; }

.other { margin-top: 10px; }
.other summary { cursor: pointer; color: var(--muted); }

.busy { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; gap: 8px; align-items: center; justify-content: center; padding: 6px; background: #1d2a44; color: #cfe0ff; font-size: 13px; }
.spinner { width: 14px; height: 14px; border: 2px solid #6d8fd0; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; width: min(520px, 100%); max-height: 90vh; overflow: auto; }
.plan-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; }
.plan-table td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.plan-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.warnings { margin: 0 0 12px; padding-left: 18px; color: var(--warn); }

.toasts { position: fixed; right: 12px; bottom: 12px; display: grid; gap: 8px; z-index: 30; max-width: min(420px, calc(100% - 24px)); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 8px; padding: 10px 12px; box-shadow: 0 6px 20px rgba(0,0,0,.4); word-break: break-word; }
.toast.ok { border-left-color: var(--accent); }
.toast.error { border-left-color: var(--bad); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: grid; gap: 10px; }

@media (max-width: 640px) {
  .swap-grid { grid-template-columns: 1fr; }
  .flip { justify-self: center; }
}

/* --- iki ag + ozel aralik --- */
.chainpill { font-size: 10px; font-weight: 800; letter-spacing: .4px; padding: 2px 6px; border-radius: 5px; vertical-align: middle; }
.chainpill.rh { background: #13301f; color: #62e39a; border: 1px solid #1f5a37; }
.chainpill.sol { background: #251b3d; color: #b89bff; border: 1px solid #45327a; }
.mid-input { width: 150px; }
.custom-row { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.custom-row .hint { margin: 0; align-self: center; }
.btn.opt.custom { border-color: #6b4fa8; color: #d6c6ff; }
.btn.ghostish { background: #173a26; color: #9ff0c2; border-color: #1f5a37; }
[hidden] { display: none !important; }
body.ext main { padding: 10px; gap: 10px; }
body.ext .top { padding: 8px 10px; }

/* ---------- Ag gorunumu: sadece aktif aga ait arayuz ---------- */
body.chain-rh .only-sol, body.chain-sol .only-rh { display: none !important; }
.wallet-group { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chainbar { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.chainbar button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; color: var(--muted); border-bottom: 3px solid transparent; opacity: .55; transition: opacity .15s, background .15s; }
.chainbar button:hover { opacity: .85; }
.chainbar .cb-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.chainbar .cb-name { font-weight: 800; letter-spacing: .3px; }
.chainbar .cb-sub { font-size: 12px; }
.chainbar .cb-count { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; background: var(--panel-2); }
.chainbar .cb-count:empty { display: none; }
body.chain-rh .chainbar [data-chain="rh"] { opacity: 1; color: #62e39a; background: linear-gradient(180deg, rgba(34,197,94,.14), transparent); border-bottom-color: #22c55e; }
body.chain-sol .chainbar [data-chain="sol"] { opacity: 1; color: #b89bff; background: linear-gradient(180deg, rgba(153,69,255,.18), transparent); border-bottom-color: #9945ff; }
body.chain-rh .top { box-shadow: inset 0 3px 0 #22c55e; }
body.chain-sol .top { box-shadow: inset 0 3px 0 #9945ff; }
body.chain-sol { --accent: #9945ff; --accent-ink: #fff; }
@media (max-width: 520px) { .chainbar .cb-sub { display: none; } .chainbar button { padding: 9px 12px; } }

.pos.closing { opacity: .45; pointer-events: none; }

/* ---------- Kompakt pozisyon karti ---------- */
.pos-title { min-width: 0; overflow-wrap: anywhere; }
.pos-head { align-items: center; margin-bottom: 2px; }
.pos-meta { font-size: 12px; margin-bottom: 4px; }
.pos-kpi { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0 2px; }
.pos-kpi div { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.pos-kpi span { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-kpi b { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos-more { margin-top: 6px; }
.pos-more > summary, details.settings > summary, .logs-card > summary { cursor: pointer; color: var(--muted); font-size: 12px; user-select: none; }
.pos-grid b { overflow-wrap: anywhere; }
details.settings { margin-top: 10px; }
.logs-card { display: block; }
.logs-card[open] > summary { margin-bottom: 8px; }

/* Dar ekran / eklenti yan paneli: tasma yok, her sey sigar */
main > *, .card, .pos, .pool { min-width: 0; }
input, select { max-width: 100%; min-width: 0; }
.mono { overflow-wrap: anywhere; }
.custom-row .row > input { flex: 1 1 0; width: auto; }
body.ext main { padding: 8px; gap: 8px; }
body.ext .card { padding: 10px; }
body.ext .pos { padding: 10px; }
body.ext .brand { font-size: 13px; }
body.ext .top { padding: 6px 8px; gap: 6px; }
body.ext .wallet { gap: 8px; font-size: 12px; }
body.ext .chainbar button { padding: 7px 10px; }
body.ext .btn.sm { padding: 5px 8px; font-size: 12px; }
body.ext .pos-actions { gap: 4px; }
body.ext .range-labels { font-size: 11px; }
body.ext h2 { font-size: 14px; }
body.ext .hint { font-size: 11px; }
@media (max-width: 360px) {
  .pos-kpi b { font-size: 13px; }
  .pos-kpi div { padding: 5px 6px; }
  .chips .chip { padding: 5px 9px; }
  .row.gap { gap: 6px; }
}
.chainbar button { flex-wrap: nowrap; min-width: 0; }
.chainbar .cb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chip { white-space: nowrap; }
.pos-kpi b { font-size: 13px; white-space: normal; overflow-wrap: anywhere; line-height: 1.25; display: block; }
@media (max-width: 380px) { .chainbar .cb-name { font-size: 13px; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ctl { min-width: 0; max-width: 100%; }
.chip-input { width: 80px; }
