:root {
  --bg: #0f1115;
  --bg-soft: #151922;
  --card: #171b24;
  --border: #262c38;
  --text: #e8eaee;
  --muted: #98a1b3;
  --primary: #4f7cff;
  --primary-soft: #21306b;
  --success: #35c07a;
  --warn: #e0a52a;
  --danger: #ef5f6b;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  font-size: 14px;
}

code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { background: #10141c; border: 1px solid var(--border); padding: 1px 5px; border-radius: 6px; font-size: 12px; }
a { color: #7aa2ff; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--danger); font-size: 12px; min-height: 16px; margin: 8px 0 0; }
.ok-text { color: var(--success); font-size: 12px; }

/* ---------- Genel bileşenler ---------- */

.btn {
  border: 1px solid var(--border);
  background: #1d222d;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: filter .15s ease, background .15s ease;
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.success { background: var(--success); border-color: var(--success); color: #06210f; }
.btn.danger { background: transparent; border-color: #55262c; color: #ff8f98; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.block { width: 100%; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #1b2130;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.pill.ok { color: var(--success); border-color: #1f4c37; background: #11251c; }
.pill.bad { color: var(--danger); border-color: #4d2329; background: #251316; }
.pill.warn { color: var(--warn); border-color: #4a3a17; background: #241d0f; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field > span em { color: #6f7a8d; font-style: normal; }
input[type="text"], input[type="password"], input[type="number"], input[type="time"], select, textarea {
  width: 100%;
  background: #10141c;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-family: inherit;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 12px; font-size: 13px; color: #c7cdd9; }
.check input { margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.inline-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.test-result { font-size: 12px; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.info-box {
  background: #121926;
  border: 1px solid #26354d;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #b8c4d8;
  line-height: 1.6;
}

/* ---------- Giriş / kurulum ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, .85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  overflow: auto;
}
.overlay-card { width: 100%; max-width: 430px; box-shadow: var(--shadow); }
.overlay-card.wide { max-width: 720px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; letter-spacing: .3px; margin-bottom: 14px; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 12px var(--danger); }
h1 { font-size: 20px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0; }

.steps { display: flex; gap: 10px; margin: 18px 0 22px; flex-wrap: wrap; }
.step-dot {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: #141a25; border: 1px solid var(--border);
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.step-dot span { font-weight: 400; }
.step-dot.active { border-color: var(--primary); color: #fff; background: #1b2540; }
.step-dot.done { border-color: #1f4c37; color: var(--success); }

.wizard-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- Uygulama kabuğu ---------- */

.app { display: block; min-height: 100vh; }
.app-body { display: flex; align-items: stretch; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar nav { display: flex; flex-direction: column; gap: 3px; margin-top: 12px; flex: 1; }
.nav-item {
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
}
.nav-item:hover { background: #1c2230; color: var(--text); }
.nav-item.active { background: #1d2740; color: #fff; font-weight: 600; }
.sidebar-footer { display: flex; flex-direction: column; gap: 10px; }
.status-pill { font-size: 12px; color: var(--muted); }

.main { flex: 1; padding: 22px 26px 60px; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- View içerikleri ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 20px; font-weight: 600; margin-top: 6px; }
.stat .sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.split { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; align-items: start; }
@media (max-width: 1050px) { .split { grid-template-columns: 1fr; } }

.section-title { display: flex; justify-content: space-between; align-items: center; margin: 0 0 12px; }
.section-title h3 { font-size: 14px; }
.card + .card { margin-top: 16px; }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.checklist .mark { width: 18px; flex-shrink: 0; text-align: center; }
.checklist .mark.ok { color: var(--success); }
.checklist .mark.bad { color: var(--danger); }
.checklist .mark.warn { color: var(--warn); }
.checklist .hint { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.checklist li.blocking .hint { color: #d9a3a8; }

.console {
  background: #0b0e14;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  height: 330px;
  overflow: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}
.console .row { display: flex; gap: 8px; }
.console .ts { color: #5b667a; flex-shrink: 0; }
.console .lv { width: 62px; flex-shrink: 0; }
.console .lv.info { color: #7aa2ff; }
.console .lv.step { color: #c58fff; }
.console .lv.success { color: var(--success); }
.console .lv.warn { color: var(--warn); }
.console .lv.error { color: var(--danger); }
.console .lv.debug { color: #6b7688; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
tr:hover td { background: #1a1f2a; }
td .title-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-tag { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.status-tag.success { color: var(--success); border-color: #1f4c37; background: #11251c; }
.status-tag.failed { color: var(--danger); border-color: #4d2329; background: #251316; }
.status-tag.running { color: var(--warn); border-color: #4a3a17; background: #241d0f; }
.status-tag.cancelled { color: var(--muted); border-color: #3a4150; }
.status-tag.skipped { color: var(--muted); }
.status-tag.pending { color: var(--muted); }

.prompt-card { margin-bottom: 12px; }
.prompt-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.prompt-head .name { font-weight: 600; }
.prompt-head .actions { display: flex; gap: 8px; align-items: center; }

.step-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.step-list li { display: flex; gap: 10px; font-size: 12.5px; align-items: baseline; }
.step-list .sname { min-width: 210px; color: #c7cdd9; }
.step-list .detail { color: var(--muted); }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: #1b2130; border: 1px solid var(--border); border-left: 3px solid var(--primary);
  padding: 11px 14px; border-radius: 9px; font-size: 13px; box-shadow: var(--shadow); max-width: 380px;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast.warn { border-left-color: var(--warn); }

.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 13px; margin-bottom: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
pre.log { background: #0b0e14; border: 1px solid var(--border); border-radius: 10px; padding: 12px; max-height: 300px; overflow: auto; font-size: 11.5px; line-height: 1.5; }

/* ---------- Mobil üst çubuk + çekmece ---------- */

.mobile-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 45;
}
.mobile-bar .brand { margin-bottom: 0; }
.mobile-bar .btn { margin-left: auto; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  width: 38px;
  height: 38px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: #1c2230; }

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, .65);
  z-index: 55;
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 720px; }

/* ---------- Çoklu saat editörü ---------- */

.times-editor { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.time-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #10141c;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px 5px 3px 10px;
}
.time-chip input[type="time"] { border: 0; background: transparent; width: 116px; padding: 6px 0; }
.time-chip input[type="time"]:focus { outline: none; }

/* ---------- Prompt testi sonuçları ---------- */

.test-run { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 12px; background: #12161f; }
.test-run-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.test-run pre.log { max-height: 240px; margin: 6px 0 0; }
details.test-block { margin-top: 10px; }
details.test-block summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
/* Prompt metinleri satır kaydırsın (yatay kaydırma yerine) */
.test-run pre.log, details.test-block pre.log { white-space: pre-wrap; overflow-wrap: anywhere; }
details.test-block[open] summary { color: var(--text); margin-bottom: 6px; }
.prompt-test-empty { color: var(--muted); font-size: 12.5px; margin-top: 10px; }

/* ---------- Mobil düzen ---------- */

@media (max-width: 860px) {
  html, body { font-size: 15px; }
  /* iOS'ta alana odaklanınca otomatik yakınlaştırmayı engeller */
  input[type="text"], input[type="password"], input[type="number"], input[type="time"], select, textarea { font-size: 16px; }

  .app-body { display: block; }
  .mobile-bar { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 300px);
    height: 100%;
    z-index: 60;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
    overflow-y: auto;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; }
  body.nav-open { overflow: hidden; }

  .main { padding: 14px 14px 90px; }
  .topbar { margin-bottom: 14px; gap: 12px; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1 1 auto; }
  #next-run-pill { width: 100%; justify-content: center; }

  .split, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat .value { font-size: 18px; }

  .card { padding: 16px; }
  .console { height: 220px; }

  /* Tabloyu mobilde kart satırlara çevir */
  .table-wrap { overflow: visible; }
  .table-wrap table { min-width: 0; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #12161f;
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  .table-wrap tr:hover td { background: transparent; }
  .table-wrap td {
    border: 0;
    padding: 4px 0;
    display: flex;
    gap: 10px;
    align-items: baseline;
  }
  .table-wrap td::before {
    content: attr(data-label);
    flex: 0 0 80px;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .4px;
  }
  .table-wrap td.title-cell { white-space: normal; overflow: visible; text-overflow: clip; max-width: none; }
  .table-wrap td.actions-cell { padding-top: 10px; }
  .table-wrap td.actions-cell::before { content: none; }
  .table-wrap td.actions-cell .btn { flex: 1; }

  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
  .kv dd { margin-bottom: 4px; word-break: break-word; }

  .step-list li { flex-wrap: wrap; }
  .step-list .sname { min-width: 0; flex: 0 0 100%; }

  .overlay { padding: 10px; align-items: flex-start; }
  .overlay-card, .overlay-card.wide { max-width: 100%; }
  .modal-head { position: sticky; top: 0; background: var(--card); padding-bottom: 10px; z-index: 1; }

  .steps { overflow-x: auto; padding-bottom: 4px; flex-wrap: nowrap; }
  .step-dot { flex: 0 0 auto; }
  .step-dot span { display: none; }
  .wizard-actions .btn { flex: 1; }

  .toasts { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .toast { max-width: none; }

  .prompt-head { flex-direction: column; align-items: stretch; }
  .prompt-head .name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .prompt-head .name input[type="text"] { max-width: none !important; flex: 1 1 140px; }
  .prompt-head .actions { justify-content: flex-end; }

  .time-chip input[type="time"] { width: 100px; }
  .inline-actions .btn { flex: 1 1 auto; }
  .section-title { flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
  .btn { padding: 10px 12px; }
  .mobile-bar .brand { font-size: 12px; }
}
