.cqp-workbench {
  display: flex;
  flex-direction: column;
  min-height: 650px;
  height: calc(100vh - 310px);
  color: #1f2937;
}

.cqp-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.cqp-form-panel,
.cqp-table-panel {
  border: 1px solid #dbe3ed;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 5%);
  min-height: 0;
}

.cqp-form-panel {
  overflow: hidden;
}

.cqp-scroll {
  height: 100%;
  overflow: auto;
  padding: 16px;
}

.cqp-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.cqp-workbench h3 {
  margin: 0;
  font-size: 16px;
  color: #172033;
}

.cqp-workbench label {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.cqp-workbench input,
.cqp-workbench select,
.cqp-workbench textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  padding: 8px 9px;
  font: inherit;
  color: #172033;
}

.cqp-workbench textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

.cqp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cqp-actions button,
.cqp-link-button {
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

.cqp-primary {
  background: #2563eb;
  color: #fff;
}

.cqp-success {
  background: #15803d;
  color: #fff;
}

.cqp-link-button {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
  padding: 5px 9px;
}

.cqp-actions button:disabled,
.cqp-link-button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.cqp-note {
  margin: 10px 0 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.55;
}

.cqp-tables {
  display: grid;
  grid-template-rows: 1.1fr .9fr;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

.cqp-table-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 14px;
  overflow: hidden;
}

.cqp-table-panel h3 {
  margin-bottom: 8px;
}

.cqp-table-scroll {
  overflow: auto;
  min-height: 0;
}

.cqp-table-scroll table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 13px;
}

.cqp-table-scroll th,
.cqp-table-scroll td {
  border-bottom: 1px solid #e5e7eb;
  padding: 9px 10px;
  text-align: left;
}

.cqp-table-scroll th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  color: #475569;
}

.cqp-table-scroll tbody tr[data-cqp-application-id] {
  cursor: pointer;
}

.cqp-table-scroll tbody tr[data-cqp-application-id]:hover,
.cqp-table-scroll tbody tr.selected {
  background: #dbeafe;
}

.cqp-empty {
  text-align: center !important;
  color: #64748b;
  padding: 24px !important;
}


/* T-0825-10 行顏色鏈：已提交待批=紅；老闆批准=藍；財務批核/草稿=原色（照月結 cmc-tone 款式：td 落色+first-child 左色條） */
.cqp-table-scroll tbody tr.cqp-tone-submitted td { background: #fef2f2; color: #dc2626; }
.cqp-table-scroll tbody tr.cqp-tone-submitted td:first-child { border-left: 3px solid #dc2626; }
.cqp-table-scroll tbody tr.cqp-tone-boss-approved td { background: #eff6ff; color: #2563eb; }
.cqp-table-scroll tbody tr.cqp-tone-boss-approved td:first-child { border-left: 3px solid #2563eb; }
.cqp-table-scroll tbody tr.cqp-tone-submitted:hover td,
.cqp-table-scroll tbody tr.cqp-tone-submitted.selected td,
.cqp-table-scroll tbody tr.cqp-tone-boss-approved:hover td,
.cqp-table-scroll tbody tr.cqp-tone-boss-approved.selected td { background: #e0e9f7; }
.cqp-apr-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.cqp-apr-pending {
  background: #ffedd5;
  color: #b45309;
}

.cqp-apr-approved {
  background: #dcfce7;
  color: #15803d;
}

.cqp-apr-rejected {
  background: #fee2e2;
  color: #b91c1c;
}

.cqp-apr-muted {
  background: #f1f5f9;
  color: #64748b;
}

.cqp-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;
}

.cqp-status {
  flex: 0 0 auto;
  margin-top: 8px;
  border-radius: 6px;
  background: #f8fafc;
  padding: 8px 11px;
  color: #475569;
  font-size: 12px;
}

@media (max-width: 1050px) {
  .cqp-workbench {
    height: auto;
  }

  .cqp-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .cqp-form-panel {
    max-height: none;
  }

  .cqp-tables {
    grid-template-rows: minmax(320px, 1.1fr) minmax(280px, .9fr);
  }
}
