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

:root {
  --brand: #FF6B00;
  --brand-dark: #CC5500;
  --brand-light: #FFF3E8;
  --sidebar-width: 260px;
  --topbar-height: 56px;
  --tabbar-height: 62px;
  --surface: #ffffff;
  --bg: #f0f2f5;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-sm: 12px;
  --content-max: 1280px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body.admin-app {
  background: var(--bg);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-top: var(--topbar-height);
}

body.admin-app.has-tabbar {
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
}

/* ── Top bar ──────────────────────────────────── */
.admin-topbar {
  height: var(--topbar-height);
  background: linear-gradient(135deg, #141414 0%, #252525 55%, #1a1a1a 100%);
  border-bottom: 2px solid var(--brand);
  box-shadow: var(--shadow-md);
  z-index: 1040;
}

.admin-topbar-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
  padding: 0 0.75rem;
  max-width: 100%;
}

.topbar-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 11px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
  transition: background 0.2s, transform 0.15s;
}

.topbar-btn:active { transform: scale(0.96); }

.topbar-btn:hover,
.topbar-btn-ghost:hover {
  background: rgba(255, 107, 0, 0.25);
  color: #fff;
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: #fff;
  min-width: 0;
  flex-shrink: 0;
  overflow: hidden;
}

.topbar-brand img {
  width: 36px;
  height: 36px;
  max-width: 36px;
  max-height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 0.92rem;
  letter-spacing: 0.06em;
}

.brand-text small {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.topbar-user {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
  padding: 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sidebar backdrop ─────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--topbar-height);
  background: rgba(0, 0, 0, 0.45);
  z-index: 1025;
  opacity: 0;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(2px);
}

body.sidebar-open .sidebar-backdrop {
  display: block;
  opacity: 1;
}

/* ── Sidebar ──────────────────────────────────── */
.admin-shell { min-height: calc(100vh - var(--topbar-height)); }

.admin-sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  height: calc(100dvh - var(--topbar-height));
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1030;
  background: linear-gradient(180deg, #1c1c1c 0%, #141414 100%) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.sidebar-profile small {
  display: block;
  color: #9ca3af;
  font-size: 0.72rem;
}

.sidebar-nav { padding: 0.5rem 0 1.5rem; }

.sidebar-label {
  color: #6b7280;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.85rem 1.15rem 0.35rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #9ca3af;
  padding: 0.72rem 1.15rem;
  font-size: 0.84rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.18s ease;
  border-radius: 0 10px 10px 0;
  margin-right: 8px;
  text-decoration: none;
  position: relative;
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255, 107, 0, 0.1);
}

.sidebar-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(255, 107, 0, 0.22) 0%, rgba(255, 107, 0, 0.06) 100%);
  border-left-color: var(--brand);
  font-weight: 600;
}

.sidebar-link i {
  width: 20px;
  font-size: 0.9rem;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link span { flex: 1; min-width: 0; }

.sidebar-badge {
  font-style: normal;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--brand);
  color: #fff;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}


/* Legacy nav-link (older pages) */
#sidebar .nav-link {
  display: flex;
  align-items: center;
  color: #9ca3af;
  padding: 0.72rem 1.15rem;
  font-size: 0.84rem;
  text-decoration: none;
}

/* ── Main content ─────────────────────────────── */
.admin-main {
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--topbar-height));
  min-height: calc(100dvh - var(--topbar-height));
}

.admin-main-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

.page-header {
  margin-bottom: 1.25rem;
  gap: 0.75rem;
}

.page-title {
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0;
}

.page-header .breadcrumb {
  font-size: 0.78rem;
  margin: 0;
}

/* ── Mobile bottom tab bar ────────────────────── */
.mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1035;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08);
}

.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.35rem 0.15rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.62rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s;
  min-width: 0;
}

.tabbar-item i { font-size: 1.15rem; }

.tabbar-item.active {
  color: var(--brand);
}

.tabbar-item:active { opacity: 0.75; }

.tabbar-icon-wrap {
  position: relative;
  display: inline-flex;
}

.tabbar-badge {
  position: absolute;
  top: -5px;
  right: -10px;
  font-style: normal;
  font-size: 0.58rem;
  font-weight: 700;
  background: #ef4444;
  color: #fff;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}

/* ── Cards ────────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  overflow: hidden;
}

.card-header {
  border-radius: 0 !important;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0.9rem 1.25rem;
  font-weight: 700;
  font-size: 0.92rem;
}

.card-body { padding: 1.15rem 1.25rem; }

/* ── Stat cards ───────────────────────────────── */
.stat-card {
  border: 1px solid var(--border);
  border-left: none !important;
  background: linear-gradient(145deg, #ffffff 0%, #fafbfc 100%);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
  font-size: 1.75rem;
  color: var(--brand);
  opacity: 0.85;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-light);
  border-radius: 12px;
}

.stat-card .fw-bold.fs-4 {
  font-weight: 800 !important;
  letter-spacing: -0.03em;
}

/* ── Mobile list cards (dashboard + tables) ───── */
.mobile-card-list {
  display: none;
}

.mobile-list-card {
  display: block;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.mobile-list-card:last-child { border-bottom: none; }

.mobile-list-card:active,
.mobile-list-card:hover {
  background: var(--brand-light);
}

.mobile-list-card .mlc-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
}

.mobile-list-card .mlc-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.mobile-list-card .mlc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* ── Buttons ──────────────────────────────────── */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
}

.btn-brand,
.btn-warning {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border: none;
  color: #fff;
}

.btn-brand:hover,
.btn-warning:hover {
  background: linear-gradient(135deg, var(--brand-dark) 0%, #aa4400 100%);
  color: #fff;
}

.btn-sm {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
}

.btn:not(.btn-sm):not(.btn-lg) {
  min-height: 42px;
}

/* ── Forms ────────────────────────────────────── */
.form-control,
.form-select {
  border-radius: var(--radius-sm);
  border-color: #e5e7eb;
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

.form-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 0.35rem;
}

/* ── Tables ───────────────────────────────────── */
.table {
  font-size: 0.875rem;
}

.table thead th {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table-responsive {
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}

.table-hover tbody tr:hover {
  background: var(--brand-light);
}

/* Mobile stacked table rows */
@media (max-width: 767.98px) {
  table.table-mobile-stack thead { display: none; }

  table.table-mobile-stack tbody tr {
    display: block;
    margin: 0.65rem;
    padding: 0.85rem;
    background: #fafbfc;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm);
  }

  table.table-mobile-stack tbody tr:hover {
    background: var(--brand-light);
  }

  table.table-mobile-stack tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0 !important;
    border: none !important;
    text-align: right !important;
  }

  table.table-mobile-stack tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
    max-width: 45%;
  }

  table.table-mobile-stack tbody td.actions-cell {
    justify-content: flex-end;
    padding-top: 0.65rem !important;
    border-top: 1px dashed var(--border) !important;
    margin-top: 0.35rem;
  }

  table.table-mobile-stack tbody td.actions-cell::before { display: none; }

  .table-desktop-only.d-md-none { display: none !important; }
}

/* ── Alerts ───────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.875rem;
  box-shadow: var(--shadow-sm);
}

/* ── Badges ───────────────────────────────────── */
.badge-active   { background: #e6f4ea; color: #2e7d32; }
.badge-inactive { background: #fce8e6; color: #c62828; }

/* ── Chat ─────────────────────────────────────── */
body.chat-active .admin-main-inner {
  padding-left: 0.65rem;
  padding-right: 0.65rem;
  padding-bottom: 0.5rem;
}

.chat-shell {
  height: calc(100vh - 220px);
  height: calc(100dvh - 220px);
  min-height: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chat-sidebar {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fafafa;
  max-height: 100%;
}

.chat-main {
  min-height: 0;
  max-height: 100%;
}

.chat-list-item {
  color: inherit;
  transition: background 0.15s;
}

.chat-list-item:hover  { background: var(--brand-light); cursor: pointer; }
.chat-list-item.active {
  background: var(--brand-light);
  border-left: 3px solid var(--brand);
}

.chat-contact-card {
  background: #f8f9fb;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.chat-back-btn {
  font-weight: 600;
  font-size: 0.85rem;
}

#chatMessages {
  background: #f4f6f9 !important;
  -webkit-overflow-scrolling: touch;
}

/* ── Misc ─────────────────────────────────────── */
.img-preview {
  max-height: 120px;
  border-radius: var(--radius-sm);
  border: 1px solid #dee2e6;
  object-fit: cover;
}

.color-swatch {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  vertical-align: middle;
  margin-right: 4px;
}

.note-editor.note-frame { border-radius: var(--radius-sm); border: 1px solid #dee2e6 !important; }
.note-toolbar { border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important; background: #f8f9fa !important; }

.dataTables_wrapper .dataTables_filter input { border-radius: var(--radius-sm); }
.drag-handle { cursor: grab; color: #aaa; }

.media-pick-item { transition: box-shadow 0.15s, transform 0.15s; background: #fff; }
.media-pick-item:hover { box-shadow: 0 0 0 2px var(--brand); transform: scale(1.02); }
.media-picker-preview img { background: #f5f5f5; padding: 4px; }

/* Quick links (dashboard mobile) */
.quick-links {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.quick-links::-webkit-scrollbar { display: none; }

.quick-link-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.quick-link-pill i { color: var(--brand); }

.quick-link-pill:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-color: rgba(255, 107, 0, 0.25);
}

/* Welcome banner mobile */
.mobile-welcome {
  background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 107, 0, 0.2);
}

.mobile-welcome h2 {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 0.25rem;
}

.mobile-welcome p {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
}

/* ── Login page ───────────────────────────────── */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  background: linear-gradient(145deg, #0a0a0a 0%, #1a1a1a 50%, #0f0f0f 100%);
}

.login-shell {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.login-brand-panel {
  display: none;
}

.login-card {
  background: linear-gradient(160deg, #1e1e1e 0%, #161616 100%);
  border-radius: 20px;
  padding: 2rem 1.75rem;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(var(--brand-rgb), 0.15);
}

.login-mobile-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 14px;
  background: #fff;
  padding: 6px;
}

.login-card-title {
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 0.25rem;
}

.login-card-sub {
  color: #888;
  font-size: 0.88rem;
  margin: 0;
}

@media (min-width: 992px) {
  .login-page {
    padding: 2.5rem;
    background: linear-gradient(135deg, #0d0d0d 0%, #1a1a1a 40%, #111 100%);
  }

  .login-shell {
    display: flex;
    align-items: stretch;
    max-width: 920px;
    min-height: 520px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(var(--brand-rgb), 0.12);
  }

  .login-brand-panel {
    display: flex !important;
    flex: 1 1 50%;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff;
  }

  .login-brand-inner {
    max-width: 340px;
  }

  .login-brand-logo {
    width: 88px;
    height: 88px;
    object-fit: contain;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    margin-bottom: 1.25rem;
  }

  .login-brand-mark {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 1.25rem;
  }

  .login-brand-name {
    font-size: 1.75rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    margin: 0 0 0.5rem;
  }

  .login-brand-tagline {
    font-size: 0.95rem;
    opacity: 0.9;
    line-height: 1.5;
    margin: 0 0 1.75rem;
  }

  .login-brand-features {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .login-brand-features li {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.88rem;
    opacity: 0.92;
    margin-bottom: 0.65rem;
  }

  .login-card {
    flex: 0 0 420px;
    max-width: 420px;
    border-radius: 0;
    border: none;
    border-left: 1px solid rgba(var(--brand-rgb), 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

.login-card .brand-title {
  color: var(--brand);
  font-weight: 800;
  letter-spacing: 0.15em;
  font-size: 1.65rem;
}

.login-card .form-control {
  background: #2a2a2a;
  border-color: #333;
  color: #fff;
  min-height: 48px;
}

.login-card .form-control:focus {
  background: #2a2a2a;
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.2);
}

.login-card label { color: #aaa; font-size: 0.85rem; font-weight: 500; }

.login-card .btn-login {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border: none;
  font-weight: 700;
  min-height: 48px;
  border-radius: var(--radius-sm);
}

.login-card .btn-login:hover {
  background: linear-gradient(135deg, var(--brand-dark) 0%, #aa4400 100%);
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 991.98px) {
  body.admin-app.has-tabbar .admin-main-inner {
    padding-bottom: calc(var(--tabbar-height) + 1rem + env(safe-area-inset-bottom, 0px));
  }

  .admin-sidebar {
    transform: translateX(-100%);
    width: min(300px, 88vw);
    box-shadow: var(--shadow-lg);
  }

  body.sidebar-open .admin-sidebar {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
  }

  .admin-main-inner {
    padding: 0.85rem 0.85rem 1.5rem;
  }

  .page-header .breadcrumb { display: none; }

  .chat-shell {
    height: auto;
    min-height: calc(100dvh - var(--topbar-height) - 80px);
    border-radius: var(--radius-sm);
  }

  body.chat-active .chat-shell {
    min-height: calc(100dvh - var(--topbar-height) - 24px);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .chat-sidebar-mobile-hidden {
    display: none !important;
  }

  .chat-main-mobile-full {
    flex: 1 1 100%;
    max-width: 100%;
    min-height: calc(100dvh - var(--topbar-height) - 60px);
  }

  /* Dashboard: show mobile cards, hide tables */
  .dashboard-mobile-cards .table-responsive { display: none; }
  .dashboard-mobile-cards .mobile-card-list { display: block; }
}

@media (max-width: 575.98px) {
  .stat-card .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.35rem;
  }

  .stat-card .fw-bold.fs-4 { font-size: 1.35rem !important; }

  .table-hide-xs { display: none; }

  .card-header {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }

  h5.fw-bold { font-size: 1rem; }

  .chat-shell .col-md-3,
  .chat-shell .col-md-4,
  .chat-shell .col-md-8,
  .chat-shell .col-md-9,
  .chat-shell .col-lg-3,
  .chat-shell .col-lg-9 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Full-width action buttons on mobile forms */
  .card-body .btn-group,
  .card-body .d-flex.gap-2 {
    flex-wrap: wrap;
  }
}

@media (min-width: 992px) {
  #sidebarToggle { display: none !important; }

  .sidebar-backdrop { display: none !important; }

  .mobile-tabbar { display: none !important; }

  body.admin-app.has-tabbar {
    padding-bottom: 0;
  }
}

/* Desktop overflow fixes */
@media (min-width: 992px) {
  .admin-main-inner {
    width: 100%;
  }

  .row.g-3 > [class*="col-"] {
    min-width: 0;
  }

  .table-responsive {
    max-width: 100%;
  }
}

.brand-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.admin-card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  animation: adminFadeIn 0.35s ease;
}

@keyframes adminFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.faq-admin-preview .accordion-button {
  font-weight: 600;
  font-size: 0.95rem;
}

.faq-admin-preview .accordion-body {
  color: var(--text-muted);
  line-height: 1.6;
}

.perm-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.perm-check:hover {
  background: rgba(255, 107, 0, 0.06);
}
.perm-check input {
  accent-color: var(--brand);
  flex-shrink: 0;
}
.perm-group {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafafa;
}

.chat-msg-bubble:hover .chat-msg-actions {
  opacity: 1;
}
.chat-msg-actions {
  position: absolute;
  top: 4px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.chat-msg-btn {
  color: inherit;
  opacity: 0.85;
  font-size: 0.7rem;
  line-height: 1;
  text-decoration: none;
  background: rgba(0,0,0,0.12);
  border: none;
  border-radius: 4px;
  padding: 2px 5px;
}
.chat-msg-btn:hover {
  opacity: 1;
}
