/* ============================================================
   BEEP AI HUB - Beep Tecnologia
   Paleta: Azul (#2563EB) + Laranja (#F97316) + Neutros azulados
   ============================================================ */

:root {
  /* ── PRIMÁRIA: Azul profundo com gradiente ── */
  --blue-900: #0A1628;
  --blue-800: #0F2044;
  --blue-700: #1A3A6E;
  --blue-600: #1E4FC2;
  --blue-500: #2563EB;
  --blue-400: #3B82F6;
  --blue-100: #DBEAFE;
  --blue-50:  #EFF6FF;

  /* ── ACENTO: Laranja vibrante ── */
  --orange-600: #C2410C;
  --orange-500: #EA580C;
  --orange-400: #F97316;
  --orange-300: #FB923C;
  --orange-100: #FFEDD5;
  --orange-50:  #FFF7ED;

  /* ── NEUTROS modernos (levemente azulados) ── */
  --gray-950: #0B0F1A;
  --gray-900: #0F172A;
  --gray-800: #1E293B;
  --gray-700: #334155;
  --gray-600: #475569;
  --gray-500: #64748B;
  --gray-400: #94A3B8;
  --gray-300: #CBD5E1;
  --gray-200: #E2E8F0;
  --gray-100: #F1F5F9;
  --gray-50:  #F8FAFC;

  /* ── SEMÂNTICAS ── */
  --white:       #FFFFFF;
  --red-700:     #B91C1C;
  --red-600:     #DC2626;
  --red-100:     #FEE2E2;
  --red-50:      #FFF5F5;
  --green-700:   #15803D;
  --green-600:   #16A34A;
  --green-100:   #DCFCE7;
  --green-50:    #F0FDF4;
  --yellow-600:  #CA8A04;
  --yellow-100:  #FEF9C3;
  --purple-600:  #7C3AED;
  --purple-100:  #EDE9FE;

  /* ── SUPERFÍCIES ── */
  --surface-1: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #F1F5F9;
  --border:    #E2E8F0;
  --border-strong: #CBD5E1;

  /* ── SIDEBAR com gradiente escuro ── */
  --sidebar-bg:        #0F1E3D;
  --sidebar-bg-hover:  rgba(255,255,255,0.06);
  --sidebar-bg-active: rgba(249,115,22,0.12);
  --sidebar-text:      rgba(255,255,255,0.65);
  --sidebar-text-active: #FB923C;
  --sidebar-border:    rgba(255,255,255,0.08);
  --sidebar-accent:    #F97316;

  /* ── LAYOUT ── */
  --sidebar-width:   260px;
  --header-height:   64px;
  --border-radius:   10px;
  --border-radius-lg: 14px;
  --border-radius-sm: 6px;

  /* ── SOMBRAS modernas ── */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 4px rgba(15,32,68,0.08), 0 1px 2px rgba(15,32,68,0.04);
  --shadow-md: 0 4px 16px rgba(15,32,68,0.12), 0 2px 6px rgba(15,32,68,0.06);
  --shadow-lg: 0 12px 40px rgba(15,32,68,0.18), 0 4px 12px rgba(15,32,68,0.08);
  --shadow-orange: 0 4px 20px rgba(249,115,22,0.30);
  --shadow-blue:   0 4px 20px rgba(37,99,235,0.25);

  /* ── TRANSIÇÕES ── */
  --transition: 0.18s ease;
  --transition-slow: 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--surface-2);
  color: var(--gray-800);
  line-height: 1.6;
}

/* ── LAYOUT PRINCIPAL ── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #0A1628 0%, #0F2044 100%);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition);
  z-index: 100;
}

.sidebar-logo {
  padding: 16px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo-img {
  max-width: 100%;
  max-height: 44px;
  object-fit: contain;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-label {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  user-select: none;
}

.nav-item:hover {
  background: var(--sidebar-bg-hover);
  color: white;
}

.nav-item.active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--sidebar-accent);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}
.nav-item.active svg { opacity: 1; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  user-select: none;
}
.nav-group-toggle:hover { background: var(--sidebar-bg-hover); color: white; }
.nav-group-toggle svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8; }

.nav-group-arrow {
  margin-left: auto;
  width: 14px;
  height: 14px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-group.open .nav-group-arrow { transform: rotate(90deg); }

.nav-group-children {
  max-height: 0;
  overflow: hidden;
  background: rgba(0,0,0,0.15);
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  opacity: 0;
}
.nav-group.open .nav-group-children { max-height: 500px; opacity: 1; }

.nav-child {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px 8px 44px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.nav-child:hover { background: var(--sidebar-bg-hover); color: white; }
.nav-child.active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--sidebar-accent);
}
.nav-child svg { width: 15px; height: 15px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover { background: var(--sidebar-bg-hover); }

.sidebar-avatar {
  width: 34px;
  height: 34px;
  background: var(--orange-400);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; flex: 1; }
.sidebar-user-name {
  color: white;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  color: rgba(255,255,255,0.45);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
  flex-shrink: 0;
}
.sidebar-logout-btn:hover { color: var(--orange-400); }
.sidebar-logout-btn svg { width: 16px; height: 16px; display: block; }

/* ── CONTEÚDO PRINCIPAL ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── HEADER ── */
.topbar {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--gray-500);
}
.topbar-breadcrumb .current {
  color: var(--gray-800);
  font-weight: 600;
}
.topbar-breadcrumb .sep { color: var(--gray-300); }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--blue-50);
  color: var(--blue-600);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ── PAGE CONTENT ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header-left h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 2px;
}
.page-header-left p {
  font-size: 13.5px;
  color: var(--gray-500);
}

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

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

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-3);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* ── STATS CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue { background: var(--blue-100); color: var(--blue-600); }
.stat-icon.orange { background: var(--orange-100); color: var(--orange-600); }
.stat-icon.green { background: var(--green-100); color: var(--green-600); }
.stat-icon.gray { background: var(--gray-100); color: var(--gray-600); }

.stat-info { overflow: hidden; }
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}
.stat-label {
  font-size: 12.5px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ── BOTÕES ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--border-radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #2563EB, #1A3A6E);
  color: white;
  border: none;
  box-shadow: var(--shadow-blue);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }

.btn-orange {
  background: linear-gradient(135deg, #F97316, #EA580C);
  color: white;
  border: none;
  box-shadow: var(--shadow-orange);
}
.btn-orange:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-outline:hover:not(:disabled) { background: var(--gray-100); border-color: var(--gray-400); }

.btn-danger {
  background: var(--red-600);
  color: white;
  border-color: var(--red-600);
}
.btn-danger:hover:not(:disabled) { background: var(--red-700); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-sm svg { width: 14px; height: 14px; }

.btn-icon {
  padding: 7px;
  background: transparent;
  border-color: var(--gray-200);
  color: var(--gray-600);
}
.btn-icon:hover:not(:disabled) { background: var(--gray-100); color: var(--gray-800); }
.btn-full { width: 100%; }

/* ── FORMULÁRIOS ── */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  font-size: 13.5px;
  color: var(--gray-800);
  background: white;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.form-control.error { border-color: var(--red-600); }

select.form-control { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-text {
  display: block;
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--blue-500); }
.form-check span { font-size: 13.5px; color: var(--gray-700); }

/* ── TABELA ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--surface-3);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-3); }

tbody td {
  padding: 13px 16px;
  color: var(--gray-700);
  vertical-align: middle;
}

.td-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-green { background: var(--green-100); color: var(--green-700); }
.badge-red { background: var(--red-100); color: var(--red-600); }
.badge-blue { background: var(--blue-100); color: var(--blue-600); }
.badge-orange { background: var(--orange-100); color: var(--orange-600); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-yellow { background: var(--yellow-100); color: var(--yellow-600); }

/* ── ALERTAS ── */
.alert {
  padding: 11px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-error { background: var(--red-100); color: var(--red-600); border: 1px solid #fca5a5; }
.alert-success { background: var(--green-100); color: var(--green-600); border: 1px solid #86efac; }
.alert-info { background: var(--blue-50); color: var(--blue-600); border: 1px solid var(--blue-100); }
.alert-warning { background: var(--yellow-100); color: var(--yellow-600); border: 1px solid #fde68a; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--transition);
}
.modal-overlay.show { opacity: 1; }

.modal {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-lg { max-width: 720px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 17px; font-weight: 700; color: var(--gray-900); }
.modal-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--gray-400);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-close svg { width: 20px; height: 20px; display: block; }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-3);
  border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* ── SEARCH / FILTROS ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-input-wrapper svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--gray-400);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 9px 13px 9px 36px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition);
  background: white;
}
.search-input:focus { border-color: var(--blue-500); }

/* ── AVATAR INICIAIS ── */
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue-600);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; color: var(--gray-800); font-size: 13.5px; }
.user-email { font-size: 12px; color: var(--gray-500); }

/* ── PERMISSÕES - TOGGLE ── */
.perm-toggle {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--gray-300);
  border: none;
  cursor: pointer;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.perm-toggle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  top: 3px;
  left: 3px;
  transition: left var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.perm-toggle.on { background: var(--blue-500); }
.perm-toggle.on::after { left: 21px; }
.perm-toggle:disabled { opacity: 0.5; cursor: not-allowed; }

.perm-cell { text-align: center; }
.perm-label { font-size: 11px; color: var(--gray-400); display: block; margin-bottom: 4px; }

/* ── DIVIDER ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; display: block; opacity: 0.4; }
.empty-state h3 { font-size: 16px; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; }

/* ── LOADING SPINNER ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-blue {
  border-color: var(--blue-100);
  border-top-color: var(--blue-500);
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

/* ── TOOLTIP ── */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: white;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 999;
  pointer-events: none;
}

/* ── NOTIFICAÇÃO TOAST ── */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--border-radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  animation: slideIn 0.3s ease;
}
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast-success { background: #16a34a; color: white; }
.toast-error { background: var(--red-600); color: white; }
.toast-info { background: var(--blue-500); color: white; }
.toast-warning { background: #d97706; color: white; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── CONFIRM DIALOG ── */
.confirm-dialog .modal { max-width: 400px; }
.confirm-dialog .modal-body { text-align: center; padding: 32px 24px 20px; }
.confirm-dialog .modal-body svg { width: 48px; height: 48px; color: var(--red-600); margin: 0 auto 16px; display: block; }
.confirm-dialog .modal-body h3 { font-size: 18px; font-weight: 700; color: var(--gray-900); margin-bottom: 8px; }
.confirm-dialog .modal-body p { font-size: 14px; color: var(--gray-500); }

/* ============================================================
   DOCUMENTAÇÃO
   ============================================================ */
.doc-search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--white); border: 1.5px solid var(--gray-200); border-radius: 10px;
  padding: 10px 16px; margin-bottom: 24px; transition: border-color var(--transition);
}
.doc-search-bar:focus-within { border-color: var(--blue-400); }
.doc-search-bar input {
  flex: 1; border: none; outline: none; font-size: 14px; background: transparent; color: var(--gray-800);
}

.doc-layout {
  display: grid; grid-template-columns: 240px 1fr; gap: 28px; align-items: start;
}
.doc-sidebar {
  position: sticky; top: 16px;
  background: var(--white); border-radius: 12px; border: 1px solid var(--gray-200);
  padding: 16px; max-height: calc(100vh - 100px); overflow-y: auto;
}
.doc-sidebar-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px;
  color: var(--gray-400); margin-bottom: 12px; padding: 0 8px;
}
.doc-toc { display: flex; flex-direction: column; gap: 2px; }
.doc-toc-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; font-size: 13px; color: var(--gray-600);
  text-decoration: none; transition: all var(--transition); cursor: pointer;
}
.doc-toc-item:hover { background: var(--gray-100); color: var(--gray-800); }
.doc-toc-item.active { background: var(--blue-50); color: var(--blue-600); font-weight: 600; }
.doc-toc-item span { font-size: 14px; flex-shrink: 0; }

.doc-main { min-width: 0; }

.doc-section {
  background: var(--white); border-radius: 12px; border: 1px solid var(--gray-200);
  margin-bottom: 16px; overflow: hidden; transition: box-shadow var(--transition);
}
.doc-section:hover { box-shadow: var(--shadow-sm); }
.doc-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; cursor: pointer; user-select: none; transition: background var(--transition);
}
.doc-section-header:hover { background: var(--gray-50); }
.doc-section-title { display: flex; align-items: center; gap: 12px; }
.doc-section-title h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--gray-800); }
.doc-section-icon { font-size: 20px; }
.doc-chevron { transition: transform 0.25s ease; flex-shrink: 0; color: var(--gray-400); }
.doc-section.collapsed .doc-chevron { transform: rotate(-90deg); }
.doc-section-body {
  padding: 0 22px 22px 22px; font-size: 14px; line-height: 1.7; color: var(--gray-700);
  border-top: 1px solid var(--gray-100);
}
.doc-section.collapsed .doc-section-body { display: none; }
.doc-section-body p { margin: 12px 0; }
.doc-section-body h4 {
  font-size: 14px; font-weight: 700; color: var(--gray-800); margin: 22px 0 10px 0;
  padding-bottom: 6px; border-bottom: 1px solid var(--gray-100);
}
.doc-section-body ul { margin: 8px 0; padding-left: 22px; }
.doc-section-body li { margin-bottom: 6px; }
.doc-section-body code {
  background: var(--gray-100); padding: 2px 6px; border-radius: 4px; font-size: 12.5px;
  color: var(--blue-600); font-family: 'SFMono-Regular', Consolas, monospace;
}

.doc-table {
  width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px;
}
.doc-table th {
  background: var(--gray-50); padding: 10px 14px; text-align: left; font-weight: 600;
  color: var(--gray-600); font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--gray-200);
}
.doc-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700);
}
.doc-table tr:hover td { background: var(--gray-50); }

.doc-api-table td:first-child { white-space: nowrap; }
.doc-api-table code { font-size: 12px; }
.doc-method {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px;
  font-weight: 700; letter-spacing: .5px; font-family: 'SFMono-Regular', Consolas, monospace;
}
.doc-method.get { background: #DCFCE7; color: #166534; }
.doc-method.post { background: #DBEAFE; color: #1E40AF; }
.doc-method.put { background: #FEF9C3; color: #854D0E; }
.doc-method.patch { background: #F3E8FF; color: #6B21A8; }
.doc-method.del { background: #FEE2E2; color: #991B1B; }

.doc-callout {
  padding: 14px 18px; border-radius: 10px; margin: 14px 0; font-size: 13px; line-height: 1.6;
  border-left: 4px solid;
}
.doc-callout-info { background: var(--blue-50); border-color: var(--blue-400); color: #1E3A5F; }
.doc-callout-warning { background: var(--yellow-100); border-color: var(--yellow-600); color: #713F12; }
.doc-callout-danger { background: var(--red-50); border-color: var(--red-600); color: #7F1D1D; }

.doc-steps { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.doc-step {
  display: flex; align-items: flex-start; gap: 14px; padding: 12px 16px;
  background: var(--gray-50); border-radius: 10px;
}
.doc-step-num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--blue-500); color: white;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.doc-step > div:last-child { font-size: 13px; padding-top: 4px; }

.doc-features-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px;
  margin: 16px 0;
}
.doc-feature-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px;
  background: var(--gray-50); border-radius: 12px; border: 1px solid var(--gray-100);
}
.doc-feature-card strong { font-size: 14px; color: var(--gray-800); }
.doc-feature-card span { font-size: 12px; color: var(--gray-500); line-height: 1.5; }
.doc-feature-icon {
  width: 40px; height: 40px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; margin-bottom: 4px;
}

.doc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.doc-tag {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  background: var(--gray-100); color: var(--gray-600);
}

.doc-faq { display: flex; flex-direction: column; gap: 8px; }
.doc-faq-item {
  border: 1px solid var(--gray-200); border-radius: 10px; overflow: hidden;
}
.doc-faq-q {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; cursor: pointer; transition: background var(--transition);
}
.doc-faq-q:hover { background: var(--gray-50); }
.doc-faq-q strong { font-size: 13px; color: var(--gray-800); }
.doc-faq-a {
  display: none; padding: 0 18px 14px 18px; font-size: 13px; color: var(--gray-600); line-height: 1.6;
  border-top: 1px solid var(--gray-100);
}
.doc-faq-item.open .doc-faq-a { display: block; padding-top: 14px; }
.doc-faq-item.open .doc-chevron { transform: rotate(180deg); }

/* ── GRID UTILITIES ── */
.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-3-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.dash-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.fin-stats-4 {
  grid-template-columns: repeat(4, 1fr);
}
.fin-stats-3 {
  grid-template-columns: repeat(3, 1fr);
}
.fin-recent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.filter-select {
  width: auto;
  min-width: 0;
}
.prompts-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 14px;
}
.integrations-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.account-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}
.fin-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  background: none;
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.fin-tab-btn:hover {
  color: var(--gray-700);
}
.fin-tab-btn.active {
  color: var(--orange-500, #F97316);
  border-bottom-color: var(--orange-500, #F97316);
  font-weight: 600;
}

/* ── MOBILE MENU BUTTON ── */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--gray-600);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition);
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--gray-100); color: var(--gray-800); }
.mobile-menu-btn svg { width: 22px; height: 22px; display: block; }

/* ── SIDEBAR OVERLAY ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition-slow);
}
.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* ── MOBILE TABLE CARD VIEW ── */
.mobile-card-list { display: none; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 270px;
    transition: left var(--transition-slow);
    box-shadow: none;
  }
  .sidebar.open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }

  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-badge span { display: none; }
  .topbar-badge { padding: 6px 8px; }

  .page-content { padding: 16px; overflow-x: hidden; }
  .page-header { flex-direction: column; gap: 12px; }
  .page-header-left h2 { font-size: 18px; }
  .page-header .btn,
  .page-header > button,
  .page-header > div > button { width: 100%; }

  .form-row { grid-template-columns: 1fr; }
  .grid-2-col { grid-template-columns: 1fr; }
  .grid-3-col { grid-template-columns: 1fr; }
  .dash-cards-grid { grid-template-columns: 1fr; }
  .fin-stats-4 { grid-template-columns: 1fr 1fr; }
  .fin-stats-3 { grid-template-columns: 1fr; }
  .fin-recent-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-select { width: 100% !important; }
  .card-header .filter-bar { gap: 8px; }

  .card-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .card-header h3 { font-size: 14px; }
  .card-body { padding: 16px; }

  .stat-card { padding: 14px; gap: 12px; }
  .stat-value { font-size: 20px; }
  .stat-icon { width: 40px; height: 40px; }
  .stat-icon svg { width: 20px; height: 20px; }

  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrapper table { min-width: 500px; }

  .modal { margin: 10px; max-height: 95vh; }
  .modal-overlay { padding: 10px; }
  .modal-header { padding: 16px 18px; }
  .modal-body { padding: 18px; }
  .modal-footer { padding: 14px 18px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 100px; }

  .doc-layout { grid-template-columns: 1fr; }
  .doc-sidebar { position: static; max-height: none; }

  .td-actions { gap: 4px; }
  .btn-sm { padding: 5px 8px; font-size: 11.5px; }

  #toastContainer { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: auto; max-width: none; }

  .prompts-card-grid { grid-template-columns: 1fr; }
  .integrations-card-grid { grid-template-columns: 1fr; }
  .account-layout { grid-template-columns: 1fr; }
  .fin-tab-btn { padding: 8px 12px; font-size: 13px; }
  .doc-features-grid { grid-template-columns: 1fr; }
  .doc-search-bar { padding: 8px 12px; }
}

@media (max-width: 480px) {
  .stats-grid,
  .fin-stats-4,
  .fin-stats-3 { grid-template-columns: 1fr; }
  .page-content { padding: 12px; }
  .topbar-breadcrumb { font-size: 12px; }
  tbody td { padding: 10px 10px; font-size: 12.5px; }
  thead th { padding: 10px 10px; font-size: 11px; }
  .stat-value { font-size: 18px; }
  .stat-card { padding: 12px; gap: 10px; }
  .card-body { padding: 12px; }
  .card-header { padding: 10px 12px; }
}

/* ═══════════════════════════════════════════════════════════ */
/* FINANCIAL REPORTS — Aging, Cashflow, DRE, Scheduler         */
/* ═══════════════════════════════════════════════════════════ */

.fin-report-tabs {
  display: flex; gap: 2px; padding: 4px;
  background: var(--bg, #f3f4f6); border-radius: 10px;
}
.fin-tab {
  padding: 7px 14px; font-size: .82rem; font-weight: 600;
  border: none; border-radius: 7px; background: transparent;
  color: var(--text-muted, #6b7280); cursor: pointer;
  transition: all .18s;
}
.fin-tab:hover { color: var(--text-primary, #111827); }
.fin-tab.active {
  background: var(--white, #fff); color: var(--text-primary, #111827);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.fin-report-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.fin-report-total { font-size: .9rem; color: var(--text-muted); }
.fin-report-total strong { color: var(--text-primary); font-size: 1.1rem; margin-left: 4px; }

.segmented {
  display: inline-flex; gap: 0;
  background: var(--bg); border-radius: 8px; padding: 3px;
}
.segmented button {
  border: none; background: transparent;
  padding: 6px 14px; font-size: .8rem; font-weight: 600;
  color: var(--text-muted); border-radius: 6px; cursor: pointer;
  transition: all .15s;
}
.segmented button.active { background: var(--white); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,.06); }

/* ─── Aging ─── */
.fin-aging-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 8px;
}
.fin-aging-card {
  background: var(--white); border: 1px solid var(--border);
  border-top: 3px solid var(--color, #888);
  border-radius: 12px; padding: 16px;
  transition: transform .18s, box-shadow .18s;
}
.fin-aging-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.06); }
.fin-aging-label {
  font-size: .72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.fin-aging-value {
  font-size: 1.4rem; font-weight: 700; margin: 6px 0 2px;
  color: var(--text-primary);
}
.fin-aging-count { font-size: .78rem; color: var(--text-muted); margin-bottom: 10px; }
.fin-aging-bar {
  height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden;
}
.fin-aging-bar-fill { height: 100%; transition: width .4s ease; }
.fin-aging-pct { font-size: .7rem; color: var(--text-muted); margin-top: 6px; }

/* ─── Cashflow Chart ─── */
.fin-report-totals-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  flex: 1; max-width: 800px;
}
.fin-total-card {
  background: var(--white); border: 1px solid var(--border);
  border-left: 3px solid var(--c, #888);
  border-radius: 10px; padding: 10px 14px;
}
.fin-total-label {
  font-size: .68rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
}
.fin-total-value { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin-top: 2px; }

.fin-legend {
  display: flex; gap: 14px; font-size: .78rem; color: var(--text-muted);
  align-items: center;
}
.fin-legend .swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 4px; vertical-align: -1px;
}

.fin-cashflow-chart {
  display: flex; gap: 4px; padding: 8px 4px 16px;
  overflow-x: auto; min-height: 240px;
  align-items: flex-end;
}
.fin-cashflow-day {
  flex: 1 0 46px; display: flex; flex-direction: column;
  align-items: center; gap: 4px;
}
.fin-cashflow-bars {
  height: 180px; width: 100%;
  display: flex; flex-direction: column-reverse;
  justify-content: flex-end; align-items: stretch;
  gap: 2px;
}
.fin-bar-inflow    { background: #10B981; border-radius: 3px 3px 0 0; min-height: 2px; }
.fin-bar-projected { background: #3B82F6; opacity: .75; border-radius: 3px 3px 0 0; min-height: 2px; }
.fin-bar-outflow   { background: #EF4444; border-radius: 0 0 3px 3px; min-height: 2px; }

.fin-cashflow-label {
  font-size: .64rem; color: var(--text-muted); font-weight: 600;
  white-space: nowrap;
}
.fin-cashflow-running {
  font-size: .62rem; color: var(--text-primary); font-weight: 700;
  white-space: nowrap;
}

/* ─── DRE ─── */
.fin-dre-bar-cell {
  display: flex; flex-direction: column; gap: 2px;
  height: 20px; justify-content: center;
}
.fin-dre-bar { height: 6px; border-radius: 3px; }

/* ─── Scheduler ─── */
.fin-scheduler-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.fin-scheduler-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
}
.fin-scheduler-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 10px;
}
.fin-scheduler-head h4 { margin: 0; font-size: .95rem; font-weight: 700; color: var(--text-primary); }
.fin-scheduler-head .subtitle { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.fin-scheduler-desc { font-size: .82rem; color: var(--text-muted); margin: 0 0 10px; line-height: 1.4; }
.fin-last-run {
  font-size: .75rem; padding: 4px 8px; border-radius: 6px;
  display: inline-block;
}
.fin-last-run.idle  { background: var(--bg); color: var(--text-muted); }
.fin-last-run.ok    { background: rgba(16,185,129,.1); color: #047857; }
.fin-last-run.error { background: rgba(239,68,68,.1); color: #b91c1c; }
.fin-scheduler-details { margin-top: 10px; }
.fin-scheduler-details summary { cursor: pointer; font-size: .75rem; color: var(--text-muted); }
.fin-scheduler-details pre {
  margin-top: 8px; padding: 10px; background: var(--bg);
  border-radius: 6px; font-size: .72rem; overflow-x: auto;
  max-height: 260px; color: var(--text-primary);
}

/* ─── Statement modal ─── */
.fin-statement-modal {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
}
.fin-statement-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
}
.fin-statement-box {
  position: relative; z-index: 1;
  width: min(1000px, 94vw); max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--white); border-radius: 14px;
  box-shadow: 0 24px 64px -12px rgba(0,0,0,.45);
  overflow: hidden;
}
.fin-statement-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.fin-statement-head h3 { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.fin-statement-head .subtitle { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.fin-statement-body { flex: 1; overflow-y: auto; padding: 0; }
.fin-statement-body table { width: 100%; }
