/* CSS Reset and Base Styles */
* {
  margin: 0;
  padding: 6px;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: #f8fafc;
  color: #1e293b;
  transition: all 0.3s ease;
  overflow-x: hidden;
}

body.dark {
  background: #0f172a;
  color: #f1f5f9;
}

/* Login Page Styles */
body.login {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  text-align: center;
}

body.dark .login-card {
  background: #1e293b;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.login-card .logo {
  width: 150px;
  margin-bottom: 32px;
}

.login-card h2 {
  color: #23c6bb;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 32px;
}

.login-card input {
  width: 100%;
  padding: 16px;
  margin-bottom: 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  font-size: 16px;
  transition: all 0.2s ease;
}

.login-card input:focus {
  outline: none;
  border-color: #23c6bb;
  background: white;
}

body.dark .login-card input {
  background: #334155;
  border-color: #475569;
  color: white;
}

body.dark .login-card input:focus {
  border-color: #23c6bb;
  background: #475569;
}

.login-card button {
  width: 100%;
  padding: 16px;
  background: #23c6bb;
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.login-card button:hover {
  background: #1db5a9;
  transform: translateY(-1px);
}

.error {
  color: #ef4444;
  margin-top: 16px;
  display: none;
  font-size: 14px;
}

/* Mobile Header */
.mobile-header {
  display: none;
  background: white;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  justify-content: space-between;
}

body.dark .mobile-header {
  background: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.mobile-header .logo {
  height: 37px;
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 130px);
  object-fit: contain;
  margin: 0;
}

/* Burger Menu (mobile sidebar open) */
.burger-menu {
  display: none;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  padding: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.burger-menu span {
  display: block;
  width: 18px;
  height: 2px;
  background: #64748b;
  border-radius: 2px;
}

body.dark .burger-menu {
  background: #1e293b;
  border-color: #334155;
}

body.dark .burger-menu span {
  background: #94a3b8;
}

/* Sidebar Navigation */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 200px;
  height: 100vh;
  background: white;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  z-index: 999;
  transition: transform 0.3s ease;
}

body.dark .sidebar {
  background: #1e293b;
  border-right-color: #334155;
}

.sidebar-header {
  padding: 20px 12px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  position: relative;
}

body.dark .sidebar-header {
  border-bottom-color: #334155;
}

.sidebar-header .logo {
  height: 37px;
  width: auto;
  margin-left: 0;
  padding-left: 0;
}

/* Display name + feedback block under the logo */
.sidebar-user-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  margin: 0;
}

.sidebar-display-name {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  padding: 0;
}

body.dark .sidebar-display-name {
  color: #f1f5f9;
}

.sidebar-feedback-link {
  font-size: 12px;
  font-weight: 600;
  color: #23c6bb;
  text-decoration: none;
  padding: 0;
}

.sidebar-feedback-link:hover {
  text-decoration: underline;
}

/* Hide user block when sidebar is collapsed/off-screen */
body.sidebar-is-collapsed #sidebarUserBlock,
.sidebar.collapsed #sidebarUserBlock {
  display: none;
}

/* FinMatch SDK embeds: isolated iframe container */
.finmatch-embed-frame {
  border: 0;
  width: 100%;
  display: block;
  background: transparent;
}

/* Tighten "Welcome to Admin Dashboard <name>" spacing (global * padding can add gaps) */
#welcomeName {
  padding: 0 !important;
  margin-left: 4px;
}

/* Sidebar Collapse Arrow - Top Right of Sidebar */
/* Collapse button removed from sidebar - now in main content area */
.sidebar-collapse-btn {
  display: none;
}

body.dark .sidebar-collapse-btn {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-collapse-btn:hover {
  background: #f8fafc;
  transform: scale(1.05);
}

body.dark .sidebar-collapse-btn:hover {
  background: #334155;
}

.sidebar-collapse-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transition: transform 0.3s ease;
}

.sidebar-collapse-icon::before {
  content: '<';
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  transition: color 0.2s ease;
  line-height: 1;
  display: block;
}

body.dark .sidebar-collapse-icon::before {
  color: #94a3b8;
}

.sidebar.collapsed .sidebar-collapse-icon {
  transform: rotate(180deg);
}

.sidebar-collapse-btn:hover .sidebar-collapse-icon::before {
  color: #1e293b;
}

body.dark .sidebar-collapse-btn:hover .sidebar-collapse-icon::before {
  color: #f1f5f9;
}

/* Theme Toggle - Top Right (Desktop) */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1002;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

body.dark .theme-toggle {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.theme-toggle:hover {
  background: #f8fafc;
  transform: scale(1.05);
}

body.dark .theme-toggle:hover {
  background: #334155;
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.desktop-only {
  display: block;
}

/* Navigation Menu */
.nav-menu {
  list-style: none;
  padding: 8px 0;
  flex: 1;
}

.nav-item {
  margin: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  min-height: 34px;
  text-decoration: none;
  color: #64748b;
  border-radius: 0;
  transition: all 0.2s ease;
  font-weight: 500;
  width: 100%;
}

/* Global reset sets padding on everything; explicitly remove it inside nav rows */
.nav-link * {
  padding: 0 !important;
}

.nav-link:hover {
  background: #f1f5f9;
  color: #1e293b;
}

body.dark .nav-link {
  color: #94a3b8;
}

body.dark .nav-link:hover {
  background: #334155;
  color: #f1f5f9;
}

.nav-item.active .nav-link {
  background: #23c6bb;
  color: white;
}

.nav-icon {
  margin-right: 8px;
  font-size: 16px;
}

.nav-text {
  font-size: 0.72rem;
  line-height: 1;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #e2e8f0;
}

body.dark .sidebar-footer {
  border-top-color: #334155;
}

.logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: none;
  border: none;
  color: #64748b;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
}

.logout-btn:hover {
  background: #fef2f2;
  color: #dc2626;
}

body.dark .logout-btn {
  color: #94a3b8;
}

body.dark .logout-btn:hover {
  background: #450a0a;
  color: #fca5a5;
}

/* Main Content */
.main-content {
  margin-left: 200px;
  padding: 32px;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* Breadcrumb Styling */
#breadcrumb {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 16px;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  padding: 0 !important;
  line-height: 1.5;
}

body.sidebar-is-collapsed #breadcrumb {
  padding: 0;
  margin-left: 0;
  margin-right: 0;
}

#breadcrumb a {
  color: #64748b;
  text-decoration: none;
  transition: color 0.2s ease;
}

#breadcrumb a:hover {
  color: #1e293b;
}

body.dark #breadcrumb {
  color: #94a3b8;
}

body.dark #breadcrumb a {
  color: #94a3b8;
}

body.dark #breadcrumb a:hover {
  color: #f1f5f9;
}

#breadcrumb span {
  color: #1e293b;
  font-weight: 500;
}

body.dark #breadcrumb span {
  color: #f1f5f9;
}

.content-header {
  margin-bottom: 32px;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.content-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

body.dark .content-header h1 {
  color: #f1f5f9;
}

.subtitle {
  color: #64748b;
  font-size: 0.75rem;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

body.dark .subtitle {
  color: #94a3b8;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.dashboard-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none !important;
  color: inherit;
  transition: all 0.2s ease;
}

.dashboard-card * {
  text-decoration: none !important;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body.dark .dashboard-card {
  background: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Lender marketing: calculator builder layout */
.calc-builder-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
  width: 100%;
  /* One outer border wrapping BOTH builder + preview */
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  background: #ffffff;
}

.calc-feature-builder {
  /* Inner border around the builder controls column */
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  box-shadow: none;
}

body.dark .calc-feature-builder {
  background: #0b1220;
  border-color: #1f2a44;
}

body.dark .calc-builder-layout {
  background: #1e293b;
  border-color: #1f2a44;
}

.calc-feature-builder .builder-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.calc-feature-builder .builder-title h4 {
  margin: 0;
  padding: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}

body.dark .calc-feature-builder .builder-title h4 {
  color: #e2e8f0;
}

.calc-feature-builder .builder-subtitle {
  margin: 0 0 10px 0;
  padding: 0;
  font-size: 12px;
  color: #64748b;
}

body.dark .calc-feature-builder .builder-subtitle {
  color: #94a3b8;
}

.feature-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feature-toggle-row {
  display: grid;
  /* Use minmax so the left column can shrink without overflowing into the switch column */
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start; /* align switch with the title (top-right) */
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

body.dark .feature-toggle-row {
  border-color: #1f2a44;
  background: #0f172a;
}

.feature-toggle-row .feature-name {
  display: flex;
  flex-direction: column;
  gap: 1px; /* reduce space between label + code name */
  min-width: 0; /* prevent overlap in narrow layouts */
}

/* Ensure builder inputs actually use available width inside the tile */
.feature-toggle-row .feature-name .fm-label-editor {
  width: 100%;
  min-width: 0;
}
.feature-toggle-row input[type="text"],
.feature-toggle-row input[type="number"] {
  max-width: 100%;
  min-width: 0;
}

.feature-toggle-row .feature-name .label {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.2;
  padding-right: 8px; /* keep distance from the switch column */
}

body.dark .feature-toggle-row .feature-name .label {
  color: #e2e8f0;
}

.feature-toggle-row .feature-name .key {
  font-size: 11px;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.15;
}

body.dark .feature-toggle-row .feature-name .key {
  color: #94a3b8;
}

/* Keep the switch aligned to the top-right of the tile */
.feature-toggle-row .switch {
  margin-top: 2px;
}

/* Toggle switch (read-only indicator) */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: default;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.2s;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.switch input:checked + .slider {
  background-color: #10b981; /* green on */
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}

/* Make disabled buttons look intentional in builder cards */
.calc-feature-builder button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.calc-preview {
  width: 100%;
}

.builder-calc-preview {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  min-height: 220px;
}

body.dark .builder-calc-preview {
  background: #0b1220;
  border-color: #1f2a44;
}

.builder-calc-preview.is-finmatch {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  min-height: 0;
}

.builder-calc-preview.is-finmatch iframe[data-finmatch-preview="1"] {
  width: 100%;
  border: 0;
  display: block;
}

/* Finance Assistant stage dots */
.fa-stage-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin: 10px 0 14px 0;
}

.fa-stage-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fa-stage-dot:hover {
  border-color: #94a3b8;
}

.fa-stage-dot.active {
  border-color: #0f172a;
  background: #0f172a;
}

body.dark .fa-stage-dot {
  border-color: #334155;
  background: #0b1220;
}

body.dark .fa-stage-dot.active {
  border-color: #e2e8f0;
  background: #e2e8f0;
}

.builder-calc-preview .preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.builder-calc-preview .preview-title h4 {
  margin: 0;
  padding: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
}

body.dark .builder-calc-preview .preview-title h4 {
  color: #e2e8f0;
}

.builder-calc-preview .preview-subtitle {
  margin: 0 0 12px 0;
  padding: 0;
  font-size: 12px;
  color: #64748b;
}

body.dark .builder-calc-preview .preview-subtitle {
  color: #94a3b8;
}

.builder-calc-preview .preview-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.builder-calc-preview .preview-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 12px;
}

body.dark .builder-calc-preview .preview-row {
  border-color: #1f2a44;
  background: #0f172a;
}

.builder-calc-preview .preview-row label {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
}

body.dark .builder-calc-preview .preview-row label {
  color: #e2e8f0;
}

.builder-calc-preview .preview-row input,
.builder-calc-preview .preview-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-size: 13px;
  background: #ffffff;
}

body.dark .builder-calc-preview .preview-row input,
body.dark .builder-calc-preview .preview-row select {
  background: #0b1220;
  border-color: #1f2a44;
  color: #e2e8f0;
}

/* Ensure <input type="color"> shows an actual swatch on desktop (Safari/Chrome),
   especially when inline styles set custom borders/radius. */
#stylingEditor input[type="color"][data-key] {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  box-sizing: border-box;
}

#stylingEditor input[type="color"][data-key]::-webkit-color-swatch-wrapper {
  padding: 0;
}

#stylingEditor input[type="color"][data-key]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

#stylingEditor input[type="color"][data-key]::-moz-color-swatch {
  border: none;
  border-radius: 6px;
}

.builder-calc-preview .preview-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

@media (max-width: 768px) {
  .calc-builder-layout {
    grid-template-columns: 1fr;
  }
}

.card-icon {
  font-size: 2rem;
  width: 64px;
  height: 64px;
  background: #f0fdfa;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.dark .card-icon {
  background: #134e4a;
}

.card-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

body.dark .card-content h3 {
  color: #f1f5f9;
}

.card-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: #23c6bb;
  margin-bottom: 4px;
}

.card-label {
  font-size: 14px;
  color: #64748b;
}

body.dark .card-label {
  color: #94a3b8;
}

/* Recent Activity */
.recent-activity {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body.dark .recent-activity {
  background: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.recent-activity h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 16px;
}

body.dark .recent-activity h2 {
  color: #f1f5f9;
}

.action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 12px 24px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.action-btn.primary {
  background: #23c6bb;
  color: white;
}

.action-btn.primary:hover {
  background: #1db5a9;
  transform: translateY(-1px);
}

.action-btn.secondary {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #e2e8f0;
}

.action-btn.secondary:hover {
  background: #e2e8f0;
}

body.dark .action-btn.secondary {
  background: #334155;
  color: #f1f5f9;
  border-color: #475569;
}

body.dark .action-btn.secondary:hover {
  background: #475569;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 250px;
  position: relative;
  display: flex;
  align-items: center;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.search-box input {
  width: 100%;
  padding: 12px 48px 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.75rem;
  background: white;
  height: 40px;
  box-sizing: border-box;
  line-height: 1.5;
}

.search-box input:focus {
  outline: none;
  border-color: #23c6bb;
}

body.dark .search-box input {
  background: #334155;
  border-color: #475569;
  color: white;
}

.search-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s ease;
  color: #64748b;
}

.search-btn:hover {
  background: #f1f5f9;
}

.search-btn:active {
  transform: scale(0.95);
}

body.dark .search-btn {
  color: #94a3b8;
}

body.dark .search-btn:hover {
  background: #334155;
}

.search-btn span {
  font-size: 18px;
  line-height: 1;
}

.filter-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.filter-controls select {
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  font-size: 0.75rem;
  height: 40px;
  box-sizing: border-box;
  line-height: 1.5;
}

body.dark .filter-controls select {
  background: #334155;
  border-color: #475569;
  color: white;
}

.export-btn {
  padding: 8px 16px;
  background: #23c6bb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.export-btn:hover {
  background: #1db5a9;
}

.add-merchant-btn {
  padding: 12px 16px;
  background: #23c6bb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 40px;
  box-sizing: border-box;
  line-height: 1.5;
  white-space: nowrap;
}

.add-merchant-btn span {
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-merchant-btn:hover {
  background: #1db5a9;
}

body.dark .add-merchant-btn {
  background: #1db5a9;
}

body.dark .add-merchant-btn:hover {
  background: #23c6bb;
}

/* Table Styles */
.table-container {
  background: white;
  border-radius: 16px;
  overflow-x: auto;
  overflow-y: visible;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 24px;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  padding: 0 !important;
  width: 100%;
  min-width: 0;
}

body.dark .table-container {
  background: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.merchants-table {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
  table-layout: auto;
  margin: 0;
}

.merchants-table th {
  /* Match public lenders table styling */
  background: #f9fafb;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  border-bottom: 2px solid #e5e7eb;
  font-size: 14px;
}

.merchants-table th:first-child {
  padding-left: 12px;
}

body.dark .merchants-table th {
  background: #334155;
  color: #f1f5f9;
  border-bottom-color: #475569;
}

.merchants-table td {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  color: #1f2937;
  font-size: 14px;
}

/* Domain cell: show multiple domains on separate lines (presentation only) */
.domain-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.domain-line {
  line-height: 1.2;
}

.merchants-table td:first-child {
  padding-left: 12px;
}

body.dark .merchants-table td {
  border-bottom-color: #334155;
  color: #f1f5f9;
}

.merchants-table tr:hover {
  /* Match public lenders hover */
  background: #dbeafe;
}

body.dark .merchants-table tr:hover {
  background: #334155;
}

/* Match public lenders table badges + product-id styling (used by lender/product tables) */
.product-id {
  font-family: 'Courier New', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  color: #2563eb;
  font-weight: 600;
  font-size: 13px;
}

.apr-badge {
  display: inline-block;
  background: #10b981;
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.apr-badge.with-interest {
  background: #f59e0b;
}

/* Lenders page: grouped rows for rate card products */
.merchants-table tr.lender-group-row td {
  background: #f9fafb;
  color: #1f2937;
  font-weight: 700;
  border-top: 2px solid #e5e7eb;
}

body.dark .merchants-table tr.lender-group-row td {
  background: #334155;
  color: #f1f5f9;
  border-top-color: #475569;
}

.loading {
  text-align: center;
  color: #64748b;
  font-style: italic;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding: 16px;
  flex-wrap: wrap;
}

.pagination-info {
  color: #64748b;
  font-size: 0.75rem;
}

body.dark .pagination-info {
  color: #94a3b8;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-info {
  color: #475569;
  font-size: 0.75rem;
  font-weight: 500;
  min-width: 100px;
  text-align: center;
}

body.dark .page-info {
  color: #cbd5e1;
}

.pagination button {
  padding: 8px 16px;
  border: 1px solid #e2e8f0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.75rem;
  font-weight: 500;
  color: #475569;
}

.pagination button:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

body.dark .pagination button {
  background: #334155;
  border-color: #475569;
  color: white;
}

body.dark .pagination button:hover:not(:disabled) {
  background: #475569;
  border-color: #64748b;
}

@media (max-width: 768px) {
  .pagination {
    flex-direction: column;
    align-items: stretch;
  }
  
  .pagination-controls {
    justify-content: center;
  }
}

/* Lenders Grid */
.lenders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.lender-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s ease;
}

.lender-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body.dark .lender-card {
  background: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.lender-logo {
  width: 64px;
  height: 64px;
  background: #f8fafc;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lender-logo img {
  max-width: 48px;
  max-height: 48px;
  object-fit: contain;
}

body.dark .lender-logo {
  background: #334155;
}

.lender-info h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

body.dark .lender-info h3 {
  color: #f1f5f9;
}

.lender-status {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  display: inline-block;
}

.lender-status.active {
  background: #dcfdf7;
  color: #065f46;
}

body.dark .lender-status.active {
  background: #064e3b;
  color: #6ee7b7;
}

.lender-merchants {
  font-size: 14px;
  color: #64748b;
}

body.dark .lender-merchants {
  color: #94a3b8;
}

/* Lender Stats */
.lender-stats {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body.dark .lender-stats {
  background: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.lender-stats h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 16px;
}

body.dark .lender-stats h2 {
  color: #f1f5f9;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  text-align: center;
  padding: 16px;
  background: #f8fafc;
  border-radius: 12px;
}

body.dark .stat-card {
  background: #334155;
}

.stat-card h3 {
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  margin-bottom: 8px;
}

body.dark .stat-card h3 {
  color: #94a3b8;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: #23c6bb;
  margin-bottom: 4px;
}

.stat-period {
  font-size: 12px;
  color: #64748b;
}

body.dark .stat-period {
  color: #94a3b8;
}

/* Analytics */
.analytics-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.metric-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 16px;
}

body.dark .metric-card {
  background: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.metric-icon {
  font-size: 2rem;
  width: 64px;
  height: 64px;
  background: #f0fdfa;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.dark .metric-icon {
  background: #134e4a;
}

.metric-content h3 {
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  margin-bottom: 4px;
}

body.dark .metric-content h3 {
  color: #94a3b8;
}

.metric-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}

body.dark .metric-number {
  color: #f1f5f9;
}

.metric-change {
  font-size: 12px;
  font-weight: 500;
}

.metric-change.positive {
  color: #23c6bb;
}

.metric-change.negative {
  color: #dc2626;
}

.analytics-section {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 24px;
}

body.dark .analytics-section {
  background: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.analytics-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
}

body.dark .analytics-section h2 {
  color: #f1f5f9;
}

.section-subtitle {
  color: #64748b;
  font-size: 14px;
  margin-bottom: 16px;
}

body.dark .section-subtitle {
  color: #94a3b8;
}

.analytics-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.analytics-btn {
  padding: 8px 16px;
  border: 1px solid #e2e8f0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: #1e293b;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
}

.analytics-btn:hover {
  background: #f1f5f9;
}

.analytics-btn.secondary {
  background: #f8fafc;
}

body.dark .analytics-btn {
  background: #334155;
  border-color: #475569;
  color: #f1f5f9;
}

body.dark .analytics-btn:hover {
  background: #475569;
}

body.dark .analytics-btn.secondary {
  background: #475569;
}

.analytics-data {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.dark .analytics-data {
  background: #334155;
}

.loading-text {
  color: #64748b;
  font-style: italic;
}

body.dark .loading-text {
  color: #94a3b8;
}

.performance-table {
  overflow-x: auto;
}

.performance-table table {
  width: 100%;
  border-collapse: collapse;
}

.performance-table th,
.performance-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

body.dark .performance-table th,
body.dark .performance-table td {
  border-bottom-color: #475569;
}

.performance-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #374151;
  font-size: 14px;
}

body.dark .performance-table th {
  background: #334155;
  color: #f1f5f9;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
}

/* Additional Component Styles */
.environment-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
}

.env-p {
  background: #fef3c7;
  color: #92400e;
}

.env-s {
  background: #dbeafe;
  color: #1e40af;
}

.env-t {
  background: #f3e8ff;
  color: #7c3aed;
}

body.dark .env-p {
  background: #451a03;
  color: #fbbf24;
}

body.dark .env-s {
  background: #1e3a8a;
  color: #93c5fd;
}

body.dark .env-t {
  background: #581c87;
  color: #c4b5fd;
}

.status-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
}

.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-active {
  background: #dbeafe;
  color: #1e40af;
}

.status-deployed {
  background: #dcfdf7;
  color: #065f46;
}

body.dark .status-pending {
  background: #451a03;
  color: #fbbf24;
}

body.dark .status-active {
  background: #1e3a8a;
  color: #93c5fd;
}

body.dark .status-deployed {
  background: #064e3b;
  color: #6ee7b7;
}

.status-trialing {
  background: #dbeafe;
  color: #1e40af;
}

.status-past-due {
  background: #fef3c7;
  color: #92400e;
}

.status-canceled {
  background: #fee2e2;
  color: #991b1b;
}

.status-none {
  background: #f1f5f9;
  color: #64748b;
}

body.dark .status-trialing {
  background: #1e3a8a;
  color: #93c5fd;
}

body.dark .status-past-due {
  background: #451a03;
  color: #fbbf24;
}

body.dark .status-canceled {
  background: #7f1d1d;
  color: #fca5a5;
}

body.dark .status-none {
  background: #334155;
  color: #94a3b8;
}

.status-commented {
  background: #fef3c7;
  color: #92400e;
}

body.dark .status-commented {
  background: #451a03;
  color: #fbbf24;
}

.status-error {
  background: #fef2f2;
  color: #dc2626;
}

body.dark .status-error {
  background: #450a0a;
  color: #fca5a5;
}

/* Help icon */
.help-icon {
  background: none;
  border: none;
  color: #64748b;
  cursor: help;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.help-icon:hover {
  background: #f1f5f9;
  color: #374151;
}

body.dark .help-icon:hover {
  background: #334155;
  color: #f1f5f9;
}

/* Status help tooltip */
.status-help-tooltip {
  position: fixed;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  padding: 16px;
  max-width: 300px;
  z-index: 10000;
  display: none;
  font-size: 14px;
  line-height: 1.5;
}

.status-help-tooltip.show {
  display: block;
}

.status-help-tooltip h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.status-help-tooltip p {
  margin: 8px 0;
  color: #64748b;
}

.status-help-tooltip .status-examples {
  margin-top: 12px;
}

.status-help-tooltip .status-examples div {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  font-size: 0.75rem;
}

body.dark .status-help-tooltip {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

body.dark .status-help-tooltip h4 {
  color: #f1f5f9;
}

body.dark .status-help-tooltip p {
  color: #94a3b8;
}

/* Actions menu */
.actions-menu {
  position: relative;
  display: inline-block;
}

.actions-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 16px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.actions-btn:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #475569;
}

.actions-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 160px;
  display: none;
  overflow: hidden;
}

.actions-dropdown.show {
  display: block;
}

.actions-dropdown button {
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.actions-dropdown button:hover {
  background: #f8fafc;
}

.actions-dropdown button:first-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.actions-dropdown button:last-child {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* Dark mode for actions menu */
body.dark .actions-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.dark .actions-btn:hover {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

body.dark .actions-dropdown {
  background: #1e293b;
  border-color: #334155;
}

body.dark .actions-dropdown button {
  color: #e2e8f0;
}

body.dark .actions-dropdown button:hover {
  background: #334155;
}

/* Legacy action buttons (keeping for compatibility) */
.action-btn-small {
  padding: 4px 8px;
  background: #23c6bb;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn-small:hover {
  background: #1db5a9;
}

.analytics-summary {
  text-align: center;
  padding: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.summary-item {
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 14px;
}

body.dark .summary-item {
  background: #334155;
}

.data-note {
  margin-top: 16px;
  font-size: 14px;
  color: #64748b;
  font-style: italic;
}

body.dark .data-note {
  color: #94a3b8;
}

.data-note a {
  color: #23c6bb;
  text-decoration: none;
}

.data-note a:hover {
  text-decoration: underline;
}

.merchant-cell {
  line-height: 1.4;
}

.merchant-cell small {
  color: #64748b;
}

body.dark .merchant-cell small {
  color: #94a3b8;
}

.error-message {
  text-align: center;
  padding: 20px;
  color: #dc2626;
}

body.dark .error-message {
  color: #fca5a5;
}

/* Burger menu animations removed */

/* Hide desktop theme toggle on mobile, show mobile version */
@media (max-width: 768px) {
  .theme-toggle:not(.mobile-theme-toggle) {
    display: none !important;
  }
}

/* Hide mobile theme toggle on desktop */
.theme-toggle.mobile-theme-toggle {
  display: none;
}

@media (max-width: 768px) {
  .theme-toggle.mobile-theme-toggle {
    display: flex !important;
    position: relative;
    top: auto;
    right: auto;
    width: 40px;
    height: 40px;
    padding: 8px;
    flex-shrink: 0;
    box-shadow: none;
    border: 1px solid #e2e8f0;
  }
  
  body.dark .theme-toggle.mobile-theme-toggle {
    border-color: #334155;
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  /* Burger menu removed; use sidebar expand button instead */
  .burger-menu {
    display: none !important;
  }
  .sidebar-collapse-btn {
    display: none !important;
  }
  .sidebar-expand-btn {
    display: flex !important;
    left: 16px !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-overlay.show {
    display: block;
  }
  
  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: 80px;
  }
  
  .desktop-only {
    display: none;
  }
  
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box {
    min-width: auto;
  }
  
  .filter-controls {
    justify-content: space-between;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  /* Lender marketing pages: full-bleed embeds (no side padding/gaps) */
  body.marketing-embeds .main-content {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-bottom: 0 !important;
    /* Keep top padding so content doesn't sit under the fixed mobile header */
    padding-top: 80px !important;
  }

  body.marketing-embeds .dashboard-grid {
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.marketing-embeds .dashboard-card {
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  body.marketing-embeds .card-content {
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Kill the global reset padding inside the marketing content area */
  body.marketing-embeds .main-content * {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .action-btn {
    justify-content: center;
  }
  
  .lenders-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .analytics-overview {
    grid-template-columns: 1fr;
  }
  
  .analytics-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 12px;
    padding-top: 80px;
  }
  
  .content-header h1 {
    font-size: 1.5rem;
  }
  
  .dashboard-card,
  .metric-card,
  .lender-card {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  
  .table-container {
    overflow-x: auto;
  }
  
  .merchants-table {
    min-width: 1200px;
  }
}

/* Add Merchant Button */
.add-merchant-btn {
  padding: 8px 16px;
  background: #23c6bb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.add-merchant-btn:hover {
  background: #1db5a9;
  transform: translateY(-1px);
}

/* Modal Styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 800px;
  min-height: calc(100vh - 40px);
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body.dark .modal-content {
  background: #1e293b;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.modal-body {
  flex: 1;
  padding: 24px;
  overflow: visible;
}

.detail-value-container {
  display: flex;
  align-items: center;
}

.detail-value.editable {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.detail-value.editable:hover {
  background-color: #f1f5f9;
}

.contacts-emoji {
  transition: transform 0.2s ease;
}

.contacts-emoji:hover {
  transform: scale(1.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid #e2e8f0;
}

body.dark .modal-header {
  border-bottom-color: #334155;
}

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

body.dark .modal-header h2 {
  color: #f1f5f9;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #64748b;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

body.dark .modal-close {
  color: #94a3b8;
}

body.dark .modal-close:hover {
  background: #334155;
  color: #f1f5f9;
}

/* Form Styles */
.form-section {
  padding: 24px;
  border-bottom: 1px solid #f1f5f9;
}

body.dark .form-section {
  border-bottom-color: #334155;
}

.form-section:last-of-type {
  border-bottom: none;
}

.form-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 16px;
}

body.dark .form-section h3 {
  color: #f1f5f9;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
  font-size: 14px;
}

body.dark .form-group label {
  color: #f1f5f9;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
  font-style: italic;
}

body.dark .form-hint {
  color: #9ca3af;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #23c6bb;
  box-shadow: 0 0 0 3px rgba(35, 198, 187, 0.1);
}

body.dark .form-group input,
body.dark .form-group select {
  background: #334155;
  border-color: #475569;
  color: white;
}

body.dark .form-group input:focus,
body.dark .form-group select:focus {
  border-color: #23c6bb;
  box-shadow: 0 0 0 3px rgba(35, 198, 187, 0.2);
}

/* Checkbox Group */
.checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.checkbox-item:hover {
  background: #f8fafc;
}

body.dark .checkbox-item:hover {
  background: #334155;
}

.checkbox-item input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.checkbox-item span {
  font-size: 14px;
  color: #374151;
}

body.dark .checkbox-item span {
  color: #f1f5f9;
}

/* Modal Actions */
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

body.dark .modal-actions {
  background: #334155;
  border-top-color: #475569;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary {
  background: #23c6bb;
  color: white;
}

.btn-primary:hover {
  background: #1db5a9;
  transform: translateY(-1px);
}

.btn-secondary {
  background: white;
  color: #374151;
  border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
  background: #f8fafc;
}

body.dark .btn-secondary {
  background: #475569;
  color: #f1f5f9;
  border-color: #64748b;
}

body.dark .btn-secondary:hover {
  background: #64748b;
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

body.dark .btn-danger {
  background: #dc2626;
}

body.dark .btn-danger:hover {
  background: #b91c1c;
}

/* Merchant page actions styling */
.merchant-page-actions {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .content-header > div {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 16px;
  }
  
  .merchant-page-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  
  .merchant-page-actions button {
    flex: 1;
    min-width: 120px;
  }
}

/* Form validation states */
.form-group input.error,
.form-group select.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.error-message {
  color: #ef4444;
  font-size: 12px;
  margin-top: 4px;
}

/* Success states */
.form-group input.success,
.form-group select.success {
  border-color: #23c6bb;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

/* Loading states */
.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary.loading {
  background: #94a3b8;
}

@media (max-width: 768px) {
  .modal-content {
    margin: 0;
    border-radius: 0;
    height: 100%;
    max-height: 100vh;
  }
  
  .modal-actions {
    flex-direction: column;
  }
  
  .checkbox-group {
    grid-template-columns: 1fr;
  }
}

/* Toast Notifications */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  z-index: 10000;
  min-width: 300px;
  max-width: 500px;
  animation: slideInRight 0.3s ease;
}

body.dark .toast {
  background: #1e293b;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.toast-success {
  border-left: 4px solid #23c6bb;
}

.toast-error {
  border-left: 4px solid #ef4444;
}

.toast-info {
  border-left: 4px solid #3b82f6;
}

.toast-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 12px;
}

.toast-content span {
  flex: 1;
  color: #1e293b;
  font-size: 14px;
}

body.dark .toast-content span {
  color: #f1f5f9;
}

.toast-content button {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.toast-content button:hover {
  background: #f1f5f9;
  color: #1e293b;
}

body.dark .toast-content button {
  color: #94a3b8;
}

body.dark .toast-content button:hover {
  background: #334155;
  color: #f1f5f9;
}

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

/* Stripe Integration Styles */
.stripe-customer-linked {
  color: #23c6bb;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
}

.stripe-customer-linked:hover {
  color: #23c6bb;
  text-decoration: underline;
}

.link-stripe-btn {
  background: #23c6bb;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.link-stripe-btn:hover {
  background: #1db5a9;
}

.customer-info {
  padding: 20px 0;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #e2e8f0;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row label {
  font-weight: 500;
  color: #64748b;
  min-width: 80px;
}

.info-row span {
  color: #1e293b;
  word-break: break-all;
}

body.dark .info-row {
  border-bottom-color: #334155;
}

body.dark .info-row label {
  color: #94a3b8;
}

body.dark .info-row span {
  color: #f1f5f9;
}

.link-customer-content {
  padding: 20px 0;
}

.link-customer-content p {
  margin-bottom: 16px;
  padding: 8px 0;
}

.link-customer-content strong {
  color: #1e293b;
  font-weight: 600;
}

body.dark .link-customer-content strong {
  color: #f1f5f9;
}

/* Merchant Details Modal Styles */
.merchant-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.details-section {
  background: #f8fafc;
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

body.dark .details-section {
  background: #1e293b;
  border-color: #334155;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

body.dark .section-header {
  border-bottom-color: #334155;
}

.details-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

body.dark .details-section h3 {
  color: #f1f5f9;
}

.link-unlink-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

body.dark .link-unlink-btn {
  background: #334155;
  border-color: #475569;
  color: #cbd5e1;
}

.link-unlink-btn:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #475569;
}

body.dark .link-unlink-btn:hover {
  background: #475569;
  border-color: #64748b;
  color: #f1f5f9;
}

.link-unlink-btn.linked {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

body.dark .link-unlink-btn.linked {
  background: #14532d;
  border-color: #22c55e;
  color: #86efac;
}

.details-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e2e8f0;
}

body.dark .details-section h3 {
  color: #f1f5f9;
  border-bottom-color: #334155;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e2e8f0;
}

.detail-row:last-child {
  border-bottom: none;
}

body.dark .detail-row {
  border-bottom-color: #334155;
}

.detail-row label {
  font-weight: 500;
  color: #64748b;
  min-width: 120px;
}

body.dark .detail-row label {
  color: #94a3b8;
}

.detail-value {
  font-weight: 500;
  color: #1e293b;
  text-align: right;
  flex: 1;
  margin-left: 1rem;
}

body.dark .detail-value {
  color: #f1f5f9;
}

.detail-value.stripe-info {
  color: #23c6bb;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
}

.detail-value.stripe-info:empty::before {
  content: "Not linked";
  color: #64748b;
  font-style: italic;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

body.dark .detail-value.stripe-info:empty::before {
  color: #94a3b8;
}

@media (max-width: 768px) {
  .merchant-details-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  
  .detail-value {
    text-align: left;
    margin-left: 0;
  }
}

/* Clickable merchant name */
.clickable-merchant-name {
  transition: color 0.2s ease;
}

.clickable-merchant-name:hover {
  color: #1d4ed8 !important;
  text-decoration: underline !important;
}

/* Form row layout for side-by-side fields */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

/* Enhanced Close Button Styles */
.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #23c6bb;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: #f0fdfa;
  color: #1db5a9;
  transform: scale(1.1);
}

body.dark .close-btn {
  color: #23c6bb;
}

body.dark .close-btn:hover {
  background: #064e3b;
  color: #6ee7b7;
}

/* Lender Badges */
.lender-badge {
  display: inline-block;
  padding: 4px 8px;
  margin: 2px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

body.dark .lender-badge {
  background: #0c4a6e;
  color: #bae6fd;
}

.sidebar {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Desktop-only collapse behavior.
   IMPORTANT: On iOS Safari, users can carry `sidebarCollapsed=true` from desktop into mobile.
   If this rule applies on mobile it can override `.sidebar.open` and the nav never appears. */
@media (min-width: 769px) {
  .sidebar.collapsed {
    transform: translateX(-200px);
  }
}

.main-content {
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 769px) {
  .main-content.sidebar-collapsed {
    margin-left: 0;
  }
}

/* Collapse/Expand Button - Always in main content area */
.sidebar-collapse-btn,
.sidebar-expand-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 6px;
}

body.dark .sidebar-collapse-btn,
body.dark .sidebar-expand-btn {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-collapse-btn:hover,
.sidebar-expand-btn:hover {
  background: #f8fafc;
  transform: scale(1.05);
}

body.dark .sidebar-collapse-btn:hover,
body.dark .sidebar-expand-btn:hover {
  background: #334155;
}

/* Show collapse button when sidebar is expanded - positioned at left edge of main content */
body:not(.sidebar-is-collapsed) .sidebar-collapse-btn {
  display: flex !important;
  left: 216px; /* 200px sidebar width + 16px margin */
}

/* Show expand button when sidebar is collapsed - positioned at left edge of main content */
body.sidebar-is-collapsed .sidebar-expand-btn {
  display: flex !important;
  left: 16px;
}

/* Smooth transition when sidebar expands/collapses - button moves with main content */
body.sidebar-is-collapsed .sidebar-collapse-btn {
  left: 16px;
  opacity: 0;
  pointer-events: none;
}

body:not(.sidebar-is-collapsed) .sidebar-expand-btn {
  left: 216px;
  opacity: 0;
  pointer-events: none;
}

/* On mobile, buttons stay at left: 16px (sidebar is overlay, not taking space) */
@media (max-width: 768px) {
  body:not(.sidebar-is-collapsed) .sidebar-collapse-btn {
    left: 16px;
  }
  
  body.sidebar-is-collapsed .sidebar-expand-btn {
    left: 16px;
  }
}

.sidebar-collapse-icon::before,
.sidebar-expand-icon {
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  transition: transform 0.3s ease, color 0.2s ease;
  line-height: 1;
  display: block;
}

.sidebar-expand-icon {
  transition: transform 0.3s ease, color 0.2s ease;
}

body.dark .sidebar-collapse-icon::before,
body.dark .sidebar-expand-icon {
  color: #94a3b8;
}

.sidebar-collapse-btn:hover .sidebar-collapse-icon::before,
.sidebar-expand-btn:hover .sidebar-expand-icon {
  color: #1e293b;
}

.sidebar-expand-btn:hover .sidebar-expand-icon {
  transform: translateX(2px);
}

body.dark .sidebar-collapse-btn:hover .sidebar-collapse-icon::before,
body.dark .sidebar-expand-btn:hover .sidebar-expand-icon {
  color: #f1f5f9;
}

/* Delete Merchant Button */
.btn-danger {
  background: #ef4444;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(239, 68, 68, 0.2);
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-danger:active:not(:disabled) {
  transform: translateY(0);
}

/* Delete confirmation input styling */
#deleteConfirmInput:focus {
  border-color: #ef4444;
  outline: none;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

#deleteConfirmInput.error {
  border-color: #ef4444;
  background-color: #fef2f2;
}

/* Lender settings: hide noisy read-only JSON behind a small code icon */
.logic-options-group {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
}

body.dark .logic-options-group {
  background: rgba(255,255,255,0.04);
  border-color: rgba(148, 163, 184, 0.25);
}

.logic-options-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logic-code-toggle {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  cursor: pointer;
}

.logic-code-toggle:hover {
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

body.dark .logic-code-toggle {
  background: rgba(255,255,255,0.06);
  border-color: rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
}