.cmc-workbench {
  display: flex;
  flex-direction: column;
  min-height: 640px;
  height: calc(100vh - 310px);
  color: #1f2937;
}

.cmc-page-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.cmc-page-tabs button {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  padding: 7px 14px;
  font-weight: 600;
  cursor: pointer;
}

.cmc-page-tabs button.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.cmc-page-tabs button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.cmc-page {
  flex: 1;
  min-height: 0;
}

/* Home page: 380px form + flexible right area (matches desktop XAML ColumnDefinition Width="380") */
.cmc-home {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  height: 100%;
}

.cmc-form-panel,
.cmc-table-panel {
  border: 1px solid #dbe3ed;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 5%);
  min-height: 0;
}

.cmc-form-panel {
  overflow: hidden;
}

.cmc-scroll {
  height: 100%;
  overflow: auto;
  padding: 16px;
}

.cmc-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.cmc-workbench h3 {
  margin: 0;
  font-size: 16px;
  color: #172033;
}

.cmc-workbench label {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.cmc-workbench input,
.cmc-workbench select,
.cmc-workbench textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  padding: 8px 9px;
  font: inherit;
  color: #172033;
}

.cmc-workbench textarea {
  min-height: 70px;
  resize: vertical;
  line-height: 1.5;
}

.cmc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cmc-actions button,
.cmc-entry-actions button,
.cmc-link-button {
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

.cmc-primary {
  background: #2563eb;
  color: #fff;
}

.cmc-success {
  background: #15803d;
  color: #fff;
}

.cmc-danger {
  background: #fff1f2;
  color: #b91c1c;
  border-color: #fda4af;
}

.cmc-link-button {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
  padding: 5px 9px;
}

.cmc-actions button:disabled,
.cmc-entry-actions button:disabled,
.cmc-link-button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.cmc-muted {
  margin: 0 0 10px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.55;
}

.cmc-note {
  margin: 10px 0 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.55;
}

/* Right table panel */
.cmc-table-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 14px;
  overflow: hidden;
}

.cmc-table-head h3 {
  margin-bottom: 6px;
}

.cmc-table-scroll {
  overflow: auto;
  min-height: 0;
}

.cmc-table-scroll table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 13px;
}

.cmc-table-scroll th,
.cmc-table-scroll td {
  border-bottom: 1px solid #e5e7eb;
  padding: 9px 10px;
  text-align: left;
}

.cmc-table-scroll th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  color: #475569;
}

.cmc-table-scroll tbody tr[data-cmc-claim-id] {
  cursor: pointer;
}

.cmc-table-scroll tbody tr[data-cmc-claim-id]:hover,
.cmc-table-scroll tbody tr.selected,
.cmc-item-table tbody tr.selected {
  background: #dbeafe;
}

.cmc-table-scroll tbody tr[data-cmc-item-row] {
  cursor: pointer;
}

.cmc-empty {
  text-align: center !important;
  color: #64748b;
  padding: 24px !important;
}

.cmc-error {
  display: grid;
  gap: 3px;
  margin-bottom: 8px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fff1f2;
  padding: 9px 12px;
  color: #991b1b;
  font-size: 12px;
}

.cmc-status {
  flex: 0 0 auto;
  margin-top: 8px;
  border-radius: 6px;
  background: #f8fafc;
  padding: 8px 11px;
  color: #475569;
  font-size: 12px;
}

/* Detail page */
.cmc-detail {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.cmc-detail-head {
  display: grid;
  grid-template-columns: 1.15fr 1.55fr 1.05fr 0.85fr 1.15fr;
  gap: 12px;
  border: 1px solid #dbe3ed;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.cmc-detail-head .cmc-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.cmc-detail-head .cmc-value {
  display: block;
  font-size: 17px;
  font-weight: 600;
  color: #172033;
  word-break: break-word;
}

.cmc-detail-head .cmc-sub {
  display: block;
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
}

.cmc-entry {
  border: 1px solid #dbe3ed;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.cmc-entry-head h3 {
  margin-bottom: 4px;
}

.cmc-entry-grid {
  display: grid;
  grid-template-columns: 2.2fr 0.62fr 0.58fr 0.72fr 0.82fr;
  gap: 10px;
  align-items: start;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fbff;
  padding: 12px;
}

.cmc-col-wide {
  grid-column: 1 / -1;
}

.cmc-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.cmc-item-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.cmc-item-table th,
.cmc-item-table td {
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.cmc-item-table th {
  background: #f1f5f9;
  color: #475569;
}

.cmc-total {
  font-weight: 600;
  color: #172033;
  font-size: 13px;
}

.cmc-detail-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #dbe3ed;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.cmc-detail-footer button {
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #f8fafc;
  color: #334155;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}

.cmc-detail-footer button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.cmc-wait-blue { color: #1D4ED8; font-weight: 600; }

/* T-0825-20 上传单据（label 包 file input，浏览器原生掣样貌一致） */
.cmc-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.cmc-upload-label:hover { background: #dbeafe; }
.cmc-upload-label input[type="file"] { display: none; }
.cmc-upload-hint {
  font-weight: 400;
  font-size: 12px;
  color: #64748b;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmc-ai-badge {
  display: inline-block;
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #FECACA;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 700;
}

tr.cmc-ai-row {
  background: #FEF2F2;
}

.cmc-home-items {
  border-top: 1px dashed #dbe3ed;
  margin-top: 10px;
  padding-top: 10px;
}

@media (max-width: 1050px) {
  .cmc-workbench {
    height: auto;
  }

  .cmc-home {
    grid-template-columns: minmax(0, 1fr);
  }

  .cmc-detail-head {
    grid-template-columns: minmax(0, 1fr);
  }

  .cmc-entry-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===== T-0825-22/23/24/25 前端UI補齊 ===== */
/* T-0825-24 行狀態色：藍 #2563eb=等老板审批 紅 #dc2626=老板批咗未收款（照BQ款：td層落色+first-child左色條） */
.cmc-table-scroll tbody tr.cmc-tone-waiting td { background: #eff6ff; color: #2563eb; }
.cmc-table-scroll tbody tr.cmc-tone-waiting td:first-child { border-left: 3px solid #2563eb; }
.cmc-table-scroll tbody tr.cmc-tone-approved td { background: #fef2f2; color: #dc2626; }
.cmc-table-scroll tbody tr.cmc-tone-approved td:first-child { border-left: 3px solid #dc2626; }
.cmc-table-scroll tbody tr.cmc-tone-waiting:hover td,
.cmc-table-scroll tbody tr.cmc-tone-waiting.selected td,
.cmc-table-scroll tbody tr.cmc-tone-approved:hover td,
.cmc-table-scroll tbody tr.cmc-tone-approved.selected td { background: #e0e9f7; }

/* T-0825-23/25 詳情 footer 分組：確認收款/總台審批/刪除申請 */
.cmc-detail-footer { flex-direction: column; align-items: stretch; gap: 8px; }
.cmc-footer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cmc-footer-title { font-weight: 700; font-size: 12px; color: #475569; white-space: nowrap; }
.cmc-footer-field { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: #475569; white-space: nowrap; }
.cmc-footer-field input { border: 1px solid #cbd5e1; border-radius: 5px; padding: 6px 8px; font: inherit; font-size: 13px; width: 120px; background: #fff; }
.cmc-footer-field.cmc-footer-wide input { width: 260px; }
