:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --border: #e4e7ee;
  --text: #151922;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --good: #12805c;
  --good-soft: #e6f5ee;
  --bad: #c4302b;
  --bad-soft: #fdecea;
  --warn: #b25e09;
  --warn-soft: #fff4e5;
  --info: #2563eb;
  --info-soft: #eaf1ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f14;
    --surface: #161921;
    --surface-2: #1e222c;
    --border: #282d39;
    --text: #e8eaf0;
    --muted: #9aa3b2;
    --accent: #8b85ff;
    --accent-2: #b28cff;
    --accent-soft: #24233d;
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .45);
    --good: #3ccf91;
    --good-soft: #15291f;
    --bad: #ff6b63;
    --bad-soft: #321a19;
    --warn: #f5a524;
    --warn-soft: #30240f;
    --info: #6ea8ff;
    --info-soft: #16233a;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  background: var(--bg); color: var(--text); display: flex; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
h3 { margin: 0; font-size: 15px; font-weight: 600; }
h4 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }

/* Sidebar */
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px 16px; }
.brand b { font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.logo {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); flex: none;
}
nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; }
nav a { color: var(--muted); padding: 8px 10px; border-radius: 9px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
nav a span:first-of-type { flex: 1; }
nav a svg, .logout svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge { background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.logout { padding: 8px 10px 14px; }
.logout .btn { display: flex; align-items: center; gap: 8px; justify-content: center; color: var(--muted); }
.sidebar-foot div { display: flex; justify-content: space-between; gap: 6px; padding: 2px 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

main { flex: 1; min-width: 0; padding: 0 24px 40px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 0 6px; position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px);
}
.filters, .top-actions, .row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.range-note { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
select, input {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px;
}
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font: inherit; font-size: 13px; display: flex; align-items: center;
}
.chip.off { opacity: .45; }
.btn {
  font: inherit; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px 14px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.block { width: 100%; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .6; cursor: wait; }
.tag { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.tag.live { background: var(--good-soft); color: var(--good); }
.tag.demo { background: var(--warn-soft); color: var(--warn); }
.banner { background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }

.tab { display: none; }
.tab.active { display: block; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 16px; }
.span-2 { grid-column: span 2; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 22px; font-weight: 650; margin: 4px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpis.primary { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.kpis.primary .value { white-space: nowrap; }
.kpis.primary .kpi { padding: 16px 18px 0; display: flex; flex-direction: column; overflow: hidden; }
.kpis.primary .value { font-size: 28px; margin: 6px 0 2px; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.spark { display: block; width: calc(100% + 36px); height: 38px; margin: 10px -18px 0; }
.gauge { height: 5px; background: var(--surface-2); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.gauge span { display: block; height: 100%; border-radius: 3px; }
.gauge.good span { background: var(--good); }
.gauge.warn span { background: var(--warn); }
.gauge.bad span { background: var(--bad); }
.kpis.secondary { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.kpi.sm { padding: 10px 14px; box-shadow: none; background: transparent; border-style: dashed; }
.kpi.sm .value { font-size: 17px; margin: 2px 0 0; }

/* Özet */
.hero {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: 18px 22px; margin-bottom: 16px;
  background: linear-gradient(120deg, var(--accent-soft), var(--surface) 70%); border: 1px solid var(--border);
}
.hero p { margin: 8px 0 0; font-size: 15px; line-height: 1.6; max-width: 980px; }
.hero-status { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; padding: 4px 12px 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.hero-status .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 0 currentColor; animation: pulse 2s infinite; }
.hero-status.good { color: var(--good); } .hero-status.good .pulse { background: var(--good); }
.hero-status.warn { color: var(--warn); } .hero-status.warn .pulse { background: var(--warn); }
.hero-status.bad { color: var(--bad); } .hero-status.bad .pulse { background: var(--bad); }
.hero-status.idle { color: var(--muted); } .hero-status.idle .pulse { animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .hero-status .pulse { animation: none; } }

/* Genel bakış ızgarası */
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-main > .card { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack > .card { margin-bottom: 0; flex: 1; }
.muted.sm { font-size: 12px; }
label.check.sm { font-size: 12px !important; color: var(--muted) !important; gap: 6px; }

.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.mini-pace .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.mini-pace .big { font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mini-pace .muted { font-size: 12px; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.f-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.f-head b { font-variant-numeric: tabular-nums; }
.f-bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.f-bar span { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.f-rate { font-size: 11px; color: var(--muted); margin-top: 3px; }
.f-foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; }

.camp-list { display: flex; flex-direction: column; }
.camp-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 8px; margin: 0 -8px; width: calc(100% + 16px);
  border: 0; border-bottom: 1px solid var(--border); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 8px;
}
.camp-item:last-child { border-bottom: 0; }
.camp-item:hover { background: var(--surface-2); }
.camp-item .dot { margin-right: 0; flex: none; }
.ci-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ci-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ci-name small, .ci-val span { color: var(--muted); font-size: 11.5px; }
.ci-val { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Giriş */
body.login-page { align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 32px 28px 24px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 6px 0 0; font-size: 20px; letter-spacing: -.02em; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.login-card input { padding: 10px 12px; font-size: 15px; }
.login-card .btn { padding: 10px 14px; margin-top: 4px; }
.logo.lg { width: 48px; height: 48px; border-radius: 12px; }
.login-msg.err { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.hint.center { text-align: center; }
input:focus-visible, select:focus-visible, .btn:focus-visible, .chip:focus-visible, nav a:focus-visible, .camp-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.delta { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.seg button { font: inherit; font-size: 12px; border: 0; background: transparent; color: var(--muted); padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

.chart-box { position: relative; height: 300px; }
.chart-box.small { height: 240px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
.tbl th:first-child, .tbl td:first-child, .tbl .left { text-align: left; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl.sortable th { cursor: pointer; user-select: none; }
.tbl th.sorted::after { content: " ↓"; }
.tbl th.sorted.asc::after { content: " ↑"; }
.tbl tfoot td { font-weight: 600; border-bottom: 0; }
.tbl td.wrap { white-space: normal; min-width: 180px; max-width: 360px; text-align: left; }
.tbl td.chk, .tbl th.chk { width: 28px; text-align: center; }
.tbl select.sm { padding: 3px 6px; font-size: 12px; }
.neg-text { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.tbl td.name { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.tbl .sub { display: block; color: var(--muted); font-size: 11px; }
.status { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.status.ACTIVE { background: var(--good-soft); color: var(--good); }
.status.PAUSED { background: var(--surface-2); color: var(--muted); }
.status.OTHER { background: var(--warn-soft); color: var(--warn); }
.good { color: var(--good); }
.bad { color: var(--bad); }

/* Insights */
.insight-list { display: flex; flex-direction: column; gap: 8px; }
.insight { display: flex; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); border-left-width: 4px; align-items: flex-start; }
.insight.critical { border-left-color: var(--bad); }
.insight.warning { border-left-color: var(--warn); }
.insight.opportunity { border-left-color: var(--good); }
.insight.info { border-left-color: var(--info); }
.insight .body { flex: 1; min-width: 0; }
.insight .title { font-weight: 600; }
.insight .meta { font-size: 12px; color: var(--muted); margin: 1px 0 4px; }
.insight .detail { font-size: 13px; }
.sev { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.sev.critical { background: var(--bad-soft); color: var(--bad); }
.sev.warning { background: var(--warn-soft); color: var(--warn); }
.sev.opportunity { background: var(--good-soft); color: var(--good); }
.sev.info { background: var(--info-soft); color: var(--info); }
.insight-list.compact .insight { padding: 9px 12px; }
.insight-list.compact .detail { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { color: var(--muted); padding: 20px; text-align: center; }

/* Pacing */
.pacing { display: flex; flex-direction: column; gap: 18px; }
.pace-row .top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.bar { position: relative; height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 6px; }
.bar .proj { position: absolute; inset: 0 auto 0 0; border-radius: 6px; opacity: .25; }
.bar .ideal { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); }
.pace-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.pace-stats b { display: block; color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }

/* Settings */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.check { flex-direction: row !important; align-items: center; gap: 8px; color: var(--text) !important; font-size: 13px !important; }
.hint { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.hint.warn { color: var(--warn); }
.save-bar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 20px; width: min(440px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

#toast { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; max-width: 420px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.toast.err { background: var(--bad); color: #fff; }

.loading { opacity: .55; pointer-events: none; transition: opacity .15s; }

@media (max-width: 1200px) {
  .kpis.secondary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
  .stack { flex-direction: row; }
  .stack > .card { flex: 1 1 0; }
}
@media (max-width: 1000px) {
  body { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; }
  .brand { padding: 14px 16px 6px; }
  nav { flex-direction: row; overflow-x: auto; }
  nav a { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .logout { position: absolute; top: 10px; right: 8px; padding: 0; }
  .logout .btn { width: auto; }
  .sidebar { position: relative; }
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  main { padding: 0 16px 40px; }
}
@media (max-width: 640px) {
  .stack { flex-direction: column; }
  .kpis.secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis.primary .value { font-size: 22px; }
  .hero p { font-size: 14px; }
}
.steps { margin: 0 0 14px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.steps select { max-width: 100%; }

#dlgBody { white-space: pre-line; }
