:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --ok: #0f9d58;
  --warn: #d97706;
  --danger: #dc2626;
  --hot: #db2777;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #1b1e26;
  color: #d5d8de;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}
.brand { font-weight: 700; font-size: 16px; margin: 4px 8px 18px; color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: #c3c7d0; padding: 9px 12px; border-radius: 8px; font-size: 14px;
}
.sidebar nav a:hover { background: #262a34; text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar-foot {
  margin-top: auto; padding: 12px 12px 0; border-top: 1px solid #2b2f3a;
  display: flex; justify-content: space-between; font-size: 13px;
}
.sidebar-foot a, .sidebar-foot .muted { color: #8b909c; }

.main { flex: 1; padding: 26px 30px; max-width: 1200px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 26px 0 10px; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.alert .n { color: var(--danger); }

table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { background: #fafbfc; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.new { background: #eef0f4; color: #4b5563; }
.badge.cold { background: #e0f2fe; color: #0369a1; }
.badge.warm { background: #fef3c7; color: #b45309; }
.badge.hot { background: #fce7f3; color: var(--hot); }
.badge.customer { background: #dcfce7; color: #15803d; }
.badge.ignored { background: #f3f4f6; color: #9ca3af; }
.badge.off { background: #f3f4f6; color: #9ca3af; }
.badge.on { background: #dcfce7; color: #15803d; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.checkline { display: flex; align-items: center; gap: 9px; margin: 9px 0; font-size: 14px; }
.checkline input { width: auto; margin: 0; }
.checkline label { margin: 0; font-weight: 400; }

.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.danger { background: #fff; color: var(--danger); border-color: #f3c9c9; }
.btn.sm { padding: 5px 10px; font-size: 13px; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 190px; }
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.toolbar label { margin: 0 0 5px; }

.flash { background: #dcfce7; color: #14532d; border: 1px solid #bbf7d0; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.err { background: #fee2e2; color: #7f1d1d; border-color: #fecaca; }

#livebar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: var(--brand); color: #fff; text-align: center;
  padding: 8px; cursor: pointer; font-size: 14px;
}

/* Söhbət */
.thread { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.bubble { max-width: 74%; padding: 9px 13px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.bubble.in { background: #eef0f4; align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.out { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble .meta { display: block; font-size: 11px; opacity: .7; margin-top: 5px; }

/* Postlar */
.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.post { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.post img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #eee; }
.post .body { padding: 10px 12px; font-size: 13px; }
.post .cap { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Giriş */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 30px; width: 100%; max-width: 360px; }
.login-box h1 { text-align: center; margin-bottom: 20px; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .sidebar-foot { margin: 0; border: none; padding: 0; gap: 10px; }
  .main { padding: 18px 14px; }
}
