:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-card-header: #f1f5f9;
  --bg-column: #edf2f7;
  --bg-modal: #ffffff;
  --border-subtle: #e2e8f0;
  --border-active: #cbd5e1;
  --border-focus: #3b82f6;
  
  --text-main: #0f172a;       /* slate-900 for ultra sharp readability */
  --text-body: #1e293b;       /* slate-800 */
  --text-muted: #475569;      /* slate-600 */
  --text-dim: #64748b;        /* slate-500 */
  
  --accent-cyan: #0284c7;     /* sky-600 */
  --accent-blue: #2563eb;     /* blue-600 */
  --accent-teal: #0d9488;     /* teal-600 */
  
  --status-green: #16a34a;    /* green-600 */
  --status-green-bg: #dcfce7; /* green-100 */
  --status-green-text: #15803d;
  
  --status-yellow: #d97706;   /* amber-600 */
  --status-yellow-bg: #fef3c7;
  --status-yellow-text: #b45309;
  
  --status-red: #dc2626;      /* red-600 */
  --status-red-bg: #fee2e2;
  --status-red-text: #b91c1c;
  
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.03);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-modal: 0 20px 40px -10px rgba(0, 0, 0, 0.2), 0 0 1px rgba(0, 0, 0, 0.2);
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-body);
  font-family: var(--font-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app-container {
  max-width: 1750px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
  background: #ffffff;
  padding: 20px 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-subtle);
}

.header-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.header-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.header-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--status-green);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--status-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

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

/* Pipeline Tabs */
.pipeline-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.pipeline-tab {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  box-shadow: var(--shadow-card);
}

.pipeline-tab:hover {
  background: #f8fafc;
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.pipeline-tab.active {
  background: #ffffff;
  border: 2px solid #2563eb;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
}

.tab-icon {
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-text-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
}

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

.tab-sum {
  font-size: 12px;
  font-family: var(--font-mono);
  color: #2563eb;
  font-weight: 700;
}

.tab-badge {
  background: #f1f5f9;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.pipeline-tab.active .tab-badge {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.icon-money { color: #0284c7; background: #e0f2fe; }
.icon-alert { color: #dc2626; background: #fee2e2; }
.icon-wrench { color: #d97706; background: #fef3c7; }
.icon-china { color: #ea580c; background: #ffedd5; }
.icon-touch { color: #7c3aed; background: #ede9fe; }

.kpi-info {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-main);
  line-height: 1.2;
  margin: 2px 0;
}

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

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: var(--shadow-card);
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  flex: 1;
  max-width: 420px;
}

.toolbar-search svg {
  color: var(--text-dim);
}

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

.toolbar-search input::placeholder {
  color: var(--text-dim);
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 16px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-group select {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.filter-group select:focus {
  border-color: var(--border-focus);
}

.view-switchers {
  display: flex;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-btn.active {
  background: #ffffff;
  color: #2563eb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Kanban Board */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 20px;
  align-items: flex-start;
}

.kanban-column {
  flex: 0 0 320px;
  background: var(--bg-column);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 340px);
}

.kanban-col-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

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

.kanban-col-count {
  background: #f1f5f9;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
}

.kanban-cards {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Deal Card in Kanban */
.deal-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.deal-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: var(--shadow-card-hover);
}

.deal-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
}

.deal-card.risk-high::before { background-color: var(--status-red); }
.deal-card.risk-medium::before { background-color: var(--status-yellow); }
.deal-card.risk-low::before { background-color: var(--status-green); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.card-id {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}

.card-cat-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.card-eff-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}

.card-eff-badge.eff-good { background: var(--status-green-bg); color: var(--status-green-text); }
.card-eff-badge.eff-warning { background: var(--status-yellow-bg); color: var(--status-yellow-text); }
.card-eff-badge.eff-danger { background: var(--status-red-bg); color: var(--status-red-text); }

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-amount {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  color: #0284c7;
  margin-bottom: 10px;
}

.card-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.card-progress-bar {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.card-progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 3px;
}

.card-diagnosis-pill {
  font-size: 12px;
  padding: 8px 10px;
  background: #f8fafc;
  border-left: 3px solid #94a3b8;
  color: var(--text-body);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 10px;
  line-height: 1.35;
}

.card-touch-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  background: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #d8b4fe;
}

.card-touch-box.overdue {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.card-touch-box.today {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

/* Table View */
.table-container {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}

.deals-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.deals-table th {
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.deals-table td {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-body);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.deals-table tr:hover td {
  background: #f8fafc;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-window {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1280px;
  max-height: 90vh;
  box-shadow: var(--shadow-modal);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-close-btn {
  position: absolute;
  top: 18px;
  right: 20px;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}

.modal-close-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

.modal-body {
  overflow-y: auto;
  padding: 28px 32px;
}

/* Modal Internal Layout */
.modal-header-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
  padding-right: 48px;
}

.modal-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 8px;
  line-height: 1.3;
}

.modal-badges {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.badge-stage {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.modal-amount {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 800;
  color: #0284c7;
  white-space: nowrap;
}

.modal-grid-2col {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
}

.modal-col {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Section Box */
.section-box {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.diag-item {
  margin-bottom: 14px;
}

.diag-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.diag-text {
  font-size: 13px;
  color: var(--text-body);
  line-height: 1.45;
}

.diag-text.danger {
  color: #b91c1c;
  font-weight: 600;
  background: #fef2f2;
  border-left: 3px solid #dc2626;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.diag-text.action {
  color: #0369a1;
  font-weight: 600;
  background: #f0f9ff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid #0284c7;
}

/* Touch Plan Form */
.touch-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  gap: 12px;
}

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

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

.form-input, .form-select, .form-textarea {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.preset-btn {
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  color: var(--text-body);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

/* Task Checkpoints */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.task-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.task-item.status-done {
  border-left: 4px solid var(--status-green);
}

.task-item.status-active {
  border-left: 4px solid var(--status-yellow);
}

.task-item.status-overdue {
  border-left: 4px solid var(--status-red);
}

.task-item-title {
  font-weight: 700;
  color: var(--text-main);
}

.task-item-deadline {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Chat Timeline in Modal */
.chat-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 350px;
  overflow-y: auto;
}

.chat-bubble {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.5;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.chat-author {
  font-weight: 700;
  color: #0284c7;
}

.chat-body {
  color: var(--text-body);
  word-break: break-word;
}

/* Responsive */
@media (max-width: 1200px) {
  .pipeline-tabs { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .modal-grid-2col { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app-container { padding: 16px; }
  .pipeline-tabs { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .app-header { flex-direction: column; align-items: flex-start; gap: 16px; }
}
