/* =============================================================
   ABInfo — Custom styles (Fluent design supplement)
   TailwindCSS handles the bulk; this file covers specifics.
   ============================================================= */

/* ── Fonts & Theme Root ─────────────────────────────────────── */
body {
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  background: #f7f9fb;
}
h1, h2, .font-headline {
  font-family: Manrope, "Segoe UI", Inter, system-ui, sans-serif;
}

/* Light / Dark theme overrides for Tailwind utility classes and custom components */
body[data-theme="dark"] {
  background-color: #020617;
  color: #E5E7EB;
}

body[data-theme="dark"] .bg-ms-bg {
  background-color: #020617 !important;
}
body[data-theme="dark"] .bg-ms-surface {
  background-color: #020617 !important;
}
body[data-theme="dark"] .border-ms-border {
  border-color: #1F2937 !important;
}
body[data-theme="dark"] .text-ms-text {
  color: #F9FAFB !important;
}
body[data-theme="dark"] .text-ms-muted {
  color: #9CA3AF !important;
}
body[data-theme="dark"] .bg-ms-neutral {
  background-color: #111827 !important;
}
body[data-theme="dark"] .bg-ms-blue-light {
  background-color: #1D4ED8 !important;
}

/* Dark-mode specific hover for buttons */
body[data-theme="dark"] button:hover {
  background-color: #1E3A8A !important; /* deeper blue hover for all buttons */
  color: #E5E7EB !important;
}

/* Sidebar nav active state in dark mode */
body[data-theme="dark"] .nav-item.active {
  background-color: #1D4ED8;
  color: #E5E7EB;
}
body[data-theme="dark"] .nav-item.active svg {
  color: #E5E7EB;
}

/* ── Sidebar nav active state ───────────────────────────────── */
.nav-item.active {
  background: #ffffff;
  color: #24389c;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(36, 56, 156, 0.12);
}
.nav-item.active svg {
  color: #24389c;
}
.nav-item {
  border-radius: 10px;
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.nav-item:hover {
  transform: translateX(3px);
  background: rgba(255, 255, 255, 0.7);
}
.nav-group.open > .nav-group-toggle {
  background-color: #ffffff;
  color: #24389c;
}
.nav-group .members-chevron {
  transition: transform 0.2s ease;
}
.nav-group.open .members-chevron {
  transform: rotate(180deg);
}
.nav-group-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.24s ease;
}
.nav-group.open .nav-group-children {
  max-height: 120px;
}
.nav-subitem {
  font-size: 13px;
}

/* ── Fluent focus ring ───────────────────────────────────────── */
*:focus-visible {
  outline: 2px solid #0078D4;
  outline-offset: 2px;
}

/* ── Fluent input ────────────────────────────────────────────── */
.fl-input {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #EDEBE9;
  border-radius: 6px;
  background: #FAF9F8;
  color: #242424;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fl-input:focus {
  outline: none;
  border-color: #0078D4;
  box-shadow: 0 0 0 2px rgba(0,120,212,0.2);
  background: #fff;
}
.fl-input::placeholder {
  color: #A19F9D;
}
body[data-theme="dark"] .fl-input {
  background: #111827;
  border-color: #1F2937;
  color: #E5E7EB;
}
body[data-theme="dark"] .fl-input:focus {
  background: #020617;
  border-color: #3B82F6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.45);
}
body[data-theme="dark"] .fl-input::placeholder {
  color: #6B7280;
}

/* ── Fluent select ───────────────────────────────────────────── */
.fl-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23605E5C' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1rem;
  padding-right: 2rem;
}

/* ── Fluent label ────────────────────────────────────────────── */
.fl-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #3B3A39;
  margin-bottom: 0.3rem;
}

/* ── Card ────────────────────────────────────────────────────── */
.fl-card {
  background: #FFFFFF;
  border: 1px solid rgba(117, 118, 132, 0.16);
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
body[data-theme="dark"] .fl-card {
  background: #020617;
  border-color: #1F2937;
  box-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

/* ── Stat Card ───────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid #EDEBE9;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
body[data-theme="dark"] .stat-card {
  background: #020617;
  border-color: #1F2937;
  box-shadow: 0 2px 6px rgba(0,0,0,0.8);
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #0078D4;
  line-height: 1.1;
}
.stat-card .stat-label {
  font-size: 0.8rem;
  color: #605E5C;
  margin-top: 0.25rem;
}

/* ── Table ───────────────────────────────────────────────────── */
.fl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.fl-table thead th {
  padding: 0.65rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  color: #605E5C;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid #EDEBE9;
  white-space: nowrap;
  background: #FAF9F8;
}
body[data-theme="dark"] .fl-table thead th {
  background: #020617;
  color: #9CA3AF;
  border-bottom-color: #1F2937;
}
.fl-table tbody tr {
  border-bottom: 1px solid #F3F2F1;
  transition: background-color 0.1s;
}
.fl-table tbody tr:hover {
  background-color: #F3F2F1;
}
body[data-theme="dark"] .fl-table tbody tr {
  border-bottom-color: #111827;
}
body[data-theme="dark"] .fl-table tbody tr:hover {
  background-color: #020617;
}
.fl-table tbody td {
  padding: 0.75rem 1rem;
  color: #242424;
  vertical-align: middle;
}
body[data-theme="dark"] .fl-table tbody td {
  color: #E5E7EB;
}
.fl-table tbody tr:last-child {
  border-bottom: none;
}

/* Processes table (Device Details ▸ Processes tab) */
.processes-table thead {
  background-color: #FAF9F8;
}
body[data-theme="dark"] .processes-table thead {
  background-color: #020617;
}
body[data-theme="dark"] .processes-table tbody tr[data-detail-for] {
  background-color: #020617;
}
body[data-theme="dark"] .proc-detail-wrapper {
  background-color: #020617;
  border-color: #1F2937;
}
body[data-theme="dark"] .proc-detail-table thead {
  background-color: #111827;
}
body[data-theme="dark"] .proc-detail-table th,
body[data-theme="dark"] .proc-detail-table td {
  color: #E5E7EB;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.fl-tab-bar {
  display: flex;
  border-bottom: 2px solid #EDEBE9;
  gap: 0;
}
.fl-tab {
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #605E5C;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.fl-tab:hover {
  color: #0078D4;
}
.fl-tab.active {
  color: #0078D4;
  border-bottom-color: #0078D4;
  font-weight: 600;
}
body[data-theme="dark"] .fl-tab-bar {
  border-bottom-color: #1F2937;
}
body[data-theme="dark"] .fl-tab {
  color: #9CA3AF;
}
body[data-theme="dark"] .fl-tab.active {
  color: #60A5FA;
  border-bottom-color: #60A5FA;
}

/* ── Badge ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
}
.badge-blue    { background: #C7E0F4; color: #0078D4; }
.badge-green   { background: #DFF6DD; color: #107C10; }
.badge-amber   { background: #FFF4CE; color: #B46900; }
.badge-red     { background: #FDE7E9; color: #A4262C; }
.badge-gray    { background: #F3F2F1; color: #605E5C; }
.badge-purple  { background: #EDE4F4; color: #5C2D91; }

/* ── Button ──────────────────────────────────────────────────── */
.fl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s;
  border: none;
  text-decoration: none;
}
.fl-btn-primary {
  background: #24389c;
  color: #fff;
}
.fl-btn-primary:hover { background: #3046b0; }
.fl-btn-secondary {
  background: #ffffff;
  color: #242424;
  border: 1px solid rgba(117, 118, 132, 0.2);
}
.fl-btn-secondary:hover { background: #f2f4f6; }
body[data-theme="dark"] .fl-btn-secondary {
  background: #111827;
  color: #E5E7EB;
  border-color: #1F2937;
}
body[data-theme="dark"] .fl-btn-secondary:hover {
  background: #1F2937;
}
.fl-btn-danger {
  background: #FDE7E9;
  color: #A4262C;
}
.fl-btn-danger:hover { background: #F1CBCD; }
.fl-btn-ghost {
  background: transparent;
  color: #605E5C;
}
.fl-btn-ghost:hover { background: #F3F2F1; color: #242424; }
body[data-theme="dark"] .fl-btn-ghost {
  color: #9CA3AF;
}
body[data-theme="dark"] .fl-btn-ghost:hover {
  background: #111827;
  color: #E5E7EB;
}
.fl-btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
}

/* Button loading state (inline spinner) */
.fl-btn.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.75;
}
.fl-btn.btn-loading::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border-radius: 9999px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #ffffff;
  animation: spin 0.6s linear infinite;
}

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #C7E0F4;
  border-top-color: #0078D4;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #fff;
  border: 1px solid #EDEBE9;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  min-width: 260px;
  max-width: 380px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  pointer-events: all;
  animation: slideIn 0.2s ease;
  font-size: 0.875rem;
}
body[data-theme="dark"] .toast {
  background: #020617;
  border-color: #1F2937;
  color: #E5E7EB;
}
.toast-success { border-left: 3px solid #107C10; }
.toast-error   { border-left: 3px solid #A4262C; }
.toast-info    { border-left: 3px solid #0078D4; }
.toast-warning { border-left: 3px solid #B46900; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: #A19F9D;
  text-align: center;
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3  { font-size: 1rem; font-weight: 600; color: #605E5C; }
.empty-state p   { font-size: 0.875rem; margin-top: 0.3rem; }
body[data-theme="dark"] .empty-state {
  color: #6B7280;
}
body[data-theme="dark"] .empty-state h3 {
  color: #E5E7EB;
}

/* ── Device type badge ───────────────────────────────────────── */
.device-laptop  { background:#EDE4F4; color:#5C2D91; }
.device-desktop { background:#C7E0F4; color:#0078D4; }
.device-server  { background:#FFF4CE; color:#B46900; }

/* ── Auth page: dark input/label helpers ─────────────────────── */
.fl-input-dark {
  background: #111827;
  border-color: #374151;
  color: #E5E7EB;
}
.fl-input-dark:focus {
  background: #1F2937;
  border-color: #3B82F6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}
.fl-input-dark::placeholder {
  color: #6B7280;
}
.fl-label-dark {
  color: #CBD5E1;
}

/* ── Auth page animations ─────────────────────────────────────── */
@keyframes authFadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-fade-up   { animation: authFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.auth-delay-1   { animation-delay: 0.08s; }
.auth-delay-2   { animation-delay: 0.16s; }
.auth-delay-3   { animation-delay: 0.24s; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C8C6C4; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #A19F9D; }

/* ── Info row (key/value detail) ─────────────────────────────── */
.info-row {
  display: flex;
  padding: 0.6rem 0;
  border-bottom: 1px solid #F3F2F1;
  font-size: 0.875rem;
}
.info-row:last-child { border-bottom: none; }
.info-row .info-key {
  width: 180px;
  flex-shrink: 0;
  color: #605E5C;
  font-weight: 500;
}
.info-row .info-val {
  color: #242424;
  flex: 1;
}
body[data-theme="dark"] .info-row {
  border-bottom-color: #111827;
}
body[data-theme="dark"] .info-row .info-key {
  color: #9CA3AF;
}
body[data-theme="dark"] .info-row .info-val {
  color: #E5E7EB;
}

/* ── Loading overlay ─────────────────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

/* ── Checkbox (Fluent style) ─────────────────────────────────── */
.fl-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #0078D4;
  cursor: pointer;
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.page-header h2 {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #242424;
}
body[data-theme="dark"] .page-header h2 {
  color: #F9FAFB;
}

/* ── Activity log ────────────────────────────────────────────── */
.activity-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid #F3F2F1;
  font-size: 0.875rem;
  align-items: flex-start;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0078D4;
  margin-top: 5px;
  flex-shrink: 0;
}

/* ── Executive shell styling ─────────────────────────────────── */
#sidebar {
  background: #f2f4f6 !important;
  border-right: 1px solid rgba(117, 118, 132, 0.2) !important;
}
#sidebar .border-b.border-ms-border,
#sidebar .border-t.border-ms-border,
#sidebar .border-ms-border {
  border-color: rgba(117, 118, 132, 0.2) !important;
}
#sidebar .nav-future {
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(117, 118, 132, 0.14);
}
#sidebar-user-avatar {
  background: #24389c !important;
}

header.bg-ms-surface {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(247, 249, 251, 0.84) !important;
  border-bottom: 1px solid rgba(117, 118, 132, 0.2) !important;
}
#page-title {
  font-weight: 800;
  letter-spacing: -0.01em;
}

#page-content {
  background: #f7f9fb !important;
}
body[data-theme="dark"] #page-content {
  background: #020617 !important;
}

.stat-card {
  border-radius: 12px;
  border-color: rgba(117, 118, 132, 0.16);
}

.fl-table thead th {
  background: rgba(230, 232, 234, 0.5);
  border-bottom-color: rgba(117, 118, 132, 0.24);
}
.fl-table tbody tr:hover {
  background-color: rgba(213, 227, 252, 0.2);
}

/* Dark mode version of the same design language */
body[data-theme="dark"] #sidebar {
  background: #020617 !important;
  border-right-color: #1f2937 !important;
}
body[data-theme="dark"] .nav-item.active {
  background: #1e3a8a;
  color: #eff1f3;
}
body[data-theme="dark"] .nav-item:hover {
  background: #111827;
}
body[data-theme="dark"] header.bg-ms-surface {
  background: rgba(2, 6, 23, 0.82) !important;
  border-bottom-color: #1f2937 !important;
}

/* ── Overview user profile header ───────────────────────────── */
.overview-user-header {
  background: linear-gradient(135deg, #C7E0F4 0%, #EDE4F4 100%);
}
body[data-theme="dark"] .overview-user-header {
  background: #1a2744;
}

/* ── Modal (overlay + dialog transitions) ───────────────────── */
.modal-overlay {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    visibility 0.22s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-overlay .modal-dialog {
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition:
    transform 0.26s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.22s ease;
}

.modal-overlay.is-open .modal-dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

body[data-theme="dark"] .modal-overlay {
  /* Darken scrim so the page reads behind; beats Tailwind bg-black/30 */
  background-color: rgba(0, 0, 0, 0.72) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Dark: default ms-surface equals page bg (#020617) — lift the dialog so it reads clearly */
body[data-theme="dark"] .modal-overlay .modal-dialog {
  background-color: #111827 !important;
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 24px 48px rgba(0, 0, 0, 0.55),
    0 8px 16px rgba(0, 0, 0, 0.35);
}

body[data-theme="dark"] .modal-overlay .modal-dialog .border-ms-border {
  border-color: rgba(51, 65, 85, 0.85) !important;
}

/* Event AI split panel inside modal */
.event-ai-shell {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  --event-ai-right-w: min(46vw, 560px);
}
.event-ai-left {
  flex: 1 1 0;
  min-width: 0;
}
.event-ai-splitter {
  display: none;
  flex: 0 0 6px;
  width: 6px;
  align-self: stretch;
  border-radius: 3px;
  cursor: col-resize;
  touch-action: none;
  background: linear-gradient(
    to right,
    transparent 0,
    transparent 1px,
    rgba(148, 163, 184, 0.45) 1px,
    rgba(148, 163, 184, 0.45) 5px,
    transparent 5px,
    transparent 100%
  );
}
.event-ai-splitter:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.65);
  outline-offset: 1px;
}
.event-ai-shell:has(.event-ai-right.is-open) .event-ai-splitter {
  display: block;
}
.event-ai-shell.event-ai-resizing .event-ai-right {
  transition: none;
}
.event-ai-right {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  opacity: 0;
  overflow: hidden;
  transition: flex-basis 0.28s ease, opacity 0.22s ease;
}
.event-ai-right.is-open {
  flex: 0 0 var(--event-ai-right-w);
  width: auto;
  min-width: 200px;
  max-width: min(85%, 900px);
  opacity: 1;
  overflow: auto;
}
.event-ai-result {
  height: 100%;
  min-height: 240px;
}
@media (max-width: 1024px) {
  .event-ai-shell {
    flex-direction: column;
  }
  .event-ai-splitter {
    display: none !important;
  }
  .event-ai-right,
  .event-ai-right.is-open {
    flex: 1 1 auto;
    width: 100% !important;
    min-width: 0;
    max-width: none;
  }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE / RESPONSIVE STYLES
   Desktop is the primary target; these kick in below 768 px.
   ═══════════════════════════════════════════════════════════ */

/* ── Sidebar hamburger toggle (hidden on desktop) ────────── */
.sidebar-toggle {
  display: none;
}

/* ── Mobile sidebar backdrop ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 25;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.is-open {
  display: block;
}
body[data-theme="dark"] .sidebar-overlay {
  background: rgba(0, 0, 0, 0.65);
}

@media (max-width: 767px) {
  /* Show hamburger on mobile */
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Off-canvas sidebar drawer ─────────────────────────── */
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;   /* top:0 left:0 bottom:0 right:auto */
    height: 100%;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  #sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  }

  /* ── Page content: tighter padding already in HTML (p-4) ── */

  /* ── Tables: horizontal scroll ─────────────────────────── */
  .fl-card:has(.fl-table) {
    overflow-x: auto !important;
    overflow-y: visible !important;
  }
  /* Fallback for browsers without :has() */
  .fl-table {
    min-width: 540px;
  }

  /* ── Tab bar: smaller touch targets ────────────────────── */
  .fl-tab {
    padding: 0.5rem 0.85rem;
    font-size: 0.8125rem;
  }

  /* ── Page header: tighter ───────────────────────────────── */
  .page-header {
    margin-bottom: 1rem;
  }
  .page-header h2 {
    font-size: 1.1rem;
  }

  /* ── Info row: stack label above value on mobile ────────── */
  .info-row {
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0;
  }
  .info-row .info-key {
    width: auto;
    font-size: 0.75rem;
  }

  /* ── Toast: full-width ───────────────────────────────────── */
  #toast-container {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
  }
  .toast {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  /* ── Stat card: smaller value text ──────────────────────── */
  .stat-card .stat-value {
    font-size: 1.6rem;
  }

  /* ── Buttons: comfortable tap targets ───────────────────── */
  .fl-btn {
    min-height: 36px;
  }
}

/* WhatsApp-like chat layout */
.wa-shell {
  display: flex;
  height: 100%;
  width: 100%;
}
.wa-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 320px;
  flex-shrink: 0;
}
.wa-contacts-list {
  overflow-y: auto;
  flex: 1;
  background: #fff;
}
.wa-contact-item {
  width: 100%;
  display: flex;
  gap: 0.75rem;
  text-align: left;
  border: none;
  border-bottom: 1px solid #F3F2F1;
  background: #fff;
  padding: 0.75rem;
}
.wa-contact-item:hover { background: #F9FAFB; }
.wa-contact-item.active { background: #E6F2FB; }
.wa-contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #C7E0F4;
  color: #0078D4;
  font-weight: 700;
  flex-shrink: 0;
}
.wa-contact-main { min-width: 0; flex: 1; }
.wa-contact-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.wa-contact-name { font-size: 0.875rem; font-weight: 600; color: #242424; }
.wa-contact-time { font-size: 0.7rem; color: #605E5C; white-space: nowrap; }
.wa-contact-preview {
  font-size: 0.78rem;
  color: #605E5C;
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6B7280;
  padding: 0.55rem 0.75rem 0.35rem;
  background: #F9FAFB;
  border-bottom: 1px solid #F3F2F1;
}
.wa-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  border: none;
}
.wa-section-chevron {
  width: 16px;
  height: 16px;
  transition: transform 0.22s ease;
}
.wa-section-chevron.collapsed {
  transform: rotate(-90deg);
}
.wa-section-group {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.28s ease, opacity 0.22s ease;
  opacity: 1;
}
.wa-section-group.collapsed {
  grid-template-rows: 0fr;
  opacity: 0.8;
}
.wa-section-group-inner {
  overflow: hidden;
}
.wa-section-empty {
  font-size: 12px;
  color: #6B7280;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #F3F2F1;
}
.wa-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #F8FAFC;
  flex: 1;
  transition: width 0.28s ease;
  min-height: 0;
}
.wa-chat #wa-chat-pane {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.wa-messages {
  flex: 1;
  min-height: 0;
  height: auto;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.wa-msg-row { display: flex; }
.wa-msg-row.out { justify-content: flex-end; }
.wa-msg-bubble {
  max-width: min(70%, 560px);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-size: 0.87rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  background: #fff;
  color: #242424;
}
.wa-msg-row.out .wa-msg-bubble { background: #DCF8C6; }
.wa-msg-meta {
  font-size: 0.68rem;
  margin-top: 0.25rem;
  color: #605E5C;
  text-align: right;
}
.wa-compose-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.wa-tool-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #4B5563;
}
.wa-tool-btn svg {
  width: 16px;
  height: 16px;
}
.wa-tool-btn:hover {
  background: transparent;
  color: #111827;
}
.wa-emoji-grid {
  max-height: 46vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
}
.wa-emoji-btn {
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  height: 30px;
}
.wa-emoji-btn:hover {
  background: #F3F4F6;
}
.wa-notes-panel {
  width: 0;
  flex-shrink: 0;
  overflow: hidden;
  background: #fff;
  transition: width 0.28s ease;
  height: 100%;
}
.wa-shell.wa-notes-open .wa-notes-panel {
  width: 320px;
}
.wa-notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border-bottom: 1px solid #EDEBE9;
  background: #fff;
}
.wa-notes-body {
  padding: 0.85rem;
  height: calc(100% - 56px);
  overflow-y: auto;
}

#page-content.member-page {
  padding: 0 !important;
  display: flex;
  min-height: 0;
}
#page-content.member-page > * {
  flex: 1;
  min-width: 0;
  min-height: 0;
}

/* ── Compact mode for non-dashboard pages ───────────────────── */
#page-content.compact-page .page-header {
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}
#page-content.compact-page .page-header h2 {
  font-size: 1rem;
  font-weight: 600;
}
#page-content.compact-page .fl-card {
  border-radius: 8px;
}
#page-content.compact-page .fl-card .fl-table {
  font-size: 0.8125rem;
}
#page-content.compact-page .fl-table thead th {
  padding: 0.45rem 0.65rem;
  font-size: 0.7rem;
}
#page-content.compact-page .fl-table tbody td {
  padding: 0.5rem 0.65rem;
}
#page-content.compact-page .fl-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  gap: 0.35rem;
}
#page-content.compact-page .fl-btn-sm {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}
#page-content.compact-page .fl-input {
  padding: 0.35rem 0.6rem;
  font-size: 0.8125rem;
}
#page-content.compact-page .fl-label {
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}
#page-content.compact-page .fl-tab {
  padding: 0.45rem 0.8rem;
  font-size: 0.8125rem;
}
#page-content.compact-page .info-row {
  padding: 0.45rem 0;
  font-size: 0.8125rem;
}
#page-content.compact-page .info-row .info-key {
  width: 150px;
  font-size: 0.75rem;
}
#page-content.compact-page .activity-item {
  gap: 0.5rem;
  padding: 0.45rem 0;
}
#page-content.compact-page .empty-state {
  padding: 2.25rem 1rem;
}
#page-content.compact-page .empty-state h3 {
  font-size: 0.92rem;
}
#page-content.compact-page .empty-state p {
  font-size: 0.8125rem;
}
body[data-theme="dark"] .wa-contacts-list,
body[data-theme="dark"] .wa-contact-item { background: #020617; }
body[data-theme="dark"] .wa-contact-item { border-bottom-color: #1F2937; }
body[data-theme="dark"] .wa-contact-item:hover { background: #111827; }
body[data-theme="dark"] .wa-contact-item.active { background: #1E3A8A; }
body[data-theme="dark"] .wa-contact-name { color: #F9FAFB; }
body[data-theme="dark"] .wa-contact-time,
body[data-theme="dark"] .wa-contact-preview { color: #9CA3AF; }
body[data-theme="dark"] .wa-section-label { background: #111827; border-bottom-color: #1F2937; color: #9CA3AF; }
body[data-theme="dark"] .wa-section-empty { border-bottom-color: #1F2937; color: #9CA3AF; }
body[data-theme="dark"] .wa-chat { background: #020617; }
body[data-theme="dark"] .wa-msg-bubble { background: #111827; color: #E5E7EB; }
body[data-theme="dark"] .wa-msg-row.out .wa-msg-bubble { background: #14532D; color: #E5E7EB; }
body[data-theme="dark"] .wa-tool-btn {
  background: transparent;
  color: #9CA3AF;
}
body[data-theme="dark"] .wa-tool-btn:hover {
  background: transparent;
  color: #E5E7EB;
}
body[data-theme="dark"] .wa-emoji-grid {
  border-color: #1F2937;
}
body[data-theme="dark"] .wa-emoji-btn:hover {
  background: #1F2937;
}
body[data-theme="dark"] .wa-notes-panel { background: #020617; border-left-color: #1F2937; }
body[data-theme="dark"] .wa-notes-head { background: #020617; border-bottom-color: #1F2937; }
@media (max-width: 900px) {
  .wa-shell { flex-direction: column; }
  .wa-sidebar { width: 100%; border-right: none; border-bottom: 1px solid #EDEBE9; max-height: 280px; }
  .wa-messages { height: 360px; }
  .wa-shell.wa-notes-open .wa-notes-panel { width: 100%; height: 180px; }
}

.wa-context-menu {
  position: fixed;
  z-index: 80;
  min-width: 180px;
  background: #fff;
  border: 1px solid #EDEBE9;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.16);
  padding: 0.3rem;
}
.wa-context-menu button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: #242424;
  font-size: 0.86rem;
  padding: 0.5rem 0.6rem;
  border-radius: 7px;
}
.wa-context-menu button svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.wa-context-menu button:hover {
  background: #F3F4F6;
}
.wa-context-menu button.danger {
  color: #A4262C;
}
body[data-theme="dark"] .wa-context-menu {
  background: #111827;
  border-color: #1F2937;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
body[data-theme="dark"] .wa-context-menu button {
  color: #E5E7EB;
}
body[data-theme="dark"] .wa-context-menu button:hover {
  background: #1F2937;
}
body[data-theme="dark"] .wa-context-menu button.danger {
  color: #FCA5A5;
}
