:root {
  --bg-dark: #040508;
  --bg-app: radial-gradient(circle at 20% 20%, #0a152e 0%, #04060d 100%);
  --bg-card: rgba(14, 22, 43, 0.7);
  --bg-card-hover: rgba(22, 33, 62, 0.85);
  --bg-input: rgba(10, 16, 31, 0.5);
  --border-color: rgba(255, 255, 255, 0.05);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  
  --accent: #d97706;
  --accent-light: #fbbf24;
  --accent-gradient: linear-gradient(135deg, #fbbf24, #d97706);
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.15);
  
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-body);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
}

/* 模擬手機外框 */
.phone-container {
  width: 100%;
  max-width: 450px;
  height: 100vh;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden; /* 防止 PWA/手機版整體頁面滾動與輸入框拉扯，鎖定視窗 */
}

@media (min-width: 480px) {
  .phone-container {
    height: 90vh;
    max-height: 850px;
    border-radius: 40px;
    border: 8px solid #1e293b;
    overflow: hidden;
  }
}

/* 狀態列模擬 */
.status-bar {
  height: 28px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  font-family: var(--font-title);
  background-color: rgba(11, 15, 25, 0.9);
  z-index: 10;
}

.status-bar .icons {
  display: flex;
  gap: 6px;
}

/* 應用程式標題列 */
.app-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(20px);
  z-index: 10;
}

.app-logo {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 20px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 內容區塊 */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 90px; /* 留給底部導覽列 */
  position: relative;
}

.app-content::-webkit-scrollbar {
  width: 0;
}

/* 底部導覽列 */
.nav-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 76px;
  background-color: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  gap: 4px;
  transition: all 0.3s ease;
  cursor: pointer;
  flex: 1;
  height: 100%;
  justify-content: center;
}

.nav-item.active {
  color: var(--accent-light);
}

.nav-item i {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.nav-item:active i {
  transform: scale(0.85);
}

/* 卡片與元件樣式 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:active {
  transform: scale(0.99);
  background: var(--bg-card-hover);
}

.clickable-card {
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.clickable-card:hover {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(15, 23, 42, 0.7);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 0 0 15px rgba(251, 191, 36, 0.05);
}

.clickable-card:active {
  transform: translateY(0) scale(0.98);
}

.clickable-card.active-glow {
  border-color: rgba(251, 191, 36, 0.6) !important;
  background: rgba(15, 23, 42, 0.8) !important;
  box-shadow: 0 0 25px rgba(251, 191, 36, 0.45), 0 4px 15px rgba(251, 191, 36, 0.25) !important;
  transform: translateY(0) scale(0.97) !important;
}

.gradient-card {
  background: var(--accent-gradient);
  border: none;
  color: white;
}

/* 儀表板樣式 */
.welcome-section {
  margin-bottom: 20px;
}

.welcome-title {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.welcome-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 14px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-val {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

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

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 標題區塊 */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-family: var(--font-title);
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-link {
  font-size: 13px;
  color: var(--accent-light);
  cursor: pointer;
}

/* 快速搜尋列 */
.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-input {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 0 16px 0 42px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all 0.3s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.search-box i {
  position: absolute;
  left: 14px;
  top: 13px;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

/* 分類標籤頁切換 */
.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  padding-bottom: 4px;
}

.filter-tabs::-webkit-scrollbar {
  height: 0;
}

.filter-tag {
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.filter-tag.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* 客戶列表項 */
.contact-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

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

.contact-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 14px;
  color: white;
}

.contact-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.contact-name {
  font-weight: 500;
  font-size: 15px;
}

.contact-company {
  font-size: 12px;
  color: var(--text-secondary);
}

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

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:active {
  background: var(--accent);
  color: white;
}

.badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.badge-lead { background: var(--warning-bg); color: var(--warning); }
.badge-contact { background: var(--info-bg); color: var(--info); }
.badge-customer { background: var(--success-bg); color: var(--success); }
.badge-lost { background: var(--danger-bg); color: var(--danger); }

/* 詳情與彈出視窗 */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-app);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s, pointer-events 0.3s;
}

.modal.open {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

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

.modal-title {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 18px;
}

.modal-close {
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* 表單樣式 */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 0 14px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
}

textarea.form-control {
  height: 80px;
  padding: 10px 14px;
  resize: none;
}

.btn {
  width: 100%;
  height: 46px;
  border-radius: 10px;
  background: var(--accent-gradient);
  border: none;
  color: white;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s;
}

.btn:active {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline {
  background: transparent;
  border: 1px dashed var(--accent);
  color: var(--accent-light);
}

/* 時間軸樣式 */
.timeline {
  position: relative;
  padding-left: 20px;
  margin-top: 16px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 16px;
}

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-app);
}

.timeline-content {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: 8px;
  white-space: pre-line;
  font-size: 13px;
}

.timeline-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 商機看板 (Kanban) */
.pipeline-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pipeline-stage {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
}

.stage-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
}

.deal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

.deal-card:last-child {
  margin-bottom: 0;
}

.deal-name {
  font-weight: 500;
  font-size: 14px;
}

.deal-price {
  font-weight: 700;
  color: var(--success);
  font-size: 13px;
  margin-top: 4px;
}

/* 任務項目 */
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.task-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.task-checkbox.checked {
  background: var(--accent);
}

.task-checkbox.checked::after {
  content: '✓';
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.task-text {
  flex: 1;
  font-size: 14px;
}

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

.task-date {
  font-size: 11px;
  color: var(--text-muted);
}

/* 演示用說明 Banner */
.demo-info-banner {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.1), rgba(251, 191, 36, 0.1));
  border: 1px solid rgba(217, 119, 6, 0.3);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 16px;
  max-height: 200px;
  opacity: 1;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.demo-info-banner.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  border-color: transparent;
}

/* 快速新增客戶橫條樣式 */
.quick-action-bar:hover {
  background: rgba(99, 102, 241, 0.15) !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
  transform: translateY(-1px);
}

.quick-action-bar:active {
  transform: translateY(0) scale(0.99);
}

.float-add {
  position: absolute;
  bottom: 92px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-gradient);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  z-index: 9;
  border: none;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
}

.empty-state i {
  width: 48px;
  height: 48px;
  stroke-width: 1.5;
  margin-bottom: 12px;
}

.import-btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.import-btn-group .btn {
  height: 38px;
  font-size: 13px;
}

/* 微小動畫 */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin {
  animation: spin 1.5s linear infinite;
}

/* 數據圖表樣式 (Rex Fast AI CRM Premium Charts) */
.chart-card {
  padding: 16px;
  margin-bottom: 16px;
}

.chart-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-title);
}

.chart-subtitle {
  font-size: 10px;
  color: var(--text-muted);
}

.bar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  flex: 1;
}

.bar-fill {
  width: 16px;
  background: var(--accent-gradient);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-label {
  font-size: 10px;
  color: var(--text-secondary);
}

/* 行動裝置隱藏模擬狀態列 (避免雙狀態列) */
@media (max-width: 480px) {
  .status-bar {
    display: none !important;
  }
}

