/* DS-scope exclusion (design-system debt, registered in docs/ui-audit.md §1.2c, added 2026-09-13):
   Rules carrying `:where(:not(.tm-ds *))` stand down inside pages that opted into the
   design system (<main class="tm-ds">); `:where()` keeps their specificity unchanged, so
   every other page resolves exactly as before. Counted in the DS metrics table
   (scripts/ui_audit_metrics.py). Removed for good in Faz 5 with this file's overlay role. */
/* =============================================================
   Trendmetrik · Grafik Paneli Sistemi
   KPI kartlarıyla aynı dil — donut, alan-çizgi, çubuk, canlı, gauge
   ============================================================= */

:root {
  --ch-line: var(--tm-border, #e4e4e7);
  --ch-line-2: var(--tm-border, #e4e4e7);
  --ch-ink: var(--tm-text-primary, #18181b);
  --ch-ink-2: var(--tm-text-secondary, #52525b);
  --ch-mute: var(--tm-text-muted, #71717a);
  --ch-faint: var(--tm-ink-300, #d4d4d8);
  --ch-c1: var(--tm-brand-500, #0175e4);
  --ch-c2: var(--tm-orange-500, #fd751f);
  --ch-c3: var(--tm-ok, #16a34a);
  --ch-c4: var(--tm-brand-300, #73b7fe);
  --ch-c5: #8b5cf6;
  --ch-c6: var(--tm-warn, #d97706);
  --ch-c7: var(--tm-bad, #dc2626);
}

/* ===== Stage / shell (shared with KPI page) ===== */
.ch-stage {
  min-height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #f4f6fa 240px), #f4f6fa;
  background-attachment: fixed;
}
.ch-shell { max-width: 1320px; margin: 0 auto; padding: 30px 28px 64px; }

.ch-topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.ch-brand { display: flex; align-items: center; gap: 11px; }
.ch-brand img { width: 30px; height: 30px; }
.ch-brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; color: var(--ch-ink); }
.ch-kicker { font-family: "Instrument Serif", Georgia, serif; font-style: italic; font-size: 15px; color: var(--ch-ink-2); margin-bottom: 1px; }
.ch-title { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; color: var(--ch-ink); line-height: 1.1; }

.ch-tabs { display: inline-flex; padding: 3px; gap: 2px; background: #eef1f6; border: 1px solid var(--ch-line); border-radius: 12px; }
.ch-tab { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border: 0; background: transparent; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--ch-ink-2); letter-spacing: -0.01em; transition: color 150ms ease; }
.ch-tab i { width: 15px; height: 15px; }
.ch-tab:hover { color: var(--ch-ink); }
.ch-tab.active { background: #fff; color: var(--ch-ink); box-shadow: 0 1px 2px rgba(15,23,42,0.06); }
.ch-tab.active.live { color: var(--color-primary-hover); }
.ch-tab .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ch-c7); }
.ch-tab.active.live .live-dot { animation: chPulse 1.4s ease-in-out infinite; }

/* ===== Grid ===== */
.ch-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--tm-dashboard-card-gap, var(--tm-card-gap, 12px)); align-items: start; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
.span-2 { grid-column: span 2; }

/* ===== Panel chassis ===== */
.ch-panel {
  background: #fff;
  border: 1px solid var(--ch-line);
  border-radius: var(--tm-radius-card, 12px);
  padding: 16px 18px 18px;
  box-shadow: var(--tm-card-shadow, 0 1px 2px rgba(15,23,42,0.04));
  display: flex; flex-direction: column;
  min-width: 0;
  transition: box-shadow 160ms ease, border-color 160ms ease;
}
.ch-panel:hover { box-shadow: var(--tm-card-shadow-hover, var(--tm-card-shadow)); }
.ch-panel.enter { opacity: 1; }

.ch-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ch-head-l { min-width: 0; }
.ch-h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--ch-ink); display: flex; align-items: center; gap: 8px; }
.ch-h3 .live-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 7px;
  border-radius: 999px; background: #fee2e2; color: #b91c1c;
  font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
}
.ch-h3 .live-badge .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ch-c7); animation: chPulse 1.4s ease-in-out infinite; }
.ch-sub { font-size: 12px; color: var(--ch-mute); margin-top: 3px; }
.ch-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ch-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 5px 9px; font-size: 12px; font-weight: 500; color: var(--ch-ink-2);
  transition: all 150ms ease;
}
.ch-chip:hover { background: #f8fafc; border-color: #cbd5e1; color: var(--ch-ink); }
.ch-chip.active { background: var(--color-primary-soft); border-color: #bfdcff; color: var(--color-primary-hover); }
.ch-chip i { width: 12px; height: 12px; }
.ch-seg { display: inline-flex; background: #f1f5f9; border-radius: 6px; padding: 2px; gap: 2px; }
.ch-seg button { border: 0; background: transparent; padding: 4px 9px; border-radius: 4px; font-size: 11px; font-weight: 600; color: var(--ch-ink-2); transition: all 130ms ease; }
.ch-seg button.on { background: #fff; color: var(--ch-ink); box-shadow: 0 1px 2px rgba(15,23,42,0.08); }

.numeric { font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.ch-live-end-pulse {
  transform-box: fill-box;
  transform-origin: center;
  animation: chLiveEndPulse 1.6s ease-in-out infinite;
}
@keyframes chLiveEndPulse {
  0%, 100% { opacity: 0.16; transform: scale(0.85); }
  50% { opacity: 0.38; transform: scale(1.35); }
}
@media (prefers-reduced-motion: reduce) {
  .ch-live-end-pulse { animation: none; opacity: 0.22; transform: none; }
}

/* ===== Chart body shared ===== */
.ch-body { position: relative; }
.ch-svg { display: block; width: 100%; overflow: visible; }
.ch-grid-line { stroke: var(--ch-line); stroke-width: 1; }
.ch-grid-line.zero { stroke: #dbe5ef; }
/* Eksen yazıları sayfa fontunu MİRAS alır (2026-09-24): açık "Inter"/mono adı, o font
   kullanıcı makinesinde yüklüyse gövdeden farklı bir yazı tipiyle çiziyordu (X ekseni saatleri
   "mono gibi" görünüyordu); gövde -apple-system/Segoe UI ise eksen de o. Rakamlar tabular. */
.ch-axis-x text, .ch-axis-y text { font-family: inherit; font-size: 11px; fill: var(--ch-mute); font-variant-numeric: tabular-nums; }

/* tooltip — fareyi gecikmeli takip (is-on ile fade+scale) */
.ch-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 12px)) scale(0.96);
  background: #0f172a; color: #fff; padding: 8px 10px; border-radius: 8px;
  pointer-events: none; z-index: 8; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(15,23,42,0.22);
  opacity: 0;
  transition: opacity 180ms ease, transform 240ms cubic-bezier(.22,.7,.28,1);
}
.ch-tip.is-on { opacity: 1; transform: translate(-50%, calc(-100% - 14px)) scale(1); }
.ch-tip.is-below { transform: translate(-50%, 14px) scale(0.96); }
.ch-tip.is-on.is-below { transform: translate(-50%, 16px) scale(1); }
.ch-tip::after { content: ''; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #0f172a; border-bottom: 0; }
.ch-tip.is-below::after { bottom: auto; top: -5px; border-top-color: transparent; border-bottom-color: #0f172a; }
.ch-tip-t { font-size: 10px; color: rgba(255,255,255,0.6); font-weight: 500; margin-bottom: 3px; letter-spacing: 0.02em; }
.ch-tip-rows { display: flex; flex-direction: column; gap: 3px; }
.ch-tip-row { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.ch-tip-row .dot { width: 8px; height: 8px; border-radius: 4px; flex-shrink: 0; }
.ch-tip-row .k { color: rgba(255,255,255,0.78); }
.ch-tip-row .v { font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-weight: 600; margin-left: auto; padding-left: 12px; }
.ch-cross { stroke: var(--ch-faint); stroke-width: 1; stroke-dasharray: 3 3; }
.ch-cross-dot { stroke: #fff; stroke-width: 2; }

/* ===== Legend ===== */
.ch-legend { list-style: none; display: flex; flex-direction: column; gap: 9px; margin: 0; padding: 0; }
.ch-legend.row { flex-direction: row; flex-wrap: wrap; gap: 10px 18px; }
.ch-legend li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; cursor: default; transition: opacity 130ms ease; min-width: 0; }
.ch-legend.row li { display: inline-flex; gap: 7px; }
.ch-legend li.dim { opacity: 0.35; }
.ch-legend .dot { width: 9px; height: 9px; border-radius: 4px; flex-shrink: 0; }
.ch-legend .nm { font-size: 13px; color: #1e293b; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-legend .vl { font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; color: var(--ch-ink); }
.ch-legend .sh { font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ch-mute); width: 52px; text-align: right; }

/* ===== Donut ===== */
.ch-donut-wrap { display: flex; align-items: center; gap: 22px; min-width: 0; }
.ch-donut-wrap .ch-legend { min-width: 0; }
.ch-donut { flex-shrink: 0; }
.ch-donut-seg { transition: opacity 130ms ease, stroke-width 130ms ease; cursor: pointer; }
.ch-donut-seg.dim { opacity: 0.25; }
.ch-donut-center-v { font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-weight: 600; fill: var(--ch-ink); }
.ch-donut-center-l { font-family: "Inter", sans-serif; font-weight: 500; fill: var(--ch-mute); }

/* ===== Bars ===== */
.ch-bar { transition: opacity 130ms ease; cursor: pointer; }
.ch-bar-col:hover .ch-bar { opacity: 0.85; }
.ch-bar-val { font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-size: 11px; fill: var(--ch-ink-2); font-weight: 600; }
.ch-bar-xlabel { font-family: inherit; font-size: 11px; fill: var(--ch-mute); font-variant-numeric: tabular-nums; }
.ch-axis-ylabel { font-family: inherit; font-variant-numeric: tabular-nums; }

/* ===== Ranking (horizontal) ===== */
.ch-rank { display: flex; flex-direction: column; gap: 13px; }
.ch-rank-row { display: grid; grid-template-columns: 20px 1fr; gap: 11px; align-items: center; }
.ch-rank-row--product { grid-template-columns: 20px 40px 1fr; }
.ch-rank-no { font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; color: var(--ch-mute); text-align: right; }
.ch-rank-media { width: 40px; height: 40px; flex-shrink: 0; }
.ch-rank-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; background: #f1f5f9; display: block; }
.ch-rank-thumb--ph { display: flex; align-items: center; justify-content: center; background: #eef2f7; }
.ch-rank-thumb--ph::after { content: ""; width: 16px; height: 16px; border-radius: 4px; background: #cbd5e1; }
.ch-rank-main { min-width: 0; }
.ch-rank-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.ch-rank-nm { font-size: 13px; font-weight: 500; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-rank-vl { font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; color: var(--ch-ink); flex-shrink: 0; }
.ch-rank-meta { font-size: 11px; color: var(--ch-mute); margin: -2px 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-rank-track { height: 8px; border-radius: 999px; background: #f1f5f9; overflow: hidden; }
.ch-rank-fill { height: 100%; border-radius: 999px; transition: width 900ms cubic-bezier(.22,1,.36,1); }

/* ===== Gauge ===== */
.ch-gauge-wrap { display: flex; flex-direction: column; align-items: center; }
.ch-gauge-v { font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-weight: 600; fill: var(--ch-ink); }
.ch-gauge-l { font-family: "Inter", sans-serif; font-weight: 500; fill: var(--ch-mute); }

/* ===== Live stream extras ===== */
.ch-live-dot-end { filter: drop-shadow(0 0 0 rgba(1,117,228,0.4)); }
.ch-stat-row { display: flex; gap: 22px; margin-top: 4px; }
.ch-stat { display: flex; flex-direction: column; gap: 2px; }
.ch-stat .l { font-size: 11px; color: var(--ch-mute); font-weight: 500; }
.ch-stat .v { font-family: var(--tm-font-sans, "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif); font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600; color: var(--ch-ink); }
.ch-stat .v.up { color: var(--ch-c3); }
.ch-stat .v.down { color: var(--ch-c7); }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .ch-grid { grid-template-columns: repeat(2, 1fr); }
  .span-6, .span-4, .span-3, .span-2 { grid-column: span 2; }
}
@media (max-width: 640px) {
  .ch-shell { padding: 22px 16px 48px; }
  .ch-grid { grid-template-columns: 1fr; }
  .span-6, .span-4, .span-3, .span-2 { grid-column: span 1; }
}

/* =============================================================
   Dark mode — chart panelleri okunur (KPI dark-mode diliyle uyumlu)
   ============================================================= */
html.dark-mode {
  --ch-line: var(--tm-border, #27272a);
  --ch-line-2: color-mix(in srgb, var(--tm-border, #27272a) 70%, transparent);
  --ch-ink: var(--tm-text-primary, #f4f4f5);
  --ch-ink-2: var(--tm-text-secondary, #cbd5e1);
  --ch-mute: var(--tm-text-muted, #94a3b8);
  --ch-faint: color-mix(in srgb, var(--tm-text-muted, #94a3b8) 55%, transparent);
}

/* Stage / panel yüzeyleri */
html.dark-mode .ch-stage {
  background: var(--tm-surface, #0f1419);
}
html.dark-mode .ch-panel:where(:not(.tm-ds *)) {
  background: var(--tm-surface-raised, #161c23);
  border-color: var(--tm-border, #27272a);
  box-shadow: var(--tm-card-shadow);
}
html.dark-mode .ch-panel:hover {
  box-shadow: var(--tm-card-shadow-hover);
}

/* Tabs / chips / segment kontrolleri */
html.dark-mode .ch-tabs {
  background: color-mix(in srgb, var(--tm-surface, #0f1419) 60%, transparent);
  border-color: var(--tm-border, #27272a);
}
html.dark-mode .ch-tab.active {
  background: var(--tm-surface-raised, #161c23);
  color: var(--tm-text-primary, #f4f4f5);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
html.dark-mode .ch-chip {
  background: color-mix(in srgb, var(--tm-surface, #0f1419) 50%, transparent);
  border-color: var(--tm-border, #27272a);
  color: var(--ch-ink-2);
}
html.dark-mode .ch-chip:hover {
  background: color-mix(in srgb, var(--tm-brand-500, #0175e4) 12%, transparent);
  border-color: color-mix(in srgb, var(--tm-brand-500, #0175e4) 40%, transparent);
  color: var(--tm-text-primary, #f4f4f5);
}
html.dark-mode .ch-chip.active {
  background: color-mix(in srgb, var(--tm-brand-500, #0175e4) 18%, transparent);
  border-color: color-mix(in srgb, var(--tm-brand-500, #0175e4) 45%, transparent);
  color: var(--tm-brand-100, #d1e9ff);
}
html.dark-mode .ch-seg {
  background: color-mix(in srgb, var(--tm-surface, #0f1419) 55%, transparent);
}
html.dark-mode .ch-seg button.on {
  background: var(--tm-surface-raised, #161c23);
  color: var(--tm-text-primary, #f4f4f5);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Eksen / grid çizgileri */
html.dark-mode .ch-grid-line { stroke: var(--ch-line); }
html.dark-mode .ch-grid-line.zero {
  stroke: color-mix(in srgb, var(--tm-text-muted, #94a3b8) 60%, transparent);
}
html.dark-mode .ch-axis-x text,
html.dark-mode .ch-axis-y text { fill: var(--ch-mute); }

/* Legend / ranking metinleri */
html.dark-mode .ch-legend .nm,
html.dark-mode .ch-rank-nm { color: var(--tm-text-secondary, #cbd5e1); }
html.dark-mode .ch-rank-track {
  background: color-mix(in srgb, var(--tm-surface, #0f1419) 60%, transparent);
}

/* Donut / gauge merkez etiketleri (fill token'ları takip eder) */
html.dark-mode .ch-donut-center-v,
html.dark-mode .ch-gauge-v { fill: var(--ch-ink); }
html.dark-mode .ch-donut-center-l,
html.dark-mode .ch-gauge-l { fill: var(--ch-mute); }
html.dark-mode .ch-cross-dot { stroke: var(--tm-surface-raised, #161c23); }

@media (prefers-reduced-motion: reduce) {
  .ch-tip { transition: none; }
}

/* WCAG AA (2026-08-19, agent-ölçümlü): grafik alt-başlık kontrastı 2.56 FAIL → 4.76 PASS */
.tmv2-overview-tab-inner .ch-sub, .tm-dashboard-ch-grid--overview .ch-sub { color: #64748b; }
