/* ─── design tokens ─── */
:root {
  --bg: #f2f4fa;
  --card: #ffffff;
  --line: #e7ebf4;
  --line-strong: #dbe1ee;
  --ink: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --primary: #111c33;
  --primary-soft: #eef1f8;
  --accent: #4f46e5;
  --accent-soft: #eeefff;
  --ok: #16a34a;
  --ok-soft: #e9f9ef;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --err: #dc2626;
  --err-soft: #fdeeee;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 30px -14px rgba(15, 23, 42, .14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ─── layout ─── */
.app { display: flex; min-height: 100dvh; }

.side {
  width: 250px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 17px; letter-spacing: -.01em;
  padding: 6px 10px 18px;
}
.brand.on-dark { color: #fff; padding-bottom: 0; }
.logo { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; border-radius: 9px; flex-shrink: 0; }
.logo svg { width: 17px; height: 17px; }
.on-dark .logo { background: rgba(255,255,255,.14); }

.nav-group { margin-top: 14px; }
.nav-title {
  font-size: 11px; font-weight: 700; letter-spacing: .09em;
  color: var(--faint); padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin: 1px 0;
  border-radius: var(--r-sm);
  color: var(--muted); font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; background: none; width: 100%;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--primary-soft); color: var(--ink); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.side-foot { margin-top: auto; padding: 12px 10px 4px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: rgba(242, 244, 250, .85);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid var(--line);
}
.page { flex: 1; padding: 26px; max-width: 1080px; width: 100%; margin: 0 auto; }

/* ─── components ─── */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600;
  padding: 5px 12px; border-radius: 99px;
  background: var(--primary-soft); color: var(--muted);
}
.pill .dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.gold { background: #fdf0d0; color: #a06c00; }

.h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat { display: flex; justify-content: space-between; gap: 12px; }
.stat-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.stat-sub { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
.icon-chip {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.icon-chip svg { width: 18px; height: 18px; }
.icon-chip.accent { background: var(--accent-soft); color: var(--accent); }
.icon-chip.ok { background: var(--ok-soft); color: var(--ok); }
.icon-chip.warn { background: var(--warn-soft); color: var(--warn); }
.icon-chip.err { background: var(--err-soft); color: var(--err); }

.bar { height: 7px; border-radius: 99px; background: var(--primary-soft); overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .5s ease; }

.banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--warn-soft); border: 1px solid #f3d9a8; color: #92610a;
  border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 18px; font-size: 14px;
}
.banner svg { width: 18px; height: 18px; flex-shrink: 0; }
.banner .spacer { flex: 1; }

.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }

.btn {
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  cursor: pointer; transition: transform .08s, box-shadow .15s, background .12s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--err); border-color: #f1c5c5; }
.btn.block { width: 100%; padding: 12px; font-size: 14.5px; }
.btn.small-btn { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: default; box-shadow: none; }

/* toggle */
.switch { position: relative; width: 46px; height: 27px; flex-shrink: 0; cursor: pointer; }
.switch input { display: none; }
.switch i {
  position: absolute; inset: 0; border-radius: 99px;
  background: var(--line-strong); transition: background .18s;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 99px; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s;
}
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(19px); }

/* feed */
.feed { display: flex; flex-direction: column; gap: 8px; }
.ev {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 13px 15px;
}
.ev .dot { width: 9px; height: 9px; border-radius: 99px; margin-top: 6px; flex-shrink: 0; }
.ev .meta { font-size: 12px; color: var(--faint); margin-top: 3px; }
.ev .txt { font-size: 14px; word-break: break-word; }
.ev b { font-size: 12.5px; letter-spacing: .04em; text-transform: uppercase; }
.t-incoming b, .t-incoming .dot { color: var(--accent); }
.t-incoming .dot { background: var(--accent); }
.t-reply b { color: var(--ok); } .t-reply .dot { background: var(--ok); }
.t-error b { color: var(--err); } .t-error .dot { background: var(--err); }
.t-skipped b { color: var(--warn); } .t-skipped .dot { background: var(--warn); }
.t-other b { color: var(--muted); } .t-other .dot { background: var(--faint); }

/* forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin: 16px 0 7px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; font: inherit; font-size: 14.5px;
  padding: 11px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: #fbfcfe; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
  background: #fff;
}
textarea { min-height: 110px; resize: vertical; }

.list { display: flex; flex-direction: column; }
.list .li {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.list .li:last-child { border-bottom: none; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; font-size: 14px; border-bottom: 1px solid var(--line); }
.kv:last-child { border: none; }
.kv b { font-weight: 600; }
.big-num { font-size: 38px; font-weight: 700; letter-spacing: -.03em; }

.empty { text-align: center; color: var(--faint); padding: 40px 0; font-size: 14px; }

/* kurulum: adım listesi + env formu + log */
.steps {
  display: flex; flex-direction: column; gap: 11px;
  margin: 16px 0 4px; padding: 14px 15px;
  background: var(--bg); border-radius: var(--r-md);
}
.step { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.step svg { width: 16px; height: 16px; margin-top: 2px; color: var(--faint); flex-shrink: 0; }
.step.done svg { color: var(--ok); }
.step.blocked { opacity: .55; }
.step b { font-size: 13.5px; }
.env-form { margin-top: 6px; }
.env-form label { margin-top: 12px; }
.req { color: var(--err); }
.field-help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field-help a { color: var(--accent); text-decoration: none; font-weight: 600; }
details.more { margin-top: 10px; }
details.more > summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 7px 0; user-select: none; list-style: none;
}
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }
details.more[open] > summary { color: var(--ink); }
.logbox {
  margin: 0; min-height: 80px; max-height: 300px; overflow: auto;
  background: #0f172a; color: #c9d4ea; border-radius: var(--r-md);
  padding: 13px 14px; font-size: 12px; line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-all;
}

/* sohbet arayüzü */
.chatwrap { display: grid; grid-template-columns: 300px 1fr; gap: 14px; height: calc(100dvh - 175px); min-height: 420px; }
.chatlist { padding: 8px; overflow-y: auto; }
.chatitem { display: flex; gap: 11px; padding: 10px; border-radius: var(--r-md); cursor: pointer; align-items: center; }
.chatitem:hover, .chatitem.active { background: var(--primary-soft); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.cbody { flex: 1; min-width: 0; }
.crow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.crow b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ubadge {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 99px; min-width: 19px; height: 19px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.chatpane { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chathead { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.msglist {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 5px; background: var(--bg);
}
.bubble { max-width: 72%; padding: 8px 12px; border-radius: 15px; font-size: 14px; line-height: 1.42; word-break: break-word; }
.bubble.in { background: var(--card); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.out { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bsender { font-size: 11.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.bmeta { font-size: 10.5px; opacity: .55; margin-top: 3px; text-align: right; }
.chatinput { display: flex; gap: 9px; padding: 12px 14px; border-top: 1px solid var(--line); }
.chatinput input { flex: 1; }
.chatinput .btn { flex-shrink: 0; }
#chatBack { display: none; }

@media (max-width: 899px) {
  .chatwrap { grid-template-columns: 1fr; height: calc(100dvh - 220px); }
  .chatpane { display: none; }
  .chatwrap.open .chatlist { display: none; }
  .chatwrap.open .chatpane { display: flex; }
  #chatBack { display: inline-flex; }
}

/* toasts */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 11px 16px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow); animation: pop .22s ease;
  max-width: min(360px, calc(100vw - 32px));
}
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.ok { border-color: #b9e8c9; color: var(--ok); }
.toast.err { border-color: #f1c5c5; color: var(--err); }
.toast.warn { border-color: #f3d9a8; color: var(--warn); }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.97); } }

/* login */
.login { position: fixed; inset: 0; z-index: 90; display: flex; background: var(--card); }
.login-hero {
  flex: 1; padding: 46px 50px; color: #e6e9f5;
  background: linear-gradient(155deg, #0b1226 30%, #1a1145 75%, #2a1a5e 100%);
  display: flex; flex-direction: column;
}
.login-hero h1 { font-size: clamp(26px, 3.4vw, 38px); letter-spacing: -.03em; line-height: 1.15; margin: auto 0 14px; color: #fff; }
.login-hero p { color: #a7aec9; font-size: 15px; max-width: 380px; margin: 0 0 26px; }
.login-hero ul { list-style: none; padding: 0; margin: 0 0 auto; display: flex; flex-direction: column; gap: 13px; }
.login-hero li { display: flex; align-items: center; gap: 11px; font-size: 14px; color: #c4c9dd; }
.login-hero li::before {
  content: ""; width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: rgba(255,255,255,.1) center / 13px no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a5b4fc' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
.login-form { flex: 1; display: flex; align-items: center; justify-content: center; padding: 30px; }
.login-card { width: 100%; max-width: 370px; }
.login-card h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }

/* bottom tab bar (mobile) */
.tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: rgba(255,255,255,.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  overflow-x: auto; scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tab-item {
  flex: 1 0 auto; min-width: 68px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; border: none; background: none; border-radius: var(--r-sm);
  color: var(--faint); font-size: 10.5px; font-weight: 600; cursor: pointer;
}
.tab-item svg { width: 20px; height: 20px; }
.tab-item.active { color: var(--primary); }

/* ─── responsive ─── */
@media (max-width: 899px) {
  .side { display: none; }
  .top { display: flex; }
  .tabbar { display: flex; }
  .page { padding: 18px 16px calc(88px + env(safe-area-inset-bottom)); }
  .login-hero { display: none; }
  .h1 { font-size: 21px; }
}
