:root {
  --sidebar-w: 250px;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg-soft: #f4f5fb;
  --card-radius: 14px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg-soft);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

[data-bs-theme="dark"] body { background: #0f1117; }
[data-bs-theme="dark"] { --bg-soft: #0f1117; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: #14142b;
  color: #cfd0e8;
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  transition: transform .25s ease;
  z-index: 1030;
}
.sidebar-brand {
  padding: 20px; font-weight: 700; font-size: 1.05rem;
  color: #fff; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  color: #b4b6d6; text-decoration: none; padding: 10px 14px;
  border-radius: 10px; font-size: .92rem; display: flex; align-items: center; gap: 10px;
  transition: .15s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--primary); color: #fff;
}
.sidebar-heading {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: #6b6d94; padding: 16px 14px 6px;
}

.main-area { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }

.topbar {
  height: 64px; display: flex; align-items: center; padding: 0 24px;
  background: var(--bs-body-bg); border-bottom: 1px solid rgba(0,0,0,.06);
  position: sticky; top: 0; z-index: 1020;
}

.content { padding: 24px; }

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-area { margin-left: 0; }
}

/* ---------- Cards / Stats ---------- */
.stat-card {
  background: var(--bs-body-bg); border-radius: var(--card-radius);
  padding: 18px 20px; box-shadow: 0 2px 10px rgba(20,20,50,.05);
  border: 1px solid rgba(0,0,0,.04);
}
.stat-card .stat-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-card .stat-label { font-size: .8rem; color: #8a8ca8; }

.card-soft {
  background: var(--bs-body-bg); border-radius: var(--card-radius);
  border: 1px solid rgba(0,0,0,.05); box-shadow: 0 2px 10px rgba(20,20,50,.04);
}

/* ---------- Auth page ---------- */
.auth-body {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.auth-wrapper { width: 100%; max-width: 380px; padding: 20px; }
.auth-card {
  background: #fff; border-radius: 18px; padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}

/* ---------- Chat / Conversation ---------- */
.chat-window {
  height: 480px; overflow-y: auto; padding: 16px;
  background: var(--bg-soft); border-radius: 10px;
}
.chat-bubble { max-width: 75%; padding: 10px 14px; border-radius: 14px; margin-bottom: 10px; font-size: .9rem; }
.chat-bubble.customer { background: #fff; border: 1px solid rgba(0,0,0,.08); }
.chat-bubble.staff { background: var(--primary); color: #fff; margin-left: auto; }
.chat-bubble.ai { background: #d1fae5; margin-left: auto; }
.chat-bubble.system { background: transparent; color: #999; text-align: center; margin: 0 auto; font-size: .75rem; }

.badge-status-open { background: #3b82f6; }
.badge-status-pending { background: #f59e0b; }
.badge-status-resolved { background: #10b981; }

.table-modern thead { background: var(--bg-soft); }
.table-modern td, .table-modern th { vertical-align: middle; }

.kb-tab-content { max-height: 60vh; overflow-y: auto; }
