:root {
  --bg: #0b0f17;
  --surface: #131925;
  --surface-2: #1b2331;
  --line: #242e3f;
  --text: #e8edf5;
  --muted: #8a96aa;
  --accent: #4f8cff;
  --up: #22c55e;
  --down: #ef4444;
  --warn: #f5a524;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: none; }
a { color: inherit; text-decoration: none; }
a, button, label, .item { touch-action: manipulation; }
button, input, select, textarea { font: inherit; color: inherit; }
.shell { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding-bottom: calc(92px + env(safe-area-inset-bottom)); position: relative; }
main { padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }

/* Header */
.topbar { display: flex; align-items: center; gap: 12px; padding: calc(18px + env(safe-area-inset-top)) 0 12px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 600; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hero { background: linear-gradient(140deg, #1d2b4a, #131925 70%); }
.hero .label { color: var(--muted); font-size: 13px; }
.hero .big { font-size: 32px; font-weight: 700; margin: 4px 0 8px; letter-spacing: -.02em; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.up { color: var(--up); }
.down { color: var(--down); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.up { background: rgba(34,197,94,.14); }
.pill.down { background: rgba(239,68,68,.14); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 15px; font-weight: 600; margin-top: 2px; }

/* Lists */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .right { text-align: right; flex: none; }
.item .right .title { font-variant-numeric: tabular-nums; }

.alloc { display: flex; height: 10px; border-radius: 999px; overflow: hidden; gap: 2px; margin: 4px 0 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 5px; }

/* Chart */
.chart-wrap { position: relative; height: 200px; margin: 8px -4px 0; touch-action: pan-y; }
.chart-wrap svg { width: 100%; height: 100%; display: block; }
.chart-tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 12px; pointer-events: none; white-space: nowrap; }
.ranges { display: flex; gap: 4px; margin-top: 10px; }
.ranges button { flex: 1; padding: 7px 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.ranges button.on { background: var(--surface-2); color: var(--text); }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input { width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 70px; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 10px 6px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.seg.buysell button.on[data-v="buy"] { background: var(--up); color: #04210f; }
.seg.buysell button.on[data-v="sell"] { background: var(--down); color: #fff; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 45%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; border-radius: 14px; padding: 14px; font-weight: 600; font-size: 15px; cursor: pointer; background: var(--accent); color: #fff; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: rgba(239,68,68,.12); color: var(--down); border: 1px solid rgba(239,68,68,.3); }
.btn.success { background: var(--up); color: #04210f; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-row { display: flex; gap: 10px; margin-bottom: 14px; }
.btn-row .btn { flex: 1; }
.selected-asset { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.suggest { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-top: 6px; overflow: hidden; }
.suggest .item { padding: 10px 12px; }
.summary-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.summary-line.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 16px; }
.toggle { position: relative; width: 46px; height: 28px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; transition: .2s; cursor: pointer; }
.toggle span::after { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: var(--muted); border-radius: 50%; transition: .2s; }
.toggle input:checked + span { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + span::after { transform: translateX(18px); background: #fff; }
.error { color: var(--down); font-size: 13px; margin-top: 6px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; stroke: var(--muted); fill: none; stroke-width: 1.5; margin-bottom: 10px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 8px; color: transparent !important; }
@keyframes sh { to { background-position: -200% 0; } }

/* Tabbar */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; display: flex; align-items: center; justify-content: space-around; background: rgba(19,25,37,.95); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 8px 4px calc(8px + env(safe-area-inset-bottom)); z-index: 10; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); flex: 1; }
.tabbar a.on { color: var(--text); }
.tabbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar .fab { flex: none; width: 54px; height: 54px; border-radius: 18px; background: var(--accent); color: #fff; justify-content: center; margin-top: -26px; box-shadow: 0 8px 20px rgba(79,140,255,.4); }
.tabbar .fab svg { width: 26px; height: 26px; }

#toasts { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: calc(100% - 32px); max-width: 448px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 12px 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: in .25s ease; }
.toast.warn { border-left-color: var(--warn); }
.toast.ok { border-left-color: var(--up); }
.toast.err { border-left-color: var(--down); }
@keyframes in { from { opacity: 0; transform: translateY(-8px); } }

.section-title { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 8px; }
.section-title h2 { font-size: 16px; margin: 0; }
.section-title a { color: var(--accent); font-size: 13px; font-weight: 600; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.badge.buy { background: rgba(34,197,94,.15); color: var(--up); }
.badge.sell { background: rgba(239,68,68,.15); color: var(--down); }
.detail-head { text-align: center; padding: 6px 0 14px; }
.detail-head .big { font-size: 28px; font-weight: 700; margin: 8px 0 4px; }
.kv { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* Portföy kategori grupları */
.group-title h2 { display: flex; align-items: center; gap: 8px; }
.group-title .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.group-sum { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.group-sum .v { font-size: 18px; font-weight: 700; margin-top: 2px; }

/* Giriş ekranı */
body.auth .tabbar { display: none; }
body.auth .shell { padding-bottom: 0; }
.login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: calc(24px + env(safe-area-inset-top)) 0 calc(24px + env(safe-area-inset-bottom)); }
.login-logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 18px; box-shadow: 0 12px 30px rgba(79,140,255,.3); }
.login h1 { font-size: 26px; margin: 0 0 8px; letter-spacing: -.02em; }
.login > p { margin: 0 auto 26px; max-width: 320px; line-height: 1.5; }
.login-card { text-align: left; }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
.topbar .icon-btn .avatar { border-radius: 0; }
