/**
 * Deal Workspace CSS
 * =================
 * Premium, action-oriented styling for the full-screen deal page.
 * Responsive design with mobile-friendly sidebar collapse.
 */

/* ===========================================
   BASE & CONTAINER
   =========================================== */

.deal-workspace-open {
  overflow: hidden;
}

#dealWorkspaceMount {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  min-width: 600px;
  max-width: 900px;
  z-index: 9000;
  background: var(--bg);
  box-shadow: -4px 0 30px rgba(15, 23, 42, 0.15);
  transform: translateX(100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s ease, opacity 0.2s ease, visibility 0.2s ease;
}

#dealWorkspaceMount.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* Overlay behind the deal panel */
.deal-workspace-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 8999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.deal-workspace-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.deal-workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===========================================
   HEADER (Sticky)
   =========================================== */

.deal-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.deal-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.deal-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.deal-back-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* Back button in center of header (from contact Projects tab) - ensure center is visible */
.deal-header[data-back-centered="true"] .deal-header-center {
  display: flex !important;
  flex: 1;
  min-width: 0;
  justify-content: center;
  border-left: none;
  border-right: none;
}

.deal-back-btn--centered {
  width: auto;
  padding: 8px 14px;
  min-width: 0;
}

.deal-back-btn--centered .deal-back-btn-label {
  white-space: nowrap;
}

.deal-header-info {
  min-width: 0;
  flex: 1;
}

.deal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.deal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.deal-star-btn {
  font-size: 20px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--border-strong, #cbd5e1);
  transition: color 0.15s ease, transform 0.15s ease;
  padding: 4px;
}

.deal-star-btn:hover {
  color: #fbbf24;
  transform: scale(1.1);
}

.deal-star-btn.starred {
  color: #fbbf24;
}

.deal-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.deal-stage-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.deal-prob-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.deal-health-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.deal-health-good {
  background: #dcfce7;
  color: #166534;
}

.deal-health-at_risk {
  background: #fef3c7;
  color: #92400e;
}

.deal-health-critical {
  background: #fee2e2;
  color: #991b1b;
}

/* Header Center - KPIs */
.deal-header-center {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.deal-kpi {
  text-align: center;
  min-width: 100px;
}

.deal-kpi-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.deal-kpi-value.overdue {
  color: #dc2626;
}

.deal-kpi-value.soon {
  color: #f59e0b;
}

.deal-kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}

/* Header Right - Actions */
.deal-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.deal-actions-primary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deal-actions-secondary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border-subtle, #e2e8f0);
}

/* Buttons */
.deal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.deal-btn-primary {
  background: var(--accent, #6366f1);
  color: white;
}

.deal-btn-primary:hover {
  background: #4f46e5;
}

.deal-btn-secondary {
  background: var(--surface-2, #f1f5f9);
  color: var(--text-secondary, #475569);
  border-color: var(--border-subtle, #e2e8f0);
}

.deal-btn-secondary:hover {
  background: var(--border-subtle, #e2e8f0);
}

.deal-btn-ghost {
  background: transparent;
  color: var(--text-secondary, #64748b);
}

.deal-btn-ghost:hover {
  background: var(--surface-2, #f1f5f9);
  color: var(--text-primary, #334155);
}

.deal-btn-success {
  background: #22c55e;
  color: white;
}

.deal-btn-success:hover {
  background: #16a34a;
}

.deal-btn-danger {
  background: #fee2e2;
  color: #dc2626;
}

.deal-btn-danger:hover {
  background: #fecaca;
}

.deal-btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.deal-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.15s ease;
}

.deal-action-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.deal-action-btn.deal-action-primary {
  background: var(--primary);
  color: var(--primary-contrast);
  border-color: var(--primary);
}

.deal-action-btn.deal-action-primary:hover {
  background: var(--primary-hover);
}

.deal-action-btn.deal-action-success {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.deal-action-btn.deal-action-success:hover {
  background: #bbf7d0;
}

.deal-action-btn.deal-action-danger {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
}

.deal-action-btn.deal-action-danger:hover {
  background: #fecaca;
}

.deal-action-btn.deal-action-icon {
  padding: 8px;
}

/* Dropdowns */
.deal-action-dropdown {
  position: relative;
}

.deal-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: var(--surface-1, white);
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  padding: 6px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.15s ease;
}

.deal-dropdown-menu.deal-dropdown-right {
  left: auto;
  right: 0;
}

.deal-dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.deal-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: none;
  font-size: 13px;
  color: var(--text-primary, #334155);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s ease;
}

.deal-dropdown-item:hover {
  background: var(--surface-2, #f1f5f9);
}

.deal-dropdown-item.deal-dropdown-danger {
  color: #dc2626;
}

.deal-dropdown-item.deal-dropdown-danger:hover {
  background: #fee2e2;
}

.deal-dropdown-divider {
  height: 1px;
  background: var(--border-subtle, #e2e8f0);
  border: none;
  margin: 6px 0;
}

/* ===========================================
   BODY (Main + Sidebar)
   =========================================== */

.deal-workspace-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.deal-main-content {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  background: var(--bg);
}

.deal-sidebar {
  background: var(--surface-2);
  border-top: 1px solid var(--border-subtle);
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  flex-shrink: 0;
  max-height: 280px;
  overflow-y: auto;
}

.deal-sidebar .deal-sidebar-card {
  margin: 0;
}

/* ===========================================
   CARDS
   =========================================== */

.deal-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  /* overflow: hidden; Removed to prevent clipping */
}

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

.deal-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.deal-contract-basics-card {
  overflow: hidden;
}

.deal-accordion-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-1);
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
}

.deal-accordion-toggle:hover {
  background: var(--surface-hover, #f8fafc);
}

.deal-accordion-chevron {
  color: var(--text-tertiary, #64748b);
  font-size: 14px;
}

.deal-contract-summary {
  font-size: 11px;
  color: var(--text-tertiary, #64748b);
  margin-top: 3px;
}

.deal-accordion-body {
  display: none;
  padding: 14px 18px 18px;
  background: var(--surface-1);
}

.deal-accordion-body.open {
  display: block;
}

.deal-contract-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.deal-contract-field {
  display: grid;
  gap: 6px;
}

.deal-contract-field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #475569);
}

.deal-contract-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary, #475569);
}

.deal-contract-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.deal-contract-status {
  font-size: 12px;
  color: var(--text-tertiary, #64748b);
}

/* ===========================================
   NEXT ACTION CARD
   =========================================== */

.deal-next-action-card {
  border: 2px solid var(--accent, #6366f1);
  background: linear-gradient(135deg, var(--surface-1, white) 0%, #f8f7ff 100%);
}

.deal-next-action-card.deal-next-action-overdue {
  border-color: #dc2626;
  background: linear-gradient(135deg, var(--surface-1, white) 0%, #fff5f5 100%);
}

.deal-next-action-card.deal-next-action-empty {
  border-style: dashed;
  border-color: var(--border-strong, #cbd5e1);
  background: var(--surface-1, white);
}

.deal-next-action-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
}

.deal-next-action-main {
  flex: 1;
  min-width: 0;
}

.deal-next-action-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
  margin-bottom: 6px;
}

.deal-next-action-due {
  font-size: 13px;
  color: var(--text-secondary, #64748b);
}

.deal-next-action-due.overdue {
  color: #dc2626;
  font-weight: 600;
}

.deal-next-action-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.deal-next-action-empty-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 20px;
  gap: 16px;
}

.deal-next-action-empty-icon {
  font-size: 40px;
  opacity: 0.5;
}

.deal-next-action-empty-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.deal-next-action-empty-text strong {
  font-size: 15px;
  color: var(--text-primary, #334155);
}

.deal-next-action-empty-text span {
  font-size: 13px;
  color: var(--text-secondary, #64748b);
}

.deal-streak-badge {
  font-size: 12px;
  font-weight: 600;
  color: #f59e0b;
}

/* ===========================================
   STAGE PROGRESS
   =========================================== */

.deal-stage-card .deal-card-header {
  border-bottom: none;
  padding-bottom: 8px;
}

.deal-stage-progress {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px 24px;
  gap: 0;
}

.deal-stage-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 0 0 auto;
  min-width: 80px;
  transition: transform 0.15s ease;
}

.deal-stage-step:hover {
  transform: translateY(-2px);
}

.deal-stage-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  background: var(--border-subtle, #e2e8f0);
  transition: all 0.2s ease;
}

.deal-stage-step.completed .deal-stage-dot {
  color: white;
}

.deal-stage-step.current .deal-stage-dot {
  color: white;
  box-shadow: var(--focus);
}

.deal-stage-step.won .deal-stage-dot {
  background: #22c55e !important;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
}

.deal-stage-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  text-align: center;
  max-width: 80px;
}

.deal-stage-step.current .deal-stage-label,
.deal-stage-step.completed .deal-stage-label {
  color: var(--text-primary, #334155);
}

.deal-stage-prob {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent, #6366f1);
  background: #eef2ff;
  padding: 2px 8px;
  border-radius: 10px;
}

.deal-stage-connector {
  flex: 1;
  height: 3px;
  background: var(--border-subtle, #e2e8f0);
  margin-top: 17px;
  min-width: 20px;
}

.deal-stage-connector.completed {
  background: var(--accent, #6366f1);
}

/* ===========================================
   ACTIVITY SECTION
   =========================================== */

.deal-activity-card {
  flex: 1;
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

.deal-activity-filters {
  display: flex;
  gap: 4px;
}

.deal-filter-btn {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  transition: all 0.15s ease;
}

.deal-filter-btn:hover {
  background: var(--surface-2, #f1f5f9);
}

.deal-filter-btn.active {
  background: var(--accent, #6366f1);
  color: white;
}

.deal-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--border-subtle, #e2e8f0);
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
}

.deal-filter-btn.active .deal-filter-count {
  background: rgba(255, 255, 255, 0.3);
}

.deal-filter-count-danger {
  background: #fee2e2;
  color: #dc2626;
}

.deal-activity-composer {
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-2, #f1f5f9);
  background: var(--surface-2, #fafbfc);
}

.deal-activity-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 8px;
  font-size: 13px;
  resize: none;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.deal-activity-input:focus {
  outline: none;
  border-color: var(--accent, #6366f1);
  box-shadow: var(--focus);
}

.deal-activity-composer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.deal-activity-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.deal-activity-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary, #94a3b8);
  font-size: 13px;
}

.deal-activity-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--surface-2, #f1f5f9);
}

.deal-activity-item:last-child {
  border-bottom: none;
}

.deal-activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.deal-activity-content {
  flex: 1;
  min-width: 0;
}

.deal-activity-text {
  font-size: 13px;
  color: var(--text-primary, #334155);
  line-height: 1.5;
}

.deal-activity-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
}

/* ===========================================
   TASKS SECTION
   =========================================== */

.deal-tasks-card .deal-card-header {
  flex-wrap: wrap;
  gap: 12px;
}

.deal-task-filters {
  display: flex;
  gap: 4px;
}

.deal-tasks-list {
  padding: 12px 20px;
}

.deal-tasks-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.deal-task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.deal-task-item:last-child {
  border-bottom: none;
}

.deal-task-item.overdue {
  background: #fff5f5;
  margin: 0 -20px;
  padding-left: 20px;
  padding-right: 20px;
}

.deal-task-check {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  color: transparent;
}

.deal-task-check:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.deal-task-item.completed .deal-task-check {
  background: #22c55e;
  border-color: #22c55e;
  color: white;
}

.deal-task-content {
  flex: 1;
  min-width: 0;
}

.deal-task-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.deal-task-title.completed {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.deal-task-meta {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.deal-task-meta .overdue {
  color: #dc2626;
  font-weight: 600;
}

.deal-task-edit {
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.deal-task-item:hover .deal-task-edit {
  opacity: 1;
}

.deal-add-task-btn {
  width: 100%;
  margin: 12px 20px 16px;
  width: calc(100% - 40px);
  justify-content: center;
}

/* ===========================================
   SIDEBAR CARDS
   =========================================== */

.deal-sidebar-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

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

.deal-sidebar-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #334155);
  margin: 0;
}

.deal-sidebar-empty {
  padding: 20px;
  text-align: center;
}

.deal-sidebar-empty p {
  margin: 0 0 8px;
  color: var(--text-tertiary, #94a3b8);
  font-size: 13px;
}

.deal-sidebar-hint {
  font-size: 11px !important;
  color: var(--border-strong, #cbd5e1) !important;
}

/* Company Card */
.deal-company-info {
  padding: 16px;
}

.deal-company-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.deal-company-industry {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  margin-bottom: 8px;
}

.deal-company-website {
  font-size: 12px;
  color: var(--accent, #6366f1);
  text-decoration: none;
}

.deal-company-website:hover {
  text-decoration: underline;
}

.deal-company-details {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-secondary, #64748b);
}

/* Primary Contact (click-to-call / click-to-email) */
.deal-primary-contact-info {
  padding: 16px;
}

.deal-primary-contact-line {
  font-size: 13px;
  color: var(--text-primary, #334155);
  line-height: 1.5;
  word-break: break-word;
}

.deal-primary-contact-link {
  color: var(--accent, #2563eb);
  text-decoration: underline;
  cursor: pointer;
}

.deal-primary-contact-link:hover {
  color: var(--accent-hover, #1d4ed8);
}

.deal-primary-contact-sep {
  color: var(--text-tertiary, #94a3b8);
  margin: 0 4px;
  font-weight: 400;
}

.deal-primary-contact-label {
  color: var(--text-secondary, #64748b);
}

.deal-primary-contact-tel,
.deal-primary-contact-email {
  color: var(--text-primary, #334155);
  text-decoration: none;
}

.deal-primary-contact-tel:hover,
.deal-primary-contact-email:hover {
  color: var(--accent, #2563eb);
  text-decoration: underline;
}

/* Contacts Card */
.deal-contacts-list {
  padding: 8px;
}

.deal-contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.deal-contact-item:hover {
  background: var(--surface-2, #f8fafc);
}

.deal-contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent, #6366f1) 0%, #8b5cf6 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.deal-contact-info {
  flex: 1;
  min-width: 0;
}

.deal-contact-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #334155);
}

.deal-contact-title {
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
  margin-bottom: 4px;
}

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

.deal-contact-actions {
  display: flex;
  gap: 4px;
}

.deal-contact-action {
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: var(--surface-2, #f1f5f9);
  cursor: pointer;
  transition: background 0.15s ease;
  font-size: 12px;
}

.deal-contact-action:hover {
  background: var(--border-subtle, #e2e8f0);
}

/* Health Card */
.deal-health-card .deal-sidebar-header {
  border-bottom: none;
}

.deal-health-score {
  font-size: 24px;
  font-weight: 700;
}

.deal-health-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 12px;
  font-size: 14px;
  font-weight: 600;
}

.deal-health-icon {
  font-size: 18px;
}

.deal-health-risks {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deal-health-risk {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2, #f8fafc);
  border-left: 3px solid var(--border-strong, #cbd5e1);
}

.deal-health-risk-high {
  border-left-color: #dc2626;
  background: #fef2f2;
}

.deal-health-risk-medium {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.deal-health-risk-low {
  border-left-color: var(--accent, #6366f1);
  background: #f5f3ff;
}

.deal-risk-message {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #334155);
}

.deal-risk-action {
  font-size: 11px;
  color: var(--text-secondary, #64748b);
  margin-top: 4px;
}

.deal-health-good {
  padding: 16px;
}

.deal-health-good p {
  margin: 0;
  font-size: 13px;
  color: #166534;
}

/* Documents Card */
.deal-documents-list {
  padding: 8px;
}

.deal-document-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.deal-document-item:hover {
  background: var(--surface-2, #f8fafc);
}

.deal-document-icon {
  font-size: 24px;
}

.deal-document-info {
  flex: 1;
  min-width: 0;
}

.deal-document-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #334155);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deal-document-meta {
  font-size: 10px;
  color: var(--text-tertiary, #94a3b8);
  margin-top: 2px;
}

.deal-document-action {
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.deal-document-item:hover .deal-document-action {
  opacity: 1;
}

/* ===========================================
   MODALS
   =========================================== */

.deal-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: dealModalFadeIn 0.2s ease;
}

@keyframes dealModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.deal-modal {
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: dealModalSlideIn 0.2s ease;
}

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

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

.deal-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.deal-modal-close {
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary, #64748b);
  transition: background 0.15s ease;
}

.deal-modal-close:hover {
  background: var(--surface-2, #f1f5f9);
}

.deal-modal-body {
  padding: 24px;
  overflow-y: auto;
}

.deal-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-2);
}

.deal-modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.deal-modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.deal-modal-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #475569);
}

.deal-modal-input,
.deal-modal-select,
.deal-modal-textarea {
  padding: 10px 12px;
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.deal-modal-input:focus,
.deal-modal-select:focus,
.deal-modal-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.deal-workspace button:focus-visible,
.deal-workspace input:focus-visible,
.deal-workspace select:focus-visible,
.deal-workspace textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.next-step-card {
  background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-lg);
}

.next-step-title {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.86;
}

.next-step-subtitle {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 700;
}

.next-step-meta {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.84;
}

.next-step-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.next-step-actions .btn {
  min-height: 44px;
}

.momentum-timeline-card .timeline-list {
  padding: 12px 16px 16px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: var(--radius-md);
  transition: background 0.15s ease;
}

.timeline-item:hover {
  background: var(--surface-hover);
}

.timeline-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 700;
}

.timeline-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.timeline-preview {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-secondary);
}

.timeline-time {
  margin-top: 5px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.timeline-empty {
  padding: 18px 12px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.mobile-action-bar {
  display: none;
}

/* ===========================================
   DEAL LINE ITEMS
   =========================================== */

.dli-section-card {
  overflow: visible;
}

.dli-table-wrap {
  overflow-x: auto;
}

.dli-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dli-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--surface-2, #f8fafc);
  border-bottom: 1px solid var(--border-subtle, #e2e8f0);
  white-space: nowrap;
}

.dli-th-grip { width: 30px; }
.dli-th-qty { width: 60px; text-align: right; }
.dli-th-price { width: 110px; text-align: right; }
.dli-th-discount { width: 90px; text-align: right; }
.dli-th-tax { width: 60px; text-align: right; }
.dli-th-total { width: 110px; text-align: right; }
.dli-th-actions { width: 90px; }

.dli-row {
  border-bottom: 1px solid var(--border-subtle, #e2e8f0);
  transition: background 0.1s ease;
}

.dli-row:hover {
  background: var(--surface-2, #f8fafc);
}

.dli-row.dli-dragging {
  opacity: 0.5;
}

.dli-row.dli-drag-over {
  border-top: 2px solid var(--accent, #6366f1);
}

.dli-row td {
  padding: 12px;
  vertical-align: top;
}

.dli-grip {
  cursor: grab;
  color: var(--text-tertiary, #94a3b8);
  font-size: 12px;
  user-select: none;
  text-align: center;
}

.dli-grip:active {
  cursor: grabbing;
}

.dli-cell-name {
  min-width: 160px;
}

.dli-item-name {
  font-weight: 600;
  color: var(--text-primary, #334155);
}

.dli-item-desc {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  margin-top: 2px;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dli-item-sku {
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
  margin-top: 2px;
}

.dli-cell-qty,
.dli-cell-price,
.dli-cell-discount,
.dli-cell-tax,
.dli-cell-total {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dli-cell-total {
  font-weight: 700;
  color: var(--text-primary, #334155);
}

.dli-freq {
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
  margin-left: 2px;
}

.dli-cell-actions {
  text-align: right;
  white-space: nowrap;
}

.dli-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.1s ease;
  opacity: 0;
}

.dli-row:hover .dli-action-btn {
  opacity: 1;
}

.dli-action-btn:hover {
  background: var(--surface-2, #f1f5f9);
}

.dli-action-delete:hover {
  background: #fee2e2;
}

/* Totals Footer */
.dli-totals-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle, #e2e8f0);
  background: var(--surface-2, #fafbfc);
  display: flex;
  justify-content: flex-end;
}

.dli-totals-grid {
  min-width: 260px;
}

.dli-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary, #64748b);
}

.dli-total-label {
  font-weight: 500;
}

.dli-total-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.dli-total-discount .dli-total-value {
  color: #dc2626;
}

.dli-total-grand {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 2px solid var(--border-strong, #cbd5e1);
  font-size: 16px;
  color: var(--text-primary, #0f172a);
}

.dli-total-grand .dli-total-label,
.dli-total-grand .dli-total-value {
  font-weight: 800;
}

.dli-total-divider {
  height: 1px;
  background: var(--border-subtle, #e2e8f0);
  margin: 6px 0;
}

.dli-total-mrr, .dli-total-arr {
  color: var(--accent, #6366f1);
}

.dli-total-mrr .dli-total-label,
.dli-total-arr .dli-total-label {
  font-weight: 700;
}

/* Empty State */
.dli-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 20px;
  gap: 8px;
}

.dli-empty-icon {
  font-size: 36px;
  opacity: 0.5;
}

.dli-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #334155);
}

.dli-empty-desc {
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  max-width: 300px;
}

.dli-add-first-btn {
  margin-top: 12px;
}

/* Modal Form Enhancements */
.dli-form-row {
  display: flex;
  gap: 12px;
}

.dli-preview-box {
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 8px;
  padding: 14px 16px;
}

.dli-preview-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-tertiary, #94a3b8);
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.dli-preview-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  font-variant-numeric: tabular-nums;
}

.dli-preview-grid span:nth-child(even) {
  text-align: right;
}

.dli-preview-total-label {
  font-weight: 700;
  color: var(--text-primary, #334155);
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle, #e2e8f0);
}

.dli-preview-total-value {
  font-weight: 800;
  color: var(--text-primary, #334155);
  font-size: 15px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle, #e2e8f0);
}

.dli-errors {
  padding: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
}

.dli-error-msg {
  font-size: 12px;
  color: #dc2626;
  padding: 2px 0;
}

.dli-error-msg::before {
  content: "• ";
}

.dli-modal-backdrop {
  z-index: 10001;
}

/* Responsive */
@media (max-width: 700px) {
  .dli-form-row {
    flex-direction: column;
    gap: 8px;
  }
  .dli-form-row .deal-modal-field {
    width: 100% !important;
  }
  .dli-th-discount,
  .dli-th-tax,
  .dli-cell-discount,
  .dli-cell-tax {
    display: none;
  }
  .dli-cell-name {
    min-width: 100px;
  }
}

.deal-modal-textarea {
  resize: vertical;
  min-height: 80px;
}

.deal-modal-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deal-modal-checkbox label {
  font-size: 13px;
  font-weight: normal;
  color: var(--text-primary, #334155);
}

.deal-snooze-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.deal-snooze-btn {
  padding: 12px;
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 8px;
  background: var(--surface-1, white);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.deal-snooze-btn:hover {
  border-color: var(--accent, #6366f1);
  background: #f5f3ff;
}

/* ===========================================
   CELEBRATIONS & TOASTS
   =========================================== */

.deal-celebration {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(34, 197, 94, 0.1);
  z-index: 20000;
  animation: dealCelebrateFade 3s ease forwards;
  pointer-events: none;
}

@keyframes dealCelebrateFade {
  0% { opacity: 0; }
  10% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

.deal-celebration-content {
  text-align: center;
  animation: dealCelebratePop 0.5s ease;
}

@keyframes dealCelebratePop {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.deal-celebration-emoji {
  font-size: 80px;
  margin-bottom: 16px;
}

.deal-celebration-text {
  font-size: 32px;
  font-weight: 700;
  color: #166534;
}

.deal-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: white;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 20000;
  opacity: 0;
  transition: all 0.3s ease;
}

.deal-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===========================================
   PANEL MODE ADJUSTMENTS (50% width)
   =========================================== */

/* Header adjustments for narrow panel */
.deal-header-left {
  flex: 1;
  min-width: 0;
}

.deal-header-center {
  display: none; /* Hide KPIs in panel mode - they're shown in cards instead */
}

.deal-header-right {
  flex-shrink: 0;
}

.deal-actions-secondary {
  display: none; /* Hide secondary actions in panel, use dropdown */
}

/* Show secondary actions in More menu instead */
.deal-action-btn.deal-action-success,
.deal-action-btn.deal-action-danger {
  display: none;
}

/* Stage progress - horizontal scroll in narrow panel */
.deal-stage-progress {
  overflow-x: auto;
  padding-bottom: 8px;
}

.deal-stage-step {
  min-width: 70px;
}

/* Sidebar as bottom grid */
.deal-sidebar {
  grid-template-columns: repeat(2, 1fr);
}

/* Activity and tasks cards fill available space */
.deal-activity-card,
.deal-tasks-card {
  max-height: 300px;
}

.deal-activity-list,
.deal-tasks-list {
  max-height: 200px;
  overflow-y: auto;
}

/* ===========================================
   RESPONSIVE (Narrower panels)
   =========================================== */

@media (max-width: 700px) {
  #dealWorkspaceMount {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .deal-sidebar {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .deal-header {
    padding: 12px 16px;
  }

  .deal-title {
    font-size: 16px;
  }

  .deal-action-btn {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 44px;
  }

  .deal-action-btn svg {
    width: 14px;
    height: 14px;
  }

  .deal-contract-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  body[data-theme="momentum"] #dealWorkspaceMount .deal-main-content {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  body[data-theme="momentum"] #dealWorkspaceMount .mobile-action-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9100;
    background: var(--surface-1);
    border-top: 1px solid var(--border-subtle);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.1);
  }

  body[data-theme="momentum"] #dealWorkspaceMount .mobile-action-btn {
    min-height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-2);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
  }
}

