:root {
    --bg: #f7f7f5;
    --surface: #ffffff;
    --text: #1d1d1b;
    --muted: #6b6b66;
    --border: #e2e2dc;
    --accent: #2459a8;
    --up: #1f7a3f;
    --down: #b3261e;
    --error: #b3261e;
    --ind-short: #c77700;
    --ind-long: #7a3fb5;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161615;
        --surface: #1f1f1d;
        --text: #ecece8;
        --muted: #9a9a93;
        --border: #34342f;
        --accent: #7aa7ec;
        --up: #5cc283;
        --down: #f0857c;
        --error: #f0857c;
        --ind-short: #f0a640;
        --ind-long: #b98ae6;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h1:focus { outline: none; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
code { font-size: .9em; }

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1.5rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 1rem; }
.topbar nav a { text-decoration: none; color: var(--muted); }
.topbar nav a.active { color: var(--text); font-weight: 600; }
.search { display: flex; gap: .4rem; margin-left: auto; }

input, button {
    font: inherit;
    padding: .35rem .7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}
input { width: 11rem; }
button { cursor: pointer; background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .6; cursor: progress; }
button.secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }

.logout { display: flex; align-items: center; gap: .5rem; }
.logout .user { color: var(--muted); font-size: .9rem; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.inline-form { display: flex; gap: .4rem; margin-bottom: 1rem; }

.backtest-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .75rem 1rem; align-items: end; margin: 1rem 0; }
.backtest-form label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
.backtest-form label.wide { grid-column: 1 / -1; }
.backtest-form input, .backtest-form select { width: 100%; }
.backtest-form .actions { display: flex; flex-wrap: wrap; gap: .5rem; grid-column: span 2; }
.table-wrap.sweep { margin-bottom: 1rem; }
.sweep th.group { text-align: center; border-left: 1px solid var(--border); }
.sweep tbody td:nth-child(2), .sweep thead tr:nth-child(2) th:nth-child(1),
.sweep tbody td:nth-child(6), .sweep thead tr:nth-child(2) th:nth-child(5) { border-left: 1px solid var(--border); }
.sweep tr.current td { font-weight: 600; }
select { font: inherit; padding: .35rem .7rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; }

.account-form { display: grid; gap: .5rem; max-width: 22rem; margin-bottom: 1rem; }
.account-form label { display: grid; gap: .25rem; }
.account-form label.check { display: flex; align-items: center; gap: .4rem; }
.account-form input:not([type=checkbox]) { width: 100%; }
.account-form input[type=checkbox] { width: auto; }
.account-form button { justify-self: start; }
.account-form .validation-message { font-size: .9rem; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }
.note { max-width: 1100px; margin: 0 auto; padding: 0 1rem 2rem; color: var(--muted); font-size: .85rem; }

.muted { color: var(--muted); font-size: .9rem; }
.error { color: var(--error); }
.up { color: var(--up); }
.down { color: var(--down); }

/* position: relative — içerideki .visually-hidden (absolute) kaydırma kutusundan taşıp sayfayı yatay kaydırmasın. */
.table-wrap { position: relative; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child > * { border-bottom: 0; }
thead th { font-size: .8rem; font-weight: 600; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.kv { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.kv th { font-weight: 500; color: var(--muted); }
/* Gün içi kurgu paneli: aşamaya göre sol kenar rengi. */
.setup-status { padding: .6rem .8rem; border: 1px solid var(--border); border-left-width: 4px; border-radius: 6px; background: var(--surface); }
.setup-status.phase-confirmed { border-left-color: var(--up, #1a7f37); }
.setup-status.phase-awaitingpullback, .setup-status.phase-awaitingconfirmation { border-left-color: #d29922; }
.setup-status.phase-levellost, .setup-status.phase-expired { border-left-color: var(--down, #cf222e); }

/* Açıklaması olan gösterge adları: üzerine gelince title metni görünür. */
.kv th[title] { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }

.price { font-variant-numeric: tabular-nums; margin-left: .5rem; }
.change { font-size: 1rem; margin-left: .5rem; }

.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 1.5rem; }
.columns.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 760px) { .columns, .columns.even { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .75rem 1rem; margin: 0 0 .75rem; }
.stats > div { min-width: 0; }
.stats dt { color: var(--muted); font-size: .8rem; }
.stats dd { margin: .1rem 0 0; font-size: 1.05rem; font-weight: 600; }
.stats dd.num { text-align: left; }
.range-bar { position: relative; height: 6px; border-radius: 3px; margin: .9rem 0 .4rem; background: linear-gradient(90deg, var(--down), var(--muted), var(--up)); }
.range-bar .marker { position: absolute; top: -7px; width: 0; height: 0; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--text); }
.month-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; list-style: none; margin: 0 0 .5rem; padding: 0; }
.month-strip li { height: 1.6rem; border-radius: 3px; background: var(--border); }
.month-strip li.up { background: var(--up); }
.month-strip li.down { background: var(--down); }
.month-strip li.flat { background: var(--muted); }

.chart { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .75rem; }
.chart .plot { display: grid; grid-template-columns: minmax(0, 1fr) 4.2rem; grid-template-rows: 240px 1.5rem; }
.chart svg { display: block; width: 100%; height: 240px; grid-column: 1; grid-row: 1; }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .grid.vertical { stroke-dasharray: 2 4; }
.chart .y-axis, .chart .x-axis { position: relative; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.chart .y-axis { grid-column: 2; grid-row: 1; }
.chart .x-axis { grid-column: 1; grid-row: 2; }
.chart .y-axis span { position: absolute; left: .4rem; transform: translateY(-50%); white-space: nowrap; }
.chart .x-axis span { position: absolute; top: .3rem; transform: translateX(-50%); white-space: nowrap; }
.chart figcaption { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; color: var(--muted); font-size: .85rem; margin-top: .4rem; }
.chart svg { touch-action: pan-y; cursor: crosshair; }
.chart .crosshair { grid-column: 1; grid-row: 1; position: relative; pointer-events: none; visibility: hidden; }
.chart .crosshair.visible { visibility: visible; }
.chart .ch-line { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--muted); }
.chart .ch-dot { display: none; position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.chart .crosshair.line-mode .ch-dot { display: block; }
.chart .ch-box {
    position: absolute;
    top: 6px;
    display: grid;
    grid-template-columns: auto auto;
    gap: .1rem .75rem;
    padding: .45rem .6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgb(0 0 0 / .12);
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.chart .ch-box strong { grid-column: 1 / -1; margin-bottom: .15rem; }
.chart .ch-box .k { color: var(--muted); }
.chart .ch-box .v { text-align: right; }
.chart .ch-box .up { color: var(--up); }
.chart .ch-box .down { color: var(--down); }
.chart .candle .wick { stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .candle .body { stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .candle.up .wick, .chart .candle.up .body { stroke: var(--up); fill: var(--up); }
.chart .candle.down .wick, .chart .candle.down .body { stroke: var(--down); fill: var(--down); }
.chart-loading { opacity: .5; transition: opacity .15s; }
.chart .overlay { fill: none; stroke-width: 1.5; stroke-linejoin: round; }
.chart .sma-short { stroke: var(--ind-short); }
.chart .sma-long { stroke: var(--ind-long); }
.chart .rsi, .chart .macd { stroke: var(--accent); }
.chart .macd-signal { stroke: var(--ind-long); }
.chart .grid.level { stroke-dasharray: 4 3; }
.chart .hist { stroke: none; opacity: .55; }
.chart .hist.up { fill: var(--up); }
.chart .hist.down { fill: var(--down); }
.chart .plot.sub { grid-template-rows: 80px; position: relative; margin-top: .35rem; border-top: 1px solid var(--border); }
.chart .plot.sub svg { height: 80px; }
.chart .sub-title { grid-column: 1; grid-row: 1; align-self: start; justify-self: start; position: relative; z-index: 1; padding: .1rem .3rem; color: var(--muted); font-size: .72rem; pointer-events: none; background: var(--surface); border-radius: 0 0 4px 0; }
.chart-legend, .chart .sub-title { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center; }
.chart-legend { color: var(--muted); font-size: .78rem; margin-bottom: .3rem; }
.chart .key::before { content: ""; display: inline-block; width: .9rem; height: 0; margin-right: .3rem; vertical-align: middle; border-top: 2px solid currentColor; }
.chart .key.sma-short::before { border-color: var(--ind-short); }
.chart .key.sma-long::before, .chart .key.macd-signal::before { border-color: var(--ind-long); }
.chart .key.macd::before { border-color: var(--accent); }

.chart-controls { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: .6rem; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segmented button {
    background: var(--surface);
    color: var(--text);
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    padding: .3rem .6rem;
    font-size: .85rem;
}
.segmented button:last-child { border-right: 0; }
.segmented button.selected { background: var(--accent); color: #fff; }
.segmented button:disabled { color: var(--muted); opacity: .45; cursor: not-allowed; }

.analysis-text {
    white-space: pre-wrap;
    margin-top: .75rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.alert { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin-bottom: .75rem; }
.alert header { display: flex; justify-content: space-between; gap: 1rem; font-weight: 600; }
.alert time { color: var(--muted); font-weight: 400; font-size: .9rem; }
.alert ul { margin: .5rem 0; padding-left: 1.2rem; }
.alert summary { cursor: pointer; color: var(--accent); }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Bir hata oluştu."; }

/* Tarama adayları: gerekçe listesi tablo hücresinde sıkı dursun. */
td.reasons-cell { white-space: normal; min-width: 18rem; }
.reasons { margin: 0; padding-left: 1.1rem; font-size: .9rem; }
.reasons li + li { margin-top: .15rem; }

/* Veri kaynağı sayfası: başlık + düğme satırı ve günlük kota çubuğu. */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.section-head h2 { margin-bottom: .5rem; }
.quota p { margin: .4rem 0; }
.meter { height: .6rem; background: var(--border); border-radius: 999px; overflow: hidden; max-width: 32rem; }
.meter span { display: block; height: 100%; background: var(--accent); }
.meter.high span { background: var(--down); }
/* Bu sayfadaki tablolar kısa: metin satır kaydırsın, çerçeve iki kez çizilmesin. */
.data-source td { white-space: normal; }
.data-source .table-wrap > table.kv { border: 0; border-radius: 0; }
.data-source .columns { margin-bottom: 1rem; }

/* Teknik görünüm */
.outlook { font-weight: 600; white-space: nowrap; }
.outlook.strong { padding: .05rem .4rem; border-radius: 4px; border: 1px solid currentColor; }
.outlook-summary { font-size: 1.05rem; margin: .25rem 0 .75rem; }
td.wrap { white-space: normal; }
.outlook-backtest th.group { text-align: center; border-left: 1px solid var(--border); }
.outlook-backtest tr.total td { font-weight: 600; border-top: 2px solid var(--border); }
.low-sample { color: var(--muted); }
.sort-links { display: flex; gap: .75rem; align-items: baseline; margin: .5rem 0; font-size: .9rem; }
.sort-links .current { font-weight: 600; }
/* Tarama adayları: sıralanabilir sütun başlıkları ve sayfa bağlantıları. */
th a.sort { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort:hover, th a.sort:focus-visible { text-decoration: underline; }
th[aria-sort="ascending"] a.sort, th[aria-sort="descending"] a.sort { color: var(--accent); }
.pager { display: flex; flex-wrap: wrap; gap: .6rem; align-items: baseline; margin: .75rem 0; font-size: .9rem; }
.pager .muted { margin-right: auto; }
.pager .current { font-weight: 600; }

/* Simülatör */
.sim-notice { border-left: 3px solid var(--ind-short); background: var(--surface); padding: .5rem .75rem; margin: 0 0 1rem; color: var(--muted); font-size: .9rem; }
.actions-cell { display: flex; gap: .75rem; }
.sim-edit td { background: var(--surface); white-space: normal; }
.sim-edit .inline-form { align-items: end; flex-wrap: wrap; margin-bottom: .5rem; }
.sim-edit label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
.nowrap { white-space: nowrap; }
.sparkline { display: block; width: 100%; height: 80px; margin: .25rem 0 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.sparkline polyline { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.sparkline polyline.up { stroke: var(--up); }
.sparkline polyline.down { stroke: var(--down); }
.sparkline .baseline { stroke: var(--border); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.sim-mode { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; border: 1px solid var(--border); border-radius: 6px; padding: .5rem .75rem; margin: 0 0 1rem; background: var(--surface); }
.sim-mode legend { color: var(--muted); font-size: .9rem; padding: 0 .25rem; }
.sim-mode label { display: flex; align-items: center; gap: .4rem; }
.sim-order-status { white-space: normal; max-width: 28rem; }
