:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-input: #182235;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.3);
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.25);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.2);
  --warning: #f59e0b;
  
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(6, 182, 212, 0.5);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 15px var(--accent-cyan-glow);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* App Container Layout */
.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100%;
  width: 100%;
}

/* Sidebar Styling */
.sidebar {
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--text-primary);
}

.logo-icon {
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 5px var(--accent-cyan-glow));
}

.connections-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  min-height: 200px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.count-badge {
  background-color: var(--bg-tertiary);
  color: var(--accent-cyan);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.connections-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 15px;
}

.text-link-btn {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.text-link-btn:hover {
  text-decoration: underline;
  color: var(--text-primary);
}

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

/* Connection Item */
.connection-item {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.connection-item:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.05);
}

.connection-item.selected {
  border-color: var(--accent-cyan);
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(6, 182, 212, 0.03) 100%);
}

.conn-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conn-selector-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  width: 100%;
}

.conn-checkbox {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--text-muted);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.conn-checkbox:checked {
  background-color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.conn-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid #000;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.conn-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.conn-type-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.conn-type-badge.mysql { background-color: rgba(242, 145, 17, 0.15); color: #f29111; }
.conn-type-badge.postgres { background-color: rgba(51, 103, 145, 0.15); color: #4183c4; }
.conn-type-badge.mssql { background-color: rgba(224, 87, 87, 0.15); color: #e05757; }
.conn-type-badge.sqlite { background-color: rgba(15, 128, 222, 0.15); color: #0f80de; }

.conn-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.conn-status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.status-dot.online { background-color: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background-color: var(--danger); box-shadow: 0 0 6px var(--danger); }
.status-dot.testing { background-color: var(--warning); animation: pulse 1s infinite alternate; }

@keyframes pulse {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

.conn-actions {
  display: flex;
  gap: 8px;
}

.conn-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: var(--transition);
}

.conn-action-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

.conn-action-btn:hover.delete {
  color: var(--danger);
  background-color: rgba(239, 68, 68, 0.05);
}

/* History Section */
.history-section {
  height: 180px;
  border-top: 1px solid var(--border-light);
  padding: 15px 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.small-icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.history-item {
  font-family: 'Fira Code', monospace;
  font-size: 0.7rem;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: var(--transition);
}

.history-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--accent-cyan);
}

/* Empty States */
.empty-state {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 15px 0;
}

/* Main Workspace */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-primary);
}

/* Toolbar */
.toolbar {
  padding: 20px 30px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-title h1 {
  font-size: 1.4rem;
  color: var(--text-primary);
}

.toolbar-title .subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* SQL Editor Section */
.editor-section {
  padding: 20px 30px 10px 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: justify;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.editor-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-primary);
}

.editor-title i {
  color: var(--accent-cyan);
}

.editor-actions {
  display: flex;
  gap: 15px;
  margin-left: auto;
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  transition: var(--transition);
}

.text-btn:hover {
  color: var(--text-primary);
}

.editor-container {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--bg-input);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
  transition: var(--transition);
}

.editor-container:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.15), inset 0 2px 4px rgba(0,0,0,0.1);
}

#sql-editor {
  width: 100%;
  height: 160px;
  background: none;
  border: none;
  outline: none;
  resize: none;
  padding: 15px;
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  color: #e4e4e7;
  line-height: 1.5;
}

/* Targets Banner */
.selected-targets-banner {
  margin: 0 30px;
  padding: 10px 15px;
  background-color: rgba(6, 182, 212, 0.05);
  border: 1.5px dashed rgba(6, 182, 212, 0.15);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.selected-targets-banner i {
  width: 16px;
  height: 16px;
  color: var(--accent-cyan);
}

/* Results Section */
.results-section {
  flex: 1;
  padding: 20px 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow: hidden;
  min-height: 0;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 10px;
}

.results-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

.results-title i {
  color: var(--accent-cyan);
}

.overall-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.results-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 40px;
  min-height: 0;
}

.empty-results-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  color: var(--text-secondary);
  gap: 10px;
}

.giant-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-results-state h3 {
  color: var(--text-primary);
  font-size: 1.1rem;
}

.empty-results-state p {
  font-size: 0.85rem;
  max-width: 300px;
}

/* Accordion Result Item per DB */
.db-result-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
  flex-shrink: 0;
}

.db-result-card.success-card {
  border-left: 4px solid var(--success);
}

.db-result-card.warning-card {
  border-left: 4px solid var(--warning);
}

.db-result-card.error-card {
  border-left: 4px solid var(--danger);
}

.db-result-header {
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.01);
  transition: var(--transition);
}

.db-result-header:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.db-result-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.db-result-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.db-badge-and-time {
  display: flex;
  align-items: center;
  gap: 10px;
}

.exec-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background-color: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'Fira Code', monospace;
}

.db-result-stats {
  display: flex;
  align-items: center;
  gap: 15px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
}

.status-badge.success {
  background-color: var(--success-glow);
  color: var(--success);
}

.status-badge.warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.status-badge.error {
  background-color: var(--danger-glow);
  color: var(--danger);
}

.toggle-arrow {
  transition: var(--transition);
  color: var(--text-muted);
}

.db-result-card.collapsed .toggle-arrow {
  transform: rotate(-90deg);
}

.db-result-body {
  border-top: 1px solid var(--border-light);
  padding: 15px 20px;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.db-result-card.collapsed .db-result-body {
  display: none;
}

/* Error Message styling */
.error-message-box {
  background-color: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  padding: 15px;
  border-radius: var(--radius-sm);
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Grid controls & search */
.grid-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.search-input-wrapper {
  position: relative;
  width: 250px;
}

.search-input-wrapper i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 6px 10px 6px 32px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--accent-cyan);
}

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

/* Table grid view */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  max-height: 350px;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: left;
}

.results-table th {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 10;
  user-select: none;
}

.results-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-family: 'Fira Code', monospace;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.results-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}

.results-table tr:last-child td {
  border-bottom: none;
}

/* Pagination controls */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.pagination-buttons {
  display: flex;
  gap: 5px;
}

/* Button UI */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--accent-cyan);
  color: #0b0f19;
}

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

.btn-glow:hover {
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-input);
  border-color: var(--text-secondary);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
}

.btn-text:hover {
  color: var(--text-primary);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.shortcut {
  font-family: inherit;
  font-size: 0.7rem;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  color: rgba(0, 0, 0, 0.6);
  margin-left: 5px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 10px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 500px;
  max-width: 95vw;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  overflow: hidden;
  margin: auto 0;
}

.modal-backdrop.open .modal {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 25px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.15rem;
}

#connection-form {
  padding: 25px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input, .form-group select {
  background-color: var(--bg-input);
  border: 1px solid var(--border-light);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--accent-cyan);
}

.form-help {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.modal-form-flex {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.modal-body {
  padding: 20px 25px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0;
  border-top: 1px solid var(--border-light);
  padding: 16px 25px;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.clients-list-header {
  justify-content: space-between;
  gap: 12px;
}

.clients-list-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.clients-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.client-live-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 12px;
}

.live-filter-chip {
  border: 1px solid var(--border-light);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.live-filter-chip.active {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.live-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.live-dot.online { color: #10b981; }
.live-dot.offline { color: #ef4444; }
.live-dot.checking { color: #9ca3af; }
.live-dot.inactive { color: #f59e0b; }

.live-dot.online::before {
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
  animation: live-pulse 2s ease-out infinite;
}

.live-dot.checking::before {
  animation: live-blink 1s ease-in-out infinite;
}

@keyframes live-pulse {
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes live-blink {
  50% { opacity: 0.35; }
}

#refresh-client-ping-btn.is-pinging {
  opacity: 0.7;
  pointer-events: none;
}

.modal-save-actions {
  display: flex;
  gap: 10px;
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(6, 182, 212, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 30px 0;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 25px;
  right: 25px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
}

.toast.show {
  transform: translateX(0);
}

.toast-icon {
  flex-shrink: 0;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.success .toast-icon { color: var(--success); }

.toast.error { border-left: 4px solid var(--danger); }
.toast.error .toast-icon { color: var(--danger); }

.toast.warning { border-left: 4px solid var(--warning); }
.toast.warning .toast-icon { color: var(--warning); }

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.toast-message {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  transition: var(--transition);
}

.toast-close:hover {
  color: var(--text-primary);
}

/* ==========================================
   VERTICAL SIDEBAR & TOPBAR LAYOUT SYSTEM
   ========================================== */
.app-layout {
  display: flex !important;
  flex-direction: row !important;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-primary);
  margin: 0;
  padding: 0;
}

.app-sidebar {
  width: 240px;
  min-width: 240px;
  height: 100vh;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  box-sizing: border-box;
}

.sidebar-brand {
  height: 60px;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-light);
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  flex-shrink: 0;
}

.sidebar-brand i {
  width: 22px;
  height: 22px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 8px var(--accent-cyan-glow));
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 15px 10px;
  overflow-y: auto;
  flex: 1;
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 12px 4px 12px;
}

.sidebar-nav .nav-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  height: auto;
  box-sizing: border-box;
}

.sidebar-nav .nav-tab:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.04);
}

.sidebar-nav .nav-tab.active {
  background-color: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.3);
  font-weight: 700;
}

.sidebar-nav .nav-tab i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ==========================================
   SIDEBAR COLLAPSED / EXPANDED STATE
   ========================================== */
.app-sidebar {
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapsed .app-sidebar {
  width: 65px !important;
  min-width: 65px !important;
}

.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 0;
}

.sidebar-collapsed .sidebar-brand span,
.sidebar-collapsed .sidebar-section-title,
.sidebar-collapsed .sidebar-nav .nav-tab span,
.sidebar-collapsed .sidebar-nav .badge {
  display: none !important;
}

.sidebar-collapsed .sidebar-nav .nav-tab {
  justify-content: center;
  padding: 12px;
  gap: 0;
}

.sidebar-collapsed .sidebar-nav {
  padding: 15px 6px;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
  background-color: var(--bg-primary);
}

.app-topbar {
  height: 60px;
  min-height: 60px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 25px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.topbar-title h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

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

.nav-tab:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

.nav-tab.active {
  color: var(--accent-cyan);
  background-color: rgba(6, 182, 212, 0.06);
  border-color: rgba(6, 182, 212, 0.2);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.05);
}

.nav-tab i {
  width: 16px;
  height: 16px;
}

.top-nav .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
}

.top-nav .logo-icon {
  width: 22px;
  height: 22px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 8px var(--accent-cyan-glow));
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
}

.nav-tab {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  height: 40px;
}

.nav-tab:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

.nav-tab.active {
  color: var(--accent-cyan);
  background-color: rgba(6, 182, 212, 0.06);
  border-color: rgba(6, 182, 212, 0.2);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.05);
}

.nav-tab i {
  width: 16px;
  height: 16px;
}

/* Nav Dropdown Styling */
.nav-dropdown-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
}

.dropdown-arrow {
  width: 14px !important;
  height: 14px !important;
  transition: transform 0.25s ease;
  margin-left: 2px;
}

.nav-dropdown-wrapper:hover .dropdown-arrow,
.nav-dropdown-wrapper.open .dropdown-arrow {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% - 6px);
  right: 0;
  min-width: 250px;
  background-color: #111827;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1050;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-dropdown-wrapper:hover .nav-dropdown-menu,
.nav-dropdown-wrapper.open .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-dropdown-item {
  width: 100%;
  height: auto;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  justify-content: flex-start;
  text-align: left;
  gap: 12px;
  background: transparent;
  border: 1px solid transparent;
}

.nav-dropdown-item i {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0;
}

.nav-dropdown-item .item-title {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.nav-dropdown-item .item-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.nav-dropdown-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.nav-dropdown-item.active {
  background-color: rgba(6, 182, 212, 0.08);
  border-color: rgba(6, 182, 212, 0.2);
}

.nav-dropdown-wrapper.has-active-child .nav-dropdown-btn {
  color: var(--accent-cyan);
  background-color: rgba(6, 182, 212, 0.06);
  border-color: rgba(6, 182, 212, 0.2);
}

.top-nav-status {
  display: flex;
  align-items: center;
  gap: 15px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  border-radius: 30px;
}

.tab-content {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.tab-pane {
  display: none;
  height: 100%;
  width: 100%;
}

.tab-pane.active {
  display: block;
}

/* Sidebar Modifications */
.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  height: 65px;
}

.sidebar-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.sidebar-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Placeholders for upcoming modules */
.pane-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  background: radial-gradient(circle at center, rgba(6, 182, 212, 0.03) 0%, var(--bg-primary) 70%);
  color: var(--text-secondary);
  text-align: center;
  padding: 40px;
  gap: 15px;
  animation: fadeIn 0.4s ease-out;
}

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

.pane-placeholder .giant-icon {
  width: 64px;
  height: 64px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 15px var(--accent-cyan-glow));
  opacity: 0.85;
  margin-bottom: 10px;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0px); }
}

.pane-placeholder h2 {
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.pane-placeholder p {
  font-size: 1rem;
  max-width: 520px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.features-preview {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 25px;
  max-width: 600px;
}

.feature-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 600;
  transition: var(--transition);
}

.feature-tag:hover {
  border-color: var(--accent-cyan);
  background-color: rgba(6, 182, 212, 0.02);
  transform: translateY(-2px);
  color: var(--accent-cyan);
}

.feature-tag i {
  width: 14px;
  height: 14px;
  color: var(--accent-cyan);
}

/* Client Details & Menu Builder layouts */
.client-details-container, .menu-builder-container {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 25px;
  padding: 30px;
  height: calc(100vh - 70px); /* Adjust based on top-nav height */
  overflow: hidden;
  box-sizing: border-box;
}

.client-details-container {
  grid-template-columns: 1fr;
}

.client-details-container.view-only, .client-details-container.full-width, .menu-builder-container.view-only {
  grid-template-columns: 1fr !important;
}

.client-form-card, .clients-list-card, .menu-form-card, .menu-tree-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

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

.card-header h2 {
  font-size: 1.15rem;
  color: var(--text-primary);
  margin: 0;
}

.card-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 4px var(--accent-cyan-glow));
}

.client-form, .menu-builder-form {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input, .form-group select {
  background-color: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.15);
}

.form-help {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.form-actions {
  margin-top: auto;
  padding-top: 15px;
}

/* Clients list & table */
.client-grid-search {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-light);
}

.clients-grid-wrapper {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.clients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.clients-table th {
  background-color: rgba(255,255,255,0.01);
  color: var(--text-primary);
  font-weight: 600;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.clients-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: middle;
}

.clients-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.015);
  color: var(--text-primary);
}

/* Menu Builder layout */
.menu-type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background-color: var(--bg-primary);
  margin: 15px 20px 0 20px;
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.menu-type-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
}

.menu-type-btn.active {
  background-color: var(--bg-tertiary);
  color: var(--accent-cyan);
}

.menu-tree-wrapper {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Toggle Switch styling */
.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-tertiary);
  transition: .3s;
  border-radius: 20px;
  border: 1px solid var(--border-light);
}

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .slider {
  background-color: var(--accent-cyan);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(18px);
  background-color: var(--bg-primary);
}

.label-text {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Rights Modal Custom */
.modal-lg {
  max-width: 750px;
  width: 90%;
}

.modal-body-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.rights-modal-info {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 15px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  font-size: 0.85rem;
}

.rights-selection-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 15px;
  background-color: var(--bg-input);
}

.rights-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 10px;
}

.rights-quick-actions {
  display: flex;
  gap: 12px;
}

.rights-tree-checklist {
  max-height: 280px;
  overflow-y: auto;
  padding-right: 5px;
}

.status-badge.muted {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

.btn-sm {
  font-size: 0.75rem;
  padding: 6px 12px;
}

/* Glow effects & micro-animations */
.btn-glow {
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}
.btn-glow:hover {
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.4);
}

/* Drag & Drop Reordering styles */
.menu-tree-node.parent.drag-over {
  border: 1.5px dashed var(--accent-cyan) !important;
  background-color: rgba(6, 182, 212, 0.05) !important;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.15);
}

.node-child.drag-over {
  border: 1px dashed var(--accent-cyan) !important;
  background-color: rgba(6, 182, 212, 0.05) !important;
}

.menu-tree-node.parent, .node-child {
  user-select: none;
  cursor: grab;
  transition: opacity 0.2s, background-color 0.2s, border-color 0.2s;
}

.menu-tree-node.parent:active, .node-child:active {
  cursor: grabbing;
}

/* Edit / Delete Buttons inside menu items */
.edit-menu-btn:hover i {
  color: var(--accent-cyan) !important;
}

.delete-menu-btn:hover i {
  color: var(--danger) !important;
}

/* Login Screen CSS Styles */
.login-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  background-image: radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.08) 0%, transparent 80%);
}

.login-card {
  width: 420px;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: loginFadeIn 0.5s ease-out;
}

@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo-icon {
  width: 48px;
  height: 48px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 8px var(--accent-cyan-glow));
  margin-bottom: 12px;
}

.login-header h2 {
  font-size: 1.6rem;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.input-wrapper input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.input-wrapper input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

/* Client Portal Styles */
.client-portal-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background-color: var(--bg-primary);
}

.portal-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  padding: 15px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.portal-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.portal-user-meta {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.user-badge i {
  width: 13px;
  height: 13px;
}

.portal-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 70px);
  width: 100%;
}

.portal-sidebar {
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  padding: 25px 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.portal-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

.portal-menu-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portal-parent-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portal-parent-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 4px 0;
}

.portal-parent-label i {
  width: 14px;
  height: 14px;
  color: var(--accent-purple);
}

.portal-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 8px 12px 8px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.portal-sub-item:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

.portal-sub-item.active {
  color: var(--text-primary);
  background-color: rgba(6, 182, 212, 0.08);
  border-left: 2.5px solid var(--accent-cyan);
}

.portal-sub-item i {
  width: 13px;
  height: 13px;
}

.portal-content {
  background-color: var(--bg-primary);
  height: 100%;
  width: 100%;
  overflow: hidden;
  padding: 20px;
}

.iframe-container {
  width: 100%;
  height: 100%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.portal-welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  text-align: center;
  padding: 40px;
}

.portal-welcome-state h2 {
  font-size: 1.8rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.portal-welcome-state p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Direct Page Parent Links in Portal Sidebar */
.portal-parent-direct-link {
  padding-left: 12px !important;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
}

.portal-parent-direct-link i {
  width: 14px !important;
  height: 14px !important;
  color: var(--accent-purple) !important;
}

.portal-parent-direct-link:hover {
  color: var(--text-primary) !important;
  background-color: rgba(255, 255, 255, 0.03) !important;
}

.portal-parent-direct-link.active {
  color: var(--text-primary) !important;
  background-color: rgba(6, 182, 212, 0.08) !important;
  border-left: 2.5px solid var(--accent-cyan) !important;
}

/* Status Badge Utility Styles */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.cyan {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.lead-filter-btn.active {
  background-color: var(--accent-cyan) !important;
  color: #0b0f19 !important;
  font-weight: 700 !important;
}

/* ==========================================
   ACCOUNTS MANAGEMENT SYSTEM STYLES
   ========================================== */
.accounts-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 20px;
  height: calc(100vh - 70px);
  overflow-y: auto;
  box-sizing: border-box;
}

.accounts-header-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 15px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.accounts-nav-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-sub-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.account-sub-tab:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.04);
}

.account-sub-tab.active {
  background-color: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.3);
}

.account-sub-tab i {
  width: 16px;
  height: 16px;
}

.account-panel {
  animation: fadeIn 0.3s ease-out;
}

/* Head Type Badges */
.head-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.head-badge.expense {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.head-badge.income {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.head-badge.asset {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.head-badge.liability {
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

/* Transaction Type Badges */
.tx-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}

.tx-badge.payment {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.tx-badge.receipt {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Sub-head item pill tag */
.sub-head-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-hover);
  border: 1px solid var(--border-light);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.8rem;
  color: var(--text-primary);
  margin: 2px 4px 2px 0;
}

.sub-head-tag .del-sub-head-btn {
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sub-head-tag .del-sub-head-btn:hover {
  color: #ef4444;
}

/* Financial Report Statements formatting */
.rpt-section-header {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-top: 15px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border-light);
}

.rpt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.88rem;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.05);
}

.rpt-row.master {
  font-weight: 600;
  color: var(--text-primary);
}

.rpt-row.sub {
  padding-left: 15px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.rpt-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  margin-top: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  border-top: 2px solid var(--border-light);
  border-bottom: 2px double var(--border-light);
}

/* ==========================================
   MOBILE & TABLET RESPONSIVE DESIGN SYSTEM
   ========================================== */

/* 1. Universal Layout & Touch Tweaks for Mobile & Tablet */
@media (max-width: 1024px) {
  body {
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh;
  }
  
  .app-wrapper {
    height: auto !important;
    min-height: 100vh;
    overflow-y: auto !important;
  }

  .tab-content {
    overflow-y: auto !important;
    height: auto !important;
  }

  .tab-pane {
    height: auto !important;
    min-height: calc(100vh - 65px);
  }
}

/* 2. Top Header Navigation on Mobile (<= 768px) */
@media (max-width: 768px) {
  .top-nav {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px !important;
    height: auto !important;
    min-height: 60px;
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
  }

  .logo {
    font-size: 1rem !important;
  }

  .top-nav-status {
    margin-left: auto;
    gap: 8px !important;
  }

  .status-indicator {
    padding: 4px 8px !important;
    font-size: 0.7rem !important;
  }

  /* Touch-friendly horizontal scrolling navigation tabs on phones */
  .nav-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-tabs::-webkit-scrollbar {
    display: none;
  }

  .nav-tab {
    flex: 0 0 auto;
    padding: 6px 12px !important;
    font-size: 0.8rem !important;
    white-space: nowrap;
  }

  /* Responsive dropdown menu on touch screens */
  .nav-dropdown-menu {
    position: fixed !important;
    top: 105px !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
    z-index: 1001;
  }
}

/* 3. SQL Query Runner Layout on Mobile (<= 768px) */
@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr !important;
    height: auto !important;
    overflow-y: auto !important;
  }

  .sidebar {
    height: auto !important;
    max-height: 250px;
    border-right: none !important;
    border-bottom: 1px solid var(--border-light);
  }

  .main-content {
    height: auto !important;
    min-height: 500px;
  }
}

/* 4. Client Details, Marketing & Accounts Modules on Mobile (<= 768px) */
@media (max-width: 768px) {
  .client-details-container, 
  .menu-builder-container {
    padding: 12px !important;
    grid-template-columns: 1fr !important;
  }

  /* Form and grid vertical stacking for Accounts */
  #acc-panel-master-sub-heads > div,
  #acc-panel-payment-methods > div,
  #acc-panel-financial-reports > div:nth-child(3) {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
  }

  .accounts-header-card {
    padding: 8px 10px !important;
  }

  /* Accounts Sub-tabs touch-scrollable on mobile */
  .accounts-nav-pills {
    overflow-x: auto;
    white-space: nowrap;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .account-sub-tab {
    flex: 0 0 auto;
    font-size: 0.8rem !important;
    padding: 6px 12px !important;
  }

  /* Financial Summary KPI Cards Grid on Mobile */
  #acc-panel-financial-reports > div:nth-child(2) {
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)) !important;
    gap: 10px !important;
  }
}

/* 5. Touch-friendly Inputs & Mobile Forms (<= 480px) */
@media (max-width: 480px) {
  input, select, textarea, button {
    font-size: 16px !important; /* Prevents auto-zoom on mobile safari/chrome */
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .modal-save-actions {
    flex-direction: column-reverse;
    width: 100%;
  }

  .modal-save-actions button {
    width: 100%;
  }
}

/* 6. Responsive Data Tables & Horizontal Smooth Scrolling */
.clients-grid-wrapper {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border-radius: var(--radius-md);
}

.clients-table {
  min-width: 650px;
}

@media (max-width: 768px) {
  .clients-table th, 
  .clients-table td {
    padding: 8px 10px !important;
    font-size: 0.8rem !important;
  }
}

/* 7. Modals on Mobile Devices */
@media (max-width: 768px) {
  .modal, .modal-lg {
    width: 94vw !important;
    max-width: 94vw !important;
    max-height: 90vh !important;
    margin: 10px !important;
    padding: 15px !important;
    overflow-y: auto !important;
  }

  .modal-header h3 {
    font-size: 1.05rem !important;
  }
}

/* 8. Portal & Client Interface Mobile Tweaks */
@media (max-width: 768px) {
  .portal-container {
    flex-direction: column !important;
  }

  .portal-sidebar {
    width: 100% !important;
    height: auto !important;
    max-height: 200px;
    overflow-y: auto;
  }

  .portal-content {
    flex: 1;
    min-height: 400px;
  }
}

/* ==========================================
   AUTHENTICATION & LOGIN SCREEN STYLES
   ========================================== */
.login-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-primary, #0b0f19);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 20px;
  box-sizing: border-box;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 35px 30px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
}

.login-header {
  text-align: center;
  margin-bottom: 25px;
}

.login-logo-icon {
  width: 40px;
  height: 40px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 10px var(--accent-cyan-glow));
  margin-bottom: 12px;
}

.login-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 6px 0;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper i {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-wrapper input {
  padding-left: 40px !important;
  width: 100%;
}

/* Card Container Layout */
.clients-list-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.clients-grid-wrapper {
  overflow-x: auto;
  max-width: 100%;
}

.clients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  table-layout: auto;
}

.clients-table th {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.clients-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  vertical-align: middle;
}

.clients-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* ==========================================
   EXECUTIVE CONTROL DASHBOARD STYLING
   ========================================== */

.dashboard-wrapper {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-welcome-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, rgba(17, 24, 39, 0.9) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px 30px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

.welcome-user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.welcome-avatar {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.welcome-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.welcome-title-row h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.welcome-sub {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 4px 0 0 0;
}

.welcome-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-date-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Dashboard Hero Metrics Grid */
.dashboard-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
}

.dash-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-cyan { background: rgba(6, 182, 212, 0.12); color: var(--accent-cyan); border: 1px solid rgba(6, 182, 212, 0.2); }
.icon-purple { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; border: 1px solid rgba(139, 92, 246, 0.2); }
.icon-blue { background: rgba(59, 130, 246, 0.12); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.2); }
.icon-emerald { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); border: 1px solid rgba(16, 185, 129, 0.2); }
.icon-amber { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.2); }

.card-glow-cyan { border-left: 3px solid var(--accent-cyan); }
.card-glow-purple { border-left: 3px solid #8b5cf6; }
.card-glow-blue { border-left: 3px solid #3b82f6; }
.card-glow-emerald { border-left: 3px solid var(--accent-emerald); }
.card-glow-amber { border-left: 3px solid var(--accent-amber); }

.dash-card-info {
  display: flex;
  flex-direction: column;
}

.dash-card-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.dash-card-info h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin: 4px 0 2px 0;
}

.dash-card-sub {
  font-size: 0.75rem;
  font-weight: 500;
}

.text-cyan { color: var(--accent-cyan) !important; }
.text-purple { color: #8b5cf6 !important; }
.text-blue { color: #3b82f6 !important; }
.text-emerald { color: var(--accent-emerald) !important; }
.text-amber { color: var(--accent-amber) !important; }

/* Dashboard 2-Column Panels Grid */
.dashboard-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .dashboard-grid-2col {
    grid-template-columns: 1fr;
  }
  .dashboard-welcome-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}

.dash-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.dash-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-light);
}

.dash-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.dash-panel-body {
  padding: 20px;
}

/* Lead Sources Chips */
.sources-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #182235;
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
}

.source-name {
  color: var(--text-primary);
  font-weight: 500;
}

.source-count {
  background: var(--accent-cyan);
  color: #000;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 10px;
}

/* Follow-up Reminders Widget */
.dash-reminders-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent-amber);
  border-radius: var(--radius-sm);
}

.reminder-notes {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.reminder-time {
  font-size: 0.75rem;
  color: var(--accent-amber);
  margin-top: 4px;
}

/* Financial Summary Grid */
.financial-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.fin-summary-box {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  text-align: center;
}

.fin-box-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 600;
}

.fin-summary-box h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 4px 0 0 0;
}

.box-income h4 { color: var(--accent-emerald); }
.box-expense h4 { color: #ef4444; }
.box-net h4 { color: var(--accent-cyan); }

.payment-balances-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.pm-balance-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #182235;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.pm-name {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.pm-bal {
  font-weight: 700;
  color: #fff;
}

/* System Stats Grid */
.system-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.sys-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.sys-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sys-stat-card h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin: 2px 0 0 0;
}

.quick-shortcuts-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.query-code-snippet {
  background: #0d131f;
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', monospace;
  font-size: 0.78rem;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* ==========================================
   MOBILE HORIZONTAL OVERFLOW PREVENTIONS
   ========================================== */
html, body {
  max-width: 100% !important;
  overflow-x: hidden !important;
  width: 100% !important;
}

.app-wrapper,
.app-layout,
.app-container,
.main-content,
.tab-content,
.tab-pane,
.accounts-container,
.client-details-container,
.menu-builder-container,
.marketing-container,
.portal-container,
.portal-content {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    position: relative;
  }

  .app-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .app-topbar,
  .top-nav,
  .card-header,
  .dash-panel-header,
  .accounts-header-card,
  .login-card {
    max-width: 100% !important;
    box-sizing: border-box !important;
    flex-wrap: wrap !important;
  }

  .clients-list-card,
  .stat-card,
  .clients-grid-wrapper {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Contain table scroll strictly inside its inner wrapper */
  .clients-grid-wrapper,
  .table-responsive {
    overflow-x: auto !important;
    max-width: 100% !important;
    display: block !important;
    width: 100% !important;
    -webkit-overflow-scrolling: touch;
  }

  .modal,
  .modal-lg {
    max-width: 95vw !important;
    width: 95vw !important;
    box-sizing: border-box !important;
  }
}

/* ==========================================
   ULTRA-PREMIUM ACCOUNT ENTRY VOUCHER MODAL
   ========================================== */
.voucher-modal {
  width: 660px !important;
  max-width: 95vw !important;
  height: auto !important;
  max-height: 90vh !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(6, 182, 212, 0.15) !important;
  border-radius: 16px !important;
  background: linear-gradient(145deg, #111827 0%, #0d131f 100%) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  margin: auto 0 !important;
}

.voucher-modal form {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.voucher-modal-header {
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.voucher-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.voucher-icon-glow {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(6, 182, 212, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.25);
  flex-shrink: 0;
}

.voucher-header-title h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.voucher-header-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.voucher-modal .modal-body-content {
  overflow: hidden !important;
  padding: 18px 20px !important;
  max-height: none !important;
}

.voucher-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}

.voucher-form-grid .form-group input,
.voucher-form-grid .form-group select {
  background: var(--bg-input) !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  font-size: 0.88rem !important;
}

.voucher-amount-input-group {
  display: flex;
  align-items: center;
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.voucher-amount-input-group:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.3);
}

.voucher-currency-tag {
  padding: 7px 12px;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  font-weight: 800;
  font-size: 0.85rem;
  border-right: 1px solid rgba(6, 182, 212, 0.25);
}

.voucher-amount-input-group input {
  border: none !important;
  background: transparent !important;
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  color: #fff !important;
  padding: 7px 12px !important;
  width: 100%;
}

.voucher-amount-input-group input:focus {
  box-shadow: none !important;
}

.voucher-modal .modal-footer {
  padding: 12px 20px !important;
  background: rgba(0, 0, 0, 0.25) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  flex-shrink: 0 !important;
}

.voucher-modal .modal-footer .btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 8px 18px !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
  height: auto !important;
}

/* ==========================================
   MARKETING LEAD TRACKER REDESIGN STYLES
   ========================================== */

/* 1. Three-Dots Context Menu & Dropdown */
.actions-dropdown-container {
  position: relative;
  display: inline-block;
}

.three-dots-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.three-dots-btn:hover, .three-dots-btn.active {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

.actions-dropdown-menu {
  position: absolute;
  right: 0;
  top: 36px;
  z-index: 1200;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  min-width: 180px;
  padding: 6px 0;
  display: none;
  flex-direction: column;
  backdrop-filter: blur(12px);
}

.actions-dropdown-menu.open {
  display: flex;
  animation: fadeInDown 0.15s ease-out forwards;
}

.actions-dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.actions-dropdown-menu button:hover {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
}

.actions-dropdown-menu button.danger-item:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* 2. Right-Side Slide-Over Drawer */
.side-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.side-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-light);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1301;
}

.side-drawer-backdrop.open .side-drawer {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

/* 3. Searchable Area Select Component */
.area-suggestions-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1100;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  max-height: 180px;
  overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  margin-top: 2px;
}

.area-suggestion-item {
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.area-suggestion-item:hover, .area-suggestion-item.highlighted {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
}

/* 4. Sales Rep Multi-Select Chips */
.rep-chip-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.rep-chip-badge:hover {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
}

.rep-chip-badge.selected {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.25);
}

.rep-chip-badge .chip-icon {
  width: 12px;
  height: 12px;
}

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

/* Call Response Option Cards */
.call-response-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-primary);
  transition: all 0.2s ease;
  user-select: none;
}

.call-response-card:hover {
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(255, 255, 255, 0.06);
}

.call-response-card:has(input:checked) {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE SYSTEM (Command Post UI Overhaul)
   ========================================================================== */

/* Mobile Sidebar Backdrop Overlay */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

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

/* --------------------------------------------------------------------------
   1. Mobile Screens (<= 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {

  /* Global Container Reset */
  html, body {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .app-wrapper,
  .app-layout {
    flex-direction: column !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    overflow: hidden !important;
    position: relative !important;
  }

  /* Off-Canvas Mobile Drawer Sidebar */
  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -290px !important;
    width: 280px !important;
    min-width: 280px !important;
    height: 100vh !important;
    z-index: 1000 !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.75);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  .mobile-sidebar-open .app-sidebar {
    transform: translateX(290px) !important;
  }

  /* Main Area Takes Full Viewport Width */
  .app-main {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  /* Touch-Optimized Topbar */
  .app-topbar {
    padding: 10px 12px !important;
    min-height: 56px !important;
    height: auto !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    justify-content: space-between !important;
    border-bottom: 1px solid var(--border-light) !important;
    background-color: var(--bg-secondary) !important;
  }

  .topbar-title {
    gap: 10px !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  .topbar-title h2 {
    font-size: 0.95rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #toggle-sidebar-btn {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    min-width: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border-light) !important;
    color: var(--accent-cyan) !important;
  }

  .topbar-actions {
    gap: 8px !important;
  }

  .status-indicator {
    display: none !important; /* Saved space for mobile title */
  }

  #dev-logout-btn {
    padding: 8px 12px !important;
    font-size: 0.78rem !important;
    min-height: 38px !important;
  }

  /* Scrollable Workspace Tab Content */
  .tab-content {
    padding: 12px 10px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 !important;
  }

  .tab-pane {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Executive Dashboard Cards */
  .dashboard-welcome-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 16px 14px !important;
  }

  .welcome-user-info {
    gap: 12px !important;
  }

  .welcome-title-row {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .welcome-title-row h1 {
    font-size: 1.25rem !important;
  }

  .welcome-actions {
    width: 100% !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .welcome-actions .btn,
  .live-date-pill {
    flex: 1 !important;
    justify-content: center !important;
    min-height: 40px !important;
    font-size: 0.82rem !important;
  }

  .dashboard-metrics-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .dash-card {
    padding: 14px !important;
  }

  .dash-card-info h3 {
    font-size: 1.45rem !important;
  }

  /* Toolbars, Search Bars & Filters */
  .filter-bar, 
  .table-toolbar, 
  .accounts-toolbar, 
  .marketing-toolbar, 
  .action-toolbar,
  .search-bar-row,
  .marketing-header-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .filter-bar input, 
  .filter-bar select, 
  .table-toolbar input, 
  .table-toolbar select, 
  .accounts-toolbar input, 
  .accounts-toolbar select,
  .search-input-group input,
  .marketing-toolbar input,
  .marketing-toolbar select {
    width: 100% !important;
    min-height: 44px !important;
    font-size: 0.9rem !important;
  }

  .filter-actions, 
  .toolbar-buttons, 
  .btn-group {
    display: flex !important;
    width: 100% !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }

  .filter-actions .btn, 
  .toolbar-buttons .btn, 
  .btn-group .btn {
    flex: 1 !important;
    justify-content: center !important;
    min-height: 44px !important;
    font-size: 0.85rem !important;
  }

  /* Form Grids & Voucher Modal Layouts */
  .form-grid, 
  .voucher-form-grid, 
  .grid-4, 
  .grid-3, 
  .grid-2, 
  .form-row,
  .client-form-grid,
  .lead-form-grid {
    grid-template-columns: 1fr !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .form-group {
    width: 100% !important;
  }

  .form-group label {
    font-size: 0.86rem !important;
    margin-bottom: 6px !important;
    display: block !important;
  }

  .form-group input, 
  .form-group select, 
  .form-group textarea {
    width: 100% !important;
    min-height: 44px !important;
    font-size: 0.95rem !important; /* Prevents auto-zoom on iOS/Android */
    padding: 10px 12px !important;
    box-sizing: border-box !important;
    border-radius: var(--radius-sm) !important;
  }

  /* Data Tables Touch Horizontal Scroll Container */
  .table-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: var(--radius-md) !important;
    margin-bottom: 15px !important;
    border: 1px solid var(--border-light) !important;
    box-shadow: var(--shadow-sm) !important;
  }

  .table-container::-webkit-scrollbar {
    height: 6px;
  }

  .table-container::-webkit-scrollbar-thumb {
    background: rgba(6, 182, 212, 0.4);
    border-radius: 4px;
  }

  .data-table {
    min-width: 680px !important; /* Guarantees readable columns without squeezing */
    width: 100% !important;
  }

  .data-table th {
    padding: 12px 10px !important;
    font-size: 0.8rem !important;
    white-space: nowrap !important;
  }

  .data-table td {
    padding: 12px 10px !important;
    font-size: 0.85rem !important;
  }

  .data-table td .btn, 
  .table-actions .btn,
  .action-btns .btn {
    padding: 6px 10px !important;
    font-size: 0.78rem !important;
    min-height: 38px !important;
  }

  .badge {
    white-space: nowrap !important;
    font-size: 0.74rem !important;
    padding: 3px 8px !important;
  }

  /* Modals & Backdrop Overlays */
  .modal-backdrop {
    padding: 10px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .modal, 
  .voucher-modal {
    width: 96vw !important;
    max-width: 96vw !important;
    margin: 0 auto !important;
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 14px !important;
    box-sizing: border-box !important;
  }

  .modal-header, 
  .voucher-modal-header {
    padding: 14px 16px !important;
  }

  .modal-header h3, 
  .voucher-header-title h3 {
    font-size: 1.15rem !important;
  }

  .modal-body-content {
    padding: 14px 16px !important;
    overflow-y: auto !important;
    max-height: 65vh !important;
    flex: 1 !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .modal-footer {
    padding: 12px 16px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .modal-footer .btn {
    flex: 1 !important;
    justify-content: center !important;
    min-height: 44px !important;
    font-size: 0.9rem !important;
  }

  /* Query Runner Responsive */
  .query-workspace {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .query-sidebar, 
  .sql-editor-container {
    width: 100% !important;
  }

  #sql-editor {
    min-height: 150px !important;
    font-size: 13px !important;
  }

  /* Client Portal Mobile */
  .portal-container {
    flex-direction: column !important;
  }

  .portal-sidebar {
    width: 100% !important;
    height: auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-light) !important;
  }

  .portal-content {
    width: 100% !important;
    height: calc(100vh - 120px) !important;
  }
}

/* --------------------------------------------------------------------------
   2. Small Smartphones (<= 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {

  .login-card {
    padding: 24px 16px !important;
    max-width: 100% !important;
    border-radius: 14px !important;
  }

  .login-header h2 {
    font-size: 1.35rem !important;
  }

  .login-header p {
    font-size: 0.8rem !important;
  }

  .dash-card-icon {
    width: 40px !important;
    height: 40px !important;
  }

  .dash-card-icon i {
    width: 20px !important;
    height: 20px !important;
  }
}

/* --------------------------------------------------------------------------
   3. Tablets (769px to 1024px)
   -------------------------------------------------------------------------- */
@media (min-width: 769px) and (max-width: 1024px) {
  
  .dashboard-metrics-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .app-sidebar {
    width: 220px !important;
    min-width: 220px !important;
  }
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-label-row label {
  margin: 0;
}

.add-host-ip-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-color, #333);
  border-radius: 6px;
  color: var(--accent-cyan, #22d3ee);
}

.add-host-ip-btn:hover {
  background-color: var(--bg-tertiary);
}







