:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --up: #0ca30c;
  --down: #d03b3b;
  --up-text: #006300;
  --down-text: #b02a2a;
  --warn: #fab219;
  --danger: #d03b3b;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --up-text: #0ca30c;
    --down-text: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #262624;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --up-text: #0ca30c;
  --down-text: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- üst bar ---- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.logo { color: var(--accent); }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2);
}
.pill-mode { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.on .dot { background: var(--up); }
.pill.off .dot { background: var(--down); }

.btn {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.btn:hover { filter: brightness(0.96); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-small { padding: 2px 8px; font-size: 12px; }
.btn-icon { padding: 6px 10px; }

select, input[type=number] {
  font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}

.banner { padding: 8px 16px; font-size: 13px; display: flex; gap: 12px; align-items: center; }
.banner-danger { background: color-mix(in srgb, var(--danger) 18%, var(--surface)); }
.banner-warn { background: color-mix(in srgb, var(--warn) 22%, var(--surface)); }

/* ---- sekmeler ---- */
.tabs {
  display: flex; gap: 2px; padding: 0 16px; overflow-x: auto; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tabs button {
  font: inherit; background: none; border: none; color: var(--text-2); padding: 10px 12px;
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 16px; }
.grid-accounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- istatistik kutuları ---- */
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--text-2); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.tile .value { font-size: 24px; font-weight: 600; margin: 4px 0 2px; }
.tile .delta { font-size: 13px; }
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.up { color: var(--up-text); }
.down { color: var(--down-text); }

/* ---- tablolar ---- */
.table-wrap { overflow-x: auto; }
.scroll-y { max-height: 420px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 8px 10px;
  border-bottom: 1px solid var(--axis); white-space: nowrap; position: sticky; top: 0; background: var(--surface);
}
th[title] { cursor: help; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2);
}
.tag-BUY { background: color-mix(in srgb, var(--up) 18%, transparent); color: var(--up-text); }
.tag-SELL { background: color-mix(in srgb, var(--down) 18%, transparent); color: var(--down-text); }

/* ---- skor çubuğu ---- */
.meter { display: inline-flex; align-items: center; gap: 6px; }
.meter-track { width: 60px; height: 6px; border-radius: 3px; background: var(--surface-2); position: relative; overflow: hidden; }
.meter-fill { position: absolute; top: 0; bottom: 0; }
.meter-mid { position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1px; background: var(--axis); }

/* ---- kararlar ---- */
.decision { border-bottom: 1px solid var(--grid); padding: 10px 0; }
.decision:last-child { border-bottom: none; }
.decision .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.decision .head .sym { font-weight: 600; }
.decision ul { margin: 6px 0 0; padding-left: 20px; color: var(--text-2); font-size: 13px; }
.decision .outcome { font-size: 12px; margin-top: 4px; }

.events { max-height: 360px; overflow-y: auto; font-size: 12px; }
.event { padding: 5px 0; border-bottom: 1px solid var(--grid); display: flex; gap: 8px; }
.event time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.event.error { color: var(--down-text); }

/* ---- grafikler ---- */
.chart { width: 100%; position: relative; }
.chart-md { height: 280px; }
.chart-lg { height: 480px; }
@media (max-width: 700px) { .chart-lg { height: 340px; } }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.legend .key { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 5px; border-radius: 1px; }
.ohlc { color: var(--text-2); min-height: 18px; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.seg button { font: inherit; font-size: 12px; border: none; background: none; color: var(--text-2); padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); font-weight: 600; }
.empty-note { text-align: center; }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.settings dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 4px 16px; font-size: 13px; }
.settings dt { color: var(--text-2); }
.settings dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.settings h3 { font-size: 13px; margin: 0 0 8px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { background: var(--surface); border-radius: var(--radius); padding: 20px; max-width: 480px; width: 100%; border: 1px solid var(--border); }

@media (max-width: 600px) {
  .topbar { padding: 8px 12px; }
  main { padding: 12px; }
  .controls .muted { display: none; }
}
.tile .sub span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- piyasa izleme: mod seçimi, seçtiklerim, tarama ---- */
input[type=text] {
  font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); min-width: 180px;
}
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .mode-cards { grid-template-columns: 1fr; } }
.mode-card {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.mode-card > span { display: flex; flex-direction: column; gap: 2px; }
.mode-card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.mode-card input { margin-top: 3px; accent-color: var(--accent); }
.star {
  font-size: 16px; line-height: 1; background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 2px 4px;
}
.star.on { color: var(--warn); }
.star:hover { color: var(--warn); }
.scroll-y.tall { max-height: 640px; }

/* ---- giriş / kayıt / ilk kurulum ---- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-box {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 24px;
}
.auth-brand { justify-content: center; font-size: 20px; margin-bottom: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form h2 { margin: 0; font-size: 18px; }
.auth-form p { margin: 0; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.auth-form input { width: 100%; }
.auth-form .btn-primary { padding: 10px; font-size: 14px; }
.auth-form a { color: var(--accent); }
.auth-msg { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 13px;
  background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.auth-msg.ok { background: color-mix(in srgb, var(--up) 14%, var(--surface)); }
.center { text-align: center; }
input[type=password] {
  font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
.auth-form input[type=text], .auth-form input[type=password] { padding: 9px 12px; min-width: 0; }

/* ---- üst bar: kullanıcı ---- */
.user-chip { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 700;
  line-height: 18px; text-align: center; background: var(--danger); color: #fff; margin-left: 4px;
}
.banner-warn.banner-ok { background: color-mix(in srgb, var(--up) 18%, var(--surface)); }

/* ---- ayar formu ---- */
.fields { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.field > span { color: var(--text-2); }
.field input[type=number], .field input[type=password], .field select { width: 150px; flex-shrink: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--accent); }
.market-field { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--grid); }
.market-field:last-child { border-bottom: none; }
@media (max-width: 600px) {
  .field { flex-direction: column; align-items: stretch; gap: 4px; }
  .field input[type=number], .field input[type=password], .field select { width: 100%; }
  .user-chip { display: none; }
}

/* ---- yönetim paneli ---- */
.admin-nav { margin-bottom: 16px; flex-wrap: wrap; }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px 2px 3px;
  border-radius: 999px; white-space: nowrap; }
.st-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%;
  font-size: 10px; font-weight: 800; color: #fff; }
.st-ok { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up-text); }
.st-ok .st-icon { background: var(--up); }
.st-warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--text); }
.st-warn .st-icon { background: #b37d00; }
.st-crit { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--down-text); }
.st-crit .st-icon { background: var(--danger); }
.health-hero .health-main { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.health-hero .health-main .st { font-size: 15px; padding: 5px 14px 5px 5px; }
.health-hero .health-main .st-icon { width: 22px; height: 22px; font-size: 13px; }
.health-hero p { margin: 10px 0 0; }
.switch-row { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding: 12px 0;
  border-bottom: 1px solid var(--grid); flex-wrap: wrap; }
.switch-row:last-child { border-bottom: none; }
.switch-row > div:first-child { flex: 1; min-width: 220px; }
.switch-row p { margin: 2px 0 8px; }
.switch-row input[type=text] { width: 100%; }
.badge-warn { background: #b37d00; }
td .wrap, .wrap { white-space: normal; word-break: break-word; }
td:has(.wrap) { white-space: normal; min-width: 220px; }
.danger-text { color: var(--down-text); }
.log-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.log-filters input[type=text] { min-width: 160px; flex: 1; }
.log-filters input[type=date] { font: inherit; padding: 5px 6px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); }
.center-row { justify-content: center; margin-top: 12px; }
.modal-wide { max-width: 1100px; max-height: 90vh; overflow-y: auto; }
.detail-sec { margin-top: 18px; }
.detail-sec h3 { font-size: 14px; margin: 0 0 8px; }
.small-value { font-size: 18px; }
.temp-pw { font: 600 22px ui-monospace, Consolas, monospace; letter-spacing: 1px; padding: 10px 14px; text-align: center;
  background: var(--surface-2); border-radius: 8px; user-select: all; }
.setting > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.range-in { display: inline-flex; gap: 6px; align-items: center; flex-shrink: 0; }
.range-in input[type=number] { width: 100px; }
.field input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.sticky-head { position: sticky; top: 56px; z-index: 5; }
#appSettingsGroups .fields { gap: 12px; }
@media (max-width: 600px) {
  /* Telefonda "en az – en çok" kutuları yan yana, satırı paylaşır (ekrandan taşmaz) */
  .field .range-in { display: flex; width: 100%; }
  .field .range-in input[type=number] { flex: 1 1 0; min-width: 0; width: auto; }
  .field input, .field select { min-width: 0; }
  .sticky-head { position: static; }
}

/* ---- bildirimler (zil) ---- */
.bell-wrap { position: relative; }
.bell { position: relative; }
.bell .badge { position: absolute; top: -6px; right: -6px; margin: 0; }
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, calc(100vw - 24px)); z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18); overflow: hidden;
}
.notif-head, .notif-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
.notif-head { border-bottom: 1px solid var(--grid); }
.notif-foot { border-top: 1px solid var(--grid); font-size: 13px; }
.notif-foot a { color: var(--accent); }
.notif-list { max-height: min(60vh, 460px); overflow-y: auto; }
.notif {
  display: flex; gap: 10px; width: 100%; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: none; border: none; border-bottom: 1px solid var(--grid); padding: 10px 14px;
}
.notif:hover { background: var(--surface-2); }
.notif.unread { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.notif.unread .notif-text b::before { content: "● "; color: var(--accent); }
.notif-icon { font-size: 18px; line-height: 1.2; }
.notif-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; min-width: 0; }
.notif-text span { color: var(--text-2); word-break: break-word; }
.notif-text time { color: var(--muted); font-size: 11px; }
.ios-help { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.ios-help ol { margin: 6px 0 0; padding-left: 20px; }
@media (max-width: 600px) {
  .bell-wrap { position: static; }
  .notif-panel { position: fixed; left: 12px; right: 12px; top: 60px; width: auto; }
}

/* ---- gerçek para ---- */
.pill-live { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--down-text); }
.tag-live { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--down-text); }
.tile-live { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.tile-warn { margin-top: 8px; font-size: 12px; padding: 6px 8px; border-radius: 6px;
  background: color-mix(in srgb, var(--warn) 22%, var(--surface)); }
.tile-empty { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tile-empty .btn { text-decoration: none; }
.live-note { font-size: 13px; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
  background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.conn-form { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--grid); max-width: 720px; }
.conn-form h3 { font-size: 14px; margin: 0 0 10px; }
.conn-form .field input[type=text], .conn-form .field input[type=password] { width: 320px; }
.conn-form .btn-primary { margin-top: 6px; }
.key-help { background: var(--surface-2); padding: 8px 10px; border-radius: 8px; }
.conn-result { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 13px;
  background: color-mix(in srgb, var(--up) 12%, var(--surface)); }
.conn-result.bad { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.conn-result .steps { margin: 6px 0; padding-left: 20px; }
.bal { display: inline-block; margin-right: 8px; font-variant-numeric: tabular-nums; }
.watch-notice { font-size: 13px; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; background: var(--surface-2); }
.watch-notice a { color: var(--accent); }
@media (max-width: 600px) { .conn-form .field input[type=text], .conn-form .field input[type=password] { width: 100%; } }

/* İnternet erişimi */
.net-grid { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.net-grid > div:first-child { flex: 1; min-width: 260px; }
.net-state { margin: 8px 0 12px; }
.net-state .st { white-space: normal; border-radius: 12px; }
.net-url { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2, transparent); }
.net-url a { font-weight: 600; word-break: break-all; }
.net-qr { background: #fff; padding: 6px; border-radius: 8px; line-height: 0; }
.net-qr svg { width: 180px; height: 180px; }
.check-row { display: flex; gap: 8px; align-items: center; margin: 12px 0 4px; }
.invite-box { margin: 10px 0; }
.invite-code { font: 600 22px/1.2 ui-monospace, Consolas, monospace; letter-spacing: 2px; }
#fixedDomainForm input[type=text] { flex: 1; min-width: 0; max-width: 360px; }
.fixed-check { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.fixed-check .ck { display: flex; gap: 8px; align-items: flex-start; }
.fixed-check .ck b { flex-shrink: 0; width: 18px; text-align: center; }
.fixed-guide { margin-top: 12px; font-size: 13px; }
.fixed-guide summary { cursor: pointer; font-weight: 600; }
.fixed-guide ol { padding-left: 20px; line-height: 1.6; }
.fixed-guide table { margin: 8px 0; border-collapse: collapse; }
.fixed-guide td, .fixed-guide th { border: 1px solid var(--border); padding: 4px 10px; text-align: left; }
#shareText { width: 100%; }
.net-ip { font: 600 20px/1.2 ui-monospace, Consolas, monospace; margin: 6px 0; }
#shareText { width: 100%; font: 13px/1.5 ui-monospace, Consolas, monospace; resize: vertical; }
