:root {
  --sidebar-w: 240px;
  --primary: #4f46e5;
  --bg: #f4f5f9;
  --card-border: #e5e7eb;
  --card-bg: #fff;
  --topbar-bg: #fff;
  --input-bg: #f9fafb;
  --muted: #6b7280;
  --heading: #111827;
}

[data-bs-theme="dark"] {
  --bg: #0b0f19;
  --card-border: #26304a;
  --card-bg: #151b28;
  --topbar-bg: #111827;
  --input-bg: #1b2333;
  --muted: #94a3b8;
  --heading: #e5e7eb;
}

body {
  background: var(--bg);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  transition: background-color 0.15s ease, color 0.15s ease;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: #111827;
  color: #d1d5db;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  font-weight: 700;
  color: #fff;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand img { width: 28px; height: 28px; border-radius: 6px; }

.sidebar-nav { display: flex; flex-direction: column; padding: 10px; gap: 2px; }
.sidebar-nav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--card-border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.search-form { position: relative; flex: 1; max-width: 420px; }
.search-form i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9ca3af; }
.search-form input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
  color: var(--heading);
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.notif-badge { position: absolute; top: -2px; right: -2px; font-size: 0.6rem; }
.notif-menu { min-width: 300px; max-height: 400px; overflow-y: auto; }

.content { padding: 24px; }

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px 18px;
}
.stat-card .stat-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--heading); }

.card, .table, .form-control, .form-select { border-radius: 10px; }

.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.kanban-col { min-width: 260px; background: var(--card-bg); border-radius: 12px; border: 1px solid var(--card-border); padding: 10px; }
.kanban-col h6 { font-size: 0.85rem; text-transform: uppercase; color: var(--muted); }
.kanban-card { background: var(--input-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 10px; margin-bottom: 8px; font-size: 0.85rem; color: var(--heading); }

.timeline { border-left: 2px solid var(--card-border); margin-left: 8px; padding-left: 18px; }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #111827, #4f46e5);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 45px rgba(0,0,0,0.25);
}

.install-app-btn { display: inline-flex; align-items: center; gap: 6px; }
.install-app-btn.d-none { display: none; }

.reply-card { display: flex; flex-direction: column; }

/* Responsive tables: each <table> is wrapped in .table-responsive (Bootstrap)
   in the templates, which scrolls horizontally on narrow screens without
   breaking header/body column alignment. */
.table-responsive .table { margin-bottom: 0; }

/* Mobile layout */
@media (max-width: 991.98px) {
  .sidebar { width: 260px; }
  .sidebar.offcanvas-lg { background: #111827; }
  .content { padding: 16px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .search-form { max-width: none; }
  .stat-card { padding: 12px 14px; }
  .stat-card .stat-value { font-size: 1.3rem; }
}

@media (max-width: 575.98px) {
  .search-form input { font-size: 0.85rem; }
  .kanban-col { min-width: 220px; }
}
