@import url('https://fonts.googleapis.com/css2?family=Baloo+Da+2:wght@400;500;600;700&display=swap');

:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --ink: #1c2333;
  --muted: #6b7487;
  --brand: #1877f2;
  --brand-dark: #145fc4;
  --ok: #0c8a4d;
  --err: #d33131;
  --warn: #b06a00;
  --line: #e3e7ef;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Baloo Da 2', -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
code { background: #eef1f7; padding: 2px 7px; border-radius: 6px; font-size: .88em; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
h1 { font-size: 1.5rem; margin: 18px 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: .92em; }
.mt { margin-top: 10px; }
.nowrap { white-space: nowrap; }

/* topbar */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px;
  flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  padding: 6px 12px; border-radius: 999px; color: var(--ink); font-weight: 500;
}
.topbar nav a.active, .topbar nav a:hover { background: #e8f0fe; color: var(--brand-dark); }
.topbar nav a.danger-link { color: var(--err); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 8px 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: .85em; padding: 18px; }

/* cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 14px 0;
  box-shadow: 0 1px 3px rgba(20, 30, 60, .05);
}

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; text-align: center;
}
.stat b { display: block; font-size: 1.7rem; color: var(--brand-dark); }
.stat.warn b { color: var(--warn); }
.stat span { color: var(--muted); font-size: .88em; }

/* forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: .93em; }
label.inline { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; margin: 6px 14px 6px 0; }
input[type=text], input[type=password], input[type=number], input:not([type]), textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid #cdd4e0; border-radius: 10px;
  font: inherit; background: #fbfcfe;
}
input:focus, textarea:focus { outline: 2px solid #a9c8f7; border-color: var(--brand); }
textarea { resize: vertical; }
.btn {
  display: inline-block; background: var(--brand); color: #fff; border: 0;
  padding: 9px 22px; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; margin-top: 12px;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: #eef1f7; color: var(--ink); }
.btn.ghost:hover { background: #e3e7ef; }
.row-btns { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.toggles { margin: 8px 0; }
.inline-form { display: inline; }

/* alerts */
.alert { padding: 10px 14px; border-radius: 10px; margin: 12px 0; font-size: .95em; }
.alert.ok { background: #e5f6ec; color: var(--ok); }
.alert.err { background: #fdeaea; color: var(--err); }
.alert.warn { background: #fdf3e0; color: var(--warn); }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92em; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
tr.inactive { opacity: .5; }
.clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* badges & mini buttons */
.badge { background: #eef1f7; border-radius: 999px; padding: 2px 10px; font-size: .85em; white-space: nowrap; }
.badge.on { background: #e5f6ec; color: var(--ok); }
.badge-btn { border: 0; border-radius: 999px; padding: 3px 12px; font: inherit; font-size: .85em; cursor: pointer; }
.badge-btn.on { background: #e5f6ec; color: var(--ok); }
.badge-btn.off { background: #fdeaea; color: var(--err); }
.mini-btn {
  display: inline-block; background: #eef1f7; border: 0; border-radius: 8px;
  padding: 4px 12px; font: inherit; font-size: .87em; cursor: pointer; color: var(--ink);
}
.mini-btn:hover { background: #e3e7ef; }
.mini-btn.on { background: var(--brand); color: #fff; }
.mini-btn.danger { color: var(--err); }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

/* checklist & kv */
.checklist { list-style: none; padding: 0; margin: 0 0 12px; }
.checklist li { padding: 5px 0; }
.checklist li.done { color: var(--ok); }
.kv { display: grid; gap: 10px; margin: 10px 0; }
.kv label { margin: 0 0 2px; }
code.copy { display: block; padding: 8px 12px; user-select: all; }

/* guide */
.guide li { margin: 6px 0; }
details summary { cursor: pointer; font-weight: 600; }

/* reply preview */
.reply-preview {
  background: #f0f6ff; border: 1px solid #cfe0fb; border-radius: 12px;
  padding: 10px 14px; margin: 10px 0;
}
.reply-preview p { margin: 4px 0 0; }

/* learned replies */
.learned-item { border-bottom: 1px solid var(--line); padding: 12px 0; }
.learned-item:last-child { border-bottom: 0; }
.learned-item.inactive { opacity: .5; }
.learned-q { margin-bottom: 4px; }
.learned-a {
  background: #f0f6ff; border: 1px solid #cfe0fb; border-radius: 10px;
  padding: 8px 12px; margin: 6px 0;
}

/* auth pages */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 8px 32px rgba(20, 30, 60, .1);
  padding: 30px 30px 26px; width: 100%; max-width: 420px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 1.3rem; }
.auth-card .btn { width: 100%; }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .clip { max-width: 130px; }
}
