* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b1220;
  --surface: #121c30;
  --surface2: #1a2740;
  --border: #24334f;
  --text: #e6edf7;
  --muted: #8fa0bb;
  --accent: #34d399;
  --accent-dim: #10b981;
  --red: #f87171;
  --radius: 12px;
}

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
header h1 { font-size: 1.1rem; }
.badge { font-size: 0.7rem; color: var(--muted); background: var(--surface2); padding: 3px 8px; border-radius: 99px; }

nav#tabs {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: calc(43px + env(safe-area-inset-top)); z-index: 19;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
nav#tabs::-webkit-scrollbar { display: none; }
nav#tabs button {
  flex: 0 0 auto;
  background: var(--surface2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 99px;
  padding: 7px 14px; font-size: 0.85rem; cursor: pointer; white-space: nowrap;
}
nav#tabs button.active { background: var(--accent-dim); color: #06281c; border-color: var(--accent-dim); font-weight: 600; }

main { padding: 16px; max-width: 780px; margin: 0 auto; }

.tab { display: none; }
.tab.active { display: block; animation: fadein 0.2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

h2 { font-size: 1.15rem; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}

label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  width: 100%; margin-top: 4px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; font-size: 16px; /* iOS zoom önleme */
  font-family: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-dim); border-color: transparent; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.btn {
  display: inline-block;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 18px; font-size: 0.95rem; cursor: pointer;
  margin: 4px 0 12px;
}
.btn.primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #06281c; font-weight: 700; width: 100%; }
.btn.small { padding: 6px 12px; font-size: 0.8rem; margin: 0; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: wait; }

/* Piyasa özeti */
.overview h3 { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 16px 0 6px; }
.qrow {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; margin-bottom: 6px;
}
.qrow .sym { font-weight: 600; font-size: 0.9rem; }
.qrow .nm { color: var(--muted); font-size: 0.75rem; }
.qrow .px { font-variant-numeric: tabular-nums; font-weight: 600; }
.up { color: var(--accent); }
.down { color: var(--red); }

/* İşlem listesi */
.trade-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; font-size: 0.85rem;
}
.trade-row .del { background: none; border: none; color: var(--red); font-size: 1rem; cursor: pointer; }

/* Pozisyon satırları */
.pos-row { display: grid; grid-template-columns: 2fr 1.4fr 1fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.pos-row input, .pos-row select { margin-top: 0; }
.pos-row .del { background: none; border: none; color: var(--red); font-size: 1.1rem; cursor: pointer; }

/* AI çıktısı */
.ai-output {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-top: 6px;
  min-height: 0; font-size: 0.92rem; overflow-wrap: break-word;
}
.ai-output:empty { display: none; }
.ai-output h1, .ai-output h2, .ai-output h3 { margin: 14px 0 6px; font-size: 1.02rem; color: var(--accent); }
.ai-output h1:first-child, .ai-output h2:first-child, .ai-output h3:first-child { margin-top: 0; }
.ai-output p { margin: 8px 0; }
.ai-output ul, .ai-output ol { margin: 8px 0 8px 20px; }
.ai-output li { margin: 3px 0; }
.ai-output strong { color: #fff; }
.ai-output code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }
.ai-output .table-wrap { overflow-x: auto; margin: 10px 0; }
.ai-output table { border-collapse: collapse; font-size: 0.82rem; min-width: 100%; }
.ai-output th, .ai-output td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; white-space: nowrap; }
.ai-output th { background: var(--surface2); }
.ai-output hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

#chart-container {
  height: 420px; width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.chart-legend {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 0.75rem; color: var(--muted); margin: 4px 2px 8px;
}
.chart-legend .chip { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.iv.active-iv { background: var(--accent-dim); color: #06281c; border-color: var(--accent-dim); font-weight: 700; }
@media (max-width: 640px) { #chart-container { height: 340px; } }

.spinner { color: var(--muted); font-size: 0.85rem; }
.spinner::after { content: ""; display: inline-block; width: 12px; height: 12px; margin-left: 8px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

label.check {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.88rem; color: var(--text); margin-bottom: 12px;
}
label.check input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent-dim); flex: 0 0 auto; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

footer {
  text-align: center; color: var(--muted); font-size: 0.72rem;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}

@media (min-width: 640px) {
  .grid2 { grid-template-columns: repeat(4, 1fr); }
  .btn.primary { width: auto; }
}
