:root {
  --bg: #0a0c10;
  --bg-elev: #12151c;
  --bg-row: #161a22;
  --border: #1f2530;
  --text: #e8eaed;
  --muted: #5a6472;
  --muted-2: #9aa4b2;
  --accent: #4ade80;
  --strong: #22c55e;
  --buy: #84cc16;
  --watch: #eab308;
  --pass: #6b7280;
  --out: #ef4444;
  --blue: #60a5fa;
  --font-display: 'Archivo', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.accent { color: var(--accent); }

/* Grain overlay */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { color: var(--accent); font-size: 20px; }
.logo.big { font-size: 42px; display: block; margin-bottom: 8px; }
.brand-name { font-weight: 800; letter-spacing: 1px; font-size: 16px; }
.topbar-meta { display: flex; align-items: center; gap: 14px; font-size: 11px; }
.ticker-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.logout { color: var(--muted); text-decoration: none; font-size: 11px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 4px; }
.logout:hover { color: var(--out); border-color: var(--out); }

.container { max-width: 1400px; margin: 0 auto; padding: 28px; position: relative; z-index: 2; }

/* Hero */
.hero { display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 28px; gap: 24px; flex-wrap: wrap; animation: fadeUp 0.5s ease; }
.display { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; }
.metrics { display: flex; gap: 14px; }
.metric { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 20px; display: flex; flex-direction: column; min-width: 90px; }
.metric-val { font-size: 28px; font-weight: 700; }
.metric-lbl { font-size: 10px; color: var(--muted); letter-spacing: 1px; margin-top: 2px; }
.metric.accent-strong { border-color: rgba(34,197,94,0.4); }
.metric.accent-strong .metric-val { color: var(--strong); }
.metric.accent-buy .metric-val { color: var(--buy); }

/* Endeks izleme şeridi */
.ticker { display: flex; gap: 18px; overflow-x: auto; padding: 10px 2px 12px;
  margin-bottom: 18px; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.ticker::-webkit-scrollbar { height: 6px; }
.ticker::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.ticker-group { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.ticker-cat { font-size: 9px; color: var(--muted); letter-spacing: 0.5px; text-transform: uppercase;
  white-space: nowrap; padding-right: 4px; border-right: 1px solid var(--border); }
.ix-chip { display: inline-flex; align-items: baseline; gap: 6px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; cursor: pointer;
  white-space: nowrap; transition: all 0.15s; }
.ix-chip:hover { border-color: var(--muted-2); }
.ix-chip.sel { border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.ix-code { font-size: 11px; font-weight: 700; color: var(--text); }
.ix-val { font-size: 11px; color: var(--muted-2); }
.ix-chg { font-size: 10px; font-weight: 700; }
.ix-chg.up { color: var(--strong); }
.ix-chg.down { color: var(--out); }
.ix-name { font-size: 11px; margin-top: 2px; max-width: 220px; }
.ix-quote { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ix-select { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-mono); font-size: 11px; padding: 7px 10px; border-radius: 6px;
  cursor: pointer; max-width: 280px; }
.ix-select:hover { border-color: var(--muted-2); }
.ix-select:focus { outline: none; border-color: var(--accent); }
.chip { background: transparent; border: 1px solid var(--border); color: var(--muted-2);
  padding: 6px 14px; border-radius: 20px; font-size: 11px; cursor: pointer;
  font-family: var(--font-mono); letter-spacing: 0.5px; transition: all 0.15s; }
.chip:hover { border-color: var(--muted-2); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #0a0c10; font-weight: 700; }
.data-actions { display: flex; align-items: center; gap: 8px; }

/* Buttons */
.btn { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 6px; cursor: pointer; font-family: var(--font-display);
  font-weight: 600; font-size: 13px; transition: all 0.15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #0a0c10; border-color: var(--accent); }
.btn.primary:hover { background: var(--strong); }
.btn.sm { padding: 6px 12px; font-size: 11px; }

/* Layout: table + detail */
.layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
@media (max-width: 1024px) { .layout { grid-template-columns: 1fr; } }

.table-wrap { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  overflow: visible; animation: fadeUp 0.5s ease 0.1s both; }
table.scan thead th:first-child { border-top-left-radius: 10px; }
table.scan thead th:last-child { border-top-right-radius: 10px; }

/* Scan table */
table.scan { width: 100%; border-collapse: collapse; }
table.scan thead th { text-align: left; padding: 12px 14px; font-size: 10px; letter-spacing: 1px;
  color: var(--muted); border-bottom: 1px solid var(--border); font-family: var(--font-mono);
  position: sticky; top: 0; background: var(--bg-elev); }
table.scan th.num, table.scan td.num { text-align: right; }
.row { border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.12s; }
.row:hover { background: var(--bg-row); }
.row.sel { background: var(--bg-row); box-shadow: inset 3px 0 0 var(--accent); }
.row td { padding: 11px 14px; font-size: 13px; }
.sym { font-weight: 700; }
.sector { color: var(--muted-2); font-size: 12px; }
.strong { color: var(--accent); font-weight: 700; }

/* Signal badge */
.badge { font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: 4px; letter-spacing: 0.5px; white-space: nowrap; }
.badge.strong-buy { background: rgba(34,197,94,0.15); color: var(--strong); border: 1px solid rgba(34,197,94,0.3); }
.badge.buy { background: rgba(132,204,22,0.12); color: var(--buy); border: 1px solid rgba(132,204,22,0.25); }
.badge.watch { background: rgba(234,179,8,0.12); color: var(--watch); border: 1px solid rgba(234,179,8,0.25); }
.badge.pass { background: rgba(107,114,128,0.12); color: var(--pass); border: 1px solid rgba(107,114,128,0.2); }
.badge.out { background: rgba(239,68,68,0.1); color: var(--out); border: 1px solid rgba(239,68,68,0.2); }

/* Detail panel */
.detail-panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; position: sticky; top: 90px; animation: fadeUp 0.5s ease 0.2s both; }
.detail-empty { padding: 40px 12px; text-align: center; font-size: 12px; }
.detail-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.detail-head h2 { font-size: 22px; font-weight: 700; }
.detail-price { font-size: 18px; color: var(--accent); }
.chart-box { margin-bottom: 14px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 10px; color: var(--muted-2);
  margin: -6px 0 14px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend .dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chart-legend .dot.up { background: #22c55e; }
.chart-legend .dot.down { background: #ef4444; }
.chart-legend .dot.ema-s { background: #4ade80; }
.chart-legend .dot.ema-l { background: #f59e0b; }

/* Bilgi ikonu + hover tooltip */
.info { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px;
  border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); font-size: 9px;
  font-family: var(--font-mono); font-style: normal; font-weight: 700; line-height: 1;
  cursor: help; margin-left: 5px; position: relative; vertical-align: middle; }
.info:hover { border-color: var(--accent); color: var(--accent); }
.info::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 9px); left: 50%;
  transform: translateX(-50%); width: 240px; max-width: 240px; padding: 9px 11px; border-radius: 6px;
  background: #0a0c10; border: 1px solid var(--border); color: var(--text); font-family: var(--font-display);
  font-weight: 400; font-style: normal; font-size: 11px; line-height: 1.45; letter-spacing: 0;
  text-align: left; white-space: normal; box-shadow: 0 10px 28px rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 60; }
.info::before { content: ''; position: absolute; bottom: calc(100% + 4px); left: 50%;
  transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--border);
  opacity: 0; transition: opacity 0.15s; z-index: 60; }
.info:hover::after, .info:hover::before { opacity: 1; }
/* Tablo başlıkları için: tooltip aşağıda ve sağa hizalı (kenardan taşmasın) */
.info.below::after { bottom: auto; top: calc(100% + 9px); }
.info.below::before { bottom: auto; top: calc(100% + 4px); border-top-color: transparent; border-bottom-color: var(--border); }
.info.r::after { left: auto; right: -2px; transform: none; }
.info.r::before { left: auto; right: 4px; transform: none; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: 6px; margin-bottom: 16px; }
.stat { background: var(--bg-elev); padding: 9px 12px; display: flex; justify-content: space-between; }
.stat:first-child { border-top-left-radius: 6px; }
.stat:nth-child(2) { border-top-right-radius: 6px; }
.stat:nth-last-child(2) { border-bottom-left-radius: 6px; }
.stat:last-child { border-bottom-right-radius: 6px; }
.stat .k { display: inline-flex; align-items: center; }
.stat .k { color: var(--muted); font-size: 11px; }
.stat .v { font-weight: 600; font-size: 12px; }

.hist-block h3 { font-size: 10px; letter-spacing: 1px; margin-bottom: 8px; }
table.mini { width: 100%; border-collapse: collapse; }
table.mini th { text-align: left; font-size: 10px; color: var(--muted); padding: 5px 8px;
  font-family: var(--font-mono); border-bottom: 1px solid var(--border); }
table.mini th.num, table.mini td.num { text-align: right; }
table.mini td { padding: 5px 8px; font-size: 11px; border-bottom: 1px solid var(--border); }

/* Empty / login states */
.empty-state { text-align: center; padding: 80px 20px; animation: fadeUp 0.5s ease; }
.empty-state .actions { display: flex; gap: 12px; justify-content: center; margin: 24px 0 8px; }
.spin-line { text-align: center; font-size: 11px; }
.hint { font-size: 11px; margin-top: 16px; }
.empty-row { padding: 30px; text-align: center; font-size: 12px; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.login-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px;
  padding: 48px; text-align: center; max-width: 360px; width: 100%; }
.login-card .display { font-size: 26px; margin-bottom: 6px; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.input { background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 12px 14px; border-radius: 6px; font-size: 14px; }
.input:focus { outline: none; border-color: var(--accent); }
.err { color: var(--out); font-size: 12px; margin-top: 12px; }

/* Toast */
.toast { padding: 10px 16px; border-radius: 6px; font-size: 12px; margin: 12px 0;
  animation: fadeUp 0.3s ease; }
.toast.ok { background: rgba(34,197,94,0.12); color: var(--strong); border: 1px solid rgba(34,197,94,0.3); }
.toast.warn { background: rgba(234,179,8,0.12); color: var(--watch); border: 1px solid rgba(234,179,8,0.3); }

.htmx-indicator { opacity: 0; color: var(--accent); font-size: 10px; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-indicator.htmx-request { opacity: 1; }

.footer { text-align: center; padding: 24px; color: var(--muted); font-size: 10px;
  border-top: 1px solid var(--border); margin-top: 40px; letter-spacing: 0.5px; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
