/* Script Editörü (TradingView Pine Editor benzeri düzen, kendi tasarımımız). Yalnız sunum. Renkler tema değişkenlerinden; AA kontrast. */
.pe-content { padding: 8px; }
.pe {
  --pe-bg: #131722; --pe-panel: #1e222d; --pe-line: #2a2e39; --pe-fg: #d1d4dc; --pe-muted: #98a0b3; --pe-accent: #2962ff; --pe-accent-fg: #ffffff;
  --pe-ok: #4cd08a; --pe-err: #ff6b6b; --pe-warn: #ffb74d; --pe-hover: #2a2e39;
  --pe-s0: #5aa9ff; --pe-s1: #ffb74d; --pe-s2: #4cd08a; --pe-s3: #c8a6ff; --pe-s4: #ff6b9a; --pe-s5: #7fe0e0;
  display: flex; flex-direction: column; max-width: 1520px; margin: 0 auto; min-height: 70vh; position: relative;
  background: var(--pe-bg); color: var(--pe-fg); border: 1px solid var(--pe-line); border-radius: 8px; overflow: hidden;
}
:root[data-theme="light"] .pe {
  --pe-bg: #f3f5f9; --pe-panel: #ffffff; --pe-line: #d7dce5; --pe-fg: #1f2937; --pe-muted: #566174; --pe-accent: #1f56e0; --pe-accent-fg: #ffffff;
  --pe-ok: #0f7a3c; --pe-err: #c62828; --pe-warn: #8a5300; --pe-hover: #e8edf6;
  --pe-s0: #1f56e0; --pe-s1: #b26500; --pe-s2: #0f7a3c; --pe-s3: #6a3fb8; --pe-s4: #b01e57; --pe-s5: #0b7a7a;
}
.pe-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.pe-top {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--pe-panel); border-bottom: 1px solid var(--pe-line);
  flex: none; overflow-x: auto; scrollbar-width: thin;
}
.pe-title { margin: 0; font-size: 14px; font-weight: 700; white-space: nowrap; color: var(--pe-fg); }
.pe-spacer { flex: 1 1 8px; }
.pe-sep { width: 1px; align-self: stretch; margin: 4px 2px; background: var(--pe-line); flex: none; }
.pe-btn, .pe-select, .pe-name, .pe-input, .pe-search {
  height: 30px; border-radius: 4px; border: 1px solid var(--pe-line); background: var(--pe-bg); color: var(--pe-fg); font: inherit; font-size: 13px; padding: 0 10px; flex: none;
}
.pe-btn { cursor: pointer; font-weight: 600; white-space: nowrap; background: transparent; }
.pe-btn:hover:not(:disabled) { background: var(--pe-hover); }
.pe-btn:disabled { opacity: .6; cursor: progress; }
.pe-btn.pe-primary { background: var(--pe-accent); border-color: var(--pe-accent); color: var(--pe-accent-fg); }
.pe-btn.pe-primary:hover:not(:disabled) { filter: brightness(1.12); background: var(--pe-accent); }
.pe-btn.pe-dirty { box-shadow: 0 0 0 2px color-mix(in srgb, var(--pe-warn) 60%, transparent); }
.pe-btn.pe-run { border-color: var(--pe-ok); color: var(--pe-ok); }
.pe-btn.pe-small { height: 24px; font-size: 12px; padding: 0 8px; }
.pe-icon-btn { width: 32px; padding: 0; font-size: 16px; }
.pe-name { flex: 1 1 200px; min-width: 140px; max-width: 360px; font-weight: 600; }
.pe-state { font-size: 12px; white-space: nowrap; min-width: 84px; color: var(--pe-muted); }
.pe-state.dirty { color: var(--pe-warn); }
.pe-state.clean { color: var(--pe-ok); }
.pe-select { padding: 0 6px; }
.pe-sym { width: 110px; text-transform: uppercase; }
.pe :focus-visible { outline: 2px solid var(--pe-accent); outline-offset: 1px; }
:root[data-theme="dark"] .pe :focus-visible { outline-color: #7aa7ff; }
.pe-guard { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; background: color-mix(in srgb, var(--pe-warn) 18%, var(--pe-panel)); border-bottom: 1px solid var(--pe-warn); font-size: 13px; }
.pe-guard[hidden], .pe [hidden] { display: none !important; }
/* Oturum kapısı kartı (AFD-17): araç çubuğunun altında, editörü örtmeden. */
.pe-kapi .oturum-kapisi { margin: 8px 12px; padding: 16px; }
.pe-main { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }
.pe-side { width: 260px; flex: none; display: flex; flex-direction: column; background: var(--pe-panel); border-inline-end: 1px solid var(--pe-line); min-height: 0; }
.pe-main.side-closed .pe-side { display: none; }
.pe-side-head { padding: 8px; border-bottom: 1px solid var(--pe-line); }
.pe-search { width: 100%; box-sizing: border-box; }
.pe-list { flex: 1; overflow-y: auto; padding: 6px; }
.pe-item { display: flex; align-items: stretch; border-radius: 6px; margin-bottom: 2px; border: 1px solid transparent; }
.pe-item:hover { background: var(--pe-hover); }
.pe-item.active { background: color-mix(in srgb, var(--pe-accent) 22%, transparent); border-color: color-mix(in srgb, var(--pe-accent) 55%, transparent); }
.pe-item-open { flex: 1; min-width: 0; text-align: start; background: transparent; border: 0; color: inherit; font: inherit; padding: 8px 10px; cursor: pointer; display: block; }
.pe-item-name { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-item-meta { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--pe-muted); margin-top: 2px; }
.pe-lang { padding: 0 6px; border-radius: 3px; border: 1px solid var(--pe-line); font-weight: 700; font-size: 10px; letter-spacing: .02em; }
.pe-lang-pine { color: var(--pe-s2); } .pe-lang-metastock { color: var(--pe-s1); } .pe-lang-csharp { color: var(--pe-s0); }
.pe-item-del { flex: none; width: 34px; background: transparent; border: 0; color: var(--pe-muted); font-size: 16px; cursor: pointer; border-radius: 6px; }
.pe-item-del:hover, .pe-item-del.armed { color: var(--pe-err); }
.pe-item-del.armed { width: auto; padding: 0 8px; font-size: 12px; font-weight: 700; }
.pe-work { --pe-panel-h: 220px; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.pe-ed { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pe-work.dock-right { --pe-panel-w: 460px; flex-direction: row; }
.pe-work.dock-right .pe-resizer { width: 6px; height: auto; cursor: ew-resize; }
.pe-work.dock-right .pe-resizer::after { left: 1px; top: 50%; width: 4px; height: 36px; margin: -18px 0 0; }
.pe-work.dock-right .pe-panel { width: var(--pe-panel-w); height: auto; }
.pe-editor { flex: 1 1 auto; min-height: 120px; display: flex; flex-direction: column; }
.pe-editor .ke { flex: 1 1 auto; }
.pe-statusbar { display: flex; gap: 14px; align-items: center; padding: 3px 12px; font-size: 12px; background: var(--pe-panel); color: var(--pe-muted); border-top: 1px solid var(--pe-line); flex: none; overflow: hidden; white-space: nowrap; }
.pe-status-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--pe-fg); }
.pe-cursor { min-width: 130px; font-variant-numeric: tabular-nums; }
.pe-resizer { height: 6px; flex: none; cursor: ns-resize; background: var(--pe-line); touch-action: none; position: relative; }
.pe-resizer::after { content: ''; position: absolute; left: 50%; top: 1px; width: 36px; height: 4px; margin-inline-start: -18px; border-radius: 2px; background: var(--pe-muted); opacity: .6; }
.pe-resizer:hover, .pe-resizer:focus-visible { background: var(--pe-accent); }
.pe-panel { height: var(--pe-panel-h); flex: none; display: flex; flex-direction: column; background: var(--pe-panel); min-height: 0; }
.pe-tabs { display: flex; align-items: center; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--pe-line); flex: none; overflow-x: auto; }
.pe-tab { height: 32px; padding: 0 12px; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--pe-muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.pe-tab:hover { color: var(--pe-fg); }
.pe-tab[aria-selected="true"] { color: var(--pe-fg); border-bottom-color: var(--pe-accent); }
.pe-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--pe-err); color: #fff; font-size: 11px; text-align: center; }
:root[data-theme="light"] .pe-badge { background: #c62828; }
.pe-runctl { margin-inline-start: auto; display: flex; gap: 6px; padding: 3px 0; }
.pe-runctl .pe-sym, .pe-runctl .pe-select { height: 26px; font-size: 12px; }
.pe-tabpanel { flex: 1 1 auto; overflow: auto; padding: 8px 12px; font-size: 13px; min-height: 0; }
.pe-con-head { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.pe-con-list { list-style: none; margin: 0; padding: 0; font-family: var(--ke-font, ui-monospace, Consolas, monospace); font-size: 12px; }
.pe-con-item { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; flex-wrap: wrap; }
.pe-con-ico { width: 14px; text-align: center; font-weight: 700; flex: none; }
.pe-con-time { color: var(--pe-muted); flex: none; }
.pe-err .pe-con-ico, .pe-err .pe-con-text { color: var(--pe-err); }
.pe-warn .pe-con-ico, .pe-warn .pe-con-text { color: var(--pe-warn); }
.pe-ok .pe-con-ico, .pe-ok .pe-con-text { color: var(--pe-ok); }
.pe-info .pe-con-text { color: var(--pe-muted); }
.pe-link { background: none; border: 0; padding: 0; color: var(--pe-s0); text-decoration: underline; cursor: pointer; font: inherit; }
.pe-empty, .pe-unavail, .pe-loading { color: var(--pe-muted); padding: 10px 2px; }
.pe-unavail { color: var(--pe-warn); }
.pe-res-head { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; color: var(--pe-muted); }
.pe-res-head strong { color: var(--pe-fg); }
.pe-chart { width: 100%; height: 150px; display: block; background: var(--pe-bg); border: 1px solid var(--pe-line); border-radius: 6px; }
.pe-grid { stroke: var(--pe-line); stroke-width: 1; }
.pe-axis { fill: var(--pe-muted); font-size: 10px; font-family: system-ui, sans-serif; }
.pe-line { stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.pe-line.pe-s1 { stroke-dasharray: 6 3; } .pe-line.pe-s2 { stroke-dasharray: 2 3; } .pe-line.pe-s3 { stroke-dasharray: 8 3 2 3; }
.pe-s0 { stroke: var(--pe-s0); background: var(--pe-s0); } .pe-s1 { stroke: var(--pe-s1); background: var(--pe-s1); } .pe-s2 { stroke: var(--pe-s2); background: var(--pe-s2); }
.pe-s3 { stroke: var(--pe-s3); background: var(--pe-s3); } .pe-s4 { stroke: var(--pe-s4); background: var(--pe-s4); } .pe-s5 { stroke: var(--pe-s5); background: var(--pe-s5); }
.pe-chart .pe-line { background: none; }
.pe-legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 6px 0; font-size: 12px; }
.pe-sw { display: inline-block; width: 14px; height: 3px; margin-inline-end: 5px; vertical-align: middle; }
.pe-table-wrap { overflow-x: auto; margin-top: 8px; }
.pe-table { border-collapse: collapse; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
.pe-table th, .pe-table td { padding: 4px 10px; border-bottom: 1px solid var(--pe-line); text-align: start; white-space: nowrap; }
.pe-table th { color: var(--pe-muted); font-weight: 600; position: sticky; top: 0; background: var(--pe-panel); }
.pe-table .pe-num { text-align: end; }
.pe-loss td:nth-child(4) { color: var(--pe-err); } .pe-gain td:nth-child(4) { color: var(--pe-ok); }
.pe-strat-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.pe-note { color: var(--pe-muted); font-size: 12px; margin: 4px 0; }
.pe-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.pe-stat { background: var(--pe-bg); border: 1px solid var(--pe-line); border-radius: 6px; padding: 6px 10px; }
.pe-stat-k { font-size: 11px; color: var(--pe-muted); }
.pe-stat-v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pe-menu-wrap { position: relative; flex: none; }
.pe-menu { position: fixed; z-index: 50; min-width: 260px; max-height: 60vh; overflow: auto; padding: 4px; margin-top: 4px; background: var(--pe-panel); border: 1px solid var(--pe-line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.pe-menu-item { display: block; width: 100%; text-align: start; padding: 7px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--pe-fg); font: inherit; font-size: 13px; cursor: pointer; }
.pe-menu-item:hover, .pe-menu-item:focus-visible { background: var(--pe-hover); }
.pe-menu-note { padding: 8px 10px; color: var(--pe-muted); font-size: 12px; }
.pe-side-backdrop { display: none; }
.pe .app-skeleton { color: var(--pe-muted); padding: 10px; }
.pe-content .app-disclaimer { max-width: 1520px; margin: 8px auto 0; }

@media (max-width: 900px) {
  .pe-side { width: 220px; }
  .pe-hint { display: none; }
}
@media (max-width: 640px) {
  .pe-content { padding: 4px; }
  .pe { border-radius: 0; border-inline: 0; }
  .pe-top { flex-wrap: nowrap; padding: 6px; }
  .pe-side { position: absolute; z-index: 20; inset-block: 0; inset-inline-start: 0; width: min(86vw, 300px); box-shadow: 8px 0 24px rgba(0, 0, 0, .4); }
  .pe-main.side-closed .pe-side { display: none; }
  .pe-side-backdrop { display: block; position: absolute; inset: 0; z-index: 10; background: rgba(0, 0, 0, .45); }
  .pe-panel { flex-direction: column-reverse; }
  .pe-tabs { border-bottom: 0; border-top: 1px solid var(--pe-line); }
  .pe-runctl { margin-inline-start: 8px; }
  .pe-cursor { min-width: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .pe-btn, .pe-tab { transition: background-color .12s, color .12s; }
}
