:root {
  --primary: #ff3c00;
  --primary-gradient: linear-gradient(135deg, #ff3c00 0%, #ff5722 100%);
  --dark: #1a1a1a;
  --bg: #EEE9E3;
  --glass: rgba(255, 255, 255, 0.8);
  --sidebar-bg: #111111;
  --main-bg: #fdfdfd;
  --card-bg: #ffffff;
  --text-dark: #0a0a0a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-width: 280px;
  --sidebar-width-collapsed: 80px;
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--main-bg);
  color: var(--text-dark);
  display: flex;
  overflow: hidden;
}

/* Login page styling (match admin.html) */
body.crm-logged-out {
  background-color: var(--bg);
}

body.crm-logged-out .main {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

body.crm-logged-out .content {
  height: 100vh;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Persistent navbar and blobs */
.background-blobs {
  display: block;
}

body.crm-logged-out .sidebar,
body.crm-logged-out .topbar {
  display: none !important;
}


.background-blobs {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.4;
}

.blob-1 {
  width: 300px;
  height: 300px;
  background: #FF3C00;
  top: -100px;
  right: -100px;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: #FF5722;
  bottom: -200px;
  left: -100px;
}

.login-card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  padding: 40px;
  border-radius: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.5);
  opacity: 0;
  transform: translateY(20px);
}

.logo {
  text-align: center;
  margin-bottom: 30px;
}

.logo img {
  width: 120px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 24px;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--dark);
}

.form-input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  border: 2px solid #ddd;
  background: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  outline: none;
  transition: all 0.3s ease;
}

.form-input:focus {
  border-color: var(--primary);
  background: #fff;
}

/* Password field with inline actions (show/hide, generate) */
.password-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.password-input-wrap .form-input,
.password-input-wrap input {
  flex: 1;
  min-width: 0;
}

.password-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.password-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.password-generate-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0 14px;
  height: 44px;
  font-size: 13px;
}

.login-btn {
  width: 100%;
  padding: 16px;
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 10px 20px rgba(255, 60, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(255, 60, 0, 0.3);
}

.error-msg {
  color: #ff3333;
  font-size: 0.85rem;
  text-align: center;
  margin-top: 16px;
  display: none;
  font-weight: 700;
}

.login-help {
  margin-top: 14px;
  color: rgba(17, 17, 17, 0.8);
  font-weight: 650;
  font-size: 0.85rem;
  text-align: center;
}

.inline-loader {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}

.loader {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 4px solid rgba(255, 60, 0, 0.18);
  border-top-color: #ff3c00;
  border-right-color: #ff7740;
  animation: crm-spin 0.8s linear infinite;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

@keyframes crm-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Role-based sidebar visibility (prevents flash for employees) */
html[data-crm-role="employee"] a.nav-link[href="crm-employees.html"],
html[data-crm-role="employee"] a.nav-link[href="crm-applicants.html"],
html[data-crm-role="employee"] a.nav-link[href="crm-reports.html"],
html[data-crm-role="employee"] a.nav-link[href="crm-users.html"] {
  display: none;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  height: 100vh;
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: width 0.25s ease;
  flex-shrink: 0;
}

.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px;
  margin-bottom: 24px;
}

.brand-logo {
  width: 120px;
  filter: brightness(0) invert(1);
  transition: opacity 0.2s ease, width 0.2s ease;
}

.sidebar.collapsed .brand-logo {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.mobile-only {
  display: none;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--primary);
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.10);
}

.nav-text {
  font-weight: 700;
}

.sidebar.collapsed .nav-text {
  display: none;
}

.sidebar-foot {
  padding: 12px 10px 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar.collapsed .pill {
  display: none;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 900;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.topbar.is-scrolled {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.92);
}

.topbar.is-hidden {
  transform: translateY(-110%);
}

.title {
  font-weight: 900;
  font-size: 20px;
}

.subtitle {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  margin-top: 2px;
}

.content {
  padding: 22px;
  overflow: auto;
  height: 100%;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 900;
}

.muted {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: end;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
  color: #111;
}

.field input,
.field select,
.search {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  outline: none;
  font-weight: 600;
}

.field input:focus,
.field select:focus,
.search:focus {
  border-color: rgba(255, 60, 0, 0.35);
  box-shadow: 0 0 0 4px rgba(255, 60, 0, 0.08);
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 16px rgba(0, 0, 0, 0.06);
}

.btn.primary {
  border: none;
  background: var(--primary-gradient);
  color: #fff;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.table-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 13px;
}

.table-search {
  width: 100%;
  padding: 11px 16px 11px 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  outline: none;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s ease;
  background: #fff;
}

.table-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 60, 0, 0.08);
}

.table-filter {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  outline: none;
  font-weight: 700;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 150px;
}

.table-filter:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 60, 0, 0.08);
}

.msg {
  grid-column: 1 / -1;
  font-weight: 700;
  font-size: 13px;
}

.msg.error {
  color: #b91c1c;
}

.msg.ok {
  color: #166534;
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.table-wrap {
  position: relative;
  /* Remove overflow-x: auto to prevent clipping of absolute menus */
  /* Instead, we handle horizontal scrolling on the table itself if needed, or allow it to pop out */
  overflow: visible; 
  border-radius: 12px;
  background: #fff;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}

.table td input,
.table td select {
  font-size: 13px;
  min-width: 120px;
}

.table th {
  text-align: left;
  font-weight: 900;
  color: #111;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.empty {
  padding: 14px 6px;
  display: none;
}

/* Keep old card width rule for logged-in layouts (login card is overridden above) */

.chat {
  margin-top: 14px;
}

.chat-split {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
}

.chat-threads {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  height: 430px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-threads-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-threads-list {
  overflow: auto;
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  padding-top: 8px;
}

.chat-thread {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: #fff;
  border-radius: 12px;
  padding: 10px 10px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-thread:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 16px rgba(0, 0, 0, 0.05);
}

.chat-thread.active {
  border-color: rgba(255, 60, 0, 0.35);
  box-shadow: 0 0 0 4px rgba(255, 60, 0, 0.06);
}

.chat-thread-title {
  font-weight: 900;
  font-size: 13px;
}

.chat-thread-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 2px;
}

.chat-pane {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  height: 430px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Chat Enhancements */
.chat-split {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  height: 700px;
}

.chat-threads {
  border-right: 1px solid var(--border);
  background: #fcfcfd;
  display: flex;
  flex-direction: column;
}

.chat-threads-head {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.chat-threads-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-thread {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: none;
  background: transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  margin-bottom: 4px;
  position: relative;
}

.chat-thread:hover {
  background: rgba(0, 82, 255, 0.04);
}

.chat-thread.active {
  background: rgba(0, 82, 255, 0.08);
}

.chat-thread-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-thread-info {
  flex: 1;
  min-width: 0;
}

.chat-thread-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-dark);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-thread-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 0 3px rgba(0, 82, 255, 0.1);
  display: none;
}

.chat-thread.unread .chat-thread-dot {
  display: block;
}

.chat-thread.unread .chat-thread-title {
  font-weight: 850;
}

.chat-type-tag {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 800;
}

.chat-type-tag.group {
  background: #eff6ff;
  color: #3b82f6;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  background: #fff;
}

.chat-pane-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8fafc;
  border: none;
  border-radius: 0;
  margin-top: 0;
}

.chat-row {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.chat-row.own {
  align-self: flex-end;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.chat-row:not(.own) .chat-bubble {
  background: #fff;
  border-bottom-left-radius: 4px;
  color: var(--text-dark);
}

.chat-row.own .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  gap: 8px;
}

.chat-row.own .chat-meta {
  justify-content: flex-end;
}

.chat-form {
  padding: 20px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

.chat-form input {
  flex: 1;
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 12px;
  background: #f8fafc;
  transition: all 0.2s;
}

.chat-form input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 82, 255, 0.1);
}

.chat-people-wrap {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 8px;
}

.chat-people-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-people-item {
  text-align: left;
}

@media (max-width: 1100px) {
  .grid4 {
    grid-template-columns: 1fr 1fr;
  }

  .search {
    min-width: 180px;
    flex: 1;
  }

  .chat-split {
    grid-template-columns: 1fr;
  }

  .chat-threads {
    height: auto;
    max-height: 240px;
  }

  .chat-pane {
    height: 460px;
  }
}

.dashboard-timer-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
}

.dashboard-timer {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text-dark);
}

.dashboard-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    z-index: 1000;
    transition: left 0.25s ease;
  }

  .sidebar.active {
    left: 0;
  }

  .main {
    margin-left: 0;
  }

  .mobile-only {
    display: inline-flex;
  }
}

/* Notifications */
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.notification-bell {
  position: relative;
  cursor: pointer;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-bell i {
  font-size: 22px;
  color: var(--primary);
}

.notification-bell:hover {
  background: #fff;
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  border-color: var(--primary);
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 2px 8px rgba(255, 60, 0, 0.4);
}

.notification-badge.show {
  opacity: 1;
  transform: scale(1);
}

.nav-badge {
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  box-shadow: 0 2px 5px rgba(255, 60, 0, 0.2);
}

.notifications-dropdown {
  position: absolute;
  top: 70px;
  right: 20px;
  width: 320px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.notifications-dropdown.active {
  display: flex;
}

.notifications-head {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notifications-list {
  max-height: 300px;
  overflow-y: auto;
}

.notification-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

.notification-item:hover {
  background: #f8fafc;
}

.notification-item.unread {
  background: rgba(255, 60, 0, 0.03);
}

.notification-item-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}

.notification-item-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-item-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Custom Confirm Dialog */
.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.confirm-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.confirm-card {
  background: #fff;
  padding: 32px;
  border-radius: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

.confirm-overlay.active .confirm-card {
  transform: scale(1);
}

.confirm-icon {
  width: 64px;
  height: 64px;
  background: rgba(255, 60, 0, 0.1);
  color: var(--primary);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 20px;
}

.confirm-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--dark);
}

.confirm-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 28px;
  font-weight: 500;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.confirm-btn {
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: 14px;
}

.btn-cancel {
  background: #f1f5f9;
  color: #64748b;
}

.btn-cancel:hover {
  background: #e2e8f0;
}

.btn-confirm {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 10px 20px rgba(255, 60, 0, 0.15);
}

.btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(255, 60, 0, 0.2);
}

/* --- LOADER STYLES --- */
.inline-loader {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  flex-direction: column;
  gap: 12px;
}

.loader {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 60, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.inline-loader::after {
  content: "Loading…";
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* --- ACTION MENU & DROPDOWN --- */
.action-menu {
  position: relative;
  display: inline-flex;
}

.dot-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
  border-radius: 10px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.dot-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--primary);
  border-color: rgba(255, 60, 0, 0.1);
  transform: translateY(-1px);
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  min-width: 180px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  display: none;
  padding: 6px;
  transform-origin: top right;
  animation: dropdownFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.dropdown-menu.active {
  display: block;
}

/* Elevate the parent container when dropdown is active */
.action-menu:has(.dropdown-menu.active) {
  z-index: 10000;
}

/* Alternative for browsers that don't support :has */
.row-active {
  z-index: 10000 !important;
  position: relative;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-dark);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.dropdown-item i {
  font-size: 14px;
  width: 18px;
  text-align: center;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.dropdown-item:hover {
  background: var(--primary-gradient);
  color: #fff;
}

.dropdown-item:hover i {
  color: #fff;
}

.dropdown-item.delete {
  color: #ef4444;
}

.dropdown-item.delete:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.dropdown-item.delete:hover i {
  color: #b91c1c;
}

.td-action {
  text-align: center;
  width: 60px;
}

.text-center {
  text-align: center;
}

/* --- CRM MODAL --- */
.crm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.crm-modal-overlay.active {
  display: flex;
}

.crm-modal-card {
  background: rgba(255, 255, 255, 0.95);
  width: 100%;
  max-width: 700px;
  border-radius: 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  transform: translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.crm-modal-overlay.active .crm-modal-card {
  transform: translateY(0);
}

.crm-modal-head {
  padding: 24px 40px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.5);
}

.crm-modal-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--dark);
  letter-spacing: -0.02em;
  margin: 0;
}

.crm-modal-close {
  background: #f1f5f9;
  border: none;
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 20px;
}

.crm-modal-close:hover {
  background: #fee2e2;
  color: #ef4444;
  transform: rotate(90deg);
}

.crm-modal-body {
  padding: 32px 40px;
  overflow-y: auto;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center; /* Centrally align components */
}

#crmModalForm {
  width: 100%;
}

.crm-modal-footer {
  padding: 24px 40px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  background: rgba(248, 250, 252, 0.8);
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.modal-field {
  margin-bottom: 4px;
}

.modal-field.full {
  grid-column: span 2;
}

.modal-field label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.modal-field input, 
.modal-field select, 
.modal-field textarea {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  transition: all 0.2s ease;
  color: var(--dark);
}

.modal-field input:focus, 
.modal-field select:focus, 
.modal-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 60, 0, 0.15);
  background: #fff;
}

.modal-field textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.remarks-section textarea {
  background: #fff;
}

.modal-field.view-only input,
.modal-field.view-only select,
.modal-field.view-only textarea {
  background: #f8fafc;
  border-color: #f1f5f9;
  color: #64748b;
  pointer-events: none;
}

/* Status Pill */
.status-pill {
  display: inline-flex;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.status-pill.lead { background: #e0f2fe; color: #0369a1; }
.status-pill.contacted { background: #fef9c3; color: #854d0e; }
.status-pill.discovery { background: #f3e8ff; color: #6b21a8; }
.status-pill.proposal_sent { background: #dcfce7; color: #15803d; }
.status-pill.negotiation { background: #ffedd5; color: #9a3412; }
.status-pill.approved { background: #dcfce7; color: #166534; font-weight: 950; }
.status-pill.onboarding { background: #ecfeff; color: #0891b2; }
.status-pill.active { background: #f0fdf4; color: #15803d; border: 1px solid #dcfce7; }
.status-pill.invoice_sent { background: #f5f3ff; color: #5b21b6; }
.status-pill.payment_received { background: #f0fdf4; color: #166534; }
.status-pill.completed { background: #f0fdf4; color: #14532d; font-weight: 900; border: 1px solid #bbf7d0; }
.status-pill.lost { background: #fee2e2; color: #b91c1c; }
.status-pill.default { background: #f1f5f9; color: #475569; }

/* Enhanced Modal Controls */
.modal-field select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5' /%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
  appearance: none;
  padding-right: 44px;
}

.modal-field.status-field select {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
}

.modal-field.status-field select option {
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  padding: 10px;
}
