/* AutoPan Omnichannel 5-Column CRM Stylesheet */
:root {
  --bg-app: #fbfbfb;
  --bg-surface: #ffffff;
  --bg-primary-nav: #09090b;
  --bg-hover: #fbfbfb;
  --bg-active: #fbfbfb;
  --bg-input: #fbfbfb;
  
  --primary: #09090b;
  --primary-hover: #18181b;
  --accent-btn: #09090b;
  
  --bubble-in: #ffffff;
  --bubble-in-border: #f0f0f2;
  --bubble-out: #09090b;
  --bubble-out-text: #ffffff;
  
  --text-main: #09090b;
  --text-muted: #71717a;
  --text-subtle: #a1a1aa;
  
  --border: #f0f0f2;
  --online-color: #10b981;
  --danger: #ef4444;
  
  --col-header-height: 60px;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

body, html {
  height: 100%;
  width: 100%;
  background-color: var(--bg-app);
  color: var(--text-main);
  overflow: hidden;
}

/* App Layout */
.crm-app-grid {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background-color: var(--bg-app);
}

.col-primary-nav {
  width: 60px;
  min-width: 60px;
  background-color: var(--bg-primary-nav);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  padding-bottom: 14px;
}

.messenger-view-container {
  display: grid;
  grid-template-columns: 210px 280px 1fr 280px;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.nav-logo {
  height: var(--col-header-height);
  min-height: var(--col-header-height);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
}

.primary-nav-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex: 1;
  width: 100%;
}

.primary-nav-item {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: #a1a1aa;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.15s;
  position: relative;
}

.primary-nav-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.primary-nav-item.active {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.nav-unread-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--online-color);
}

.primary-nav-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.user-avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #27272a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* COLUMN 1: Navigation Filters Sidebar */
.col-nav-sidebar {
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.brand-box {
  height: var(--col-header-height);
  min-height: var(--col-header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.brand-title {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.nav-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-subtle);
  letter-spacing: 0.5px;
  padding: 4px 8px;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-link:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.nav-link.active {
  background-color: var(--bg-active);
  color: var(--primary);
  font-weight: 600;
}

.nav-label-text {
  flex: 1;
  text-align: left;
}

.nav-count {
  font-size: 11.5px;
  color: var(--text-subtle);
  margin-left: auto;
}

.nav-badge {
  background-color: var(--primary);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: auto;
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 2px;
  margin-right: 2px;
}
.dot-all { background-color: var(--text-subtle); }
.dot-agent { background-color: #3b82f6; }
.dot-awaiting { background-color: #f59e0b; }
.dot-paused { background-color: #10b981; }

.agent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.agent-item:hover {
  background-color: var(--bg-hover);
}

.agent-item.active {
  background-color: var(--bg-input);
  font-weight: 600;
  color: var(--text-main);
}

.agent-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #e4e4e7;
  color: #09090b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.agent-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: auto;
}
.agent-status.online { background-color: var(--online-color); }

/* COLUMN 2: Conversation Sidebar */
.col-conv-sidebar {
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.conv-sidebar-header {
  height: var(--col-header-height);
  min-height: var(--col-header-height);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  position: relative;
}

.conv-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
}

.conv-header-title.dropdown-toggle {
  cursor: pointer;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.conv-header-title.dropdown-toggle:hover {
  background-color: var(--bg-hover);
}

.conv-header-title svg {
  color: var(--text-muted);
}

.chevron-down {
  opacity: 0.6;
}

.number-dropdown {
  position: absolute;
  top: 52px;
  left: 12px;
  width: 230px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
}

.dropdown-header {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-subtle);
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.number-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s;
}

.number-item:hover {
  background-color: var(--bg-hover);
}

.number-item.active {
  font-weight: 700;
  background-color: var(--bg-active);
}

.number-val {
  font-family: monospace;
}

.number-tag {
  font-size: 10.5px;
  color: var(--text-muted);
  background-color: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Filter Tags Bar */
.filter-tags-bar {
  padding: 8px 12px 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.15s;
}

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

.filter-red-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #ef4444;
}

.filter-pill-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-pill-tag:hover {
  background-color: var(--bg-hover);
  border-color: #a1a1aa;
}

.filter-pill-tag.active {
  background-color: #09090b;
  color: #ffffff;
  border-color: #09090b;
}

.filter-pill-tag .close-tag {
  font-size: 13px;
  opacity: 0.6;
  padding: 0 2px;
  border-radius: 3px;
}

.filter-pill-tag .close-tag:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.1);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-conversations-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 50px 16px;
  color: var(--text-subtle);
  font-size: 13px;
  font-weight: 500;
}

.empty-conversations-state svg {
  color: var(--text-subtle);
  opacity: 0.5;
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-subtle);
  text-align: center;
  width: 100%;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 14px;
  border-bottom: none;
  background-color: transparent;
  transition: background 0.15s;
}

.conv-item:hover {
  background-color: var(--bg-hover);
}

.conv-item.active {
  background-color: #f2f2f4;
  border-radius: 14px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.conv-details {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.conv-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.conv-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.conv-time {
  font-size: 11px;
  color: var(--text-subtle);
  flex-shrink: 0;
}

.conv-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.conv-snippet {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.unread-badge {
  background-color: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
  flex-shrink: 0;
}

/* COLUMN 3: Centered Main Active Chat Window */
.col-chat-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-app);
  position: relative;
  overflow: hidden;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.empty-card {
  max-width: 360px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--bg-input);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-card h3 {
  font-size: 16px;
  font-weight: 700;
}

.empty-card p {
  color: var(--text-muted);
  font-size: 13px;
}

.active-chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.hidden {
  display: none !important;
}

.chat-header {
  height: var(--col-header-height);
  min-height: var(--col-header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 700;
  font-size: 14px;
}

.user-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

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

.chat-actions {
  display: flex;
  gap: 6px;
}

.action-btn {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.action-btn.close-btn {
  background-color: #09090b;
  color: #fff;
}

/* Centered Chat Content Container */
.chat-center-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100% - var(--col-header-height));
  width: 100%;
  max-width: 100%;
  margin: 0;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.messages-container::-webkit-scrollbar {
  width: 5px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--border);
}

.date-separator {
  align-self: center;
  background-color: #e4e4e7;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
  margin: 6px 0;
}

.message-bubble {
  max-width: 65%;
  padding: 9px 13px;
  border-radius: 12px;
  word-wrap: break-word;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-bubble.inbound {
  align-self: flex-start;
  background-color: var(--bubble-in);
  color: var(--text-main);
  border: 1px solid var(--bubble-in-border);
  border-bottom-left-radius: 2px;
}

.message-bubble.outbound {
  align-self: flex-end;
  background-color: var(--bubble-out);
  color: var(--bubble-out-text);
  border-bottom-right-radius: 2px;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10px;
  opacity: 0.8;
  align-self: flex-end;
}

.status-icon {
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
  letter-spacing: -1px;
  display: inline-block;
}

.status-icon.status-sending {
  opacity: 0.5;
  color: #a1a1aa;
}

.status-icon.status-sent {
  color: #a1a1aa;
  opacity: 0.85;
}

.status-icon.status-delivered {
  color: #ffffff;
  opacity: 0.95;
}

.status-icon.status-read {
  color: #10b981;
  opacity: 1;
  font-weight: 800;
}

.media-image {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  margin-top: 4px;
  object-fit: cover;
}

/* Chat Floating Input Container */
.chat-input-container {
  padding: 10px 16px;
}

.input-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-card textarea {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-size: 13.5px;
  resize: none;
  min-height: 52px;
  max-height: 120px;
}

.input-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.left-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.send-btn {
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* COLUMN 4: Details, Tasks & Notes Sidebar */
.col-details-sidebar {
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.details-header {
  height: var(--col-header-height);
  min-height: var(--col-header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.details-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Tasks Section */
.tasks-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tasks-title {
  font-size: 13px;
  font-weight: 700;
}

.tasks-count-badge {
  background-color: var(--bg-input);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  color: var(--text-muted);
}

.task-add-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-add-box input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-size: 12px;
}

.task-add-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.priority-select {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  padding: 2px 4px;
  outline: none;
  cursor: pointer;
}

.add-task-btn {
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  transition: all 0.15s;
}

.task-card.completed {
  opacity: 0.55;
  text-decoration: line-through;
}

.task-card input[type="checkbox"] {
  margin-top: 2px;
  cursor: pointer;
}

.task-title {
  flex: 1;
  word-break: break-word;
}

.task-del-btn {
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.15s;
}

.task-card:hover .task-del-btn {
  opacity: 1;
}

/* Fixed Bottom 1/3 Notes Section */
.notes-bottom-section {
  height: 33.33%;
  min-height: 200px;
  max-height: 300px;
  border-top: 1px solid var(--border);
  background-color: var(--bg-surface);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex-shrink: 0;
}

.details-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.details-user-meta {
  display: flex;
  flex-direction: column;
}

.details-name {
  font-weight: 700;
  font-size: 14px;
}

.edit-hint {
  font-size: 10.5px;
  color: var(--text-subtle);
}

.editable-field {
  cursor: pointer;
  padding: 1px 2px;
  margin: -1px -2px;
  transition: all 0.15s;
  outline: none;
  border-bottom: 1px dashed transparent;
}

.editable-field:hover {
  background-color: transparent;
  border-bottom: 1px dashed var(--text-subtle);
}

.editable-field:focus {
  background-color: transparent;
  border-bottom: 2px solid var(--primary);
  color: var(--text-main);
  border-radius: 0;
  box-shadow: none;
}

.details-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.details-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.details-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
}

.details-row .label {
  color: var(--text-muted);
}

.details-row .val {
  font-weight: 600;
}

.badge {
  background-color: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
}

/* Notes Section */
.notes-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notes-title {
  font-size: 13px;
  font-weight: 700;
}

.note-input-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-input-box textarea {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-size: 12px;
  resize: none;
  height: 50px;
}

.save-note-btn {
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  align-self: flex-end;
  cursor: pointer;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-card {
  background-color: var(--bg-input);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
}

.note-author {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(9, 9, 11, 0.4);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background-color: var(--bg-surface);
  border-radius: 12px;
  width: 90%;
  max-width: 420px;
  padding: 18px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  border: none;
  cursor: pointer;
}

.primary-btn {
  background-color: var(--primary);
  color: #fff;
}

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

/* Responsive Grid */
@media (max-width: 1200px) {
  .crm-app-grid {
    grid-template-columns: 60px 200px 260px 1fr;
  }
  .col-details-sidebar {
    display: none;
  }
}

@media (max-width: 900px) {
  .crm-app-grid {
    grid-template-columns: 60px 240px 1fr;
  }
  .col-nav-sidebar {
    display: none;
  }
}

/* CONTACTS DATABASE VIEW STYLES */
.contacts-view-container {
  flex: 1;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
}

.contacts-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--col-header-height);
  min-height: var(--col-header-height);
  padding: 0 32px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  width: 100%;
}

.contacts-view-content {
  flex: 1;
  min-height: 0;
  padding: 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.contacts-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.contacts-page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.header-user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.header-user-profile:hover {
  background-color: var(--bg-hover);
}

.user-profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #09090b;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-profile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.contacts-badge {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
  color: var(--text-muted);
}

.contacts-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contacts-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  width: 300px;
  box-shadow: var(--shadow-sm);
}

.contacts-search-box input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-size: 12.5px;
}

.btn-contacts-primary {
  background-color: #09090b;
  color: #fff;
  border: none;
  border-radius: 8px;
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s;
}

.btn-contacts-primary:hover {
  opacity: 0.9;
}

.btn-contacts-secondary {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: none;
  transition: background 0.15s;
}

.btn-contacts-secondary:hover {
  background-color: var(--bg-hover);
}

/* Contacts Metrics Grid */
.contacts-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.metric-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: none;
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.metric-trend.positive {
  font-size: 11px;
  font-weight: 700;
  color: #10b981;
  background-color: #ecfdf5;
  padding: 2px 6px;
  border-radius: 6px;
}

.metric-trend.neutral {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  background-color: #f3f4f6;
  padding: 2px 6px;
  border-radius: 6px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.metric-sub {
  font-size: 11.5px;
  color: var(--text-subtle);
}

/* Contacts Filter Toolbar (Single Row) */
.contacts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
  border-bottom: none;
}

.toolbar-left-group, .toolbar-right-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-search-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 36px;
  padding: 0 12px;
  width: 300px;
  box-shadow: none;
}

.toolbar-search-box input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text-main);
}

.cmd-k-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-subtle);
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.toolbar-filter-btn {
  background-color: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: none;
  transition: all 0.15s;
}

.toolbar-filter-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
  border-color: #d4d4d8;
}

/* Source Filter Segmented Buttons */
.source-segmented-group {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  height: 36px;
  box-shadow: none;
}

.source-segmented-btn {
  background: none;
  border: none;
  outline: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0 12px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.source-segmented-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.source-segmented-btn.active {
  background-color: var(--text-main);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Segmented Control Switcher */
.toolbar-segmented-control {
  display: flex;
  align-items: center;
  background-color: #f4f4f5;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}

.segmented-btn {
  background: none;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.segmented-btn.active {
  background-color: #ffffff;
  color: var(--text-main);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Contacts Table */
.contacts-table-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.contacts-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}

.contacts-table th {
  background-color: var(--bg-hover);
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.sortable-th:hover {
  background-color: var(--bg-input);
  color: var(--text-main);
}

.th-content {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sort-icon-svg {
  opacity: 0.35;
  transition: transform 0.2s ease, opacity 0.15s;
}

.sortable-th:hover .sort-icon-svg {
  opacity: 0.9;
}

.sortable-th.active-sort .sort-icon-svg {
  opacity: 1;
  color: var(--text-main);
}

.sortable-th.sort-asc .sort-icon-svg {
  transform: rotate(180deg);
}

.sortable-th.sort-desc .sort-icon-svg {
  transform: rotate(0deg);
}

.contacts-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.contacts-table tr:hover {
  background-color: #fbfbfb;
}

.contact-user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.contact-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
}

.contact-status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.contact-status-tag.client {
  background-color: #ecfdf5;
  color: #047857;
}

.contact-status-tag.lead {
  background-color: #fffbeb;
  color: #b45309;
}

.contact-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}

.contact-action-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

/* Drag & Drop Import Dropzone */
.import-dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  background-color: var(--bg-hover);
  cursor: pointer;
  transition: all 0.2s ease;
}

.import-dropzone:hover, .import-dropzone.dragover {
  border-color: var(--text-main);
  background-color: var(--bg-surface);
}

.file-preview-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 14px;
}

/* Export Button Animations */
.btn-contacts-secondary.exporting {
  background-color: var(--bg-hover);
  color: var(--text-main);
  pointer-events: none;
  opacity: 0.85;
}

.btn-contacts-secondary.exporting .export-icon {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.btn-contacts-secondary.export-success {
  background-color: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
  transition: all 0.25s ease;
}

/* Outer White Frame Container - Fitted Viewport Height */
.kanban-outer-frame {
  flex: 1;
  min-height: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Kanban Board Grid (inside Outer Frame) */
.kanban-board-container {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  overflow-x: auto;
}

.kanban-column {
  background-color: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 220px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.kanban-column-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.stage-dot.new-dot { background-color: #6b7280; }
.stage-dot.qualified-dot { background-color: #3b82f6; }
.stage-dot.proposal-dot { background-color: #f59e0b; }
.stage-dot.contract-dot { background-color: #8b5cf6; }
.stage-dot.won-dot { background-color: #10b981; }

.kanban-count-badge {
  font-size: 11px;
  font-weight: 700;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 10px;
}

.kanban-column-sum {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.kanban-cards-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.kanban-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.kanban-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.kanban-card-menu {
  font-size: 11px;
  color: var(--text-subtle);
  cursor: pointer;
}

.kanban-client-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-client-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

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

.kanban-price-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.kanban-manager {
  display: flex;
  align-items: center;
  gap: 6px;
}

.manager-avatar {
  width: 20px;
  height: 20px;
  background-color: var(--text-main);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.manager-name {
  font-size: 11.5px;
  color: var(--text-subtle);
}

.kanban-task-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 6px;
}

.kanban-task-pill.green {
  background-color: #ecfdf5;
  color: #047857;
}
