/*
 * Kule — EmAlgoLab subscriber UI system.
 * Familiar retail-investing look: white surfaces on a soft grey page,
 * rounded controls, one blue for actions, green/red only for Long/Short and P/L,
 * soft amber reserved for pending (unsaved) changes.
 * Source of truth for tokens and components: DESIGN.md.
 */

/* ---------- Tokens ---------- */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f3;
  --ink: #14171c;
  --ink-2: #5b6470;
  --ink-3: #737b86;
  --line: #e4e7eb;
  --line-strong: #d3d7dd;
  --primary: #1d5fd1;
  --primary-hover: #174fb0;
  --primary-soft: #e9f0fc;
  --on-primary: #ffffff;
  --long: #12805c;
  --long-soft: #e5f4ed;
  --short: #c9372a;
  --short-soft: #fbeae8;
  --warn: #c2610c;
  --pending: #e0a100;
  --pending-soft: #fff5d6;
  --profit: #12805c;
  --loss: #c9372a;
  --focus: #1d5fd1;
  --shadow-1: 0 1px 2px rgb(20 23 28 / 0.06), 0 1px 1px rgb(20 23 28 / 0.04);
  --shadow-2: 0 6px 16px -6px rgb(20 23 28 / 0.2), 0 2px 4px rgb(20 23 28 / 0.06);

  --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;

  --t-xs: 0.75rem;
  --t-sm: 0.8125rem;
  --t-md: 0.9375rem;
  --t-lg: 1.0625rem;
  --t-xl: 1.25rem;
  --t-2xl: 1.625rem;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --row: 56px;
  --header: 60px;
  --side: 340px;
  --ease: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1c2128;
    --surface-3: #252b33;
    --ink: #eef1f4;
    --ink-2: #a7b0bb;
    --ink-3: #8a94a0;
    --line: #2a3038;
    --line-strong: #363d47;
    --primary: #5b93ff;
    --primary-hover: #7aa8ff;
    --primary-soft: #1c2a44;
    --on-primary: #0f1216;
    --long: #3fbf8c;
    --long-soft: #16302a;
    --short: #ff6b5e;
    --short-soft: #3a1f1d;
    --warn: #f5964a;
    --pending: #f2bd3a;
    --pending-soft: #3a3116;
    --profit: #3fbf8c;
    --loss: #ff6b5e;
    --focus: #5b93ff;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 6px 16px -6px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1c2128;
  --surface-3: #252b33;
  --ink: #eef1f4;
  --ink-2: #a7b0bb;
  --ink-3: #8a94a0;
  --line: #2a3038;
  --line-strong: #363d47;
  --primary: #5b93ff;
  --primary-hover: #7aa8ff;
  --primary-soft: #1c2a44;
  --on-primary: #0f1216;
  --long: #3fbf8c;
  --long-soft: #16302a;
  --short: #ff6b5e;
  --short-soft: #3a1f1d;
  --warn: #f5964a;
  --pending: #f2bd3a;
  --pending-soft: #3a3116;
  --profit: #3fbf8c;
  --loss: #ff6b5e;
  --focus: #5b93ff;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-2: 0 6px 16px -6px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.kule {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t-md)/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}
.kule ::selection { background: var(--primary-soft); color: var(--ink); }
.kule :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:where(.kule) a { color: inherit; text-underline-offset: 3px; }
:where(.kule) :is(input, button, select) { font: inherit; color: inherit; caret-color: var(--primary); }
:where(.kule) button { cursor: pointer; }
.kule * { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.kule h1, .kule h2, .kule h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
.kule .muted { color: var(--ink-2); }
.kule .profit { color: var(--profit); }
.kule .loss { color: var(--loss); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.shelf {
  position: sticky; top: 0; z-index: 30;
  height: var(--header);
  display: flex; align-items: center; gap: var(--s-5);
  padding: 0 var(--s-5);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
/* Brand lockup: EmAlgoLab "E" mark + wordmark. The SVG mark takes the text colour. */
.brand-mark { display: block; flex: none; }
/* 1em tall ≈ 1.4× cap height; nudged up so the mark centres on the capitals, not the line box. */
svg.brand-mark { height: 1em; width: calc(1em * 76 / 72); transform: translateY(-0.04em); }
img.brand-mark { height: 28px; width: auto; max-width: 140px; object-fit: contain; }
.shelf-brand { display: inline-flex; align-items: center; gap: 0.45em; font-weight: 700; font-size: var(--t-lg); letter-spacing: -0.015em; line-height: 1; color: var(--ink); text-decoration: none; white-space: nowrap; }
.shelf-nav { display: flex; gap: var(--s-1); }
.shelf-nav a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
.shelf-nav a:hover { color: var(--ink); background: var(--surface-3); }
.shelf-nav a[aria-current="page"] { color: var(--ink); background: var(--surface-3); }
.shelf-end { margin-left: auto; display: flex; align-items: center; gap: var(--s-1); }
.shelf-icon {
  position: relative; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 999px;
  background: none; border: 0; color: var(--ink-2); text-decoration: none; font-size: 1.1rem;
}
.shelf-icon:hover { background: var(--surface-3); color: var(--ink); }
.shelf-icon .count {
  position: absolute; top: 4px; right: 4px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--short); color: #fff;
  font: 700 11px/18px var(--font); text-align: center;
}

/* ---------- Layout ---------- */
.console {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side);
  gap: var(--s-5);
  max-width: 1480px; margin: 0 auto;
  padding: var(--s-5);
}
.page { max-width: 1200px; margin: 0 auto; padding: var(--s-5) var(--s-5) var(--s-6); }
.frame-wrap { min-width: 0; display: flex; flex-direction: column; gap: var(--s-4); }
.page-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-3) var(--s-4); }
.page-head h1 { font-size: var(--t-2xl); }
.page-head .grow { flex: 1; }
.stack { display: grid; gap: var(--s-4); }

/* Status chips: account state at a glance */
.status { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: var(--t-sm); font-weight: 600; color: var(--ink-2);
  text-decoration: none; white-space: nowrap;
}
:is(button, a).chip:hover { border-color: var(--line-strong); color: var(--ink); }
.only-stacked { display: none !important; }
.chip b { color: var(--ink); font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 999px; flex: none; background: var(--ink-3); }
.dot.ok { background: var(--long); }
.dot.bad { background: var(--short); }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.panel-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: var(--t-lg); }
.panel-head .grow { flex: 1; }
.panel-body { padding: var(--s-4) var(--s-5); }
.panel > .frame { border-radius: 0 0 var(--r-lg) var(--r-lg); overflow: hidden; }

/* ---------- Toolbar ---------- */
.symtabs { display: flex; gap: var(--s-2); overflow-x: auto; padding: var(--s-4) var(--s-5) 0; }
.command { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding: var(--s-3) var(--s-5) var(--s-4); border-bottom: 1px solid var(--line); }
.command .grow { flex: 1; }
.search {
  display: flex; align-items: center; gap: var(--s-2);
  height: 40px; padding: 0 var(--s-3); border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  min-width: 220px; flex: 1; max-width: 320px;
}
.search:focus-within { border-color: var(--primary); background: var(--surface); }
.search input { border: 0; background: none; outline: none; width: 100%; height: 100%; }
.search input:focus-visible { outline: none; } /* the pill shows focus via :focus-within */
.search input::-webkit-search-cancel-button { cursor: pointer; }

.symtab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.symtab:hover { color: var(--ink); border-color: var(--line-strong); }
.symtab[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.symtab .meta { font-weight: 500; font-size: var(--t-xs); opacity: 0.8; }
.symtab img { width: 18px; height: 18px; }
.symtab.has-pending::after { content: ""; position: absolute; top: 2px; right: 2px; width: 9px; height: 9px; border-radius: 999px; background: var(--pending); box-shadow: 0 0 0 2px var(--surface); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-3); }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: none; color: var(--ink-2); font-weight: 600; font-size: var(--t-sm); }
.seg button:hover { color: var(--ink); }
.seg > [aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
/* Editable threshold inside a segmented control (e.g. "Başarı ≥ %70") */
.seg-num { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 8px 0 14px; border-radius: 999px; color: var(--ink-2); font-weight: 600; font-size: var(--t-sm); cursor: pointer; white-space: nowrap; }
.seg-num:hover { color: var(--ink); }
.seg-num input { width: 4ch; height: 24px; padding: 0 2px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); text-align: center; font-weight: 700; outline: none; }
.seg-num input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.seg-num input[aria-invalid="true"] { border-color: var(--short); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 var(--s-4); border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background var(--ease), border-color var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: none; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { height: 32px; padding: 0 12px; font-size: var(--t-sm); }
.btn-lg { height: 46px; padding: 0 var(--s-5); font-size: var(--t-lg); }
.btn-block { width: 100%; }
.btn .bi { font-size: 1.05em; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.input {
  height: 42px; padding: 0 var(--s-3); border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  outline: none; width: 100%;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder { color: var(--ink-3); }
.input[aria-invalid="true"] { border-color: var(--short); box-shadow: 0 0 0 3px var(--short-soft); }
.input.is-pending { background: var(--pending-soft); border-color: var(--pending); }
.input.is-preview { border-style: dashed; border-color: var(--pending); }
.field-hint { font-size: var(--t-xs); color: var(--ink-2); }
.field-error { font-size: var(--t-xs); color: var(--short); }

/* ---------- Strategy table ---------- */
.frame { width: 100%; border-collapse: collapse; table-layout: fixed; }
.frame thead th {
  height: 40px; padding: 0 var(--s-3);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: var(--t-xs); font-weight: 600; color: var(--ink-2);
  text-align: left; white-space: nowrap;
}
.frame th:first-child, .frame td:first-child { padding-left: var(--s-5); }
.frame th:last-child, .frame td:last-child { padding-right: var(--s-5); }
.frame th.r, .frame td.r { text-align: right; }
.frame td { height: var(--row); padding: 0 var(--s-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.frame tbody tr { transition: background var(--ease); }
.frame tbody tr:hover td { background: var(--surface-2); }
.frame tbody tr.is-selected td { background: var(--primary-soft); }
.frame tbody tr[hidden] { display: none; }
.frame .section td { height: 44px; background: var(--surface-2) !important; }
.section-title { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; }
.section-title .muted { font-weight: 500; font-size: var(--t-sm); }
.section-title img { width: 20px; height: 20px; }

.col-sel { width: 52px; }
.col-lever { width: 80px; }
.col-dir { width: 90px; }
.col-ver { width: 130px; }
.col-lot { width: 104px; }
.col-pip { width: 176px; }

.check { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; vertical-align: middle; }

/* Strategy number: quiet reference used for search */
.plate { color: var(--ink-3); font-size: var(--t-xs); font-weight: 600; margin-left: 6px; }
.plate::before { content: "#"; }
tr.is-saving td { opacity: 0.6; }
tr.is-error .s-name { color: var(--short); }

/* Switch */
.lever {
  position: relative; width: 44px; height: 26px; padding: 0; flex: none;
  border: 0; border-radius: 999px; background: var(--line-strong);
  transition: background var(--ease), box-shadow var(--ease);
}
.lever::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform var(--ease);
}
.lever[aria-checked="true"] { background: var(--primary); }
.lever[aria-checked="true"]::after { transform: translateX(18px); }
.lever:disabled, tr.is-locked .lever { opacity: 0.45; cursor: not-allowed; }
tr.is-pending .lever { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--pending); }

/* Direction badge */
.dir { display: inline-flex; align-items: center; white-space: nowrap; height: 24px; padding: 0 10px; border-radius: 999px; font-size: var(--t-xs); font-weight: 700; }
.dir-long { background: var(--long-soft); color: var(--long); }
.dir-short { background: var(--short-soft); color: var(--short); }
.dir-both { background: var(--surface-3); color: var(--ink-2); }

/* Market trend badge (section header) */
.trend { display: inline-flex; align-items: center; gap: 8px; height: 30px; margin-left: var(--s-2); padding: 0 12px 0 10px; border-radius: 999px; font-size: var(--t-sm); font-weight: 700; white-space: nowrap; }
.trend-line { width: 30px; height: 16px; overflow: visible; }
.trend-line polyline { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: trend-draw 0.9s ease-out 0.2s forwards; }
.trend-line circle { fill: currentColor; transform-box: fill-box; transform-origin: center; opacity: 0; animation: trend-pulse 2.4s ease-out 1.1s infinite; }
@keyframes trend-draw { to { stroke-dashoffset: 0; } }
@keyframes trend-pulse { 0% { opacity: 1; transform: scale(1); } 60% { opacity: 1; transform: scale(1.35); } 100% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .trend-line polyline { animation: none; stroke-dashoffset: 0; }
  .trend-line circle { animation: none; opacity: 1; }
}
.trend-up { background: var(--long-soft); color: var(--long); }
.trend-down { background: var(--short-soft); color: var(--short); }
.trend-flat { background: var(--surface-3); color: var(--ink-2); }

.s-name { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.s-desc { display: block; font-size: var(--t-xs); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ver { display: inline-flex; gap: var(--s-3); font-size: var(--t-sm); }
/* Success rate bands (same thresholds as the old UI): >%80 good, >%70 caution, else weak */
.ver span { font-weight: 600; }
.ver .high { color: var(--long); }
.ver .mid { color: var(--warn); }
.ver .low { color: var(--short); font-weight: 700; }
.cell-pip { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.cell-pip .input { width: 72px; height: 36px; text-align: right; }
.cell-pip .usd { font-size: var(--t-xs); min-width: 7ch; text-align: right; font-weight: 600; white-space: nowrap; }
.cell-lot .input { width: 80px; height: 36px; text-align: right; margin-left: auto; display: block; }

.frame-empty { padding: var(--s-6); text-align: center; color: var(--ink-2); }
.frame-empty[hidden] { display: none; }
.frame-empty .btn { margin-top: var(--s-3); }

/* ---------- Floating bars: selection actions + unsaved changes ---------- */
.floatdock { position: sticky; bottom: var(--s-4); z-index: 25; display: grid; gap: var(--s-2); }
.floatdock:empty { display: none; }
.floatbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2) var(--s-3);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-5);
  border-radius: 999px; box-shadow: var(--shadow-2);
}
.floatbar[hidden] { display: none; }
.floatbar .grow { flex: 1; }
.selbar { background: var(--surface); }
.selbar-count { font-weight: 700; }
.pending-bar { background: var(--pending-soft); }
.pending-count { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; }
.pending-count [data-pending-n] { min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--pending); color: #1d1606; font-size: var(--t-sm); }
.pending-detail { color: var(--ink-2); font-size: var(--t-sm); }
.save-state { font-size: var(--t-sm); color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.save-state:empty { display: none; }
.save-state.ok { color: var(--long); }
.save-state.err { color: var(--short); }

/* Popover for changing a value on many strategies */
details.popover { position: relative; }
details.popover > summary { list-style: none; }
details.popover > summary::-webkit-details-marker { display: none; }
.popover-body {
  position: absolute; bottom: calc(100% + 14px); right: 0; z-index: 40;
  width: 320px; padding: var(--s-5); border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-2);
  display: grid; gap: var(--s-4);
}
.popover-body h2 { font-size: var(--t-lg); }
.popover-body .field-hint { margin-top: -8px; }

/* ---------- Side column ---------- */
.side { display: flex; flex-direction: column; gap: var(--s-4); align-self: start; position: sticky; top: calc(var(--header) + var(--s-5)); }
.side-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-1); }
.side-section h2 { font-size: var(--t-lg); margin-bottom: var(--s-3); display: flex; align-items: center; gap: var(--s-2); }
.side-section h2 .chip { margin-left: auto; height: 26px; }
.big-number { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.readings { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3) var(--s-4); margin: var(--s-4) 0 0; }
.readings dt { font-size: var(--t-xs); color: var(--ink-2); }
.readings dd { margin: 2px 0 0; font-weight: 600; }
.readings .wide { grid-column: 1 / -1; }
.form-grid { display: grid; gap: var(--s-3); }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-top: var(--s-4); }

.gauge-track { position: relative; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.gauge-zero { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink-3); }
.gauge-fill { position: absolute; top: 0; bottom: 0; }
.gauge-fill.profit { background: var(--profit); }
.gauge-fill.loss { background: var(--loss); }
.gauge-scale { display: flex; justify-content: space-between; font-size: var(--t-xs); color: var(--ink-2); margin-top: 6px; }

details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--s-2); font-weight: 700; font-size: var(--t-lg); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .bi-chevron-down { margin-left: auto; transition: transform var(--ease); }
details.fold[open] > summary .bi-chevron-down { transform: rotate(180deg); }
details.fold[open] > summary { margin-bottom: var(--s-4); }

/* ---------- Notice ---------- */
.notice { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r); background: var(--short-soft); color: var(--ink); }
.notice[hidden] { display: none; }
.notice .bi { color: var(--short); font-size: 1.2em; }
.notice.info { background: var(--primary-soft); }
.notice.info .bi { color: var(--primary); }

/* ---------- Toast ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--header) + 12px); z-index: 50; display: grid; gap: var(--s-2); justify-items: center; }
.toast {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: var(--surface); font-weight: 600; font-size: var(--t-sm);
  box-shadow: var(--shadow-2);
  animation: toast-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.err { background: var(--short); color: #fff; }
@keyframes toast-in { from { transform: translateY(-6px); opacity: 0; } }

/* ---------- Generic list table ---------- */
.ledger { width: 100%; border-collapse: collapse; }
.ledger th { height: 40px; padding: 0 var(--s-5); text-align: left; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); }
.ledger td { height: 52px; padding: 0 var(--s-5); border-bottom: 1px solid var(--line); }
.ledger tr:last-child td { border-bottom: 0; }
.ledger .r { text-align: right; }

/* Summary row */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-4); margin: 0; }
.strip > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-4) var(--s-5); box-shadow: var(--shadow-1); }
.strip dt { font-size: var(--t-sm); color: var(--ink-2); font-weight: 600; }
.strip dd { margin: 6px 0 0; font-size: var(--t-2xl); font-weight: 700; letter-spacing: -0.02em; }
.strip .sub { font-size: var(--t-xs); color: var(--ink-2); margin: 4px 0 0; }

/* Notifications */
.note-row td { height: auto; padding-top: var(--s-3); padding-bottom: var(--s-3); }
.note-row td:first-child { width: 36px; padding-right: 0; }
.note-row .ndot { width: 8px; height: 8px; border-radius: 999px; background: var(--primary); display: inline-block; }
.note-row.read .ndot { background: transparent; }
.note-row.read .note-title { font-weight: 500; color: var(--ink-2); }
.note-title { font-weight: 700; }
.note-body { display: block; font-size: var(--t-sm); color: var(--ink-2); }
.tag { display: inline-block; white-space: nowrap; padding: 3px 10px; border-radius: 999px; font-size: var(--t-xs); font-weight: 600; background: var(--surface-3); color: var(--ink-2); }

/* Auth: form on the left, system-flow panel on the right (desktop only) */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s-5); }
.auth-card { width: min(420px, 100%); background: var(--surface); border-radius: var(--r-lg); padding: var(--s-6); box-shadow: var(--shadow-2); }
.auth-card .shelf-brand { margin-bottom: var(--s-5); }
.auth-card h1 { font-size: var(--t-2xl); margin-bottom: var(--s-1); }
.auth-card form { display: grid; gap: var(--s-4); margin-top: var(--s-5); }
.auth-card .alt { margin: var(--s-4) 0 0; font-size: var(--t-sm); color: var(--ink-2); text-align: center; }

body.kule.auth-page { background: var(--surface); }
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-pane { display: flex; flex-direction: column; gap: var(--s-6); padding: var(--s-6) clamp(24px, 5vw, 72px); }
.auth-pane > .shelf-brand { align-self: flex-start; }
.auth-form { width: min(400px, 100%); margin: auto; display: grid; gap: var(--s-5); }
.auth-form h1 { font-size: 2rem; letter-spacing: -0.02em; line-height: 1.15; }
.auth-form .lede { margin: var(--s-2) 0 0; color: var(--ink-2); }
.auth-form form { display: grid; gap: var(--s-4); }
.auth-form .alt { margin: 0; padding-top: var(--s-4); border-top: 1px solid var(--line); font-size: var(--t-sm); color: var(--ink-2); }
.auth-form .alt a { color: var(--primary); font-weight: 700; text-decoration: none; }
.auth-form .alt a:hover { text-decoration: underline; }
.auth-foot { font-size: var(--t-xs); color: var(--ink-2); display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }
.auth-foot a { text-decoration: none; }
.auth-foot a:hover { color: var(--ink); text-decoration: underline; }
.captcha { min-height: 78px; }
.captcha > div { max-width: 100%; }

.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 48px; }
.pass-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 34px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); display: grid; place-items: center; }
.pass-toggle:hover { background: var(--surface-3); color: var(--ink); }

.form-alert { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r); background: var(--short-soft); color: var(--ink); font-size: var(--t-sm); }
.form-alert .bi { color: var(--short); font-size: 1.1em; line-height: 1.3; }

/* Auth side panel: the system's own flow drawn in SVG (signal → your rules → MT5 accounts).
   Fixed dark in both themes, same palette as the landing scene. Final frame is the default state,
   so reduced-motion users get the completed flow; the loop only runs when motion is allowed. */
.auth-visual {
  position: relative; isolation: isolate; overflow: hidden;
  margin: 12px 12px 12px 0; border-radius: 24px;
  display: flex; flex-direction: column; gap: clamp(20px, 4vh, 40px);
  padding: clamp(28px, 4vw, 48px);
  background: radial-gradient(70% 45% at 50% 6%, rgb(61 123 255 / 0.2), transparent 70%), #06080d;
  color: #eef2f7;
}
.auth-visual::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(rgb(255 255 255 / 0.035) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 0.035) 1px, transparent 1px);
  background-size: 40px 40px; background-position: center;
  mask-image: radial-gradient(ellipse 75% 60% at 50% 38%, #000 25%, transparent 80%);
}
.auth-flow { flex: 1 1 0; min-height: 0; width: 100%; display: block; overflow: visible; font-family: var(--font); }
.auth-flow text { fill: #eef2f7; }
.auth-flow .af-ink { fill: #eef2f7; }
.auth-flow .af-muted { fill: #9aa5b5; font-weight: 600; }
.auth-flow .af-dim, .auth-flow .af-dim tspan { fill: #6b7686; }
.auth-flow .af-buy { fill: #22c38e; }
.af-box { fill: rgb(16 21 31 / 0.9); stroke: rgb(255 255 255 / 0.1); stroke-width: 1; }
.af-signal .af-box { stroke: rgb(107 155 255 / 0.55); }
.af-rules .af-box { stroke: rgb(107 155 255 / 0.45); }
.af-acct-box { stroke: rgb(34 195 142 / 0.45); }
.af-chip rect { fill: rgb(255 255 255 / 0.05); stroke: rgb(255 255 255 / 0.1); }
.auth-flow .af-chip text { fill: #c7d0dc; font-size: 12px; font-weight: 600; }
.af-rail path { fill: none; stroke: rgb(255 255 255 / 0.1); stroke-width: 1.5; }
.af-rail .af-rail-off { stroke-dasharray: 3 6; stroke-linecap: round; }
.af-beam path { fill: none; stroke: url(#af-beam); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; filter: drop-shadow(0 0 4px rgb(107 155 255 / 0.6)); }
.af-wait rect { fill: rgb(255 255 255 / 0.05); }
.auth-flow .af-wait text { fill: #8a94a0; font-size: 12px; font-weight: 700; }
.af-wait:not(.af-off) { opacity: 0; }
.af-open rect { fill: rgb(34 195 142 / 0.16); }
.af-open circle { fill: #22c38e; }
.auth-flow .af-open text { fill: #22c38e; font-size: 12px; font-weight: 700; }
.af-acct-off { opacity: 0.6; }

@media (prefers-reduced-motion: no-preference) {
  .af-signal .af-box, .af-rules .af-box, .af-acct-box, .af-beam path, .af-wait:not(.af-off), .af-open { animation: 7s ease-in-out infinite both; }
  .af-signal .af-box { animation-name: af-signal; }
  .af-rules .af-box { animation-name: af-rules; }
  .af-beam .af-beam-in { animation-name: af-beam-in; }
  .af-beam .af-beam-out { animation-name: af-beam-out; }
  .af-acct-box { animation-name: af-acct; }
  .af-wait:not(.af-off) { animation-name: af-wait; }
  .af-open { animation-name: af-open; }
}
@keyframes af-signal {
  0%, 2% { stroke: rgb(255 255 255 / 0.1); }
  8%, 86% { stroke: rgb(107 155 255 / 0.55); }
  96%, 100% { stroke: rgb(255 255 255 / 0.1); }
}
@keyframes af-beam-in {
  0%, 8% { stroke-dashoffset: 1; opacity: 1; }
  20%, 86% { stroke-dashoffset: 0; opacity: 1; }
  96%, 100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes af-rules {
  0%, 19% { stroke: rgb(255 255 255 / 0.1); }
  25%, 86% { stroke: rgb(107 155 255 / 0.45); }
  96%, 100% { stroke: rgb(255 255 255 / 0.1); }
}
@keyframes af-beam-out {
  0%, 28% { stroke-dashoffset: 1; opacity: 1; }
  42%, 86% { stroke-dashoffset: 0; opacity: 1; }
  96%, 100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes af-acct {
  0%, 41% { stroke: rgb(255 255 255 / 0.1); }
  47%, 86% { stroke: rgb(34 195 142 / 0.45); }
  96%, 100% { stroke: rgb(255 255 255 / 0.1); }
}
@keyframes af-wait {
  0%, 41% { opacity: 1; }
  45%, 88% { opacity: 0; }
  96%, 100% { opacity: 1; }
}
@keyframes af-open {
  0%, 41% { opacity: 0; }
  45%, 88% { opacity: 1; }
  96%, 100% { opacity: 0; }
}
.auth-visual-copy { display: grid; gap: var(--s-4); }
.auth-visual-copy h2 { font-size: clamp(1.5rem, 2.2vw, 2rem); line-height: 1.2; letter-spacing: -0.02em; max-width: 22ch; }
.auth-visual-copy ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); font-size: var(--t-md); color: rgb(238 242 247 / 0.8); }
.auth-visual-copy li { display: flex; gap: var(--s-2); align-items: baseline; }
.auth-visual-copy .bi { color: #6b9bff; }
/* Short desktop windows: the copy keeps its room, the diagram gives way first. */
@media (max-height: 620px) { .auth-flow { display: none; } .auth-visual { justify-content: flex-end; } }

@media (max-width: 899px) {
  .auth-split { grid-template-columns: minmax(0, 1fr); }
  .auth-visual { display: none; }
  .auth-pane { padding: var(--s-5) var(--s-4); gap: var(--s-5); }
  .auth-form h1 { font-size: var(--t-2xl); }
}

/* Narrow single-panel page (password, simple forms) */
.page-narrow { max-width: 560px; }
.page-narrow .panel-body { display: grid; gap: var(--s-4); padding: var(--s-5); }
.rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: var(--t-xs); color: var(--ink-2); }
.rules li { display: flex; gap: 6px; align-items: center; }
.rules li.ok { color: var(--long); }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s-2); padding: var(--s-4); border-top: 1px solid var(--line); }
.pager .muted { font-size: var(--t-sm); padding: 0 var(--s-2); }

/* Empty state inside a panel */
.empty { padding: var(--s-6) var(--s-5); text-align: center; color: var(--ink-2); display: grid; justify-items: center; gap: var(--s-2); }
.empty .bi { font-size: 1.75rem; color: var(--ink-3); }
.empty strong { color: var(--ink); font-size: var(--t-lg); }
.empty[hidden] { display: none; }

/* Chart (P/L bars, inline SVG) */
.chart { display: block; width: 100%; height: 220px; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .bar-p { fill: var(--profit); }
.chart .bar-l { fill: var(--loss); }
.chart text { fill: var(--ink-2); font: 500 11px var(--font); }

/* Notifications columns */
.note-tag { width: 150px; }
.note-when { width: 150px; white-space: nowrap; }
.note-act { width: 150px; white-space: nowrap; }
.note-row[hidden] { display: none; }

/* P/L */
.pl-periods { flex-wrap: wrap; border-radius: var(--r-lg); }
.pl-custom { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-5); }
.pl-custom[hidden] { display: none; }
.pl-custom .field { min-width: 180px; }
.pl-split { display: flex; flex-wrap: wrap; gap: 0 var(--s-3); font-size: var(--t-xl) !important; padding-top: 6px; }
#pl.is-loading .strip dd, #pl.is-loading .pl-chart-wrap, #pl.is-loading .pl-cols { opacity: 0.55; transition: opacity var(--ease); }
.pl-chart-wrap { padding: var(--s-4) var(--s-4) var(--s-3); }
.pl-chart-wrap .chart { height: 240px; }
.chart .cum { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.pl-legend { display: flex; gap: var(--s-4); font-size: var(--t-xs); color: var(--ink-2); font-weight: 600; }
.pl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-p { background: var(--profit); } .sw-l { background: var(--loss); } .sw-c { height: 2px; border-radius: 2px; width: 14px; background: var(--primary); }
.pl-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: var(--s-4); align-items: start; }
.pl-comment { display: block; font-size: var(--t-xs); color: var(--ink-2); max-width: 22ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-none { text-align: center; height: 80px !important; }
.table-scroll { overflow-x: auto; }
.table-scroll .ledger td, .table-scroll .ledger th { white-space: nowrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1439px) {
  .only-stacked { display: inline-flex !important; }
  .side-section { scroll-margin-top: calc(var(--header) + var(--s-4)); }
  .console { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}
@media (max-width: 899px) {
  .pl-cols { grid-template-columns: minmax(0, 1fr); }
  .strip { grid-template-columns: 1fr 1fr; gap: var(--s-3); }
  .strip > div { padding: var(--s-3) var(--s-4); }
  .strip dd { font-size: var(--t-xl); }
  .pl-split { font-size: var(--t-md) !important; }
  .pl-chart-wrap { padding: var(--s-3) var(--s-2); }
  .note-tag { display: none; }
  .note-when, .note-act { width: auto; }
  .ledger td, .ledger th { padding-left: var(--s-4); padding-right: var(--s-4); }
  .col-ver, .col-dir, td.ver-cell, td.dir-cell, .s-desc { display: none; }
  .shelf { gap: var(--s-3); padding: 0 var(--s-4); }
  .console, .page { padding: var(--s-4); }
}
@media (max-width: 599px) {
  .shelf-nav { display: none; }
  .command, .symtabs { padding-left: var(--s-4); padding-right: var(--s-4); }
  .search { max-width: none; min-width: 0; flex-basis: 100%; }
  .frame thead { display: none; }
  .frame tbody tr:not(.section) {
    display: grid; grid-template-columns: 28px repeat(3, minmax(0, 1fr));
    grid-template-areas: "sel name name lever" ". lot tp sl";
    gap: 10px var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line);
  }
  .frame tbody tr:not(.section) td { height: auto; border: 0; padding: 0 !important; }
  .frame td.sel-cell { grid-area: sel; }
  .frame td.name-cell { grid-area: name; } .frame td.lever-cell { grid-area: lever; text-align: right; }
  .frame td.cell-lot { grid-area: lot; } .frame td.tp-cell { grid-area: tp; } .frame td.sl-cell { grid-area: sl; }
  .frame td.cell-lot .input { margin-left: 0; width: 100%; }
  .cell-pip { flex-direction: column; align-items: stretch; gap: 2px; }
  .cell-pip .usd { text-align: left; min-width: 0; }
  .frame td.cell-lot, .frame td.tp-cell, .frame td.sl-cell { display: flex; flex-direction: column; gap: 4px; text-align: left; }
  .frame td.cell-lot::before, .frame td.tp-cell::before, .frame td.sl-cell::before { font-size: var(--t-xs); color: var(--ink-2); font-weight: 600; }
  .frame td.cell-lot::before { content: "Lot"; }
  .frame td.tp-cell::before { content: "Kâr al"; }
  .frame td.sl-cell::before { content: "Zarar durdur"; }
  .cell-pip .input { width: 100%; }
  .frame .section td { display: block; padding: 0 var(--s-4) !important; line-height: 44px; }
  .floatbar { border-radius: var(--r); padding-left: var(--s-4); }
  .popover-body { right: auto; left: 0; width: min(320px, 86vw); }
}

@media (prefers-reduced-motion: reduce) {
  .kule *, .kule *::before, .kule *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
