:root {
  --primary: #2563eb;
  --secondary: #0f172a;
  --bg: #f8fafc;
  --card: #ffffff;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --muted: #64748b;
  --line: #dbe4ef;
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --secondary: #e2e8f0;
  --bg: #020617;
  --card: #0f172a;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --muted: #94a3b8;
  --line: #1e293b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 5% 10%, rgba(37, 99, 235, 0.12), transparent 38%),
    radial-gradient(circle at 95% 5%, rgba(15, 23, 42, 0.12), transparent 30%),
    var(--bg);
  color: var(--secondary);
  font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
  min-height: 100vh;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
  font-weight: 600;
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

#menuToggle {
  position: relative;
  width: 44px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.menu-toggle-icon {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.menu-toggle-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
}

#menuToggle.is-open .menu-toggle-open {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}

#menuToggle.is-open .menu-toggle-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.sidebar {
  background: linear-gradient(165deg, #0f172a, #112544);
  color: #e2e8f0;
  padding: 20px 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  top: auto;
  max-height: none;
  overflow: visible;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 700;
}

.brand p {
  margin: 0;
  color: #94a3b8;
  font-size: 13px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-label {
  margin: 14px 8px 6px;
  font-size: 12px;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.08em;
}

.nav-item {
  text-decoration: none;
  color: #d6deea;
  padding: 10px 12px;
  border-radius: 10px;
  transition: 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(37, 99, 235, 0.26);
  color: #fff;
}

.workspace {
  padding: 18px 20px 26px;
  min-width: 0;
  max-width: 100%;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
  position: sticky;
  top: 8px;
  z-index: 20;
  min-width: 0;
  background: color-mix(in srgb, var(--bg) 86%, transparent 14%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  backdrop-filter: blur(8px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 12px;
  padding-left: 10px;
  flex-wrap: nowrap;
}

.topbar-actions > .icon-btn,
.topbar-actions > .quick-add-menu,
.topbar-actions > .profile-menu {
  margin: 0;
}

.topbar-actions > .alerts-menu {
  margin: 0;
}

.icon-btn,
.profile-btn,
.quick-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px 13px;
  font-weight: 600;
  color: var(--secondary);
  cursor: pointer;
  min-height: 46px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.icon-btn:hover,
.profile-btn:hover,
.quick-btn:hover {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.quick-btn {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.btn-icon,
.btn-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  font-size: 14px;
}

.badge {
  background: var(--danger);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
  box-shadow: 0 6px 14px rgba(220, 38, 38, 0.28);
}

.badge.is-empty {
  background: #cbd5e1;
  box-shadow: none;
}

.badge-floating {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 25px;
  height: 25px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--card);
  margin: 0;
  box-shadow: 0 10px 18px rgba(220, 38, 38, 0.34);
}

.alerts-menu {
  position: relative;
}

.alerts-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-right: 20px;
}

.alerts-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(380px, calc(100vw - 32px));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  z-index: 45;
}

.alerts-dropdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.alerts-dropdown-head strong {
  font-size: 14px;
}

.alerts-dropdown-head span {
  font-size: 12px;
  color: var(--muted);
}

.alerts-dropdown-body {
  max-height: min(70vh, 420px);
  overflow-y: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.alert-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-left: 5px solid #16a34a;
  border-radius: 12px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  background: #f8fbff;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.alert-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.alert-item.severity-high {
  border-left-color: #dc2626;
  background: #fff5f5;
}

.alert-item.severity-medium {
  border-left-color: #d97706;
  background: #fffaf0;
}

.alert-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.alert-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--secondary);
}

.alert-item-count {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
}

.alert-item.severity-high .alert-item-count {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

.alert-item.severity-medium .alert-item-count {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
}

.alert-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
}

.alert-item-severity {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}

.alert-item.severity-high .alert-item-severity {
  color: #b91c1c;
}

.alert-item.severity-medium .alert-item-severity {
  color: #b45309;
}

.alert-item-action {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.alert-item-cta {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border-radius: 999px;
  padding: 3px 8px;
  letter-spacing: 0.01em;
}

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

#globalSearch {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 16px 12px 42px;
  background: color-mix(in srgb, var(--card) 88%, #eef4ff 12%);
  color: var(--secondary);
  min-height: 46px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

#globalSearch::placeholder {
  color: color-mix(in srgb, var(--muted) 88%, transparent 12%);
}

#globalSearch:focus {
  outline: none;
  border-color: #4c6ef5;
  box-shadow: 0 0 0 2px rgba(76, 110, 245, 0.12);
  background: var(--card);
}

.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 5;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.search-results button {
  width: 100%;
  text-align: left;
  border: 0;
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
}

.search-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-type {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-results button:hover {
  background: #eff6ff;
}

.profile-menu {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 188px;
  justify-content: space-between;
}

.profile-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--primary) 12%, var(--card) 88%);
  flex-shrink: 0;
}

.profile-copy {
  display: grid;
  text-align: left;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.profile-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

#profileUserName {
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-caret {
  color: var(--muted);
  font-size: 12px;
}

.quick-add-menu {
  position: relative;
}

.quick-add-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.quick-add-menu.is-open .quick-add-trigger {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.quick-add-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 248px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16), 0 8px 18px rgba(15, 23, 42, 0.08);
  padding: 8px;
  display: grid;
  gap: 4px;
  z-index: 45;
  transform-origin: top right;
  animation: quickAddFadeSlide 0.2s ease;
}

.quick-add-dropdown[hidden] {
  display: none !important;
}

.quick-add-item {
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 10px 11px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  text-align: left;
  color: var(--secondary);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  border-bottom: 1px solid #f0f2f5;
}

.quick-add-item:last-child {
  border-bottom: 0;
}

.quick-add-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.14), rgba(37, 99, 235, 0.04));
  font-size: 15px;
}

.quick-add-item-copy {
  display: grid;
  gap: 2px;
}

.quick-add-item strong {
  font-size: 14px;
  line-height: 1.25;
}

.quick-add-item-copy span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.quick-add-item:hover {
  background: #f5f7fb;
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.quick-add-item:focus-visible {
  outline: none;
  background: #f5f7fb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

@keyframes quickAddFadeSlide {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  width: 44px;
  padding: 0;
}

.theme-toggle-glyph {
  font-size: 18px;
  line-height: 1;
  color: #334155;
  transition: transform 0.22s ease, color 0.22s ease, opacity 0.22s ease;
}

.theme-toggle.is-dark .theme-toggle-glyph {
  color: #f8fafc;
  transform: rotate(16deg) scale(1.05);
}

.profile-menu-list {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  min-width: 170px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.16);
  padding: 6px;
  display: none;
  gap: 4px;
  z-index: 40;
}

.profile-menu-list.is-open {
  display: grid;
}

.profile-menu-list[hidden] {
  display: none !important;
}

.profile-menu-item {
  border: 0;
  background: transparent;
  color: var(--secondary);
  text-align: left;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 600;
  cursor: pointer;
}

.profile-menu-item:hover {
  background: #eff6ff;
}

.profile-menu-item-danger {
  color: #b91c1c;
}

.profile-menu-item-danger:hover {
  background: #fee2e2;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
  align-items: stretch;
}

.dashboard-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  position: sticky;
  top: 84px;
  z-index: 18;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent 12%);
  backdrop-filter: blur(6px);
}

.dashboard-tab-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--secondary);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s ease;
}

.dashboard-tab-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.dashboard-tab-btn.active {
  background: #0f3db7;
  border-color: #0f3db7;
  color: #fff;
  box-shadow: 0 12px 22px rgba(15, 61, 183, 0.3);
  transform: translateY(-1px);
}

.dashboard-last-updated {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  animation: riseIn 0.45s ease both;
  height: 100%;
}

.kpi-card[data-kpi-target] {
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.kpi-card[data-kpi-target]:hover {
  border-color: #93c5fd;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.kpi-card[data-kpi-target]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.26), 0 12px 22px rgba(15, 23, 42, 0.08);
}

.kpi-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  white-space: normal;
  text-overflow: clip;
  word-break: normal;
  overflow-wrap: anywhere;
}

.kpi-card h2 {
  margin: 8px 0 5px;
  font-size: 28px;
}

.trend {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.72;
}

.trend.up {
  color: var(--success);
}

.trend.down {
  color: var(--danger);
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-top: 12px;
  min-width: 0;
  max-width: 100%;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.main-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.main-grid > .panel,
.main-grid.two-col > .panel {
  margin-top: 0;
  height: 100%;
}

.panel:hover {
  border-color: #c7d8ee;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.pipeline-controls {
  display: grid;
  grid-template-columns: 1fr 190px;
  gap: 8px;
  margin-bottom: 10px;
}

.pipeline-controls input,
.pipeline-controls select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--card);
  color: var(--secondary);
}

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 12px;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.dashboard-pipeline-scroll {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 2px;
}

.kanban::-webkit-scrollbar {
  height: 10px;
}

.kanban::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 999px;
}

.kanban::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 999px;
}

.kanban.is-dragging .dropzone {
  border-color: #c7ddf7;
  background: #f8fbff;
}

.kanban-col {
  background: #f8fbff;
  border: 1px solid #d7e3f1;
  border-top: 3px solid #94a3b8;
  border-radius: 12px;
  padding: 10px;
  min-height: 220px;
  scroll-snap-align: start;
}

.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.kanban-col-head h4 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.stage-indicator {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}

.stage-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #1e3a8a;
  background: #dbeafe;
}

.column-add-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--secondary);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.column-add-btn:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.kanban-col.stage-new-lead .stage-indicator {
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.22);
}

.kanban-col.stage-contacted .stage-indicator {
  background: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.22);
}

.kanban-col.stage-consultation .stage-indicator {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
}

.kanban-col.stage-documents-pending .stage-indicator {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}

.kanban-col.stage-processing .stage-indicator {
  background: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

.kanban-col.stage-proposal-sent .stage-indicator {
  background: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
}

.kanban-col.stage-converted .stage-indicator {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.22);
}

.kanban-col.stage-lost .stage-indicator {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.22);
}

.kanban-col > h4 {
  font-size: 14px;
  margin-bottom: 8px;
}

.dropzone {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px dashed transparent;
  border-radius: 10px;
  padding: 2px;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.dropzone.is-drag-over {
  border-color: #93c5fd;
  background: #eff6ff;
}

.empty-dropzone {
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  display: grid;
  gap: 7px;
}

.empty-dropzone strong {
  font-size: 13px;
  color: var(--secondary);
}

.empty-dropzone p {
  margin: 0;
}

.empty-add-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--secondary);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  justify-self: center;
}

.empty-add-btn:hover {
  background: #eff6ff;
}

.lead-card {
  position: relative;
}

.lead-card {
  background: #fff;
  border: 1px solid #d9e2ef;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  box-shadow: 0 7px 14px rgba(15, 23, 42, 0.05);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.lead-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.12);
  border-color: #bfd2eb;
  background: #fbfdff;
}

.lead-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35), 0 12px 22px rgba(15, 23, 42, 0.12);
}

.lead-card.is-dragging {
  opacity: 0.55;
  transform: rotate(1deg);
}

.lead-card.drop-placed {
  animation: cardDropPulse 0.28s ease;
}

.lead-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.lead-card h5 {
  margin: 0 0 4px;
  font-size: 14px;
}

.card-menu-wrap {
  position: relative;
}

.card-menu-toggle {
  border: 1px solid #dbe4ef;
  background: #f8fbff;
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
}

.card-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 140px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.12);
  padding: 5px;
  display: grid;
  gap: 2px;
  z-index: 20;
}

.card-menu[hidden] {
  display: none !important;
}

.card-menu-item {
  border: 0;
  background: transparent;
  color: var(--secondary);
  text-align: left;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.card-menu-item:hover {
  background: #eff6ff;
}

.card-menu-item.is-danger {
  color: #b91c1c;
}

.card-menu-item.is-danger:hover {
  background: #fee2e2;
}

.lead-card p {
  margin: 0 0 4px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
}

.lead-card-meta,
.lead-card-status-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.lead-card-meta-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.urgency-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
}

.urgency-chip.is-overdue {
  background: #fee2e2;
  color: #b91c1c;
}

.urgency-chip.is-today {
  background: #ffedd5;
  color: #9a3412;
}

.urgency-chip.is-upcoming {
  background: #dbeafe;
  color: #1e3a8a;
}

.urgency-chip.is-none {
  background: #e2e8f0;
  color: #334155;
}

.priority-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
}

.priority-chip.is-high {
  background: #fee2e2;
  color: #b91c1c;
}

.priority-chip.is-medium {
  background: #fff7ed;
  color: #b45309;
}

.priority-chip.is-normal {
  background: #dcfce7;
  color: #166534;
}

.flag-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
}

.flag-chip.is-overdue {
  background: #fee2e2;
  color: #b91c1c;
}

.flag-chip.is-unassigned {
  background: #fff7ed;
  color: #b45309;
}

.lead-card-owner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
}

.owner-avatar {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  background: #dbeafe;
  color: #1e3a8a;
}

.lead-card-owner.is-unassigned {
  color: #b91c1c;
}

.lead-card-owner.is-unassigned .owner-avatar {
  background: #fee2e2;
  color: #b91c1c;
}

.lead-card small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  line-height: 1.35;
}

.followup-row {
  border-radius: 8px;
  padding: 2px 6px;
  margin-bottom: 3px;
}

.followup-row.is-overdue {
  color: #b91c1c;
  background: #fee2e2;
  font-weight: 700;
}

.followup-row.is-today {
  color: #9a3412;
  background: #ffedd5;
  font-weight: 700;
}

.followup-row.is-upcoming {
  color: #1e3a8a;
  background: #dbeafe;
}

.lead-card-quick-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-quick-icon {
  border: 1px solid #dbe4ef;
  background: #f8fbff;
  color: #334155;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.card-quick-icon:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  transform: translateY(-1px);
}

.lead-card.is-overdue {
  border-color: #fca5a5;
  background: #fff1f2;
}

.kanban-col.stage-new-lead {
  border-top-color: #94a3b8;
}

.kanban-col.stage-contacted {
  border-top-color: #60a5fa;
}

.kanban-col.stage-consultation {
  border-top-color: #22c55e;
}

.kanban-col.stage-documents-pending {
  border-top-color: #f59e0b;
}

.kanban-col.stage-processing {
  border-top-color: #3b82f6;
}

.kanban-col.stage-proposal-sent {
  border-top-color: #6366f1;
}

.kanban-col.stage-converted {
  border-top-color: #16a34a;
}

.kanban-col.stage-lost {
  border-top-color: #ef4444;
}

@keyframes cardDropPulse {
  0% {
    transform: scale(0.98);
  }

  100% {
    transform: scale(1);
  }
}

[data-theme="dark"] .lead-card {
  background: #0b1222;
  border-color: #243347;
}

[data-theme="dark"] .lead-card.is-overdue {
  background: #251218;
  border-color: #7f1d1d;
}

.followup-pill {
  display: none;
  margin-top: 7px;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
}

.lead-card.is-overdue .followup-pill {
  display: inline-block;
}

.main-grid.dashboard-section[data-dashboard-section~="operations"] {
  grid-template-columns: minmax(230px, 1.05fr) minmax(230px, 1fr) minmax(260px, 1.2fr);
}

.main-grid.two-col {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.main-grid.two-col > .panel.is-wide {
  grid-column: 1 / -1;
}

.main-grid.two-col.dashboard-section[data-dashboard-section~="operations"] {
  grid-template-columns: minmax(260px, 0.95fr) minmax(300px, 1.25fr);
}

.task-list,
.note-list,
.feed-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-list li,
.note-list li,
.feed-list li {
  background: #f8fbff;
  border: 1px solid #dde7f4;
  border-radius: 10px;
  padding: 8px 10px;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.task-list li:hover,
.note-list li:hover,
.feed-list li:hover {
  border-color: #c6d9f1;
  background: #f2f8ff;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.task-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.task-toggle {
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #1e3a8a;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.task-toggle:hover {
  border-color: #93c5fd;
  background: #dbeafe;
  transform: translateY(-1px);
}

.task-list li.is-complete {
  opacity: 0.9;
}

.task-list li.is-complete > span:nth-child(2) {
  text-decoration: line-through;
  color: var(--muted);
}

.feed-event {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: start;
}

.feed-event p {
  margin: 0;
  font-size: 12px;
  color: var(--secondary);
  line-height: 1.45;
}

.feed-event small {
  color: var(--muted);
  font-size: 11px;
}

.feed-action {
  color: #1d4ed8;
  font-weight: 700;
}

.feed-case {
  color: #065f46;
  font-weight: 700;
  background: #dcfce7;
  border-radius: 999px;
  padding: 1px 6px;
}

.feed-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #1e3a8a;
  background: #dbeafe;
}

.note-list a {
  text-decoration: none;
  color: inherit;
}

.note-list li {
  padding: 0;
  overflow: hidden;
}

.note-alert-link {
  display: grid;
  gap: 4px;
  width: 100%;
  height: 100%;
  padding: 9px 10px;
}

.note-alert-link:hover {
  background: rgba(219, 234, 254, 0.35);
}

.note-list .severity-high {
  border-left: 4px solid #dc2626;
  background: #fff5f5;
}

.note-list .severity-medium {
  border-left: 4px solid #d97706;
  background: #fffaf0;
}

.note-alert-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}

.note-alert-text {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.note-alert-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
}

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  margin-right: 8px;
}

.tag.pending {
  background: #e2e8f0;
  color: #334155;
}

.tag.progress {
  background: #dbeafe;
  color: #1e40af;
}

.tag.overdue {
  background: #fee2e2;
  color: #b91c1c;
}

.tag.done {
  background: #dcfce7;
  color: #166534;
}

.progress-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, minmax(80px, 1fr));
  gap: 8px;
}

.case-progress-summary {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.case-progress-summary strong {
  font-size: 13px;
  color: #1e3a8a;
}

.case-progress-bar {
  height: 10px;
  border-radius: 999px;
  background: #dbeafe;
  overflow: hidden;
}

.case-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #22c55e, #1d4ed8);
  transition: width 0.24s ease;
}

.progress-steps li {
  text-align: center;
  border-radius: 10px;
  border: 1px solid #d5e2f0;
  padding: 10px 6px;
  font-size: 12px;
  background: #f8fbff;
}

.progress-steps li.done {
  background: #dcfce7;
  border-color: #86efac;
}

.progress-steps li.active {
  background: #dbeafe;
  border-color: #93c5fd;
}

.progress-steps li.pending {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.status-legend {
  margin-top: 10px;
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 6px;
}

.dot.done {
  background: var(--success);
}

.dot.active {
  background: var(--primary);
}

.dot.pending {
  background: #64748b;
}

.chart-row {
  height: 170px;
  display: grid;
  grid-template-columns: repeat(4, minmax(50px, 1fr));
  align-items: end;
  gap: 10px;
}

.bar {
  height: var(--h);
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  border-radius: 10px 10px 0 0;
  color: #fff;
  font-size: 12px;
  display: grid;
  place-items: end center;
  padding-bottom: 8px;
}

.is-hidden-by-role {
  display: none !important;
}

.analytics-stack {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.analytics-controls {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.analytics-filters {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.analytics-filters > * {
  min-width: 0;
}

.analytics-filters select,
.analytics-filters input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--card);
  color: var(--secondary);
  width: 100%;
}

.analytics-filters .action-btn {
  width: auto;
  white-space: nowrap;
}

.analytics-export-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.export-menu {
  position: relative;
}

.export-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.export-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.14);
  padding: 6px;
  z-index: 24;
  display: grid;
  gap: 4px;
}

.export-menu-list[hidden] {
  display: none !important;
}

.export-menu-item {
  border: 0;
  background: transparent;
  color: var(--secondary);
  border-radius: 8px;
  padding: 7px 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.export-menu-item:hover {
  background: #eff6ff;
}

.automation-run-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.mini-chart-block h4 {
  margin: 0 0 8px;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.mini-chart-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: color-mix(in srgb, var(--card) 88%, #f8fbff 12%);
  height: 272px;
  display: flex;
  flex-direction: column;
}

.mini-chart-block > .mini-chart-grid,
.mini-chart-block > .line-chart-grid,
.mini-chart-block > .pipeline-grid {
  flex: 1;
  min-height: 0;
}

.mini-chart-grid {
  display: grid;
  gap: 8px;
}

.mini-chart-row {
  display: grid;
  grid-template-columns: 120px 1fr 44px 52px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.mini-chart-label {
  font-weight: 600;
}

.mini-chart-row .bar-wrap {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.mini-chart-row .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
}

.mini-chart-pct {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  text-align: right;
}

.mini-chart-row.tone-0 .bar-fill {
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
}

.mini-chart-row.tone-1 .bar-fill {
  background: linear-gradient(90deg, #0ea5e9, #0284c7);
}

.mini-chart-row.tone-2 .bar-fill {
  background: linear-gradient(90deg, #06b6d4, #0e7490);
}

.mini-chart-row.tone-3 .bar-fill {
  background: linear-gradient(90deg, #22c55e, #15803d);
}

.mini-chart-row.tone-4 .bar-fill {
  background: linear-gradient(90deg, #f59e0b, #b45309);
}

.mini-chart-row.tone-5 .bar-fill {
  background: linear-gradient(90deg, #8b5cf6, #6d28d9);
}

.line-chart-grid {
  display: block;
  min-height: 120px;
  padding: 6px;
  border-radius: 10px;
  background: repeating-linear-gradient(
    to top,
    rgba(148, 163, 184, 0.14) 0,
    rgba(148, 163, 184, 0.14) 1px,
    transparent 1px,
    transparent 22px
  );
}

.monthly-chart-wrap {
  position: relative;
  padding-top: 8px;
}

.monthly-chart-line {
  position: absolute;
  inset: 8px 0 24px;
  width: 100%;
  height: calc(100% - 32px);
  pointer-events: none;
}

.monthly-chart-line polyline {
  fill: none;
  stroke: #1d4ed8;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.monthly-chart-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  align-items: end;
  gap: 8px;
  min-height: 150px;
}

.line-point {
  position: relative;
  display: grid;
  gap: 5px;
  justify-items: center;
}

.line-value {
  font-size: 11px;
  color: #1e293b;
  font-weight: 700;
}

.line-point .line-bar {
  width: 80%;
  border-radius: 8px 8px 0 0;
  min-height: 8px;
  background: linear-gradient(180deg, #93c5fd, #2563eb);
  border: 1px solid rgba(37, 99, 235, 0.16);
}

.line-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #1d4ed8;
  border: 2px solid #dbeafe;
  transform: translate(-50%, -50%);
}

.automation-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

#dashboardAutomationStatus.status-chip {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #e2e8f0;
  color: #334155;
  text-transform: capitalize;
}

#dashboardAutomationStatus.status-chip.is-ok {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

#dashboardAutomationStatus.status-chip.is-warn {
  background: #ffedd5;
  border-color: #fdba74;
  color: #9a3412;
}

#dashboardAutomationStatus.status-chip.is-fail {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.line-point small {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* ── History / Timeline ──────────────────────────────── */
.history-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.history-event {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  padding-bottom: 16px;
}

.history-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  flex-shrink: 0;
  border: 2px solid var(--card);
}

.history-icon.icon-lead    { background: #dbeafe; color: #1d4ed8; }
.history-icon.icon-case    { background: #dcfce7; color: #16a34a; }
.history-icon.icon-task    { background: #fef9c3; color: #a16207; }
.history-icon.icon-document { background: #f3e8ff; color: #7c3aed; }
.history-icon.icon-payment { background: #d1fae5; color: #065f46; }
.history-icon.icon-checklist { background: #e0f2fe; color: #0369a1; }

.history-body {
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}

.history-body strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.history-body p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.history-meta {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

/* ── Counselor Performance table ─────────────────────── */
#dashboardCounselorPerformance {
  display: grid;
  gap: 8px;
}

.counselor-card-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #f8fbff;
  display: grid;
  gap: 6px;
}

.counselor-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.counselor-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.counselor-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 8px;
  font-size: 11px;
  color: var(--muted);
}

.counselor-metrics strong {
  color: var(--secondary);
  font-weight: 700;
}

.counselor-row {
  display: grid;
  grid-template-columns: 38px 1fr 56px 56px 74px 84px 92px 62px;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  min-width: 660px;
}

.rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 11px;
  font-weight: 700;
}

.counselor-row.header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.counselor-row .rate-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #dcfce7;
  color: #166534;
}

.counselor-row .rate-pill.low {
  background: #fee2e2;
  color: #b91c1c;
}

.counselor-row .rate-pill.mid {
  background: #ffedd5;
  color: #9a3412;
}

.counselor-row .rate-pill.high {
  background: #dcfce7;
  color: #166534;
}

.perf-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.perf-pill.good {
  background: #dcfce7;
  color: #166534;
}

.perf-pill.average {
  background: #ffedd5;
  color: #9a3412;
}

.perf-pill.poor {
  background: #fee2e2;
  color: #b91c1c;
}

.pipeline-grid {
  display: grid;
  gap: 8px;
  max-height: 100%;
  overflow-y: auto;
}

.pipeline-row {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 6px;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.pipeline-row.severity-high {
  border-left-color: #dc2626;
  background: #fff5f5;
}

.pipeline-row.severity-medium {
  border-left-color: #d97706;
  background: #fffaf0;
}

.pipeline-row.severity-low {
  border-left-color: #16a34a;
  background: #f0fdf4;
}

.pipeline-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
}

.pipeline-link {
  text-decoration: none;
  color: inherit;
}

.pipeline-link-cta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
}

.pipeline-link-cta::after {
  content: "->";
  font-size: 11px;
}

.pipeline-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.pipeline-count {
  font-weight: 700;
  color: var(--primary);
}

.pipeline-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.log-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.log-status.severity-high {
  background: #fee2e2;
  color: #b91c1c;
}

.log-status.severity-medium {
  background: #ffedd5;
  color: #9a3412;
}

.log-status.severity-low {
  background: #dcfce7;
  color: #166534;
}

.log-time {
  font-size: 11px;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  place-items: center;
  z-index: 20;
}

.modal.show {
  display: grid;
}

.modal-card {
  background: #fff;
  border-radius: 14px;
  width: min(500px, calc(100vw - 24px));
  padding: 16px;
}

.quick-form {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quick-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--card);
  color: var(--secondary);
}

.action-btn,
.close-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
}

.action-btn-automation {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border-color: transparent;
}

.action-btn-automation:hover {
  background: linear-gradient(135deg, #6d28d9, #5b21b6);
}

.action-btn-automation:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.close-btn {
  width: 100%;
  margin-top: 12px;
}

.table-wrap {
  overflow-x: auto;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 10px;
  margin-bottom: 10px;
}

.filter-row input,
.filter-row select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--card);
  color: var(--secondary);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: #f1f6ff;
}

.data-table tbody tr.active {
  background: #dbeafe;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pager-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.tab-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.tab-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--secondary);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 600;
}

.tab-btn.active {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.split-line {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

.case-timeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.timeline-node {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--secondary);
  padding: 10px 8px;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.2s ease;
}

.timeline-node:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #94a3b8;
}

.timeline-label {
  font-size: 12px;
  font-weight: 700;
}

.timeline-node.completed {
  border-color: #86efac;
  background: #dcfce7;
}

.timeline-node.completed .timeline-dot {
  background: #16a34a;
}

.timeline-node.current {
  border-color: #93c5fd;
  background: #dbeafe;
}

.timeline-node.current .timeline-dot {
  background: #2563eb;
}

.timeline-node.pending {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.case-timeline.is-updating {
  opacity: 0.75;
  pointer-events: none;
}

/* ── Quick status chips (Tasks) ─────────────────────────── */
.status-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.status-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
  opacity: 0.38;
  background: transparent;
  line-height: 1.5;
}

.status-chip:hover {
  opacity: 0.72;
  transform: translateY(-1px);
}

.status-chip.active {
  opacity: 1;
  cursor: default;
}

.status-chip[data-status="Pending"] {
  color: #64748b;
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.status-chip[data-status="Pending"].active {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.status-chip[data-status="In Progress"] {
  color: #1d4ed8;
  border-color: #93c5fd;
  background: #eff6ff;
}

.status-chip[data-status="In Progress"].active {
  background: #dbeafe;
  border-color: #3b82f6;
}

.status-chip[data-status="Completed"] {
  color: #15803d;
  border-color: #86efac;
  background: #f0fdf4;
}

.status-chip[data-status="Completed"].active {
  background: #dcfce7;
  border-color: #22c55e;
}

.status-chip.is-saving {
  opacity: 0.45;
  pointer-events: none;
}

[data-theme="dark"] .status-chip[data-status="Pending"] {
  color: #94a3b8;
  border-color: #334155;
  background: #1e293b;
}

[data-theme="dark"] .status-chip[data-status="Pending"].active {
  background: #334155;
  border-color: #64748b;
}

[data-theme="dark"] .status-chip[data-status="In Progress"] {
  color: #93c5fd;
  border-color: #1e40af;
  background: #172554;
}

[data-theme="dark"] .status-chip[data-status="In Progress"].active {
  background: #1e3a8a;
  border-color: #3b82f6;
}

[data-theme="dark"] .status-chip[data-status="Completed"] {
  color: #86efac;
  border-color: #14532d;
  background: #052e16;
}

[data-theme="dark"] .status-chip[data-status="Completed"].active {
  background: #14532d;
  border-color: #22c55e;
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at 5% 10%, rgba(59, 130, 246, 0.2), transparent 38%),
    radial-gradient(circle at 95% 5%, rgba(15, 23, 42, 0.22), transparent 30%),
    var(--bg);
}

[data-theme="dark"] .sidebar {
  background: linear-gradient(165deg, #020617, #0b1222);
}

[data-theme="dark"] .task-list li,
[data-theme="dark"] .note-list li,
[data-theme="dark"] .feed-list li {
  background: #111827;
  border-color: #273449;
}

[data-theme="dark"] .dashboard-tab-btn {
  background: #0f172a;
  border-color: #334155;
  color: #dbeafe;
}

[data-theme="dark"] .dashboard-tab-btn:hover {
  background: #1e293b;
  border-color: #475569;
}

[data-theme="dark"] .dashboard-tab-btn.active {
  background: #1e3a8a;
  border-color: #3b82f6;
}

[data-theme="dark"] .dashboard-tabs {
  background: rgba(2, 6, 23, 0.9);
  border-color: #334155;
}

[data-theme="dark"] .dashboard-last-updated {
  color: #94a3b8;
}

[data-theme="dark"] .panel:hover {
  border-color: #334155;
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.55);
}

[data-theme="dark"] .task-toggle {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

[data-theme="dark"] .task-toggle:hover {
  background: #334155;
  border-color: #475569;
}

[data-theme="dark"] .feed-action {
  color: #93c5fd;
}

[data-theme="dark"] .feed-case {
  color: #bbf7d0;
  background: #14532d;
}

[data-theme="dark"] .note-alert-link:hover {
  background: rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .mini-chart-block {
  background: #0f172a;
  border-color: #243347;
}

[data-theme="dark"] .mini-chart-pct {
  color: #94a3b8;
}

[data-theme="dark"] .line-value {
  color: #cbd5e1;
}

[data-theme="dark"] .monthly-chart-line polyline {
  stroke: #60a5fa;
}

[data-theme="dark"] .line-dot {
  background: #60a5fa;
  border-color: #1e293b;
}

[data-theme="dark"] .case-progress-bar {
  background: #1e293b;
}

[data-theme="dark"] .feed-avatar {
  background: #1e3a8a;
  color: #dbeafe;
}

[data-theme="dark"] .automation-summary {
  color: #94a3b8;
}

[data-theme="dark"] .export-menu-list {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .export-menu-item:hover {
  background: #1e293b;
}

[data-theme="dark"] #dashboardAutomationStatus.status-chip {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

[data-theme="dark"] .rank-pill {
  background: #1e3a8a;
  color: #dbeafe;
}

[data-theme="dark"] .pipeline-row.severity-high {
  background: rgba(127, 29, 29, 0.24);
}

[data-theme="dark"] .pipeline-row.severity-medium {
  background: rgba(120, 53, 15, 0.24);
}

[data-theme="dark"] .pipeline-row.severity-low {
  background: rgba(20, 83, 45, 0.24);
}

[data-theme="dark"] .pipeline-link-cta {
  color: #93c5fd;
}

[data-theme="dark"] .log-status.severity-high {
  background: rgba(127, 29, 29, 0.45);
  color: #fecaca;
}

[data-theme="dark"] .log-status.severity-medium {
  background: rgba(120, 53, 15, 0.45);
  color: #fed7aa;
}

[data-theme="dark"] .log-status.severity-low {
  background: rgba(20, 83, 45, 0.45);
  color: #bbf7d0;
}

[data-theme="dark"] .perf-pill.good {
  background: rgba(20, 83, 45, 0.45);
  color: #bbf7d0;
}

[data-theme="dark"] .perf-pill.average {
  background: rgba(120, 53, 15, 0.45);
  color: #fed7aa;
}

[data-theme="dark"] .perf-pill.poor {
  background: rgba(127, 29, 29, 0.45);
  color: #fecaca;
}

[data-theme="dark"] .kanban-col {
  background: #0b1222;
  border-color: #253449;
}

[data-theme="dark"] .kanban::-webkit-scrollbar-track {
  background: #1e293b;
}

[data-theme="dark"] .kanban::-webkit-scrollbar-thumb {
  background: #475569;
}

[data-theme="dark"] .pipeline-controls input,
[data-theme="dark"] .pipeline-controls select,
[data-theme="dark"] .empty-add-btn {
  background: #111827;
  border-color: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .empty-dropzone {
  border-color: #334155;
}

[data-theme="dark"] .stage-count {
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.24);
}

[data-theme="dark"] .column-add-btn {
  background: #111827;
  border-color: #334155;
  color: #dbeafe;
}

[data-theme="dark"] .column-add-btn:hover {
  background: #1e293b;
}

[data-theme="dark"] .card-quick-icon {
  background: #111827;
  border-color: #334155;
  color: #dbeafe;
}

[data-theme="dark"] .card-quick-icon:hover {
  background: #1e293b;
  border-color: #475569;
}

[data-theme="dark"] .followup-row.is-upcoming {
  background: #1e3a8a;
  color: #dbeafe;
}

[data-theme="dark"] .kanban-col.stage-new-lead {
  border-top-color: #94a3b8;
}

[data-theme="dark"] .kanban-col.stage-contacted {
  border-top-color: #60a5fa;
}

[data-theme="dark"] .kanban-col.stage-consultation {
  border-top-color: #22c55e;
}

[data-theme="dark"] .kanban-col.stage-documents-pending {
  border-top-color: #f59e0b;
}

[data-theme="dark"] .kanban-col.stage-processing {
  border-top-color: #3b82f6;
}

[data-theme="dark"] .kanban-col.stage-proposal-sent {
  border-top-color: #818cf8;
}

[data-theme="dark"] .kanban-col.stage-converted {
  border-top-color: #22c55e;
}

[data-theme="dark"] .kanban-col.stage-lost {
  border-top-color: #f87171;
}

[data-theme="dark"] .data-table tbody tr:hover {
  background: #1e293b;
}

[data-theme="dark"] .data-table tbody tr.active {
  background: #1d4ed8;
}

[data-theme="dark"] .tab-btn.active {
  background: #1e3a8a;
  border-color: #3b82f6;
  color: #dbeafe;
}

[data-theme="dark"] .timeline-node.pending {
  background: #0b1222;
  border-color: #243347;
}

[data-theme="dark"] .timeline-node.current {
  background: #1e3a8a;
  border-color: #3b82f6;
}

[data-theme="dark"] .timeline-node.completed {
  background: #14532d;
  border-color: #22c55e;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  .workspace {
    padding: 14px 14px 20px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(200px, 1fr));
  }

  .kanban {
    grid-auto-columns: minmax(230px, 1fr);
  }

  .analytics-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .case-timeline {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 270px;
    transform: translateX(-110%);
    transition: transform 0.22s ease;
    z-index: 30;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    grid-template-columns: auto 1fr;
    row-gap: 8px;
  }

  .dashboard-tabs {
    top: 64px;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
  }

  .alerts-dropdown {
    right: auto;
    left: 0;
  }

  .quick-add-dropdown {
    right: auto;
    left: 0;
    width: min(248px, calc(100vw - 32px));
  }

  .profile-btn,
  #themeToggle {
    display: none;
  }

  .main-grid,
  .main-grid.two-col,
  .progress-steps {
    grid-template-columns: 1fr;
  }

  .kanban {
    grid-auto-columns: minmax(240px, 82vw);
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .pipeline-controls {
    grid-template-columns: 1fr;
  }

  .analytics-filters {
    grid-template-columns: 1fr;
  }

  .analytics-stack {
    grid-template-columns: 1fr;
  }

  .analytics-export-actions {
    align-items: flex-start;
  }

  .automation-run-hint {
    width: 100%;
  }

  .dashboard-pipeline-scroll {
    max-height: 460px;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 12px 10px 16px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 16px;
  }

  .sidebar {
    width: 250px;
  }

  .panel {
    padding: 12px;
  }

  .alerts-dropdown {
    width: min(340px, calc(100vw - 20px));
  }

  .kanban {
    grid-auto-columns: minmax(250px, 88vw);
  }

  .dashboard-tabs {
    gap: 6px;
    top: 56px;
  }

  .dashboard-tab-btn {
    padding: 7px 12px;
    font-size: 11px;
  }

  .dashboard-last-updated {
    width: 100%;
    margin-left: 0;
  }

  .dashboard-pipeline-scroll {
    max-height: 430px;
  }
}
