* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Meiryo','Yu Gothic',sans-serif; background: #f0f2f5; color: #333; }

.header {
  background: #1a237e; color: #fff; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.header h1 { font-size: 18px; font-weight: bold; }
.header .sub { font-size: 12px; color: #90caf9; margin-top: 2px; }

.btn {
  padding: 8px 16px; border: none; border-radius: 6px; font-size: 13px;
  cursor: pointer; font-family: inherit; font-weight: bold;
}
.btn-primary { background: #3949ab; color: #fff; }
.btn-primary:hover { background: #283593; }
.btn-success { background: #2e7d32; color: #fff; }
.btn-success:hover { background: #1b5e20; }
.btn-warning { background: #f57c00; color: #fff; }
.btn-warning:hover { background: #ef6c00; }
.btn-danger { background: #c62828; color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-outline { background: #fff; color: #3949ab; border: 1px solid #3949ab; }

.tab-bar { display: flex; background: #283593; }
.tab-btn {
  padding: 12px 0; flex: 1; max-width: 200px; border: none; background: transparent;
  color: #9fa8da; font-size: 14px; font-weight: bold; cursor: pointer;
  font-family: inherit;
}
.tab-btn.active { background: #3949ab; color: #fff; border-bottom: 3px solid #90caf9; }

.page { display: none; }
.page.active { display: block; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }

.card {
  background: #fff; border-radius: 10px; padding: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08); margin-bottom: 18px;
}
.card h2 { font-size: 15px; color: #1a237e; border-bottom: 2px solid #e8eaf6;
            padding-bottom: 8px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border: 1px solid #e0e0e0; padding: 8px 10px; text-align: left; }
th { background: #e8eaf6; color: #1a237e; font-weight: bold; white-space: nowrap; }
tbody tr:hover { background: #f5f7ff; }
td.actions { white-space: nowrap; width: 1%; }
td.actions .btn { margin-right: 4px; }

.form-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-row label { display: block; font-size: 12px; color: #555; font-weight: bold; margin-bottom: 4px; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px;
  font-size: 13px; font-family: inherit;
}
.form-row textarea { resize: vertical; min-height: 50px; }

/* modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 10px; padding: 24px; width: 100%; max-width: 880px;
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { color: #1a237e; font-size: 17px; margin-bottom: 16px; border-bottom: 2px solid #e8eaf6; padding-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; border-top: 1px solid #eee; padding-top: 14px; }

.component-block {
  border: 1px solid #e0e0e0; border-radius: 8px; padding: 12px; margin-bottom: 12px; background: #fafbff;
}
.component-block .comp-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.comp-head .comp-name { font-weight: bold; font-size: 14px; color: #1a237e; }

.flow-list { list-style: none; }
.flow-list li {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid #e8eaf6;
  border-radius: 6px; margin-bottom: 6px; background: #fff; font-size: 13px;
}
.flow-list .step-no {
  background: #3949ab; color: #fff; border-radius: 50%; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0;
}
.flow-list .step-name { font-weight: bold; min-width: 110px; }
.flow-list .step-material { flex: 1; color: #666; }
.flow-list .step-material input {
  width: 100%; padding: 4px 6px; border: 1px solid #ddd; border-radius: 4px; font-size: 12px; font-family: inherit;
}
.add-flow-row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.add-flow-row select, .add-flow-row input { padding: 6px 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 12px; font-family: inherit; }
.add-flow-row select { flex: 0 0 160px; }
.add-flow-row input { flex: 1; }

.empty-msg { color: #999; font-size: 13px; padding: 10px 0; }

.add-component-row { display: flex; gap: 8px; margin-top: 6px; }
.add-component-row input { flex: 1; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 13px; font-family: inherit; }

.top-actions { display: flex; justify-content: flex-end; margin-bottom: 12px; gap: 8px; }

.save-status {
  font-size: 12px; color: #2e7d32; font-weight: bold; opacity: 0; transition: opacity .2s;
}
.save-status.show { opacity: 1; }
.save-status.error { color: #c62828; }

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: #eef0f8; }
.sort-arrow { font-size: 10px; color: #3949ab; margin-left: 2px; }

.comment-cell {
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #555; font-size: 12px;
}

.process-count-summary {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px;
}
.count-chip {
  background: #e8eaf6; color: #1a237e; border-radius: 14px; padding: 4px 12px;
  font-size: 12px; font-weight: bold; white-space: nowrap;
}
.count-chip.total { background: #1a237e; color: #fff; }
.count-chip.unassigned { background: #eeeeee; color: #666; }
.comp-count-badge {
  background: #3949ab; color: #fff; border-radius: 10px; padding: 1px 8px;
  font-size: 11px; font-weight: normal; margin-left: 6px;
}
