/* ── Searchable Select ── */
.ss-wrap { position: relative; }
.ss-input { width: 100%; }
.ss-panel {
  display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 200;
  max-height: 200px; overflow-y: auto;
  background: #2a2a2a; border: 1px solid #3a3a3a; border-radius: 4px;
  margin-top: 2px; box-shadow: 0 4px 12px rgba(0,0,0,.5);
}
.ss-item {
  padding: 6px 12px; font-size: 13px; cursor: pointer; color: #d1d5db;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ss-item:hover, .ss-item.ss-active { background: #3b82f6; color: #fff; }
.ss-item.ss-selected { color: #60a5fa; }
.ss-empty { padding: 8px 12px; color: #6b7280; font-size: 12px; }

/* CRM Tab Styles */

.crm-root {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  min-height: 400px;
  font-size: 14px;
}

/* ── Sub-tabs (專案/報價總覽) ── */
.crm-sub-tabs {
    display: flex; gap: 0; border-bottom: 1px solid #3a3a3a; padding: 0 16px;
    flex-shrink: 0; background: #2a2a2a;
}
.crm-sub-tab {
    background: none; border: none; border-bottom: 2px solid transparent;
    color: #6b7280; font-size: 13px; font-weight: 600; padding: 10px 16px;
    cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.crm-sub-tab:hover { color: #e0e0e0; }
.crm-sub-tab.active { color: #fff; border-bottom-color: #3b82f6; }

/* ── Toolbar ── */
.crm-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #3a3a3a;
  background: #2a2a2a;
  flex-shrink: 0;
}

.crm-search-input {
  flex: 1;
  min-width: 160px;
  max-width: 280px;
  background: #1e1e1e;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}
.crm-search-input:focus { border-color: #3b82f6; }

.crm-select {
  background: #1e1e1e;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.crm-select:focus { border-color: #3b82f6; }

.crm-toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* ── Buttons ── */
.crm-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}
.crm-btn:disabled { opacity: 0.45; cursor: default; }
.crm-btn-sm { padding: 4px 10px; font-size: 12px; }
.crm-btn-primary { background: #3b82f6; color: #fff; }
.crm-btn-primary:hover:not(:disabled) { background: #2563eb; }
.crm-btn-secondary { background: #3a3a3a; color: #e0e0e0; }
.crm-btn-secondary:hover:not(:disabled) { background: #444; }
.crm-btn-danger { background: #7f1d1d; color: #fca5a5; }
.crm-btn-danger:hover:not(:disabled) { background: #991b1b; }

/* ── Kebab menu ── */
.crm-kebab-wrap { position: relative; flex: 0 0 36px; text-align: center; }
.crm-kebab-btn {
  background: none; border: none; color: #9ca3af; font-size: 18px; cursor: pointer;
  padding: 2px 6px; border-radius: 4px; line-height: 1;
}
.crm-kebab-btn:hover { background: #3a3a3a; color: #e0e0e0; }
.crm-kebab-menu {
  display: none; position: fixed; z-index: 999;
  background: #2a2a2a; border: 1px solid #444; border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.4); min-width: 100px; overflow: hidden;
}
.crm-kebab-menu.open { display: block; }
.crm-kebab-item {
  padding: 8px 16px; font-size: 13px; color: #e0e0e0; cursor: pointer;
  white-space: nowrap;
}
.crm-kebab-item:hover { background: #3a3a3a; }
.crm-kebab-danger { color: #fca5a5; }
.crm-kebab-danger:hover { background: #7f1d1d; }

/* ── Body layout ── */
.crm-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── List panel ── */
.crm-list-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #3a3a3a;
  transition: flex 0.25s;
}

.crm-list-header {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: #222;
  border-bottom: 1px solid #3a3a3a;
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  gap: 4px;
}

.crm-col-name    { flex: 1.5; min-width: 60px; }
.crm-col-status  { flex: 0.6; min-width: 50px; }
.crm-col-am      { flex: 0.8; min-width: 40px; }
.crm-col-proj    { flex: 0.3; text-align: center; min-width: 30px; }
.crm-col-revenue { flex: 0.8; text-align: right; min-width: 60px; }
.crm-col-contact { flex: 0.7; text-align: right; min-width: 70px; }
.crm-col-actions { width: 36px; flex-shrink: 0; }

#crm-list-body,
[id$="-list-body"] {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.crm-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #2e2e2e;
  cursor: pointer;
  transition: background 0.1s;
  gap: 4px;
}
.crm-row:hover { background: #333; }
.crm-row.selected { background: #1e3a5f; }

.crm-row-name { flex: 1.5; min-width: 60px; font-weight: 600; color: #e0e0e0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-row-status { flex: 0.6; min-width: 50px; }
.crm-row-am { flex: 0.8; min-width: 40px; display: flex; align-items: center; gap: 4px; color: #9ca3af; font-size: 12px; overflow: hidden; white-space: nowrap; }
.crm-row-am span { overflow: hidden; text-overflow: ellipsis; }
.crm-row-proj { flex: 0.3; min-width: 30px; text-align: center; font-size: 13px; color: #e0e0e0; }
.crm-row-revenue { flex: 0.8; min-width: 60px; text-align: right; font-size: 12px; font-weight: 600; color: #fbbf24; white-space: nowrap; }
.crm-row-contact { flex: 0.7; min-width: 70px; text-align: right; color: #6b7280; font-size: 12px; }
.crm-row-actions { width: 36px; flex-shrink: 0; display: flex; gap: 4px; justify-content: flex-end; }

.crm-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: #3b82f6; color: #fff;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.crm-avatar img { width: 100%; height: 100%; object-fit: cover; }

.crm-empty {
  padding: 40px;
  text-align: center;
  color: #4b5563;
  font-size: 13px;
}

/* ── Status badges ── */
.crm-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.crm-badge-潛在客戶 { background: #374151; color: #9ca3af; }
.crm-badge-新客戶   { background: #1e3a5f; color: #93c5fd; }
.crm-badge-舊客戶   { background: #14532d; color: #86efac; }
.crm-badge-暫停合作 { background: #3b1f1f; color: #fca5a5; }

/* ── Detail panel ── */
/* ── Resize handle ── */
.crm-resize-handle {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: #3a3a3a;
  transition: background 0.15s;
}
.crm-resize-handle:hover,
.crm-resize-handle.dragging { background: #3b82f6; }

.crm-detail-panel {
  width: 65%;
  min-width: 320px;
  max-width: 1200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: #252525;
}

/* ── Detail bar (title + tabs + actions in one row) ── */
.crm-detail-bar {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid #3a3a3a;
  flex-shrink: 0;
  gap: 4px;
  height: 42px;
}

.crm-detail-bar-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}

.crm-detail-bar-tabs {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}

.crm-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
  padding: 10px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.crm-tab:hover { color: #e0e0e0; }
.crm-tab.active { color: #fff; border-bottom-color: #3b82f6; }

.crm-detail-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.crm-detail-close {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.crm-detail-close:hover { color: #e0e0e0; background: #3a3a3a; }

.crm-detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 32px;
}

.crm-detail-prop {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #2e2e2e;
  font-size: 13px;
}
.crm-detail-prop:last-child { border-bottom: none; }

.crm-prop-label {
  width: 110px;
  flex-shrink: 0;
  color: #6b7280;
  font-size: 12px;
  padding-top: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.crm-prop-value {
  flex: 1;
  color: #d1d5db;
  word-break: break-word;
}
.crm-prop-value.empty { color: #4b5563; font-style: italic; }

.crm-detail-section {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 0 6px;
  border-bottom: 1px solid #3a3a3a;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-am-row { display: flex; align-items: center; gap: 8px; }
.crm-muted { color: #4b5563; }

/* ── Modal ── */
.crm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.crm-modal {
  background: #2d2d2d;
  border: 1px solid #444;
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.crm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #3a3a3a;
  flex-shrink: 0;
}
.crm-modal-header h3 { font-size: 16px; font-weight: 700; color: #fff; margin: 0; }

.crm-modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.crm-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #3a3a3a;
  flex-shrink: 0;
}

/* ── Form ── */
.crm-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.crm-form-section {
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 0 6px;
  border-bottom: 1px solid #3a3a3a;
  margin-bottom: 14px;
}
.crm-form-section:first-child { padding-top: 0; }

.crm-field { display: flex; flex-direction: column; gap: 5px; }
.crm-field-full { grid-column: 1 / -1; }

.crm-field label { font-size: 12px; color: #9ca3af; font-weight: 600; }
.crm-required { color: #f87171; }

.crm-input {
  background: #1e1e1e;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}
.crm-input:focus { border-color: #3b82f6; }
.crm-input-auto { background: #2a2a2a; color: #9ca3af; }

.crm-textarea { resize: vertical; min-height: 60px; }

.crm-error {
  margin-top: 12px;
  padding: 8px 12px;
  background: #3b1f1f;
  border: 1px solid #7f1d1d;
  border-radius: 6px;
  color: #fca5a5;
  font-size: 13px;
}

/* ── CSV Import ── */
.crm-import-hint { font-size: 13px; color: #9ca3af; margin-bottom: 16px; line-height: 1.6; }

.crm-drop-zone {
  border: 2px dashed #3a3a3a;
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
  transition: border-color 0.15s;
}
.crm-drop-zone.drag-over { border-color: #3b82f6; background: #1e3a5f22; }
.crm-drop-icon { font-size: 32px; margin-bottom: 8px; }

.crm-import-result {
  margin-top: 16px;
  padding: 12px 16px;
  background: #1a2e1a;
  border: 1px solid #166534;
  border-radius: 8px;
  color: #86efac;
  font-size: 13px;
  line-height: 1.8;
}
.crm-import-result-error {
  background: #3b1f1f;
  border-color: #7f1d1d;
  color: #fca5a5;
}

/* ── Project badge colors (8 階段管線) ── */
/* 售前群（投標/開發/洽詢/提案）— 琥珀/橘色調 */
.crm-proj-badge-投標 { background: #3b2f1f; color: #fbbf24; }
.crm-proj-badge-開發 { background: #3b2a1f; color: #fb923c; }
.crm-proj-badge-洽詢 { background: #3a3320; color: #fcd34d; }
.crm-proj-badge-提案 { background: #3a2617; color: #fdba74; }
/* 製作 — 藍 */
.crm-proj-badge-製作 { background: #1e3a5f; color: #93c5fd; }
/* 結案 — 綠 */
.crm-proj-badge-結案 { background: #14532d; color: #86efac; }
/* 歸檔 — 灰 */
.crm-proj-badge-歸檔 { background: #374151; color: #9ca3af; }
/* 未成案 — 紅/靜音 */
.crm-proj-badge-未成案 { background: #3b1f1f; color: #fca5a5; }

/* ── Project list columns ── */
.crm-col-client { flex: 1.2; }
.crm-col-date   { flex: 1; text-align: right; }

/* 點欄頭排序 — 通用樣式,只要欄頭 <span> 帶 data-sort-key 就吃這套 */
.crm-list-header [data-sort-key] {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}
.crm-list-header [data-sort-key]:hover { color: #c9d1d9; }
.crm-list-header .crm-sort-active { color: #58a6ff; }
.crm-list-header .crm-sort-ind {
  font-size: 9px;
  opacity: 0.5;
  margin-left: 2px;
}
.crm-list-header .crm-sort-active .crm-sort-ind { opacity: 1; }
.crm-row-client { flex: 1.2; color: #9ca3af; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-row-date   { flex: 1; text-align: right; color: #6b7280; font-size: 12px; }

/* ── PM checkbox list ── */
.crm-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  padding: 6px;
  background: #1e1e1e;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
}
.crm-checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #d1d5db;
}
.crm-checkbox-item:hover { background: #333; }
.crm-checkbox-item input[type="checkbox"] {
  accent-color: #3b82f6;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Quotation badge colors ── */
.crm-quote-badge-草稿   { background: #374151; color: #9ca3af; }
.crm-quote-badge-已寄送 { background: #1e3a5f; color: #93c5fd; }
.crm-quote-badge-已簽核 { background: #14532d; color: #86efac; }
.crm-quote-badge-已拒絕 { background: #3b1f1f; color: #fca5a5; }

/* ── Quotation list columns ── */
.crm-col-amount { flex: 0.8; text-align: right; }
.crm-row-amount { flex: 0.8; text-align: right; font-weight: 600; color: #e0e0e0; font-size: 13px; }

/* ── Stat cards ── */
.quote-stat-card {
  background: #1e1e1e;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 10px 18px;
  min-width: 100px;
}
.quote-stat-label { font-size: 11px; color: #6b7280; margin-bottom: 2px; }
.quote-stat-value { font-size: 18px; font-weight: 700; color: #e0e0e0; }

/* ── Quotation items edit ── */
.quote-items-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.quote-item-edit-row {
  display: flex; gap: 6px; align-items: center; font-size: 13px;
}
.quote-item-edit-row .crm-input { padding: 5px 6px; font-size: 12px; }
.qi-amount { width: 90px; text-align: right; color: #9ca3af; font-size: 12px; flex-shrink: 0; }
.qi-remove { flex-shrink: 0; }

/* ── Quotation totals ── */
.quote-totals {
  background: #1e1e1e; border: 1px solid #3a3a3a; border-radius: 8px;
  padding: 12px 16px; margin-bottom: 16px;
}
.quote-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; font-size: 13px; color: #9ca3af;
}
.quote-total-row.total { font-size: 15px; font-weight: 700; color: #e0e0e0; border-top: 1px solid #3a3a3a; margin-top: 4px; padding-top: 8px; }

/* ── Quotation detail items ── */
.quote-group-title { font-size: 12px; font-weight: 700; color: #6b7280; padding: 10px 0 4px; border-bottom: 1px solid #2e2e2e; }
.quote-item-row { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid #2e2e2e; font-size: 13px; }
.quote-item-desc { flex: 2; color: #d1d5db; }
.quote-item-qty { flex: 0.5; color: #9ca3af; text-align: center; }
.quote-item-price { flex: 0.6; color: #9ca3af; text-align: right; }
.quote-item-amount { flex: 0.6; color: #e0e0e0; text-align: right; font-weight: 600; }

/* ── Template list ── */
.quote-template-row { padding: 10px 0; border-bottom: 1px solid #2e2e2e; }

/* ── Payment status badges ── */
.crm-pay-未到帳   { background: #3b1f1f; color: #fca5a5; }
.crm-pay-部分到帳 { background: #3b2f1f; color: #fbbf24; }
.crm-pay-全額到帳 { background: #14532d; color: #86efac; }

/* ── Inline edit ── */
.crm-inline-input { padding: 4px 8px; font-size: 13px; margin: 0; }
.crm-prop-value-edit { flex: 1; }
.crm-prop-value-edit .crm-input { width: 100%; }

/* ── View Switcher ── */
.crm-view-switcher { display: flex; gap: 2px; padding: 10px 16px 0; background: #2a2a2a; flex-shrink: 0; }
.crm-view-btn { background: #333; border: none; color: #9ca3af; font-size: 13px; font-weight: 600; padding: 7px 20px; cursor: pointer; border-radius: 6px 6px 0 0; transition: background 0.15s, color 0.15s; }
.crm-view-btn:hover { color: #e0e0e0; background: #3a3a3a; }
.crm-view-btn.active { background: #1e1e1e; color: #fff; }

/* ── Invoice badge colors ── */
.crm-pay-badge-收款 { background: #14532d; color: #86efac; }
.crm-pay-badge-未收款 { background: #3b2f1f; color: #fbbf24; }
.crm-pay-badge-付款 { background: #3b2f1f; color: #fbbf24; }
.crm-pay-badge-作廢 { background: #374151; color: #9ca3af; text-decoration: line-through; }

/* ── Client project cards ── */
.crm-project-card {
  padding: 10px 14px;
  border: 1px solid #2e2e2e;
  border-radius: 6px;
  margin: 6px 0;
  cursor: pointer;
  transition: border-color 0.15s;
}
.crm-project-card:hover { border-color: #3b82f6; }
.crm-project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.crm-project-card-name { font-weight: 600; font-size: 13px; color: #e0e0e0; }
.crm-project-card-meta {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: #9ca3af;
}
.crm-project-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
/* ── Client performance cards ── */
.crm-perf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.crm-perf-card {
  background: #1e1e1e;
  border: 1px solid #2e2e2e;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.crm-perf-num {
  font-size: 20px;
  font-weight: 700;
  color: #e0e0e0;
}
.crm-perf-label {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

.crm-project-year-header {
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  padding: 10px 0 4px;
  margin-top: 4px;
  border-bottom: 1px solid #2e2e2e;
}

/* ── Payable month group headers ── */
.payable-month-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  background: #1e1e1e;
  border-bottom: 1px solid #2e2e2e;
  font-size: 12px;
  font-weight: 700;
  color: #9ca3af;
  position: sticky;
  top: 0;
  z-index: 1;
}
.payable-month-header span:last-child { color: #fbbf24; }

/* ── Accounting tabs: centered, uniform columns ── */
.acct-header span { flex: 1; text-align: center; }

#inv-list-body .crm-row > div:not(.crm-kebab-wrap),
#inv-list-body .crm-row > span:not(:last-child),
#pay-list-body .crm-row > div:not(.crm-kebab-wrap),
#pay-list-body .crm-row > span:not(:last-child),
#cash-list-body .crm-row > div:not(.crm-kebab-wrap),
#cash-list-body .crm-row > span:not(:last-child),
#payable-list-body .crm-row > div:not(.crm-kebab-wrap),
#recv-list-body .crm-row > div:not(.crm-kebab-wrap) {
  flex: 1; text-align: center; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#pay-list-body .crm-row-name,
#cash-list-body .crm-row-name,
#inv-list-body .crm-row-name { font-weight: 600; color: #e0e0e0; }

#pay-list-body .crm-row-amount,
#cash-list-body .crm-row-amt-out,
#cash-list-body .crm-row-amt-in,
#inv-list-body .crm-row-amount,
#payable-list-body .crm-row-amount { font-weight: 600; font-size: 13px; }

/* ── Cash entry columns ── */
.crm-col-amt-out { flex: 0.7; text-align: right; }
.crm-col-amt-in  { flex: 0.7; text-align: right; }
.crm-row-amt-out { flex: 0.7; text-align: right; font-size: 13px; }
.crm-row-amt-in  { flex: 0.7; text-align: right; font-size: 13px; }

/* ── Payable cards ── */
.payable-card { background: #222; border: 1px solid #3a3a3a; border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.payable-header { display: flex; align-items: center; padding: 10px 14px; cursor: pointer; gap: 8px; }
.payable-header:hover { background: #2a2a2a; }
.payable-name { flex: 1; font-weight: 700; color: #e0e0e0; font-size: 14px; }
.payable-amount { font-weight: 700; color: #fbbf24; font-size: 15px; }
.payable-toggle { color: #6b7280; font-size: 12px; transition: transform 0.2s; }
.payable-card.open .payable-toggle { transform: rotate(180deg); }
.payable-bank { padding: 0 14px 8px; font-size: 12px; color: #9ca3af; }
.payable-items { display: none; padding: 0 14px 10px; }
.payable-card.open .payable-items { display: block; }
.payable-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid #2e2e2e; font-size: 12px; }
.payable-check { flex-shrink: 0; }
.payable-check input { accent-color: #3b82f6; width: 16px; height: 16px; }
.payable-item-date { width: 70px; color: #6b7280; }
.payable-item-summary { flex: 1; color: #d1d5db; }
.payable-item-cat { width: 60px; color: #9ca3af; }
.payable-item-amt { width: 80px; text-align: right; font-weight: 600; color: #e0e0e0; }
.payable-actions { padding: 8px 0 4px; text-align: right; }

/* ── Invoice modal: section titles ── */
.inv-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #9ca3af;
  padding: 18px 0 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid #3a3a3a;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Invoice modal: label with right-aligned button ── */
.inv-label-row {
  display: flex;
  align-items: center;
  width: 100%;
}
.inv-label-row .inv-icon-btn { margin-left: auto; }

/* ── Invoice modal: icon button (calculator, settings) ── */
.inv-icon-btn {
  background: none;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}
.inv-icon-btn:hover { background: #3a3a3a; }

/* ── Invoice modal: radio group ── */
.inv-radio-group {
  display: flex;
  gap: 20px;
  padding: 4px 0;
}
.inv-radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #d1d5db;
  cursor: pointer;
}
.inv-radio-label input[type="radio"] {
  accent-color: #3b82f6;
  width: 16px;
  height: 16px;
  margin: 0;
}

/* ── Invoice modal: popup (calculator / commission settings) ── */
.inv-popup {
  position: fixed;
  z-index: 1100;
  background: #2d2d2d;
  border: 1px solid #555;
  border-radius: 10px;
  width: 340px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.inv-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #3a3a3a;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}
.inv-popup-body { padding: 14px 16px; }

/* ── Calculator results ── */
.inv-calc-results {
  margin-top: 14px;
  background: #1e1e1e;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 10px 14px;
}
.inv-calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
}
.inv-calc-label { color: #9ca3af; }
.inv-calc-value { color: #e0e0e0; font-weight: 700; font-size: 14px; }
.inv-calc-copyable { user-select: all; cursor: text; }
.inv-calc-divider { border-top: 1px dashed #3a3a3a; margin: 6px 0; }

/* ── Staff badge colors ── */
.crm-staff-badge-在職 { background: #14532d; color: #86efac; }
.crm-staff-badge-兼職 { background: #3b2f1f; color: #fbbf24; }
.crm-staff-badge-專案 { background: #1e3a5f; color: #93c5fd; }
.crm-staff-badge-單位 { background: #3b1f3b; color: #d8b4fe; }

/* ── Staff list columns ── */
.crm-col-role  { flex: 1; }
.crm-col-rate  { flex: 0.7; text-align: right; }
.crm-col-phone { flex: 1; }
.crm-row-role  { flex: 1; color: #9ca3af; font-size: 12px; }
.crm-row-rate  { flex: 0.7; text-align: right; color: #e0e0e0; font-size: 13px; font-weight: 600; }
.crm-row-phone { flex: 1; color: #6b7280; font-size: 12px; }

/* ── Expense section ── */
.expense-section { margin: 8px 0; padding: 10px; background: #1a1a1a; border-radius: 8px; border: 1px solid #2e2e2e; }
.expense-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 12px; color: #9ca3af; }
.expense-row { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid #2e2e2e; font-size: 12px; }
.expense-row:last-child { border-bottom: none; }
.expense-row-header { color: #6b7280; font-weight: 600; }
.expense-cat { flex: 1; color: #d1d5db; }
.expense-num { width: 80px; text-align: right; color: #e0e0e0; }
.expense-receipt { width: 30px; text-align: center; }
.expense-actions { width: 80px; display: flex; gap: 2px; justify-content: flex-end; }

/* ── Cost Lines Table (成本估算) ── */
.cost-table { font-size: 12px; margin: 4px 0; }
.cost-row {
    display: flex; align-items: center; gap: 4px;
    padding: 4px 0; border-bottom: 1px solid #2e2e2e;
}
.cost-row:last-child { border-bottom: none; }
.cost-row-header { color: #6b7280; font-weight: 600; font-size: 11px; }
.cost-phase-header {
    padding: 6px 0 2px; color: #9ca3af; font-weight: 700;
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
    border-top: 1px solid #3a3a3a; margin-top: 4px;
}
.cost-phase-header:first-child { border-top: none; margin-top: 0; }
.cost-row-subtotal { background: #1a1a1a; border-radius: 4px; padding: 4px 6px; }
.cost-row-total {
    font-weight: 700; border-top: 2px solid #3a3a3a;
    padding-top: 6px; color: #e0e0e0;
}
.cost-col-item  { flex: 1; min-width: 60px; color: #d1d5db; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cost-col-price { flex: 1; min-width: 40px; text-align: right; color: #e0e0e0; }
.cost-col-qty   { flex: 0.5; min-width: 24px; text-align: center; color: #e0e0e0; overflow: hidden; }
.cost-col-qty input { width: 100%; max-width: 100%; box-sizing: border-box; -moz-appearance: textfield; }
.cost-col-qty input::-webkit-inner-spin-button,
.cost-col-qty input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cost-col-unit  { flex: 0.5; min-width: 30px; }
.cost-unit-sel  { width: 100%; font-size: 10px; padding: 1px 2px; }
.cost-col-amt   { flex: 1; min-width: 40px; text-align: right; color: #9ca3af; overflow: hidden; }
.cost-col-amt input, .cost-col-price input { width: 100%; max-width: 100%; box-sizing: border-box; -moz-appearance: textfield; }
.cost-col-amt input::-webkit-inner-spin-button,
.cost-col-amt input::-webkit-outer-spin-button,
.cost-col-price input::-webkit-inner-spin-button,
.cost-col-price input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cost-col-staff { width: 110px; flex-shrink: 0; text-align: center; padding-left: 8px; }
.cost-col-diff  { flex: 1; min-width: 50px; text-align: right; }
.cost-col-actions { width: 24px; flex-shrink: 0; text-align: center; }
.cost-editable  { cursor: pointer; }
.cost-editable:hover { color: #93c5fd; }
.cost-editable:hover .crm-muted { color: #93c5fd; }

.cost-toolbar-btn {
    padding: 0 6px;
    font-size: 11px;
    line-height: 18px;
}

/* 行政雜支列：獨立欄位布局（不走成本估算的 14 欄 grid）
   細項保留最大寬度，避免被擠壓成「0...」 */
.cost-row-expense {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0; border-bottom: 1px solid #2e2e2e;
}
.cost-row-expense .exp-col-date {
    flex: 0 0 80px;
    color: #6b7280; font-size: 10px;
    font-variant-numeric: tabular-nums;
}
.cost-row-expense .exp-col-cat {
    flex: 0 0 56px;
    color: #d1d5db;
}
.cost-row-expense .exp-col-sub {
    flex: 1 1 auto; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: #d1d5db;
}
.cost-row-expense .exp-col-amt {
    flex: 0 0 100px;
    text-align: right; color: #e0e0e0;
    font-variant-numeric: tabular-nums;
}
.cost-row-expense .exp-col-payee {
    flex: 0 0 90px;
    font-size: 11px; color: #9ca3af;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cost-row-expense .exp-col-receipt {
    flex: 0 0 40px;
    text-align: center; color: #9ca3af;
}
.cost-row-expense .exp-col-action {
    flex: 0 0 32px;
    text-align: center;
}
.cost-divider { margin-right: 0; border-right: 1px solid #3a3a3a; padding-right: 8px; }
.cost-col-copy { width: 20px; flex-shrink: 0; text-align: center; color: #555; cursor: pointer; font-size: 12px; }
.cost-col-copy:hover { color: #3b82f6; }
.cost-row-header .cost-col-copy, .cost-row-subtotal .cost-col-copy, .cost-row-total .cost-col-copy { cursor: default; color: transparent; }
.cost-staff-sel { width: 100%; font-size: 11px; padding: 2px 4px; }
/* ── Project Info — 3-layer card layout ── */
.pi-wrap { display: flex; flex-direction: column; gap: 12px; }
.pi-empty { color: #4b5563; font-style: italic; }

/* Cell-by-cell click-to-edit hover affordance */
.pi-edit-cell { cursor: pointer; border-bottom: 1px dashed transparent; transition: border-color 0.15s; }
.pi-edit-cell:hover { border-bottom-color: #4b5563; }
.pi-pm-popover label:hover { background: #2a2a2a; }

/* Layer 1: Summary bar */
.pi-summary {
    display: flex; gap: 1px; background: #2e2e2e; border-radius: 8px; overflow: hidden;
}
.pi-summary-cell {
    flex: 1; background: #1e1e1e; padding: 10px 12px; text-align: center;
}
.pi-summary-cell:first-child { border-radius: 8px 0 0 8px; }
.pi-summary-cell:last-child  { border-radius: 0 8px 8px 0; }
.pi-summary-val {
    font-size: 13px; font-weight: 600; color: #e0e0e0; margin-bottom: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: flex; align-items: center; justify-content: center; gap: 4px;
}
.pi-summary-label { font-size: 10px; color: #6b7280; }

/* Layer 2: People row */
.pi-people {
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
    padding: 6px 12px; background: #1e1e1e; border: 1px solid #2e2e2e; border-radius: 8px;
}
.pi-person {
    display: flex; align-items: center; gap: 5px; font-size: 12px; color: #d1d5db;
}
.pi-person-role {
    font-size: 10px; font-weight: 700; color: #6b7280; min-width: 20px;
}

/* Layer 3: Budget cards (async, primary visual) */
.pi-finance { display: flex; gap: 8px; }
.pi-fin-card {
    flex: 1; background: #1e1e1e; border: 1px solid #2e2e2e; border-radius: 8px;
    padding: 10px 12px; text-align: center;
}
.pi-fin-label { font-size: 11px; color: #6b7280; margin-bottom: 4px; }
.pi-fin-value { font-size: 18px; font-weight: 700; }
.pi-fin-sub   { font-size: 10px; color: #555; margin-top: 2px; }

/* Layer 4: Contract inline */
.pi-contract-line {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 12px; color: #9ca3af; padding: 8px 12px;
    background: #1e1e1e; border: 1px solid #2e2e2e; border-radius: 8px;
}
.pi-contract-line b { font-weight: 600; }
.pi-dot { width: 3px; height: 3px; border-radius: 50%; background: #4b5563; flex-shrink: 0; }

/* Budget meta (progress label + ratios) */
.pi-budget-meta {
    font-size: 11px; color: #6b7280; text-align: right; margin-top: -4px;
}

/* Activate project option */
.pi-activate-option {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: #1e1e1e; border: 1px solid #3a3a3a; border-radius: 6px;
    padding: 10px 14px; cursor: pointer; color: #d1d5db; font-size: 13px;
    transition: border-color 0.15s;
}
.pi-activate-option:hover { border-color: #3b82f6; background: #252525; }

/* Section title with divider */
.pi-section-title {
    font-size: 11px; font-weight: 700; color: #6b7280; text-transform: uppercase;
    letter-spacing: 0.5px; padding-bottom: 6px; margin-bottom: 4px;
    border-bottom: 1px solid #3a3a3a;
}

/* Layer 5: Details card */
.pi-details-card {
    background: #1e1e1e; border: 1px solid #2e2e2e; border-radius: 8px; padding: 14px 16px;
    display: flex; flex-direction: column; gap: 10px;
}
.pi-det-text { font-size: 13px; color: #d1d5db; line-height: 1.5; }
.pi-det-paths { display: flex; flex-direction: column; gap: 4px; }
.pi-det-path {
    font-size: 12px; color: #9ca3af; display: flex; align-items: center; gap: 4px;
    word-break: break-all;
}
.pi-det-note {
    font-size: 12px; color: #6b7280; font-style: italic; line-height: 1.4;
}

/* ── Cost Dashboard (財務卡片 + 進度條) ── */
.cost-dashboard {
    display: flex; gap: 8px; margin-bottom: 10px;
}
.cost-card {
    flex: 1; background: #1e1e1e; border: 1px solid #2e2e2e; border-radius: 8px;
    padding: 10px 12px; text-align: center;
}
.cost-card-label { font-size: 11px; color: #6b7280; margin-bottom: 4px; }
.cost-card-value { font-size: 18px; font-weight: 700; }
.cost-card-sub { font-size: 10px; color: #555; margin-top: 2px; }
.cost-progress-wrap {
    height: 6px; background: #2e2e2e; border-radius: 3px; overflow: hidden; margin-bottom: 4px;
}
.cost-progress-bar { height: 100%; border-radius: 3px; transition: width 0.3s; }
.cost-progress-label { font-size: 11px; color: #6b7280; text-align: right; margin-bottom: 8px; }
.cost-dashboard-detail {
    display: flex; gap: 16px; font-size: 11px; color: #9ca3af;
    padding: 6px 0; border-top: 1px solid #2e2e2e; margin-bottom: 4px;
}

.cost-tpl-item {
    padding: 6px 12px; cursor: pointer; font-size: 12px;
    border-bottom: 1px solid #333; display: flex; justify-content: space-between;
}
.cost-tpl-item:last-child { border-bottom: none; }
.cost-tpl-item:hover { background: #333; }

/* ── Project Quote Tab ── */
.pq-row {
    display: flex; align-items: center; gap: 12px; padding: 8px 12px;
    border-bottom: 1px solid #2e2e2e; cursor: pointer; font-size: 13px;
    transition: background 0.1s;
}
.pq-row:hover { background: #2a2a2a; }
.pq-row.selected { background: #1e3a5f; }
.pq-version { font-weight: 600; color: #e0e0e0; min-width: 30px; }
.pq-price { margin-left: auto; font-weight: 600; color: #60a5fa; }
.pq-date { color: #6b7280; font-size: 12px; min-width: 80px; text-align: right; }
.pq-detail-card {
    background: #1e1e1e; border: 1px solid #2e2e2e; border-radius: 8px;
    padding: 16px; margin-top: 12px;
}
.pq-detail-header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 10px; border-bottom: 1px solid #2e2e2e; margin-bottom: 12px;
}
.pq-info-row {
    display: flex; gap: 16px; font-size: 12px; color: #9ca3af;
    padding-bottom: 10px; border-bottom: 1px solid #2e2e2e; margin-bottom: 12px;
}
.pq-group-header {
    font-size: 11px; font-weight: 700; color: #6b7280; padding: 6px 0 4px;
    border-bottom: 1px solid #2e2e2e;
}
.pq-item-row {
    display: flex; align-items: center; gap: 8px; padding: 4px 0;
    font-size: 12px; color: #d1d5db; border-bottom: 1px solid #1a1a1a;
}
.pq-item-desc { flex: 1; }
.pq-item-qty { width: 60px; color: #9ca3af; text-align: center; }
.pq-item-price { width: 80px; text-align: right; color: #9ca3af; }
.pq-item-amount { width: 80px; text-align: right; font-weight: 600; }
.pq-totals { margin-top: 12px; }
.pq-total-row {
    display: flex; justify-content: space-between; padding: 3px 0;
    font-size: 12px; color: #9ca3af;
}
.pq-total-main { font-weight: 700; color: #e0e0e0; font-size: 13px; padding: 6px 0; }
.pq-stages { font-size: 12px; color: #d1d5db; margin-top: 10px; padding-top: 8px; border-top: 1px solid #2e2e2e; }
.pq-terms { font-size: 12px; color: #6b7280; font-style: italic; margin-top: 6px; }

/* ── Staff Resume Tab ── */
.staff-resume-wrap {
    padding: 16px;
}
.staff-resume-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.staff-photo-circle {
    width: 80px; height: 80px; border-radius: 50%;
    background: #2a2a2a; border: 2px solid #3a3a3a;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; cursor: pointer; flex-shrink: 0;
    transition: border-color 0.15s;
}
.staff-photo-circle:hover { border-color: #3b82f6; }
.staff-photo-circle img { width: 100%; height: 100%; object-fit: cover; }
.staff-photo-placeholder { font-size: 28px; opacity: 0.4; }
.staff-resume-name-block { display: flex; flex-direction: column; gap: 2px; }
.staff-resume-name { font-size: 18px; font-weight: 700; color: #e0e0e0; }
.staff-resume-role { font-size: 13px; color: #9ca3af; }

.staff-section-title {
    font-size: 12px; font-weight: 700; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.5px;
    padding: 12px 0 6px; margin-top: 8px;
    border-bottom: 1px solid #2a2a2a;
}
.staff-resume-textarea {
    width: 100%; background: #1e1e1e; border: 1px solid #3a3a3a;
    border-radius: 6px; color: #d1d5db; padding: 8px 10px;
    font-size: 13px; resize: vertical; outline: none; margin-top: 6px;
    font-family: inherit;
}
.staff-resume-textarea:focus { border-color: #3b82f6; }
.staff-resume-save-bio { margin-top: 6px; }

/* Skills tags */
.staff-skills-wrap {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 8px 0; align-items: center;
}
.staff-skill-tag {
    display: inline-flex; align-items: center; gap: 4px;
    background: #1e3a5f; color: #93c5fd; font-size: 12px;
    padding: 3px 10px; border-radius: 12px; font-weight: 500;
}
.staff-skill-remove {
    background: none; border: none; color: #93c5fd; cursor: pointer;
    font-size: 14px; padding: 0 0 0 2px; line-height: 1; opacity: 0.6;
}
.staff-skill-remove:hover { opacity: 1; }
.staff-skill-add-wrap { flex: 0 0 auto; }
.staff-skill-input {
    background: #1e1e1e; border: 1px solid #3a3a3a; border-radius: 12px;
    color: #d1d5db; padding: 3px 10px; font-size: 12px; outline: none;
    width: 120px;
}
.staff-skill-input:focus { border-color: #3b82f6; }

/* Portfolio cards */
.staff-portfolio-list { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.staff-portfolio-card {
    display: flex; align-items: center; gap: 10px;
    background: #252525; border: 1px solid #2a2a2a; border-radius: 6px;
    padding: 8px 10px;
}
.staff-portfolio-thumb {
    width: 60px; height: 40px; border-radius: 4px; object-fit: cover;
    flex-shrink: 0; background: #1e1e1e;
}
.staff-portfolio-thumb-empty { border: 1px dashed #3a3a3a; }
.staff-portfolio-info { flex: 1; min-width: 0; }
.staff-portfolio-title { font-size: 13px; color: #e0e0e0; font-weight: 600; }
.staff-portfolio-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Resume list rows (experience, education, awards) */
.staff-resume-list-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0; border-bottom: 1px solid #2a2a2a; font-size: 13px;
}
.staff-resume-list-main { flex: 1; color: #e0e0e0; font-weight: 500; }

/* Company projects in resume */
.staff-resume-projects { padding: 8px 0; }
.staff-resume-project-row {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 0; border-bottom: 1px solid #1a1a1a; font-size: 13px;
    color: #d1d5db;
}
.staff-resume-project-name { font-weight: 500; }

/* Footer actions */
.staff-resume-actions {
    display: flex; gap: 8px; padding: 16px 0 8px;
    margin-top: 12px; border-top: 1px solid #2a2a2a;
}

/* ══ Showcase / Delivery Tab ══ */

.showcase-wrap { padding: 16px; display: flex; flex-direction: column; gap: 20px; }

.showcase-section { background: #1e1e1e; border: 1px solid #2a2a2a; border-radius: 8px; padding: 14px 16px; }
.showcase-section-title {
    font-size: 13px; font-weight: 700; color: #9ca3af; text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 10px; padding-bottom: 6px;
    border-bottom: 1px solid #2a2a2a;
}
.showcase-section-body { }

/* Cover upload zone */
.showcase-cover-zone {
    position: relative; width: 100%; aspect-ratio: 16/9; max-height: 280px;
    background: #141414; border: 2px dashed #3a3a3a; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; overflow: hidden; transition: border-color 0.15s;
}
.showcase-cover-zone:hover, .showcase-cover-zone.drag-over { border-color: #3b82f6; }
.showcase-cover-preview { width: 100%; height: 100%; object-fit: cover; }
.showcase-cover-placeholder { text-align: center; }
.showcase-cover-placeholder.hidden { display: none; }

/* Info grid */
.showcase-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.showcase-info-grid .crm-field-full { grid-column: 1 / -1; }

/* Gallery grid */
.showcase-gallery-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
.showcase-gallery-item {
    position: relative; aspect-ratio: 16/10; border-radius: 6px;
    overflow: hidden; background: #141414; border: 1px solid #2a2a2a;
}
.showcase-gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.showcase-gallery-del, .showcase-process-del {
    position: absolute; top: 4px; right: 4px;
    background: rgba(0,0,0,0.7); color: #f87171; border: none;
    border-radius: 50%; width: 22px; height: 22px;
    cursor: pointer; font-size: 14px; line-height: 22px; text-align: center;
    opacity: 0; transition: opacity 0.15s;
}
.showcase-gallery-item:hover .showcase-gallery-del,
.showcase-gallery-item:hover .showcase-process-del,
.showcase-media-item:hover .showcase-process-del,
.showcase-timeline-item:hover .showcase-process-del { opacity: 1; }
.showcase-gallery-add {
    aspect-ratio: 16/10; border: 2px dashed #3a3a3a; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: border-color 0.15s;
}
.showcase-gallery-add:hover { border-color: #3b82f6; }

/* Process mode buttons */
.showcase-process-modes { display: flex; gap: 4px; margin-bottom: 10px; }
.showcase-process-mode-btn {
    background: #252525; border: 1px solid #3a3a3a; border-radius: 6px;
    color: #9ca3af; padding: 6px 14px; font-size: 12px; cursor: pointer;
    transition: all 0.15s;
}
.showcase-process-mode-btn:hover { color: #e0e0e0; border-color: #555; }
.showcase-process-mode-btn.active { background: #2563eb22; color: #60a5fa; border-color: #2563eb66; }

/* Media list (media mode) */
.showcase-media-list { display: flex; flex-direction: column; gap: 8px; }
.showcase-media-item {
    position: relative; display: flex; align-items: center; gap: 10px;
    background: #252525; border: 1px solid #2a2a2a; border-radius: 6px; padding: 8px;
}
.showcase-media-thumb { width: 80px; height: 54px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.showcase-media-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.showcase-media-caption, .showcase-media-url { font-size: 12px; }

/* Timeline (timeline mode) */
.showcase-timeline-phase { margin-bottom: 14px; }
.showcase-timeline-phase-title {
    font-size: 13px; font-weight: 600; color: #d48a04; margin-bottom: 8px;
    padding-left: 10px; border-left: 3px solid #d48a04;
}
.showcase-timeline-phase-body { display: flex; flex-direction: column; gap: 6px; }
.showcase-timeline-item {
    position: relative; display: flex; align-items: center; gap: 8px;
    background: #252525; border: 1px solid #2a2a2a; border-radius: 6px; padding: 6px 8px;
}

/* Credits */
.showcase-credits-list { display: flex; flex-direction: column; gap: 4px; }
.showcase-credit-row {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    background: #252525; border-radius: 6px; font-size: 13px;
}
.showcase-credit-role { color: #9ca3af; min-width: 60px; font-weight: 500; }
.showcase-credit-name { color: #e0e0e0; flex: 1; }
.showcase-credit-del {
    background: none; border: none; color: #6b7280; cursor: pointer;
    font-size: 16px; padding: 0 4px; opacity: 0.5;
}
.showcase-credit-del:hover { opacity: 1; color: #f87171; }

/* Publish bar */
.showcase-publish-bar {
    display: flex; align-items: center; justify-content: space-between;
}
.showcase-publish-status { font-size: 13px; font-weight: 600; }
.showcase-status-published { color: #22c55e; }
.showcase-status-draft { color: #6b7280; }

/* ───────── Cost Groups (成本子表切換器) ───────── */
.cg-switcher-title {
    font-size: 12px; font-weight: 700; color: #6b7280;
    margin: 16px 0 8px; padding-top: 10px;
    border-top: 1px solid #2e2e2e;
}
.cg-switcher {
    display: flex; gap: 8px;
    overflow-x: auto;
    padding: 4px 2px 10px;
    scrollbar-width: thin;
}
.cg-switcher::-webkit-scrollbar { height: 6px; }
.cg-switcher::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
.cg-chip {
    position: relative;
    flex: 0 0 auto;
    width: 160px;
    padding: 10px 10px 8px;
    border-radius: 8px;
    background: #1f2937;
    border: 1px solid #374151;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex; flex-direction: column; gap: 3px;
}
.cg-chip:hover { border-color: #4b5563; background: #263244; }
.cg-chip.active { border: 2px solid #3b82f6; background: #1e3a5f; padding: 9px 9px 7px; }
.cg-chip-menu {
    position: absolute; top: 4px; right: 4px;
    background: transparent; border: none; color: #6b7280;
    cursor: pointer; font-size: 14px; line-height: 1;
    padding: 2px 6px; border-radius: 3px;
}
.cg-chip-menu:hover { background: rgba(255,255,255,0.08); color: #e5e7eb; }
.cg-chip-name {
    font-size: 13px; font-weight: 700; color: #e5e7eb;
    padding-right: 18px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cg-chip-date { font-size: 11px; color: #9ca3af; margin-bottom: 3px; }
.cg-chip-budget, .cg-chip-actual { font-size: 11px; color: #d1d5db; }
.cg-chip .cg-muted { color: #6b7280; }
.cg-chip-bar {
    height: 3px; background: #374151; border-radius: 2px;
    margin-top: 4px; overflow: hidden;
}
.cg-chip-bar-fill { height: 100%; border-radius: 2px; transition: width 0.2s; }
.cg-chip-status { font-size: 10px; margin-top: 4px; }
.cg-chip-add {
    width: 120px;
    justify-content: center; align-items: center;
    border: 1px dashed #4b5563; background: transparent;
    color: #9ca3af;
}
.cg-chip-add:hover { border-color: #60a5fa; color: #60a5fa; background: rgba(59,130,246,0.08); }
.cg-chip-add-icon { font-size: 20px; line-height: 1; }

/* Chip state variants — 用底色表達預算狀態（取代 badge） */
.cg-chip-warn { background: #3f2d0b; border-color: #78350f; }
.cg-chip-warn:hover { background: #4a350e; }
.cg-chip-warn.active { background: #4a350e; border-color: #f59e0b; }

.cg-chip-danger { background: #3b1212; border-color: #7f1d1d; }
.cg-chip-danger:hover { background: #4a1717; }
.cg-chip-danger.active { background: #4a1717; border-color: #ef4444; }

/* Chip rows — 剩餘 / 進度條 + % / 未設預算提示 / 編輯按鈕 */
.cg-chip-remain { font-size: 11px; color: #d1d5db; }
.cg-chip-remain-over { color: #fca5a5; font-weight: 700; }
.cg-chip .cg-muted.cg-chip-remain,
.cg-chip-remain.cg-muted { color: #6b7280; }

.cg-chip-bar-row {
    display: flex; align-items: center; gap: 6px;
    margin-top: 4px;
}
.cg-chip-bar-row .cg-chip-bar { flex: 1; }
.cg-chip-pct {
    font-size: 10px; color: #9ca3af;
    min-width: 34px; text-align: right; font-variant-numeric: tabular-nums;
}
.cg-chip-danger .cg-chip-pct { color: #fca5a5; font-weight: 700; }

.cg-chip-hint {
    font-size: 11px; color: #60a5fa;
    padding: 4px 0 2px;
}

.cg-chip-edit {
    margin-top: 8px;
    padding: 4px 8px;
    background: #374151; color: #e5e7eb;
    border: 1px solid #4b5563; border-radius: 4px;
    font-size: 11px; font-weight: 600;
    cursor: pointer; width: 100%;
    transition: background 0.15s;
}
.cg-chip-edit:hover { background: #4b5563; }
.cg-chip-edit-primary {
    background: #3b82f6; border-color: #2563eb; color: #fff;
}
.cg-chip-edit-primary:hover { background: #2563eb; }
.cg-chip-edit-success {
    background: #14532d !important; border-color: #22c55e !important; color: #86efac !important;
}

/* Toast (分享連結複製回饋) */
.cg-toast {
    position: fixed; top: 20px; left: 50%;
    background: #1f2937; color: #e5e7eb;
    padding: 10px 18px; border-radius: 8px;
    border: 1px solid #3b82f6;
    font-size: 13px; font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    transform: translate(-50%, -20px);
    opacity: 0;
    transition: transform 0.25s, opacity 0.25s;
    z-index: 10000;
    pointer-events: none;
    white-space: nowrap;
}
.cg-toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Menu popover */
.cg-menu-pop {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 4px;
    min-width: 120px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    display: flex; flex-direction: column;
}
.cg-menu-item {
    background: transparent; border: none;
    color: #e5e7eb; text-align: left;
    padding: 6px 10px; border-radius: 4px;
    cursor: pointer; font-size: 12px;
}
.cg-menu-item:hover { background: #374151; }
.cg-menu-danger { color: #fca5a5; }
.cg-menu-danger:hover { background: #7f1d1d; color: #fecaca; }

/* Allocation hints */
.cg-alert {
    padding: 8px 12px; border-radius: 6px;
    font-size: 12px; margin: 8px 0 4px;
}
.cg-alert-danger { background: #7f1d1d; color: #fca5a5; }
.cg-alert-ok { background: #064e3b; color: #86efac; font-size: 11px; padding: 4px 10px; }
.cg-alert-hint { background: #1e3a5f; color: #60a5fa; font-size: 11px; padding: 4px 10px; }

/* Modal allocation hint */
.cg-alloc-hint { margin: 12px 0 0; }
.cg-alloc-ok, .cg-alloc-danger {
    padding: 10px 12px; border-radius: 6px; font-size: 12px; line-height: 1.6;
}
.cg-alloc-ok { background: #1e3a5f; color: #93c5fd; }
.cg-alloc-danger { background: #7f1d1d; color: #fca5a5; }

/* Staff detail panel — 專案紀錄 tab 統計 chip + project row + quick_add hint */
.crm-stat-chips { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.crm-stat-chip {
    background: #1f2937; border-radius: 6px; padding: 8px 14px;
}
.crm-stat-chip-label { color: #9ca3af; font-size: 11px; }
.crm-stat-chip-value { color: #e0e0e0; font-size: 18px; font-weight: 700; }
.crm-stat-chip.warn { background: #7c2d12; }
.crm-stat-chip.warn .crm-stat-chip-label { color: #fbbf24; }
.crm-stat-chip.warn .crm-stat-chip-value { color: #fef3c7; }
.crm-stat-chip.info { background: #1e3a8a; }
.crm-stat-chip.info .crm-stat-chip-label { color: #93c5fd; }
.crm-stat-chip.info .crm-stat-chip-value { color: #dbeafe; }

.crm-project-row { padding: 10px 0; border-bottom: 1px solid #2a2a2a; }
.crm-project-row-title { color: #e0e0e0; font-weight: 500; margin-bottom: 4px; }
.crm-project-row-meta { font-size: 12px; padding: 2px 0; }
.crm-project-row-meta.assigned { color: #9ca3af; }
.crm-project-row-meta.credit { color: #86efac; }
.crm-project-row-meta.warn { color: #fbbf24; }

.crm-info-box {
    margin-top: 14px; padding: 10px 12px;
    background: #1e3a5f; border-left: 3px solid #3b82f6; border-radius: 4px;
    color: #dbeafe; font-size: 12px; line-height: 1.5;
}
.crm-info-box-sub { color: #93c5fd; margin-top: 4px; font-size: 11px; }


